LIKE predicate does not accept a pure column reference as righthand operand
(gives ERROR 42824)
-----------------------------------------------------------------------------------------------
Key: DERBY-2147
URL: http://issues.apache.org/jira/browse/DERBY-2147
Project: Derby
Issue Type: Bug
Components: SQL
Affects Versions: 10.3.0.0
Reporter: Ole Solberg
Priority: Minor
Given "create table t (v varchar(32));" the query "select * from t where
'dilldall' like v; " gives ERROR 42824.
The problem is easily bypassed using a cast: "select * from t where 'dilldall'
like cast (v as varchar(32));".
create table t (v varchar(32));
insert into t values ('%lda%');
select * from t where 'dilldall' like v; -- ERROR 42824: An operand of LIKE is
not a string, or the first operand is not a column.
select * from t where 'dilldall' like cast (v as varchar(32)); -- 1 row. OK
select * from t where v like 'dilldall'; -- 0 rows - OK, not a pattern as right
op.
select * from t where cast (v as varchar(32)) like 'dilldall'; -- 0 rows - OK,
not a pattern as right op.
A column reference as a righthand operand should be accepted according to
ISO/IEC 9075-2:1999 (E):
8.5 <like predicate>
<like predicate> ::=
<character like predicate> | <octet like predicate>
<character like predicate> ::=
<character match value> [ NOT ] LIKE <character pattern> [ ESCAPE <escape
character> ]
<character match value> ::= <character value expression>
<character pattern> ::= <character value expression>
6.27 <string value expression>
<character value expression> ::= <concatenation> | <character factor>
<character factor> ::= <character primary> [ <collate clause> ]
<character primary> ::= <value expression primary> | <string value function>
6.23 <value expression>
<value expression primary> ::= <parenthesized value expression> |
<nonparenthesized value expression primary>
<nonparenthesized value expression primary> ::= <unsigned value specification>
| <column reference> | ....
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira