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 ka...@apache.org on 2009/09/09 13:40:46 UTC

svn commit: r812895 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/ testing/org/apache/derbyTesting/functionTests/master/

Author: kahatlen
Date: Wed Sep  9 11:40:46 2009
New Revision: 812895

URL: http://svn.apache.org/viewvc?rev=812895&view=rev
Log:
DERBY-4369: Give a more useful error message when join specification is missing

Backed out revision 812387 since it introduced an ambiguity in the
grammar, and also because making the join specification optional
appeared to be unnecessary for DERBY-4355.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/db2Compatibility.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/innerjoin.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/outerjoin.out

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj?rev=812895&r1=812894&r2=812895&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj Wed Sep  9 11:40:46 2009
@@ -9202,12 +9202,19 @@
 	TableOperatorNode	ton = null;
 	Object[]			onOrUsingClause = null;
 	ResultColumnList	usingClause = null;
-	ValueNode			onClause = null;
+	ValueNode			onClause;
 }
 {
+	/* RESOLVE - If we ever support NATURAL JOIN then we will need to break up
+	 * this rule.  Right now the joinSpecification() is non-optional.  This
+	 * allows us to build the Join tree from left to right. With NATURAL JOINS
+	 * there is no joinSpecification() and we would want to build the tree from
+	 * right to left.
+	 */
+	//[ <NATURAL> ] 
 		[ joinType = joinType() ] <JOIN>
 		rightRSN = tableReferenceTypes(nestedInParens) 
-		[ onOrUsingClause = joinSpecification(leftRSN, rightRSN) ]
+		onOrUsingClause = joinSpecification(leftRSN, rightRSN)
 	{
 		/* If NATURAL OR UNION is specified, then no joinSpecification()
 		 * is required, otherwise it is required.
@@ -9219,11 +9226,8 @@
 		 */
 
 		/* Figure out whether an ON or USING clause was used */
-		if (onOrUsingClause != null)
-		{
-			onClause = (ValueNode) onOrUsingClause[ON_CLAUSE];
-			usingClause = (ResultColumnList) onOrUsingClause[USING_CLAUSE];
-		}
+		onClause = (ValueNode) onOrUsingClause[ON_CLAUSE];
+		usingClause = (ResultColumnList) onOrUsingClause[USING_CLAUSE];
 
 		if (onClause == null && usingClause == null)
 		{

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/db2Compatibility.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/db2Compatibility.out?rev=812895&r1=812894&r2=812895&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/db2Compatibility.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/db2Compatibility.out Wed Sep  9 11:40:46 2009
@@ -1192,16 +1192,28 @@
 ij> -- CROSS JOIN not supported in both Cloudscape and DB2 mode and that is why rather than getting feature not implemented, we will get syntax error
 -- (1) CROSS JOIN should be disabled in FROM clause of SELECT statement
 SELECT * FROM t1 CROSS JOIN t2;
-ERROR 42Y11: A join specification is required with the 'INNER JOIN' clause.
+ERROR 42X01: Syntax error: Encountered "<EOF>" at line 3, column 30.
+Issue the 'help' command for general information on IJ command syntax.
+Any unrecognized commands are treated as potential SQL commands and executed directly.
+Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
 ij> -- (2) USING should be disabled in INNER JOIN of SELECT statement
 SELECT * FROM t1 INNER JOIN t2 USING (col1);
-ERROR 42Y11: A join specification is required with the 'INNER JOIN' clause.
+ERROR 42X01: Syntax error: Encountered "USING" at line 2, column 32.
+Issue the 'help' command for general information on IJ command syntax.
+Any unrecognized commands are treated as potential SQL commands and executed directly.
+Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
 ij> -- (3) USING should be disabled in INNER JOIN of SELECT statement
 SELECT * FROM t1 LEFT OUTER JOIN t2 USING (col1);
-ERROR 42Y11: A join specification is required with the 'LEFT OUTER JOIN' clause.
+ERROR 42X01: Syntax error: Encountered "USING" at line 2, column 37.
+Issue the 'help' command for general information on IJ command syntax.
+Any unrecognized commands are treated as potential SQL commands and executed directly.
+Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
 ij> -- (4) USING should be disabled in INNER JOIN of SELECT statement
 SELECT * FROM t1 RIGHT OUTER JOIN t2 USING (col1);
-ERROR 42Y11: A join specification is required with the 'RIGHT OUTER JOIN' clause.
+ERROR 42X01: Syntax error: Encountered "USING" at line 2, column 38.
+Issue the 'help' command for general information on IJ command syntax.
+Any unrecognized commands are treated as potential SQL commands and executed directly.
+Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
 ij> -- (5) TRUE and FALSE constants should be disabled in WHERE clause of SELECT statement
 SELECT * FROM t1 INNER JOIN t2 ON t1.col1 = t2.col1 WHERE true;
 ERROR 42X01: Syntax error: true.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/innerjoin.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/innerjoin.out?rev=812895&r1=812894&r2=812895&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/innerjoin.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/innerjoin.out Wed Sep  9 11:40:46 2009
@@ -40,12 +40,21 @@
 
 -- no join clause
 select * from t1 join t2;
-ERROR 42Y11: A join specification is required with the 'INNER JOIN' clause.
+ERROR 42X01: Syntax error: Encountered "<EOF>" at line 4, column 24.
+Issue the 'help' command for general information on IJ command syntax.
+Any unrecognized commands are treated as potential SQL commands and executed directly.
+Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
 ij> select * from t1 inner join t2;
-ERROR 42Y11: A join specification is required with the 'INNER JOIN' clause.
+ERROR 42X01: Syntax error: Encountered "<EOF>" at line 1, column 30.
+Issue the 'help' command for general information on IJ command syntax.
+Any unrecognized commands are treated as potential SQL commands and executed directly.
+Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
 ij> -- empty column list
 select * from t1 join t2 using ();
-ERROR 42Y11: A join specification is required with the 'INNER JOIN' clause.
+ERROR 42X01: Syntax error: Encountered "using" at line 2, column 26.
+Issue the 'help' command for general information on IJ command syntax.
+Any unrecognized commands are treated as potential SQL commands and executed directly.
+Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
 ij> -- non-boolean join clause
 select * from t1 join t2 on 1;
 ERROR 42Y12: The ON clause of a JOIN is a 'INTEGER' expression.  It must be a BOOLEAN expression.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/outerjoin.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/outerjoin.out?rev=812895&r1=812894&r2=812895&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/outerjoin.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/outerjoin.out Wed Sep  9 11:40:46 2009
@@ -62,9 +62,15 @@
 Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
 ij> -- no join clause
 select * from t1 left outer join t2;
-ERROR 42Y11: A join specification is required with the 'LEFT OUTER JOIN' clause.
+ERROR 42X01: Syntax error: Encountered "<EOF>" at line 2, column 35.
+Issue the 'help' command for general information on IJ command syntax.
+Any unrecognized commands are treated as potential SQL commands and executed directly.
+Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
 ij> select * from t1 right outer join t2;
-ERROR 42Y11: A join specification is required with the 'RIGHT OUTER JOIN' clause.
+ERROR 42X01: Syntax error: Encountered "<EOF>" at line 1, column 36.
+Issue the 'help' command for general information on IJ command syntax.
+Any unrecognized commands are treated as potential SQL commands and executed directly.
+Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
 ij> -- positive tests
 select t1.c1 from t1 left outer join t2 on t1.c1 = t2.c1;
 C1