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

From: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
To: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Stark <stark(at)mit(dot)edu>, Erik Rijkers <er(at)xs4all(dot)nl>, Robert Haas <robertmhaas(at)gmail(dot)com>, Daniel Verite <daniel(at)manitou-mail(dot)org>, Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>, 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-03-03 06:53:15
Message-ID: CADkLM=dLtw4GtfbZM=jTgsp3nQ1r6DcSque-DxV7fJ0rYqhyRw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Mar 3, 2017 at 1:25 AM, Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> wrote:

>
>
> For endif, I really exagerated, "switch { defaut: " is too much, please
>> accept my apology. Maybe just do the pop & error reporting?
>>
>
It seemed like overkill, but I decided to roll with it.

>
> Or maybe be more explicit:
>
> switch (current state)
> case NONE:
> error no matching if;
> case ELSE_FALSE:
> case ELSE_TRUE:
> case ...:
> pop;
> Assert(success);

the pop() function tests for an empty stack, so this switch is
double-testing, but it's also no big deal, so here you go...

Attachment Content-Type Size
0001.if_endif.v21.diff text/plain 32.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2017-03-03 07:12:55 Re: allow referring to functions without arguments when unique
Previous Message Michael Paquier 2017-03-03 06:44:10 Re: [patch] reorder tablespaces in basebackup tar stream for backup_label