Derby
  1. Derby
  2. DERBY-4904

Plan exporter doesn't work if XPLAIN schema has special characters

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 10.7.1.1
    • Fix Version/s: 10.7.1.1, 10.8.1.2
    • Component/s: Tools
    • Labels:
      None

      Description

      If the XPLAIN schema contains lowercase characters (e.g, CALL SYSCS_UTIL.SYSCS_SET_XPLAIN_SCHEMA('my_stats_schema')), the plan exporter will fail with

      ERROR 42Y07: Schema 'MY_STATS_SCHEMA' does not exist
      at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:286)
      at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getSchemaDescriptor(DataDictionaryImpl.java:1528)
      (...)
      at org.apache.derby.impl.jdbc.EmbedStatement.executeQuery(EmbedStatement.java:153)
      at org.apache.derby.impl.tools.planexporter.AccessDatabase.noOfNodes(AccessDatabase.java:417)
      at org.apache.derby.impl.tools.planexporter.AccessDatabase.initializeDataArray(AccessDatabase.java:323)
      at org.apache.derby.tools.PlanExporter.main(PlanExporter.java:59)

      If the schema contains spaces or special characters, like single-quotes or double-quotes, it will get a syntax error instead:

      ij> CALL SYSCS_UTIL.SYSCS_SET_RUNTIMESTATISTICS(1);
      ij> CALL SYSCS_UTIL.SYSCS_SET_XPLAIN_SCHEMA('my "quoted" schema');
      ij> SELECT * FROM SYSIBM.SYSDUMMY1;

      $ java org.apache.derby.tools.PlanExporter jdbc:derby:db 'my "quoted" schema' 6f2b430a-012c-4ec6-f4a1-00000d4d4fe5 -xml plan.xml -html plan.html
      ERROR 42X01: Syntax error: Encountered "schema" at line 1, column 34.
      at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:286)
      at org.apache.derby.impl.sql.compile.ParserImpl.parseStatement(ParserImpl.java:155)
      (...)
      at org.apache.derby.impl.jdbc.EmbedStatement.executeQuery(EmbedStatement.java:153)
      at org.apache.derby.impl.tools.planexporter.AccessDatabase.noOfNodes(AccessDatabase.java:417)
      at org.apache.derby.impl.tools.planexporter.AccessDatabase.initializeDataArray(AccessDatabase.java:323)
      at org.apache.derby.tools.PlanExporter.main(PlanExporter.java:59)

      1. d4904.diff
        16 kB
        Knut Anders Hatlen

        Activity

        Hide
        Knut Anders Hatlen added a comment -

        All the regression tests ran cleanly.

        Committed to trunk with revision 1035603.
        Committed to 10.7 with revision 1035608.

        Show
        Knut Anders Hatlen added a comment - All the regression tests ran cleanly. Committed to trunk with revision 1035603. Committed to 10.7 with revision 1035608.
        Hide
        Knut Anders Hatlen added a comment -

        Attaching a patch with a fix for the problem and a test cases that exposes the bug.

        The patch changes all the queries in AccessDatabase from Statement to PreparedStatement, and makes all variable parts of the queries parameters instead of concatenating and escaping string literals manually.

        Show
        Knut Anders Hatlen added a comment - Attaching a patch with a fix for the problem and a test cases that exposes the bug. The patch changes all the queries in AccessDatabase from Statement to PreparedStatement, and makes all variable parts of the queries parameters instead of concatenating and escaping string literals manually.
        Hide
        Knut Anders Hatlen added a comment -

        Looks like the schema isn't escaped when AccessDatabase creates queries against the xplain tables. I'll see if I can come up with a fix.

        Show
        Knut Anders Hatlen added a comment - Looks like the schema isn't escaped when AccessDatabase creates queries against the xplain tables. I'll see if I can come up with a fix.

          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