I sent this to PATCHES last week, but it did not show up on the list.

----------------------------------------------------------------
Travis Bauer | CS Grad Student | IU |www.cs.indiana.edu/~trbauer
----------------------------------------------------------------

---------- Forwarded message ----------
Date: Thu, 31 Aug 2000 12:26:59 -0500 (EST)
From: Travis Bauer <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: Change to DatabaseMetaData.java for the jdbc2 driver

This is a patch which lets the DatabaseMetaData return the object type
when getTables(....) is called.  It does not really fix any bug, but it
fills in some functionality that should be there anyway.  The diff
included here is off of the CVS as of just now :)

----------------------------------------------------------------
Travis Bauer | CS Grad Student | IU |www.cs.indiana.edu/~trbauer
----------------------------------------------------------------
Index: DatabaseMetaData.java
===================================================================
RCS file: 
/home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java,v

retrieving revision 1.2
diff -u -r1.2 DatabaseMetaData.java
--- DatabaseMetaData.java       2000/07/20 15:30:05     1.2
+++ DatabaseMetaData.java       2000/08/31 17:24:03
@@ -1651,7 +1651,7 @@
     f[4] = new Field(connection, new String("REMARKS"), iVarcharOid, 32);
     
     // Now form the query
-    StringBuffer sql = new StringBuffer("select relname,oid from pg_class where (");
+    StringBuffer sql = new StringBuffer("select relname,oid,relkind from pg_class 
+where (");
     boolean notFirst=false;
     for(int i=0;i<types.length;i++) {
       if(notFirst)
@@ -1687,10 +1687,25 @@
          remarks = defaultRemarks;
        dr.close();
        
+       String relKind;
+       switch (r.getBytes(3)[0]) {
+       case 'r':
+           relKind = "TABLE";
+           break;
+       case 'i':
+           relKind = "INDEX";
+           break;
+       case 'S':
+           relKind = "SEQUENCE";
+           break;
+       default:
+           relKind = null;
+       }
+
        tuple[0] = null;                // Catalog name
        tuple[1] = null;                // Schema name
-       tuple[2] = r.getBytes(1);       // Table name
-       tuple[3] = null;                // Table type
+       tuple[2] = r.getBytes(1);       // Table name   
+       tuple[3] = relKind.getBytes();  // Table type
        tuple[4] = remarks;             // Remarks
        v.addElement(tuple);
       }

Reply via email to