pgsql: Fix ecpg's mishandling of B'...' and X'...' literals.
От | Tom Lane |
---|---|
Тема | pgsql: Fix ecpg's mishandling of B'...' and X'...' literals. |
Дата | |
Msg-id | E1kbURJ-00056d-1y@gemulon.postgresql.org обсуждение исходный текст |
Список | pgsql-committers |
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(-)
В списке pgsql-committers по дате отправления: