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

Commit4b9a98e

Browse files
committed
Clean up code, comments, and formatting for table partitioning.
Amit Langote, plus pgindent-ing by me. Inspired in part by reviewcomments from Tomas Vondra.
1 parentacddbe2 commit4b9a98e

File tree

6 files changed

+187
-185
lines changed

6 files changed

+187
-185
lines changed

‎src/backend/catalog/heap.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,6 +1887,10 @@ heap_drop_with_catalog(Oid relid)
18871887

18881888
if (parent)
18891889
{
1890+
/*
1891+
* Invalidate the parent's relcache so that the partition is no longer
1892+
* included in its partition descriptor.
1893+
*/
18901894
CacheInvalidateRelcache(parent);
18911895
heap_close(parent,NoLock);/* keep the lock */
18921896
}

‎src/backend/catalog/partition.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,7 +1492,7 @@ generate_partition_qual(Relation rel, bool recurse)
14921492
*Construct values[] and isnull[] arrays for the partition key
14931493
*of a tuple.
14941494
*
1495-
*pkinfopartition key execution info
1495+
*pdPartition dispatch object of the partitioned table
14961496
*slotHeap tuple from which to extract partition key
14971497
*estateexecutor state for evaluating any partition key
14981498
*expressions (must be non-NULL)
@@ -1565,7 +1565,7 @@ FormPartitionKeyDatum(PartitionDispatch pd,
15651565
* the latter case.
15661566
*/
15671567
int
1568-
get_partition_for_tuple(PartitionDispatch*pd,
1568+
get_partition_for_tuple(PartitionDispatch*pd,
15691569
TupleTableSlot*slot,
15701570
EState*estate,
15711571
Oid*failed_at)

‎src/backend/commands/copy.c

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ typedef struct CopyStateData
161161
ExprState**defexprs;/* array of default att expressions */
162162
boolvolatile_defexprs;/* is any of defexprs volatile? */
163163
List*range_table;
164-
PartitionDispatch*partition_dispatch_info;
165-
intnum_dispatch;
166-
intnum_partitions;
167-
ResultRelInfo*partitions;
168-
TupleConversionMap**partition_tupconv_maps;
164+
PartitionDispatch*partition_dispatch_info;
165+
intnum_dispatch;
166+
intnum_partitions;
167+
ResultRelInfo*partitions;
168+
TupleConversionMap**partition_tupconv_maps;
169169

170170
/*
171171
* These variables are used to reduce overhead in textual COPY FROM.
@@ -1403,31 +1403,28 @@ BeginCopy(ParseState *pstate,
14031403
errmsg("table \"%s\" does not have OIDs",
14041404
RelationGetRelationName(cstate->rel))));
14051405

1406-
/*
1407-
* Initialize state for CopyFrom tuple routing. Watch out for
1408-
* any foreign partitions.
1409-
*/
1406+
/* Initialize state for CopyFrom tuple routing. */
14101407
if (is_from&&rel->rd_rel->relkind==RELKIND_PARTITIONED_TABLE)
14111408
{
1412-
PartitionDispatch*pd;
1413-
List*leaf_parts;
1414-
ListCell*cell;
1415-
inti,
1416-
num_parted,
1417-
num_leaf_parts;
1418-
ResultRelInfo*leaf_part_rri;
1409+
List*leaf_parts;
1410+
ListCell*cell;
1411+
inti,
1412+
num_parted;
1413+
ResultRelInfo*leaf_part_rri;
14191414

14201415
/* Get the tuple-routing information and lock partitions */
1421-
pd=RelationGetPartitionDispatchInfo(rel,RowExclusiveLock,
1422-
&num_parted,&leaf_parts);
1423-
num_leaf_parts=list_length(leaf_parts);
1424-
cstate->partition_dispatch_info=pd;
1416+
cstate->partition_dispatch_info=
1417+
RelationGetPartitionDispatchInfo(rel,RowExclusiveLock,
1418+
&num_parted,
1419+
&leaf_parts);
14251420
cstate->num_dispatch=num_parted;
1426-
cstate->num_partitions=num_leaf_parts;
1427-
cstate->partitions= (ResultRelInfo*)palloc(num_leaf_parts*
1428-
sizeof(ResultRelInfo));
1421+
cstate->num_partitions=list_length(leaf_parts);
1422+
cstate->partitions= (ResultRelInfo*)
1423+
palloc(cstate->num_partitions*
1424+
sizeof(ResultRelInfo));
14291425
cstate->partition_tupconv_maps= (TupleConversionMap**)
1430-
palloc0(num_leaf_parts*sizeof(TupleConversionMap*));
1426+
palloc0(cstate->num_partitions*
1427+
sizeof(TupleConversionMap*));
14311428

14321429
leaf_part_rri=cstate->partitions;
14331430
i=0;
@@ -1438,8 +1435,8 @@ BeginCopy(ParseState *pstate,
14381435
/*
14391436
* We locked all the partitions above including the leaf
14401437
* partitions. Note that each of the relations in
1441-
* cstate->partitions will be closed by CopyFrom() after
1442-
*it'sfinished with its processing.
1438+
* cstate->partitions will be closed by CopyFrom() after it's
1439+
* finished with its processing.
14431440
*/
14441441
partrel=heap_open(lfirst_oid(cell),NoLock);
14451442

@@ -1451,18 +1448,19 @@ BeginCopy(ParseState *pstate,
14511448

14521449
InitResultRelInfo(leaf_part_rri,
14531450
partrel,
1454-
1,/* dummy */
1455-
false,/* no partition constraint check */
1451+
1,/* dummy */
1452+
false,/* no partition constraint
1453+
* check */
14561454
0);
14571455

14581456
/* Open partition indices */
14591457
ExecOpenIndices(leaf_part_rri, false);
14601458

14611459
if (!equalTupleDescs(tupDesc,RelationGetDescr(partrel)))
14621460
cstate->partition_tupconv_maps[i]=
1463-
convert_tuples_by_name(tupDesc,
1464-
RelationGetDescr(partrel),
1465-
gettext_noop("could not convert row type"));
1461+
convert_tuples_by_name(tupDesc,
1462+
RelationGetDescr(partrel),
1463+
gettext_noop("could not convert row type"));
14661464
leaf_part_rri++;
14671465
i++;
14681466
}
@@ -2486,8 +2484,8 @@ CopyFrom(CopyState cstate)
24862484
* BEFORE/INSTEAD OF triggers, or we need to evaluate volatile default
24872485
* expressions. Such triggers or expressions might query the table we're
24882486
* inserting to, and act differently if the tuples that have already been
2489-
* processed and prepared for insertion are not there. We also can't
2490-
*doit if the table is partitioned.
2487+
* processed and prepared for insertion are not there. We also can't do
2488+
* it if the table is partitioned.
24912489
*/
24922490
if ((resultRelInfo->ri_TrigDesc!=NULL&&
24932491
(resultRelInfo->ri_TrigDesc->trig_insert_before_row||
@@ -2572,7 +2570,7 @@ CopyFrom(CopyState cstate)
25722570
/* Determine the partition to heap_insert the tuple into */
25732571
if (cstate->partition_dispatch_info)
25742572
{
2575-
intleaf_part_index;
2573+
intleaf_part_index;
25762574
TupleConversionMap*map;
25772575

25782576
/*
@@ -2584,7 +2582,7 @@ CopyFrom(CopyState cstate)
25842582
* partition, respectively.
25852583
*/
25862584
leaf_part_index=ExecFindPartition(resultRelInfo,
2587-
cstate->partition_dispatch_info,
2585+
cstate->partition_dispatch_info,
25882586
slot,
25892587
estate);
25902588
Assert(leaf_part_index >=0&&
@@ -2601,7 +2599,7 @@ CopyFrom(CopyState cstate)
26012599
if (resultRelInfo->ri_FdwRoutine)
26022600
ereport(ERROR,
26032601
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2604-
errmsg("cannot route inserted tuples to a foreign table")));
2602+
errmsg("cannot route inserted tuples to a foreign table")));
26052603

26062604
/*
26072605
* For ExecInsertIndexTuples() to work on the partition's indexes
@@ -2752,7 +2750,7 @@ CopyFrom(CopyState cstate)
27522750
/* Close all the partitioned tables, leaf partitions, and their indices */
27532751
if (cstate->partition_dispatch_info)
27542752
{
2755-
inti;
2753+
inti;
27562754

27572755
/*
27582756
* Remember cstate->partition_dispatch_info[0] corresponds to the root

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp