Re: ECPG cleanup and fix for clang compile-time problem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alexander Lakhin <exclusion(at)gmail(dot)com>
Cc: John Naylor <johncnaylorls(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Subject: Re: ECPG cleanup and fix for clang compile-time problem
Date: 2024-10-17 19:42:41
Message-ID: 704337.1729194161@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alexander Lakhin <exclusion(at)gmail(dot)com> writes:
> I've spent a day testing ecpg preprocessor and found another couple of
> bugs:

Thanks for the report! The first couple of these seem simple
enough to fix, so I've done so. As for

> Also, processing of .../ecpg/test/sql/include.pgc, containing only:
> EXEC SQL INCLUDE ../sql;
> emits merely:
> input in flex scanner failed

what we have here is an attempt to read a directory. On Linux
it seems that fopen() is okay with that but then fread() fails
with EISDIR. The fread() occurs in code emitted by flex that
is totally failing to produce a useful error report:

while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, base_yyin)) == 0 && ferror(base_yyin)) \
{ \
if( errno != EINTR) \
{ \
YY_FATAL_ERROR( "input in flex scanner failed" ); \
break; \
} \

It looks like YY_FATAL_ERROR can only accept a literal string,
so I can see why this isn't including strerror(errno), but still
I'd say that this is their poor error reporting not ours. The
only thing we could really do about it is fstat the fopen's FD
and see if it's a directory, but that would only improve matters
for EISDIR not any other error cause. I don't believe we've done
that anywhere else we use flex, so I'm not inclined to do it here.

> I think that's all that can be found here without extra efforts.

Thanks for poking at it! I don't feel a huge need to search out
ecpg bugs in advance of field reports, but we might as well fix
things we do stumble across.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Florents Tselai 2024-10-17 20:09:58 Re: doc: virtual envs with Pl/Python
Previous Message Bruce Momjian 2024-10-17 18:05:02 Re: minor doc issue in 9.16.2.1.1. Boolean Predicate Check Expressions