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 ba...@apache.org on 2005/09/02 07:10:23 UTC
svn commit: r266286 - in /db/derby/code/trunk/java:
engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
testing/org/apache/derbyTesting/functionTests/master/nonreserved.out
testing/org/apache/derbyTesting/functionTests/tests/lang/nonreserved.sql
Author: bandaram
Date: Thu Sep 1 22:10:17 2005
New Revision: 266286
URL: http://svn.apache.org/viewcvs?rev=266286&view=rev
Log:
DERBY-468: Unreserve COUNT keyword, so it can be used as an identifier.
Submitted by Satheesh Bandaram (satheesh@sourcery.org)
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/nonreserved.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/nonreserved.sql
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj?rev=266286&r1=266285&r2=266286&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 Thu Sep 1 22:10:17 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 "
@@ -8571,23 +8575,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)
- <LEFT_PAREN> setQuantifier() value = additiveExpression(null, 0, false) <RIGHT_PAREN>
- {
- return (ValueNode) nodeFactory.getNode(
- C_NodeTypes.AGGREGATE_NODE,
- value,
- methodAliasString,
- Boolean.TRUE,
- methodAliasString,
- getContextManager());
- }
}
/*
@@ -11594,7 +11581,6 @@
| tok = <CONTINUE>
| tok = <CONVERT>
| tok = <CORRESPONDING>
-| tok = <COUNT>
| tok = <CREATE>
| tok = <CURRENT>
| tok = <CURRENT_DATE>
@@ -11812,6 +11798,7 @@
| tok = <CONCAT>
| tok = <CONTAINS>
| tok = <CONTENT>
+ | tok = <COUNT>
| tok = <CS>
| tok = <CURDATE>
| tok = <CURTIME>
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/nonreserved.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/nonreserved.out?rev=266286&r1=266285&r2=266286&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/nonreserved.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/nonreserved.out Thu Sep 1 22:10:17 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/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/nonreserved.sql
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/nonreserved.sql?rev=266286&r1=266285&r2=266286&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/nonreserved.sql (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/nonreserved.sql Thu Sep 1 22:10:17 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;