aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2017-01-20 11:10:02 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2017-01-20 11:10:22 -0500
commitcdc2a70470bdbe3663dc464deb753d6d931bba61 (patch)
tree66d0896df12847de3794d3dd28f4e610ddbd9659 /src
parent954737095061e5b5f1d87fb8cc43f7f8afff64c6 (diff)
downloadpostgresql-cdc2a70470bdbe3663dc464deb753d6d931bba61.tar.gz
postgresql-cdc2a70470bdbe3663dc464deb753d6d931bba61.zip
Allow backslash line continuations in pgbench's meta commands.
A pgbench meta command can now be continued onto additional line(s) of a script file by writing backslash-return. The continuation marker is equivalent to white space in that it separates tokens. Eventually it'd be nice to have the same thing in psql, but that will be a much larger project. Fabien Coelho, reviewed by Rafia Sabih Discussion: https://postgr.es/m/alpine.DEB.2.20.1610031049310.19411@lancre
Diffstat (limited to 'src')
-rw-r--r--src/bin/pgbench/exprscan.l21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/bin/pgbench/exprscan.l b/src/bin/pgbench/exprscan.l
index 9a3be3d667f..dc1367bbdbc 100644
--- a/src/bin/pgbench/exprscan.l
+++ b/src/bin/pgbench/exprscan.l
@@ -66,6 +66,9 @@ space [ \t\r\f\v]
nonspace [^ \t\r\f\v\n]
newline [\n]
+/* Line continuation marker */
+continuation \\{newline}
+
/* Exclusive states */
%x EXPR
@@ -96,8 +99,20 @@ newline [\n]
return 1;
}
+ /*
+ * We need this rule to avoid returning "word\" instead of recognizing
+ * a continuation marker just after a word:
+ */
+{nonspace}+{continuation} {
+ /* Found "word\\\n", emit and return just "word" */
+ psqlscan_emit(cur_state, yytext, yyleng - 2);
+ return 1;
+ }
+
{space}+ { /* ignore */ }
+{continuation} { /* ignore */ }
+
{newline} {
/* report end of command */
last_was_newline = true;
@@ -138,14 +153,16 @@ newline [\n]
return FUNCTION;
}
+{space}+ { /* ignore */ }
+
+{continuation} { /* ignore */ }
+
{newline} {
/* report end of command */
last_was_newline = true;
return 0;
}
-{space}+ { /* ignore */ }
-
. {
/*
* must strdup yytext so that expr_yyerror_more doesn't