summaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/test/expected/preproc-strings.c
diff options
context:
space:
mode:
authorTom Lane2020-11-07 20:03:44 +0000
committerTom Lane2020-11-07 20:03:44 +0000
commit1e3868ab3bef5cfa0f4d44a6937a880be7a3a482 (patch)
treea3066180fe01cf5e800c7323a44ce36acdf0b720 /src/interfaces/ecpg/test/expected/preproc-strings.c
parentbdc4edbea6fc847f806e1e7118d730e159512bfc (diff)
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
Diffstat (limited to 'src/interfaces/ecpg/test/expected/preproc-strings.c')
-rw-r--r--src/interfaces/ecpg/test/expected/preproc-strings.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/interfaces/ecpg/test/expected/preproc-strings.c b/src/interfaces/ecpg/test/expected/preproc-strings.c
index 1e50cd36c38..87662e01766 100644
--- a/src/interfaces/ecpg/test/expected/preproc-strings.c
+++ b/src/interfaces/ecpg/test/expected/preproc-strings.c
@@ -63,8 +63,18 @@ int main(void)
printf("%s %s %s %s %s %s\n", s1, s2, s3, s4, s5, s6);
+ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select b'0010' , x'019ABcd'", ECPGt_EOIT,
+ ECPGt_char,&(s1),(long)0,(long)1,(1)*sizeof(char),
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+ ECPGt_char,&(s2),(long)0,(long)1,(1)*sizeof(char),
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+#line 26 "strings.pgc"
+
+
+ printf("%s %s\n", s1, s2);
+
{ ECPGdisconnect(__LINE__, "CURRENT");}
-#line 25 "strings.pgc"
+#line 30 "strings.pgc"
return 0;
}