You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by rh...@apache.org on 2009/08/18 17:08:18 UTC
svn commit: r805443 - in /db/derby/code/trunk/java:
engine/org/apache/derby/impl/sql/compile/ engine/org/apache/derby/loc/
shared/org/apache/derby/shared/common/reference/
testing/org/apache/derbyTesting/functionTests/tests/lang/
Author: rhillegas
Date: Tue Aug 18 15:08:18 2009
New Revision: 805443
URL: http://svn.apache.org/viewvc?rev=805443&view=rev
Log:
DERBY-4092: Don't allow invocations of table functions in contexts which expect a scalar function return value.
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaToSQLValueNode.java
db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml
db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaToSQLValueNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaToSQLValueNode.java?rev=805443&r1=805442&r2=805443&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaToSQLValueNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaToSQLValueNode.java Tue Aug 18 15:08:18 2009
@@ -21,6 +21,7 @@
package org.apache.derby.impl.sql.compile;
+import org.apache.derby.catalog.TypeDescriptor;
import org.apache.derby.iapi.sql.dictionary.DataDictionary;
import org.apache.derby.iapi.types.DataTypeDescriptor;
import org.apache.derby.iapi.types.StringDataValue;
@@ -251,6 +252,13 @@
throw StandardException.newException(SQLState.LANG_NO_CORRESPONDING_S_Q_L_TYPE,
javaNode.getJavaTypeName());
}
+
+ TypeDescriptor catalogType = dts.getCatalogType();
+
+ if ( catalogType.getTypeName().equals( "java.sql.ResultSet" ) )
+ {
+ throw StandardException.newException(SQLState.LANG_TABLE_FUNCTION_NOT_ALLOWED);
+ }
setType(dts);
Modified: db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml?rev=805443&r1=805442&r2=805443&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml Tue Aug 18 15:08:18 2009
@@ -2768,6 +2768,11 @@
<arg>className</arg>
</msg>
+ <msg>
+ <name>42ZB6</name>
+ <text>A scalar value is expected, not a row set returned by a table function.</text>
+ </msg>
+
</family>
Modified: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java?rev=805443&r1=805442&r2=805443&view=diff
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java (original)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java Tue Aug 18 15:08:18 2009
@@ -1092,6 +1092,7 @@
String LANG_XML_NOT_ALLOWED_DJRS = "42ZB3";
String LANG_NOT_TABLE_FUNCTION = "42ZB4";
String LANG_NO_COSTING_CONSTRUCTOR = "42ZB5";
+ String LANG_TABLE_FUNCTION_NOT_ALLOWED = "42ZB6";
//following 3 matches the DB2 sql states
String LANG_DECLARED_GLOBAL_TEMP_TABLE_ONLY_IN_SESSION_SCHEMA = "428EK";
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java?rev=805443&r1=805442&r2=805443&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java Tue Aug 18 15:08:18 2009
@@ -925,6 +925,8 @@
subqueryTest();
coercionTest();
+
+ miscBugs();
}
/**
@@ -1621,6 +1623,51 @@
/**
* <p>
+ * Miscellaneous bugs.
+ * </p>
+ */
+ private void miscBugs()
+ throws Exception
+ {
+ derby_4092();
+ }
+
+ /**
+ * <p>
+ * Don't allow table functions to appear where scalar functions are expected.
+ * </p>
+ */
+ private void derby_4092()
+ throws Exception
+ {
+ goodStatement
+ (
+ "create function derby_4092()\n" +
+ "returns TABLE\n" +
+ " (\n" +
+ " column0 varchar( 10 ),\n" +
+ " column1 varchar( 10 )\n" +
+ " )\n" +
+ "language java\n" +
+ "parameter style DERBY_JDBC_RESULT_SET\n" +
+ "no sql\n" +
+ "external name '" + getClass().getName() + ".returnsACoupleRows'\n"
+ );
+
+ expectError
+ (
+ "42ZB6",
+ "values( derby_4092() )"
+ );
+ expectError
+ (
+ "42ZB6",
+ "select derby_4092(), tablename from sys.systables"
+ );
+ }
+
+ /**
+ * <p>
* Make the input rows for the coercion function.
* </p>
*/