Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 98297 invoked from network); 27 Apr 2007 17:38:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 Apr 2007 17:38:39 -0000 Received: (qmail 44763 invoked by uid 500); 27 Apr 2007 17:38:46 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 44741 invoked by uid 500); 27 Apr 2007 17:38:46 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 44730 invoked by uid 99); 27 Apr 2007 17:38:45 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Apr 2007 10:38:45 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Apr 2007 10:38:38 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 2698B1A9838; Fri, 27 Apr 2007 10:38:18 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r533175 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java Date: Fri, 27 Apr 2007 17:38:18 -0000 To: derby-commits@db.apache.org From: kahatlen@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070427173818.2698B1A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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)