postgresql/src/include
Tom Lane 7f380c59f8 Reduce size of backend scanner's tables.
Previously, the core scanner's yy_transition[] array had 37045 elements.
Since that number is larger than INT16_MAX, Flex generated the array to
contain 32-bit integers.  By reimplementing some of the bulkier scanner
rules, this patch reduces the array to 20495 elements.  The much smaller
total length, combined with the consequent use of 16-bit integers for
the array elements reduces the binary size by over 200kB.  This was
accomplished in two ways:

1. Consolidate handling of quote continuations into a new start condition,
rather than duplicating that logic for five different string types.

2. Treat Unicode strings and identifiers followed by a UESCAPE sequence
as three separate tokens, rather than one.  The logic to de-escape
Unicode strings is moved to the filter code in parser.c, which already
had the ability to provide special processing for token sequences.
While we could have implemented the conversion in the grammar, that
approach was rejected for performance and maintainability reasons.

Performance in microbenchmarks of raw parsing seems equal or slightly
faster in most cases, and it's reasonable to expect that in real-world
usage (with more competition for the CPU cache) there will be a larger
win.  The exception is UESCAPE sequences; lexing those is about 10%
slower, primarily because the scanner now has to be called three times
rather than one.  This seems acceptable since that feature is very
rarely used.

The psql and epcg lexers are likewise modified, primarily because we
want to keep them all in sync.  Since those lexers don't use the
space-hogging -CF option, the space savings is much less, but it's
still good for perhaps 10kB apiece.

While at it, merge the ecpg lexer's handling of C-style comments used
in SQL and in C.  Those have different rules regarding nested comments,
but since we already have the ability to keep track of the previous
start condition, we can use that to handle both cases within a single
start condition.  This matches the core scanner more closely.

John Naylor

Discussion: https://postgr.es/m/CACPNZCvaoa3EgVWm5yZhcSTX6RAtaLgniCPcBVOCwm8h3xpWkw@mail.gmail.com
2020-01-13 15:04:31 -05:00
..
access Fix typo. 2020-01-13 14:44:55 +05:30
bootstrap Update copyrights for 2020 2020-01-01 12:21:45 -05:00
catalog Reconsider the representation of join alias Vars. 2020-01-09 11:56:59 -05:00
commands Make better use of ParseState in ProcessUtility 2020-01-04 13:12:41 +01:00
common Add support for automatically updating Unicode derived files 2020-01-09 10:08:14 +01:00
datatype Update copyrights for 2020 2020-01-01 12:21:45 -05:00
executor Improve the handling of result type coercions in SQL functions. 2020-01-08 11:07:59 -05:00
fe_utils Reduce size of backend scanner's tables. 2020-01-13 15:04:31 -05:00
foreign Update copyrights for 2020 2020-01-01 12:21:45 -05:00
jit Update copyrights for 2020 2020-01-01 12:21:45 -05:00
lib Skip memcpy(x, x) in qunique(). 2020-01-04 11:31:42 -08:00
libpq Update copyrights for 2020 2020-01-01 12:21:45 -05:00
mb Reduce size of backend scanner's tables. 2020-01-13 15:04:31 -05:00
nodes Reconsider the representation of join alias Vars. 2020-01-09 11:56:59 -05:00
optimizer Update copyrights for 2020 2020-01-01 12:21:45 -05:00
parser Reduce size of backend scanner's tables. 2020-01-13 15:04:31 -05:00
partitioning Update copyrights for 2020 2020-01-01 12:21:45 -05:00
port Update copyrights for 2020 2020-01-01 12:21:45 -05:00
portability Update copyrights for 2020 2020-01-01 12:21:45 -05:00
postmaster Update copyrights for 2020 2020-01-01 12:21:45 -05:00
regex Update copyrights for 2020 2020-01-01 12:21:45 -05:00
replication Clean up representation of flags in struct ReorderBufferTXN 2020-01-10 17:46:57 -03:00
rewrite Update copyrights for 2020 2020-01-01 12:21:45 -05:00
snowball Update copyrights for 2020 2020-01-01 12:21:45 -05:00
statistics Update copyrights for 2020 2020-01-01 12:21:45 -05:00
storage Remove STATUS_FOUND 2020-01-11 07:48:57 +01:00
tcop Update copyrights for 2020 2020-01-01 12:21:45 -05:00
tsearch Update copyrights for 2020 2020-01-01 12:21:45 -05:00
utils Update copyrights for 2020 2020-01-01 12:21:45 -05:00
.gitignore Refactor dlopen() support 2018-09-06 11:33:04 +02:00
Makefile Get rid of jsonpath_gram.h and jsonpath_scanner.h 2019-03-20 11:13:34 +03:00
c.h Remove STATUS_FOUND 2020-01-11 07:48:57 +01:00
fmgr.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
funcapi.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
getaddrinfo.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
getopt_long.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
miscadmin.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_config.h.in Fix handling of OpenSSL's SSL_clear_options 2019-12-06 15:13:55 +09:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_manual.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_getopt.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_trace.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pgstat.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pgtar.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pgtime.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
port.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
postgres.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
postgres_ext.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postgres_fe.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
rusagestub.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
windowapi.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00