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