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

[UDF] execute prepared statement with positional parameter return empty result

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Neo
    • Neo
    • js-evaluator
    • 7.1.0-1801
    • Untriaged
    • 1
    • Unknown

    Description

      To repro:

      • register function

      curl -s -k -X POST http://172.23.104.91:8093/evaluator/v1/libraries/n1ql -u Administrator:password -H 'content-type: application/json' -d 'function execute_prepare_positional() { var params = ["Lyon"]; var query = N1QL("EXECUTE lyon_airport", params); var acc = []; for (const row of query) { acc.push(row); }            return acc; }' 

      • create function:

      CREATE OR REPLACE FUNCTION execute_prepare_positional() LANGUAGE JAVASCRIPT AS "execute_prepare_positional" AT "n1ql"; 

      • prepare statement:

      prepare lyon_airport as select airportname from `travel-sample`.inventory.airport where city = $1; 

      • execute function:

      Returns empty result:

      cbq> execute function execute_prepare_positional();
      {
          "requestID": "dc43de52-aba6-4cf8-8c82-e659e6c229fa",
          "signature": null,
          "results": [
          []
          ],
          "status": "success",
          "metrics": {
              "elapsedTime": "22.07583ms",
              "executionTime": "21.896501ms",
              "resultCount": 1,
              "resultSize": 2,
              "serviceLoad": 18
          }
      }
       

      Attachments

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

        Activity

          marco.greco Marco Greco added a comment -

          Abhishek Jindal in OpenStatement(), I see that the positional parameters array passed does not contain ["Lyon"], but [nil, "Lyon"].
          If I pass two positional parameters, I get [nil, nil, "Lyon", "parameter2"].
          Could you have a look?

          marco.greco Marco Greco added a comment - Abhishek Jindal in OpenStatement(), I see that the positional parameters array passed does not contain ["Lyon"] , but [nil, "Lyon"] . If I pass two positional parameters, I get [nil, nil, "Lyon", "parameter2"] . Could you have a look?
          marco.greco Marco Greco added a comment -

          FYI, for the testcase, if I change the prepare statement to

          prepare lyon_airport as select airportname from `travel-sample`.inventory.airport where city = $2;
          

          Then the function returns results.

          marco.greco Marco Greco added a comment - FYI, for the testcase, if I change the prepare statement to prepare lyon_airport as select airportname from `travel-sample`.inventory.airport where city = $2; Then the function returns results.

          Pierre Regazzoni This has been fixed in latest build:

          Would request that we test the following positional parameter'ed query again:

          params = ["val1", "val2", "val3"];
          var query = N1QL("EXECUTE lyon_airport", params);
          

          abhishek.jindal Abhishek Jindal added a comment - Pierre Regazzoni This has been fixed in latest build: Would request that we test the following positional parameter'ed query again: params = ["val1", "val2", "val3"]; var query = N1QL("EXECUTE lyon_airport", params);

          Build couchbase-server-7.1.0-1867 contains eventing-ee commit 33225a3 with commit message:
          MB-49824 : Fix positional parameters array allocation

          build-team Couchbase Build Team added a comment - Build couchbase-server-7.1.0-1867 contains eventing-ee commit 33225a3 with commit message: MB-49824 : Fix positional parameters array allocation

          Verified on 7.1.0-2021

          pierre.regazzoni Pierre Regazzoni added a comment - Verified on 7.1.0-2021

          People

            pierre.regazzoni Pierre Regazzoni
            pierre.regazzoni Pierre Regazzoni
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty