Re: Set query_id for query contained in utility statement
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: pgsql-hackers@lists.postgresql.org, Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
Date: 2024-11-18T01:24:35Z
Lists: pgsql-hackers
On Sat, Nov 16, 2024 at 09:43:12PM +0100, Alvaro Herrera wrote: > I just noticed that this commit broke pgaudit pretty thoroughly. I'm > not sure if this means pgaudit needs changes, or this commit needs to be > reconsidered in some way; at this point I'm just raising the alarm. > > (FWIW there are a few other pgaudit-breaking changes in 18, but they > don't seem as bad as this one, to the extent that the fixes likely > belong into pgaudit.) Thanks for the heads-up. I have looked at that, and as far as I can see this is something that I think is an improvement for pgaudit because we are able to track more precisely the subqueries that are run as part of a CTAS or an EXPLAIN. Well, that's the whole point of what's been done by Anthonin. Here are a couple of examples from regression.diffs: -NOTICE: AUDIT: SESSION,5,1,READ,SELECT,,,CREATE TABLE tmp2 AS (SELECT * FROM tmp),<not logged> +NOTICE: AUDIT: SESSION,5,1,READ,SELECT,,,SELECT * FROM tmp,<not logged> [...] -NOTICE: AUDIT: SESSION,30,1,READ,SELECT,,,explain select 1,<none> +NOTICE: AUDIT: SESSION,30,1,READ,SELECT,,,select 1,<none> NOTICE: AUDIT: SESSION,30,2,MISC,EXPLAIN,,,explain select 1,<none> We still track the parent query and it is intact. Things change so as the subquery showing in the logs is actually what's running, not what's part of the parent query. This one also looks less confusing to me: -WARNING: AUDIT: OBJECT,1,1,WRITE,INSERT,TABLE,public.test4,"PREPARE testinsert(int, text) AS - INSERT INTO test4 VALUES($1, $2)","1,<long param suppressed>" +WARNING: AUDIT: OBJECT,1,1,WRITE,INSERT,TABLE,public.test4,"INSERT INTO test4 VALUES($1, $2)","1,<long param suppressed>" As a whole, it seems to me that this requires a refresh of the regression test output. (I've found two small issues for pgaudit, will send some pull requests in a few minutes.) -- Michael
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