Re: \if, \elseif, \else, \endif (was Re: [HACKERS] PSQL commands: \quit_if, \quit_unless)
От | Daniel Verite |
---|---|
Тема | Re: \if, \elseif, \else, \endif (was Re: [HACKERS] PSQL commands: \quit_if, \quit_unless) |
Дата | |
Msg-id | 68ff2c1d-943b-4ac6-804e-3d56a77e11a2@manitou-mail.org обсуждение исходный текст |
Ответ на | Re: \if, \elseif, \else, \endif (was Re: [HACKERS] PSQL commands:\quit_if, \quit_unless) (Corey Huinker <corey.huinker@gmail.com>) |
Ответы |
Re: \if, \elseif, \else, \endif (was Re: [HACKERS] PSQL commands:\quit_if, \quit_unless)
|
Список | pgsql-hackers |
Corey Huinker wrote: > > \if ERROR > > \echo X > > \else > > \echo Y > > \endif > > > > having both X & Y printed and error reported on else and endif. I think > > that an expression error should just put the stuff in ignore state. > > > > Not just false, but ignore the whole if-endif? interesting. I hadn't > thought of that. Can do. If we use the Unix shell as a model, in POSIX "test" and "if" are such that an evaluation error (exit status>1) leads to the same flow than when evaluating to false (exit status=1). References I can find: test: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html if: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_04_07 BTW, in "set -e" mode, it also says that a failure to evaluate an "if"expression does not lead to the script stopping: <quote> The -e setting shall be ignored when executing the compound list following the while, until, if, or elif reservedword, a pipeline beginning with the ! reserved word, or any command of an AND-OR list other than the last </quote> So psql is not following that model with ON_ERROR_STOP if it exits with an error when unable to evaluate an "if" expression. I'm not implying that we should necessarily adopt the shell behavior, but as these choices have certainly been made in POSIX for good reasons, we should make sure to think twice about why they don't apply to psql. Best regards, -- Daniel Vérité PostgreSQL-powered mailer: http://www.manitou-mail.org Twitter: @DanielVerite
В списке pgsql-hackers по дате отправления: