db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From banda...@apache.org
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 GMT
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)
-	<LEFT_PAREN> setQuantifier() value = additiveExpression(null, 0, false) <RIGHT_PAREN>
-	{
-		return (ValueNode) nodeFactory.getNode(
-								C_NodeTypes.AGGREGATE_NODE,
-								value,
-								methodAliasString, 
-								Boolean.TRUE,
-								methodAliasString, 
-								getContextManager());
-	}
 }
 
 /*
@@ -11574,7 +11561,6 @@
 |	tok = <CONTINUE>
 |	tok = <CONVERT>
 |	tok = <CORRESPONDING>
-|	tok = <COUNT>
 |	tok = <CREATE>
 |	tok = <CURRENT>
 |	tok = <CURRENT_DATE>
@@ -11792,6 +11778,7 @@
 	|	tok = <CONCAT>
 	|	tok = <CONTAINS>
 	|	tok = <CONTENT>
+	|	tok = <COUNT>
 	|   tok = <CS>
 	|	tok = <CURDATE>
 	|	tok = <CURTIME>

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; 



Mime
View raw message