Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-45428

Fix LIKE pattern matching when matching backslashes

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Cheshire-Cat, 6.6.2
    • Fix Version/s: 7.0.0
    • Component/s: query
    • Labels:
      None
    • Triage:
      Untriaged
    • Story Points:
      1
    • Is this a Regression?:
      Unknown

      Description

      Literal LIKE patterns require double escaped backslashes but these may not be correctly interpreted when they precede a wildcard. 

        Attachments

        For Gerrit Dashboard: MB-45428
        # Subject Branch Project Status CR V

          Activity

          Hide
          build-team Couchbase Build Team added a comment -

          Build couchbase-server-7.0.0-4895 contains query commit 7d974aa with commit message:
          MB-45428 Fix LIKE matching when matching backslashes

          Show
          build-team Couchbase Build Team added a comment - Build couchbase-server-7.0.0-4895 contains query commit 7d974aa with commit message: MB-45428 Fix LIKE matching when matching backslashes
          Hide
          build-team Couchbase Build Team added a comment -

          Build couchbase-server-7.0.0-4896 contains query commit 83bf168 with commit message:
          Revert "MB-45428 Fix LIKE matching when matching backslashes"

          Show
          build-team Couchbase Build Team added a comment - Build couchbase-server-7.0.0-4896 contains query commit 83bf168 with commit message: Revert " MB-45428 Fix LIKE matching when matching backslashes"
          Hide
          build-team Couchbase Build Team added a comment -

          Build couchbase-server-7.0.0-4897 contains query commit 00e4cd7 with commit message:
          MB-45428 Fix LIKE matching when matching backslashes

          Show
          build-team Couchbase Build Team added a comment - Build couchbase-server-7.0.0-4897 contains query commit 00e4cd7 with commit message: MB-45428 Fix LIKE matching when matching backslashes
          Hide
          Donald.haggart Donald Haggart added a comment - - edited

          With this change backslashes should be consistently escaped noting that to provide them in string literals, double escaping is necessary since backslash is also the string literal escape character.  Hence

          "\\"

          whenever a LIKE escape character is needed and

          "\\\\"

          whenever a literal backslash is needed.

          Show
          Donald.haggart Donald Haggart added a comment - - edited With this change backslashes should be consistently escaped noting that to provide them in string literals, double escaping is necessary since backslash is also the string literal escape character.  Hence "\\" whenever a LIKE escape character is needed and "\\\\" whenever a literal backslash is needed.
          Hide
          Donald.haggart Donald Haggart added a comment - - edited

          For the record / clarity / future reference:

          SELECT "at the end \\\\" like "% \\\\";

          Does NOT match because the search-space string 

          "at the end \\\\"

          passes through only string literal escaping resulting in the string 

          "at the end \\"

          The LIKE pattern passes first through string literal escaping becoming 

          "% \\"

          and then on to LIKE pattern escaping, becoming

          "% \"

          As noted above, in the LIKE pattern 4 backslashes are needed  whenever a single backslash is to be matched (when passing the pattern as a string literal).

          SELECT "at the end \\\\" like "% \\\\\\\\";

          Uses the correct pattern to match this. 

          Obviously if the pattern is supplied as a parameter the language/environment used to construct the necessary pattern string

          "% \\"

          may have different escaping rules. 

          Show
          Donald.haggart Donald Haggart added a comment - - edited For the record / clarity / future reference: SELECT "at the end \\\\" like "% \\\\" ; Does NOT match because the search-space string  "at the end \\\\" passes through only string literal escaping resulting in the string  "at the end \\" The LIKE pattern passes first through string literal escaping becoming  "% \\" and then on to LIKE pattern escaping, becoming "% \" As noted above, in the LIKE pattern 4 backslashes are needed  whenever a single backslash is to be matched (when passing the pattern as a string literal). SELECT "at the end \\\\" like "% \\\\\\\\" ; Uses the correct pattern to match this.  Obviously if the pattern is supplied as a parameter the language/environment used to construct the necessary pattern string "% \\" may have different escaping rules. 

            People

            Assignee:
            Donald.haggart Donald Haggart
            Reporter:
            Donald.haggart Donald Haggart
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes

                  PagerDuty