@@ -5211,7 +5211,7 @@ check_partition_bounds_for_split_range(Relation parent,
5211
5211
if (first || last )
5212
5212
{
5213
5213
PartitionBoundSpec * split_spec = get_partition_bound_spec (splitPartOid , splitPartName );
5214
- bool overlap = false ;
5214
+ PartitionRangeDatum * datum ;
5215
5215
5216
5216
if (first )
5217
5217
{
@@ -5229,8 +5229,30 @@ check_partition_bounds_for_split_range(Relation parent,
5229
5229
* Lower bound of "spec" should be equal (or greater than or equal
5230
5230
* in case defaultPart=true) to lower bound of split partition.
5231
5231
*/
5232
- if ((!defaultPart && cmpval ) || (defaultPart && cmpval < 0 ))
5233
- overlap = true;
5232
+ if (!defaultPart )
5233
+ {
5234
+ if (cmpval != 0 )
5235
+ {
5236
+ datum = list_nth (spec -> lowerdatums , abs (cmpval ) - 1 );
5237
+ ereport (ERROR ,
5238
+ (errcode (ERRCODE_INVALID_OBJECT_DEFINITION ),
5239
+ errmsg ("lower bound of partition \"%s\" is not equal to lower bound of split partition" ,
5240
+ relname ),
5241
+ parser_errposition (pstate , datum -> location )));
5242
+ }
5243
+ }
5244
+ else
5245
+ {
5246
+ if (cmpval < 0 )
5247
+ {
5248
+ datum = list_nth (spec -> lowerdatums , abs (cmpval ) - 1 );
5249
+ ereport (ERROR ,
5250
+ (errcode (ERRCODE_INVALID_OBJECT_DEFINITION ),
5251
+ errmsg ("lower bound of partition \"%s\" is less than lower bound of split partition" ,
5252
+ relname ),
5253
+ parser_errposition (pstate , datum -> location )));
5254
+ }
5255
+ }
5234
5256
}
5235
5257
else
5236
5258
{
@@ -5248,24 +5270,30 @@ check_partition_bounds_for_split_range(Relation parent,
5248
5270
* Upper bound of "spec" should be equal (or less than or equal in
5249
5271
* case defaultPart=true) to upper bound of split partition.
5250
5272
*/
5251
- if ((!defaultPart && cmpval ) || (defaultPart && cmpval > 0 ))
5252
- overlap = true;
5253
- }
5254
-
5255
- if (overlap )
5256
- {
5257
- PartitionRangeDatum * datum ;
5258
-
5259
- datum = list_nth (first ? spec -> lowerdatums : spec -> upperdatums , abs (cmpval ) - 1 );
5260
-
5261
- ereport (ERROR ,
5262
- (errcode (ERRCODE_INVALID_OBJECT_DEFINITION ),
5263
- errmsg ("%s bound of partition \"%s\" is %s %s bound of split partition" ,
5264
- first ? "lower" : "upper" ,
5265
- relname ,
5266
- defaultPart ? (first ? "less than" : "greater than" ) : "not equal to" ,
5267
- first ? "lower" : "upper" ),
5268
- parser_errposition (pstate , datum -> location )));
5273
+ if (!defaultPart )
5274
+ {
5275
+ if (cmpval != 0 )
5276
+ {
5277
+ datum = list_nth (spec -> upperdatums , abs (cmpval ) - 1 );
5278
+ ereport (ERROR ,
5279
+ (errcode (ERRCODE_INVALID_OBJECT_DEFINITION ),
5280
+ errmsg ("upper bound of partition \"%s\" is not equal to upper bound of split partition" ,
5281
+ relname ),
5282
+ parser_errposition (pstate , datum -> location )));
5283
+ }
5284
+ }
5285
+ else
5286
+ {
5287
+ if (cmpval > 0 )
5288
+ {
5289
+ datum = list_nth (spec -> upperdatums , abs (cmpval ) - 1 );
5290
+ ereport (ERROR ,
5291
+ (errcode (ERRCODE_INVALID_OBJECT_DEFINITION ),
5292
+ errmsg ("upper bound of partition \"%s\" is greater than upper bound of split partition" ,
5293
+ relname ),
5294
+ parser_errposition (pstate , datum -> location )));
5295
+ }
5296
+ }
5269
5297
}
5270
5298
}
5271
5299
}
0 commit comments