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

Commit1983275

Browse files
committed
Fix some ill-chosen names for globally-visible partition support functions.
"compute_hash_value" is particularly gratuitously generic, but IMOall of these ought to have names clearly related to partitioning.
1 parente23bae8 commit1983275

File tree

6 files changed

+41
-35
lines changed

6 files changed

+41
-35
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
855855
*/
856856
if (OidIsValid(defaultPartOid))
857857
{
858-
check_default_allows_bound(parent,defaultRel,bound);
858+
check_default_partition_contents(parent,defaultRel,bound);
859859
/* Keep the lock until commit. */
860860
heap_close(defaultRel,NoLock);
861861
}

‎src/backend/executor/execPartition.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,17 +1085,20 @@ get_partition_for_tuple(Relation relation, Datum *values, bool *isnull)
10851085
intpart_index=-1;
10861086
PartitionKeykey=RelationGetPartitionKey(relation);
10871087
PartitionDescpartdesc=RelationGetPartitionDesc(relation);
1088+
PartitionBoundInfoboundinfo=partdesc->boundinfo;
10881089

10891090
/* Route as appropriate based on partitioning strategy. */
10901091
switch (key->strategy)
10911092
{
10921093
casePARTITION_STRATEGY_HASH:
10931094
{
1094-
PartitionBoundInfoboundinfo=partdesc->boundinfo;
1095-
intgreatest_modulus=get_hash_partition_greatest_modulus(boundinfo);
1096-
uint64rowHash=compute_hash_value(key->partnatts,
1097-
key->partsupfunc,
1098-
values,isnull);
1095+
intgreatest_modulus;
1096+
uint64rowHash;
1097+
1098+
greatest_modulus=get_hash_partition_greatest_modulus(boundinfo);
1099+
rowHash=compute_partition_hash_value(key->partnatts,
1100+
key->partsupfunc,
1101+
values,isnull);
10991102

11001103
part_index=boundinfo->indexes[rowHash %greatest_modulus];
11011104
}
@@ -1104,19 +1107,19 @@ get_partition_for_tuple(Relation relation, Datum *values, bool *isnull)
11041107
casePARTITION_STRATEGY_LIST:
11051108
if (isnull[0])
11061109
{
1107-
if (partition_bound_accepts_nulls(partdesc->boundinfo))
1108-
part_index=partdesc->boundinfo->null_index;
1110+
if (partition_bound_accepts_nulls(boundinfo))
1111+
part_index=boundinfo->null_index;
11091112
}
11101113
else
11111114
{
11121115
boolequal= false;
11131116

11141117
bound_offset=partition_list_bsearch(key->partsupfunc,
11151118
key->partcollation,
1116-
partdesc->boundinfo,
1119+
boundinfo,
11171120
values[0],&equal);
11181121
if (bound_offset >=0&&equal)
1119-
part_index=partdesc->boundinfo->indexes[bound_offset];
1122+
part_index=boundinfo->indexes[bound_offset];
11201123
}
11211124
break;
11221125

@@ -1143,7 +1146,7 @@ get_partition_for_tuple(Relation relation, Datum *values, bool *isnull)
11431146
{
11441147
bound_offset=partition_range_datum_bsearch(key->partsupfunc,
11451148
key->partcollation,
1146-
partdesc->boundinfo,
1149+
boundinfo,
11471150
key->partnatts,
11481151
values,
11491152
&equal);
@@ -1154,7 +1157,7 @@ get_partition_for_tuple(Relation relation, Datum *values, bool *isnull)
11541157
* bound of the partition we're looking for, if there
11551158
* actually exists one.
11561159
*/
1157-
part_index=partdesc->boundinfo->indexes[bound_offset+1];
1160+
part_index=boundinfo->indexes[bound_offset+1];
11581161
}
11591162
}
11601163
break;
@@ -1169,7 +1172,7 @@ get_partition_for_tuple(Relation relation, Datum *values, bool *isnull)
11691172
* the default partition, if there is one.
11701173
*/
11711174
if (part_index<0)
1172-
part_index=partdesc->boundinfo->default_index;
1175+
part_index=boundinfo->default_index;
11731176

11741177
returnpart_index;
11751178
}

‎src/backend/partitioning/partbounds.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,8 @@ check_new_partition_bound(char *relname, Relation parent,
470470
*upper;
471471

472472
Assert(spec->strategy==PARTITION_STRATEGY_RANGE);
473-
lower=make_one_range_bound(key,-1,spec->lowerdatums, true);
474-
upper=make_one_range_bound(key,-1,spec->upperdatums, false);
473+
lower=make_one_partition_rbound(key,-1,spec->lowerdatums, true);
474+
upper=make_one_partition_rbound(key,-1,spec->upperdatums, false);
475475

476476
/*
477477
* First check if the resulting range would be empty with
@@ -589,15 +589,15 @@ check_new_partition_bound(char *relname, Relation parent,
589589
}
590590

591591
/*
592-
*check_default_allows_bound
592+
*check_default_partition_contents
593593
*
594594
* This function checks if there exists a row in the default partition that
595595
* would properly belong to the new partition being added. If it finds one,
596596
* it throws an error.
597597
*/
598598
void
599-
check_default_allows_bound(Relationparent,Relationdefault_rel,
600-
PartitionBoundSpec*new_spec)
599+
check_default_partition_contents(Relationparent,Relationdefault_rel,
600+
PartitionBoundSpec*new_spec)
601601
{
602602
List*new_part_constraints;
603603
List*def_part_constraints;
@@ -757,14 +757,14 @@ get_hash_partition_greatest_modulus(PartitionBoundInfo bound)
757757
}
758758

759759
/*
760-
*make_one_range_bound
760+
*make_one_partition_rbound
761761
*
762762
* Return a PartitionRangeBound given a list of PartitionRangeDatum elements
763763
* and a flag telling whether the bound is lower or not. Made into a function
764764
* because there are multiple sites that want to use this facility.
765765
*/
766766
PartitionRangeBound*
767-
make_one_range_bound(PartitionKeykey,intindex,List*datums,boollower)
767+
make_one_partition_rbound(PartitionKeykey,intindex,List*datums,boollower)
768768
{
769769
PartitionRangeBound*bound;
770770
ListCell*lc;
@@ -2052,20 +2052,21 @@ get_range_nulltest(PartitionKey key)
20522052
}
20532053

20542054
/*
2055-
*compute_hash_value
2055+
*compute_partition_hash_value
20562056
*
2057-
* Compute the hash value for givennot nullpartition key values.
2057+
* Compute the hash value for given partition key values.
20582058
*/
20592059
uint64
2060-
compute_hash_value(intpartnatts,FmgrInfo*partsupfunc,
2061-
Datum*values,bool*isnull)
2060+
compute_partition_hash_value(intpartnatts,FmgrInfo*partsupfunc,
2061+
Datum*values,bool*isnull)
20622062
{
20632063
inti;
20642064
uint64rowHash=0;
20652065
Datumseed=UInt64GetDatum(HASH_PARTITION_SEED);
20662066

20672067
for (i=0;i<partnatts;i++)
20682068
{
2069+
/* Nulls are just ignored */
20692070
if (!isnull[i])
20702071
{
20712072
Datumhash;

‎src/backend/partitioning/partprune.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2018,7 +2018,8 @@ get_matching_hash_bounds(PartitionPruneContext *context,
20182018
isnull[i]=bms_is_member(i,nullkeys);
20192019

20202020
greatest_modulus=get_hash_partition_greatest_modulus(boundinfo);
2021-
rowHash=compute_hash_value(partnatts,partsupfunc,values,isnull);
2021+
rowHash=compute_partition_hash_value(partnatts,partsupfunc,
2022+
values,isnull);
20222023

20232024
if (partindices[rowHash %greatest_modulus] >=0)
20242025
result->bound_offsets=

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,10 +499,10 @@ RelationBuildPartitionDesc(Relation rel)
499499
continue;
500500
}
501501

502-
lower=make_one_range_bound(key,i,spec->lowerdatums,
503-
true);
504-
upper=make_one_range_bound(key,i,spec->upperdatums,
505-
false);
502+
lower=make_one_partition_rbound(key,i,spec->lowerdatums,
503+
true);
504+
upper=make_one_partition_rbound(key,i,spec->upperdatums,
505+
false);
506506
all_bounds[ndatums++]=lower;
507507
all_bounds[ndatums++]=upper;
508508
i++;

‎src/include/partitioning/partbounds.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ typedef struct PartitionRangeBound
105105
}PartitionRangeBound;
106106

107107
externintget_hash_partition_greatest_modulus(PartitionBoundInfob);
108-
externuint64compute_hash_value(intpartnatts,FmgrInfo*partsupfunc,
109-
Datum*values,bool*isnull);
108+
externuint64compute_partition_hash_value(intpartnatts,FmgrInfo*partsupfunc,
109+
Datum*values,bool*isnull);
110110
externList*get_qual_from_partbound(Relationrel,Relationparent,
111111
PartitionBoundSpec*spec);
112112
externboolpartition_bounds_equal(intpartnatts,int16*parttyplen,
@@ -116,11 +116,12 @@ extern PartitionBoundInfo partition_bounds_copy(PartitionBoundInfo src,
116116
PartitionKeykey);
117117
externvoidcheck_new_partition_bound(char*relname,Relationparent,
118118
PartitionBoundSpec*spec);
119-
externvoidcheck_default_allows_bound(Relationparent,RelationdefaultRel,
120-
PartitionBoundSpec*new_spec);
119+
externvoidcheck_default_partition_contents(Relationparent,
120+
RelationdefaultRel,
121+
PartitionBoundSpec*new_spec);
121122

122-
externPartitionRangeBound*make_one_range_bound(PartitionKeykey,intindex,
123-
List*datums,boollower);
123+
externPartitionRangeBound*make_one_partition_rbound(PartitionKeykey,intindex,
124+
List*datums,boollower);
124125
externint32partition_hbound_cmp(intmodulus1,intremainder1,intmodulus2,
125126
intremainder2);
126127
externint32partition_rbound_cmp(intpartnatts,FmgrInfo*partsupfunc,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp