summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2017-05-19 22:05:20 +0000
committerTom Lane2017-05-19 22:05:20 +0000
commit5c837ddd7092ce9243225d12ca03fdbae136227f (patch)
tree764764c57bb16c785ffca3626f8bbf07d9611339
parenta95410e2ec39b6776381fd01198dc57a063e8185 (diff)
Rethink flex flags for syncrep_scanner.l.
Using flex's -i switch to achieve case-insensitivity is not a very safe practice, because the scanner's behavior may then depend on the locale that flex was invoked in. In the particular example at hand, that's not academic: the possible matches for "FIRST" will be different in a Turkish locale than elsewhere. Do it the hard way instead, as our other scanners do. Also, drop use of -b -CF -p, because this scanner is only used when parsing the contents of a GUC variable. That's not done often, and the amount of text to be parsed can be expected to be trivial, so prioritizing scanner speed over code size seems like quite the wrong tradeoff. Using flex's default optimization options reduces the size of syncrep_gram.o by more than 50%. The case-insensitivity problem is new in HEAD (cf commit 3901fd70c). The poor choice of optimization flags exists also in 9.6, but it doesn't seem important enough to back-patch. Discussion: https://postgr.es/m/[email protected]
-rw-r--r--src/backend/replication/Makefile5
-rw-r--r--src/backend/replication/syncrep_scanner.l6
2 files changed, 6 insertions, 5 deletions
diff --git a/src/backend/replication/Makefile b/src/backend/replication/Makefile
index da8bcf0471..562b55fbaa 100644
--- a/src/backend/replication/Makefile
+++ b/src/backend/replication/Makefile
@@ -24,10 +24,9 @@ include $(top_srcdir)/src/backend/common.mk
# repl_scanner is compiled as part of repl_gram
repl_gram.o: repl_scanner.c
-# syncrep_scanner is complied as part of syncrep_gram
+# syncrep_scanner is compiled as part of syncrep_gram
syncrep_gram.o: syncrep_scanner.c
-syncrep_scanner.c: FLEXFLAGS = -CF -p -i
-syncrep_scanner.c: FLEX_NO_BACKUP=yes
# repl_gram.c, repl_scanner.c, syncrep_gram.c and syncrep_scanner.c
# are in the distribution tarball, so they are not cleaned here.
+# (Our parent Makefile takes care of them during maintainer-clean.)
diff --git a/src/backend/replication/syncrep_scanner.l b/src/backend/replication/syncrep_scanner.l
index 7baf1b68d1..d1d1b26a48 100644
--- a/src/backend/replication/syncrep_scanner.l
+++ b/src/backend/replication/syncrep_scanner.l
@@ -64,8 +64,10 @@ xdinside [^"]+
%%
{space}+ { /* ignore */ }
-ANY { return ANY; }
-FIRST { return FIRST; }
+ /* brute-force case insensitivity is safer than relying on flex -i */
+
+[Aa][Nn][Yy] { return ANY; }
+[Ff][Ii][Rr][Ss][Tt] { return FIRST; }
{xdstart} {
initStringInfo(&xdbuf);