Re: Variable substitution in psql backtick expansion

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Daniel Verite <daniel(at)manitou-mail(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Variable substitution in psql backtick expansion
Date: 2017-04-03 19:30:09
Message-ID: alpine.DEB.2.20.1704032126450.23892@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> [...] but OTOH "\if sql 1 from table where expr" looks awkward. Given an
> implicit select, I would prefer "\if exists (select 1 from table where
> expr)" but now it's not shorter.

Possibly, but it is just an SQL expression, which looks good in the middle
of an sql script.

> An advantage of prepending the SELECT automatically, is that it
> would prevent people from abusing this syntax by putting
> update/insert/delete or even DDL in there, imagining that this would
> be a success/failure test for these operations.

> Having these fail to execute in the first place, when called by \if,
> seems like a sane failure mode that we would gain incidentally.

Yes, it should be avoided.

--
Fabien.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2017-04-03 19:31:59 Re: parallel explain analyze support not exercised
Previous Message Andrew Dunstan 2017-04-03 19:30:06 Re: [PATCH] few fts functions for jsonb