Re: Set query_id for query contained in utility statement
Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
From: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
To: jian he <jian.universality@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>,
PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2024-10-15T08:11:40Z
Lists: pgsql-hackers
Attachments
- v8-0002-Track-location-to-extract-relevant-part-in-nested.patch (application/octet-stream) patch v8-0002
- v8-0003-Set-query_id-for-queries-contained-in-utility-sta.patch (application/octet-stream) patch v8-0003
- v8-0004-Use-view-s-definition-as-query-string-on-a-materi.patch (application/octet-stream) patch v8-0004
- v8-0001-Add-tests-covering-pgss-nested-queries.patch (application/octet-stream) patch v8-0001
I've found that COPY wasn't correctly managed. "COPY (SELECT 1) to stdout;" nested statement would be tracked as "SELECT $1) to stdout". Since COPY accepts a PreparableStmt, stmt_len for all types of PreparableStmt needs to be tracked. This is done through updatePreparableStmtEnd in CopyStmt since we know the location of the closing parenthesis. The logic to set Query->stmt_len for statements that have a possible stmt_len has also been moved to a dedicated setQueryStmtLen function. I've updated the patchset with additional tests for COPY in 0001. 0002 includes the necessary modifications to handle COPY.
Commits
-
Set query ID for inner queries of CREATE TABLE AS and DECLARE
- 6b652e6ce85a 18.0 landed
-
Track more precisely query locations for nested statements
- 499edb09741b 18.0 landed
-
pg_stat_statements: Add tests for nested queries with level tracking
- 45e0ba30fc40 18.0 landed
-
Fix race condition in COMMIT PREPARED causing orphaned 2PC files
- cf4401fe6cf5 18.0 cited