db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1480909 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/CallStatementNode.java testing/org/apache/derbyTesting/functionTests/tests/lang/LangProcedureTest.java
Date Fri, 10 May 2013 07:58:14 GMT
Author: kahatlen
Date: Fri May 10 07:58:13 2013
New Revision: 1480909

URL: http://svn.apache.org/r1480909
Log:
DERBY-6212: NullPointerException when calling a procedure with sub-query as argument

Raise a syntax error instead of a NullPointerException if a sub-query
is given as argument to a CALL statement.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CallStatementNode.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangProcedureTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CallStatementNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CallStatementNode.java?rev=1480909&r1=1480908&r2=1480909&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CallStatementNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CallStatementNode.java
Fri May 10 07:58:13 2013
@@ -122,15 +122,24 @@ public class CallStatementNode extends D
 		if (SanityManager.DEBUG)
 			SanityManager.ASSERT((dd != null), "Failed to get data dictionary");
 
+        SubqueryList subqueries = (SubqueryList) getNodeFactory().getNode(
+                C_NodeTypes.SUBQUERY_LIST, getContextManager());
+
 		getCompilerContext().pushCurrentPrivType(getPrivType());
 		methodCall = (JavaToSQLValueNode) methodCall.bindExpression(
 							(FromList) getNodeFactory().getNode(
 								C_NodeTypes.FROM_LIST,
 								getNodeFactory().doJoinOrderOptimization(),
 								getContextManager()), 
-							null,
+                            subqueries,
 							null);
 
+        // Don't allow sub-queries in CALL statements.
+        if (subqueries.size() != 0) {
+            throw StandardException.newException(
+                    SQLState.LANG_INVALID_CALL_STATEMENT);
+        }
+
 		// Disallow creation of BEFORE triggers which contain calls to 
 		// procedures that modify SQL data. 
   		checkReliability();

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangProcedureTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangProcedureTest.java?rev=1480909&r1=1480908&r2=1480909&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangProcedureTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangProcedureTest.java
Fri May 10 07:58:13 2013
@@ -48,6 +48,7 @@ import org.apache.derbyTesting.junit.Tes
 public class LangProcedureTest extends BaseJDBCTestCase {
 
     private final static String LANG_STRING_TRUNCATION = "22001";
+    private final static String LANG_INVALID_CALL_STATEMENT = "42X74";
     private final String thisClassName = getClass().getName();
 
     public LangProcedureTest(String name) {
@@ -202,6 +203,10 @@ public class LangProcedureTest extends B
             "42X15", s,
             "call syscs_util.syscs_set_database_property(\"foo\", \"bar\")");
 
+        // Not so long ago (DERBY-6212) this caused a NullPointerException.
+        assertCompileError(LANG_INVALID_CALL_STATEMENT,
+          "call syscs_util.syscs_set_database_property('foo', (values 'bar'))");
+
         s.close();
     }
 



Mime
View raw message