Derby
  1. Derby
  2. DERBY-5370

The toSQL method of the org.apache.derby.vti.Restriction class does not output correct constants for VARCHAR, Timestamp, Date, Time, or CHAR FOR BIT DATA types

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 10.8.1.2
    • Fix Version/s: 10.8.3.0, 10.9.1.0
    • Component/s: SQL
    • Labels:
      None
    • Urgency:
      Urgent

      Description

      The toSQL method of the org.apache.derby.vti.Restriction class does not output correct constants for VARCHAR, Timestamp, Date, Time, or CHAR FOR BIT DATA types. This method is useful for building the WHERE clause when implementing a Restricted Table Function. The result of calling the toSQL method with restrictions on columns of these types does not produce valid SQL constants. For example with a VARCHAR column being restricted the single quote characters are not placed round the string constant.

      1. derby-5370-01-aa-withTest.diff
        25 kB
        Rick Hillegas
      2. derby-5370.diff
        1 kB
        Brett Bergquist

        Activity

        Hide
        Knut Anders Hatlen added a comment -

        [bulk update: close all resolved issues that haven't had any activity the last year]

        Show
        Knut Anders Hatlen added a comment - [bulk update: close all resolved issues that haven't had any activity the last year]
        Hide
        Kathey Marsden added a comment -

        Assigning this issue to Brett who contributed the patch. Actually it was a collaboration as Rick Wrote the test

        Show
        Kathey Marsden added a comment - Assigning this issue to Brett who contributed the patch. Actually it was a collaboration as Rick Wrote the test
        Hide
        Rick Hillegas added a comment -

        Ported 1160680 from trunk to 10.8 branch at subversion revision 1160683.

        Show
        Rick Hillegas added a comment - Ported 1160680 from trunk to 10.8 branch at subversion revision 1160683.
        Hide
        Rick Hillegas added a comment -

        Attaching derby-5370-02-aa-disableOnJSR169.diff. This patch disables the new test on JSR169 platforms. Committed to trunk at subversion revision 1160680.

        The new test relies on a table function which extends org.apache.derby.vti.VTITemplate, an implementation of the JDBC 3.0 ResultSet. JDBC 3.0 ResultSets pull in classes which do not exist on the small JSR169 platform, resulting in ClassNotFoundExceptions during method resolution.

        Kathey noticed that the new test case fails on weme. She posted her findings in this derby-dev thread: http://old.nabble.com/weme-failures-with-a-sane-build-to32316105.html#a32316105

        Touches the following file:

        M java/testing/org/apache/derbyTesting/functionTests/tests/lang/RestrictedVTITest.java

        Show
        Rick Hillegas added a comment - Attaching derby-5370-02-aa-disableOnJSR169.diff. This patch disables the new test on JSR169 platforms. Committed to trunk at subversion revision 1160680. The new test relies on a table function which extends org.apache.derby.vti.VTITemplate, an implementation of the JDBC 3.0 ResultSet. JDBC 3.0 ResultSets pull in classes which do not exist on the small JSR169 platform, resulting in ClassNotFoundExceptions during method resolution. Kathey noticed that the new test case fails on weme. She posted her findings in this derby-dev thread: http://old.nabble.com/weme-failures-with-a-sane-build-to32316105.html#a32316105 Touches the following file: M java/testing/org/apache/derbyTesting/functionTests/tests/lang/RestrictedVTITest.java
        Hide
        Rick Hillegas added a comment -

        Ported 1160445 from trunk to 10.8 branch at subversion revision 1160455.

        Show
        Rick Hillegas added a comment - Ported 1160445 from trunk to 10.8 branch at subversion revision 1160455.
        Hide
        Rick Hillegas added a comment -

        Tests passed cleanly for me. Committed derby-5370-01-aa-withTest.diff to trunk at subversion revision 1160445.

        Show
        Rick Hillegas added a comment - Tests passed cleanly for me. Committed derby-5370-01-aa-withTest.diff to trunk at subversion revision 1160445.
        Hide
        Rick Hillegas added a comment -

        Attaching derby-5370-01-aa-withTest.diff. This adds a regression test to Brett's patch. I am running tests now.

        Touches the following files:

        -----------

        M java/engine/org/apache/derby/vti/Restriction.java

        Brett's change.

        -----------

        A java/testing/org/apache/derbyTesting/functionTests/tests/lang/RestrictedTableVTI.java
        M java/testing/org/apache/derbyTesting/functionTests/tests/lang/RestrictedVTITest.java

        Test case for the improved Restriction.toSQL() method.

        Show
        Rick Hillegas added a comment - Attaching derby-5370-01-aa-withTest.diff. This adds a regression test to Brett's patch. I am running tests now. Touches the following files: ----------- M java/engine/org/apache/derby/vti/Restriction.java Brett's change. ----------- A java/testing/org/apache/derbyTesting/functionTests/tests/lang/RestrictedTableVTI.java M java/testing/org/apache/derbyTesting/functionTests/tests/lang/RestrictedVTITest.java Test case for the improved Restriction.toSQL() method.
        Hide
        Rick Hillegas added a comment -

        Thanks for that quick response, Brett. In case you haven't stumbled across this material yet, a good place to start is http://wiki.apache.org/db-derby/DerbyTesting . RestrictedVTITest is a JUnit test so the material on JUnit testing is particularly relevant.

        Show
        Rick Hillegas added a comment - Thanks for that quick response, Brett. In case you haven't stumbled across this material yet, a good place to start is http://wiki.apache.org/db-derby/DerbyTesting . RestrictedVTITest is a JUnit test so the material on JUnit testing is particularly relevant.
        Hide
        Brett Bergquist added a comment -

        I would add a test case but I am just learning my way around the code now. It may be a bit before I can figure out what I need to do but I can give it a shot. It will be useful to learn a bit more about the testing framework.

        Show
        Brett Bergquist added a comment - I would add a test case but I am just learning my way around the code now. It may be a bit before I can figure out what I need to do but I can give it a shot. It will be useful to learn a bit more about the testing framework.
        Hide
        Rick Hillegas added a comment -

        Thanks for the patch, Brett. I think that this should cover the comparable Derby types. Since BLOB and CLOB aren't comparable I don't think we need cases for them. If you want to add a test case to RestrictedVTITest, that would be great. If you don't want to, I will beef up the patch with a test. Thanks.

        Show
        Rick Hillegas added a comment - Thanks for the patch, Brett. I think that this should cover the comparable Derby types. Since BLOB and CLOB aren't comparable I don't think we need cases for them. If you want to add a test case to RestrictedVTITest, that would be great. If you don't want to, I will beef up the patch with a test. Thanks.
        Hide
        Brett Bergquist added a comment -

        Patch to output correct constants for the data types.

        Show
        Brett Bergquist added a comment - Patch to output correct constants for the data types.
        Hide
        Brett Bergquist added a comment -

        Actually it is not the column types that matter, but rather constant types that are passed with the SELECT statement WHERE clause that uses a Restricted Table Function. These constant types are not correctly reproduced by the toSQL method.

        Show
        Brett Bergquist added a comment - Actually it is not the column types that matter, but rather constant types that are passed with the SELECT statement WHERE clause that uses a Restricted Table Function. These constant types are not correctly reproduced by the toSQL method.

          People

          • Assignee:
            Brett Bergquist
            Reporter:
            Brett Bergquist
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development