@@ -220,14 +220,12 @@ find_or_create_range_partition(PG_FUNCTION_ARGS)
220
220
search_rangerel_result search_state ;
221
221
222
222
prel = get_pathman_relation_info (parent_oid );
223
-
224
- if (!prel )
225
- PG_RETURN_NULL ();
223
+ shout_if_prel_is_invalid (parent_oid ,prel ,PT_RANGE );
226
224
227
225
fill_type_cmp_fmgr_info (& cmp_func ,value_type ,prel -> atttype );
228
226
229
- /*FIXME: does this function even work? */
230
- search_state = search_range_partition_eq (value ,& cmp_func ,prel ,
227
+ /*Use available PartRelationInfo to find partition */
228
+ search_state = search_range_partition_eq (value ,& cmp_func ,prel ,
231
229
& found_rentry );
232
230
233
231
/*
@@ -286,9 +284,7 @@ get_range_by_part_oid(PG_FUNCTION_ARGS)
286
284
const PartRelationInfo * prel ;
287
285
288
286
prel = get_pathman_relation_info (parent_oid );
289
- if (!prel )
290
- elog (ERROR ,"Relation \"%s\" is not partitioned by pg_pathman" ,
291
- get_rel_name_or_relid (parent_oid ));
287
+ shout_if_prel_is_invalid (parent_oid ,prel ,PT_RANGE );
292
288
293
289
ranges = PrelGetRangesArray (prel );
294
290
@@ -306,6 +302,7 @@ get_range_by_part_oid(PG_FUNCTION_ARGS)
306
302
PG_RETURN_ARRAYTYPE_P (arr );
307
303
}
308
304
305
+ /* No partition found, report error */
309
306
elog (ERROR ,"Relation \"%s\" has no partition \"%s\"" ,
310
307
get_rel_name_or_relid (parent_oid ),
311
308
get_rel_name_or_relid (child_oid ));
@@ -330,9 +327,7 @@ get_range_by_idx(PG_FUNCTION_ARGS)
330
327
const PartRelationInfo * prel ;
331
328
332
329
prel = get_pathman_relation_info (parent_oid );
333
- if (!prel )
334
- elog (ERROR ,"Relation \"%s\" is not partitioned by pg_pathman" ,
335
- get_rel_name_or_relid (parent_oid ));
330
+ shout_if_prel_is_invalid (parent_oid ,prel ,PT_RANGE );
336
331
337
332
if (((uint32 )abs (idx )) >=PrelChildrenCount (prel ))
338
333
elog (ERROR ,"Partition #%d does not exist (total amount is %u)" ,
@@ -366,14 +361,7 @@ get_min_range_value(PG_FUNCTION_ARGS)
366
361
const PartRelationInfo * prel ;
367
362
368
363
prel = get_pathman_relation_info (parent_oid );
369
- if (!prel )
370
- elog (ERROR ,"Relation \"%s\" is not partitioned by pg_pathman" ,
371
- get_rel_name_or_relid (parent_oid ));
372
-
373
- if (prel -> parttype != PT_RANGE )
374
- if (!prel )
375
- elog (ERROR ,"Relation \"%s\" is not partitioned by RANGE" ,
376
- get_rel_name_or_relid (parent_oid ));
364
+ shout_if_prel_is_invalid (parent_oid ,prel ,PT_RANGE );
377
365
378
366
ranges = PrelGetRangesArray (prel );
379
367
@@ -391,14 +379,7 @@ get_max_range_value(PG_FUNCTION_ARGS)
391
379
const PartRelationInfo * prel ;
392
380
393
381
prel = get_pathman_relation_info (parent_oid );
394
- if (!prel )
395
- elog (ERROR ,"Relation \"%s\" is not partitioned by pg_pathman" ,
396
- get_rel_name_or_relid (parent_oid ));
397
-
398
- if (prel -> parttype != PT_RANGE )
399
- if (!prel )
400
- elog (ERROR ,"Relation \"%s\" is not partitioned by RANGE" ,
401
- get_rel_name_or_relid (parent_oid ));
382
+ shout_if_prel_is_invalid (parent_oid ,prel ,PT_RANGE );
402
383
403
384
ranges = PrelGetRangesArray (prel );
404
385
@@ -428,14 +409,7 @@ check_overlap(PG_FUNCTION_ARGS)
428
409
const PartRelationInfo * prel ;
429
410
430
411
prel = get_pathman_relation_info (parent_oid );
431
- if (!prel )
432
- elog (ERROR ,"Relation \"%s\" is not partitioned by pg_pathman" ,
433
- get_rel_name_or_relid (parent_oid ));
434
-
435
- if (prel -> parttype != PT_RANGE )
436
- if (!prel )
437
- elog (ERROR ,"Relation \"%s\" is not partitioned by RANGE" ,
438
- get_rel_name_or_relid (parent_oid ));
412
+ shout_if_prel_is_invalid (parent_oid ,prel ,PT_RANGE );
439
413
440
414
/* comparison functions */
441
415
fill_type_cmp_fmgr_info (& cmp_func_1 ,p1_type ,prel -> atttype );