summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2018-09-17 16:11:43 +0000
committerTom Lane2018-09-17 16:11:43 +0000
commitdb37ab2c60b877b977f531bcd680848ee4511537 (patch)
tree4c64e62955cd9ed03fac3269d92917d40718d29c
parentf9907c6ac2e9817baffe37c9087bedc8df3e9625 (diff)
Fix pgbench lexer's "continuation" rule to cope with Windows newlines.
Our general practice in frontend code is to accept input with either Unix-style newlines (\n) or DOS-style (\r\n). pgbench was mostly down with that, but its rule for line continuations (backslash-newline) was not. This had been masked on Windows buildfarm machines before commit 0ba06e0bf by use of Windows text mode to read files. We could have fixed it by forcing text mode again, but it's better to fix the parsing code so that Windows-style text files on Unix systems don't cause problems. Back-patch to v10 where pgbench grew line continuations. Discussion: https://postgr.es/m/[email protected]
-rw-r--r--src/bin/pgbench/exprscan.l10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/bin/pgbench/exprscan.l b/src/bin/pgbench/exprscan.l
index 5c1bd88128..61c20364ed 100644
--- a/src/bin/pgbench/exprscan.l
+++ b/src/bin/pgbench/exprscan.l
@@ -69,7 +69,7 @@ nonspace [^ \t\r\f\v\n]
newline [\n]
/* Line continuation marker */
-continuation \\{newline}
+continuation \\\r?{newline}
/* case insensitive keywords */
and [Aa][Nn][Dd]
@@ -122,8 +122,12 @@ notnull [Nn][Oo][Tt][Nn][Uu][Ll][Ll]
* a continuation marker just after a word:
*/
{nonspace}+{continuation} {
- /* Found "word\\\n", emit and return just "word" */
- psqlscan_emit(cur_state, yytext, yyleng - 2);
+ /* Found "word\\\r?\n", emit and return just "word" */
+ int wordlen = yyleng - 2;
+ if (yytext[wordlen] == '\r')
+ wordlen--;
+ Assert(yytext[wordlen] == '\\');
+ psqlscan_emit(cur_state, yytext, wordlen);
return 1;
}