Re: Patch for Statement.getGeneratedKeys()

From: Kris Jurka <books(at)ejurka(dot)com>
To: Ken Johanson <pg-user(at)kensystem(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Patch for Statement.getGeneratedKeys()
Date: 2008-01-16 07:20:28
Message-ID: Pine.BSO.4.64.0801160212320.10937@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-jdbc

On Wed, 16 Jan 2008, Ken Johanson wrote:

>> I've lost track of the context in which this needs to be done, but in
>> some cases a cast to or from regclass offers a painless way to
>> disambiguate table names. Just a suggestion ...
>
> Tom, can you offer an example of this and how the overall goal might be
> achieved? Kris, please jump in where I'm missing anything:

Regclass is actually exactly what you need. This let's us skip all kinds
of parsing, deducing, ...

SELECT 'database.schema.table'::regclass::oid;
SELECT 'schema.table'::regclass::oid;
SELECT 'table'::regclass::oid;
SELECT '"database".schema."table"'::regclass::oid;

will all return the same thing, the oid for the qualified table, or if
unqualified, the first matching table on the search path. The oid will be
pg_class.oid which can then easily be used to lookup the columns in
pg_attribute as people have explained on -general.

> #Questions:
>
> -would the regclass-cast technique (I have no experience with it) work
> directly in the RETURNING or need to be in the [information_schema] query?
> Can you point me to examples?

Needs to be in a separate query.

> -would it be feasible to modify RETURNING in new server versions to accept
> indexes as args? That would obviate this whole discussion.
>

Not really, RETURNING is an arbitrary SELECT list, so you can say things
like RETURNING 1, 2+columnA, f(columnB). You could potentially add some
kind of keyword like RETURNING INDEXES 1,2,7, but I doubt the server
people have a great desire to support something this braindead for just
one client API to use.

Kris Jurka

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ken Johanson 2008-01-16 07:22:22 Re: Query to get column-names in table via PG tables?
Previous Message Ken Johanson 2008-01-16 07:09:29 Re: Patch for Statement.getGeneratedKeys()

Browse pgsql-jdbc by date

  From Date Subject
Next Message Tom Lane 2008-01-16 07:38:37 Re: Patch for Statement.getGeneratedKeys()
Previous Message Ken Johanson 2008-01-16 07:09:29 Re: Patch for Statement.getGeneratedKeys()