Re: PSQL commands: \quit_if, \quit_unless

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PSQL commands: \quit_if, \quit_unless
Date: 2017-01-14 06:57:09
Message-ID: alpine.DEB.2.20.1701140734040.15294@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2017-01-14 07:02:17 Re: Fixing matching of boolean index columns to sort ordering
Previous Message Tom Lane 2017-01-14 05:22:26 Re: PSQL commands: \quit_if, \quit_unless