Re: JDBC patch for DatabaseMetaData - Mailing list pgsql-jdbc
From | Barry Lind |
---|---|
Subject | Re: JDBC patch for DatabaseMetaData |
Date | |
Msg-id | 3C39DE6E.4070806@xythos.com Whole thread Raw |
In response to | JDBC patch for DatabaseMetaData ("Ed Yu" <ekyu@sc.rr.com>) |
Responses |
Re: JDBC patch for DatabaseMetaData
|
List | pgsql-jdbc |
It appears that this patch is trying to add schema support for the getTables method. But since postgres doesn't yet support schemas (perhaps in 7.3), I don't see how this is going to be possible. I certainly don't agree with the approach here that user = schema. That may be how Oracle does it, but certainly isn't how the ANSI standard defines schemas. thanks, --Barry Ed Yu wrote: > 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@asgnet.psc.sc.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@asgnet.psc.sc.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@asgnet.psc.sc.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 >> >> > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html > >
pgsql-jdbc by date: