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

Поиск
Список
Период
Сортировка
От Corey Huinker
Тема \if, \elseif, \else, \endif (was Re: [HACKERS] PSQL commands:\quit_if, \quit_unless)
Дата
Msg-id CADkLM=c94OSRTnat=LX0ivNq4pxDNeoomFfYvBKM5N_xfmLtAA@mail.gmail.com
обсуждение исходный текст
Ответы Re: \if, \elseif, \else, \endif (was Re: [HACKERS] PSQL commands:\quit_if, \quit_unless)  (Fabien COELHO <coelho@cri.ensmp.fr>)
Список pgsql-hackers

Fabien is pressed for time, so I've been speaking with him out-of-thread about how I should go about implementing it.

The v1 patch will be \if <expr>, \elseif <expr>, \else, \endif, where <expr> will be naively evaluated via ParseVariableBool().

\ifs and \endifs must be in the same "file" (each MainLoop will start a new if-stack). This is partly for sanity (you can see the pairings unless the programmer is off in \gset meta-land), partly for ease  of design (data structures live in MainLoop), but mostly because it would an absolute requirement if we ever got around to doing \while.

I hope to have something ready for the next commitfest.

As for the fate of \quit_if, I can see it both ways. On the one hand, it's super-simple, already written, and handy.

On the other hand, it's easily replaced by
\if <expr>
    \q
\endif

So I'll leave that as a separate reviewable patch.

As for loops, I don't think anyone was pushing for implementing \while now, only to have a decision about what it would look like and how it would work. There's a whole lot of recording infrastructure (the input could be a stream) needed to make it happen. Moreover, I think \gexec scratched a lot of the itches that would have been solved via a psql looping structure.


And here's the patch. I've changed the subject line and will be submitting a new entry to the commitfest.
Вложения

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

Предыдущее
От: Jim Nasby
Дата:
Сообщение: Re: [HACKERS] [WIP]Vertical Clustered Index (columnar storeextension)
Следующее
От: Petr Jelinek
Дата:
Сообщение: Re: [HACKERS] Logical Replication WIP