Support external parameters in EXECUTE command - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Support external parameters in EXECUTE command
Date
Msg-id 308bff6b-980c-f992-86c2-f4df12db3de2@2ndquadrant.com
Whole thread Raw
Responses Re: Support external parameters in EXECUTE command  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Continuing the discussion in [0], here is a patch that allows parameter 
references in the arguments of the EXECUTE command.  The main purpose is 
submitting protocol-level parameters, but the added regression test case 
shows another way to exercise it.

What's confusing is that the code already contains a reference that 
indicates that this should be possible:

     /* Evaluate parameters, if any */
     if (entry->plansource->num_params > 0)
     {
         /*
          * Need an EState to evaluate parameters; must not delete it 
till end
          * of query, in case parameters are pass-by-reference.  Note 
that the
          * passed-in "params" could possibly be referenced in the parameter
          * expressions.
          */
         estate = CreateExecutorState();
         estate->es_param_list_info = params;
         paramLI = EvaluateParams(pstate, entry, stmt->params, estate);
     }

I'm not sure what this is supposed to do without my patch on top of it. 
If I remove the estate->es_param_list_info assignment, no tests fail 
(except the one I added).  Either this is a leftover from previous 
variants of this code (as discussed in [0]), or there is something I 
haven't understood.


[0]: 
https://www.postgresql.org/message-id/flat/6e7aa4a1-be6a-1a75-b1f9-83a678e5184a%402ndquadrant.com

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Just for fun: Postgres 20?
Next
From: Shichao Jin
Date:
Subject: Re: Memory-comparable Serialization of Data Types