Attached patch does what is described in the title, hopefully. Continuations in other pgbench backslash-commands should be dealt with elsewhere...
Also attached is a small test script.While looking at the code, I noticed that newline is \n. Maybe it should be (\r|\n|\r\n) to allow for MacOS & Windows. I have not changed that for now.
-- Fabien.
diff --git a/doc/src/sgml/ref/pgbench.sgml b/doc/src/sgml/ref/pgbench.sgml
index 285608d..6f068cd 100644
--- a/doc/src/sgml/ref/pgbench.sgml
+++ b/doc/src/sgml/ref/pgbench.sgml
@@ -818,6 +818,8 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
<para>
Sets variable <replaceable>varname</> to a value calculated
from <replaceable>expression</>.
+ The expression may span several lines with backslash-newline
+ continuations.
The expression may contain integer constants such as <literal>5432</>,
double constants such as <literal>3.14159</>,
references to variables <literal>:</><replaceable>variablename</>,
@@ -832,7 +834,8 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
Examples:
<programlisting>
\set ntellers 10 * :scale
-\set aid (1021 * random(1, 100000 * :scale)) % (100000 * :scale) + 1
+\set aid (1021 * random(1, 100000 * :scale)) % \
+ (100000 * :scale) + 1
</programlisting></para>
</listitem>
</varlistentry>
diff --git a/src/bin/pgbench/exprscan.l b/src/bin/pgbench/exprscan.l
index 20891a3..97e7a79 100644
--- a/src/bin/pgbench/exprscan.l
+++ b/src/bin/pgbench/exprscan.l
@@ -65,6 +65,8 @@ alnum [a-zA-Z0-9_]
space [ \t\r\f\v]
nonspace [^ \t\r\f\v\n]
newline [\n]
+/* continuations in pgbench expressions */
+continuation \\{newline}
/* Exclusive states */
%x EXPR
@@ -138,6 +140,8 @@ newline [\n]
return FUNCTION;
}
+{continuation} { /* ignore */ }
+
{newline} {
/* report end of command */
last_was_newline = true;
cont.sql
Description: application/sql
-- Sent via pgsql-hackers mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
