Hi hackers,

"SET local" is currently recorded in VariableSetStmt (with the boolean is_local) but "SET session" is not.

Please find attached a patch proposal to also record "SET session" so that VariableSetStmt records all the cases.

Remark: Recording "SET session" will also help for the Jumbling work being done in [1].

[1]: https://www.postgresql.org/message-id/66be1104-164f-dcb8-6c43-f03a68a139a7%40gmail.com

Looking forward to your feedback,

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
commit 2401087366432b0a520ac45947c4584924099617
Author: bdrouvotAWS <bdrou...@amazon.com>
Date:   Thu Oct 6 10:20:18 2022 +0000

    v1-0001-record-set-session-in-VariableSetStmt.patch

diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 94d5142a4a..809e617d18 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -1563,6 +1563,7 @@ VariableSetStmt:
                                        VariableSetStmt *n = $2;
 
                                        n->is_local = false;
+                                       n->is_session = false;
                                        $$ = (Node *) n;
                                }
                        | SET LOCAL set_rest
@@ -1570,6 +1571,7 @@ VariableSetStmt:
                                        VariableSetStmt *n = $3;
 
                                        n->is_local = true;
+                                       n->is_session = false;
                                        $$ = (Node *) n;
                                }
                        | SET SESSION set_rest
@@ -1577,6 +1579,7 @@ VariableSetStmt:
                                        VariableSetStmt *n = $3;
 
                                        n->is_local = false;
+                                       n->is_session = true;
                                        $$ = (Node *) n;
                                }
                ;
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 633e7671b3..c3f33e7c4a 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -2228,6 +2228,7 @@ typedef struct VariableSetStmt
        char       *name;                       /* variable to be set */
        List       *args;                       /* List of A_Const nodes */
        bool            is_local;               /* SET LOCAL? */
+       bool            is_session;             /* SET SESSION? */
 } VariableSetStmt;
 
 /* ----------------------

Reply via email to