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

Commitf26b917

Browse files
committed
Arrange for indexes and toast tables to inherit their ownership from
the parent table, even if the command that creates them is executed bysomeone else (such as a superuser or a member of the owning role).Per gripe from Michael Fuhr.
1 parent09a6c90 commitf26b917

File tree

8 files changed

+25
-11
lines changed

8 files changed

+25
-11
lines changed

‎src/backend/bootstrap/bootparse.y

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.77 2005/06/29 22:51:54 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.78 2005/08/26 03:07:00 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -29,6 +29,7 @@
2929
#include"catalog/heap.h"
3030
#include"catalog/pg_am.h"
3131
#include"catalog/pg_attribute.h"
32+
#include"catalog/pg_authid.h"
3233
#include"catalog/pg_class.h"
3334
#include"catalog/pg_namespace.h"
3435
#include"catalog/pg_tablespace.h"
@@ -199,6 +200,7 @@ Boot_CreateStmt:
199200
PG_CATALOG_NAMESPACE,
200201
$3 ? GLOBALTABLESPACE_OID :0,
201202
$6,
203+
BOOTSTRAP_SUPERUSERID,
202204
tupdesc,
203205
RELKIND_RELATION,
204206
$3,

‎src/backend/catalog/heap.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.289 2005/08/12 01:35:56 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.290 2005/08/26 03:07:12 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -65,6 +65,7 @@
6565
staticvoidAddNewRelationTuple(Relationpg_class_desc,
6666
Relationnew_rel_desc,
6767
Oidnew_rel_oid,Oidnew_type_oid,
68+
Oidrelowner,
6869
charrelkind);
6970
staticOidAddNewRelationType(constchar*typeName,
7071
OidtypeNamespace,
@@ -555,6 +556,7 @@ AddNewRelationTuple(Relation pg_class_desc,
555556
Relationnew_rel_desc,
556557
Oidnew_rel_oid,
557558
Oidnew_type_oid,
559+
Oidrelowner,
558560
charrelkind)
559561
{
560562
Form_pg_classnew_rel_reltup;
@@ -587,7 +589,7 @@ AddNewRelationTuple(Relation pg_class_desc,
587589
break;
588590
}
589591

590-
new_rel_reltup->relowner=GetUserId();
592+
new_rel_reltup->relowner=relowner;
591593
new_rel_reltup->reltype=new_type_oid;
592594
new_rel_reltup->relkind=relkind;
593595

@@ -665,6 +667,7 @@ heap_create_with_catalog(const char *relname,
665667
Oidrelnamespace,
666668
Oidreltablespace,
667669
Oidrelid,
670+
Oidownerid,
668671
TupleDesctupdesc,
669672
charrelkind,
670673
boolshared_relation,
@@ -740,6 +743,7 @@ heap_create_with_catalog(const char *relname,
740743
new_rel_desc,
741744
relid,
742745
new_type_oid,
746+
ownerid,
743747
relkind);
744748

745749
/*
@@ -769,7 +773,7 @@ heap_create_with_catalog(const char *relname,
769773
referenced.objectSubId=0;
770774
recordDependencyOn(&myself,&referenced,DEPENDENCY_NORMAL);
771775

772-
recordDependencyOnOwner(RelationRelationId,relid,GetUserId());
776+
recordDependencyOnOwner(RelationRelationId,relid,ownerid);
773777
}
774778

775779
/*

‎src/backend/catalog/index.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.259 2005/08/12 01:35:56 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.260 2005/08/26 03:07:12 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -562,7 +562,7 @@ index_create(Oid heapRelationId,
562562
*
563563
* XXX should have a cleaner way to create cataloged indexes
564564
*/
565-
indexRelation->rd_rel->relowner=GetUserId();
565+
indexRelation->rd_rel->relowner=heapRelation->rd_rel->relowner;
566566
indexRelation->rd_rel->relam=accessMethodObjectId;
567567
indexRelation->rd_rel->relkind=RELKIND_INDEX;
568568
indexRelation->rd_rel->relhasoids= false;

‎src/backend/commands/cluster.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.138 2005/05/10 13:16:26 momjian Exp $
14+
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.139 2005/08/26 03:07:16 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -577,6 +577,7 @@ make_new_heap(Oid OIDOldHeap, const char *NewName, Oid NewTableSpace)
577577
RelationGetNamespace(OldHeap),
578578
NewTableSpace,
579579
InvalidOid,
580+
OldHeap->rd_rel->relowner,
580581
tupdesc,
581582
OldHeap->rd_rel->relkind,
582583
OldHeap->rd_rel->relisshared,

‎src/backend/commands/tablecmds.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.169 2005/08/23 22:40:07 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.170 2005/08/26 03:07:16 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -427,6 +427,7 @@ DefineRelation(CreateStmt *stmt, char relkind)
427427
namespaceId,
428428
tablespaceId,
429429
InvalidOid,
430+
GetUserId(),
430431
descriptor,
431432
relkind,
432433
false,
@@ -5946,6 +5947,7 @@ AlterTableCreateToastTable(Oid relOid, bool silent)
59465947
PG_TOAST_NAMESPACE,
59475948
rel->rd_rel->reltablespace,
59485949
InvalidOid,
5950+
rel->rd_rel->relowner,
59495951
tupdesc,
59505952
RELKIND_TOASTVALUE,
59515953
shared_relation,

‎src/backend/executor/execMain.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
*
2828
* IDENTIFICATION
29-
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.254 2005/08/20 00:39:55 tgl Exp $
29+
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.255 2005/08/26 03:07:25 tgl Exp $
3030
*
3131
*-------------------------------------------------------------------------
3232
*/
@@ -759,6 +759,7 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
759759
namespaceId,
760760
InvalidOid,
761761
InvalidOid,
762+
GetUserId(),
762763
tupdesc,
763764
RELKIND_RELATION,
764765
false,

‎src/backend/utils/cache/relcache.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.227 2005/08/12 01:35:59 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.228 2005/08/26 03:07:48 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -39,6 +39,7 @@
3939
#include"catalog/pg_amproc.h"
4040
#include"catalog/pg_attrdef.h"
4141
#include"catalog/pg_attribute.h"
42+
#include"catalog/pg_authid.h"
4243
#include"catalog/pg_constraint.h"
4344
#include"catalog/pg_index.h"
4445
#include"catalog/pg_namespace.h"
@@ -2074,6 +2075,8 @@ RelationBuildLocalRelation(const char *relname,
20742075
rel->rd_rel->relhasoids=rel->rd_att->tdhasoid;
20752076
rel->rd_rel->relnatts=natts;
20762077
rel->rd_rel->reltype=InvalidOid;
2078+
/* needed when bootstrapping: */
2079+
rel->rd_rel->relowner=BOOTSTRAP_SUPERUSERID;
20772080

20782081
/*
20792082
* Insert relation physical and logical identifiers (OIDs) into the

‎src/include/catalog/heap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/catalog/heap.h,v 1.74 2005/04/14 01:38:20 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/catalog/heap.h,v 1.75 2005/08/26 03:08:15 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -48,6 +48,7 @@ extern Oid heap_create_with_catalog(const char *relname,
4848
Oidrelnamespace,
4949
Oidreltablespace,
5050
Oidrelid,
51+
Oidownerid,
5152
TupleDesctupdesc,
5253
charrelkind,
5354
boolshared_relation,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp