db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r533175 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java
Date Fri, 27 Apr 2007 17:38:18 GMT
Author: kahatlen
Date: Fri Apr 27 10:38:17 2007
New Revision: 533175

URL: http://svn.apache.org/viewvc?view=rev&rev=533175
Log:
DERBY-2595: JUnit tests use getExportedKeys with table name null

Rewrote invalid usage of DatabaseMetaData.getExportedKeys() in
JDBC.dropSchema().

Contributed by Jørgen Løland.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java?view=diff&rev=533175&r1=533174&r2=533175
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java Fri Apr 27 10:38:17
2007
@@ -221,26 +221,32 @@
         // foreign key constraints leading to a dependency loop.
         // Drop any constraints that remain and then drop the tables.
         // If there are no tables then this should be a quick no-op.
-        rs = dmd.getExportedKeys((String) null, schema, (String) null);
-        while (rs.next())
-        {
-            short keyPosition = rs.getShort("KEY_SEQ");
-            if (keyPosition != 1)
-                continue;
-            String fkName = rs.getString("FK_NAME");
-            // No name, probably can't happen but couldn't drop it anyway.
-            if (fkName == null)
-                continue;
-            String fkSchema = rs.getString("FKTABLE_SCHEM");
-            String fkTable = rs.getString("FKTABLE_NAME");
-            
-            String ddl = "ALTER TABLE " +
-                JDBC.escape(fkSchema, fkTable) +
-                " DROP FOREIGN KEY " +
-                JDBC.escape(fkName);
-            s.executeUpdate(ddl);
+        ResultSet table_rs = dmd.getTables((String) null, schema, (String) null,
+                new String[] {"TABLE"});
+
+        while (table_rs.next()) {
+            String tablename = table_rs.getString("TABLE_NAME");
+            rs = dmd.getExportedKeys((String) null, schema, tablename);
+            while (rs.next()) {
+                short keyPosition = rs.getShort("KEY_SEQ");
+                if (keyPosition != 1)
+                    continue;
+                String fkName = rs.getString("FK_NAME");
+                // No name, probably can't happen but couldn't drop it anyway.
+                if (fkName == null)
+                    continue;
+                String fkSchema = rs.getString("FKTABLE_SCHEM");
+                String fkTable = rs.getString("FKTABLE_NAME");
+
+                String ddl = "ALTER TABLE " +
+                    JDBC.escape(fkSchema, fkTable) +
+                    " DROP FOREIGN KEY " +
+                    JDBC.escape(fkName);
+                s.executeUpdate(ddl);
+            }
+            rs.close();
         }
-        rs.close();
+        table_rs.close();
         conn.commit();
                 
         // Tables (again)



Mime
View raw message