Re: proposal: condition blocks in psql - Mailing list pgsql-hackers

From Corey Huinker
Subject Re: proposal: condition blocks in psql
Date
Msg-id CADkLM=e0HG2voztVDuiOn7t2trpD56X8WfRQ_ooZmHn+edU_cA@mail.gmail.com
Whole thread Raw
In response to Re: proposal: condition blocks in psql  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: proposal: condition blocks in psql  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers

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


 

pgsql-hackers by date:

Previous
From: Josh Berkus
Date:
Subject: Re: Solaris testers wanted for strxfrm() behavior
Next
From: Heikki Linnakangas
Date:
Subject: Re: Redesigning checkpoint_segments