From: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: small bug in ecpg unicode identifier error handling
Date: Mon, 10 Jan 2022 14:14:37 +0100
Message-ID: <82fafa79-331c-9d65-e51b-8b5d1b2383fc@enterprisedb.com> (raw)
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.lindex 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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: peter.eisentraut@enterprisedb.com
Subject: Re: small bug in ecpg unicode identifier error handling
In-Reply-To: <82fafa79-331c-9d65-e51b-8b5d1b2383fc@enterprisedb.com>
References: <82fafa79-331c-9d65-e51b-8b5d1b2383fc@enterprisedb.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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