Re: [HACKERS] \if, \elseif, \else, \endif (was Re: PSQL commands:\quit_if, \quit_unless)

Поиск
Список
Период
Сортировка
От Corey Huinker
Тема Re: [HACKERS] \if, \elseif, \else, \endif (was Re: PSQL commands:\quit_if, \quit_unless)
Дата
Msg-id CADkLM=f3_Sf2EHNBFgLWUA-1PRSJ-qVmyVqFuHjXEgLPWjaJtw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [HACKERS] \if, \elseif, \else, \endif (was Re: PSQL commands:\quit_if, \quit_unless)  (Corey Huinker <corey.huinker@gmail.com>)
Ответы Re: [HACKERS] \if, \elseif, \else, \endif (was Re: PSQL commands:\quit_if, \quit_unless)  (Fabien COELHO <coelho@cri.ensmp.fr>)
Re: \if, \elseif, \else, \endif (was Re: PSQL commands:\quit_if, \quit_unless)  (Fabien COELHO <coelho@cri.ensmp.fr>)
Список pgsql-hackers
On Fri, Mar 17, 2017 at 2:18 PM, Corey Huinker <corey.huinker@gmail.com> wrote:

> \set x 'arg1 arg2'

> \if false
>     \cmd_that_takes_exactly_two_args :x
> \endif

Yeah, throwing errors for bad arguments would also need to be suppressed.

                        regards, tom lane

Ok, barring other feedback, I'm going to take my marching orders as "make each slash command active-aware". To keep that sane, I'm probably going to break out each slash command family into it's own static function.

...and here it is.

v24 highlights:

- finally using git format-patch
- all conditional slash commands broken out into their own functions (exec_command_$NAME) , each one tests if it's in an active branch, and if it's not it consumes the same number of parameters, but discards them. comments for each slash-command family were left as-is, may need to be bulked up.
- TAP tests discarded in favor of one ON_EROR_STOP test for invalid \elif placement
- documentation recommending ON_ERROR_STOP removed, because invalid expressions no longer throw off if-endif balance 
- documentation updated to reflex that contextually-correct-but-invalid boolean expressions are treated as false
- psql_get_variable has a passthrough void pointer now, but I ended up not needing it. Instead, all slash commands in false blocks either fetch OT_NO_EVAL or OT_WHOLE_LINE options. If I'm missing something, let me know.

Вложения

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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: [HACKERS] background sessions
Следующее
От: Robert Haas
Дата:
Сообщение: Re: [HACKERS] createlang/droplang deprecated