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 bp...@apache.org on 2016/07/23 15:14:15 UTC

svn commit: r1753876 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/load/ImportReadData.java testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java

Author: bpendleton
Date: Sat Jul 23 15:14:15 2016
New Revision: 1753876

URL: http://svn.apache.org/viewvc?rev=1753876&view=rev
Log:
DERBY-4555: Expand SYSCS_IMPORT_TABLE to accept CSV file with header lines
DERBY-6894: Enhance COLUMNINDEXES parsing for SYSCS_IMPORT_DATA

This patch was contributed by Danoja Dias (danojadias at gmail dot com)

This patch is a follow-on to revision 1752990, and ensures that the
new readHeaders() logic correctly increments the ImportReadData's
lineNumber field as it's reading the column header lines, so that if
an error occurs while reading those header lines, a reasonable line
number is reported in the error message.

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

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ImportReadData.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ImportReadData.java?rev=1753876&r1=1753875&r2=1753876&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ImportReadData.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ImportReadData.java Sat Jul 23 15:14:15 2016
@@ -182,6 +182,7 @@ final class ImportReadData implements ja
     for(int i =0;i<skipLines;i++){
        if(!readNextToken(recordSeparator, 0, recordSeparatorLength, true))
           throw LoadError.unexpectedEndOfFile(lineNumber+1);
+       lineNumber++;
     }
   }
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java?rev=1753876&r1=1753875&r2=1753876&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java Sat Jul 23 15:14:15 2016
@@ -26,6 +26,7 @@ import java.sql.CallableStatement;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.Statement;
+import java.sql.SQLException;
 import junit.framework.Test;
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.BaseTestSuite;
@@ -2066,7 +2067,15 @@ public class ImportExportProcedureTest e
             + "'PET1' , null , '\"Pet Name\",\"Kind of\",\"Age\"' ,   'extinout/pet.dat' "
             + "  , null , null , null, 0, 2) ");
 
-	assertStatementError("XIE0R", cSt);	
+        try {
+            cSt.execute();
+        }
+        catch ( SQLException se )
+        {
+            assertSQLState( "XIE0R", se );
+            assertTrue("not column C3:"+se.getMessage(),
+                       se.getMessage().indexOf("C3") >= 0);
+        }
 
         //Skip=4
 	cSt = prepareCall(
@@ -2249,7 +2258,17 @@ public class ImportExportProcedureTest e
 	//Skip argument is 7 that is greater than number of rows in the file.
 	cSt = prepareCall(
             " call SYSCS_UTIL.SYSCS_IMPORT_TABLE_BULK(null, 'PET', 'extinout/pet.dat', null, null, null, 0, 7) ");
-	assertStatementError("XIE0E", cSt);
+
+        try {
+            cSt.execute();
+        }
+        catch ( SQLException se )
+        {
+            // Check line number in message:
+            assertSQLState( "XIE0E", se );
+            assertTrue("not line 7:"+se.getMessage(),
+                       se.getMessage().indexOf("7") >= 0);
+        }
 
 	//End of tests for SYSCS_IMPORT_TABLE_BULK procedure