Re: PSQL commands: \quit_if, \quit_unless

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: PSQL commands: \quit_if, \quit_unless
Дата
Msg-id CA+TgmoZB=+CuJt7JTd65OxZa317txdeL-UZpbkxYhS2GQeX+uQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: PSQL commands: \quit_if, \quit_unless  (Fabien COELHO <coelho@cri.ensmp.fr>)
Ответы Re: PSQL commands: \quit_if, \quit_unless  (Fabien COELHO <coelho@cri.ensmp.fr>)
Re: [HACKERS] PSQL commands: \quit_if, \quit_unless  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
On Sat, Dec 3, 2016 at 2:16 AM, Fabien COELHO <coelho@cri.ensmp.fr> wrote:
>> My guess is that something comparable to where pgbench is would be a
>> reasonable target --- not least because I think we should strive to
>> reduce unnecessary differences between psql and pgbench metalanguages.
>>
>> I'm not sure that I'm ready to propose that they should share the same
>> expression engine, but perhaps it's not a totally wacky idea.
>
>
> I'm trying to summarize a proposal for a conditional structure:
>
>  - existing psql ":"-variables can be used, allowing anything from SQL
>   (eg querying about available objects, features, extensions,
>    current settings...)
>
>  - target psql conditional syntax could be:
>
>     \if <expression>
>       ...
>     \elif <...>
>       ...
>     \else
>       ...
>     \endif
>
>  - possible incremental implemention steps on this path:
>
>   (1) minimal condition and expression, compatible with
>       a possible future full-blown expression syntax
>
>      \if :variable
>      \if not :variable -- maybe \if ! :variable
>        ...
>      \endif
>
>   (2) add "\else"
>
>   (3) add "\elif ..." (or maybe "\elsif ..."?)
>
>   (4) add greater but limited expressions, compatible with a full blown
>       expression syntax (eg \if :var/const <comparison-operator> :var/const)
>
>   (5) add full-blown <expression> support for \if, which suggest that
>       it would also be available for \set
>
>
> Does this looks okay, or does it need to be amended?
>
> A few comments:
>
> Given the experience with pgbench and the psql context, I do not think that
> it would really need to go beyond step 2 above, but I agree that I may be
> wrong and it is best to be prepared for that from the start. Given the
> complexity and effort involved with (5), it seems wise to wait for a clearer
> motivation with actual use-cases before going that far.

Well, my vote would be to go all the way to #5 in one commit.
Stopping short of that doesn't seem to me to save enough work to make
much sense.  I don't think we're talking about anything all that
complex, and it will make future improvements a lot simpler.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: Proposal: scan key push down to heap [WIP]
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [COMMITTERS] pgsql: Introduce dynamic shared memory areas.