From: | Jehan-Guillaume de Rorthais <jgdr(at)dalibo(dot)com> |
---|---|
To: | "Daniel Verite" <daniel(at)manitou-mail(dot)org> |
Cc: | Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Pgsql-Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: psql: Add command to use extended query protocol |
Date: | 2022-11-02 16:24:35 |
Message-ID: | 20221102172435.4e8afb2d@karst |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, 02 Nov 2022 16:04:02 +0100
"Daniel Verite" <daniel(at)manitou-mail(dot)org> wrote:
> Jehan-Guillaume de Rorthais wrote:
>
> > As I wrote in my TCE review, would it be possible to use psql vars to set
> > some named parameters for the prepared query? This would looks like:
> >
> > \set p1 foo
> > \set p2 bar
> > SELECT :'p1', :'p2' \gp
>
> As I understand the feature, variables would be passed like this:
>
> \set var1 'foo bar'
> \set var2 'baz''qux'
>
> select $1, $2 \gp :var1 :var2
>
> ?column? | ?column?
> ----------+----------
> foo bar | baz'qux
>
> It appears to work fine with the current patch.
Indeed, nice.
> This is consistent with the fact that PQexecParams passes $N
> parameters ouf of the SQL query (versus injecting them in the text of
> the query)
I was not thinking about injecting them in the texte of the query, this
would not be using the extended protocol anymore, or maybe with no parameter,
but there's no point.
What I was thinking about is psql replacing the variables from the query text
with the $N notation before sending it using PQprepare.
> which is also why no quoting is needed.
Indeed, the quotes were not needed in my example.
Thanks,
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2022-11-02 16:37:42 | Re: Segfault on logical replication to partitioned table with foreign children |
Previous Message | Tom Lane | 2022-11-02 15:37:35 | Re: spinlock support on loongarch64 |