Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcdc2a70

Browse files
committed
Allow backslash line continuations in pgbench's meta commands.
A pgbench meta command can now be continued onto additional line(s) of ascript file by writing backslash-return. The continuation marker isequivalent to white space in that it separates tokens.Eventually it'd be nice to have the same thing in psql, but that willbe a much larger project.Fabien Coelho, reviewed by Rafia SabihDiscussion:https://postgr.es/m/alpine.DEB.2.20.1610031049310.19411@lancre
1 parent9547370 commitcdc2a70

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

‎doc/src/sgml/ref/pgbench.sgml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,8 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
809809

810810
<para>
811811
Script file meta commands begin with a backslash (<literal>\</>) and
812-
extend to the end of the line.
812+
normally extend to the end of the line, although they can be continued
813+
to additional lines by writing backslash-return.
813814
Arguments to a meta command are separated by white space.
814815
These meta commands are supported:
815816
</para>
@@ -838,7 +839,8 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
838839
Examples:
839840
<programlisting>
840841
\set ntellers 10 * :scale
841-
\set aid (1021 * random(1, 100000 * :scale)) % (100000 * :scale) + 1
842+
\set aid (1021 * random(1, 100000 * :scale)) % \
843+
(100000 * :scale) + 1
842844
</programlisting></para>
843845
</listitem>
844846
</varlistentry>

‎src/bin/pgbench/exprscan.l

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ space[ \t\r\f\v]
6666
nonspace[^\t\r\f\v\n]
6767
newline[\n]
6868

69+
/* Line continuation marker */
70+
continuation\\{newline}
71+
6972
/* Exclusive states */
7073
%xEXPR
7174

@@ -96,8 +99,20 @@ newline[\n]
9699
return1;
97100
}
98101

102+
/*
103+
* We need this rule to avoid returning "word\" instead of recognizing
104+
* a continuation marker just after a word:
105+
*/
106+
{nonspace}+{continuation}{
107+
/* Found "word\\\n", emit and return just "word" */
108+
psqlscan_emit(cur_state, yytext, yyleng -2);
109+
return1;
110+
}
111+
99112
{space}+{/* ignore */ }
100113

114+
{continuation}{/* ignore */ }
115+
101116
{newline}{
102117
/* report end of command */
103118
last_was_newline =true;
@@ -138,14 +153,16 @@ newline[\n]
138153
return FUNCTION;
139154
}
140155

156+
{space}+{/* ignore */ }
157+
158+
{continuation}{/* ignore */ }
159+
141160
{newline}{
142161
/* report end of command */
143162
last_was_newline =true;
144163
return0;
145164
}
146165

147-
{space}+{/* ignore */ }
148-
149166
.{
150167
/*
151168
* must strdup yytext so that expr_yyerror_more doesn't

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp