DatabaseMetaData.java patch (7.1.3) - Mailing list pgsql-jdbc

From Ed Yu
Subject DatabaseMetaData.java patch (7.1.3)
Date
Msg-id 000b01c19cb0$89270ee0$bf00a8c0@sc.rr.com
Whole thread Raw
List pgsql-jdbc
This patch fixes the null pointer exception when returning the data row for
a view. Also, this fixes the table schema argument to the getTable() method
to properly recognize the underscore as a wildcard expression.

*** DatabaseMetaData.java.orig Fri Feb 16 11:45:00 2001
--- DatabaseMetaData.java Sun Jan 13 21:19:07 2002
***************
*** 1635,1641 ****
      if(types==null)
        types = defaultTableTypes;

!     if(tableNamePattern==null)
        tableNamePattern="%";

      // the field descriptors for the new ResultSet
--- 1635,1641 ----
      if(types==null)
        types = defaultTableTypes;

!     if((tableNamePattern==null) || (tableNamePattern.length()==0))
        tableNamePattern="%";

      // the field descriptors for the new ResultSet
***************
*** 1663,1672 ****
      }

      // Added by Stefan Andreasen <stefan@linux.kapow.dk>
      // Now take the pattern into account
!     sql.append(") and relname like '");
!     sql.append(tableNamePattern.toLowerCase());
!     sql.append("'");

      // Now run the query
      r = connection.ExecSQL(sql.toString());
--- 1663,1677 ----
      }

      // Added by Stefan Andreasen <stefan@linux.kapow.dk>
+     // Modified by Ed Yu <ekyu@asgnet.psc.sc.edu>
      // Now take the pattern into account
!     sql.append(") and relname");
!     if ((tableNamePattern.indexOf("%") >= 0) ||
!             (tableNamePattern.indexOf("_") >= 0))
!         sql.append(" like ");
!     else
!         sql.append(" = ");
!     sql.append("'" + tableNamePattern.toLowerCase() + "'");

      // Now run the query
      r = connection.ExecSQL(sql.toString());
***************
*** 1686,1691 ****
--- 1691,1698 ----
     remarks = defaultRemarks;
   dr.close();

+  // JDBC definition for TABLE_TYPE - "TABLE", "VIEW", "SYSTEM TABLE",
+  // "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
   String relKind;
   switch (r.getBytes(3)[0]) {
   case 'r':
***************
*** 1697,1702 ****
--- 1704,1712 ----
   case 'S':
       relKind = "SEQUENCE";
       break;
+  case 'v':
+             relKind = "VIEW";
+             break;
   default:
       relKind = null;
   }
***************
*** 1704,1710 ****
   tuple[0] = null;  // Catalog name
   tuple[1] = null;  // Schema name
   tuple[2] = r.getBytes(1); // Table name
!  tuple[3] = relKind.getBytes(); // Table type
   tuple[4] = remarks;  // Remarks
   v.addElement(tuple);
        }
--- 1714,1728 ----
   tuple[0] = null;  // Catalog name
   tuple[1] = null;  // Schema name
   tuple[2] = r.getBytes(1); // Table name
!
!  // 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
!
   tuple[4] = remarks;  // Remarks
   v.addElement(tuple);
        }


pgsql-jdbc by date:

Previous
From: Timo Savola
Date:
Subject: Re: ResultSet memory usage
Next
From: "Vianen, Jeroen van"
Date:
Subject: Problem with getImportedKeys / getExportedKeys