Re: Patch for getBestRowIdentifier (for testing with Oracle JDeveloper)

From: snpe <snpe(at)snpe(dot)co(dot)yu>
To: Dave Cramer <Dave(at)micro-automation(dot)net>
Cc: pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Patch for getBestRowIdentifier (for testing with Oracle JDeveloper)
Date: 2002-09-11 20:52:55
Message-ID: 200209112252.55871.snpe@snpe.co.yu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-jdbc

I'am sorry (reverse *java and *orig)

correct patch
--- AbstractJdbc1DatabaseMetaData.java.orig Wed Sep 11 22:20:36 2002
+++ AbstractJdbc1DatabaseMetaData.java Wed Sep 11 22:50:37 2002
@@ -2381,21 +2381,44 @@
// Implementation note: This is required for Borland's JBuilder to work
public java.sql.ResultSet getBestRowIdentifier(String catalog, String
schema, String table, int scope, boolean nullable) throws SQLException
{
- // for now, this returns an empty result set.
- Field f[] = new Field[8];
- ResultSet r; // ResultSet for the SQL query that we need to do
- Vector v = new Vector(); // The new ResultSet tuple stuff
+ if (connection.haveMinimumServerVersion("7.3")) {
+ StringBuffer sql = new StringBuffer(512);
+ sql.append("SELECT " +
+ scope + " as SCOPE," +
+ "a.attname as COLUMN_NAME," +
+ "a.atttypid as DATA_TYPE," +
+ "t.typname as TYPE_NAME," +
+ "t.typlen as COLUMN_SIZE," +
+ "0::int4 as BUFFER_LENGTH," +
+ "0::int4 as DECIMAL_DIGITS," +
+ "0::int4 as PSEUDO_COLUMN " +
+ "FROM pg_catalog.pg_type t,pg_catalog.pg_class bc," +
+ "pg_catalog.pg_class ic, pg_catalog.pg_index i, pg_catalog.pg_attribute a
" +
+ "WHERE bc.relkind = 'r' " +
+ "AND t.oid=a.atttypid " +
+ "AND upper(bc.relname) = upper('" + table + "') " +
+ "AND i.indrelid = bc.oid " +
+ "AND i.indexrelid = ic.oid " +
+ "AND ic.oid = a.attrelid " +
+ "AND i.indisprimary='t' ");
+ return connection.createStatement().executeQuery(sql.toString());
+ } else {
+ // for now, this returns an empty result set.
+ Field f[] = new Field[8];
+ ResultSet r; // ResultSet for the SQL query that we need to do
+ Vector v = new Vector(); // The new ResultSet tuple stuff

- f[0] = new Field(connection, "SCOPE", iInt2Oid, 2);
- f[1] = new Field(connection, "COLUMN_NAME", iVarcharOid, NAME_SIZE);
- f[2] = new Field(connection, "DATA_TYPE", iInt2Oid, 2);
- f[3] = new Field(connection, "TYPE_NAME", iVarcharOid, NAME_SIZE);
- f[4] = new Field(connection, "COLUMN_SIZE", iInt4Oid, 4);
- f[5] = new Field(connection, "BUFFER_LENGTH", iInt4Oid, 4);
- f[6] = new Field(connection, "DECIMAL_DIGITS", iInt2Oid, 2);
- f[7] = new Field(connection, "PSEUDO_COLUMN", iInt2Oid, 2);
+ f[0] = new Field(connection, "SCOPE", iInt2Oid, 2);
+ f[1] = new Field(connection, "COLUMN_NAME", iVarcharOid, NAME_SIZE);
+ f[2] = new Field(connection, "DATA_TYPE", iInt2Oid, 2);
+ f[3] = new Field(connection, "TYPE_NAME", iVarcharOid, NAME_SIZE);
+ f[4] = new Field(connection, "COLUMN_SIZE", iInt4Oid, 4);
+ f[5] = new Field(connection, "BUFFER_LENGTH", iInt4Oid, 4);
+ f[6] = new Field(connection, "DECIMAL_DIGITS", iInt2Oid, 2);
+ f[7] = new Field(connection, "PSEUDO_COLUMN", iInt2Oid, 2);

- return connection.getResultSet(null, f, v, "OK", 1);
+ return connection.getResultSet(null, f, v, "OK", 1);
+ }
}

/*

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dave Page 2002-09-11 21:09:59 Re:
Previous Message snpe 2002-09-11 20:38:08 Patch for getBestRowIdentifier (for testing with Oracle JDeveloper)

Browse pgsql-jdbc by date

  From Date Subject
Next Message snpe 2002-09-11 21:33:56 Re: problem with new autocommit config parameter and jdbc
Previous Message snpe 2002-09-11 20:38:08 Patch for getBestRowIdentifier (for testing with Oracle JDeveloper)