Derby
  1. Derby
  2. DERBY-4828

Import fails if column names contain double quotes

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 10.7.1.1
    • Fix Version/s: 10.7.1.1
    • Component/s: Tools
    • Labels:
      None
    • Issue & fix info:
      Repro attached

      Description

      If the target table for an import operation contains columns with double quotes in their names, the import will fail with a syntax error.

      1. derby-4828-1a.diff
        3 kB
        Knut Anders Hatlen
      2. test.diff
        2 kB
        Knut Anders Hatlen

        Activity

        Hide
        Knut Anders Hatlen added a comment -

        Thanks for reviewing the patch, Bryan. As to the tab/space issue, ColumnInfo uses both indentation styles, approximately evenly distributed, so I chose to stick with spaces for my changes.

        All the regression tests ran cleanly with the patch.

        Committed revision 1004197.

        Show
        Knut Anders Hatlen added a comment - Thanks for reviewing the patch, Bryan. As to the tab/space issue, ColumnInfo uses both indentation styles, approximately evenly distributed, so I chose to stick with spaces for my changes. All the regression tests ran cleanly with the patch. Committed revision 1004197.
        Hide
        Bryan Pendleton added a comment -

        Aside from a possible spaces vs. tabs problem in ColumnInfo.java,
        the patch looks fine to me. The test cases look complete and thorough.

        Thanks for cleaning this up. +1 to commit.

        Show
        Bryan Pendleton added a comment - Aside from a possible spaces vs. tabs problem in ColumnInfo.java, the patch looks fine to me. The test cases look complete and thorough. Thanks for cleaning this up. +1 to commit.
        Hide
        Knut Anders Hatlen added a comment -

        Here's a fix that makes ColumnInfo use an existing helper method for quoting the column names. Originally, it just added quotes around the names, but that's not enough if the name itself contains quotes. The helper method in IdUtil handles these cases correctly.

        ImportExportTest ran cleanly with the patch. I'll run the rest of the regression tests and come back with the results.

        Show
        Knut Anders Hatlen added a comment - Here's a fix that makes ColumnInfo use an existing helper method for quoting the column names. Originally, it just added quotes around the names, but that's not enough if the name itself contains quotes. The helper method in IdUtil handles these cases correctly. ImportExportTest ran cleanly with the patch. I'll run the rest of the regression tests and come back with the results.
        Hide
        Knut Anders Hatlen added a comment -

        Attached a test case that demonstrates the bug. If you apply the patch and run ImportExportTest, you'll see this error:

        1) testQuotesInColumnNames(org.apache.derbyTesting.functionTests.tests.tools.ImportExportTest)java.sql.SQLException: The exception 'java.sql.SQLException: Syntax error: Encountered ":" at line 1, column 66.' was thrown while evaluating an expression.
        at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:95)
        at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:142)
        at org.apache.derby.impl.jdbc.Util.seeNextException(Util.java:278)
        at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:398)
        at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346)
        at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2269)
        at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81)
        at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1321)
        at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java:1680)
        at org.apache.derby.impl.jdbc.EmbedPreparedStatement.execute(EmbedPreparedStatement.java:1335)
        at org.apache.derbyTesting.functionTests.tests.tools.ImportExportTest.doImportFromFile(ImportExportTest.java:323)

        Show
        Knut Anders Hatlen added a comment - Attached a test case that demonstrates the bug. If you apply the patch and run ImportExportTest, you'll see this error: 1) testQuotesInColumnNames(org.apache.derbyTesting.functionTests.tests.tools.ImportExportTest)java.sql.SQLException: The exception 'java.sql.SQLException: Syntax error: Encountered ":" at line 1, column 66.' was thrown while evaluating an expression. at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:95) at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:142) at org.apache.derby.impl.jdbc.Util.seeNextException(Util.java:278) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:398) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2269) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1321) at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java:1680) at org.apache.derby.impl.jdbc.EmbedPreparedStatement.execute(EmbedPreparedStatement.java:1335) at org.apache.derbyTesting.functionTests.tests.tools.ImportExportTest.doImportFromFile(ImportExportTest.java:323)

          People

          • Assignee:
            Knut Anders Hatlen
            Reporter:
            Knut Anders Hatlen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development