pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Pavel Luzanov <p.luzanov@postgrespro.ru>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: psql variables in the DO command
Date: Mon, 5 Mar 2018 17:02:40 +0300
Message-ID: <e40d6745-1b47-0fbe-b344-185ea317fd60@postgrespro.ru> (raw)
In-Reply-To: <CAFj8pRB=Fb1gp+CorX82Qnz6aB34pkW3aOLCNFYNtcc-gAgM0Q@mail.gmail.com>
References: <5bae153c-ade4-ad24-bd46-857993240cfd@postgrespro.ru>
	<CAFj8pRCf0=rnpccADpt6tZepjxQneJ_Tz900Owjbd6jZAxChDQ@mail.gmail.com>
	<f80e9cbb-75e8-d349-e5e9-6d33abca259b@postgrespro.ru>
	<CAFj8pRB=Fb1gp+CorX82Qnz6aB34pkW3aOLCNFYNtcc-gAgM0Q@mail.gmail.com>

On 05.03.2018 16:56, Pavel Stehule wrote:
>
>>
>>         I can't use psql variable in the DO command. Is it
>>         intentional behavior?
>>
>>
>>     yes. psql variables living on client side, and are not accessible
>>     from server side . DO command is executed on server side.
>
>     But SELECT command also executed on a server side ))
>     I thought that the command is sent to the server after variable's
>     replacement.
>
>
> The psql variables are injected into SQL string before execution 
> (before SQL string is sent to server). But this injection is disabled 
> inside strings - and body of DO command is passed as string.
Yes, now I understand this. But at first glance this is not an obvious 
behavior.

-----
Pavel Luzanov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

view thread (11+ messages)  latest in thread

Message-ID: <e40d6745-1b47-0fbe-b344-185ea317fd60@postgrespro.ru>
Permalink:  ../e40d6745-1b47-0fbe-b344-185ea317fd60@postgrespro.ru/
Also on:    postgresql.org/message-id/e40d6745-1b47-0fbe-b344-185ea317fd60@postgrespro.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: p.luzanov@postgrespro.ru, pavel.stehule@gmail.com
  Subject: Re: psql variables in the DO command
  In-Reply-To: <e40d6745-1b47-0fbe-b344-185ea317fd60@postgrespro.ru>
  References: <5bae153c-ade4-ad24-bd46-857993240cfd@postgrespro.ru> <CAFj8pRCf0=rnpccADpt6tZepjxQneJ_Tz900Owjbd6jZAxChDQ@mail.gmail.com> <f80e9cbb-75e8-d349-e5e9-6d33abca259b@postgrespro.ru> <CAFj8pRB=Fb1gp+CorX82Qnz6aB34pkW3aOLCNFYNtcc-gAgM0Q@mail.gmail.com> <e40d6745-1b47-0fbe-b344-185ea317fd60@postgrespro.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox