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

Поиск
Список
Период
Сортировка
От Corey Huinker
Тема Re: \if, \elseif, \else, \endif (was Re: [HACKERS] PSQL commands:\quit_if, \quit_unless)
Дата
Msg-id CADkLM=d1pmBN5x+X4Hm46UHOXHSdTCVpToC6ZPEAFM7T8UYEnw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: \if, \elseif, \else, \endif (was Re: [HACKERS] PSQL commands:\quit_if, \quit_unless)  (Fabien COELHO <coelho@cri.ensmp.fr>)
Ответы Re: \if, \elseif, \else, \endif (was Re: [HACKERS] PSQL commands:\quit_if, \quit_unless)  (Fabien COELHO <coelho@cri.ensmp.fr>)
Список pgsql-hackers
Hmmm. ISTM that control-c must at least reset the stack, otherwise their is not easy way to get out. What can be left to another patch is doing a control-C for contents and then another one for the stack when there is no content.

And so it shall be.
 
- put Fabien's tap test in place verbatim

Hmmm. That was really just a POC... I would suggest some more tests, eg:

  # elif error
  "\\if false\n\\elif error\n\\endif\n"

  # ignore commands on error (stdout must be empty)
  "\\if error\n\\echo NO\n\\else\n\\echo NO\n\\endif\n"

Those are already in the regression (around line 2763 of expected/psql.out), are you saying we should have them in TAP as well? Should we only do TAP tests?

Anyway, here's the Ctrl-C behavior:

# \if true
new \if is true, executing commands
# \echo msg
msg
# ^C
escaped \if, executing commands
# \if false
new \if is false, ignoring commands until next \elif, \else, or \endif
# \echo msg
inside inactive branch, command ignored.
# ^C
escaped \if, executing commands
# \echo msg
msg
# \endif
encountered un-matched \endif

Ctrl-C exits do the same before/after state checks that \endif does, the lone difference being that it "escaped" the \if rather than "exited" the \if. Thanks to Daniel for pointing out where it should be handled, because I wasn't going to figure that out on my own.

v7's only major difference from v6 is the Ctrl-C branch escaping.
Вложения

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

Предыдущее
От: Claudio Freire
Дата:
Сообщение: Re: ParallelFinish-hook of FDW/CSP (Re: [HACKERS] Steps inside ExecEndGather)
Следующее
От: Amit Khandekar
Дата:
Сообщение: Re: [HACKERS] Parallel Append implementation