@@ -180,14 +180,12 @@ find_or_create_range_partition(PG_FUNCTION_ARGS)
180180 search_rangerel_result search_state ;
181181
182182 prel = get_pathman_relation_info (parent_oid );
183-
184- if (!prel )
185- PG_RETURN_NULL ();
183+ shout_if_prel_is_invalid (parent_oid , prel , PT_RANGE );
186184
187185 fill_type_cmp_fmgr_info (& cmp_func , value_type , prel -> atttype );
188186
189- /* FIXME: does this function even work? */
190- search_state = search_range_partition_eq (value , & cmp_func ,prel ,
187+ /* Use available PartRelationInfo to find partition */
188+ search_state = search_range_partition_eq (value , & cmp_func , prel ,
191189 & found_rentry );
192190
193191 /*
@@ -246,9 +244,7 @@ get_range_by_part_oid(PG_FUNCTION_ARGS)
246244 const PartRelationInfo * prel ;
247245
248246 prel = get_pathman_relation_info (parent_oid );
249- if (!prel )
250- elog (ERROR , "Relation \"%s\" is not partitioned by pg_pathman" ,
251- get_rel_name_or_relid (parent_oid ));
247+ shout_if_prel_is_invalid (parent_oid , prel , PT_RANGE );
252248
253249 ranges = PrelGetRangesArray (prel );
254250
@@ -266,6 +262,7 @@ get_range_by_part_oid(PG_FUNCTION_ARGS)
266262 PG_RETURN_ARRAYTYPE_P (arr );
267263 }
268264
265+ /* No partition found, report error */
269266 elog (ERROR , "Relation \"%s\" has no partition \"%s\"" ,
270267 get_rel_name_or_relid (parent_oid ),
271268 get_rel_name_or_relid (child_oid ));
@@ -290,9 +287,7 @@ get_range_by_idx(PG_FUNCTION_ARGS)
290287 const PartRelationInfo * prel ;
291288
292289 prel = get_pathman_relation_info (parent_oid );
293- if (!prel )
294- elog (ERROR , "Relation \"%s\" is not partitioned by pg_pathman" ,
295- get_rel_name_or_relid (parent_oid ));
290+ shout_if_prel_is_invalid (parent_oid , prel , PT_RANGE );
296291
297292 if (((uint32 ) abs (idx )) >= PrelChildrenCount (prel ))
298293 elog (ERROR , "Partition #%d does not exist (total amount is %u)" ,
@@ -326,14 +321,7 @@ get_min_range_value(PG_FUNCTION_ARGS)
326321 const PartRelationInfo * prel ;
327322
328323 prel = get_pathman_relation_info (parent_oid );
329- if (!prel )
330- elog (ERROR , "Relation \"%s\" is not partitioned by pg_pathman" ,
331- get_rel_name_or_relid (parent_oid ));
332-
333- if (prel -> parttype != PT_RANGE )
334- if (!prel )
335- elog (ERROR , "Relation \"%s\" is not partitioned by RANGE" ,
336- get_rel_name_or_relid (parent_oid ));
324+ shout_if_prel_is_invalid (parent_oid , prel , PT_RANGE );
337325
338326 ranges = PrelGetRangesArray (prel );
339327
@@ -351,14 +339,7 @@ get_max_range_value(PG_FUNCTION_ARGS)
351339 const PartRelationInfo * prel ;
352340
353341 prel = get_pathman_relation_info (parent_oid );
354- if (!prel )
355- elog (ERROR , "Relation \"%s\" is not partitioned by pg_pathman" ,
356- get_rel_name_or_relid (parent_oid ));
357-
358- if (prel -> parttype != PT_RANGE )
359- if (!prel )
360- elog (ERROR , "Relation \"%s\" is not partitioned by RANGE" ,
361- get_rel_name_or_relid (parent_oid ));
342+ shout_if_prel_is_invalid (parent_oid , prel , PT_RANGE );
362343
363344 ranges = PrelGetRangesArray (prel );
364345
@@ -388,14 +369,7 @@ check_overlap(PG_FUNCTION_ARGS)
388369 const PartRelationInfo * prel ;
389370
390371 prel = get_pathman_relation_info (parent_oid );
391- if (!prel )
392- elog (ERROR , "Relation \"%s\" is not partitioned by pg_pathman" ,
393- get_rel_name_or_relid (parent_oid ));
394-
395- if (prel -> parttype != PT_RANGE )
396- if (!prel )
397- elog (ERROR , "Relation \"%s\" is not partitioned by RANGE" ,
398- get_rel_name_or_relid (parent_oid ));
372+ shout_if_prel_is_invalid (parent_oid , prel , PT_RANGE );
399373
400374 /* comparison functions */
401375 fill_type_cmp_fmgr_info (& cmp_func_1 , p1_type , prel -> atttype );
0 commit comments