Re: \if, \elseif, \else, \endif (was Re: PSQL commands: \quit_if, \quit_unless)
Fabien COELHO <coelho@cri.ensmp.fr>
From: Fabien COELHO <coelho@cri.ensmp.fr>
To: Corey Huinker <corey.huinker@gmail.com>
Cc: Daniel Verite <daniel@manitou-mail.org>, Erik Rijkers <er@xs4all.nl>,
Tom Lane <tgl@sss.pgh.pa.us>, Jim Nasby <Jim.Nasby@bluetreble.com>,
PostgreSQL <pgsql-hackers@postgresql.org>,
pgsql-hackers-owner@postgresql.org
Date: 2017-02-06T09:36:26Z
Lists: pgsql-hackers
>> # elif error >> "\\if false\n\\elif error\n\\endif\n" >> >> # ignore commands on error (stdout must be empty) >> "\\if error\n\\echo NO\n\\else\n\\echo NO\n\\endif\n" > > Those are already in the regression (around line 2763 of > expected/psql.out), are you saying we should have them in TAP as well? > Should we only do TAP tests? Ok. so, maybe just the first one. The idea would be to cover more cases of on error stop and check that it indeed stopped. Find attached a small patch to improve tap tests, which also checks that psql really exited by checking that nothing is printed afterwards. Also, for some reason there were \\n instead of \n in some place, it was working because the first command induced the error. > Anyway, here's the Ctrl-C behavior: Ok. Basically it moves up each time Ctrl-C is called. Fine. The future improvement would be to do that if the current input line was empty, otherwise only the current input line would be cleaned up. > Ctrl-C exits do the same before/after state checks that \endif does, the > lone difference being that it "escaped" the \if rather than "exited" the > \if. Thanks to Daniel for pointing out where it should be handled, because > I wasn't going to figure that out on my own. > > v7's only major difference from v6 is the Ctrl-C branch escaping. Ok. Bar from minor tests improvements, this looks pretty much ok to me. -- Fabien.
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