Re: proposal: condition blocks in psql

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal: condition blocks in psql
Date: 2015-06-28 08:46:46
Message-ID: alpine.DEB.2.10.1506281004190.23688@sto
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hello again Pavel,

Note that I'm not against cpp-like features on principle, I did macros for
apache configurations a very long time ago, and that I only give my 0.02€
on this, for what's the € is worth these days:-)

> you can use parameters for functions, but you cannot it for DO statement
> (simply).

Indeed. Maybe this is worth improving independently of adding
conditionals. Not sure about a (clean) syntax, though... Maybe psql could
export its variables somehow to PL/pgSQL. Hmmm.

> the implementation of \if_version_gt is pretty simple - needs few lines of
> new code.

I'm curious, how many "few" lines?

You would need a stack to manage nesting, you need some kind of more or
less condition evaluation which is open-ended in itself, you need reading
up to the end token (possibly this is more or less already available), you
need adapting the prompt to reflect the nesting, you need to deal with
badly nested scripts (say can an included file be "badly nested" on \i?),
you need to decide what to put in the input line history, depending on the
available infrastructure within psql...

I would say 100-300 few lines (but I may be proven wrong both ways), all
that for something which is already more or less doable with PL/pgSQL. I
would rather try to upgrade the PL/pgSQL experience.

--
Fabien.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sawada Masahiko 2015-06-28 08:52:36 Re: Support for N synchronous standby servers - take 2
Previous Message Pavel Stehule 2015-06-28 07:50:44 Re: proposal: condition blocks in psql