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

Commit9cf4beb

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 parent086ecd1 commit9cf4beb

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
@@ -1382,7 +1382,9 @@ deleteOneObject(const ObjectAddress *object, Relation *depRel, int flags)
13821382
/*
13831383
* Delete any comments, security labels, or initial privileges associated
13841384
* with this object. (This is a convenient place to do these things,
1385-
* rather than having every object type know to do it.)
1385+
* rather than having every object type know to do it.) As above, all
1386+
* these functions must remove records for sub-objects too if the subid is
1387+
* zero.
13861388
*/
13871389
DeleteComments(object->objectId,object->classId,object->objectSubId);
13881390
DeleteSecurityLabel(object);
@@ -2992,6 +2994,7 @@ DeleteInitPrivs(const ObjectAddress *object)
29922994
{
29932995
Relationrelation;
29942996
ScanKeyDatakey[3];
2997+
intnkeys;
29952998
SysScanDescscan;
29962999
HeapTupleoldtuple;
29973000

@@ -3005,13 +3008,19 @@ DeleteInitPrivs(const ObjectAddress *object)
30053008
Anum_pg_init_privs_classoid,
30063009
BTEqualStrategyNumber,F_OIDEQ,
30073010
ObjectIdGetDatum(object->classId));
3008-
ScanKeyInit(&key[2],
3009-
Anum_pg_init_privs_objsubid,
3010-
BTEqualStrategyNumber,F_INT4EQ,
3011-
Int32GetDatum(object->objectSubId));
3011+
if (object->objectSubId!=0)
3012+
{
3013+
ScanKeyInit(&key[2],
3014+
Anum_pg_init_privs_objsubid,
3015+
BTEqualStrategyNumber,F_INT4EQ,
3016+
Int32GetDatum(object->objectSubId));
3017+
nkeys=3;
3018+
}
3019+
else
3020+
nkeys=2;
30123021

30133022
scan=systable_beginscan(relation,InitPrivsObjIndexId, true,
3014-
NULL,3,key);
3023+
NULL,nkeys,key);
30153024

30163025
while (HeapTupleIsValid(oldtuple=systable_getnext(scan)))
30173026
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
@@ -91,3 +91,10 @@ ALTER EXTENSION test_pg_dump DROP SERVER s0;
9191
ALTER EXTENSION test_pg_dump DROP TABLE test_pg_dump_t1;
9292
ALTER EXTENSION test_pg_dump DROP TYPE test_pg_dump_e1;
9393
ALTER EXTENSION test_pg_dump DROP VIEW test_pg_dump_v1;
94+
DROP EXTENSION test_pg_dump;
95+
-- shouldn't be anything left in pg_init_privs
96+
SELECT * FROM pg_init_privs WHERE privtype = 'e';
97+
objoid | classoid | objsubid | privtype | initprivs
98+
--------+----------+----------+----------+-----------
99+
(0 rows)
100+

‎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