You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2009/06/09 20:15:04 UTC
svn commit: r783087 - in /db/derby/code/branches/10.5: ./
java/engine/org/apache/derby/impl/load/ColumnInfo.java
java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportTest.java
Author: kahatlen
Date: Tue Jun 9 18:15:03 2009
New Revision: 783087
URL: http://svn.apache.org/viewvc?rev=783087&view=rev
Log:
DERBY-3296: Importing to table in default schema fails when another table with the same name exists in a different schema
Merged fix from trunk (revision 779681).
Modified:
db/derby/code/branches/10.5/ (props changed)
db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/load/ColumnInfo.java
db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportTest.java
Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun 9 18:15:03 2009
@@ -1 +1 @@
-/db/derby/code/trunk:772090,772449,772534,774281,782991
+/db/derby/code/trunk:772090,772449,772534,774281,779681,782991
Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/load/ColumnInfo.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/load/ColumnInfo.java?rev=783087&r1=783086&r2=783087&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/load/ColumnInfo.java (original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/load/ColumnInfo.java Tue Jun 9 18:15:03 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/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportTest.java?rev=783087&r1=783086&r2=783087&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportTest.java (original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportTest.java Tue Jun 9 18:15:03 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).
*/