Re: ecpg: issue related to preprocessor directives

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: ecpg: issue related to preprocessor directives
Date: 2020-08-01 00:06:31
Message-ID: 1853327.1596240391@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com> writes:
> When the following ecpg program having preprocessor directives is compiled,
> the output produced is not correct.
> ...
> As seen from above output, both exec sql ifdef and exec sql else block got
> compiled which is wrong. If the above output is further compiled using gcc
> compiler, the compilation would fail.

Looking at pgc.l, it seems that 'elif' is treated as though it were
'endif' followed by 'ifdef', which of course completely loses the
expected property that a previous successful branch would keep the
elif branch from being expanded.

While this doesn't look terribly hard to fix, I'm a little disturbed
by the fact that the existing semantics seem to date back to 1999
(b57b0e044). We're probably risking breaking existing app code if
we change it. I think we *should* change it, of course, but I'm kind
of inclined not to back-patch.

regards, tom lane

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Tom Lane 2020-08-01 14:35:31 Re: ecpg: issue related to preprocessor directives
Previous Message Ashutosh Sharma 2020-07-31 05:16:00 ecpg: issue related to preprocessor directives