db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r779681 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/load/ColumnInfo.java testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportTest.java
Date Thu, 28 May 2009 17:25:48 GMT
Author: kahatlen
Date: Thu May 28 17:25:48 2009
New Revision: 779681

URL: http://svn.apache.org/viewvc?rev=779681&view=rev
Log:
DERBY-3296: Importing to table in default schema fails when another table with the same name
exists in a different schema

If schema isn't specified, ColumnInfo should pass the name of the
session's current schema to DatabaseMetaData.getColumns().

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ColumnInfo.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ColumnInfo.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ColumnInfo.java?rev=779681&r1=779680&r2=779681&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ColumnInfo.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ColumnInfo.java Thu May 28
17:25:48 2009
@@ -33,6 +33,7 @@
 import java.sql.ResultSetMetaData;
 import java.sql.DatabaseMetaData;
 import java.util.*;
+import org.apache.derby.iapi.jdbc.EngineConnection;
 
 /**
  *	
@@ -86,6 +87,11 @@
 		noOfColumns = 0;
 		this.conn = conn;
 
+        if (sName == null) {
+            // Use the current schema if no schema is specified.
+            sName = ((EngineConnection) conn).getCurrentSchemaName();
+        }
+
 		this.schemaName = sName;
 		this.tableName =  tName;
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportTest.java?rev=779681&r1=779680&r2=779681&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportTest.java
Thu May 28 17:25:48 2009
@@ -162,6 +162,25 @@
 	}
 
     /**
+     * Test that import to a table in the default schema works if a table
+     * with the same name exists in a different schema (DERBY-3296).
+     */
+    public void testImportWithSameNameInDifferentSchema() throws Exception {
+        resetTables();
+        doExport(null, "T1", null, null, null);
+        Statement s = createStatement();
+        s.executeUpdate("create table otherschema.t2(x int)");
+        // toSchema must be null to trigger the bug. The bug is not exposed if
+        // the schema is explicit.
+        doImport("T1", null, "T2", null, null, null, 0);
+        // Check that the rows were imported to the correct table (APP.T2)
+        JDBC.assertSingleValueResultSet(
+                s.executeQuery("select count(*) from app.t2"), "4");
+        setAutoCommit(false); // requirement for dropSchema()
+        JDBC.dropSchema(getConnection().getMetaData(), "OTHERSCHEMA");
+    }
+
+    /**
      * Test that quotes in the arguments to the export and import procedures
      * are handled properly (DERBY-4042).
      */



Mime
View raw message