Thread: JDBC Patches DatabaseMetaData.java and ResultSetMetaData.java (Postgresql 7.1.3)

Sorry about that, I forgot about the Postgresql version, here they are
again!

DatabaseMetaData.java:

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
>

ResultSetMetaData.java:

450a451,508
> /*
>     The following data type mapping came from ../Field.java.
>
>     "int2",
>     "int4","oid",
>     "int8",
>     "cash","money",
>     "numeric",
>     "float4",
>     "float8",
>     "bpchar","char","char2","char4","char8","char16",
>     "varchar","text","name","filename",
>     "bool",
>     "date",
>     "time",
>     "abstime","timestamp"
>
>     Types.SMALLINT,
>     Types.INTEGER,Types.INTEGER,
>     Types.BIGINT,
>     Types.DOUBLE,Types.DOUBLE,
>     Types.NUMERIC,
>     Types.REAL,
>     Types.DOUBLE,
>     Types.CHAR,Types.CHAR,Types.CHAR,Types.CHAR,Types.CHAR,Types.CHAR,
>     Types.VARCHAR,Types.VARCHAR,Types.VARCHAR,Types.VARCHAR,
>     Types.BIT,
>     Types.DATE,
>     Types.TIME,
>     Types.TIMESTAMP,Types.TIMESTAMP
> */
>
>     int sql_type = getField(column).getSQLType();
>
>     switch (sql_type)
>       {
>       case Types.BIT:
>         return("java.lang.Boolean");
>       case Types.SMALLINT:
>         return("java.lang.Integer");
>       case Types.INTEGER:
>         return("java.lang.Integer");
>       case Types.BIGINT:
>         return("java.lang.Long");
>       case Types.NUMERIC:
>         return("java.math.BigDecimal");
>       case Types.REAL:
>         return("java.lang.Float");
>       case Types.DOUBLE:
>         return("java.lang.Double");
>       case Types.CHAR:
>       case Types.VARCHAR:
>         return("java.lang.String");
>       case Types.DATE:
>       case Types.TIME:
>       case Types.TIMESTAMP:
>         return("java.sql.Timestamp");
>       default:
451a510
>       }



Re: JDBC Patches DatabaseMetaData.java and ResultSetMetaData.java

From
Bruce Momjian
Date:
Sorry, we need context diffs (diff -c).


---------------------------------------------------------------------------

Ed Yu wrote:
> Sorry about that, I forgot about the Postgresql version, here they are
> again!
>
> DatabaseMetaData.java:
>
> 1638c1638,1641

--
  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