Re: \if, \elseif, \else, \endif (was Re: PSQL commands: \quit_if, \quit_unless)
Jim Nasby <jim.nasby@bluetreble.com>
From: Jim Nasby <Jim.Nasby@BlueTreble.com>
To: Corey Huinker <corey.huinker@gmail.com>
Cc: Fabien COELHO <coelho@cri.ensmp.fr>, Erik Rijkers <er@xs4all.nl>, Tom Lane <tgl@sss.pgh.pa.us>, Daniel Verite <daniel@manitou-mail.org>, PostgreSQL <pgsql-hackers@postgresql.org>, <pgsql-hackers-owner@postgresql.org>
Date: 2017-02-04T00:42:18Z
Lists: pgsql-hackers
On 2/2/17 4:39 PM, Corey Huinker wrote: > > On Wed, Feb 1, 2017 at 4:58 PM, Jim Nasby <Jim.Nasby@bluetreble.com > <mailto:Jim.Nasby@bluetreble.com>> wrote: > > I think the issue here is that the original case for this is a user > accidentally getting into an \if and then having no clue what's > going on. That's similar to what happens when you miss a quote or a > semicolon. We handle those cases with %R, and I think %R needs to > support if as well. > > Perhaps there's value to providing more info (active branch, etc), > but ISTM trying to do that will just confuse the original (%R) case. > > > Jim, > > After spending a few minutes to familiarize myself with %R, I'm in > agreement with your second statement (adding if-else to %R will just > confuse %R). However, your first statement seems to indicate the > opposite. Can you elaborate? My point was that we need a way for users to know if they're stuck in an \if block, and right now that's handled with %R (inside transaction, parens, etc). My other point is that adding all the extra info to %R would be folly. Since the current consensus is to be very verbose about \if, this is obviously a non-issue. Maybe worth adding a 'I' case to %R, but no big deal if that doesn't happen. -- Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX Experts in Analytics, Data Architecture and PostgreSQL Data in Trouble? Get it in Treble! http://BlueTreble.com 855-TREBLE2 (855-873-2532)
Commits
-
Support \if ... \elif ... \else ... \endif in psql scripting.
- e984ef5861df 10.0 landed
-
Add a "void *" passthrough pointer for psqlscan.l's callback functions.
- 895e36bb3f36 10.0 landed