Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 26308 invoked from network); 2 Sep 2005 18:23:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 Sep 2005 18:23:14 -0000 Received: (qmail 72787 invoked by uid 500); 2 Sep 2005 18:23:14 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 72751 invoked by uid 500); 2 Sep 2005 18:23:13 -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 72738 invoked by uid 99); 2 Sep 2005 18:23:13 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 02 Sep 2005 11:23:13 -0700 Received: (qmail 26299 invoked by uid 65534); 2 Sep 2005 18:23:12 -0000 Message-ID: <20050902182312.26298.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r267247 - in /db/derby/code/branches/10.1/java: engine/org/apache/derby/impl/sql/compile/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/tests/lang/ Date: Fri, 02 Sep 2005 18:23:12 -0000 To: derby-commits@db.apache.org From: bandaram@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: bandaram Date: Fri Sep 2 11:23:07 2005 New Revision: 267247 URL: http://svn.apache.org/viewcvs?rev=267247&view=rev Log: DERBY-468: Unreserve COUNT keyword, so it can be used as an identifier. Merged from trunk to 10.1 branch. Submitted by Satheesh Bandaram (satheesh@sourcery.org) Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/nonreserved.out db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/nonreserved.sql Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj?rev=267247&r1=267246&r2=267247&view=diff ============================================================================== --- db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj (original) +++ db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj Fri Sep 2 11:23:07 2005 @@ -986,7 +986,6 @@ switch (getToken(1).kind) { - case COUNT: case MAX: case AVG: case MIN: @@ -995,6 +994,11 @@ retval = true; break; + case COUNT: + // COUNT is not a reserved word + // This may eclipse use of COUNT as a function or a procedure that is probably what we want + if (getToken(2).kind == LEFT_PAREN) + retval = true; default: // Not a built-in aggregate - assume the first token is an // identifier, and see whether it is followed by " ( DISTINCT " @@ -8557,23 +8561,6 @@ { return aggExpr; } -| - /* - ** If we know we have a distinct, then we can catch - ** a user aggregate here; otherwise, we have to generate - ** a staticMethodNode and fix it up later. - */ - methodAliasString = identifier(Limits.MAX_IDENTIFIER_LENGTH, true) - setQuantifier() value = additiveExpression(null, 0, false) - { - return (ValueNode) nodeFactory.getNode( - C_NodeTypes.AGGREGATE_NODE, - value, - methodAliasString, - Boolean.TRUE, - methodAliasString, - getContextManager()); - } } /* @@ -11574,7 +11561,6 @@ | tok = | tok = | tok = -| tok = | tok = | tok = | tok = @@ -11792,6 +11778,7 @@ | tok = | tok = | tok = + | tok = | tok = | tok = | tok = Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/nonreserved.out URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/nonreserved.out?rev=267247&r1=267246&r2=267247&view=diff ============================================================================== --- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/nonreserved.out (original) +++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/nonreserved.out Fri Sep 2 11:23:07 2005 @@ -401,4 +401,58 @@ ij> drop table LOCKS; 0 rows inserted/updated/deleted ij> remove locks; +ij> -- making COUNT keyword nonreserved as fix for Derby- +create table count(i int); +0 rows inserted/updated/deleted +ij> drop table count; +0 rows inserted/updated/deleted +ij> create table t1 (count int); +0 rows inserted/updated/deleted +ij> drop table t1; +0 rows inserted/updated/deleted +ij> create table count(count int); +0 rows inserted/updated/deleted +ij> insert into count values (1); +1 row inserted/updated/deleted +ij> select * from count; +COUNT +----------- +1 +ij> select count from count; +COUNT +----------- +1 +ij> select count from count where count=1; +COUNT +----------- +1 +ij> select count.count from count; +COUNT +----------- +1 +ij> prepare count as 'select * from count'; +ij> create index count on count(count); +0 rows inserted/updated/deleted +ij> drop table count; +0 rows inserted/updated/deleted +ij> remove count; +ij> create table t1(i int); +0 rows inserted/updated/deleted +ij> insert into t1 values -1,2,-3,4,-5,6,-7,8,-9,0; +10 rows inserted/updated/deleted +ij> create function count(i int) returns int no sql +external name 'java.lang.Math.abs' language java parameter style java; +0 rows inserted/updated/deleted +ij> select count(*) from t1; +1 +----------- +10 +ij> select count(i) from t1; +1 +----------- +10 +ij> select * from t1 where count(i)=i; +ERROR 42903: Invalid use of an aggregate function. +ij> drop table t1; +0 rows inserted/updated/deleted ij> Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/nonreserved.sql URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/nonreserved.sql?rev=267247&r1=267246&r2=267247&view=diff ============================================================================== --- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/nonreserved.sql (original) +++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/nonreserved.sql Fri Sep 2 11:23:07 2005 @@ -182,3 +182,28 @@ create index locks on locks(locks); drop table LOCKS; remove locks; + +-- making COUNT keyword nonreserved as fix for Derby- +create table count(i int); +drop table count; +create table t1 (count int); +drop table t1; +create table count(count int); +insert into count values (1); +select * from count; +select count from count; +select count from count where count=1; +select count.count from count; +prepare count as 'select * from count'; +create index count on count(count); +drop table count; +remove count; +create table t1(i int); +insert into t1 values -1,2,-3,4,-5,6,-7,8,-9,0; +create function count(i int) returns int no sql +external name 'java.lang.Math.abs' language java parameter style java; + +select count(*) from t1; +select count(i) from t1; +select * from t1 where count(i)=i; +drop table t1;