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

With secondary index, EXPLAIN and PREPARE fail when using placeholders

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • cbq-beta, 4.0.0
    • 4.0.0
    • query
    • Security Level: Public
    • sherlock, build 1335
    • Untriaged
    • Unknown

    Description

      When there is a relevant secondary index and one tries to query it with placeholders (positional parameters or named parameters), the request fails due to a JSON marshalling issue.

      To see it on beer-sample in cbq, first create an appropriate index:
      CREATE INDEX cities ON `beer-sample` (city);

      A few queries that work (the one with placeholder just complains that no value was passed for $1):
      SELECT * FROM `beer-sample` WHERE city = 'Wrzburg';
      SELECT * FROM `beer-sample` WHERE city = $1;
      EXPLAIN SELECT * FROM `beer-sample` WHERE city = 'Wrzburg';

      But explain and prepare with the placeholder fail:
      EXPLAIN SELECT * FROM `beer-sample` WHERE city = $1;
      PREPARE SELECT * FROM `beer-sample` WHERE city = $city;

      The response is:
      cbq> EXPLAIN SELECT * FROM `beer-sample` WHERE city = $city;
      {
      "requestID": "716c77ff-8120-4433-82bc-2dc10691b34e",
      "signature": "json",
      "results": [
      ],
      "errors": [

      { "code": 5000, "msg": "Failed to marshal JSON. - cause: json: error calling MarshalJSON for type *plan.Sequence: json: error calling MarshalJSON for type plan.Operator: json: error calling MarshalJSON for type expression.Expression: invalid character '$' looking for beginning of value" }

      ],
      "status": "stopped",
      "metrics":

      { "elapsedTime": "685.526us", "executionTime": "606.07us", "resultCount": 0, "resultSize": 0, "errorCount": 1 }

      }

      Attachments

        Issue Links

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

          Activity

            People

              colm Colm Mchugh (Inactive)
              simonbasle Simon Baslé (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty