From 811f75f941ab732b309d791268fbcfdc800aa5c6 Mon Sep 17 00:00:00 2001 From: noon-moon Date: Wed, 21 Jun 2023 12:03:14 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=BA=E9=99=B7?= =?UTF-8?q?=EF=BC=9Agrant=20select=20(prosrc)=20on=20pg=5Fproc=20to=20test?= =?UTF-8?q?=EF=BC=8C=20=E6=95=B0=E6=8D=AE=E5=BA=93=E5=AE=95=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gausskernel/storage/access/heap/heapam.cpp | 8 ++++++++ src/test/regress/expected/generated_col.out | 5 +++++ src/test/regress/sql/generated_col.sql | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/src/gausskernel/storage/access/heap/heapam.cpp b/src/gausskernel/storage/access/heap/heapam.cpp index a89b6168c9..972e897d43 100755 --- a/src/gausskernel/storage/access/heap/heapam.cpp +++ b/src/gausskernel/storage/access/heap/heapam.cpp @@ -6095,6 +6095,14 @@ void simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup) errmsg("All built-in functions are hard coded, and they should not be updated."))); } + /* All attribute of system table columns are hard coded, and thus they should not be updated */ + Oid attrelid = ((Form_pg_attribute)GETSTRUCT(tup))->attrelid; + if (u_sess->attr.attr_common.IsInplaceUpgrade == false && IsAttributeRelation(relation) && + IsSystemObjOid(attrelid)) { + ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("All attribute of system table columns are hard coded, and they should not be updated."))); + } + result = heap_update(relation, NULL, otid, diff --git a/src/test/regress/expected/generated_col.out b/src/test/regress/expected/generated_col.out index 1cbf8485d4..f0d1d36a65 100644 --- a/src/test/regress/expected/generated_col.out +++ b/src/test/regress/expected/generated_col.out @@ -1134,3 +1134,8 @@ DROP TABLE gtest1; DROP TABLE gtest2; DROP TABLE gtest3; DROP TABLE gtest10; +CREATE USER grant_attr_user1 PASSWORD 'gauss@123'; +GRANT select (prosrc) on pg_proc to grant_attr_user1; +ERROR: All attribute of system table columns are hard coded, and they should not be updated. +revoke select (prosrc) on pg_proc from grant_attr_user1; +drop user grant_attr_user1 cascade; \ No newline at end of file diff --git a/src/test/regress/sql/generated_col.sql b/src/test/regress/sql/generated_col.sql index 7d27f914d3..a8ab769900 100644 --- a/src/test/regress/sql/generated_col.sql +++ b/src/test/regress/sql/generated_col.sql @@ -669,3 +669,8 @@ DROP TABLE gtest2; DROP TABLE gtest3; DROP TABLE gtest10; + +CREATE USER grant_attr_user1 PASSWORD 'gauss@123'; +GRANT select (prosrc) on pg_proc to grant_attr_user1; +revoke select (prosrc) on pg_proc from grant_attr_user1; +drop user grant_attr_user1 cascade; \ No newline at end of file -- Gitee From 9124bb156f2dbc2b80435bf5847b1f6944ada1c7 Mon Sep 17 00:00:00 2001 From: noon-moon Date: Wed, 21 Jun 2023 14:23:01 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/regress/expected/generated_col.out | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/regress/expected/generated_col.out b/src/test/regress/expected/generated_col.out index f0d1d36a65..39e34c462b 100644 --- a/src/test/regress/expected/generated_col.out +++ b/src/test/regress/expected/generated_col.out @@ -1138,4 +1138,4 @@ CREATE USER grant_attr_user1 PASSWORD 'gauss@123'; GRANT select (prosrc) on pg_proc to grant_attr_user1; ERROR: All attribute of system table columns are hard coded, and they should not be updated. revoke select (prosrc) on pg_proc from grant_attr_user1; -drop user grant_attr_user1 cascade; \ No newline at end of file +drop user grant_attr_user1 cascade; -- Gitee From 98a19c9c2f3a43ae6ba43ef333a12d96538fc1cc Mon Sep 17 00:00:00 2001 From: noon-moon Date: Thu, 29 Jun 2023 13:23:22 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=84=E5=AE=A1?= =?UTF-8?q?=E6=84=8F=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gausskernel/storage/access/heap/heapam.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gausskernel/storage/access/heap/heapam.cpp b/src/gausskernel/storage/access/heap/heapam.cpp index 972e897d43..521722d9e2 100755 --- a/src/gausskernel/storage/access/heap/heapam.cpp +++ b/src/gausskernel/storage/access/heap/heapam.cpp @@ -6096,11 +6096,12 @@ void simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup) } /* All attribute of system table columns are hard coded, and thus they should not be updated */ - Oid attrelid = ((Form_pg_attribute)GETSTRUCT(tup))->attrelid; - if (u_sess->attr.attr_common.IsInplaceUpgrade == false && IsAttributeRelation(relation) && - IsSystemObjOid(attrelid)) { - ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("All attribute of system table columns are hard coded, and they should not be updated."))); + if (u_sess->attr.attr_common.IsInplaceUpgrade == false && IsAttributeRelation(relation)) { + Oid attrelid = ((Form_pg_attribute)GETSTRUCT(tup))->attrelid; + if (IsSystemObjOid(attrelid)) { + ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("All attribute of system table columns are hard coded, and they should not be updated."))); + } } result = heap_update(relation, -- Gitee