Derby
  1. Derby
  2. DERBY-5170

Client doesn't handle double quotes in savepoint names

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 10.7.1.1
    • Fix Version/s: 10.8.1.2
    • Component/s: JDBC
    • Labels:
      None
    • Issue & fix info:
      Repro attached
    • Bug behavior facts:
      Embedded/Client difference

      Description

      I added the following test case to SavepointJdbc30Test and saw that it failed with the client driver:

      public void testQuotes() throws SQLException

      { setAutoCommit(false); Statement s = createStatement(); s.execute("create table test_quotes(x int)"); s.execute("insert into test_quotes values 1"); Savepoint sp = getConnection().setSavepoint("a \" b ' c"); s.execute("insert into test_quotes values 2"); getConnection().rollback(sp); JDBC.assertSingleValueResultSet( s.executeQuery("select * from test_quotes"), "1"); }

      Embedded had no problems with the savepoint, but the client raised this error when calling setSavepoint():

      java.sql.SQLSyntaxErrorException: Syntax error: Encountered "b" at line 1, column 16.

      1. derby-5170-1a.diff
        7 kB
        Knut Anders Hatlen

        Activity

        Hide
        Knut Anders Hatlen added a comment -

        Attaching a patch that makes the repro test case pass with the client driver too.

        The Connection class generates SQL statements to create, release and roll back to savepoints, but it doesn't quote the savepoint names properly. The ResultSet class had a private helper method that did proper quoting of SQL identifiers. I moved this method to a utility class so that it could be used by the Connection class too.

        Show
        Knut Anders Hatlen added a comment - Attaching a patch that makes the repro test case pass with the client driver too. The Connection class generates SQL statements to create, release and roll back to savepoints, but it doesn't quote the savepoint names properly. The ResultSet class had a private helper method that did proper quoting of SQL identifiers. I moved this method to a utility class so that it could be used by the Connection class too.
        Hide
        Knut Anders Hatlen added a comment -

        All the regression tests ran cleanly with the patch.

        Show
        Knut Anders Hatlen added a comment - All the regression tests ran cleanly with the patch.
        Hide
        Knut Anders Hatlen added a comment -

        Committed revision 1088500.

        Show
        Knut Anders Hatlen added a comment - Committed revision 1088500.

          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