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

Query: POSITION() function works different compare to MySQL POSITION() function

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not a Bug
    • Major
    • feature-backlog
    • 6.5.0
    • query
    • Untriaged
    • Centos 64-bit
    • Yes

    Description

      Build: 6.5.0-3994

      Assume, we have pretty simple bucket in couchbase instance, containing just 3 docs:

      [
       {
       "varchar_field1": "oALDoptAQw"
       },
       {
       "varchar_field1": "jaHVuOoPaC"
       },
       {
       "varchar_field1": "pYYMXixekX"
       }
      ]

      and corresponding data in mysql instance.

      Then run the following queries:

      n1ql:

      SELECT varchar_field1, POSITION(varchar_field1, "o") FROM simple_table_db_58108062_simple_table where varchar_field1 in ['oALDoptAQw', 'pYYMXixekX', 'jaHVuOoPaC']

      which gives the following results:

      [
       {
       "$1": 0,
       "varchar_field1": "oALDoptAQw"
       },
       {
       "$1": 6,
       "varchar_field1": "jaHVuOoPaC"
       },
       {
       "$1": -1,
       "varchar_field1": "pYYMXixekX"
       }
      ]

      and corresponding mysql query:

      SELECT varchar_field1, POSITION( "o" IN varchar_field1) FROM simple_table where varchar_field1 in ('oALDoptAQw', 'pYYMXixekX', 'jaHVuOoPaC');

      which gives the following results:

       
      +----------------+----------------------------------+
      | varchar_field1 | POSITION( "o" IN varchar_field1) |
      +----------------+----------------------------------+
      | oALDoptAQw | 1 |
      | jaHVuOoPaC | 7 |
      | pYYMXixekX | 0 |
      +----------------+----------------------------------+
      

      We see that mysql results are shifted by +1 compare to couchbase results.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            keshav Keshav Murthy
            evgeny.makarenko Evgeny Makarenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty