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

Commit27cdb34

Browse files
committed
Reindent table partitioning code.
We've accumulated quite a bit of stuff with which pgindent is notquite happy in this code; clean it up to provide a less-annoying basefor future pgindent runs.
1 parent96e0ccc commit27cdb34

File tree

15 files changed

+130
-130
lines changed

15 files changed

+130
-130
lines changed

‎src/backend/catalog/heap.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1780,12 +1780,12 @@ heap_drop_with_catalog(Oid relid)
17801780

17811781
/*
17821782
* If the relation is a partition, we must grab exclusive lock on its
1783-
* parent because we need to update its partition descriptor. We must
1784-
*takea table lock strong enough to prevent all queries on the parent
1785-
*fromproceeding until we commit and send out a shared-cache-inval
1786-
*noticethat will make them update their partition descriptor.
1787-
*Sometimes, doingthis is cycles spent uselessly, especially if the
1788-
*parent will bedropped as part of the same command anyway.
1783+
* parent because we need to update its partition descriptor. We must take
1784+
* a table lock strong enough to prevent all queries on the parent from
1785+
* proceeding until we commit and send out a shared-cache-inval notice
1786+
* that will make them update their partition descriptor. Sometimes, doing
1787+
* this is cycles spent uselessly, especially if the parent will be
1788+
* dropped as part of the same command anyway.
17891789
*/
17901790
if (rel->rd_rel->relispartition)
17911791
{
@@ -2084,8 +2084,8 @@ StoreRelCheck(Relation rel, char *ccname, Node *expr,
20842084
rel->rd_rel->relkind==RELKIND_PARTITIONED_TABLE)
20852085
ereport(ERROR,
20862086
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
2087-
errmsg("cannot add NO INHERIT constraint to partitioned table \"%s\"",
2088-
RelationGetRelationName(rel))));
2087+
errmsg("cannot add NO INHERIT constraint to partitioned table \"%s\"",
2088+
RelationGetRelationName(rel))));
20892089

20902090
/*
20912091
* Create the Check Constraint
@@ -3113,8 +3113,8 @@ StorePartitionKey(Relation rel,
31133113
HeapTupletuple;
31143114
Datumvalues[Natts_pg_partitioned_table];
31153115
boolnulls[Natts_pg_partitioned_table];
3116-
ObjectAddressmyself;
3117-
ObjectAddressreferenced;
3116+
ObjectAddressmyself;
3117+
ObjectAddressreferenced;
31183118

31193119
Assert(rel->rd_rel->relkind==RELKIND_PARTITIONED_TABLE);
31203120

@@ -3129,7 +3129,7 @@ StorePartitionKey(Relation rel,
31293129
/* Convert the expressions (if any) to a text datum */
31303130
if (partexprs)
31313131
{
3132-
char*exprString;
3132+
char*exprString;
31333133

31343134
exprString=nodeToString(partexprs);
31353135
partexprDatum=CStringGetTextDatum(exprString);
@@ -3149,7 +3149,7 @@ StorePartitionKey(Relation rel,
31493149
values[Anum_pg_partitioned_table_partrelid-1]=ObjectIdGetDatum(RelationGetRelid(rel));
31503150
values[Anum_pg_partitioned_table_partstrat-1]=CharGetDatum(strategy);
31513151
values[Anum_pg_partitioned_table_partnatts-1]=Int16GetDatum(partnatts);
3152-
values[Anum_pg_partitioned_table_partattrs-1]=PointerGetDatum(partattrs_vec);
3152+
values[Anum_pg_partitioned_table_partattrs-1]=PointerGetDatum(partattrs_vec);
31533153
values[Anum_pg_partitioned_table_partclass-1]=PointerGetDatum(partopclass_vec);
31543154
values[Anum_pg_partitioned_table_partcollation-1]=PointerGetDatum(partcollation_vec);
31553155
values[Anum_pg_partitioned_table_partexprs-1]=partexprDatum;
@@ -3185,8 +3185,8 @@ StorePartitionKey(Relation rel,
31853185

31863186
/*
31873187
* Anything mentioned in the expressions. We must ignore the column
3188-
* references, which will depend on the table itself; there is no
3189-
*separatepartition key object.
3188+
* references, which will depend on the table itself; there is no separate
3189+
* partition key object.
31903190
*/
31913191
if (partexprs)
31923192
recordDependencyOnSingleRelExpr(&myself,
@@ -3204,7 +3204,7 @@ StorePartitionKey(Relation rel,
32043204
}
32053205

32063206
/*
3207-
*RemovePartitionKeyByRelId
3207+
*RemovePartitionKeyByRelId
32083208
*Remove pg_partitioned_table entry for a relation
32093209
*/
32103210
void
@@ -3240,9 +3240,9 @@ StorePartitionBound(Relation rel, Relation parent, Node *bound)
32403240
RelationclassRel;
32413241
HeapTupletuple,
32423242
newtuple;
3243-
Datumnew_val[Natts_pg_class];
3244-
boolnew_null[Natts_pg_class],
3245-
new_repl[Natts_pg_class];
3243+
Datumnew_val[Natts_pg_class];
3244+
boolnew_null[Natts_pg_class],
3245+
new_repl[Natts_pg_class];
32463246

32473247
/* Update pg_class tuple */
32483248
classRel=heap_open(RelationRelationId,RowExclusiveLock);
@@ -3254,8 +3254,8 @@ StorePartitionBound(Relation rel, Relation parent, Node *bound)
32543254

32553255
#ifdefUSE_ASSERT_CHECKING
32563256
{
3257-
Form_pg_classclassForm;
3258-
boolisnull;
3257+
Form_pg_classclassForm;
3258+
boolisnull;
32593259

32603260
classForm= (Form_pg_class)GETSTRUCT(tuple);
32613261
Assert(!classForm->relispartition);

‎src/backend/catalog/partition.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ RelationGetPartitionDispatchInfo(Relation rel, int lockmode,
10691069
Relationpartrel=lfirst(lc1);
10701070
Relationparent=lfirst(lc2);
10711071
PartitionKeypartkey=RelationGetPartitionKey(partrel);
1072-
TupleDesctupdesc=RelationGetDescr(partrel);
1072+
TupleDesctupdesc=RelationGetDescr(partrel);
10731073
PartitionDescpartdesc=RelationGetPartitionDesc(partrel);
10741074
intj,
10751075
m;
@@ -1082,17 +1082,17 @@ RelationGetPartitionDispatchInfo(Relation rel, int lockmode,
10821082
if (parent!=NULL)
10831083
{
10841084
/*
1085-
* For every partitioned table other than root, we must store
1086-
*atuple table slot initialized with its tuple descriptor and
1087-
*atuple conversion map to convert a tuple from its parent's
1088-
* rowtype to its own. That is to make sure that we are looking
1089-
*atthe correct row using the correct tuple descriptor when
1085+
* For every partitioned table other than root, we must store a
1086+
* tuple table slot initialized with its tuple descriptor and a
1087+
* tuple conversion map to convert a tuple from its parent's
1088+
* rowtype to its own. That is to make sure that we are looking at
1089+
* the correct row using the correct tuple descriptor when
10901090
* computing its partition key for tuple routing.
10911091
*/
10921092
pd[i]->tupslot=MakeSingleTupleTableSlot(tupdesc);
10931093
pd[i]->tupmap=convert_tuples_by_name(RelationGetDescr(parent),
10941094
tupdesc,
1095-
gettext_noop("could not convert row type"));
1095+
gettext_noop("could not convert row type"));
10961096
}
10971097
else
10981098
{
@@ -1574,10 +1574,10 @@ generate_partition_qual(Relation rel)
15741574
result=my_qual;
15751575

15761576
/*
1577-
* Change Vars to have partition's attnos instead of the parent's.
1578-
*We dothis after we concatenate the parent's quals, because
1579-
*we want every Varin it to bear this relation's attnos.
1580-
*It's safe to assume varno = 1here.
1577+
* Change Vars to have partition's attnos instead of the parent's. We do
1578+
* this after we concatenate the parent's quals, because we want every Var
1579+
* in it to bear this relation's attnos. It's safe to assume varno = 1
1580+
* here.
15811581
*/
15821582
result=map_partition_varattnos(result,1,rel,parent);
15831583

‎src/backend/commands/copy.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,9 @@ typedef struct CopyStateData
163163
List*range_table;
164164

165165
PartitionDispatch*partition_dispatch_info;
166-
intnum_dispatch;/* Number of entries in the above array */
167-
intnum_partitions;/* Number of members in the following
168-
* arrays */
169-
ResultRelInfo*partitions;/* Per partition result relation */
166+
intnum_dispatch;/* Number of entries in the above array */
167+
intnum_partitions;/* Number of members in the following arrays */
168+
ResultRelInfo*partitions;/* Per partition result relation */
170169
TupleConversionMap**partition_tupconv_maps;
171170
TupleTableSlot*partition_tuple_slot;
172171

@@ -1416,12 +1415,12 @@ BeginCopy(ParseState *pstate,
14161415
/* Initialize state for CopyFrom tuple routing. */
14171416
if (is_from&&rel->rd_rel->relkind==RELKIND_PARTITIONED_TABLE)
14181417
{
1419-
PartitionDispatch*partition_dispatch_info;
1420-
ResultRelInfo*partitions;
1418+
PartitionDispatch*partition_dispatch_info;
1419+
ResultRelInfo*partitions;
14211420
TupleConversionMap**partition_tupconv_maps;
1422-
TupleTableSlot*partition_tuple_slot;
1423-
intnum_parted,
1424-
num_partitions;
1421+
TupleTableSlot*partition_tuple_slot;
1422+
intnum_parted,
1423+
num_partitions;
14251424

14261425
ExecSetupPartitionTupleRouting(rel,
14271426
&partition_dispatch_info,
@@ -2499,7 +2498,7 @@ CopyFrom(CopyState cstate)
24992498
for (;;)
25002499
{
25012500
TupleTableSlot*slot,
2502-
*oldslot;
2501+
*oldslot;
25032502
boolskip_tuple;
25042503
Oidloaded_oid=InvalidOid;
25052504

‎src/backend/commands/trigger.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
193193
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
194194
errmsg("\"%s\" is a partitioned table",
195195
RelationGetRelationName(rel)),
196-
errdetail("Partitioned tables cannot have ROW triggers.")));
196+
errdetail("Partitioned tables cannot have ROW triggers.")));
197197
}
198198
elseif (rel->rd_rel->relkind==RELKIND_VIEW)
199199
{

‎src/backend/executor/execMain.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,7 @@ InitResultRelInfo(ResultRelInfo *resultRelInfo,
12221222
Relationpartition_root,
12231223
intinstrument_options)
12241224
{
1225-
List*partition_check=NIL;
1225+
List*partition_check=NIL;
12261226

12271227
MemSet(resultRelInfo,0,sizeof(ResultRelInfo));
12281228
resultRelInfo->type=T_ResultRelInfo;
@@ -1754,10 +1754,10 @@ ExecPartitionCheck(ResultRelInfo *resultRelInfo, TupleTableSlot *slot,
17541754
*/
17551755
if (resultRelInfo->ri_PartitionCheckExpr==NULL)
17561756
{
1757-
List*qual=resultRelInfo->ri_PartitionCheck;
1757+
List*qual=resultRelInfo->ri_PartitionCheck;
17581758

17591759
resultRelInfo->ri_PartitionCheckExpr= (List*)
1760-
ExecPrepareExpr((Expr*)qual,estate);
1760+
ExecPrepareExpr((Expr*)qual,estate);
17611761
}
17621762

17631763
/*
@@ -1837,7 +1837,7 @@ ExecConstraints(ResultRelInfo *resultRelInfo,
18371837
ereport(ERROR,
18381838
(errcode(ERRCODE_NOT_NULL_VIOLATION),
18391839
errmsg("null value in column \"%s\" violates not-null constraint",
1840-
NameStr(orig_tupdesc->attrs[attrChk-1]->attname)),
1840+
NameStr(orig_tupdesc->attrs[attrChk-1]->attname)),
18411841
val_desc ?errdetail("Failing row contains %s.",val_desc) :0,
18421842
errtablecol(orig_rel,attrChk)));
18431843
}
@@ -1900,9 +1900,9 @@ ExecConstraints(ResultRelInfo *resultRelInfo,
19001900
64);
19011901
ereport(ERROR,
19021902
(errcode(ERRCODE_CHECK_VIOLATION),
1903-
errmsg("new row for relation \"%s\" violates partition constraint",
1904-
RelationGetRelationName(orig_rel)),
1905-
val_desc ?errdetail("Failing row contains %s.",val_desc) :0));
1903+
errmsg("new row for relation \"%s\" violates partition constraint",
1904+
RelationGetRelationName(orig_rel)),
1905+
val_desc ?errdetail("Failing row contains %s.",val_desc) :0));
19061906
}
19071907
}
19081908

@@ -3118,7 +3118,7 @@ ExecSetupPartitionTupleRouting(Relation rel,
31183118
*partitions= (ResultRelInfo*)palloc(*num_partitions*
31193119
sizeof(ResultRelInfo));
31203120
*tup_conv_maps= (TupleConversionMap**)palloc0(*num_partitions*
3121-
sizeof(TupleConversionMap*));
3121+
sizeof(TupleConversionMap*));
31223122

31233123
/*
31243124
* Initialize an empty slot that will be used to manipulate tuples of any
@@ -3157,7 +3157,7 @@ ExecSetupPartitionTupleRouting(Relation rel,
31573157

31583158
InitResultRelInfo(leaf_part_rri,
31593159
partrel,
3160-
1,/* dummy */
3160+
1,/* dummy */
31613161
rel,
31623162
0);
31633163

@@ -3190,8 +3190,8 @@ int
31903190
ExecFindPartition(ResultRelInfo*resultRelInfo,PartitionDispatch*pd,
31913191
TupleTableSlot*slot,EState*estate)
31923192
{
3193-
intresult;
3194-
Oidfailed_at;
3193+
intresult;
3194+
Oidfailed_at;
31953195
ExprContext*econtext=GetPerTupleExprContext(estate);
31963196

31973197
econtext->ecxt_scantuple=slot;
@@ -3218,7 +3218,7 @@ ExecFindPartition(ResultRelInfo *resultRelInfo, PartitionDispatch *pd,
32183218
(errcode(ERRCODE_CHECK_VIOLATION),
32193219
errmsg("no partition of relation \"%s\" found for row",
32203220
get_rel_name(failed_at)),
3221-
val_desc ?errdetail("Failing row contains %s.",val_desc) :0));
3221+
val_desc ?errdetail("Failing row contains %s.",val_desc) :0));
32223222
}
32233223

32243224
returnresult;

‎src/backend/executor/nodeModifyTable.c

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ ExecInsert(ModifyTableState *mtstate,
263263
OidnewId;
264264
List*recheckIndexes=NIL;
265265
TupleTableSlot*oldslot=slot,
266-
*result=NULL;
266+
*result=NULL;
267267

268268
/*
269269
* get the heap tuple out of the tuple table slot, making sure we have a
@@ -279,19 +279,19 @@ ExecInsert(ModifyTableState *mtstate,
279279
/* Determine the partition to heap_insert the tuple into */
280280
if (mtstate->mt_partition_dispatch_info)
281281
{
282-
intleaf_part_index;
282+
intleaf_part_index;
283283
TupleConversionMap*map;
284284

285285
/*
286286
* Away we go ... If we end up not finding a partition after all,
287287
* ExecFindPartition() does not return and errors out instead.
288-
* Otherwise, the returned value is to be used as an index into
289-
*arraysmt_partitions[] and mt_partition_tupconv_maps[] that
290-
*will get usthe ResultRelInfo and TupleConversionMap for the
291-
*partition,respectively.
288+
* Otherwise, the returned value is to be used as an index into arrays
289+
* mt_partitions[] and mt_partition_tupconv_maps[] that will get us
290+
* the ResultRelInfo and TupleConversionMap for the partition,
291+
* respectively.
292292
*/
293293
leaf_part_index=ExecFindPartition(resultRelInfo,
294-
mtstate->mt_partition_dispatch_info,
294+
mtstate->mt_partition_dispatch_info,
295295
slot,
296296
estate);
297297
Assert(leaf_part_index >=0&&
@@ -308,7 +308,7 @@ ExecInsert(ModifyTableState *mtstate,
308308
if (resultRelInfo->ri_FdwRoutine)
309309
ereport(ERROR,
310310
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
311-
errmsg("cannot route inserted tuples to a foreign table")));
311+
errmsg("cannot route inserted tuples to a foreign table")));
312312

313313
/* For ExecInsertIndexTuples() to work on the partition's indexes */
314314
estate->es_result_relation_info=resultRelInfo;
@@ -320,14 +320,14 @@ ExecInsert(ModifyTableState *mtstate,
320320
map=mtstate->mt_partition_tupconv_maps[leaf_part_index];
321321
if (map)
322322
{
323-
Relationpartrel=resultRelInfo->ri_RelationDesc;
323+
Relationpartrel=resultRelInfo->ri_RelationDesc;
324324

325325
tuple=do_convert_tuple(tuple,map);
326326

327327
/*
328-
* We must use the partition's tuple descriptor from this
329-
*pointon, until we're finished dealing with the partition.
330-
*Use thededicated slot for that.
328+
* We must use the partition's tuple descriptor from this point
329+
* on, until we're finished dealing with the partition. Use the
330+
* dedicated slot for that.
331331
*/
332332
slot=mtstate->mt_partition_tuple_slot;
333333
Assert(slot!=NULL);
@@ -1730,12 +1730,12 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
17301730
if (operation==CMD_INSERT&&
17311731
rel->rd_rel->relkind==RELKIND_PARTITIONED_TABLE)
17321732
{
1733-
PartitionDispatch*partition_dispatch_info;
1734-
ResultRelInfo*partitions;
1733+
PartitionDispatch*partition_dispatch_info;
1734+
ResultRelInfo*partitions;
17351735
TupleConversionMap**partition_tupconv_maps;
1736-
TupleTableSlot*partition_tuple_slot;
1737-
intnum_parted,
1738-
num_partitions;
1736+
TupleTableSlot*partition_tuple_slot;
1737+
intnum_parted,
1738+
num_partitions;
17391739

17401740
ExecSetupPartitionTupleRouting(rel,
17411741
&partition_dispatch_info,
@@ -1784,7 +1784,7 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
17841784
{
17851785
TupleTableSlot*slot;
17861786
ExprContext*econtext;
1787-
List*returningList;
1787+
List*returningList;
17881788

17891789
/*
17901790
* Initialize result tuple slot and assign its rowtype using the first
@@ -1821,9 +1821,9 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
18211821
/*
18221822
* Build a projection for each leaf partition rel. Note that we
18231823
* didn't build the returningList for each partition within the
1824-
* planner, but simple translation of the varattnos for each
1825-
*partitionwill suffice. This only occurs for the INSERT case;
1826-
*UPDATE/DELETEare handled above.
1824+
* planner, but simple translation of the varattnos for each partition
1825+
* will suffice. This only occurs for the INSERT case; UPDATE/DELETE
1826+
* are handled above.
18271827
*/
18281828
resultRelInfo=mtstate->mt_partitions;
18291829
returningList=linitial(node->returningLists);
@@ -2095,7 +2095,8 @@ ExecEndModifyTable(ModifyTableState *node)
20952095
resultRelInfo);
20962096
}
20972097

2098-
/* Close all the partitioned tables, leaf partitions, and their indices
2098+
/*
2099+
* Close all the partitioned tables, leaf partitions, and their indices
20992100
*
21002101
* Remember node->mt_partition_dispatch_info[0] corresponds to the root
21012102
* partitioned table, which we must not try to close, because it is the

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp