[HACKERS] psql - add ability to test whether a variable exists
От
Fabien COELHO
Тема
[HACKERS] psql - add ability to test whether a variable exists
Дата
Msg-id
alpine.DEB.2.20.1708260835520.3627@lancre
Список
Дерево обсуждения
[HACKERS] psql - add ability to test whether a variable exists Fabien COELHO <coelho@cri.ensmp.fr>
Re: [HACKERS] psql - add ability to test whether a variable exists Pavel Stehule <pavel.stehule@gmail.com>
Re: [HACKERS] psql - add ability to test whether a variable exists Fabien COELHO <coelho@cri.ensmp.fr>
Re: [HACKERS] psql - add ability to test whether a variable exists Fabien COELHO <coelho@cri.ensmp.fr>
Re: [HACKERS] psql - add ability to test whether a variable exists Pavel Stehule <pavel.stehule@gmail.com>
Re: [HACKERS] psql - add ability to test whether a variable exists Fabien COELHO <coelho@cri.ensmp.fr>
Re: [HACKERS] psql - add ability to test whether a variable exists Robins Tharakan <tharakan@gmail.com>
Re: [HACKERS] psql - add ability to test whether a variable exists Fabien COELHO <coelho@cri.ensmp.fr>
Re: [HACKERS] psql - add ability to test whether a variable exists Robins Tharakan <tharakan@gmail.com>
Re: [HACKERS] psql - add ability to test whether a variable exists Robins Tharakan <tharakan@gmail.com>
Re: [HACKERS] psql - add ability to test whether a variable exists Fabien COELHO <coelho@cri.ensmp.fr>
Re: [HACKERS] psql - add ability to test whether a variable exists Robins Tharakan <tharakan@gmail.com>
Re: [HACKERS] psql - add ability to test whether a variable exists Fabien COELHO <coelho@cri.ensmp.fr>
Re: [HACKERS] psql - add ability to test whether a variable exists Corey Huinker <corey.huinker@gmail.com>
Hello,
As a follow-up to the \if patch by Corey Huinker, here is a proposal to
allow testing whether a client-side variable exists in psql.
The syntax is as ugly as the current :'var' and :"var" things, but ISTM
that this is the only simple option to have a working SQL-compatible
syntax with both client-side substitution and server side execution. See
the second example below.
-- client side use
psql> \set i 1
psql> \if :?i?
psql> \echo 'i is defined'
psql> \endif
-- use server-side in an SQL expression
psql> SELECT NOT :?VERSION_NUM? OR :'VERSION' <> VERSTION() AS bad_conf \gset
psql> \if :bad_conf \echo 'too bad...' \quit \endif
The other option would be to have some special keyword syntax, say
"defined var", but then it would have to be parsed client side, and how to
do that in an SQL expression is unclear, and moreover it would not look
right in an SQL expression. If it would look like a function call, say
"defined('var')", it would potentially interact with existing server-side
user-defined functions, which is pretty undesirable. Hence the :?...?
proposal above which is limited to variable subsitution syntax.
--
Fabien.
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
В списке pgsql-hackers по дате отправления
От: Fabien COELHO
Дата:
От: Pavel Stehule
Дата: