DatabaseMetaData.getIndexInfo() added
Hi all!
Attached is a patch that implements DatabaseMetaData.getIndexInfo()
for the JDBC2 driver. It also fixes a compile error under jikes by
casting characters in case statements of a byte-compared switch to
bytes.
A few notes on getIndexInfo():
1.) getArray() is not implemented for the postgresql JDBC driver yet,
so getIndexInfo() parses the pg_index.indkey field into separate
integers by hand.
2.) I have guessed that if pg_index.indisclustered is "false", then
the index is "hashed"; if not, line 2561 of the resultant class
should have "tableIndexOther" rather than "tableIndexHashed".
3.) I didn't know what sort sequence (if any) was used in indexes, so
I have set it to "null" (unknown) on line 2566.
4.) For "CARDINALITY" (number of unique index items, the 11th field of
the ResultSet returned by getIndexInfo()) I have used
pg_classes.reltuples.
I have tested this method, but hardly extensively. Is there a proper
regression test suite for the JDBC driver that tests can be added to?
William
--
William Webber william@peopleweb.net.au
Senior Programmer
PeopleWeb Australia http://www.peopleweb.com
Attachments:
DatabaseMetaData.java.patchtext/plain; charset=us-asciiDownload+41-6
Peter, can you comment on this patch?
Hi all!
Attached is a patch that implements DatabaseMetaData.getIndexInfo()
for the JDBC2 driver. It also fixes a compile error under jikes by
casting characters in case statements of a byte-compared switch to
bytes.A few notes on getIndexInfo():
1.) getArray() is not implemented for the postgresql JDBC driver yet,
so getIndexInfo() parses the pg_index.indkey field into separate
integers by hand.2.) I have guessed that if pg_index.indisclustered is "false", then
the index is "hashed"; if not, line 2561 of the resultant class
should have "tableIndexOther" rather than "tableIndexHashed".3.) I didn't know what sort sequence (if any) was used in indexes, so
I have set it to "null" (unknown) on line 2566.4.) For "CARDINALITY" (number of unique index items, the 11th field of
the ResultSet returned by getIndexInfo()) I have used
pg_classes.reltuples.I have tested this method, but hardly extensively. Is there a proper
regression test suite for the JDBC driver that tests can be added to?William
--
William Webber william@peopleweb.net.au
Senior Programmer
PeopleWeb Australia http://www.peopleweb.com
[ Attachment, skipping... ]
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Attachments:
/bjm/patchtext/plainDownload+41-6
I am about to apply this to 7.2.
Hi all!
Attached is a patch that implements DatabaseMetaData.getIndexInfo()
for the JDBC2 driver. It also fixes a compile error under jikes by
casting characters in case statements of a byte-compared switch to
bytes.A few notes on getIndexInfo():
1.) getArray() is not implemented for the postgresql JDBC driver yet,
so getIndexInfo() parses the pg_index.indkey field into separate
integers by hand.
OK.
2.) I have guessed that if pg_index.indisclustered is "false", then
the index is "hashed"; if not, line 2561 of the resultant class
should have "tableIndexOther" rather than "tableIndexHashed".
I will fix this. I know how to do it because I just did this for ODBC.
3.) I didn't know what sort sequence (if any) was used in indexes, so
I have set it to "null" (unknown) on line 2566.
OK.
4.) For "CARDINALITY" (number of unique index items, the 11th field of
the ResultSet returned by getIndexInfo()) I have used
pg_classes.reltuples.
Is that perhaps the number of columns in the index?
I have tested this method, but hardly extensively. Is there a proper
regression test suite for the JDBC driver that tests can be added to?
Does this get added to JDBC1 too?
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Here is my version of your patch. I have gotten the hash test to work.
Can someone test this? It compiles OK, but I am unsure how to test this
feature.
I read about Cardinality in the comments and I think you got it fine.
Hi all!
Attached is a patch that implements DatabaseMetaData.getIndexInfo()
for the JDBC2 driver. It also fixes a compile error under jikes by
casting characters in case statements of a byte-compared switch to
bytes.A few notes on getIndexInfo():
1.) getArray() is not implemented for the postgresql JDBC driver yet,
so getIndexInfo() parses the pg_index.indkey field into separate
integers by hand.2.) I have guessed that if pg_index.indisclustered is "false", then
the index is "hashed"; if not, line 2561 of the resultant class
should have "tableIndexOther" rather than "tableIndexHashed".3.) I didn't know what sort sequence (if any) was used in indexes, so
I have set it to "null" (unknown) on line 2566.4.) For "CARDINALITY" (number of unique index items, the 11th field of
the ResultSet returned by getIndexInfo()) I have used
pg_classes.reltuples.I have tested this method, but hardly extensively. Is there a proper
regression test suite for the JDBC driver that tests can be added to?William
--
William Webber william@peopleweb.net.au
Senior Programmer
PeopleWeb Australia http://www.peopleweb.com
[ Attachment, skipping... ]
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Attachments:
/pgpatches/jdbcindextext/plainDownload+63-11
Patch applied to jdbc1 and jdbc2. This allows index lookups from jdbc.
Thanks.
Hi all!
Attached is a patch that implements DatabaseMetaData.getIndexInfo()
for the JDBC2 driver. It also fixes a compile error under jikes by
casting characters in case statements of a byte-compared switch to
bytes.A few notes on getIndexInfo():
1.) getArray() is not implemented for the postgresql JDBC driver yet,
so getIndexInfo() parses the pg_index.indkey field into separate
integers by hand.2.) I have guessed that if pg_index.indisclustered is "false", then
the index is "hashed"; if not, line 2561 of the resultant class
should have "tableIndexOther" rather than "tableIndexHashed".3.) I didn't know what sort sequence (if any) was used in indexes, so
I have set it to "null" (unknown) on line 2566.4.) For "CARDINALITY" (number of unique index items, the 11th field of
the ResultSet returned by getIndexInfo()) I have used
pg_classes.reltuples.I have tested this method, but hardly extensively. Is there a proper
regression test suite for the JDBC driver that tests can be added to?William
--
William Webber william@peopleweb.net.au
Senior Programmer
PeopleWeb Australia http://www.peopleweb.com
[ Attachment, skipping... ]
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026