Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-2147

LIKE predicate does not accept a pure column reference as righthand operand (gives ERROR 42824)

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 10.3.1.4
    • 10.3.1.4
    • SQL
    • None

    Description

      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> | ....

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            bernt Bernt Johnsen
            olesolberg Ole Solberg
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment