From derby-commits-return-12060-apmail-db-derby-commits-archive=db.apache.org@db.apache.org Tue Sep 08 08:35:06 2009 Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 62376 invoked from network); 8 Sep 2009 08:35:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 Sep 2009 08:35:06 -0000 Received: (qmail 24068 invoked by uid 500); 8 Sep 2009 08:35:06 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 24006 invoked by uid 500); 8 Sep 2009 08:35:05 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 23997 invoked by uid 99); 8 Sep 2009 08:35:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Sep 2009 08:35:05 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Sep 2009 08:35:01 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D451D238886D; Tue, 8 Sep 2009 08:34:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r812387 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/ testing/org/apache/derbyTesting/functionTests/master/ Date: Tue, 08 Sep 2009 08:34:40 -0000 To: derby-commits@db.apache.org From: kahatlen@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090908083440.D451D238886D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kahatlen Date: Tue Sep 8 08:34:40 2009 New Revision: 812387 URL: http://svn.apache.org/viewvc?rev=812387&view=rev Log: DERBY-4369: Give a more useful error message when join specification is missing Made the join specification optional in the grammar. This makes the parser go further before failing because of a missing ON clause, and existing code that emits a more useful error message can be reached. 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=812387&r1=812386&r2=812387&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 Tue Sep 8 08:34:40 2009 @@ -9202,19 +9202,12 @@ TableOperatorNode ton = null; Object[] onOrUsingClause = null; ResultColumnList usingClause = null; - ValueNode onClause; + ValueNode onClause = null; } { - /* 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. - */ - //[ ] [ joinType = joinType() ] 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. @@ -9226,8 +9219,11 @@ */ /* Figure out whether an ON or USING clause was used */ - onClause = (ValueNode) onOrUsingClause[ON_CLAUSE]; - usingClause = (ResultColumnList) onOrUsingClause[USING_CLAUSE]; + if (onOrUsingClause != null) + { + 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=812387&r1=812386&r2=812387&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 Tue Sep 8 08:34:40 2009 @@ -1192,28 +1192,16 @@ 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 42X01: Syntax error: Encountered "" 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. +ERROR 42Y11: A join specification is required with the 'INNER JOIN' clause. ij> -- (2) USING should be disabled in INNER JOIN of SELECT statement SELECT * FROM t1 INNER JOIN t2 USING (col1); -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. +ERROR 42Y11: A join specification is required with the 'INNER JOIN' clause. ij> -- (3) USING should be disabled in INNER JOIN of SELECT statement SELECT * FROM t1 LEFT OUTER JOIN t2 USING (col1); -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. +ERROR 42Y11: A join specification is required with the 'LEFT OUTER JOIN' clause. ij> -- (4) USING should be disabled in INNER JOIN of SELECT statement SELECT * FROM t1 RIGHT OUTER JOIN t2 USING (col1); -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. +ERROR 42Y11: A join specification is required with the 'RIGHT OUTER JOIN' clause. 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=812387&r1=812386&r2=812387&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 Tue Sep 8 08:34:40 2009 @@ -40,21 +40,12 @@ -- no join clause select * from t1 join t2; -ERROR 42X01: Syntax error: Encountered "" 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. +ERROR 42Y11: A join specification is required with the 'INNER JOIN' clause. ij> select * from t1 inner join t2; -ERROR 42X01: Syntax error: Encountered "" 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. +ERROR 42Y11: A join specification is required with the 'INNER JOIN' clause. ij> -- empty column list select * from t1 join t2 using (); -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. +ERROR 42Y11: A join specification is required with the 'INNER JOIN' clause. 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=812387&r1=812386&r2=812387&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 Tue Sep 8 08:34:40 2009 @@ -62,15 +62,9 @@ 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 42X01: Syntax error: Encountered "" 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. +ERROR 42Y11: A join specification is required with the 'LEFT OUTER JOIN' clause. ij> select * from t1 right outer join t2; -ERROR 42X01: Syntax error: Encountered "" 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. +ERROR 42Y11: A join specification is required with the 'RIGHT OUTER JOIN' clause. ij> -- positive tests select t1.c1 from t1 left outer join t2 on t1.c1 = t2.c1; C1