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

Commita2e35b5

Browse files
committed
Change many routines to return ObjectAddress rather than OID
The changed routines are mostly those that can be directly called byProcessUtilitySlow; the intention is to make the affected objectinformation more precise, in support for future event trigger changes.Originally it was envisioned that the OID of the affected object wouldbe enough, and in most cases that is correct, but upon actuallyimplementing the event trigger changes it turned out that ObjectAddressis more widely useful.Additionally, some command execution routines grew an output argumentthat's an object address which provides further info about the executedcommand. To wit:* for ALTER DOMAIN / ADD CONSTRAINT, it corresponds to the address of the new constraint* for ALTER OBJECT / SET SCHEMA, it corresponds to the address of the schema that originally contained the object.* for ALTER EXTENSION {ADD, DROP} OBJECT, it corresponds to the address of the object added to or dropped from the extension.There's no user-visible change in this commit, and no functional changeeither.Discussion: 20150218213255.GC6717@tamriel.snowman.netReviewed-By: Stephen Frost, Andres Freund
1 parent6f9d799 commita2e35b5

File tree

68 files changed

+840
-558
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+840
-558
lines changed

‎src/backend/bootstrap/bootparse.y

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ Boot_CreateStmt:
251251
(Datum)0,
252252
false,
253253
true,
254-
false);
254+
false,
255+
NULL);
255256
elog(DEBUG4,"relation created with OID %u", id);
256257
}
257258
do_end();

‎src/backend/catalog/heap.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static void AddNewRelationTuple(Relation pg_class_desc,
8989
charrelkind,
9090
Datumrelacl,
9191
Datumreloptions);
92-
staticOidAddNewRelationType(constchar*typeName,
92+
staticObjectAddressAddNewRelationType(constchar*typeName,
9393
OidtypeNamespace,
9494
Oidnew_rel_oid,
9595
charnew_rel_kind,
@@ -935,7 +935,7 @@ AddNewRelationTuple(Relation pg_class_desc,
935935
*define a composite type corresponding to the new relation
936936
* --------------------------------
937937
*/
938-
staticOid
938+
staticObjectAddress
939939
AddNewRelationType(constchar*typeName,
940940
OidtypeNamespace,
941941
Oidnew_rel_oid,
@@ -1006,6 +1006,9 @@ AddNewRelationType(const char *typeName,
10061006
*allow_system_table_mods: TRUE to allow creation in system namespaces
10071007
*is_internal: is this a system-generated catalog?
10081008
*
1009+
* Output parameters:
1010+
*typaddress: if not null, gets the object address of the new pg_type entry
1011+
*
10091012
* Returns the OID of the new relation
10101013
* --------------------------------
10111014
*/
@@ -1029,14 +1032,16 @@ heap_create_with_catalog(const char *relname,
10291032
Datumreloptions,
10301033
booluse_user_acl,
10311034
boolallow_system_table_mods,
1032-
boolis_internal)
1035+
boolis_internal,
1036+
ObjectAddress*typaddress)
10331037
{
10341038
Relationpg_class_desc;
10351039
Relationnew_rel_desc;
10361040
Acl*relacl;
10371041
Oidexisting_relid;
10381042
Oidold_type_oid;
10391043
Oidnew_type_oid;
1044+
ObjectAddressnew_type_addr;
10401045
Oidnew_array_oid=InvalidOid;
10411046

10421047
pg_class_desc=heap_open(RelationRelationId,RowExclusiveLock);
@@ -1187,13 +1192,16 @@ heap_create_with_catalog(const char *relname,
11871192
* creating the same type name in parallel but hadn't committed yet when
11881193
* we checked for a duplicate name above.
11891194
*/
1190-
new_type_oid=AddNewRelationType(relname,
1191-
relnamespace,
1192-
relid,
1193-
relkind,
1194-
ownerid,
1195-
reltypeid,
1196-
new_array_oid);
1195+
new_type_addr=AddNewRelationType(relname,
1196+
relnamespace,
1197+
relid,
1198+
relkind,
1199+
ownerid,
1200+
reltypeid,
1201+
new_array_oid);
1202+
new_type_oid=new_type_addr.objectId;
1203+
if (typaddress)
1204+
*typaddress=new_type_addr;
11971205

11981206
/*
11991207
* Now make the array type if wanted.

‎src/backend/catalog/objectaddress.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,12 @@ ObjectTypeMap[] =
531531
{"policy",OBJECT_POLICY }
532532
};
533533

534+
constObjectAddressInvalidObjectAddress=
535+
{
536+
InvalidOid,
537+
InvalidOid,
538+
0
539+
};
534540

535541
staticObjectAddressget_object_address_unqualified(ObjectTypeobjtype,
536542
List*qualname,boolmissing_ok);

‎src/backend/catalog/pg_aggregate.c

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static Oid lookup_agg_function(List *fnName, int nargs, Oid *input_types,
4343
/*
4444
* AggregateCreate
4545
*/
46-
Oid
46+
ObjectAddress
4747
AggregateCreate(constchar*aggName,
4848
OidaggNamespace,
4949
charaggKind,
@@ -522,32 +522,33 @@ AggregateCreate(const char *aggName,
522522
* aggregate. (This could fail if there's already a conflicting entry.)
523523
*/
524524

525-
procOid=ProcedureCreate(aggName,
526-
aggNamespace,
527-
false,/* no replacement */
528-
false,/* doesn't return a set */
529-
finaltype,/* returnType */
530-
GetUserId(),/* proowner */
531-
INTERNALlanguageId,/* languageObjectId */
532-
InvalidOid,/* no validator */
533-
"aggregate_dummy",/* placeholder proc */
534-
NULL,/* probin */
535-
true,/* isAgg */
536-
false,/* isWindowFunc */
537-
false,/* security invoker (currently not
525+
myself=ProcedureCreate(aggName,
526+
aggNamespace,
527+
false,/* no replacement */
528+
false,/* doesn't return a set */
529+
finaltype,/* returnType */
530+
GetUserId(),/* proowner */
531+
INTERNALlanguageId,/* languageObjectId */
532+
InvalidOid,/* no validator */
533+
"aggregate_dummy",/* placeholder proc */
534+
NULL,/* probin */
535+
true,/* isAgg */
536+
false,/* isWindowFunc */
537+
false,/* security invoker (currently not
538538
* definable for agg) */
539-
false,/* isLeakProof */
540-
false,/* isStrict (not needed for agg) */
541-
PROVOLATILE_IMMUTABLE,/* volatility (not
539+
false,/* isLeakProof */
540+
false,/* isStrict (not needed for agg) */
541+
PROVOLATILE_IMMUTABLE,/* volatility (not
542542
* needed for agg) */
543-
parameterTypes,/* paramTypes */
544-
allParameterTypes,/* allParamTypes */
545-
parameterModes,/* parameterModes */
546-
parameterNames,/* parameterNames */
547-
parameterDefaults,/* parameterDefaults */
548-
PointerGetDatum(NULL),/* proconfig */
549-
1,/* procost */
550-
0);/* prorows */
543+
parameterTypes,/* paramTypes */
544+
allParameterTypes,/* allParamTypes */
545+
parameterModes,/* parameterModes */
546+
parameterNames,/* parameterNames */
547+
parameterDefaults,/* parameterDefaults */
548+
PointerGetDatum(NULL),/* proconfig */
549+
1,/* procost */
550+
0);/* prorows */
551+
procOid=myself.objectId;
551552

552553
/*
553554
* Okay to create the pg_aggregate entry.
@@ -599,9 +600,6 @@ AggregateCreate(const char *aggName,
599600
* on aggTransType since we depend on it indirectly through transfn.
600601
* Likewise for aggmTransType if any.
601602
*/
602-
myself.classId=ProcedureRelationId;
603-
myself.objectId=procOid;
604-
myself.objectSubId=0;
605603

606604
/* Depends on transition function */
607605
referenced.classId=ProcedureRelationId;
@@ -654,7 +652,7 @@ AggregateCreate(const char *aggName,
654652
recordDependencyOn(&myself,&referenced,DEPENDENCY_NORMAL);
655653
}
656654

657-
returnprocOid;
655+
returnmyself;
658656
}
659657

660658
/*

‎src/backend/catalog/pg_conversion.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
* Add a new tuple to pg_conversion.
3939
*/
40-
Oid
40+
ObjectAddress
4141
ConversionCreate(constchar*conname,Oidconnamespace,
4242
Oidconowner,
4343
int32conforencoding,int32contoencoding,
@@ -141,7 +141,7 @@ ConversionCreate(const char *conname, Oid connamespace,
141141
heap_freetuple(tup);
142142
heap_close(rel,RowExclusiveLock);
143143

144-
returnoid;
144+
returnmyself;
145145
}
146146

147147
/*

‎src/backend/catalog/pg_operator.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static Oid get_other_operator(List *otherOp,
6161
OidleftTypeId,OidrightTypeId,
6262
boolisCommutator);
6363

64-
staticvoidmakeOperatorDependencies(HeapTupletuple);
64+
staticObjectAddressmakeOperatorDependencies(HeapTupletuple);
6565

6666

6767
/*
@@ -325,7 +325,7 @@ OperatorShellMake(const char *operatorName,
325325
* Forward declaration is used only for this purpose, it is
326326
* not available to the user as it is for type definition.
327327
*/
328-
Oid
328+
ObjectAddress
329329
OperatorCreate(constchar*operatorName,
330330
OidoperatorNamespace,
331331
OidleftTypeId,
@@ -352,6 +352,7 @@ OperatorCreate(const char *operatorName,
352352
NameDataoname;
353353
TupleDesctupDesc;
354354
inti;
355+
ObjectAddressaddress;
355356

356357
/*
357358
* Sanity checks
@@ -540,7 +541,7 @@ OperatorCreate(const char *operatorName,
540541
CatalogUpdateIndexes(pg_operator_desc,tup);
541542

542543
/* Add dependencies for the entry */
543-
makeOperatorDependencies(tup);
544+
address=makeOperatorDependencies(tup);
544545

545546
/* Post creation hook for new operator */
546547
InvokeObjectPostCreateHook(OperatorRelationId,operatorObjectId,0);
@@ -564,7 +565,7 @@ OperatorCreate(const char *operatorName,
564565
if (OidIsValid(commutatorId)||OidIsValid(negatorId))
565566
OperatorUpd(operatorObjectId,commutatorId,negatorId);
566567

567-
returnoperatorObjectId;
568+
returnaddress;
568569
}
569570

570571
/*
@@ -764,7 +765,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
764765
* NB: the OidIsValid tests in this routine are necessary, in case
765766
* the given operator is a shell.
766767
*/
767-
staticvoid
768+
staticObjectAddress
768769
makeOperatorDependencies(HeapTupletuple)
769770
{
770771
Form_pg_operatoroper= (Form_pg_operator)GETSTRUCT(tuple);
@@ -860,4 +861,6 @@ makeOperatorDependencies(HeapTuple tuple)
860861

861862
/* Dependency on extension */
862863
recordDependencyOnCurrentExtension(&myself, true);
864+
865+
returnmyself;
863866
}

‎src/backend/catalog/pg_proc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static bool match_prosrc_to_literal(const char *prosrc, const char *literal,
6464
* not "ArrayType *", to avoid importing array.h into pg_proc_fn.h.
6565
* ----------------------------------------------------------------
6666
*/
67-
Oid
67+
ObjectAddress
6868
ProcedureCreate(constchar*procedureName,
6969
OidprocNamespace,
7070
boolreplace,
@@ -703,7 +703,7 @@ ProcedureCreate(const char *procedureName,
703703
AtEOXact_GUC(true,save_nestlevel);
704704
}
705705

706-
returnretval;
706+
returnmyself;
707707
}
708708

709709

‎src/backend/catalog/pg_type.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Oidbinary_upgrade_next_pg_type_oid = InvalidOid;
5252
*with correct ones, and "typisdefined" will be set to true.
5353
* ----------------------------------------------------------------
5454
*/
55-
Oid
55+
ObjectAddress
5656
TypeShellMake(constchar*typeName,OidtypeNamespace,OidownerId)
5757
{
5858
Relationpg_type_desc;
@@ -63,6 +63,7 @@ TypeShellMake(const char *typeName, Oid typeNamespace, Oid ownerId)
6363
boolnulls[Natts_pg_type];
6464
Oidtypoid;
6565
NameDataname;
66+
ObjectAddressaddress;
6667

6768
Assert(PointerIsValid(typeName));
6869

@@ -171,26 +172,28 @@ TypeShellMake(const char *typeName, Oid typeNamespace, Oid ownerId)
171172
/* Post creation hook for new shell type */
172173
InvokeObjectPostCreateHook(TypeRelationId,typoid,0);
173174

175+
ObjectAddressSet(address,TypeRelationId,typoid);
176+
174177
/*
175178
* clean up and return the type-oid
176179
*/
177180
heap_freetuple(tup);
178181
heap_close(pg_type_desc,RowExclusiveLock);
179182

180-
returntypoid;
183+
returnaddress;
181184
}
182185

183186
/* ----------------------------------------------------------------
184187
*TypeCreate
185188
*
186189
*This does all the necessary work needed to define a new type.
187190
*
188-
*Returns theOID assigned to the new type. If newTypeOid is
189-
*zero (the normal case), a new OID is created; otherwise we
190-
*use exactly that OID.
191+
*Returns theObjectAddress assigned to the new type.
192+
*If newTypeOid iszero (the normal case), a new OID is created;
193+
*otherwise weuse exactly that OID.
191194
* ----------------------------------------------------------------
192195
*/
193-
Oid
196+
ObjectAddress
194197
TypeCreate(OidnewTypeOid,
195198
constchar*typeName,
196199
OidtypeNamespace,
@@ -233,6 +236,7 @@ TypeCreate(Oid newTypeOid,
233236
NameDataname;
234237
inti;
235238
Acl*typacl=NULL;
239+
ObjectAddressaddress;
236240

237241
/*
238242
* We assume that the caller validated the arguments individually, but did
@@ -488,12 +492,14 @@ TypeCreate(Oid newTypeOid,
488492
/* Post creation hook for new type */
489493
InvokeObjectPostCreateHook(TypeRelationId,typeObjectId,0);
490494

495+
ObjectAddressSet(address,TypeRelationId,typeObjectId);
496+
491497
/*
492498
* finish up
493499
*/
494500
heap_close(pg_type_desc,RowExclusiveLock);
495501

496-
returntypeObjectId;
502+
returnaddress;
497503
}
498504

499505
/*

‎src/backend/catalog/toasting.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
289289
reloptions,
290290
false,
291291
true,
292-
true);
292+
true,
293+
NULL);
293294
Assert(toast_relid!=InvalidOid);
294295

295296
/* make the toast relation visible, else heap_open will fail */

‎src/backend/commands/aggregatecmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
* isn't an ordered-set aggregate.
5252
* "parameters" is a list of DefElem representing the agg's definition clauses.
5353
*/
54-
Oid
54+
ObjectAddress
5555
DefineAggregate(List*name,List*args,boololdstyle,List*parameters,
5656
constchar*queryString)
5757
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp