Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit879639b

Browse files
committed
This patch for the 7.0.2 JDBC interface addresses four issues I
encountered while getting my reporting tool up and running with thedriver. 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 theString array) resulted in a malformed SQL statement and subsequentparsing errorResolution: Unsupported table types are now ignored without errorProblem: In a getTables() call, tables and views were both returned bythe "TABLE" table type, and the "VIEW" table type was unsupportedResolution: Changed the "TABLE" type to return only physical tables andadded support for the "VIEW" table type (returning only views)Problem: The getIdentifierQuoteString() method was returning nullResolution: This method now returns a double-quoteChristopher Cain
1 parent0ba0e32 commit879639b

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public String getDatabaseProductName() throws SQLException
179179
*/
180180
publicStringgetDatabaseProductVersion()throwsSQLException
181181
{
182-
return ("6.5.2");
182+
return ("7.0.2");
183183
}
184184

185185
/**
@@ -363,7 +363,7 @@ public boolean storesMixedCaseQuotedIdentifiers() throws SQLException
363363
*/
364364
publicStringgetIdentifierQuoteString()throwsSQLException
365365
{
366-
returnnull;
366+
return"\"";
367367
}
368368

369369
/**
@@ -1654,10 +1654,10 @@ public java.sql.ResultSet getTables(String catalog, String schemaPattern, String
16541654
StringBuffersql =newStringBuffer("select relname,oid from pg_class where (");
16551655
booleannotFirst=false;
16561656
for(inti=0;i<types.length;i++) {
1657-
if(notFirst)
1658-
sql.append(" or ");
16591657
for(intj=0;j<getTableTypes.length;j++)
16601658
if(getTableTypes[j][0].equals(types[i])) {
1659+
if(notFirst)
1660+
sql.append(" or ");
16611661
sql.append(getTableTypes[j][1]);
16621662
notFirst=true;
16631663
}
@@ -1706,7 +1706,8 @@ public java.sql.ResultSet getTables(String catalog, String schemaPattern, String
17061706
//
17071707
// IMPORTANT: the query must be enclosed in ( )
17081708
privatestaticfinalStringgetTableTypes[][] = {
1709-
{"TABLE","(relkind='r' and relname !~ '^pg_' and relname !~ '^xinv')"},
1709+
{"TABLE","(relkind='r' and relhasrules='f' and relname !~ '^pg_' and relname !~ '^xinv')"},
1710+
{"VIEW","(relkind='r' and relhasrules='t' and relname !~ '^pg_' and relname !~ '^xinv')"},
17101711
{"INDEX","(relkind='i' and relname !~ '^pg_' and relname !~ '^xinx')"},
17111712
{"LARGE OBJECT","(relkind='r' and relname ~ '^xinv')"},
17121713
{"SEQUENCE","(relkind='S' and relname !~ '^pg_')"},
@@ -1717,7 +1718,7 @@ public java.sql.ResultSet getTables(String catalog, String schemaPattern, String
17171718
// These are the default tables, used when NULL is passed to getTables
17181719
// The choice of these provide the same behaviour as psql's \d
17191720
privatestaticfinalStringdefaultTableTypes[] = {
1720-
"TABLE","INDEX","SEQUENCE"
1721+
"TABLE","VIEW","INDEX","SEQUENCE"
17211722
};
17221723

17231724
/**

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public String getDatabaseProductName() throws SQLException
179179
*/
180180
publicStringgetDatabaseProductVersion()throwsSQLException
181181
{
182-
return ("6.5.2");
182+
return ("7.0.2");
183183
}
184184

185185
/**
@@ -363,7 +363,7 @@ public boolean storesMixedCaseQuotedIdentifiers() throws SQLException
363363
*/
364364
publicStringgetIdentifierQuoteString()throwsSQLException
365365
{
366-
returnnull;
366+
return"\"";
367367
}
368368

369369
/**
@@ -1654,10 +1654,10 @@ public java.sql.ResultSet getTables(String catalog, String schemaPattern, String
16541654
StringBuffersql =newStringBuffer("select relname,oid from pg_class where (");
16551655
booleannotFirst=false;
16561656
for(inti=0;i<types.length;i++) {
1657-
if(notFirst)
1658-
sql.append(" or ");
16591657
for(intj=0;j<getTableTypes.length;j++)
16601658
if(getTableTypes[j][0].equals(types[i])) {
1659+
if(notFirst)
1660+
sql.append(" or ");
16611661
sql.append(getTableTypes[j][1]);
16621662
notFirst=true;
16631663
}
@@ -1706,7 +1706,8 @@ public java.sql.ResultSet getTables(String catalog, String schemaPattern, String
17061706
//
17071707
// IMPORTANT: the query must be enclosed in ( )
17081708
privatestaticfinalStringgetTableTypes[][] = {
1709-
{"TABLE","(relkind='r' and relname !~ '^pg_' and relname !~ '^xinv')"},
1709+
{"TABLE","(relkind='r' and relhasrules='f' and relname !~ '^pg_' and relname !~ '^xinv')"},
1710+
{"VIEW","(relkind='r' and relhasrules='t' and relname !~ '^pg_' and relname !~ '^xinv')"},
17101711
{"INDEX","(relkind='i' and relname !~ '^pg_' and relname !~ '^xinx')"},
17111712
{"LARGE OBJECT","(relkind='r' and relname ~ '^xinv')"},
17121713
{"SEQUENCE","(relkind='S' and relname !~ '^pg_')"},
@@ -1717,7 +1718,7 @@ public java.sql.ResultSet getTables(String catalog, String schemaPattern, String
17171718
// These are the default tables, used when NULL is passed to getTables
17181719
// The choice of these provide the same behaviour as psql's \d
17191720
privatestaticfinalStringdefaultTableTypes[] = {
1720-
"TABLE","INDEX","SEQUENCE"
1721+
"TABLE","VIEW","INDEX","SEQUENCE"
17211722
};
17221723

17231724
/**

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp