aboutsummaryrefslogtreecommitdiff
path: root/contrib/pg_stat_statements
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-01-22 18:10:47 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2015-01-22 18:11:00 -0500
commiteb213acfe2a51ab3dc6d9bbe02d5d8a903366779 (patch)
tree40de0ad7990d8b1b7fd415f1c31b91ed515bd920 /contrib/pg_stat_statements
parentf5f2c2de163352849879fd40e9793a0195fd6594 (diff)
downloadpostgresql-eb213acfe2a51ab3dc6d9bbe02d5d8a903366779.tar.gz
postgresql-eb213acfe2a51ab3dc6d9bbe02d5d8a903366779.zip
Prevent duplicate escape-string warnings when using pg_stat_statements.
contrib/pg_stat_statements will sometimes run the core lexer a second time on submitted statements. Formerly, if you had standard_conforming_strings turned off, this led to sometimes getting two copies of any warnings enabled by escape_string_warning. While this is probably no longer a big deal in the field, it's a pain for regression testing. To fix, change the lexer so it doesn't consult the escape_string_warning GUC variable directly, but looks at a copy in the core_yy_extra_type state struct. Then, pg_stat_statements can change that copy to disable warnings while it's redoing the lexing. It seemed like a good idea to make this happen for all three of the GUCs consulted by the lexer, not just escape_string_warning. There's not an immediate use-case for callers to adjust the other two AFAIK, but making it possible is easy enough and seems like good future-proofing. Arguably this is a bug fix, but there doesn't seem to be enough interest to justify a back-patch. We'd not be able to back-patch exactly as-is anyway, for fear of breaking ABI compatibility of the struct. (We could perhaps back-patch the addition of only escape_string_warning by adding it at the end of the struct, where there's currently alignment padding space.)
Diffstat (limited to 'contrib/pg_stat_statements')
-rw-r--r--contrib/pg_stat_statements/pg_stat_statements.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c
index 2629bfca34f..95616b36914 100644
--- a/contrib/pg_stat_statements/pg_stat_statements.c
+++ b/contrib/pg_stat_statements/pg_stat_statements.c
@@ -2816,6 +2816,9 @@ fill_in_constant_lengths(pgssJumbleState *jstate, const char *query)
ScanKeywords,
NumScanKeywords);
+ /* we don't want to re-emit any escape string warnings */
+ yyextra.escape_string_warning = false;
+
/* Search for each constant, in sequence */
for (i = 0; i < jstate->clocations_count; i++)
{