Hi,

I just found that pg_stat_statements causes assert when queryId is
set by other module, which is loaded prior to pg_stat_statements in
the shared_preload_libraries parameter.

Theoretically, queryId in the shared memory could be set by other
module by design.

So, IMHO, pg_stat_statements should not cause assert even if queryId
already has non-zero value --- my module has this problem now.

Is my understanding correct? Any comments?

Regards,

-- 
NAGAYASU Satoshi <sn...@uptime.jp>
commit b975d7c2fe1b36a3ded1e0960be191466704e0fc
Author: Satoshi Nagayasu <sn...@uptime.jp>
Date:   Sat Aug 8 08:51:45 2015 +0000

    Fix pg_stat_statements to avoid assert failure when queryId already has 
non-zero value.

diff --git a/contrib/pg_stat_statements/pg_stat_statements.c 
b/contrib/pg_stat_statements/pg_stat_statements.c
index 59b8a2e..84c5200 100644
--- a/contrib/pg_stat_statements/pg_stat_statements.c
+++ b/contrib/pg_stat_statements/pg_stat_statements.c
@@ -776,8 +776,9 @@ pgss_post_parse_analyze(ParseState *pstate, Query *query)
        if (prev_post_parse_analyze_hook)
                prev_post_parse_analyze_hook(pstate, query);
 
-       /* Assert we didn't do this already */
-       Assert(query->queryId == 0);
+       /* Assume that other module has calculated and set queryId */
+       if (query->queryId > 0)
+               return;
 
        /* Safety check... */
        if (!pgss || !pgss_hash)
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to