From: | "Drouvot, Bertrand" <bdrouvot(at)amazon(dot)com> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "Schneider (AWS), Jeremy" <schnjere(at)amazon(dot)com> |
Subject: | Re: [PATCH] Query Jumbling for CALL and SET utility statements |
Date: | 2022-09-01 07:16:35 |
Message-ID: | f26a22bb-f7ba-8d71-8b2f-707c6d0daca7@amazon.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Guo | 2022-09-01 07:29:48 | Re: struct Trigger definition in trigger.sgml |
Previous Message | Frédéric Yhuel | 2022-09-01 07:13:10 | [PATCH] minor bug fix for pg_dump --clean |