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.


git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/trunk@1753876 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/java/engine/org/apache/derby/impl/load/ImportReadData.java b/java/engine/org/apache/derby/impl/load/ImportReadData.java
index c2a7df6..2539e2f 100644
--- a/java/engine/org/apache/derby/impl/load/ImportReadData.java
+++ b/java/engine/org/apache/derby/impl/load/ImportReadData.java
@@ -182,6 +182,7 @@
     for(int i =0;i<skipLines;i++){
        if(!readNextToken(recordSeparator, 0, recordSeparatorLength, true))
           throw LoadError.unexpectedEndOfFile(lineNumber+1);
+       lineNumber++;
     }
   }
 
diff --git a/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java b/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java
index 12ae956..010ec16 100644
--- a/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java
+++ b/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java
@@ -26,6 +26,7 @@
 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 @@
             + "'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 @@
 	//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