Support external parameters in EXECUTE command

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Support external parameters in EXECUTE command
Date: 2020-02-12 15:00:14
Message-ID: 308bff6b-980c-f992-86c2-f4df12db3de2@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
v1-0001-Support-external-parameters-in-EXECUTE-command.patch text/plain 3.7 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Shichao Jin 2020-02-12 15:41:26 Re: Memory-comparable Serialization of Data Types
Previous Message Tom Lane 2020-02-12 14:46:48 Re: Just for fun: Postgres 20?