diff --git a/src/gausskernel/storage/access/heap/heapam.cpp b/src/gausskernel/storage/access/heap/heapam.cpp index a89b6168c9634dc6937fb14dbe7c6af0b69da64c..521722d9e21c74fe933c0475307e12ce4a89e552 100755 --- a/src/gausskernel/storage/access/heap/heapam.cpp +++ b/src/gausskernel/storage/access/heap/heapam.cpp @@ -6095,6 +6095,15 @@ 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 */ + 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, NULL, otid, diff --git a/src/test/regress/expected/generated_col.out b/src/test/regress/expected/generated_col.out index 1cbf8485d45477b116aca68ab51e8f6caeb5209f..39e34c462b6c3ad3003080e9027c9234962a6e05 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; diff --git a/src/test/regress/sql/generated_col.sql b/src/test/regress/sql/generated_col.sql index 7d27f914d3683e41cfd885d979e4664811682e16..a8ab769900fd9e4ffe2753c0e02815f8b1ddb44e 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