Re: [HACKERS] PSQL commands: \quit_if, \quit_unless - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: [HACKERS] PSQL commands: \quit_if, \quit_unless
Date
Msg-id CAB7nPqTx5_rLAitt1BGb=LxRBLHsBedrHp7X3t8eYBrFVJL_Sg@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] PSQL commands: \quit_if, \quit_unless  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: [HACKERS] PSQL commands: \quit_if, \quit_unless
List pgsql-hackers
On Wed, Jan 18, 2017 at 3:24 AM, Robert Haas <robertmhaas@gmail.com> wrote:
> On Sat, Jan 14, 2017 at 12:22 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>
>> $ cat loop.sql
>> \if :x < 1000
>>   \echo :x
>>   \set x :x + 1
>>   \include loop.sql
>> \fi
>> $ psql --set x=0 -f loop.sql
>>
>> Somebody is going to think of that workaround for not having loops, and
>> then whine about how psql runs out of file descriptors and/or stack.
>
> Hmm, I think somebody just DID think of it.
>
> But personally this doesn't upset me a bit.  If somebody complains
> about that particular thing, I think that would be an excellent time
> to suggest that they write a patch to add a looping construct.

Agreed.

As far as I can see on this thread, something could be done, it is
just that we don't know yet at which extent things could be done with
the first shot. There are many things that could be done, but at least
I'd suggest to get \if, \fi and \quit to satisfy the first
requirements of this thread, and let loops out of it. I have switched
the patch as "returned with feedback" as getting a new patch is going
to require some thoughts to get the context handling done correctly on
psql side.
-- 
Michael



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [HACKERS] DROP FUNCTION of multiple functions
Next
From: Dilip Kumar
Date:
Subject: Re: [HACKERS] Parallel bitmap heap scan