From: Drouvot, Bertrand <bdrouvot@amazon.com>
To: Andres Freund <andres@anarazel.de>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Schneider (AWS), Jeremy <schnjere@amazon.com>
Subject: Re: [PATCH] Query Jumbling for CALL and SET utility statements
Date: Thu, 1 Sep 2022 09:16:35 +0200
Message-ID: <f26a22bb-f7ba-8d71-8b2f-707c6d0daca7@amazon.com> (raw)
In-Reply-To: <20220831160839.wseeotr7rckucpmv@awork3.anarazel.de>
References: <36e5bffe-e989-194f-85c8-06e7bc88e6f7@amazon.com>
<20220831160839.wseeotr7rckucpmv@awork3.anarazel.de>
Hi,
On 8/31/22 6:08 PM, Andres Freund wrote:
> Hi,
>
> On 2022-08-31 17:33:44 +0200, Drouvot, Bertrand wrote:
>> @@ -383,6 +384,30 @@ JumbleExpr(JumbleState *jstate, Node *node)
>> APP_JUMB(var->varlevelsup);
>> }
>> break;
>> + case T_CallStmt:
>> + {
>> + CallStmt *stmt = (CallStmt *) node;
>> + FuncExpr *expr = stmt->funcexpr;
>> +
>> + APP_JUMB(expr->funcid);
>> + JumbleExpr(jstate, (Node *) expr->args);
>> + }
>> + break;
> Why do we need to take the arguments into account?
Thanks for looking at it!
Agree that It's not needed to "solve" the Lock contention issue, but I
think it's needed for the "render".
Without it we would get, things like:
postgres=# call MY_PROC(10);
CALL
postgres=# call MY_PROC(100000000);
CALL
postgres=# SELECT query, calls, rows FROM pg_stat_statements;
query | calls | rows
-----------------------------------+-------+------
select pg_stat_statements_reset() | 1 | 1
call MY_PROC(10) | 2 | 0
(2 rows)
instead of
postgres=# SELECT query, calls, rows FROM pg_stat_statements;
query | calls | rows
-----------------------------------+-------+------
select pg_stat_statements_reset() | 1 | 1
call MY_PROC($1) | 2 | 0
(2 rows)
>
>
>> + case T_VariableSetStmt:
>> + {
>> + VariableSetStmt *stmt = (VariableSetStmt *) node;
>> +
>> + APP_JUMB_STRING(stmt->name);
>> + JumbleExpr(jstate, (Node *) stmt->args);
>> + }
>> + break;
> Same?
yeah, same reason. Without it we would get things like:
postgres=# set enable_seqscan=false;
SET
postgres=# set enable_seqscan=true;
SET
postgres=# SELECT query, calls, rows FROM pg_stat_statements;
query | calls | rows
-----------------------------------+-------+------
select pg_stat_statements_reset() | 1 | 1
set enable_seqscan=false | 2 | 0
(2 rows)
instead of
postgres=# SELECT query, calls, rows FROM pg_stat_statements;
query | calls | rows
-----------------------------------+-------+------
set enable_seqscan=$1 | 2 | 0
select pg_stat_statements_reset() | 1 | 1
(2 rows)
>
>> + case T_A_Const:
>> + {
>> + int loc = ((const A_Const *) node)->location;
>> +
>> + RecordConstLocation(jstate, loc);
>> + }
>> + break;
> I suspect we only need this because of the jumbling of unparsed arguments I
> questioned above?
Right but only for the T_VariableSetStmt case.
> If we do end up needing it, shouldn't we include the type
> in the jumbling?
I don't think so as this is only for the T_VariableSetStmt case.
And looking closer I don't see such as thing as "consttype" (that we can
find in the Const struct) in the A_Const struct.
Regards,
--
Bertrand Drouvot
Amazon Web Services:https://aws.amazon.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: bdrouvot@amazon.com, andres@anarazel.de, schnjere@amazon.com
Subject: Re: [PATCH] Query Jumbling for CALL and SET utility statements
In-Reply-To: <f26a22bb-f7ba-8d71-8b2f-707c6d0daca7@amazon.com>
References: <36e5bffe-e989-194f-85c8-06e7bc88e6f7@amazon.com> <20220831160839.wseeotr7rckucpmv@awork3.anarazel.de> <f26a22bb-f7ba-8d71-8b2f-707c6d0daca7@amazon.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox