Re: Patch for getBestRowIdentifier (for testing with Oracle

From: Kris Jurka <books(at)ejurka(dot)com>
To: snpe <snpe(at)snpe(dot)co(dot)yu>
Cc: Dave Cramer <Dave(at)micro-automation(dot)net>, pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Patch for getBestRowIdentifier (for testing with Oracle
Date: 2002-09-12 17:02:28
Message-ID: Pine.LNX.4.33.0209121259320.6022-100000@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-jdbc


I will add a version of this patch to my work on making DatabaseMetaData
schema aware.

Kris Jurka

On Wed, 11 Sep 2002, snpe wrote:

> 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);
> + }
> }
>
> /*
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message scott.marlowe 2002-09-12 17:07:10 Re: DROP COLUMN misbehaviour with multiple inheritance
Previous Message Mike Mascari 2002-09-12 17:00:55 Re: PGXLOG variable worthwhile?

Browse pgsql-jdbc by date

  From Date Subject
Next Message snpe 2002-09-12 22:40:54 JDBC idea with special JDBC views
Previous Message Kris Jurka 2002-09-12 16:57:52 Re: Is getProcedureColumns working for pgjdbc2.jar?