pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix ecpg's mishandling of B'...' and X'...' literals. 2+ messages / 1 participants [nested] [flat]
* pgsql: Fix ecpg's mishandling of B'...' and X'...' literals. @ 2020-11-07 20:03 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2020-11-07 20:03 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix ecpg's mishandling of B'...' and X'...' literals. These were broken in multiple ways: * The xbstart and xhstart lexer actions neglected to set "state_before_str_start" before transitioning to the xb/xh states, thus possibly resulting in "internal error: unreachable state" later. * The test for valid string contents at the end of xb state was flat out wrong, as it accounted incorrectly for the "b" prefix that the xbstart action had injected. Meanwhile, the xh state had no such check at all. * The generated literal value failed to include any quote marks. * The grammar did the wrong thing anyway, typically ignoring the literal value and emitting something else, since BCONST and XCONST tokens were handled randomly differently from SCONST tokens. The first of these problems is evidently an oversight in commit 7f380c59f, but the others seem to be very ancient. The lack of complaints shows that ECPG users aren't using these syntaxes much (although I do vaguely remember one previous complaint). As written, this patch is dependent on 7f380c59f, so it can't go back further than v13. Given the shortage of complaints, I'm not excited about adapting the patch to prior branches. Report and patch by Shenhao Wang (test case adjusted by me) Discussion: https://postgr.es/m/d6402f1bacb74ecba22ef715dbba17fd@G08CNEXMBPEKD06.g08.fujitsu.local Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/1e3868ab3bef5cfa0f4d44a6937a880be7a3a482 Modified Files -------------- src/interfaces/ecpg/preproc/ecpg.trailer | 4 ++-- src/interfaces/ecpg/preproc/ecpg.type | 2 ++ src/interfaces/ecpg/preproc/parse.pl | 1 + src/interfaces/ecpg/preproc/pgc.l | 12 +++++++----- src/interfaces/ecpg/test/expected/preproc-strings.c | 12 +++++++++++- src/interfaces/ecpg/test/expected/preproc-strings.stderr | 10 ++++++++++ src/interfaces/ecpg/test/expected/preproc-strings.stdout | 1 + src/interfaces/ecpg/test/preproc/strings.pgc | 5 +++++ 8 files changed, 39 insertions(+), 8 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: Fix ecpg's mishandling of B'...' and X'...' literals. @ 2020-11-07 20:03 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2020-11-07 20:03 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix ecpg's mishandling of B'...' and X'...' literals. These were broken in multiple ways: * The xbstart and xhstart lexer actions neglected to set "state_before_str_start" before transitioning to the xb/xh states, thus possibly resulting in "internal error: unreachable state" later. * The test for valid string contents at the end of xb state was flat out wrong, as it accounted incorrectly for the "b" prefix that the xbstart action had injected. Meanwhile, the xh state had no such check at all. * The generated literal value failed to include any quote marks. * The grammar did the wrong thing anyway, typically ignoring the literal value and emitting something else, since BCONST and XCONST tokens were handled randomly differently from SCONST tokens. The first of these problems is evidently an oversight in commit 7f380c59f, but the others seem to be very ancient. The lack of complaints shows that ECPG users aren't using these syntaxes much (although I do vaguely remember one previous complaint). As written, this patch is dependent on 7f380c59f, so it can't go back further than v13. Given the shortage of complaints, I'm not excited about adapting the patch to prior branches. Report and patch by Shenhao Wang (test case adjusted by me) Discussion: https://postgr.es/m/d6402f1bacb74ecba22ef715dbba17fd@G08CNEXMBPEKD06.g08.fujitsu.local Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/1bccb159af5813b8f34fd177acdbdb2ad82cd596 Modified Files -------------- src/interfaces/ecpg/preproc/ecpg.trailer | 4 ++-- src/interfaces/ecpg/preproc/ecpg.type | 2 ++ src/interfaces/ecpg/preproc/parse.pl | 1 + src/interfaces/ecpg/preproc/pgc.l | 12 +++++++----- src/interfaces/ecpg/test/expected/preproc-strings.c | 12 +++++++++++- src/interfaces/ecpg/test/expected/preproc-strings.stderr | 10 ++++++++++ src/interfaces/ecpg/test/expected/preproc-strings.stdout | 1 + src/interfaces/ecpg/test/preproc/strings.pgc | 5 +++++ 8 files changed, 39 insertions(+), 8 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2020-11-07 20:03 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2020-11-07 20:03 pgsql: Fix ecpg's mishandling of B'...' and X'...' literals. Tom Lane <tgl@sss.pgh.pa.us> 2020-11-07 20:03 pgsql: Fix ecpg's mishandling of B'...' and X'...' literals. Tom Lane <tgl@sss.pgh.pa.us>
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