@@ -220,14 +220,12 @@ find_or_create_range_partition(PG_FUNCTION_ARGS)
220220search_rangerel_result search_state ;
221221
222222prel = 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 );
226224
227225fill_type_cmp_fmgr_info (& cmp_func ,value_type ,prel -> atttype );
228226
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 ,
231229& found_rentry );
232230
233231/*
@@ -286,9 +284,7 @@ get_range_by_part_oid(PG_FUNCTION_ARGS)
286284const PartRelationInfo * prel ;
287285
288286prel = 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 );
292288
293289ranges = PrelGetRangesArray (prel );
294290
@@ -306,6 +302,7 @@ get_range_by_part_oid(PG_FUNCTION_ARGS)
306302PG_RETURN_ARRAYTYPE_P (arr );
307303}
308304
305+ /* No partition found, report error */
309306elog (ERROR ,"Relation \"%s\" has no partition \"%s\"" ,
310307get_rel_name_or_relid (parent_oid ),
311308get_rel_name_or_relid (child_oid ));
@@ -330,9 +327,7 @@ get_range_by_idx(PG_FUNCTION_ARGS)
330327const PartRelationInfo * prel ;
331328
332329prel = 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 );
336331
337332if (((uint32 )abs (idx )) >=PrelChildrenCount (prel ))
338333elog (ERROR ,"Partition #%d does not exist (total amount is %u)" ,
@@ -366,14 +361,7 @@ get_min_range_value(PG_FUNCTION_ARGS)
366361const PartRelationInfo * prel ;
367362
368363prel = 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 );
377365
378366ranges = PrelGetRangesArray (prel );
379367
@@ -391,14 +379,7 @@ get_max_range_value(PG_FUNCTION_ARGS)
391379const PartRelationInfo * prel ;
392380
393381prel = 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 );
402383
403384ranges = PrelGetRangesArray (prel );
404385
@@ -428,14 +409,7 @@ check_overlap(PG_FUNCTION_ARGS)
428409const PartRelationInfo * prel ;
429410
430411prel = 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 );
439413
440414/* comparison functions */
441415fill_type_cmp_fmgr_info (& cmp_func_1 ,p1_type ,prel -> atttype );