JDBC MetaData getImportedKeys query

From: Kris Jurka <jurka(at)ejurka(dot)com>
To: pgsql-patches(at)postgresql(dot)org, pgsql-jdbc(at)postgresql(dot)org
Subject: JDBC MetaData getImportedKeys query
Date: 2003-01-13 19:12:09
Message-ID: 3E230F89.74F551D9@ejurka.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc pgsql-patches


For the DatabaseMetaData methods getImportedKeys, getExportedKeys, and
getCrossReference a large query is used that triggered the genetic query
optimizer which occasionally produced bad plans which made it look like
the driver "hung" while it executed. I've add some explicit JOIN
statements so that it no longer enables the genetic optimizer and
generates reasonable and consistent plans.

I've attached two versions of the patch. One which has an additional
change to the value of the FK_NAME column. Currently the returned value
is the triggers arguments which look like

"<unnamed>\000t2\000t1\000UNSPECIFIED\000a\000a\000"

This was required for server versions < 7.3 when a user did not supply
constraint names. Every constraint was named "<unnamed>"
. 7.3 has enforced unique constraint names per table so unnamed foreign
keys will have different names "$1", "$2" and so on. I've used logic
along the lines of the following to preserve the unique names in the
original scheme, but allow people who go to the trouble of naming their
constraints to see them:

if (triggerargs.startsWith("<unnamed>")) {
fkname = [the whole ugly trigger args name originally used];
} else {
fkname = [the actual fk name];
}

Kris Jurka

Attachment Content-Type Size
explicitfkjoin.patch text/plain 6.9 KB
explicitfkjoin_with_fkname.patch text/plain 8.7 KB

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Carlos Correia 2003-01-13 19:18:05 Errors compiling Postgres (bison -maximum table size excceeded)
Previous Message Barry Lind 2003-01-13 18:05:51 Re: No class found for refcursor

Browse pgsql-patches by date

  From Date Subject
Next Message Joe Conway 2003-01-13 19:19:20 Re: targetlist functions part 1 (was [HACKERS] targetlist
Previous Message Neil Conway 2003-01-13 19:03:48 fix for PL/PgSQL segfault