Re: proposal: condition blocks in psql

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal: condition blocks in psql
Date: 2015-06-29 03:17:13
Message-ID: CAFj8pRDm+1zC_GYLvJ+PRorT=2BMg+f3pVvXKAS5g0NKoYUhjg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2015-06-28 22:43 GMT+02:00 Corey Huinker <corey(dot)huinker(at)gmail(dot)com>:

>
>> I implemented \foreach five years ago, and this is not simple to
>> implement statement - so don't propose it. I wouldn't to inject full
>> scripting language to psql. Then it is better to use bash, perl, python.
>>
>> But well designed conditional statements needs only few lines for
>> implementation, and be good enough for almost all tasks what I need to do
>> in psql. More the working with versions needs a different operation than
>> comparing strings or comparing numbers, and can be nice if this
>> functionality is available with some user friendly syntax.
>>
>
> Yes, I'll read up on that project, and set my foreach dreams aside for the
> time being.
>
> even a simple \if var_name, where var_name is judged by the accepted
> PostgreSQL string values of TRUE/FALSE, would be immensely useful.
>
> select (version() like '%9.4.1%') as is_941
> \gset
>
> \if is_941
> \endif
> \if is_942
> \endif
>

This is design detail - there can be more variants of supported conditions.

Regards

Pavel

>
>
>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Sawada Masahiko 2015-06-29 03:52:39 Re: pg_file_settings view vs. Windows
Previous Message Amit Langote 2015-06-29 02:43:41 Re: Adjust errorcode in background worker code