@@ -105,13 +105,6 @@ static void pathman_update_trigger_func_move_tuple(Relation source_rel,
105
105
HeapTuple old_tuple ,
106
106
HeapTuple new_tuple );
107
107
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
-
115
108
116
109
/*
117
110
* ------------------------
@@ -538,7 +531,7 @@ validate_relname(PG_FUNCTION_ARGS)
538
531
/* Fetch relation's Oid */
539
532
relid = PG_GETARG_OID (0 );
540
533
541
- if (!check_relation_exists ( relid ))
534
+ if (!SearchSysCacheExists1 ( RELOID , ObjectIdGetDatum ( relid ) ))
542
535
ereport (ERROR , (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
543
536
errmsg ("relation \"%u\" does not exist" , relid ),
544
537
errdetail ("triggered in function "
@@ -600,7 +593,7 @@ build_update_trigger_name(PG_FUNCTION_ARGS)
600
593
const char * result ;
601
594
602
595
/* Check that relation exists */
603
- if (!check_relation_exists ( relid ))
596
+ if (!SearchSysCacheExists1 ( RELOID , ObjectIdGetDatum ( relid ) ))
604
597
ereport (ERROR , (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
605
598
errmsg ("relation \"%u\" does not exist" , relid )));
606
599
@@ -618,7 +611,7 @@ build_update_trigger_func_name(PG_FUNCTION_ARGS)
618
611
* func_name ;
619
612
620
613
/* Check that relation exists */
621
- if (!check_relation_exists ( relid ))
614
+ if (!SearchSysCacheExists1 ( RELOID , ObjectIdGetDatum ( relid ) ))
622
615
ereport (ERROR , (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
623
616
errmsg ("relation \"%u\" does not exist" , relid )));
624
617
@@ -638,7 +631,7 @@ build_check_constraint_name(PG_FUNCTION_ARGS)
638
631
Oid relid = PG_GETARG_OID (0 );
639
632
const char * result ;
640
633
641
- if (!check_relation_exists ( relid ))
634
+ if (!SearchSysCacheExists1 ( RELOID , ObjectIdGetDatum ( relid ) ))
642
635
ereport (ERROR , (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
643
636
errmsg ("relation \"%u\" does not exist" , relid )));
644
637
@@ -681,7 +674,7 @@ add_to_pathman_config(PG_FUNCTION_ARGS)
681
674
errmsg ("'parent_relid' should not be NULL" )));
682
675
683
676
/* Check that relation exists */
684
- if (!check_relation_exists ( relid ))
677
+ if (!SearchSysCacheExists1 ( RELOID , ObjectIdGetDatum ( relid ) ))
685
678
ereport (ERROR , (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
686
679
errmsg ("relation \"%u\" does not exist" , relid )));
687
680
@@ -827,7 +820,7 @@ pathman_config_params_trigger_func(PG_FUNCTION_ARGS)
827
820
partrel = DatumGetObjectId (partrel_datum );
828
821
829
822
/* Finally trigger pg_pathman's cache invalidation event */
830
- if (check_relation_exists ( partrel ))
823
+ if (SearchSysCacheExists1 ( RELOID , ObjectIdGetDatum ( partrel ) ))
831
824
CacheInvalidateRelcacheByRelid (partrel );
832
825
833
826
pathman_config_params_trigger_func_return :
@@ -1383,7 +1376,7 @@ has_update_trigger(PG_FUNCTION_ARGS)
1383
1376
Oid parent_relid = PG_GETARG_OID (0 );
1384
1377
1385
1378
/* Check that relation exists */
1386
- if (!check_relation_exists ( parent_relid ))
1379
+ if (!SearchSysCacheExists1 ( RELOID , ObjectIdGetDatum ( parent_relid ) ))
1387
1380
ereport (ERROR , (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
1388
1381
errmsg ("relation \"%u\" does not exist" , parent_relid )));
1389
1382
0 commit comments