From: | Craig Ringer <craig(dot)ringer(at)2ndquadrant(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>, Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: BUG: pg_stat_statements query normalization issues with combined queries |
Date: | 2017-01-26 02:38:02 |
Message-ID: | CAMsr+YHD7whzhCyPgwK_qkrec_Zmcnpdp6MFeTDe0zfZahyKNA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 15 January 2017 at 05:18, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> writes:
>>> It ends up being about 30 fewer lines of code overall, despite there
>>> being four places that have to make ad-hoc RawStmt nodes. On the whole
>>> I feel like this is cleaner,
>
>> I agree: Better typing, more homogeneous code (PlannedStmt for all),
>> less ad-hoc checks to work around utility statements...
>
> OK, pushed like that.
Thanks very much for that Tom, it's great to see this change.
One suggestion: it's currently non-obvious that ProcessUtility_hook
gets called with the full text of all parts of a multi-statement. I
suggest the following wording added to the comment on ProcessUtility()
in src/backend/tcop/utility.c, after the note on the query string, or
something like it:
The same query string may be passed to multiple invocations of ProcessUtility
if a utility statement in turn invokes other utility statements, or if the
user supplied a query string containing multiple semicolon-separated
statements in a single protocol message. It is also possible for the query
text to contain other non-utility-statement text like comments, empty
statements, and plannable statements. Callers that use the queryString
should use pstmt->stmt_location and pstmt->stmt_len to extract the text for
the statement of interest and should guard against re-entrant invocation.
That should help with at least some of the traps around
ProcessUtility_hook, and I certainly wish I'd known it some months
ago.
For the record, this is commits
ab1f0c8225714aaa18d2f9ca4f80cd009f145421 and
83f2061dd037477ec8479ee160367840e203a722 .
--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2017-01-26 02:56:59 | Re: pg_ls_dir & friends still have a hard-coded superuser check |
Previous Message | Michael Paquier | 2017-01-26 02:17:41 | Re: pg_hba_file_settings view patch |