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

RQG: Difference in subquery results(n1ql vs sql vs oracle) with not in/in (null)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Test Blocker
    • 4.6.0, 5.0.0
    • 5.0.0
    • query
    • 4.5.0-2601
    • Untriaged
    • Centos 64-bit
    • Unknown

    Description

      Difference in results from sql vs n1ql:
       
      Sql queries:
      SELECT 3 not in (null);
       
      Result : null
       
      SELECT 3 in (null);
       
      Result : null
       
      SELECT * FROM  simple_table_1   where primary_key_id=789   WHERE     int_field1  NOT IN       (query returning a null array) ;
      Result: null
       
       
      SELECT * FROM  simple_table_1   where primary_key_id=789   WHERE     int_field1  IN       (query returning a null array) ;
      Result: null
       
       
       
      SELECT * FROM  simple_table_1  t_3 USE KEYS "789"   WHERE     int_field1  NOT IN       (query returning a null array) ;
      Gives 1 result with key as 789.
       Explain of above query gives keyscan.
       
      Without use keys:
       
      SELECT * FROM  simple_table_1  t_3 WHERE     int_field1  NOT IN       (query returning a null array) ;
      Explain of above query gives ValueScan.
      

       
      Following scenario gives different results:
       
      Create bucket default in couchbase
      Create primary index on default.
       
      N1QL Query issued:
      select 3  in (select min(x) from default);
      [
        {
          "$1": false
        }
      ]
       
       
      sql query issued for table test with no documents:
       
      mysql> select 3  in (select min(x) from test);
      +---------------------------------+
      | 3  in (select min(x) from test) |
      +---------------------------------+
      |                            NULL |
      +---------------------------------+
      1 row in set (0.01 sec)
      
      

      Result from oracle is attached.
      It gives no rows for queries like:
      select 4 from dual where 4 in (null);
      select 4 from dual where 4 in (null,6);

      Attachments

        Activity

          People

            Prerna.Manaktala Prerna Manaktala (Inactive)
            Prerna.Manaktala Prerna Manaktala (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