Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit198de79

Browse files
committed
Clean out column-level pg_init_privs entries when dropping tables.
DeleteInitPrivs did not get the memo about how, when dropping awhole object (with subid == 0), you should drop entries relatingto its sub-objects too. This is visible in the test_pg_dump testcase if one drops the extension at the end: the entry forGRANT SELECT(col1) ON regress_pg_dump_table TO public;was still present in pg_init_privs afterwards, although it waspointing to a dangling table OID.Noted while fooling with a fix for REASSIGN OWNED for pg_init_privsentries. This bug is aboriginal in the pg_init_privs featurethough, and there seems no reason not to back-patch the fix.
1 parentc7de5a6 commit198de79

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

‎src/backend/catalog/dependency.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,9 @@ deleteOneObject(const ObjectAddress *object, Relation *depRel, int flags)
13281328
/*
13291329
* Delete any comments, security labels, or initial privileges associated
13301330
* with this object. (This is a convenient place to do these things,
1331-
* rather than having every object type know to do it.)
1331+
* rather than having every object type know to do it.) As above, all
1332+
* these functions must remove records for sub-objects too if the subid is
1333+
* zero.
13321334
*/
13331335
DeleteComments(object->objectId,object->classId,object->objectSubId);
13341336
DeleteSecurityLabel(object);
@@ -2887,6 +2889,7 @@ DeleteInitPrivs(const ObjectAddress *object)
28872889
{
28882890
Relationrelation;
28892891
ScanKeyDatakey[3];
2892+
intnkeys;
28902893
SysScanDescscan;
28912894
HeapTupleoldtuple;
28922895

@@ -2900,13 +2903,19 @@ DeleteInitPrivs(const ObjectAddress *object)
29002903
Anum_pg_init_privs_classoid,
29012904
BTEqualStrategyNumber,F_OIDEQ,
29022905
ObjectIdGetDatum(object->classId));
2903-
ScanKeyInit(&key[2],
2904-
Anum_pg_init_privs_objsubid,
2905-
BTEqualStrategyNumber,F_INT4EQ,
2906-
Int32GetDatum(object->objectSubId));
2906+
if (object->objectSubId!=0)
2907+
{
2908+
ScanKeyInit(&key[2],
2909+
Anum_pg_init_privs_objsubid,
2910+
BTEqualStrategyNumber,F_INT4EQ,
2911+
Int32GetDatum(object->objectSubId));
2912+
nkeys=3;
2913+
}
2914+
else
2915+
nkeys=2;
29072916

29082917
scan=systable_beginscan(relation,InitPrivsObjIndexId, true,
2909-
NULL,3,key);
2918+
NULL,nkeys,key);
29102919

29112920
while (HeapTupleIsValid(oldtuple=systable_getnext(scan)))
29122921
CatalogTupleDelete(relation,&oldtuple->t_self);

‎src/test/modules/test_pg_dump/expected/test_pg_dump.out

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,10 @@ ALTER EXTENSION test_pg_dump DROP SERVER s0;
9393
ALTER EXTENSION test_pg_dump DROP TABLE test_pg_dump_t1;
9494
ALTER EXTENSION test_pg_dump DROP TYPE test_pg_dump_e1;
9595
ALTER EXTENSION test_pg_dump DROP VIEW test_pg_dump_v1;
96+
DROP EXTENSION test_pg_dump;
97+
-- shouldn't be anything left in pg_init_privs
98+
SELECT * FROM pg_init_privs WHERE privtype = 'e';
99+
objoid | classoid | objsubid | privtype | initprivs
100+
--------+----------+----------+----------+-----------
101+
(0 rows)
102+

‎src/test/modules/test_pg_dump/sql/test_pg_dump.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,8 @@ ALTER EXTENSION test_pg_dump DROP SERVER s0;
106106
ALTER EXTENSION test_pg_dumpDROPTABLEtest_pg_dump_t1;
107107
ALTER EXTENSION test_pg_dump DROP TYPE test_pg_dump_e1;
108108
ALTER EXTENSION test_pg_dump DROP VIEW test_pg_dump_v1;
109+
110+
DROP EXTENSION test_pg_dump;
111+
112+
-- shouldn't be anything left in pg_init_privs
113+
SELECT*FROM pg_init_privsWHERE privtype='e';

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp