From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Clean up parsing of synchronous_standby_names GUC variable. |
Date: | 2016-04-27 21:55:39 |
Message-ID: | E1avXQp-0007lp-Ox@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Clean up parsing of synchronous_standby_names GUC variable.
Commit 989be0810dffd08b added a flex/bison lexer/parser to interpret
synchronous_standby_names. It was done in a pretty crufty way, though,
making assorted end-use sites responsible for calling the parser at the
right times. That was not only vulnerable to errors of omission, but made
it possible that lexer/parser errors occur at very undesirable times,
and created memory leakages even if there was no error.
Instead, perform the parsing once during check_synchronous_standby_names
and let guc.c manage the resulting data. To do that, we have to flatten
the parsed representation into a single hunk of malloc'd memory, but that
is not very hard.
While at it, work a little harder on making useful error reports for
parsing problems; the previous code felt that "synchronous_standby_names
parser returned 1" was an appropriate user-facing error message. (To
be fair, it did also log a syntax error message, but separately from the
GUC problem report, which is at best confusing.) It had some outright
bugs in the face of invalid input, too.
I (tgl) also concluded that we need to restrict unquoted names in
synchronous_standby_names to be just SQL identifiers. The previous coding
would accept darn near anything, which (1) makes the quoting convention
both nearly-unnecessary and formally ambiguous, (2) makes it very hard to
understand what is a syntax error and what is a creative interpretation of
the input as a standby name, and (3) makes it impossible to further extend
the syntax in future without a compatibility break. I presume that we're
intending future extensions of the syntax, else this parsing infrastructure
is massive overkill, so (3) is an important objection. Since we've taken
a compatibility hit for non-identifier names with this change anyway, we
might as well lock things down now and insist that users use double quotes
for standby names that aren't identifiers.
Kyotaro Horiguchi and Tom Lane
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/4c804fbdfb472cf71db33609258b8e1aaad81943
Modified Files
--------------
doc/src/sgml/config.sgml | 27 ++---
src/backend/replication/syncrep.c | 168 +++++++++++++-----------------
src/backend/replication/syncrep_gram.y | 68 ++++++++----
src/backend/replication/syncrep_scanner.l | 99 ++++++++++--------
src/backend/replication/walsender.c | 13 +--
src/backend/utils/misc/guc.c | 2 +-
src/include/replication/syncrep.h | 25 +++--
7 files changed, 208 insertions(+), 194 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2016-04-27 22:15:07 | Re: Re: [COMMITTERS] pgsql: Modify the isolation tester so that multiple sessions can wait. |
Previous Message | Thomas Munro | 2016-04-27 21:54:55 | Re: Re: [COMMITTERS] pgsql: Modify the isolation tester so that multiple sessions can wait. |