JDBC patch for DatabaseMetaData

From: "Ed Yu" <ekyu(at)sc(dot)rr(dot)com>
To: "pgsql-jdbc" <pgsql-jdbc(at)postgresql(dot)org>
Subject: JDBC patch for DatabaseMetaData
Date: 2002-01-06 02:36:28
Message-ID: 002101c1965a$f1a303e0$bf00a8c0@sc.rr.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

The following patches up the DatabaseMetaData.getTables() method:

1638c1638,1641
< if(tableNamePattern==null)
---
> if((schemaPattern==null) || (schemaPattern.length()==0))
> schemaPattern="%";
>
> if((tableNamePattern==null) || (tableNamePattern.length()==0))
1653c1656,1657
< StringBuffer sql = new StringBuffer("select relname,oid,relkind from
pg_class where (");
---
> StringBuffer sql = new StringBuffer(
> "select relname,pg_class.oid,relkind from pg_class, pg_user where
(");
1665a1670
> // Modified by Ed Yu <ekyu(at)asgnet(dot)psc(dot)sc(dot)edu>
1667,1669c1672,1678
< sql.append(") and relname like '");
< sql.append(tableNamePattern.toLowerCase());
< sql.append("'");
---
> sql.append(") and relname");
> if ((tableNamePattern.indexOf("%") >= 0) ||
> (tableNamePattern.indexOf("_") >= 0))
> sql.append(" like ");
> else
> sql.append(" = ");
> sql.append("'" + tableNamePattern.toLowerCase() + "'");
1670a1680,1690
> // Added by Ed Yu <ekyu(at)asgnet(dot)psc(dot)sc(dot)edu>
> // Now take the schemaPattern into account
> sql.append(" and pg_class.relowner = pg_user.usesysid");
> sql.append(" and pg_user.usename");
> if ((schemaPattern.indexOf("%") >= 0) ||
> (schemaPattern.indexOf("_") >= 0))
> sql.append(" like ");
> else
> sql.append(" = ");
> sql.append("'" + schemaPattern + "'");
>
1688a1709,1710
> // JDBC definition for TABLE_TYPE - "TABLE", "VIEW", "SYSTEM TABLE",
> // "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
1699a1722,1724
> case 'v':
> relKind = "VIEW";
> break;
1707c1732,1740
< tuple[3] = relKind.getBytes(); // Table type
---
>
> // Added by Ed Yu <ekyu(at)asgnet(dot)psc(dot)sc(dot)edu>
> // Fix NullPointerException if return type is not handled in the
> // above switch statement.
> if (relKind==null)
> tuple[3] = null;
> else
> tuple[3] = relKind.getBytes(); // Table type
>

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Ed Yu 2002-01-06 02:53:00 JDBC Patches DatabaseMetaData.java and ResultSetMetaData.java (Postgresql 7.1.3)
Previous Message Ed Yu 2002-01-06 02:34:50 JDBC Driver patch (ResultSetMetaData.java)