Skip to content

Commit 4f5cdad

Browse files
committed
Applied to jdbc1 and jdbc2.
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 ----------------------------------------------------------------
1 parent 264c068 commit 4f5cdad

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,7 +1651,7 @@ public java.sql.ResultSet getTables(String catalog, String schemaPattern, String
16511651
f[4] = new Field(connection, new String("REMARKS"), iVarcharOid, 32);
16521652

16531653
// Now form the query
1654-
StringBuffer sql = new StringBuffer("select relname,oid from pg_class where (");
1654+
StringBuffer sql = new StringBuffer("select relname,oid,relkind from pg_class where (");
16551655
boolean notFirst=false;
16561656
for(int i=0;i<types.length;i++) {
16571657
for(int j=0;j<getTableTypes.length;j++)
@@ -1687,10 +1687,25 @@ public java.sql.ResultSet getTables(String catalog, String schemaPattern, String
16871687
remarks = defaultRemarks;
16881688
dr.close();
16891689

1690+
String relKind;
1691+
switch (r.getBytes(3)[0]) {
1692+
case 'r':
1693+
relKind = "TABLE";
1694+
break;
1695+
case 'i':
1696+
relKind = "INDEX";
1697+
break;
1698+
case 'S':
1699+
relKind = "SEQUENCE";
1700+
break;
1701+
default:
1702+
relKind = null;
1703+
}
1704+
16901705
tuple[0] = null; // Catalog name
16911706
tuple[1] = null; // Schema name
1692-
tuple[2] = r.getBytes(1); // Table name
1693-
tuple[3] = null; // Table type
1707+
tuple[2] = r.getBytes(1); // Table name
1708+
tuple[3] = relKind.getBytes(); // Table type
16941709
tuple[4] = remarks; // Remarks
16951710
v.addElement(tuple);
16961711
}

src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,7 +1651,7 @@ public java.sql.ResultSet getTables(String catalog, String schemaPattern, String
16511651
f[4] = new Field(connection, new String("REMARKS"), iVarcharOid, 32);
16521652

16531653
// Now form the query
1654-
StringBuffer sql = new StringBuffer("select relname,oid from pg_class where (");
1654+
StringBuffer sql = new StringBuffer("select relname,oid,relkind from pg_class where (");
16551655
boolean notFirst=false;
16561656
for(int i=0;i<types.length;i++) {
16571657
for(int j=0;j<getTableTypes.length;j++)
@@ -1687,10 +1687,25 @@ public java.sql.ResultSet getTables(String catalog, String schemaPattern, String
16871687
remarks = defaultRemarks;
16881688
dr.close();
16891689

1690+
String relKind;
1691+
switch (r.getBytes(3)[0]) {
1692+
case 'r':
1693+
relKind = "TABLE";
1694+
break;
1695+
case 'i':
1696+
relKind = "INDEX";
1697+
break;
1698+
case 'S':
1699+
relKind = "SEQUENCE";
1700+
break;
1701+
default:
1702+
relKind = null;
1703+
}
1704+
16901705
tuple[0] = null; // Catalog name
16911706
tuple[1] = null; // Schema name
1692-
tuple[2] = r.getBytes(1); // Table name
1693-
tuple[3] = null; // Table type
1707+
tuple[2] = r.getBytes(1); // Table name
1708+
tuple[3] = relKind.getBytes(); // Table type
16941709
tuple[4] = remarks; // Remarks
16951710
v.addElement(tuple);
16961711
}

0 commit comments

Comments
 (0)