db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From be...@apache.org
Subject svn commit: r488672 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Tue, 19 Dec 2006 13:35:15 GMT
Author: bernt
Date: Tue Dec 19 05:35:14 2006
New Revision: 488672

URL: http://svn.apache.org/viewvc?view=rev&rev=488672
Log:
DERBY-2147 Enable code that allows pattern and escape in LIKE predicate to be column references

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/db2Compatibility.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dynamicLikeOptimization.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/db2Compatibility.sql

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java?view=diff&rev=488672&r1=488671&r2=488672
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
Tue Dec 19 05:35:14 2006
@@ -159,22 +159,11 @@
 
 		String pattern = null;
 
-		// pattern cannot be a column
-		if (leftOperand instanceof ColumnReference)
-			throw StandardException.newException(SQLState.LANG_DB2_LIKE_SYNTAX_ERROR);
-
 		// pattern must be a string or a parameter
 
 		if (!(leftOperand.requiresTypeFromContext()) && !(leftOperand.getTypeId().isStringTypeId()))
 			throw StandardException.newException(SQLState.LANG_DB2_FUNCTION_INCOMPATIBLE,
 													 "LIKE", "FUNCTION");
-
-		// escape cannot be a column
-		if (rightOperand != null && rightOperand instanceof ColumnReference)
-		{
-			throw StandardException.newException(SQLState.LANG_INVALID_ESCAPE_CHARACTER,
-										 ((ColumnReference) rightOperand).getColumnName());
-		}
 
 		// escape must be a string or a parameter
 		if ((rightOperand != 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?view=diff&rev=488672&r1=488671&r2=488672
==============================================================================
--- 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 Dec 19 05:35:14 2006
@@ -1187,19 +1187,15 @@
 ERROR 42846: Cannot convert types 'CHAR' to 'BLOB'.
 ij> values cast('a' as blob(1M));
 ERROR 42846: Cannot convert types 'CHAR' to 'BLOB'.
-ij> -- beetle 5294
+ij> -- Test removed: DERBY-2147
+-- beetle 5294
 -- diable column names in the characterExpression and escape clause of a LIKE predicate
-create table likeable (match_me varchar(10), pattern varchar(10), esc varchar(1));
-0 rows inserted/updated/deleted
-ij> insert into likeable values ('foo%bar3', 'fooZ%bar3', 'Z');
-1 row inserted/updated/deleted
-ij> select match_me from likeable where match_me like pattern escape esc;
-ERROR 42824: An operand of LIKE is not a string, or the first operand is not a column.
-ij> select match_me from likeable where match_me like pattern escape 'Z';
-ERROR 42824: An operand of LIKE is not a string, or the first operand is not a column.
-ij> drop table likeable;
-0 rows inserted/updated/deleted
-ij> -- beetle 5298 
+-- create table likeable (match_me varchar(10), pattern varchar(10), esc varchar(1));
+-- insert into likeable values ('foo%bar3', 'fooZ%bar3', 'Z');
+-- select match_me from likeable where match_me like pattern escape esc;
+-- select match_me from likeable where match_me like pattern escape 'Z';
+-- drop table likeable;
+-- beetle 5298 
 -- disable Field Access
 VALUES java.lang.Integer::MAX_VALUE;
 ERROR 42X01: Syntax error: java.lang.Integer::MAX_VALUE.
@@ -1272,23 +1268,18 @@
 MATCH_ME  
 ----------
 foo%bar3  
-ij> -- SQLSTATE=42824
-select match_me from likeable where match_me like pattern escape esc;
-ERROR 42824: An operand of LIKE is not a string, or the first operand is not a column.
-ij> select match_me from likeable where match_me like pattern escape e;
-ERROR 42824: An operand of LIKE is not a string, or the first operand is not a column.
-ij> select match_me from likeable where match_me like pattern escape 'Z';
-ERROR 42824: An operand of LIKE is not a string, or the first operand is not a column.
-ij> select match_me from likeable where match_me like pattern;
-ERROR 42824: An operand of LIKE is not a string, or the first operand is not a column.
-ij> select match_me from likeable where match_me like e;
-ERROR 42824: An operand of LIKE is not a string, or the first operand is not a column.
-ij> -- SQLSTATE=22019
-select match_me from likeable where match_me like 'fooZ%bar3' escape esc;
-ERROR 22019: Invalid escape sequence, 'ESC'. The escape string must be exactly one character.
It cannot be a null or more than one character.
-ij> select match_me from likeable where match_me like 'fooZ%bar3' escape e;
-ERROR 22019: Invalid escape sequence, 'E'. The escape string must be exactly one character.
It cannot be a null or more than one character.
-ij> -- SQLSTATE=42884
+ij> -- Test removed: DERBY-2147
+-- SQLSTATE=42824
+-- select match_me from likeable where match_me like pattern escape esc;
+-- select match_me from likeable where match_me like pattern escape e;
+-- select match_me from likeable where match_me like pattern escape 'Z';
+-- select match_me from likeable where match_me like pattern;
+-- select match_me from likeable where match_me like e;
+-- Test removed: DERBY-2147
+-- SQLSTATE=22019
+-- select match_me from likeable where match_me like 'fooZ%bar3' escape esc;
+-- select match_me from likeable where match_me like 'fooZ%bar3' escape e;
+-- SQLSTATE=42884
 select match_me from likeable where match_me like 'fooZ%bar3' escape 1;
 ERROR 42884: No authorized routine named 'LIKE' of type 'FUNCTION' having compatible arguments
was found.
 ij> select match_me from likeable where match_me like 'fooZ%bar3' escape 1;

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dynamicLikeOptimization.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dynamicLikeOptimization.out?view=diff&rev=488672&r1=488671&r2=488672
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dynamicLikeOptimization.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dynamicLikeOptimization.out
Tue Dec 19 05:35:14 2006
@@ -413,21 +413,29 @@
 1 row inserted/updated/deleted
 ij> -- error
 select match_me from likeable where match_me like pattern escape esc;
-ERROR 42824: An operand of LIKE is not a string, or the first operand is not a column.
+MATCH_ME  
+----------
+foo%bar   
+foo%bar   
+ERROR 22025: Escape character must be followed by escape character, '_', or '%'. It cannot
be followed by any other character or be at the end of the pattern.
 ij> delete from likeable;
 3 rows inserted/updated/deleted
 ij> insert into likeable values ('foo%bar', 'foo%bar', NULL);
 1 row inserted/updated/deleted
 ij> -- should error
 select match_me from likeable where match_me like pattern escape esc;
-ERROR 42824: An operand of LIKE is not a string, or the first operand is not a column.
+MATCH_ME  
+----------
+ERROR 22501: An ESCAPE clause of NULL returns undefined results and is not allowed.
 ij> delete from likeable;
 1 row inserted/updated/deleted
 ij> insert into likeable values ('foo%bar', 'foo%bar', '');
 1 row inserted/updated/deleted
 ij> -- should error
 select match_me from likeable where match_me like pattern escape esc;
-ERROR 42824: An operand of LIKE is not a string, or the first operand is not a column.
+MATCH_ME  
+----------
+ERROR 22019: Invalid escape sequence, ''. The escape string must be exactly one character.
It cannot be a null or more than one character.
 ij> -- Defect 6002/6039
 create table cei(id int, name varchar(192) not null, source varchar(252) not null);
 0 rows inserted/updated/deleted

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/db2Compatibility.sql
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/db2Compatibility.sql?view=diff&rev=488672&r1=488671&r2=488672
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/db2Compatibility.sql
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/db2Compatibility.sql
Tue Dec 19 05:35:14 2006
@@ -805,13 +805,14 @@
 values cast('   ' as blob(1M));
 values cast('a' as blob(1M));
 
+-- Test removed: DERBY-2147
 -- beetle 5294
 -- diable column names in the characterExpression and escape clause of a LIKE predicate
-create table likeable (match_me varchar(10), pattern varchar(10), esc varchar(1));
-insert into likeable values ('foo%bar3', 'fooZ%bar3', 'Z');
-select match_me from likeable where match_me like pattern escape esc;
-select match_me from likeable where match_me like pattern escape 'Z';
-drop table likeable;
+-- create table likeable (match_me varchar(10), pattern varchar(10), esc varchar(1));
+-- insert into likeable values ('foo%bar3', 'fooZ%bar3', 'Z');
+-- select match_me from likeable where match_me like pattern escape esc;
+-- select match_me from likeable where match_me like pattern escape 'Z';
+-- drop table likeable;
 
 -- beetle 5298 
 -- disable Field Access
@@ -854,16 +855,18 @@
 select match_me from likeable where 'foo%bar3' like 'foo%';
 
 
+-- Test removed: DERBY-2147
 -- SQLSTATE=42824
-select match_me from likeable where match_me like pattern escape esc;
-select match_me from likeable where match_me like pattern escape e;
-select match_me from likeable where match_me like pattern escape 'Z';
-select match_me from likeable where match_me like pattern;
-select match_me from likeable where match_me like e;
+-- select match_me from likeable where match_me like pattern escape esc;
+-- select match_me from likeable where match_me like pattern escape e;
+-- select match_me from likeable where match_me like pattern escape 'Z';
+-- select match_me from likeable where match_me like pattern;
+-- select match_me from likeable where match_me like e;
 
+-- Test removed: DERBY-2147
 -- SQLSTATE=22019
-select match_me from likeable where match_me like 'fooZ%bar3' escape esc;
-select match_me from likeable where match_me like 'fooZ%bar3' escape e;
+-- select match_me from likeable where match_me like 'fooZ%bar3' escape esc;
+-- select match_me from likeable where match_me like 'fooZ%bar3' escape e;
 
 -- SQLSTATE=42884
 select match_me from likeable where match_me like 'fooZ%bar3' escape 1;



Mime
View raw message