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

From Fabien COELHO
Subject Re: [HACKERS] PSQL commands: \quit_if, \quit_unless
Date
Msg-id alpine.DEB.2.20.1701140734040.15294@lancre
Whole thread Raw
In response to Re: [HACKERS] PSQL commands: \quit_if, \quit_unless  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
> $ cat loop.sql
> \if :x < 1000
>  \echo :x
>  \set x :x + 1
>  \include loop.sql
> \fi
> $ psql --set x=0 -f loop.sql

Nice one! CPP does not have arithmetic, so it is harder to do that because 
one must reimplement arithmetic with #if...

> 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.

One can already have "include nested too deeply" errors, I guess, without 
a recursion.

I would say that's this consequence is acceptable, and that this is a 
feature.

I think having some kind of client-side test brings significant value 
because it would help writing application schema upgrades for instance, 
and that the this potential whining source is worth handling.

-- 
Fabien.



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] PSQL commands: \quit_if, \quit_unless
Next
From: Michael Paquier
Date:
Subject: Re: [HACKERS] Fixing matching of boolean index columns to sort ordering