getTableName() in ResultSetMetaData

From: Ola Sundell <ola(at)miranda(dot)org>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: getTableName() in ResultSetMetaData
Date: 2001-03-02 18:18:15
Message-ID: Pine.LNX.4.21.0103021304340.21247-100000@miranda.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hello.

I've been hacking a bit, and I've come to a conclusion, which may or may
not be true; to implement quite a number of things in the
ResultSetMetaData class, we'll need to implement getTableName(int colnum),
and to implement getTable(), we need additional information from the
backend, like the relid from pg_class, where relid is SELECT relid FROM
pg_class WHERE relname = 'table_where_col_is_from', added to the Field
class. It would, too, be good to include attnum from pg_attribute, too.

This will also ease implementation of things like isAutoIncrement(int
colnum), if you define auto incrementation as having a DEFAULT value
which is read from a sequence that is incremented one step at a time. I
really need this feature (and I want it to behave like I described, as you
might have guessed :). An idea, to make the definition of a column which
"auto increments", is to alter table pg_attribute add attisserial boolean,
and then just set that, if the newly-created column is serial, and use
the pg_attribute column to check whether it is auto incrementing, or not.

Now, I know of two things that you probably will say:

a) Feature freeze - not in 7.1 (naturally). I can understand that, and I
can also, sorta, wait until 7.2 development starts...but I'd love to see
this asap, naturall
b) Postgresql doesn't really support auto incrementation. I know that,
too, but I want, due to ejb-specific reasons, be able to gather
information about whether the column is auto-incrementing, or not. I can,
of course, write a small hack in my own app, but this seems much
neater. :)

OK, did that make sense at all?

Ola

--
---
Ola Sundell
ola(at)miranda(dot)org - olas(at)wiw(dot)org - ola(dot)sundell(at)mimer(dot)se
http://miranda.org/~ola
PGP key information:
pub 1024/744E6D8D 2000/02/13 Ola Sundell <ola(at)miranda(dot)org>
Key fingerprint = 8F CA 7C 6F EC 0D C0 23 1E 08 BF 32 FC 37 24 E3

Browse pgsql-jdbc by date

  From Date Subject
Next Message Aaron Brashears 2001-03-04 20:43:43 Connection pooling
Previous Message Rini Dutta 2001-03-02 16:48:20 Multiple threads querying using the same connection