pgsql: SQL commands in pgbench scripts are now ended by semicolons, not

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: SQL commands in pgbench scripts are now ended by semicolons, not
Дата
Msg-id E1ahgh5-0001sl-Mb@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
SQL commands in pgbench scripts are now ended by semicolons, not newlines.

To allow multiline SQL commands in scripts, adopt the same rules psql uses
to decide what is the end of a SQL command, to wit, an unquoted semicolon
not encased in parentheses.  Do this by importing the same flex lexer that
psql uses, since coping with stuff like dollar-quoted literals is hard to
get right without going the full nine yards.

This makes use of the infrastructure added in commit 0ea9efbe9ec1bf07 to
support independently-written flex lexers scanning the same PsqlScanState
input-buffer data structure.  Since that infrastructure isn't very
friendly to ad-hoc parsing code such as strtok(), improve exprscan.l
so that it can parse either whitespace-separated words or expression
tokens, on demand, and rewrite pgbench.c's backslash-command parsing
code to always use the lexer to fetch tokens.

It's still the case that pgbench backslash commands extend to the end
of the line, no more and no less.  That could be changed in a fairly
localized way now, and there was some interest in doing so, but it
seems like material for a separate patch.

In passing, make some marginal cleanups in syntax error reporting,
const-ify a few data structures that could use it, and run some of
this code through pgindent.

I can't tell whether the MSVC build scripts need to be taught explicitly
about the changes here or not, but the buildfarm will soon tell us.

Kyotaro Horiguchi and Tom Lane

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/68ab8e8ba4a471d91b69f2f89782ba10a0fbef0c

Modified Files
--------------
doc/src/sgml/ref/pgbench.sgml |  43 ++-
src/bin/pgbench/Makefile      |  14 +-
src/bin/pgbench/exprparse.y   |  65 ++--
src/bin/pgbench/exprscan.l    | 320 ++++++++++++++----
src/bin/pgbench/pgbench.c     | 750 ++++++++++++++++++++++++------------------
src/bin/pgbench/pgbench.h     |  25 +-
6 files changed, 776 insertions(+), 441 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: pgsql: Make pgbench's expression lexer reentrant.
Следующее
От: Tom Lane
Дата:
Сообщение: Re: pgsql: Make pgbench's expression lexer reentrant.