@@ -105,13 +105,6 @@ static void pathman_update_trigger_func_move_tuple(Relation source_rel,
105105 HeapTuple old_tuple ,
106106 HeapTuple new_tuple );
107107
108- /* Extracted common check */
109- static inline bool
110- check_relation_exists (Oid relid )
111- {
112- return get_rel_type_id (relid ) != InvalidOid ;
113- }
114-
115108
116109/*
117110 * ------------------------
@@ -538,7 +531,7 @@ validate_relname(PG_FUNCTION_ARGS)
538531 /* Fetch relation's Oid */
539532 relid = PG_GETARG_OID (0 );
540533
541- if (!check_relation_exists ( relid ))
534+ if (!SearchSysCacheExists1 ( RELOID , ObjectIdGetDatum ( relid ) ))
542535 ereport (ERROR , (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
543536 errmsg ("relation \"%u\" does not exist" , relid ),
544537 errdetail ("triggered in function "
@@ -600,7 +593,7 @@ build_update_trigger_name(PG_FUNCTION_ARGS)
600593 const char * result ;
601594
602595 /* Check that relation exists */
603- if (!check_relation_exists ( relid ))
596+ if (!SearchSysCacheExists1 ( RELOID , ObjectIdGetDatum ( relid ) ))
604597 ereport (ERROR , (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
605598 errmsg ("relation \"%u\" does not exist" , relid )));
606599
@@ -618,7 +611,7 @@ build_update_trigger_func_name(PG_FUNCTION_ARGS)
618611 * func_name ;
619612
620613 /* Check that relation exists */
621- if (!check_relation_exists ( relid ))
614+ if (!SearchSysCacheExists1 ( RELOID , ObjectIdGetDatum ( relid ) ))
622615 ereport (ERROR , (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
623616 errmsg ("relation \"%u\" does not exist" , relid )));
624617
@@ -638,7 +631,7 @@ build_check_constraint_name(PG_FUNCTION_ARGS)
638631 Oid relid = PG_GETARG_OID (0 );
639632 const char * result ;
640633
641- if (!check_relation_exists ( relid ))
634+ if (!SearchSysCacheExists1 ( RELOID , ObjectIdGetDatum ( relid ) ))
642635 ereport (ERROR , (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
643636 errmsg ("relation \"%u\" does not exist" , relid )));
644637
@@ -681,7 +674,7 @@ add_to_pathman_config(PG_FUNCTION_ARGS)
681674 errmsg ("'parent_relid' should not be NULL" )));
682675
683676 /* Check that relation exists */
684- if (!check_relation_exists ( relid ))
677+ if (!SearchSysCacheExists1 ( RELOID , ObjectIdGetDatum ( relid ) ))
685678 ereport (ERROR , (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
686679 errmsg ("relation \"%u\" does not exist" , relid )));
687680
@@ -827,7 +820,7 @@ pathman_config_params_trigger_func(PG_FUNCTION_ARGS)
827820 partrel = DatumGetObjectId (partrel_datum );
828821
829822 /* Finally trigger pg_pathman's cache invalidation event */
830- if (check_relation_exists ( partrel ))
823+ if (SearchSysCacheExists1 ( RELOID , ObjectIdGetDatum ( partrel ) ))
831824 CacheInvalidateRelcacheByRelid (partrel );
832825
833826pathman_config_params_trigger_func_return :
@@ -1383,7 +1376,7 @@ has_update_trigger(PG_FUNCTION_ARGS)
13831376 Oid parent_relid = PG_GETARG_OID (0 );
13841377
13851378 /* Check that relation exists */
1386- if (!check_relation_exists ( parent_relid ))
1379+ if (!SearchSysCacheExists1 ( RELOID , ObjectIdGetDatum ( parent_relid ) ))
13871380 ereport (ERROR , (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
13881381 errmsg ("relation \"%u\" does not exist" , parent_relid )));
13891382
0 commit comments