pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
small bug in ecpg unicode identifier error handling
3+ messages / 2 participants
[nested] [flat]

Commits from this thread:
  2022-01-12 a18b6d2dc2  ecpg: Catch zero-length Unicode identifiers correctly
* small bug in ecpg unicode identifier error handling
@ 2022-01-10 13:14 Peter Eisentraut <peter.eisentraut@enterprisedb.com>
  2022-01-10 15:05 ` Re: small bug in ecpg unicode identifier error handling Tom Lane <tgl@sss.pgh.pa.us>
  2022-01-12 10:00 ` Re: small bug in ecpg unicode identifier error handling Peter Eisentraut <peter.eisentraut@enterprisedb.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Peter Eisentraut @ 2022-01-10 13:14 UTC (permalink / raw)
  To: pgsql-hackers

I think this patch is necessary:

inline patch 1: src/interfaces/ecpg/preproc/pgc.l (+1/-1 lines) download inline-1.patchdiff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l index 07fee80a9c..3529b2ea86 100644 --- a/src/interfaces/ecpg/preproc/pgc.l +++ b/src/interfaces/ecpg/preproc/pgc.l @@ -753,7 +753,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+ } <xui>{dquote} { BEGIN(state_before_str_start); - if (literallen == 2) /* "U&" */ + if (literallen == 0) mmerror(PARSE_ERROR, ET_ERROR, "zero-length delimited identifier"); /* The backend will truncate the identifier here. We do not as it does not change the result. */ base_yylval.str = psprintf("U&\"%s\"", literalbuf);
The old code doesn't make sense. The literallen is the length of the data in literalbuf, which clearly doesn't include the "U&" as the comment suggests. A test case is to preprocess a file like this (ecpg test.pgc): exec sql select u&" which currently does *not* give the above error, but it should. ^ permalink raw reply [nested|flat] 3+ messages in thread

* Re: small bug in ecpg unicode identifier error handling
  2022-01-10 13:14 small bug in ecpg unicode identifier error handling Peter Eisentraut <peter.eisentraut@enterprisedb.com>
@ 2022-01-10 15:05 ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2022-01-10 15:05 UTC (permalink / raw)
  To: Peter Eisentraut <peter.eisentraut@enterprisedb.com>; +Cc: pgsql-hackers

Peter Eisentraut <peter.eisentraut@enterprisedb.com> writes:
> I think this patch is necessary:
> -					if (literallen == 2) /* "U&" */
> +					if (literallen == 0)

Seems sensible, and matches the corresponding code in scan.l.
+1.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: small bug in ecpg unicode identifier error handling
  2022-01-10 13:14 small bug in ecpg unicode identifier error handling Peter Eisentraut <peter.eisentraut@enterprisedb.com>
@ 2022-01-12 10:00 ` Peter Eisentraut <peter.eisentraut@enterprisedb.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Peter Eisentraut @ 2022-01-12 10:00 UTC (permalink / raw)
  To: pgsql-hackers

On 10.01.22 14:14, Peter Eisentraut wrote:
> I think this patch is necessary:
> 
> diff --git a/src/interfaces/ecpg/preproc/pgc.l 
> b/src/interfaces/ecpg/preproc/pgc.l
> index 07fee80a9c..3529b2ea86 100644
> --- a/src/interfaces/ecpg/preproc/pgc.l
> +++ b/src/interfaces/ecpg/preproc/pgc.l
> @@ -753,7 +753,7 @@ cppline            
> {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
>                   }
>   <xui>{dquote}    {
>                       BEGIN(state_before_str_start);
> -                    if (literallen == 2) /* "U&" */
> +                    if (literallen == 0)
>                           mmerror(PARSE_ERROR, ET_ERROR, "zero-length 
> delimited identifier");
>                       /* The backend will truncate the identifier here. 
> We do not as it does not change the result. */
>                       base_yylval.str = psprintf("U&\"%s\"", literalbuf);
> 
> The old code doesn't make sense.  The literallen is the length of the
> data in literalbuf, which clearly doesn't include the "U&" as the
> comment suggests.
> 
> A test case is to preprocess a file like this (ecpg test.pgc):
> 
> exec sql select u&"
> 
> which currently does *not* give the above error, but it should.

Committed.

For the record, the correct test case was actually

exec sql select u&"";





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2022-01-12 10:00 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-01-10 13:14 small bug in ecpg unicode identifier error handling Peter Eisentraut <peter.eisentraut@enterprisedb.com>
2022-01-10 15:05 ` Tom Lane <tgl@sss.pgh.pa.us>
2022-01-12 10:00 ` Peter Eisentraut <peter.eisentraut@enterprisedb.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox