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 18:19:20 +0300
Message-ID: <36771268-3624-8f20-9e31-6598c15a1ee8@postgrespro.ru> (raw)
In-Reply-To: <CAFj8pRBk-6DhB70PFhpHXAgVWQ_OPU9xXsnN8LRRwdNSYGr+bg@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>
	<e40d6745-1b47-0fbe-b344-185ea317fd60@postgrespro.ru>
	<CAFj8pRBk-6DhB70PFhpHXAgVWQ_OPU9xXsnN8LRRwdNSYGr+bg@mail.gmail.com>

On 05.03.2018 18:01, Pavel Stehule wrote:
>
> It is most correct when you thinking about it.
>
> 1. :xx is out of SQL syntax, so can by safely used. There is not risk 
> of unwanted usage.
But there is absence of wanted usage too.
>
> 2. but string literal can contain :xxx symbols and not necessary it 
> means so it should be usage of psql variable - so additional syntax 
> for disabling evaluation should be necessary
Yes and Oracle sqlplus (I khow than you know this tool) has special 
command to control this: set define ...

>
> Unfortunately DO command is half baked - and doesn't support 
> parameters. I am working on schema variables and I hope it will be a 
> solution of this issue:
>
> CREATE VARIABLE var as integer;
>
> LET var = :psqlintvar;
>
> DO $$
> BEGIN
>   RAISE NOTICE '%', var;
> END;
> $$;
>

It will be great. I already commented it in your blog.

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

view thread (11+ messages)  latest in thread

Message-ID: <36771268-3624-8f20-9e31-6598c15a1ee8@postgrespro.ru>
Permalink:  ../36771268-3624-8f20-9e31-6598c15a1ee8@postgrespro.ru/
Also on:    postgresql.org/message-id/36771268-3624-8f20-9e31-6598c15a1ee8@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: <36771268-3624-8f20-9e31-6598c15a1ee8@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> <CAFj8pRBk-6DhB70PFhpHXAgVWQ_OPU9xXsnN8LRRwdNSYGr+bg@mail.gmail.com> <36771268-3624-8f20-9e31-6598c15a1ee8@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