Re: \if, \elseif, \else, \endif (was Re: PSQL commands: \quit_if, \quit_unless)

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Erik Rijkers <er(at)xs4all(dot)nl>
Cc: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>, Daniel Verite <daniel(at)manitou-mail(dot)org>, PostgreSQL <pgsql-hackers(at)postgresql(dot)org>, pgsql-hackers-owner(at)postgresql(dot)org
Subject: Re: \if, \elseif, \else, \endif (was Re: PSQL commands: \quit_if, \quit_unless)
Date: 2017-02-03 13:24:33
Message-ID: alpine.DEB.2.20.1702031421490.4856@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


>> 2. Inside an \if block \q should be given precedence and cause a direct
>> exit of psql (or at the very least exit the if block(s)), as in regular SQL
>> statements (compare: 'select * from t \q' which will immediately exit psql
>> -- this is good. )
>
> One use case if to be able to write "\if ... \q \endif" in scripts. If \q is
> always executed, then the use case is blown. I cannot think of any language
> that would execute anything in a false branch. So Ctrl-C or Ctrl-D is the way
> out, and \if control must really have precedence over its contents.

After giving it some more thoughts, a possible solution could be to have a
"\exit [status]" which could be ignored (there has been some talk about
that one), and have \q which is not, but I would find it weird and error
prone for the user. As already said, \if use-case is not about interactive
psql.

--
Fabien.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2017-02-03 14:26:41 Re: patch: optimize information_schema.constraint_column_usage
Previous Message Thomas Munro 2017-02-03 13:04:55 Re: Parallel tuplesort (for parallel B-Tree index creation)