Re: Set query_id for query contained in utility statement

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, Anthonin Bonnefoy <anthonin(dot)bonnefoy(at)datadoghq(dot)com>
Subject: Re: Set query_id for query contained in utility statement
Date: 2024-11-18 01:24:35
Message-ID: ZzqXU-2uTWzC38jO@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhijie Hou (Fujitsu) 2024-11-18 02:53:52 RE: memory leak in pgoutput
Previous Message Andy Fan 2024-11-18 00:23:52 Re: Extract numeric filed in JSONB more effectively