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

Commitf724022

Browse files
committed
Revise API for partition bound search functions.
Similar to what commitb022923 for adifferent set of functions, pass the required bits of the PartitionKeyinstead of the whole thing. This allows these functions to be usedwithout needing the PartitionKey to be available.Amit Langote. The larger patch series of which this patch is a parthas been reviewed and tested by Ashutosh Bapat, David Rowley, DilipKumar, Jesper Pedersen, Rajkumar Raghuwanshi, Beena Emerson, KyotaroHoriguchi, Álvaro Herrera, and me, but especially and in great detailby David Rowley.Discussion:http://postgr.es/m/098b9c71-1915-1a2a-8d52-1a7a50ce79e8@lab.ntt.co.jpDiscussion:http://postgr.es/m/1f6498e8-377f-d077-e791-5dc84dba2c00@lab.ntt.co.jp
1 parentb022923 commitf724022

File tree

1 file changed

+38
-28
lines changed

1 file changed

+38
-28
lines changed

‎src/backend/catalog/partition.c

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -174,22 +174,24 @@ static int32 partition_rbound_datum_cmp(FmgrInfo *partsupfunc,
174174
Datum*rb_datums,PartitionRangeDatumKind*rb_kind,
175175
Datum*tuple_datums,intn_tuple_datums);
176176

177-
staticintpartition_list_bsearch(PartitionKeykey,
177+
staticintpartition_list_bsearch(FmgrInfo*partsupfunc,Oid*partcollation,
178178
PartitionBoundInfoboundinfo,
179179
Datumvalue,bool*is_equal);
180-
staticintpartition_range_bsearch(PartitionKeykey,
180+
staticintpartition_range_bsearch(intpartnatts,FmgrInfo*partsupfunc,
181+
Oid*partcollation,
181182
PartitionBoundInfoboundinfo,
182183
PartitionRangeBound*probe,bool*is_equal);
183-
staticintpartition_range_datum_bsearch(PartitionKeykey,
184+
staticintpartition_range_datum_bsearch(FmgrInfo*partsupfunc,
185+
Oid*partcollation,
184186
PartitionBoundInfoboundinfo,
185187
intnvalues,Datum*values,bool*is_equal);
186-
staticintpartition_hash_bsearch(PartitionKeykey,
187-
PartitionBoundInfoboundinfo,
188+
staticintpartition_hash_bsearch(PartitionBoundInfoboundinfo,
188189
intmodulus,intremainder);
189190

190191
staticintget_partition_bound_num_indexes(PartitionBoundInfob);
191192
staticintget_greatest_modulus(PartitionBoundInfob);
192-
staticuint64compute_hash_value(PartitionKeykey,Datum*values,bool*isnull);
193+
staticuint64compute_hash_value(intpartnatts,FmgrInfo*partsupfunc,
194+
Datum*values,bool*isnull);
193195

194196
/*
195197
* RelationBuildPartitionDesc
@@ -1004,7 +1006,7 @@ check_new_partition_bound(char *relname, Relation parent,
10041006
* boundinfo->datums that is less than or equal to the
10051007
* (spec->modulus, spec->remainder) pair.
10061008
*/
1007-
offset=partition_hash_bsearch(key,boundinfo,
1009+
offset=partition_hash_bsearch(boundinfo,
10081010
spec->modulus,
10091011
spec->remainder);
10101012
if (offset<0)
@@ -1080,7 +1082,9 @@ check_new_partition_bound(char *relname, Relation parent,
10801082
intoffset;
10811083
boolequal;
10821084

1083-
offset=partition_list_bsearch(key,boundinfo,
1085+
offset=partition_list_bsearch(key->partsupfunc,
1086+
key->partcollation,
1087+
boundinfo,
10841088
val->constvalue,
10851089
&equal);
10861090
if (offset >=0&&equal)
@@ -1155,7 +1159,10 @@ check_new_partition_bound(char *relname, Relation parent,
11551159
* since the index array is initialised with an extra -1
11561160
* at the end.
11571161
*/
1158-
offset=partition_range_bsearch(key,boundinfo,lower,
1162+
offset=partition_range_bsearch(key->partnatts,
1163+
key->partsupfunc,
1164+
key->partcollation,
1165+
boundinfo,lower,
11591166
&equal);
11601167

11611168
if (boundinfo->indexes[offset+1]<0)
@@ -2574,7 +2581,9 @@ get_partition_for_tuple(Relation relation, Datum *values, bool *isnull)
25742581
{
25752582
PartitionBoundInfoboundinfo=partdesc->boundinfo;
25762583
intgreatest_modulus=get_greatest_modulus(boundinfo);
2577-
uint64rowHash=compute_hash_value(key,values,isnull);
2584+
uint64rowHash=compute_hash_value(key->partnatts,
2585+
key->partsupfunc,
2586+
values,isnull);
25782587

25792588
part_index=boundinfo->indexes[rowHash %greatest_modulus];
25802589
}
@@ -2590,7 +2599,8 @@ get_partition_for_tuple(Relation relation, Datum *values, bool *isnull)
25902599
{
25912600
boolequal= false;
25922601

2593-
bound_offset=partition_list_bsearch(key,
2602+
bound_offset=partition_list_bsearch(key->partsupfunc,
2603+
key->partcollation,
25942604
partdesc->boundinfo,
25952605
values[0],&equal);
25962606
if (bound_offset >=0&&equal)
@@ -2619,7 +2629,8 @@ get_partition_for_tuple(Relation relation, Datum *values, bool *isnull)
26192629

26202630
if (!range_partkey_has_null)
26212631
{
2622-
bound_offset=partition_range_datum_bsearch(key,
2632+
bound_offset=partition_range_datum_bsearch(key->partsupfunc,
2633+
key->partcollation,
26232634
partdesc->boundinfo,
26242635
key->partnatts,
26252636
values,
@@ -2938,7 +2949,7 @@ partition_rbound_datum_cmp(FmgrInfo *partsupfunc, Oid *partcollation,
29382949
* to the input value.
29392950
*/
29402951
staticint
2941-
partition_list_bsearch(PartitionKeykey,
2952+
partition_list_bsearch(FmgrInfo*partsupfunc,Oid*partcollation,
29422953
PartitionBoundInfoboundinfo,
29432954
Datumvalue,bool*is_equal)
29442955
{
@@ -2953,8 +2964,8 @@ partition_list_bsearch(PartitionKey key,
29532964
int32cmpval;
29542965

29552966
mid= (lo+hi+1) /2;
2956-
cmpval=DatumGetInt32(FunctionCall2Coll(&key->partsupfunc[0],
2957-
key->partcollation[0],
2967+
cmpval=DatumGetInt32(FunctionCall2Coll(&partsupfunc[0],
2968+
partcollation[0],
29582969
boundinfo->datums[mid][0],
29592970
value));
29602971
if (cmpval <=0)
@@ -2981,7 +2992,8 @@ partition_list_bsearch(PartitionKey key,
29812992
* to the input range bound
29822993
*/
29832994
staticint
2984-
partition_range_bsearch(PartitionKeykey,
2995+
partition_range_bsearch(intpartnatts,FmgrInfo*partsupfunc,
2996+
Oid*partcollation,
29852997
PartitionBoundInfoboundinfo,
29862998
PartitionRangeBound*probe,bool*is_equal)
29872999
{
@@ -2996,8 +3008,7 @@ partition_range_bsearch(PartitionKey key,
29963008
int32cmpval;
29973009

29983010
mid= (lo+hi+1) /2;
2999-
cmpval=partition_rbound_cmp(key->partnatts,key->partsupfunc,
3000-
key->partcollation,
3011+
cmpval=partition_rbound_cmp(partnatts,partsupfunc,partcollation,
30013012
boundinfo->datums[mid],
30023013
boundinfo->kind[mid],
30033014
(boundinfo->indexes[mid]==-1),
@@ -3026,7 +3037,7 @@ partition_range_bsearch(PartitionKey key,
30263037
* to the input tuple.
30273038
*/
30283039
staticint
3029-
partition_range_datum_bsearch(PartitionKeykey,
3040+
partition_range_datum_bsearch(FmgrInfo*partsupfunc,Oid*partcollation,
30303041
PartitionBoundInfoboundinfo,
30313042
intnvalues,Datum*values,bool*is_equal)
30323043
{
@@ -3041,8 +3052,8 @@ partition_range_datum_bsearch(PartitionKey key,
30413052
int32cmpval;
30423053

30433054
mid= (lo+hi+1) /2;
3044-
cmpval=partition_rbound_datum_cmp(key->partsupfunc,
3045-
key->partcollation,
3055+
cmpval=partition_rbound_datum_cmp(partsupfunc,
3056+
partcollation,
30463057
boundinfo->datums[mid],
30473058
boundinfo->kind[mid],
30483059
values,
@@ -3069,8 +3080,7 @@ partition_range_datum_bsearch(PartitionKey key,
30693080
*all of them are greater
30703081
*/
30713082
staticint
3072-
partition_hash_bsearch(PartitionKeykey,
3073-
PartitionBoundInfoboundinfo,
3083+
partition_hash_bsearch(PartitionBoundInfoboundinfo,
30743084
intmodulus,intremainder)
30753085
{
30763086
intlo,
@@ -3268,27 +3278,27 @@ get_greatest_modulus(PartitionBoundInfo bound)
32683278
* Compute the hash value for given not null partition key values.
32693279
*/
32703280
staticuint64
3271-
compute_hash_value(PartitionKeykey,Datum*values,bool*isnull)
3281+
compute_hash_value(intpartnatts,FmgrInfo*partsupfunc,
3282+
Datum*values,bool*isnull)
32723283
{
32733284
inti;
3274-
intnkeys=key->partnatts;
32753285
uint64rowHash=0;
32763286
Datumseed=UInt64GetDatum(HASH_PARTITION_SEED);
32773287

3278-
for (i=0;i<nkeys;i++)
3288+
for (i=0;i<partnatts;i++)
32793289
{
32803290
if (!isnull[i])
32813291
{
32823292
Datumhash;
32833293

3284-
Assert(OidIsValid(key->partsupfunc[i].fn_oid));
3294+
Assert(OidIsValid(partsupfunc[i].fn_oid));
32853295

32863296
/*
32873297
* Compute hash for each datum value by calling respective
32883298
* datatype-specific hash functions of each partition key
32893299
* attribute.
32903300
*/
3291-
hash=FunctionCall2(&key->partsupfunc[i],values[i],seed);
3301+
hash=FunctionCall2(&partsupfunc[i],values[i],seed);
32923302

32933303
/* Form a single 64-bit hash value */
32943304
rowHash=hash_combine64(rowHash,DatumGetUInt64(hash));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp