Re: [HACKERS] Undefined psql variables

Поиск
Список
Период
Сортировка
От Corey Huinker
Тема Re: [HACKERS] Undefined psql variables
Дата
Msg-id CADkLM=f9bPK0hozfnBKttt3q1n2VXCJ_Mherd4iSfZbJiAOTPA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [HACKERS] Undefined psql variables  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [HACKERS] Undefined psql variables  (Fabien COELHO <coelho@cri.ensmp.fr>)
Список pgsql-hackers
On Mon, Jan 23, 2017 at 12:53 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Corey Huinker <corey.huinker@gmail.com> writes:
> I was giving some thought to how psql handles undefined variables.
> I would like an option where either psql can provide an alternate value
> when an undefined variable is referenced, or a way to detect that a
> specific variable is undefined and replace it with a defined variable.

This seems pretty bizarre.  What's the use case?  Why would it not
be better to build the behavior out of other spare parts, along the
lines of COALESCE or perhaps

      \if not defined(x)
      \set x y
      \fi

Obviously the \if stuff is things we don't have yet either, but
it seems less likely to have surprising side-effects.

                        regards, tom lane

That'd work too, if \if and defined(psql_var_name) come to fruition.

A use case we have now is where a script has several values that are almost always a default value.

Instead of  

PGSERVICE=foo psql -f script.sql --set var1=a --set var2=b --set var3=d ... --set varN=n

I can just specify the non-default values:

PGSERVCE=foo psql -f script.sql --set var3=unusual_value

and the code then shows the unusual needle in the default haystack.



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

Предыдущее
От: Greg Stark
Дата:
Сообщение: Re: [HACKERS] Online enabling of page level checksums
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: [HACKERS] Undefined psql variables