Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitedc7a1f

Browse files
committed
replace check_relation_exists() with syscache search
1 parent453eb27 commitedc7a1f

File tree

3 files changed

+9
-23
lines changed

3 files changed

+9
-23
lines changed

‎src/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ read_pathman_config(void)
766766
relid=DatumGetObjectId(values[Anum_pathman_config_partrel-1]);
767767

768768
/* Check that relation 'relid' exists */
769-
if (get_rel_type_id(relid)==InvalidOid)
769+
if (!SearchSysCacheExists1(RELOID,ObjectIdGetDatum(relid)))
770770
{
771771
DisablePathman();/* disable pg_pathman since config is broken */
772772
ereport(ERROR,

‎src/pl_funcs.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,6 @@ static void pathman_update_trigger_func_move_tuple(Relation source_rel,
105105
HeapTupleold_tuple,
106106
HeapTuplenew_tuple);
107107

108-
/* Extracted common check */
109-
staticinlinebool
110-
check_relation_exists(Oidrelid)
111-
{
112-
returnget_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
constchar*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
Oidrelid=PG_GETARG_OID(0);
639632
constchar*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

833826
pathman_config_params_trigger_func_return:
@@ -1383,7 +1376,7 @@ has_update_trigger(PG_FUNCTION_ARGS)
13831376
Oidparent_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

‎src/pl_range_funcs.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,6 @@ static bool interval_is_trivial(Oid atttype,
7070
Datuminterval,
7171
Oidinterval_type);
7272

73-
/* Extracted common check */
74-
staticinlinebool
75-
check_relation_exists(Oidrelid)
76-
{
77-
returnget_rel_type_id(relid)!=InvalidOid;
78-
}
79-
8073

8174
/*
8275
* -----------------------------
@@ -580,7 +573,7 @@ build_sequence_name(PG_FUNCTION_ARGS)
580573
Oidparent_nsp;
581574
char*result;
582575

583-
if (!check_relation_exists(parent_relid))
576+
if (!SearchSysCacheExists1(RELOID,ObjectIdGetDatum(parent_relid)))
584577
ereport(ERROR, (errmsg("relation \"%u\" does not exist",parent_relid)));
585578

586579
parent_nsp=get_rel_namespace(parent_relid);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp