postgresql/src/backend
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 comment in heapam.c 2020-01-13 17:57:38 +09:00
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 lsn argument of walrcv_create_slot() optional 2020-01-11 09:07:14 +01:00
executor Improve the handling of result type coercions in SQL functions. 2020-01-08 11:07:59 -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 Update copyrights for 2020 2020-01-01 12:21:45 -05:00
libpq Extensive code review for GSSAPI encryption mechanism. 2020-01-11 17:14:08 -05:00
main Update copyrights for 2020 2020-01-01 12:21:45 -05:00
nodes Reconsider the representation of join alias Vars. 2020-01-09 11:56:59 -05:00
optimizer Reconsider the representation of join alias Vars. 2020-01-09 11:56:59 -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
po Translation updates 2019-06-17 15:30:20 +02:00
port 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 Fix base backup with database OIDs larger than INT32_MAX 2020-01-13 13:41:12 +01:00
rewrite Reconsider the representation of join alias Vars. 2020-01-09 11:56:59 -05:00
snowball Update copyrights for 2020 2020-01-01 12:21:45 -05:00
statistics Apply multiple multivariate MCV lists when possible 2020-01-13 01:21:17 +01:00
storage Remove STATUS_FOUND 2020-01-11 07:48:57 +01:00
tcop Make better use of ParseState in ProcessUtility 2020-01-04 13:12:41 +01:00
tsearch Update copyrights for 2020 2020-01-01 12:21:45 -05:00
utils Fix edge-case crashes and misestimation in range containment selectivity. 2020-01-12 14:36:59 -05:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
Makefile Update copyrights for 2020 2020-01-01 12:21:45 -05:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
nls.mk Translation updates 2019-05-20 16:00:53 +02:00