Derby
  1. Derby
  2. DERBY-4092

You should not be able to invoke a table function as a scalar function

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 10.5.1.1
    • Fix Version/s: 10.5.3.1, 10.6.1.0
    • Component/s: SQL
    • Labels:
      None
    • Urgency:
      Normal
    • Issue & fix info:
      Newcomer, Patch Available
    • Bug behavior facts:
      Deviation from standard, Wrong query result

      Description

      If you invoke a table function as a scalar function, Derby instantiates the ResultSet returned by the table function and returns that ResultSet. This behavior looks wrong. Derby should raise an error if you invoke a table function as a scalar function. Here is an example of the problem:

      ij> values ( badVTI( 'foo' ) );
      1
      ---------------
      BadVTI@1ef69

        Activity

        Hide
        Rick Hillegas added a comment -

        Ported 805443 from trunk to 10.5 branch at subversion revision 805444.

        Show
        Rick Hillegas added a comment - Ported 805443 from trunk to 10.5 branch at subversion revision 805444.
        Hide
        Rick Hillegas added a comment -

        Committed derby-4092-01-aa-noVTIsAsScalarValues.diff at subversion revision 805443.

        Show
        Rick Hillegas added a comment - Committed derby-4092-01-aa-noVTIsAsScalarValues.diff at subversion revision 805443.
        Hide
        Rick Hillegas added a comment -

        The tests ran cleanly for me except for the following, pre-existing heisenbug in NetworkServerMBeanTest. The heisenbug did not recur when I ran the test standalone:

        1) testAttributeAccumulatedConnectionCount(org.apache.derbyTesting.functionTests.tests.management.NetworkServerMBeanTest)java.security.PrivilegedActionException: javax.management.InstanceNotFoundException: org.apache.derby:type=NetworkServer,system=c013800d-0123-2df6-f73c-ffffe1d7aa3e
        at java.security.AccessController.doPrivileged(Native Method)
        at org.apache.derbyTesting.functionTests.tests.management.MBeanTest.getAttribute(MBeanTest.java:379)
        at org.apache.derbyTesting.functionTests.tests.management.NetworkServerMBeanTest.testAttributeAccumulatedConnectionCount(NetworkServerMBeanTest.java:93)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:109)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
        at junit.extensions.TestSetup.run(TestSetup.java:25)
        at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
        at junit.extensions.TestSetup.run(TestSetup.java:25)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
        at junit.extensions.TestSetup.run(TestSetup.java:25)
        at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
        Caused by: javax.management.InstanceNotFoundException: org.apache.derby:type=NetworkServer,system=c013800d-0123-2df6-f73c-ffffe1d7aa3e
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1010)
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(DefaultMBeanServerInterceptor.java:627)
        at com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(JmxMBeanServer.java:659)
        at org.apache.derbyTesting.functionTests.tests.management.MBeanTest$4.run(MBeanTest.java:382)
        ... 41 more

        FAILURES!!!
        Tests run: 10219, Failures: 0, Errors: 1

        Show
        Rick Hillegas added a comment - The tests ran cleanly for me except for the following, pre-existing heisenbug in NetworkServerMBeanTest. The heisenbug did not recur when I ran the test standalone: 1) testAttributeAccumulatedConnectionCount(org.apache.derbyTesting.functionTests.tests.management.NetworkServerMBeanTest)java.security.PrivilegedActionException: javax.management.InstanceNotFoundException: org.apache.derby:type=NetworkServer,system=c013800d-0123-2df6-f73c-ffffe1d7aa3e at java.security.AccessController.doPrivileged(Native Method) at org.apache.derbyTesting.functionTests.tests.management.MBeanTest.getAttribute(MBeanTest.java:379) at org.apache.derbyTesting.functionTests.tests.management.NetworkServerMBeanTest.testAttributeAccumulatedConnectionCount(NetworkServerMBeanTest.java:93) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:109) at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24) at junit.extensions.TestSetup$1.protect(TestSetup.java:21) at junit.extensions.TestSetup.run(TestSetup.java:25) at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57) at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24) at junit.extensions.TestSetup$1.protect(TestSetup.java:21) at junit.extensions.TestSetup.run(TestSetup.java:25) at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24) at junit.extensions.TestSetup$1.protect(TestSetup.java:21) at junit.extensions.TestSetup.run(TestSetup.java:25) at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57) Caused by: javax.management.InstanceNotFoundException: org.apache.derby:type=NetworkServer,system=c013800d-0123-2df6-f73c-ffffe1d7aa3e at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1010) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(DefaultMBeanServerInterceptor.java:627) at com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(JmxMBeanServer.java:659) at org.apache.derbyTesting.functionTests.tests.management.MBeanTest$4.run(MBeanTest.java:382) ... 41 more FAILURES!!! Tests run: 10219, Failures: 0, Errors: 1
        Hide
        Rick Hillegas added a comment -

        Attaching derby-4092-01-aa-noVTIsAsScalarValues.diff. This patch raises an error during the binding of scalar Java return values if a java.sql.ResultSet is seen.

        I have not run regression tests yet although TableFunctionTest runs cleanly with the new test case.

        Touches the following files:

        M java/engine/org/apache/derby/impl/sql/compile/JavaToSQLValueNode.java

        Raise an error during bind() if a scalar value sits on top of a call to a table function.

        M java/engine/org/apache/derby/loc/messages.xml
        M java/shared/org/apache/derby/shared/common/reference/SQLState.java

        A new message for this error state.

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

        A test case to verify this fix.

        Show
        Rick Hillegas added a comment - Attaching derby-4092-01-aa-noVTIsAsScalarValues.diff. This patch raises an error during the binding of scalar Java return values if a java.sql.ResultSet is seen. I have not run regression tests yet although TableFunctionTest runs cleanly with the new test case. Touches the following files: M java/engine/org/apache/derby/impl/sql/compile/JavaToSQLValueNode.java Raise an error during bind() if a scalar value sits on top of a call to a table function. M java/engine/org/apache/derby/loc/messages.xml M java/shared/org/apache/derby/shared/common/reference/SQLState.java A new message for this error state. M java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java A test case to verify this fix.
        Hide
        Rick Hillegas added a comment -

        Triaged July 2, 2009: Assigned normal urgency.

        Show
        Rick Hillegas added a comment - Triaged July 2, 2009: Assigned normal urgency.

          People

          • Assignee:
            Rick Hillegas
            Reporter:
            Rick Hillegas
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development