postgresql/src
Tom Lane 0ea9efbe9e Split psql's lexer into two separate .l files for SQL and backslash cases.
This gets us to a point where psqlscan.l can be used by other frontend
programs for the same purpose psql uses it for, ie to detect when it's
collected a complete SQL command from input that is divided across
line boundaries.  Moreover, other programs can supply their own lexers
for backslash commands of their own choosing.  A follow-on patch will
use this in pgbench.

The end result here is roughly the same as in Kyotaro Horiguchi's
0001-Make-SQL-parser-part-of-psqlscan-independent-from-ps.patch, although
the details of the method for switching between lexers are quite different.
Basically, in this patch we share the entire PsqlScanState, YY_BUFFER_STATE
stack, *and* yyscan_t between different lexers.  The only thing we need
to do to switch to a different lexer is to make sure the start_state is
valid for the new lexer.  This works because flex doesn't keep any other
persistent state that depends on the specific lexing tables generated for
a particular .l file.  (We are assuming that both lexers are built with
the same flex version, or at least versions that are compatible with
respect to the contents of yyscan_t; but that doesn't seem likely to
be a big problem in practice, considering how slowly flex changes.)

Aside from being more efficient than Horiguchi-san's original solution,
this avoids possible corner-case changes in semantics: the original code
was capable of popping the input buffer stack while still staying in
backslash-related parsing states.  I'm not sure that that equates to any
useful user-visible behaviors, but I'm not sure it doesn't either, so
I'm loath to assume that we only need to consider the topmost buffer when
parsing a backslash command.

I've attempted to update the MSVC build scripts for the added .l file,
but will rely on the buildfarm to see if I missed anything.

Kyotaro Horiguchi and Tom Lane
2016-03-19 00:24:55 -04:00
..
backend Merge wal_level "archive" and "hot_standby" into new name "replica" 2016-03-18 23:56:03 +01:00
bin Split psql's lexer into two separate .l files for SQL and backslash cases. 2016-03-19 00:24:55 -04:00
common Make get_controlfile() error logging consistent with src/common 2016-03-07 15:14:20 -08:00
include Merge wal_level "archive" and "hot_standby" into new name "replica" 2016-03-18 23:56:03 +01:00
interfaces Be more careful about out-of-range dates and timestamps. 2016-03-16 19:09:28 -04:00
makefiles Fix typos in comments and doc 2016-01-28 16:47:36 +09:00
pl Update PL/Perl's comment about hv_store(). 2016-03-14 14:45:45 -04:00
port Suppress GCC 6 warning about self-comparison 2016-03-08 19:41:51 -05:00
template Remove some remains from Alpha support removal 2015-10-29 16:40:14 -04:00
test Merge wal_level "archive" and "hot_standby" into new name "replica" 2016-03-18 23:56:03 +01:00
timezone Update time zone data files to tzdata release 2016a. 2016-02-05 10:59:09 -05:00
tools Split psql's lexer into two separate .l files for SQL and backslash cases. 2016-03-19 00:24:55 -04:00
tutorial Update copyright for 2016 2016-01-02 13:33:40 -05:00
.gitignore
bcc32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
DEVELOPERS
Makefile Create libpgcommon, and move pg_malloc et al to it 2013-02-12 11:21:05 -03:00
Makefile.global.in Respect TEMP_CONFIG when pg_regress_check and friends are called 2016-02-27 12:28:21 -05:00
Makefile.shlib AIX: Link TRANSFORM modules with their dependencies. 2015-07-15 21:00:26 -04:00
nls-global.mk Setup error context callback for transaction lock waits 2014-03-19 15:10:36 -03:00
win32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00