On 15 January 2017 at 05:18, Tom Lane <t...@sss.pgh.pa.us> wrote: > Fabien COELHO <coe...@cri.ensmp.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 . https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=ab1f0c8225714aaa18d2f9ca4f80cd009f145421 https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=83f2061dd037477ec8479ee160367840e203a722 -- Craig Ringer http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (firstname.lastname@example.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers