pgsql: Fix behavior of ecpg's "EXEC SQL elif name".

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

pgsql: Fix behavior of ecpg's "EXEC SQL elif name".

Tom Lane-2
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.




Modified Files
doc/src/sgml/ecpg.sgml                             |  50 +++++---
src/interfaces/ecpg/preproc/pgc.l                  | 128 ++++++++++++++-------
src/interfaces/ecpg/test/expected/preproc-define.c |  79 ++++++++-----
.../ecpg/test/expected/preproc-define.stderr       |  48 ++++----
src/interfaces/ecpg/test/preproc/define.pgc        |  17 +++
5 files changed, 211 insertions(+), 111 deletions(-)