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

Commitb022923

Browse files
committed
Revise API for partition_rbound_cmp/partition_rbound_datum_cmp.
Instead of passing the PartitionKey, pass just the required bits ofit. This allows these functions to be used without needing thePartitionKey to be available, which is important for severalpending patches.Ashutosh Bapat, reviewed by Amit Langote, with a comment tweakby me.Discussion:http://postgr.es/m/3d835ed1-36ab-f06d-0ce8-a76a2bbf7677@lab.ntt.co.jpDiscussion:http://postgr.es/m/b4d88995-094b-320c-b614-2282fae0bf6c@lab.ntt.co.jp
1 parent76b6aa4 commitb022923

File tree

1 file changed

+41
-21
lines changed

1 file changed

+41
-21
lines changed

‎src/backend/catalog/partition.c

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,12 @@ static PartitionRangeBound *make_one_range_bound(PartitionKey key, int index,
165165
List*datums,boollower);
166166
staticint32partition_hbound_cmp(intmodulus1,intremainder1,intmodulus2,
167167
intremainder2);
168-
staticint32partition_rbound_cmp(PartitionKeykey,
169-
Datum*datums1,PartitionRangeDatumKind*kind1,
170-
boollower1,PartitionRangeBound*b2);
171-
staticint32partition_rbound_datum_cmp(PartitionKeykey,
168+
staticint32partition_rbound_cmp(intpartnatts,FmgrInfo*partsupfunc,
169+
Oid*partcollation,Datum*datums1,
170+
PartitionRangeDatumKind*kind1,boollower1,
171+
PartitionRangeBound*b2);
172+
staticint32partition_rbound_datum_cmp(FmgrInfo*partsupfunc,
173+
Oid*partcollation,
172174
Datum*rb_datums,PartitionRangeDatumKind*rb_kind,
173175
Datum*tuple_datums,intn_tuple_datums);
174176

@@ -1113,8 +1115,9 @@ check_new_partition_bound(char *relname, Relation parent,
11131115
* First check if the resulting range would be empty with
11141116
* specified lower and upper bounds
11151117
*/
1116-
if (partition_rbound_cmp(key,lower->datums,lower->kind, true,
1117-
upper) >=0)
1118+
if (partition_rbound_cmp(key->partnatts,key->partsupfunc,
1119+
key->partcollation,lower->datums,
1120+
lower->kind, true,upper) >=0)
11181121
{
11191122
ereport(ERROR,
11201123
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
@@ -1174,7 +1177,10 @@ check_new_partition_bound(char *relname, Relation parent,
11741177
kind=boundinfo->kind[offset+1];
11751178
is_lower= (boundinfo->indexes[offset+1]==-1);
11761179

1177-
cmpval=partition_rbound_cmp(key,datums,kind,
1180+
cmpval=partition_rbound_cmp(key->partnatts,
1181+
key->partsupfunc,
1182+
key->partcollation,
1183+
datums,kind,
11781184
is_lower,upper);
11791185
if (cmpval<0)
11801186
{
@@ -2614,10 +2620,11 @@ get_partition_for_tuple(Relation relation, Datum *values, bool *isnull)
26142620
if (!range_partkey_has_null)
26152621
{
26162622
bound_offset=partition_range_datum_bsearch(key,
2617-
partdesc->boundinfo,
2618-
key->partnatts,
2619-
values,
2620-
&equal);
2623+
partdesc->boundinfo,
2624+
key->partnatts,
2625+
values,
2626+
&equal);
2627+
26212628
/*
26222629
* The bound at bound_offset is less than or equal to the
26232630
* tuple value, so the bound at offset+1 is the upper
@@ -2811,7 +2818,9 @@ qsort_partition_rbound_cmp(const void *a, const void *b, void *arg)
28112818
PartitionRangeBound*b2= (*(PartitionRangeBound*const*)b);
28122819
PartitionKeykey= (PartitionKey)arg;
28132820

2814-
returnpartition_rbound_cmp(key,b1->datums,b1->kind,b1->lower,b2);
2821+
returnpartition_rbound_cmp(key->partnatts,key->partsupfunc,
2822+
key->partcollation,b1->datums,b1->kind,
2823+
b1->lower,b2);
28152824
}
28162825

28172826
/*
@@ -2820,6 +2829,10 @@ qsort_partition_rbound_cmp(const void *a, const void *b, void *arg)
28202829
* Return for two range bounds whether the 1st one (specified in datums1,
28212830
* kind1, and lower1) is <, =, or > the bound specified in *b2.
28222831
*
2832+
* partnatts, partsupfunc and partcollation give the number of attributes in the
2833+
* bounds to be compared, comparison function to be used and the collations of
2834+
* attributes, respectively.
2835+
*
28232836
* Note that if the values of the two range bounds compare equal, then we take
28242837
* into account whether they are upper or lower bounds, and an upper bound is
28252838
* considered to be smaller than a lower bound. This is important to the way
@@ -2828,7 +2841,7 @@ qsort_partition_rbound_cmp(const void *a, const void *b, void *arg)
28282841
* two contiguous partitions.
28292842
*/
28302843
staticint32
2831-
partition_rbound_cmp(PartitionKeykey,
2844+
partition_rbound_cmp(intpartnatts,FmgrInfo*partsupfunc,Oid*partcollation,
28322845
Datum*datums1,PartitionRangeDatumKind*kind1,
28332846
boollower1,PartitionRangeBound*b2)
28342847
{
@@ -2838,7 +2851,7 @@ partition_rbound_cmp(PartitionKey key,
28382851
PartitionRangeDatumKind*kind2=b2->kind;
28392852
boollower2=b2->lower;
28402853

2841-
for (i=0;i<key->partnatts;i++)
2854+
for (i=0;i<partnatts;i++)
28422855
{
28432856
/*
28442857
* First, handle cases where the column is unbounded, which should not
@@ -2859,8 +2872,8 @@ partition_rbound_cmp(PartitionKey key,
28592872
*/
28602873
break;
28612874

2862-
cmpval=DatumGetInt32(FunctionCall2Coll(&key->partsupfunc[i],
2863-
key->partcollation[i],
2875+
cmpval=DatumGetInt32(FunctionCall2Coll(&partsupfunc[i],
2876+
partcollation[i],
28642877
datums1[i],
28652878
datums2[i]));
28662879
if (cmpval!=0)
@@ -2884,9 +2897,14 @@ partition_rbound_cmp(PartitionKey key,
28842897
*
28852898
* Return whether range bound (specified in rb_datums, rb_kind, and rb_lower)
28862899
* is <, =, or > partition key of tuple (tuple_datums)
2900+
*
2901+
* n_tuple_datums, partsupfunc and partcollation give number of attributes in
2902+
* the bounds to be compared, comparison function to be used and the collations
2903+
* of attributes resp.
2904+
*
28872905
*/
28882906
staticint32
2889-
partition_rbound_datum_cmp(PartitionKeykey,
2907+
partition_rbound_datum_cmp(FmgrInfo*partsupfunc,Oid*partcollation,
28902908
Datum*rb_datums,PartitionRangeDatumKind*rb_kind,
28912909
Datum*tuple_datums,intn_tuple_datums)
28922910
{
@@ -2900,8 +2918,8 @@ partition_rbound_datum_cmp(PartitionKey key,
29002918
elseif (rb_kind[i]==PARTITION_RANGE_DATUM_MAXVALUE)
29012919
return1;
29022920

2903-
cmpval=DatumGetInt32(FunctionCall2Coll(&key->partsupfunc[i],
2904-
key->partcollation[i],
2921+
cmpval=DatumGetInt32(FunctionCall2Coll(&partsupfunc[i],
2922+
partcollation[i],
29052923
rb_datums[i],
29062924
tuple_datums[i]));
29072925
if (cmpval!=0)
@@ -2978,7 +2996,8 @@ partition_range_bsearch(PartitionKey key,
29782996
int32cmpval;
29792997

29802998
mid= (lo+hi+1) /2;
2981-
cmpval=partition_rbound_cmp(key,
2999+
cmpval=partition_rbound_cmp(key->partnatts,key->partsupfunc,
3000+
key->partcollation,
29823001
boundinfo->datums[mid],
29833002
boundinfo->kind[mid],
29843003
(boundinfo->indexes[mid]==-1),
@@ -3022,7 +3041,8 @@ partition_range_datum_bsearch(PartitionKey key,
30223041
int32cmpval;
30233042

30243043
mid= (lo+hi+1) /2;
3025-
cmpval=partition_rbound_datum_cmp(key,
3044+
cmpval=partition_rbound_datum_cmp(key->partsupfunc,
3045+
key->partcollation,
30263046
boundinfo->datums[mid],
30273047
boundinfo->kind[mid],
30283048
values,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp