PSQL commands: \quit_if, \quit_unless

Started by Corey Huinkerover 9 years ago67 messageshackers
Jump to latest
#1Corey Huinker
corey.huinker@gmail.com

This patch adds two very simple psql commands: \quit_if and \quit_unless.

Each takes an optional string parameter and evaluates it for truthiness via
ParseVariableBool().

If a true-ish value is passed to \quit_if, psql will behave as if the user
had input \quit.

\quit_unless will do nothing if the value given was true-ish, and will
\quit in any other circumstances.

Examples below show the behavior:

$ psql postgres
psql (10devel)
Type "help" for help.

# \quit_if
# \quit_unless
$ psql postgres
psql (10devel)
Type "help" for help.

# \quit_if f
# \quit_if 0
# \quit_if false
# \quit_if 2
unrecognized value "2" for "\quit_if"; assuming "on"
$ psql postgres
psql (10devel)
Type "help" for help.

# \quit_unless 2
unrecognized value "2" for "\quit_unless"; assuming "on"
# \quit_unless f
$

The need for this patch has arisen from several scripts I've written
recently that were about 97% psql and 3% bash or similar glue language. In
those scripts, there's often a test that says "there is no work to do here,
and that is not an error". I could engineer an optional SELECT 1/0 to
generate an error, but then I have to make the bash script determine
whether that was an error-error or a no-everything-is-ok-error. I also
don't want to wrap hundreds of lines of SQL inside python docstrings (thus
losing syntax highlighting, etc) just to handle one if/then.

Many thanks to Pavel Stehule for brainstorming this one with me.

Attachments:

0001.quit_if.difftext/plain; charset=US-ASCII; name=0001.quit_if.diffDownload+42-0
#2Fabien COELHO
coelho@cri.ensmp.fr
In reply to: Corey Huinker (#1)
Re: PSQL commands: \quit_if, \quit_unless

Hello Corey,

This patch adds two very simple psql commands: \quit_if and \quit_unless.

A few comments about the feature design:

I'm unsure about the name, esp with '_'. There are some \lo_* commands,
but others rely on pasted words (\crosstabview, \errverbose, ...).

I'm wondering if an simplistic interpreted \if \elsif/\else \fi would make
more sense:

Quitting seems a little bit definitive, and means that if I have some
alternatives then I have to have something that relaunch another script
outside...

When \includes are process, does \quit stop the include or the full
script. I'm afraid it is the script.

Now probably an \if... would have also some drawbacks, but ISTM that there
could be less of them.

There is no test provided with the patch.

--
Fabien.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Pavel Stehule
pavel.stehule@gmail.com
In reply to: Fabien COELHO (#2)
Re: PSQL commands: \quit_if, \quit_unless

2016-11-28 20:03 GMT+01:00 Fabien COELHO <coelho@cri.ensmp.fr>:

Hello Corey,

This patch adds two very simple psql commands: \quit_if and \quit_unless.

A few comments about the feature design:

I'm unsure about the name, esp with '_'. There are some \lo_* commands,
but others rely on pasted words (\crosstabview, \errverbose, ...).

There are not any other conditional statements - so using "_" can be better

I'm wondering if an simplistic interpreted \if \elsif/\else \fi would make
more sense:

The \if \ese \elseif is not in contradiction with \quit_if - \if is more
generic, \quit_if is simple for implementation, one liner, and best readable

Pavel

Show quoted text

Quitting seems a little bit definitive, and means that if I have some
alternatives then I have to have something that relaunch another script
outside...

When \includes are process, does \quit stop the include or the full
script. I'm afraid it is the script.

Now probably an \if... would have also some drawbacks, but ISTM that there
could be less of them.

There is no test provided with the patch.

--
Fabien.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4Corey Huinker
corey.huinker@gmail.com
In reply to: Fabien COELHO (#2)
Re: PSQL commands: \quit_if, \quit_unless

On Mon, Nov 28, 2016 at 2:03 PM, Fabien COELHO <coelho@cri.ensmp.fr> wrote:

Hello Corey,

This patch adds two very simple psql commands: \quit_if and \quit_unless.

A few comments about the feature design:

I'm unsure about the name, esp with '_'. There are some \lo_* commands,
but others rely on pasted words (\crosstabview, \errverbose, ...).

I'm completely flexible with regard to the names.

I'm wondering if an simplistic interpreted \if \elsif/\else \fi would make
more sense:

The problem is that \if \elsif \else \fi is anything but simplistic, and
would be a vastly bigger change. Detecting nested if-thens, detecting
un-matched if-thens, etc.

Quitting seems a little bit definitive, and means that if I have some
alternatives then I have to have something that relaunch another script
outside...

When \includes are process, does \quit stop the include or the full
script. I'm afraid it is the script.

It behaves exactly as if the script contained \quit at that location.

Now probably an \if... would have also some drawbacks, but ISTM that there
could be less of them.

It'd be nice, but I'm trying to keep things simple.

There is no test provided with the patch.

Indeed, but testing such a feature is hard within our current test harness.
I welcome suggestions for how to convert the example script in my first
email to tests.

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Corey Huinker (#4)
Re: PSQL commands: \quit_if, \quit_unless

Corey Huinker <corey.huinker@gmail.com> writes:

On Mon, Nov 28, 2016 at 2:03 PM, Fabien COELHO <coelho@cri.ensmp.fr> wrote:

I'm wondering if an simplistic interpreted \if \elsif/\else \fi would make
more sense:

The problem is that \if \elsif \else \fi is anything but simplistic, and
would be a vastly bigger change. Detecting nested if-thens, detecting
un-matched if-thens, etc.

Yes, but... We've generally refrained from inventing any control flow
metacommands for psql, and TBH this does *not* seem like the place to
start. If we take this patch we are very likely to find that it doesn't
fit in at all whenever someone does show up with a proposal for control
flow features.

If we had an agreed-on sketch for what that feature set would look like,
I wouldn't necessarily object to implementing commands like these first.
But as it stands I think we'd be painting ourselves into a corner.
There's no reason to assume a-priori that this patch creates either naming
conventions or semantics (e.g. what is suitable as a boolean expression)
that we'd be happy with in a larger context.

As far as the original problem goes, I wonder whether what you really
want isn't a \quit command that lets you specify psql's exit code.
I'm not quite seeing how this proposal advances the problem of
communicating between psql and shell portions of a script; but I can
see how returning 0 (ok) vs 1 (error) vs 2 (some special case) would
help with that.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#6David G. Johnston
david.g.johnston@gmail.com
In reply to: Tom Lane (#5)
Re: PSQL commands: \quit_if, \quit_unless

On Mon, Nov 28, 2016 at 2:07 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Corey Huinker <corey.huinker@gmail.com> writes:

On Mon, Nov 28, 2016 at 2:03 PM, Fabien COELHO <coelho@cri.ensmp.fr>

wrote:

There's no reason to assume a-priori that this patch creates either naming

conventions or semantics (e.g. what is suitable as a boolean expression)
that we'd be happy with in a larger context.

Would we be happy borrowing the definition of FOUND from pl/pgsql?​

As far as the original problem goes, I wonder whether what you really

want isn't a \quit command that lets you specify psql's exit code.

Actually, I'm seeing this as basically an assertion capability and maybe
should be named as such

\assert_is
\assert_isnot ​

​David J.

#7Corey Huinker
corey.huinker@gmail.com
In reply to: David G. Johnston (#6)
Re: PSQL commands: \quit_if, \quit_unless

As far as the original problem goes, I wonder whether what you really

want isn't a \quit command that lets you specify psql's exit code.

The ability to specify an exit code was part of the brainstorming, yes. But
with it was the ability to conditionally quit.

Actually, I'm seeing this as basically an assertion capability and maybe
should be named as such

\assert_is
\assert_isnot ​

That came up too! I see real value in the ability to test for error
conditions. I just had a more immediate need for a non-error exit condition.

#8Andrew Dunstan
andrew@dunslane.net
In reply to: Tom Lane (#5)
Re: PSQL commands: \quit_if, \quit_unless

On 11/28/2016 04:07 PM, Tom Lane wrote:

... We've generally refrained from inventing any control flow
metacommands for psql

I think it's really time we seriously considered adding some flow
control logic, though. I'm mildly tired of either jumping through hoops
to get around the lack or having to switch to using some other thing
that has the required logic mechanism (hello Perl).

cheers

andrew

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#9Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andrew Dunstan (#8)
Re: PSQL commands: \quit_if, \quit_unless

Andrew Dunstan <andrew@dunslane.net> writes:

On 11/28/2016 04:07 PM, Tom Lane wrote:

... We've generally refrained from inventing any control flow
metacommands for psql

I think it's really time we seriously considered adding some flow
control logic, though.

Yeah, maybe. I'd be interested to see a fully worked out proposal
for that.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#10Fabien COELHO
coelho@cri.ensmp.fr
In reply to: Tom Lane (#9)
Re: PSQL commands: \quit_if, \quit_unless

Hello,

I think it's really time we seriously considered adding some flow
control logic, though.

Yeah, maybe. I'd be interested to see a fully worked out proposal
for that.

I agree that designing a fuller proposal before including individual parts
would be great and result in a more consistent result.

In order to bootstrap the discussion, I suggest the following:

- boolexpr is a simple "boolean" (t, non 0 int, non empty string.. as
proposed by Corey and Pavel) or !/not boolexp ; it could be extended if
necessary, but I would try to avoid that, as

- actual more complex expressions could be left to the server through SQL
which simplifies the client a lot by avoiding an expression language
altogether

- then having a conditional block is very versatile and can be adapted to
many use cases... maybe all

- \quit CODE, or I would prefer \exit CODE, could be used to exit while
controlling the status

It could look like (although I do not like gset in this context, but
anyway):

SELECT ... AS has_foo_extension \gset
SELECT ... AS has_bla_extension \gset
\if :has_foo_extension
...
\elif :has_bla_extension
...
\else -- no foo nor bla extension
\echo please install foo or bla extension
\exit 1
\fi -- extension
...
SELECT ... AS has_xxx_feature \gset
\if ! :has_xxx_feature
\echo "feature xxx is needed, aborting"
\exit 2
\fi
...

--
Fabien

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#11Pavel Stehule
pavel.stehule@gmail.com
In reply to: Fabien COELHO (#10)
Re: PSQL commands: \quit_if, \quit_unless

2016-11-29 8:44 GMT+01:00 Fabien COELHO <coelho@cri.ensmp.fr>:

Hello,

I think it's really time we seriously considered adding some flow

control logic, though.

Yeah, maybe. I'd be interested to see a fully worked out proposal
for that.

I agree that designing a fuller proposal before including individual parts
would be great and result in a more consistent result.

In order to bootstrap the discussion, I suggest the following:

- boolexpr is a simple "boolean" (t, non 0 int, non empty string.. as
proposed by Corey and Pavel) or !/not boolexp ; it could be extended if
necessary, but I would try to avoid that, as

Now, the psql statements are designed do nothing in syntax error. I am not
sure about be more strict in this case. I see strong advantages - but it
can be little bit different than current behave.

- actual more complex expressions could be left to the server through SQL
which simplifies the client a lot by avoiding an expression language
altogether

- then having a conditional block is very versatile and can be adapted to
many use cases... maybe all

- \quit CODE, or I would prefer \exit CODE, could be used to exit while
controlling the status

It could look like (although I do not like gset in this context, but
anyway):

SELECT ... AS has_foo_extension \gset
SELECT ... AS has_bla_extension \gset
\if :has_foo_extension
...
\elif :has_bla_extension
...
\else -- no foo nor bla extension
\echo please install foo or bla extension
\exit 1
\fi -- extension
...
SELECT ... AS has_xxx_feature \gset
\if ! :has_xxx_feature

I prefer the commands instead symbols - the parsing and processing symbols
should be more complex than it is now. A psql parser is very simple - and
any complex syntax enforces lot of code.

\if_not

Regards

Pavel

Show quoted text

\echo "feature xxx is needed, aborting"
\exit 2
\fi
...

--
Fabien

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#12Fabien COELHO
coelho@cri.ensmp.fr
In reply to: Pavel Stehule (#11)
Re: PSQL commands: \quit_if, \quit_unless

Hello Pavel,

Now, the psql statements are designed do nothing in syntax error. I am not
sure about be more strict in this case. I see strong advantages - but it
can be little bit different than current behave.

Indeed, an error on a conditional construct should stop the script, which
is slightly different that "go on whatever", which is okay in the
interactive mode.

I do not see that as an issue, just as features which are more interactive
vs script oriented and behave accordingly: typing a \if in interactive
does not makes much sense, because you have tested something is there, so
you know the answer and can act directly, so there is no point using a
condition.

\if ! :has_xxx_feature

I prefer the commands instead symbols - the parsing and processing
symbols should be more complex than it is now. A psql parser is very
simple - and any complex syntax enforces lot of code. \if_not

My 0,02 €, which is just a personal opinion:

I think that handling manually "!/not" would be worth the effort rather
than having two commands, especially if the boolean expression syntax may
be extended some day and the negative if would become obsolete.

If there is a negative condition syntax, I would slightly prefer \ifnot to
\if_not or worse \unless. I would disaprove strongly of \unless because it
looses the clear symmetry with a closing \fi.

--
Fabien.
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#13Corey Huinker
corey.huinker@gmail.com
In reply to: Fabien COELHO (#12)
Re: PSQL commands: \quit_if, \quit_unless

My 0,02 €, which is just a personal opinion:

I think that handling manually "!/not" would be worth the effort rather
than having two commands, especially if the boolean expression syntax may
be extended some day and the negative if would become obsolete.

If there is a negative condition syntax, I would slightly prefer \ifnot to
\if_not or worse \unless. I would disaprove strongly of \unless because it
looses the clear symmetry with a closing \fi.

--
Fabien.

Pavel had previously written this patch
http://ftp.pgpi.org/pub/databases/postgresql/projects/pgFoundry/epsql/epsql/epsql-8.5-develop/psql-enhanced-macros.diff
which I leave here as a point of reference.

Obviously, there's a lot more in there than we'd need, and it's back quite
a few versions.

I agree that the boolean tests available should be *very* simple, and all
of the weight of complex calculation should be put in SQL, like we do with
\gset

I propose those be:

\if STRING : true if STRING evaluates to true via ParseVariableBool, empty
means false
\ifnot STRING: true if STRING evaluates to false via ParseVariableBool,
empty means false
\ifdef psql_var: true if psql_var is defined
\ifndef psql_var: true if psql_var is not defined, helpful for when --set
var=val was omitted and should be defaulted

A full compliment of \elseif \elseifnot \elseifdef \elseifndef, each
matching the corresponding \if* above. I'm ok with these being optional in
the first revision.

\else - technically we could leave this out as well
\endif

Then seems like we need an if-state-stack to handle nesting. At any given
point, the mode could be:

1. None

psql currently isn't in an if-then structure, no non-conditional statements
are skipped. any conditional commands other than \if* are an error.
For that matter, the script can always add a new level to the stack with an
\if* command.

2. If-Then

psql is currently executing statements in an \if* branch that evaluated to
true. valid conditional commands are: \if*, \else* \endif

3. If-Skip

psql is currently in a block that evaluated to false, and will still parse
commands for psql-correctness, but will skip them until it encounters an
\endif or \else*

4. Else-Then

Just like If-Then, but encountering an \else* command would be an error.

5. Else-Skip

Just like If-Skip, but encountering an \else* command would be an error.

The only data structure we'd need is the stack of enums listed above. Any
commands would check against the stack-state before executing, but would
otherwise be parsed and checked as they are now. The new \commands would
manipulate that stack.

Does that seem work-able?

#14Fabien COELHO
coelho@cri.ensmp.fr
In reply to: Corey Huinker (#13)
Re: PSQL commands: \quit_if, \quit_unless

Hello Corey,

I agree that the boolean tests available should be *very* simple, and all
of the weight of complex calculation should be put in SQL, like we do with
\gset

Yes.

I propose those be:

\if STRING : true if STRING evaluates to true via ParseVariableBool, empty
means false

Yep.

\ifnot STRING: true if STRING evaluates to false via ParseVariableBool,
empty means false

I'd like other opinions about having unique \if and an not operator, vs
multiplying \if* and possibly \elif* keywords.

\ifdef psql_var: true if psql_var is defined
\ifndef psql_var: true if psql_var is not defined, helpful for when --set
var=val was omitted and should be defaulted

Hmmm. Would you have an example use case that could not be done simply
with the previous ifs? cpp did that end ended up with a single if in the
end.

A full compliment of \elseif \elseifnot \elseifdef \elseifndef, each
matching the corresponding \if* above. I'm ok with these being optional in
the first revision.

\else - technically we could leave this out as well
\endif

For consistency, the possible sources of inspiration for a syntax with an
explicit end marker are:

- PL/pgSQL: if / then / elsif / else / endif
- cpp: if / elif / else / endif
- sh: if / then / elif / else / fi

Now "then" is useless in a line oriented syntax, for which the closest
example above is cpp, which does not have it. I think that we should stick
to one of these.

I like the shell syntax (without then), but given the line orientation
maybe it would make sense to use the cpp version, close to what you are
proposing.

I cannot remember a language with elseif* variants, and I find them quite
ugly, so from an aethetical point of view I would prefer to avoid that...
On the other hand having an "else if" capability makes sense (eg do
something slightly different for various versions of pg), so that would
suggest to stick to a simpler "if" without variants, if possible.

Then seems like we need an if-state-stack to handle nesting. [...]

Yes, a stack or recursion is needed for implementing nesting.

States: None, If-Then, If-Skip, Else-Then, Else-Skip.

With an "else if" construct you probably need some more states: You have
to know whether you already executed a block in which case a subsequent
condition is ignored, so there is a state "skip all to end" needed.

Does that seem work-able?

Sure. I think the priority is to try to agree about a syntax, the
implementation is a detail.

--
Fabien.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#15Corey Huinker
corey.huinker@gmail.com
In reply to: Fabien COELHO (#14)
Re: PSQL commands: \quit_if, \quit_unless

Hmmm. Would you have an example use case that could not be done simply
with the previous ifs? cpp did that end ended up with a single if in the
end.

I think this is what you're asking for...

$ cat not_defined.sql
select :'foo';

$ psql postgres --no-psqlrc -f not_defined.sql --set foo=bar
?column?
----------
bar
(1 row)

$ psql postgres --no-psqlrc -f not_defined.sql
psql:not_defined.sql:3: ERROR: syntax error at or near ":"
LINE 1: select :'foo';
^

Now, if we instead added a way for psql to test whether or not a psql var
was defined and set that boolean as ANOTHER variable, then we could avoid
\ifdef and \ifndef.

For consistency, the possible sources of inspiration for a syntax with an
explicit end marker are:

- PL/pgSQL: if / then / elsif / else / endif
- cpp: if / elif / else / endif
- sh: if / then / elif / else / fi

Now "then" is useless in a line oriented syntax, for which the closest
example above is cpp, which does not have it. I think that we should stick
to one of these.

I like the shell syntax (without then), but given the line orientation
maybe it would make sense to use the cpp version, close to what you are
proposing.

I think we should use pl/pgsql as our inspiration, though there's no need
for the "then" because psql commands end the line....which makes it
identical to the C++ version.
But if we can get this thing done, I really don't care which we use.

I cannot remember a language with elseif* variants, and I find them quite
ugly, so from an aethetical point of view I would prefer to avoid that...
On the other hand having an "else if" capability makes sense (eg do
something slightly different for various versions of pg), so that would
suggest to stick to a simpler "if" without variants, if possible.

We need to keep things easy to parse. Earlier someone said no psql command
should ever have more than 2 parameters, and generally only one. Increasing
the number of commands allows us to avoid multi-parameter commands. So it's
a trade-off, we have more, simpler commands, or fewer, more complicated
ones.

\if [not] [defined] [<string>]
\elsif [not] [defined] [<string>]

is problematic if string is ever "not" or "defined". If someone can show me
a way around that, I'm game.

Then seems like we need an if-state-stack to handle nesting. [...]

Yes, a stack or recursion is needed for implementing nesting.

States: None, If-Then, If-Skip, Else-Then, Else-Skip.

With an "else if" construct you probably need some more states: You have
to know whether you already executed a block in which case a subsequent
condition is ignored, so there is a state "skip all to end" needed.

Right, we'd have to check every level of the stack for a skip-state, not a
big deal.

#16Andrew Dunstan
andrew@dunslane.net
In reply to: Fabien COELHO (#14)
Re: PSQL commands: \quit_if, \quit_unless

On 11/29/2016 03:07 PM, Fabien COELHO wrote:

I cannot remember a language with elseif* variants, and I find them
quite ugly, so from an aethetical point of view I would prefer to
avoid that... On the other hand having an "else if" capability makes
sense (eg do something slightly different for various versions of pg),
so that would suggest to stick to a simpler "if" without variants, if
possible.

FTR I *strongly* disagree with this. (And if you can't remember a
language that comes with them then you need to get out more. The Bourne
shell, where it's spelled "elif", and Ada are two obvious examples.)

cheers

andrew

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#17David Steele
david@pgmasters.net
In reply to: Andrew Dunstan (#16)
Re: PSQL commands: \quit_if, \quit_unless

On 11/29/16 5:08 PM, Andrew Dunstan wrote:

On 11/29/2016 03:07 PM, Fabien COELHO wrote:

I cannot remember a language with elseif* variants, and I find them
quite ugly, so from an aethetical point of view I would prefer to
avoid that... On the other hand having an "else if" capability makes
sense (eg do something slightly different for various versions of pg),
so that would suggest to stick to a simpler "if" without variants, if
possible.

FTR I *strongly* disagree with this. (And if you can't remember a
language that comes with them then you need to get out more. The Bourne
shell, where it's spelled "elif", and Ada are two obvious examples.)

Not to mention PL/pgSQL and Perl.

--
-David
david@pgmasters.net

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#18Andrew Dunstan
andrew@dunslane.net
In reply to: David Steele (#17)
Re: PSQL commands: \quit_if, \quit_unless

On 11/29/2016 05:25 PM, David Steele wrote:

On 11/29/16 5:08 PM, Andrew Dunstan wrote:

On 11/29/2016 03:07 PM, Fabien COELHO wrote:

I cannot remember a language with elseif* variants, and I find them
quite ugly, so from an aethetical point of view I would prefer to
avoid that... On the other hand having an "else if" capability makes
sense (eg do something slightly different for various versions of pg),
so that would suggest to stick to a simpler "if" without variants, if
possible.

FTR I *strongly* disagree with this. (And if you can't remember a
language that comes with them then you need to get out more. The Bourne
shell, where it's spelled "elif", and Ada are two obvious examples.)

Not to mention PL/pgSQL and Perl.

Indeed.

cheers

andrew

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#19David Fetter
david@fetter.org
In reply to: Fabien COELHO (#12)
Re: PSQL commands: \quit_if, \quit_unless

On Tue, Nov 29, 2016 at 01:10:06PM +0100, Fabien COELHO wrote:

If there is a negative condition syntax, I would slightly prefer \ifnot to
\if_not or worse \unless. I would disaprove strongly of \unless because it
looses the clear symmetry with a closing \fi.

I take it \sselnu is right out.

Best,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#20Tom Lane
tgl@sss.pgh.pa.us
In reply to: David Fetter (#19)
Re: PSQL commands: \quit_if, \quit_unless

David Fetter <david@fetter.org> writes:

On Tue, Nov 29, 2016 at 01:10:06PM +0100, Fabien COELHO wrote:

If there is a negative condition syntax, I would slightly prefer \ifnot to
\if_not or worse \unless. I would disaprove strongly of \unless because it
looses the clear symmetry with a closing \fi.

I take it \sselnu is right out.

[ splorf... ] But really, \fi is something that could only be loved
by a certain academic breed of hackers. I'd go for \endif, probably.
That still doesn't relate well with \unless, so +1 for \if, \ifnot,
\else, and \endif.

I'm not really convinced that we need an \elseif at this point.
It could be added later if people find it compelling, but I'm
having a hard time believing that it's essential.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#21Fabien COELHO
coelho@cri.ensmp.fr
In reply to: Tom Lane (#20)
#22Fabien COELHO
coelho@cri.ensmp.fr
In reply to: Andrew Dunstan (#16)
#23Andrew Dunstan
andrew@dunslane.net
In reply to: Fabien COELHO (#22)
#24Robert Haas
robertmhaas@gmail.com
In reply to: Pavel Stehule (#11)
#25Tom Lane
tgl@sss.pgh.pa.us
In reply to: Robert Haas (#24)
#26Corey Huinker
corey.huinker@gmail.com
In reply to: Tom Lane (#25)
#27Tom Lane
tgl@sss.pgh.pa.us
In reply to: Corey Huinker (#26)
#28Robert Haas
robertmhaas@gmail.com
In reply to: Corey Huinker (#26)
#29Jim Nasby
Jim.Nasby@BlueTreble.com
In reply to: Robert Haas (#28)
#30Fabien COELHO
coelho@cri.ensmp.fr
In reply to: Tom Lane (#27)
#31Pavel Stehule
pavel.stehule@gmail.com
In reply to: Fabien COELHO (#30)
#32Fabien COELHO
coelho@cri.ensmp.fr
In reply to: Pavel Stehule (#31)
#33Pavel Stehule
pavel.stehule@gmail.com
In reply to: Fabien COELHO (#32)
#34Fabien COELHO
coelho@cri.ensmp.fr
In reply to: Pavel Stehule (#33)
#35Pavel Stehule
pavel.stehule@gmail.com
In reply to: Fabien COELHO (#34)
#36Robert Haas
robertmhaas@gmail.com
In reply to: Fabien COELHO (#30)
#37Fabien COELHO
coelho@cri.ensmp.fr
In reply to: Robert Haas (#36)
#38Robert Haas
robertmhaas@gmail.com
In reply to: Fabien COELHO (#37)
#39Fabien COELHO
coelho@cri.ensmp.fr
In reply to: Robert Haas (#38)
#40Robert Haas
robertmhaas@gmail.com
In reply to: Fabien COELHO (#39)
#41Fabien COELHO
coelho@cri.ensmp.fr
In reply to: Robert Haas (#40)
#42Robert Haas
robertmhaas@gmail.com
In reply to: Robert Haas (#36)
#43David G. Johnston
david.g.johnston@gmail.com
In reply to: Robert Haas (#42)
#44Pavel Stehule
pavel.stehule@gmail.com
In reply to: David G. Johnston (#43)
#45David G. Johnston
david.g.johnston@gmail.com
In reply to: Pavel Stehule (#44)
#46Tom Lane
tgl@sss.pgh.pa.us
In reply to: Robert Haas (#42)
#47Pavel Stehule
pavel.stehule@gmail.com
In reply to: David G. Johnston (#45)
#48Robert Haas
robertmhaas@gmail.com
In reply to: Pavel Stehule (#44)
#49Pavel Stehule
pavel.stehule@gmail.com
In reply to: Robert Haas (#48)
#50Fabien COELHO
coelho@cri.ensmp.fr
In reply to: Tom Lane (#46)
#51Pavel Stehule
pavel.stehule@gmail.com
In reply to: Fabien COELHO (#50)
#52Robert Haas
robertmhaas@gmail.com
In reply to: Tom Lane (#46)
#53Corey Huinker
corey.huinker@gmail.com
In reply to: Robert Haas (#52)
#54Robert Haas
robertmhaas@gmail.com
In reply to: Corey Huinker (#53)
#55Pavel Stehule
pavel.stehule@gmail.com
In reply to: Robert Haas (#54)
#56David G. Johnston
david.g.johnston@gmail.com
In reply to: Robert Haas (#54)
#57Corey Huinker
corey.huinker@gmail.com
In reply to: Robert Haas (#54)
#58Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: David G. Johnston (#56)
#59David G. Johnston
david.g.johnston@gmail.com
In reply to: Alvaro Herrera (#58)
#60Corey Huinker
corey.huinker@gmail.com
In reply to: David G. Johnston (#59)
#61Pavel Stehule
pavel.stehule@gmail.com
In reply to: Corey Huinker (#60)
#62Tom Lane
tgl@sss.pgh.pa.us
In reply to: Pavel Stehule (#61)
#63Fabien COELHO
coelho@cri.ensmp.fr
In reply to: Tom Lane (#62)
#64Jim Nasby
Jim.Nasby@BlueTreble.com
In reply to: Tom Lane (#62)
#65Robert Haas
robertmhaas@gmail.com
In reply to: Tom Lane (#62)
#66Michael Paquier
michael@paquier.xyz
In reply to: Robert Haas (#65)
#67Corey Huinker
corey.huinker@gmail.com
In reply to: Michael Paquier (#66)