Re: PSQL commands: \quit_if, \quit_unless

Поиск
Список
Период
Сортировка
От Fabien COELHO
Тема Re: PSQL commands: \quit_if, \quit_unless
Дата
Msg-id alpine.DEB.2.20.1612042045550.4497@lancre
обсуждение исходный текст
Ответ на Re: PSQL commands: \quit_if, \quit_unless  (Pavel Stehule <pavel.stehule@gmail.com>)
Ответы Re: PSQL commands: \quit_if, \quit_unless  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-hackers
>> Yes, that is a possibility, but this can already be queried into a 
>> :-variable, so it is less indispensable.
>
> can you show some examples, please?
 SELECT COUNT(*) AS has_unit_extension   FROM pg_extension WHERE extname='unit' \gset \echo :has_unit_extension 1

So that
 \if ! :hash_unit_extension CREATE TABLE foo(id SERIAL, stuff UNIT); \else \echo "unit extension is not loaded" \quit
\fi

Ok, for this example one may try:
 CREATE EXTENSION IF NOT EXISTS unit;

Or use the "ON_ERROR_STOP" setting, but that is the idea, SQL can be used 
to test anything server-side.

-- 
Fabien.



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

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: PSQL commands: \quit_if, \quit_unless
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: PSQL commands: \quit_if, \quit_unless