db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r566692 - in /db/derby/code/branches/10.3/java: engine/org/apache/derby/impl/jdbc/ testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ testing/org/apache/derbyTesting/junit/ tools/org/apache/derby/impl/tools/ij/
Date Thu, 16 Aug 2007 12:53:09 GMT
Author: kmarsden
Date: Thu Aug 16 05:53:09 2007
New Revision: 566692

URL: http://svn.apache.org/viewvc?view=rev&rev=566692
Log:
DERBY-3000 - getTables() call with 10.3 causes java.sql.SQLException: The parameter position
'8' is out of range. The number of parameters for this prepared statement is '7'.

DERBY-1790 - DatabaseMetaData.getTables() with passed in table type of SYNONYM returns system
tables and not SYNONYMS

port from trunk



Added:
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DMDBugsTest.java
      - copied unchanged from r566359, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DMDBugsTest.java
Modified:
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/JDBC.java
    db/derby/code/branches/10.3/java/tools/org/apache/derby/impl/tools/ij/ij.jj

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java?view=diff&rev=566692&r1=566691&r2=566692
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java
Thu Aug 16 05:53:09 2007
@@ -1737,43 +1737,44 @@
 		//then the "if" statement below will use those types values
 		//for ?s. If there are still some ?s in the IN list that are left 
 		//with unassigned values, then we will set those ? to NULL.
-		//eg if getTables is called to only look for table types 'S' and 
-		//'A', then 'S' will be used for first ? in TABLETYPE IN (?, ?, ?, ?)
-		//'A' will be used for second ? in TABLETYPE IN (?, ?, ?, ?) and
-		//NULL will be used for third and fourth ?s in 
+		// So paramter 4 will be "T" for TABLE, 5 will be "V" for VIEW, 6 will be
+		// "A" for SYNONYM, 7 will be "S" for system table in 
 		//TABLETYPE IN (?, ?, ?, ?)
-		//If the user hasn't asked for any specific table types, then the
-		//"else" statement below will kick in. When the control comes to 
-		//"else" statement, it means that the user wants to see all the
-		//table types supported by Derby. And hence, we simply set first
-		//? to 'T', second ? to 'S', third ? to 'V' and fourth ? to 'A'.
-		//When a new table type is added to Derby in future, we will have
-		//to do another setString for that in the "else" statement for that
-		//new table type.
-		if (types != null  &&  types.length >= 1) {
-			int i=0;
-			final int numberOfTableTypesInDerby = 4;
-			for (; i<types.length; i++){
-				/*
-				 * Let's assume for now that the table type first char 
-				 * corresponds to JBMS table type identifiers.
-				 * 
-				 * The reason I have i+4 is because there are already 3 ?s in
-				 * the getTables sql before the ?s in the IN clause. Hence
-				 * setString for table types should be done starting 4th 
-				 * parameter.
-				 */
-				s.setString(i+4, types[i].substring(0, 1));					
-			}
-			for (; i<numberOfTableTypesInDerby; i++) {
-				s.setNull(i+4, Types.CHAR);
-			}
-		} else {
-			s.setString(4, "T");
-			s.setString(5, "S");
-			s.setString(6, "V");
-			s.setString(7, "A");				
+		// If the user hasn't asked for any specific table types then all
+		// four values will be set.
+		// When a new table type is added to Derby we will have to add a 
+		// parameter to the metadata statement and handle it here.
+		
+		// Array for type parameters
+		final int numberOfTableTypesInDerby = 4;
+		if (types == null)  {// null means all types 
+			types = new String[] {"TABLE","VIEW","SYNONYM","SYSTEM TABLE"};
 		}
+		String[] typeParams = new String[numberOfTableTypesInDerby];
+		for (int i=0; i < numberOfTableTypesInDerby;i++)
+			typeParams[i] = null;
+		
+		for (int i = 0; i<types.length; i++){
+			if ("TABLE".equals(types[i]))
+				typeParams[0] = "T";
+			else if ("VIEW".equals(types[i]))
+				typeParams[1] = "V";
+			else if ("SYNONYM".equals(types[i]))
+				typeParams[2] = "A";
+			else if ("SYSTEM TABLE".equals(types[i]) ||
+					"SYSTEM_TABLE".equals(types[i])) // Keep SYSTEM_TABLE since this is how we have been
testing
+					typeParams[3] = "S";
+			// If user puts in other types we simply ignore.
+			}
+		
+		// 	TABLETYPE IN (?,?,?,?) starts at parameter 4 so we add 4
+		// Set to value passed in or null if no value was given.
+		for (int i=0; i < numberOfTableTypesInDerby; i++)
+			if (typeParams[i] == null)
+				s.setNull(i+4,Types.CHAR);
+			else
+				s.setString(i+4,typeParams[i]);	
+					
 		return s.executeQuery();
 	}
 

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java?view=diff&rev=566692&r1=566691&r2=566692
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java
Thu Aug 16 05:53:09 2007
@@ -79,6 +79,7 @@
         suite.addTest(BlobUpdatableStreamTest.suite());
         suite.addTest(AIjdbcTest.suite());
         suite.addTest(LargeDataLocksTest.suite());
+        suite.addTest(DMDBugsTest.suite());
 
         // Old harness .java tests that run using the HarnessJavaTest
         // adapter and continue to use a single master file.

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/JDBC.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/JDBC.java?view=diff&rev=566692&r1=566691&r2=566692
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/JDBC.java (original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/JDBC.java Thu Aug
16 05:53:09 2007
@@ -52,11 +52,10 @@
     public static final String[] GET_TABLES_VIEW = new String[] {"VIEW"};
     /**
      * Constant to pass to DatabaseMetaData.getTables() to fetch
-     * just synonyms. Need work around for DERBY-1790 where
-     * passing a table type of SYNONYM fails.
+     * just synonyms.
      */
     public static final String[] GET_TABLES_SYNONYM =
-        new String[] {"AA_DERBY-1790-SYNONYM"};
+        new String[] {"SYNONYM"};
     
     /**
      * Types.SQLXML value without having to compile with JDBC4.

Modified: db/derby/code/branches/10.3/java/tools/org/apache/derby/impl/tools/ij/ij.jj
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/tools/org/apache/derby/impl/tools/ij/ij.jj?view=diff&rev=566692&r1=566691&r2=566692
==============================================================================
--- db/derby/code/branches/10.3/java/tools/org/apache/derby/impl/tools/ij/ij.jj (original)
+++ db/derby/code/branches/10.3/java/tools/org/apache/derby/impl/tools/ij/ij.jj Thu Aug 16
05:53:09 2007
@@ -1747,7 +1747,7 @@
 		else if(v!=null)
 			types = new String[] { "VIEW" };
 		else
-			types = new String[] { "ALIAS" };
+			types = new String[] { "SYNONYM" };
 		return showTables(schema, types);
 	}
 |	<SHOW> <INDEXES> 



Mime
View raw message