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

Wrong results when filter has conditional query parameters

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Critical
    • 7.0.5
    • 7.0.4
    • query
    • 1

    Description

      create index ix1 on default(c1,c2);
       
      upsert into default values ("k01",{"c1":1, "c2":5});
      select count(1) FROM default AS d WHERE d.c1 = 1 AND ((d.c2 = 6 AND IFMISSINGORNULL(1,"") != "" ) OR IFMISSINGORNULL(1,"") = "");
       
      --gives 0  correct answer
      select count(1) FROM default AS d WHERE d.c1 = 1 AND ((d.c2 = 6 AND IFMISSINGORNULL($qp1,"") != "" ) OR IFMISSINGORNULL($qp1,"") = "");
       
      -- gives 1 wrong answer it not even depends on $qp1 no complain because it used index aggregates the spans not exact
       
      explain select count(1) FROM default AS d WHERE d.c1 = 1 AND ((d.c2 = 6 AND IFMISSINGORNULL($qp1,"") != "" ) OR IFMISSINGORNULL($qp1,"") = "");
       
       
      {
          "requestID": "367dbde2-d3f3-4365-a518-696f5826ba14",
          "signature": "json",
          "results": [
          {
              "plan": {
                  "#operator": "Sequence",
                  "~children": [
                      {
                          "#operator": "IndexScan3",
                          "as": "d",
                          "covers": [
                              "cover ((`d`.`c1`))",
                              "cover ((`d`.`c2`))",
                              "cover ((meta(`d`).`id`))",
                              "cover (count(1))"
                          ],
                          "index": "ix1",
                         "index_group_aggs": {
                              "aggregates": [
                                  {
                                      "aggregate": "COUNT",
                                      "expr": "1",
                                      "id": 3,
                                      "keypos": -1
                                  }
                              ]
                          },
                          "index_id": "f8939e87c23640f4",
                          "index_projection": {
                              "entry_keys": [
                                  3
                              ]
                          },
                          "keyspace": "default",
                          "namespace": "default",
                          "spans": [
                              {
                                  "exact": true,
                                  "range": [
                                      {
                                          "high": "1",
                                          "inclusion": 3,
                                          "low": "1"
                                      },
                                      {
                                          "high": "6",
       
                                       "inclusion": 3,
                                          "low": "6"
                                      }
                                  ]
                              },
                              {
                                  "exact": true,
                                  "range": [
                                      {
                                          "high": "1",
                                          "inclusion": 3,
                                          "low": "1"
                                      }
                                  ]
                              }
                          ],
                          "using": "gsi"
                      },
                      {
                          "#operator": "Parallel",
                          "~child": {
                              "#operator": "Sequence",
                              "~children": [
                                  {
                                      "#operator": "InitialProject",
                                      "result_terms": [
                                          {
                                              "expr": "cover (count(1))"
                                          }
                         }
                                      ]
                                  }
                              ]
                          }
                      }
                  ]
              },
              "text": "select count(1) FROM default AS d WHERE d.c1 = 1 AND ((d.c2 = 6 AND IFMISSINGORNULL($qp1,\"\") != \"\" ) OR IFMISSINGORNULL($qp1,\"\") = \"\");"
          }
          ],
          "status": "success",
          "metrics": {
              "elapsedTime": "2.715615ms",
              "executionTime": "2.527752ms",
              "resultCount": 1,
              "resultSize": 3011,
              "serviceLoad": 3
          }
      }
      

      Attachments

        Issue Links

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

          Activity

            People

              pierre.regazzoni Pierre Regazzoni
              Sitaram.Vemulapalli Sitaram Vemulapalli
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                PagerDuty