@@ -76,8 +76,8 @@ static void copy_foreign_keys(Oid parent_relid, Oid partition_oid);
76
76
/* Create one RANGE partition [start_value, end_value) */
77
77
Oid
78
78
create_single_range_partition_internal (Oid parent_relid ,
79
- const Infinitable * start_value ,
80
- const Infinitable * end_value ,
79
+ const Bound * start_value ,
80
+ const Bound * end_value ,
81
81
Oid value_type ,
82
82
RangeVar * partition_rv ,
83
83
char * tablespace )
@@ -276,8 +276,8 @@ create_partitions_for_value_internal(Oid relid, Datum value, Oid value_type)
276
276
/* TODO */
277
277
// bound_min = PrelGetRangesArray(prel)[0].min;
278
278
// bound_max = PrelGetRangesArray(prel)[PrelLastChild(prel)].max;
279
- bound_min = InfinitableGetValue (& ranges [0 ].min );
280
- bound_max = InfinitableGetValue (& ranges [PrelLastChild (prel )].max );
279
+ bound_min = BoundGetValue (& ranges [0 ].min );
280
+ bound_max = BoundGetValue (& ranges [PrelLastChild (prel )].max );
281
281
282
282
/* Copy datums on order to protect them from cache invalidation */
283
283
bound_min = datumCopy (bound_min , prel -> attbyval , prel -> attlen );
@@ -501,7 +501,7 @@ spawn_partitions_val(Oid parent_relid, /* parent's Oid */
501
501
check_lt (& cmp_value_bound_finfo , value , cur_leading_bound ))
502
502
{
503
503
Datum args [2 ];
504
- Infinitable bounds [2 ];
504
+ Bound bounds [2 ];
505
505
506
506
/* Assign the 'following' boundary to current 'leading' value */
507
507
cur_following_bound = cur_leading_bound ;
@@ -514,8 +514,8 @@ spawn_partitions_val(Oid parent_relid, /* parent's Oid */
514
514
args [0 ] = should_append ? cur_following_bound : cur_leading_bound ;
515
515
args [1 ] = should_append ? cur_leading_bound : cur_following_bound ;
516
516
517
- MakeInfinitable (& bounds [0 ], args [0 ], false );
518
- MakeInfinitable (& bounds [1 ], args [1 ], false );
517
+ MakeBound (& bounds [0 ], args [0 ], FINITE );
518
+ MakeBound (& bounds [1 ], args [1 ], FINITE );
519
519
520
520
last_partition = create_single_range_partition_internal (parent_relid ,
521
521
& bounds [0 ], & bounds [1 ],
@@ -781,8 +781,8 @@ copy_foreign_keys(Oid parent_relid, Oid partition_oid)
781
781
/* Build RANGE check constraint expression tree */
782
782
Node *
783
783
build_raw_range_check_tree (char * attname ,
784
- const Infinitable * start_value ,
785
- const Infinitable * end_value ,
784
+ const Bound * start_value ,
785
+ const Bound * end_value ,
786
786
Oid value_type )
787
787
{
788
788
BoolExpr * and_oper = makeNode (BoolExpr );
@@ -805,7 +805,7 @@ build_raw_range_check_tree(char *attname,
805
805
{
806
806
/* Left boundary */
807
807
left_const -> val = * makeString (
808
- datum_to_cstring (InfinitableGetValue (start_value ), value_type ));
808
+ datum_to_cstring (BoundGetValue (start_value ), value_type ));
809
809
left_const -> location = -1 ;
810
810
811
811
left_arg -> name = list_make1 (makeString (">=" ));
@@ -821,7 +821,7 @@ build_raw_range_check_tree(char *attname,
821
821
{
822
822
/* Right boundary */
823
823
right_const -> val = * makeString (
824
- datum_to_cstring (InfinitableGetValue (end_value ), value_type ));
824
+ datum_to_cstring (BoundGetValue (end_value ), value_type ));
825
825
right_const -> location = -1 ;
826
826
827
827
right_arg -> name = list_make1 (makeString ("<" ));
@@ -842,8 +842,8 @@ build_raw_range_check_tree(char *attname,
842
842
Constraint *
843
843
build_range_check_constraint (Oid child_relid ,
844
844
char * attname ,
845
- const Infinitable * start_value ,
846
- const Infinitable * end_value ,
845
+ const Bound * start_value ,
846
+ const Bound * end_value ,
847
847
Oid value_type )
848
848
{
849
849
Constraint * range_constr ;
@@ -879,8 +879,8 @@ build_range_check_constraint(Oid child_relid,
879
879
/* Check if range overlaps with any partitions */
880
880
bool
881
881
check_range_available (Oid parent_relid ,
882
- const Infinitable * start_value ,
883
- const Infinitable * end_value ,
882
+ const Bound * start ,
883
+ const Bound * end ,
884
884
Oid value_type ,
885
885
bool raise_error )
886
886
{
@@ -913,30 +913,32 @@ check_range_available(Oid parent_relid,
913
913
* range ends in plus infinity then the left boundary of the first
914
914
* range is on the left. Otherwise compare specific values
915
915
*/
916
- c1 = (IsInfinite (start_value ) || IsInfinite (& ranges [i ].max )) ?
917
- -1 :
918
- FunctionCall2 (& cmp_func ,
919
- InfinitableGetValue ( start_value ),
920
- InfinitableGetValue (& ranges [i ].max ));
916
+ // c1 = (IsInfinite(start ) || IsInfinite(&ranges[i].max)) ?
917
+ // -1 :
918
+ // FunctionCall2(&cmp_func,
919
+ // BoundGetValue(start ),
920
+ // BoundGetValue (&ranges[i].max));
921
921
/*
922
922
* Similary check that right boundary of the range we're checking is on
923
923
* the right of the beginning of the current one
924
924
*/
925
- c2 = (IsInfinite (end_value ) || IsInfinite (& ranges [i ].min )) ?
926
- 1 :
927
- FunctionCall2 (& cmp_func ,
928
- InfinitableGetValue (end_value ),
929
- InfinitableGetValue (& ranges [i ].min ));
925
+ // c2 = (IsInfinite(end) || IsInfinite(&ranges[i].min)) ?
926
+ // 1 :
927
+ // FunctionCall2(&cmp_func,
928
+ // BoundGetValue(end),
929
+ // BoundGetValue(&ranges[i].min));
930
+
931
+ c1 = cmp_bounds (& cmp_func , start , & ranges [i ].max );
932
+ c2 = cmp_bounds (& cmp_func , end , & ranges [i ].min );
930
933
931
934
/* There's someone! */
932
935
if (c1 < 0 && c2 > 0 )
933
936
{
934
937
if (raise_error )
935
- /* TODO: print infinity */
936
938
elog (ERROR , "specified range [%s, %s) overlaps "
937
939
"with existing partitions" ,
938
- datum_to_cstring (InfinitableGetValue ( start_value ), value_type ),
939
- datum_to_cstring (InfinitableGetValue ( end_value ), value_type ));
940
+ ! IsInfinite ( start ) ? datum_to_cstring (BoundGetValue ( start ), value_type ) : "NULL" ,
941
+ ! IsInfinite ( end ) ? datum_to_cstring (BoundGetValue ( end ), value_type ) : "NULL" );
940
942
else
941
943
return false;
942
944
}
@@ -1002,8 +1004,8 @@ invoke_init_callback_internal(init_callback_params *cb_params)
1002
1004
{
1003
1005
char * start_value ,
1004
1006
* end_value ;
1005
- Infinitable sv_datum = cb_params -> params .range_params .start_value ,
1006
- ev_datum = cb_params -> params .range_params .end_value ;
1007
+ Bound sv_datum = cb_params -> params .range_params .start_value ,
1008
+ ev_datum = cb_params -> params .range_params .end_value ;
1007
1009
Oid type = cb_params -> params .range_params .value_type ;
1008
1010
1009
1011
/* Convert min & max to CSTRING */
@@ -1023,7 +1025,7 @@ invoke_init_callback_internal(init_callback_params *cb_params)
1023
1025
JSB_INIT_VAL (& key , WJB_KEY , "range_min" );
1024
1026
if (!IsInfinite (& sv_datum ))
1025
1027
{
1026
- start_value = datum_to_cstring (InfinitableGetValue (& sv_datum ), type );
1028
+ start_value = datum_to_cstring (BoundGetValue (& sv_datum ), type );
1027
1029
JSB_INIT_VAL (& val , WJB_VALUE , start_value );
1028
1030
}
1029
1031
else
@@ -1033,7 +1035,7 @@ invoke_init_callback_internal(init_callback_params *cb_params)
1033
1035
JSB_INIT_VAL (& key , WJB_KEY , "range_max" );
1034
1036
if (!IsInfinite (& ev_datum ))
1035
1037
{
1036
- end_value = datum_to_cstring (InfinitableGetValue (& ev_datum ), type );
1038
+ end_value = datum_to_cstring (BoundGetValue (& ev_datum ), type );
1037
1039
JSB_INIT_VAL (& val , WJB_VALUE , end_value );
1038
1040
}
1039
1041
else
0 commit comments