This is an automated email from the ASF dual-hosted git repository.
chenjinbao1989 pushed a commit to branch cbdb-postgres-merge
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
The following commit(s) were added to refs/heads/cbdb-postgres-merge by this
push:
new 1bc8b03bf7b Add permission check on initplan
1bc8b03bf7b is described below
commit 1bc8b03bf7bdcec57d41c7642821a61aa06e891a
Author: Jinbao Chen <[email protected]>
AuthorDate: Sat Nov 15 11:28:29 2025 +0800
Add permission check on initplan
---
contrib/pg_surgery/heap_surgery.c | 1 -
src/backend/executor/execMain.c | 7 +++++++
src/backend/nodes/copyfuncs.c | 1 +
src/test/regress/expected/updatable_views.out | 21 ---------------------
4 files changed, 8 insertions(+), 22 deletions(-)
diff --git a/contrib/pg_surgery/heap_surgery.c
b/contrib/pg_surgery/heap_surgery.c
index 6a77e45b558..b5e1dac96c8 100644
--- a/contrib/pg_surgery/heap_surgery.c
+++ b/contrib/pg_surgery/heap_surgery.c
@@ -383,7 +383,6 @@ sanity_check_tid_array(ArrayType *ta, int *ntids)
}
/*-------------------------------------------------------------------------
-<<<<<<< HEAD
* sanity_check_relation()
*
* Perform sanity checks on the given relation.
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index 563274e85ad..5333800b528 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -1818,6 +1818,13 @@ InitPlan(QueryDesc *queryDesc, int eflags)
}
}
+ /*
+ * Do permissions checks
+ */
+ if (operation != CMD_SELECT || Gp_role != GP_ROLE_EXECUTE)
+ {
+ ExecCheckPermissions(rangeTable, plannedstmt->permInfos, true);
+ }
/*
* initialize the node's execution state
*/
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index b287dcf8a9d..033574274e5 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -115,6 +115,7 @@ _copyPlannedStmt(const PlannedStmt *from)
COPY_SCALAR_FIELD(jitFlags);
COPY_NODE_FIELD(planTree);
COPY_NODE_FIELD(rtable);
+ COPY_NODE_FIELD(permInfos);
COPY_NODE_FIELD(resultRelations);
COPY_NODE_FIELD(appendRelations);
COPY_NODE_FIELD(subplans);
diff --git a/src/test/regress/expected/updatable_views.out
b/src/test/regress/expected/updatable_views.out
index 3372041db39..680caab7cfe 100644
--- a/src/test/regress/expected/updatable_views.out
+++ b/src/test/regress/expected/updatable_views.out
@@ -463,27 +463,6 @@ SELECT a, b FROM base_tbl_hist;
10 |
(2 rows)
--- it's still updatable if we add a DO ALSO rule
-CREATE TABLE base_tbl_hist(ts timestamptz default now(), a int, b text);
-CREATE RULE base_tbl_log AS ON INSERT TO rw_view1 DO ALSO
- INSERT INTO base_tbl_hist(a,b) VALUES(new.a, new.b);
-SELECT table_name, is_updatable, is_insertable_into
- FROM information_schema.views
- WHERE table_name = 'rw_view1';
- table_name | is_updatable | is_insertable_into
-------------+--------------+--------------------
- rw_view1 | YES | YES
-(1 row)
-
--- Check behavior with DEFAULTs (bug #17633)
-INSERT INTO rw_view1 VALUES (9, DEFAULT), (10, DEFAULT);
-SELECT a, b FROM base_tbl_hist;
- a | b
-----+---
- 9 |
- 10 |
-(2 rows)
-
DROP TABLE base_tbl CASCADE;
NOTICE: drop cascades to view rw_view1
DROP TABLE base_tbl_hist;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]