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

Block modifying a primary index/ any index on views via UI as well.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Fix
    • Major
    • cbq-beta, 4.0.0
    • 4.0.0
    • query
    • Security Level: Public
    • None
    • Untriaged
    • Unknown

    Description

      Via UI , I can copy a "primary" view index to dev mode and make changes to it.

      The queries do not work after that, example.
      1. Create primary index on `beer-sample`
      2. Copy the primary index to dev-mode ( using the UI)
      3. Make some small change in the function

      function (doc, meta) {
      var stringToUtf8Bytes = function (str) {
      var utf8 = unescape(encodeURIComponent(str));
      var bytes = [];
      for (var i = 1; i < str.length; ++i)

      { bytes.push(str.charCodeAt(i)); }

      return bytes;
      };

      emit([160, stringToUtf8Bytes(meta.id)], null);
      }
      // salt: 4088582

      4. Edit/Publish primary index - Should this be allowed ?
      5. Select Query on the bucket – Returns no results.

      Based on earlier scope of Sherlock - Alter index should be disallowed.
      Maybe we should then block the ability via UI too.

      Also, the query not working seems odd.

      Output from the non-working select stmt.
      cbq> select * from `beer-sample` limit 2;
      {
      "requestID": "9b0b02eb-a2ed-4c1b-a76d-c1ee9a7e2688",
      "signature":

      { "*": "*" }

      ,
      "results": [
      ],
      "status": "success",
      "metrics":

      { "elapsedTime": "12.306244ms", "executionTime": "12.143944ms", "resultCount": 0, "resultSize": 0 }

      }

      Explain Output.
      cbq> select * from system:indexes;
      {
      "requestID": "020b1e36-8a6b-42d1-a378-493bd4e0479c",
      "signature":

      { "*": "*" }

      ,
      "results": [
      {
      "indexes":

      { "datastore_id": "http://127.0.0.1:8091", "id": "#primary", "index_key": [ "(meta(`beer-sample`).`id`)" ], "keyspace_id": "beer-sample", "name": "#primary", "namespace_id": "default", "using": "view" }

      }
      ],
      "status": "success",
      "metrics":

      { "elapsedTime": "1.341878ms", "executionTime": "1.202571ms", "resultCount": 1, "resultSize": 397 }

      }

      cbq> explain select * from `beer-sample` limit 2;
      {
      "requestID": "caf08556-a66f-42c0-a6a8-7f71f749d8bd",
      "signature": "json",
      "results": [
      {
      "#operator": "Sequence",
      "~children": [
      {
      "#operator": "Sequence",
      "~children": [

      { "#operator": "PrimaryScan", "index": "#primary", "keyspace": "beer-sample", "namespace": "default", "using": "view" }

      ,
      {
      "#operator": "Parallel",
      "~child": {
      "#operator": "Sequence",
      "~children": [

      { "#operator": "Fetch", "keyspace": "beer-sample", "namespace": "default" }

      ,
      {
      "#operator": "InitialProject",
      "result_terms": [

      { "star": true }

      ]
      },

      { "#operator": "FinalProject" }

      ]
      }
      }
      ]
      },

      { "#operator": "Limit", "expr": "2" }

      ]
      }
      ],
      "status": "success",
      "metrics":

      { "elapsedTime": "1.89391ms", "executionTime": "1.744817ms", "resultCount": 1, "resultSize": 1774 }

      }

      Attachments

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

        Activity

          People

            keshav Keshav Murthy
            ketaki Ketaki Gangal (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty