]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix behavior of ecpg's "EXEC SQL elif name".
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 3 Aug 2020 13:46:12 +0000 (09:46 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 3 Aug 2020 13:46:12 +0000 (09:46 -0400)
commit44cd434ec4a70d2dfbc460492fc0574d08440250
tree180986e2085b5692bee288bd59378e205b2900aa
parentf5293fb09e7346bb663f2f5c63081e8aabe61a8e
Fix behavior of ecpg's "EXEC SQL elif name".

This ought to work much like C's "#elif defined(name)"; but the code
implemented it in a way equivalent to endif followed by ifdef, so that
it didn't matter whether any previous branch of the IF construct had
succeeded.  Fix that; add some test cases covering elif and nested IFs;
and improve the documentation, which also seemed a bit confused.

AFAICS the code has been like this since the feature was added in 1999
(commit b57b0e044).  So while it's surely wrong, there might be code
out there relying on the current behavior.  Hence, don't back-patch
into stable branches.  It seems all right to fix it in v13 though.

Per report from Ashutosh Sharma.  Reviewed by Ashutosh Sharma and
Michael Meskes.

Discussion: https://postgr.es/m/CAE9k0P=dQk9X0cU2tN49S7a9tv733-e1pVdpB1P-pWJ5PdTktg@mail.gmail.com
doc/src/sgml/ecpg.sgml
src/interfaces/ecpg/preproc/pgc.l
src/interfaces/ecpg/test/expected/preproc-define.c
src/interfaces/ecpg/test/expected/preproc-define.stderr
src/interfaces/ecpg/test/preproc/define.pgc