This patch for the 7.0.2 JDBC interface addresses four issues I
encountered while getting my reporting tool up and running with the driver. All changes are in the DatabaseMetaData class. Problem: The getDatabaseProductVersion() method was returning "6.5.2" Resolution: Changed it to return "7.0.2" Problem: A call to getTables() with an unsupported table type (in the String array) resulted in a malformed SQL statement and subsequent parsing error Resolution: Unsupported table types are now ignored without error Problem: In a getTables() call, tables and views were both returned by the "TABLE" table type, and the "VIEW" table type was unsupported Resolution: Changed the "TABLE" type to return only physical tables and added support for the "VIEW" table type (returning only views) Problem: The getIdentifierQuoteString() method was returning null Resolution: This method now returns a double-quote Christopher Cain
This commit is contained in:
parent
0ba0e32172
commit
879639b5be
@ -179,7 +179,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
*/
|
||||
public String getDatabaseProductVersion() throws SQLException
|
||||
{
|
||||
return ("6.5.2");
|
||||
return ("7.0.2");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -363,7 +363,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
*/
|
||||
public String getIdentifierQuoteString() throws SQLException
|
||||
{
|
||||
return null;
|
||||
return "\"";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1654,10 +1654,10 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
StringBuffer sql = new StringBuffer("select relname,oid from pg_class where (");
|
||||
boolean notFirst=false;
|
||||
for(int i=0;i<types.length;i++) {
|
||||
if(notFirst)
|
||||
sql.append(" or ");
|
||||
for(int j=0;j<getTableTypes.length;j++)
|
||||
if(getTableTypes[j][0].equals(types[i])) {
|
||||
if(notFirst)
|
||||
sql.append(" or ");
|
||||
sql.append(getTableTypes[j][1]);
|
||||
notFirst=true;
|
||||
}
|
||||
@ -1706,7 +1706,8 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
//
|
||||
// IMPORTANT: the query must be enclosed in ( )
|
||||
private static final String getTableTypes[][] = {
|
||||
{"TABLE", "(relkind='r' and relname !~ '^pg_' and relname !~ '^xinv')"},
|
||||
{"TABLE", "(relkind='r' and relhasrules='f' and relname !~ '^pg_' and relname !~ '^xinv')"},
|
||||
{"VIEW", "(relkind='r' and relhasrules='t' and relname !~ '^pg_' and relname !~ '^xinv')"},
|
||||
{"INDEX", "(relkind='i' and relname !~ '^pg_' and relname !~ '^xinx')"},
|
||||
{"LARGE OBJECT", "(relkind='r' and relname ~ '^xinv')"},
|
||||
{"SEQUENCE", "(relkind='S' and relname !~ '^pg_')"},
|
||||
@ -1717,7 +1718,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
// These are the default tables, used when NULL is passed to getTables
|
||||
// The choice of these provide the same behaviour as psql's \d
|
||||
private static final String defaultTableTypes[] = {
|
||||
"TABLE","INDEX","SEQUENCE"
|
||||
"TABLE","VIEW","INDEX","SEQUENCE"
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -179,7 +179,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
*/
|
||||
public String getDatabaseProductVersion() throws SQLException
|
||||
{
|
||||
return ("6.5.2");
|
||||
return ("7.0.2");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -363,7 +363,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
*/
|
||||
public String getIdentifierQuoteString() throws SQLException
|
||||
{
|
||||
return null;
|
||||
return "\"";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1654,10 +1654,10 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
StringBuffer sql = new StringBuffer("select relname,oid from pg_class where (");
|
||||
boolean notFirst=false;
|
||||
for(int i=0;i<types.length;i++) {
|
||||
if(notFirst)
|
||||
sql.append(" or ");
|
||||
for(int j=0;j<getTableTypes.length;j++)
|
||||
if(getTableTypes[j][0].equals(types[i])) {
|
||||
if(notFirst)
|
||||
sql.append(" or ");
|
||||
sql.append(getTableTypes[j][1]);
|
||||
notFirst=true;
|
||||
}
|
||||
@ -1706,7 +1706,8 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
//
|
||||
// IMPORTANT: the query must be enclosed in ( )
|
||||
private static final String getTableTypes[][] = {
|
||||
{"TABLE", "(relkind='r' and relname !~ '^pg_' and relname !~ '^xinv')"},
|
||||
{"TABLE", "(relkind='r' and relhasrules='f' and relname !~ '^pg_' and relname !~ '^xinv')"},
|
||||
{"VIEW", "(relkind='r' and relhasrules='t' and relname !~ '^pg_' and relname !~ '^xinv')"},
|
||||
{"INDEX", "(relkind='i' and relname !~ '^pg_' and relname !~ '^xinx')"},
|
||||
{"LARGE OBJECT", "(relkind='r' and relname ~ '^xinv')"},
|
||||
{"SEQUENCE", "(relkind='S' and relname !~ '^pg_')"},
|
||||
@ -1717,7 +1718,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
// These are the default tables, used when NULL is passed to getTables
|
||||
// The choice of these provide the same behaviour as psql's \d
|
||||
private static final String defaultTableTypes[] = {
|
||||
"TABLE","INDEX","SEQUENCE"
|
||||
"TABLE","VIEW","INDEX","SEQUENCE"
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user