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

Commit7661809

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 parent01aa88f commit7661809

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
@@ -1326,7 +1326,9 @@ deleteOneObject(const ObjectAddress *object, Relation *depRel, int flags)
13261326
/*
13271327
* Delete any comments, security labels, or initial privileges associated
13281328
* with this object. (This is a convenient place to do these things,
1329-
* rather than having every object type know to do it.)
1329+
* rather than having every object type know to do it.) As above, all
1330+
* these functions must remove records for sub-objects too if the subid is
1331+
* zero.
13301332
*/
13311333
DeleteComments(object->objectId,object->classId,object->objectSubId);
13321334
DeleteSecurityLabel(object);
@@ -2784,6 +2786,7 @@ DeleteInitPrivs(const ObjectAddress *object)
27842786
{
27852787
Relationrelation;
27862788
ScanKeyDatakey[3];
2789+
intnkeys;
27872790
SysScanDescscan;
27882791
HeapTupleoldtuple;
27892792

@@ -2797,13 +2800,19 @@ DeleteInitPrivs(const ObjectAddress *object)
27972800
Anum_pg_init_privs_classoid,
27982801
BTEqualStrategyNumber,F_OIDEQ,
27992802
ObjectIdGetDatum(object->classId));
2800-
ScanKeyInit(&key[2],
2801-
Anum_pg_init_privs_objsubid,
2802-
BTEqualStrategyNumber,F_INT4EQ,
2803-
Int32GetDatum(object->objectSubId));
2803+
if (object->objectSubId!=0)
2804+
{
2805+
ScanKeyInit(&key[2],
2806+
Anum_pg_init_privs_objsubid,
2807+
BTEqualStrategyNumber,F_INT4EQ,
2808+
Int32GetDatum(object->objectSubId));
2809+
nkeys=3;
2810+
}
2811+
else
2812+
nkeys=2;
28042813

28052814
scan=systable_beginscan(relation,InitPrivsObjIndexId, true,
2806-
NULL,3,key);
2815+
NULL,nkeys,key);
28072816

28082817
while (HeapTupleIsValid(oldtuple=systable_getnext(scan)))
28092818
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
@@ -276,3 +276,10 @@ SELECT pg_describe_object(classid,objid,objsubid) COLLATE "C" AS obj,
276276
(0 rows)
277277

278278
DROP ROLE regress_dump_test_role;
279+
DROP EXTENSION test_pg_dump;
280+
-- shouldn't be anything left in pg_init_privs
281+
SELECT * FROM pg_init_privs WHERE privtype = 'e';
282+
objoid | classoid | objsubid | privtype | initprivs
283+
--------+----------+----------+----------+-----------
284+
(0 rows)
285+

‎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
@@ -146,3 +146,8 @@ SELECT pg_describe_object(classid,objid,objsubid) COLLATE "C" AS obj,
146146
ORDER BY1,3;
147147

148148
DROP ROLE regress_dump_test_role;
149+
150+
DROP EXTENSION test_pg_dump;
151+
152+
-- shouldn't be anything left in pg_init_privs
153+
SELECT*FROM pg_init_privsWHERE privtype='e';

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp