Re: [HACKERS] \if, \elseif, \else, \endif (was Re: PSQL commands:\quit_if, \quit_unless) - Mailing list pgsql-hackers

From Corey Huinker
Subject Re: [HACKERS] \if, \elseif, \else, \endif (was Re: PSQL commands:\quit_if, \quit_unless)
Date
Msg-id CADkLM=dLtw4GtfbZM=jTgsp3nQ1r6DcSque-DxV7fJ0rYqhyRw@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] \if, \elseif, \else, \endif (was Re: PSQL commands:\quit_if, \quit_unless)  (Fabien COELHO <coelho@cri.ensmp.fr>)
Responses Re: [HACKERS] \if, \elseif, \else, \endif (was Re: PSQL commands:\quit_if, \quit_unless)  (Fabien COELHO <coelho@cri.ensmp.fr>)
Re: [HACKERS] \if, \elseif, \else, \endif (was Re: PSQL commands: \quit_if, \quit_unless)  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: [HACKERS] \if, \elseif, \else, \endif (was Re: PSQL commands: \quit_if, \quit_unless)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Fri, Mar 3, 2017 at 1:25 AM, Fabien COELHO <coelho@cri.ensmp.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

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [HACKERS] [patch] reorder tablespaces in basebackup tar streamfor backup_label
Next
From: Michael Paquier
Date:
Subject: Re: [HACKERS] allow referring to functions without arguments when unique