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

Commit1f1eedd

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 parentdf95c1e commit1f1eedd

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
@@ -1374,7 +1374,9 @@ deleteOneObject(const ObjectAddress *object, Relation *depRel, int flags)
13741374
/*
13751375
* Delete any comments, security labels, or initial privileges associated
13761376
* with this object. (This is a convenient place to do these things,
1377-
* rather than having every object type know to do it.)
1377+
* rather than having every object type know to do it.) As above, all
1378+
* these functions must remove records for sub-objects too if the subid is
1379+
* zero.
13781380
*/
13791381
DeleteComments(object->objectId,object->classId,object->objectSubId);
13801382
DeleteSecurityLabel(object);
@@ -2985,6 +2987,7 @@ DeleteInitPrivs(const ObjectAddress *object)
29852987
{
29862988
Relationrelation;
29872989
ScanKeyDatakey[3];
2990+
intnkeys;
29882991
SysScanDescscan;
29892992
HeapTupleoldtuple;
29902993

@@ -2998,13 +3001,19 @@ DeleteInitPrivs(const ObjectAddress *object)
29983001
Anum_pg_init_privs_classoid,
29993002
BTEqualStrategyNumber,F_OIDEQ,
30003003
ObjectIdGetDatum(object->classId));
3001-
ScanKeyInit(&key[2],
3002-
Anum_pg_init_privs_objsubid,
3003-
BTEqualStrategyNumber,F_INT4EQ,
3004-
Int32GetDatum(object->objectSubId));
3004+
if (object->objectSubId!=0)
3005+
{
3006+
ScanKeyInit(&key[2],
3007+
Anum_pg_init_privs_objsubid,
3008+
BTEqualStrategyNumber,F_INT4EQ,
3009+
Int32GetDatum(object->objectSubId));
3010+
nkeys=3;
3011+
}
3012+
else
3013+
nkeys=2;
30053014

30063015
scan=systable_beginscan(relation,InitPrivsObjIndexId, true,
3007-
NULL,3,key);
3016+
NULL,nkeys,key);
30083017

30093018
while (HeapTupleIsValid(oldtuple=systable_getnext(scan)))
30103019
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