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

Commit582bbcf

Browse files
committed
Move SPI error reporting out of ri_ReportViolation()
These are two completely unrelated code paths, so it doesn't make senseto pack them into one function.Add attribute noreturn to ri_ReportViolation().Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
1 parent9eafa2b commit582bbcf

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

‎src/backend/utils/adt/ri_triggers.c

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ static void ri_ExtractValues(Relation rel, HeapTuple tup,
242242
staticvoidri_ReportViolation(constRI_ConstraintInfo*riinfo,
243243
Relationpk_rel,Relationfk_rel,
244244
HeapTupleviolator,TupleDesctupdesc,
245-
intqueryno,boolspi_err);
245+
intqueryno)pg_attribute_noreturn();
246246

247247

248248
/* ----------
@@ -2499,7 +2499,7 @@ RI_Initial_Check(Trigger *trigger, Relation fk_rel, Relation pk_rel)
24992499
ri_ReportViolation(&fake_riinfo,
25002500
pk_rel,fk_rel,
25012501
tuple,tupdesc,
2502-
RI_PLAN_CHECK_LOOKUPPK, false);
2502+
RI_PLAN_CHECK_LOOKUPPK);
25032503
}
25042504

25052505
if (SPI_finish()!=SPI_OK_FINISH)
@@ -3147,11 +3147,13 @@ ri_PerformCheck(const RI_ConstraintInfo *riinfo,
31473147
elog(ERROR,"SPI_execute_snapshot returned %d",spi_result);
31483148

31493149
if (expect_OK >=0&&spi_result!=expect_OK)
3150-
ri_ReportViolation(riinfo,
3151-
pk_rel,fk_rel,
3152-
new_tuple ?new_tuple :old_tuple,
3153-
NULL,
3154-
qkey->constr_queryno, true);
3150+
ereport(ERROR,
3151+
(errcode(ERRCODE_INTERNAL_ERROR),
3152+
errmsg("referential integrity query on \"%s\" from constraint \"%s\" on \"%s\" gave unexpected result",
3153+
RelationGetRelationName(pk_rel),
3154+
NameStr(riinfo->conname),
3155+
RelationGetRelationName(fk_rel)),
3156+
errhint("This is most likely due to a rule having rewritten the query.")));
31553157

31563158
/* XXX wouldn't it be clearer to do this part at the caller? */
31573159
if (qkey->constr_queryno!=RI_PLAN_CHECK_LOOKUPPK_FROM_PK&&
@@ -3161,7 +3163,7 @@ ri_PerformCheck(const RI_ConstraintInfo *riinfo,
31613163
pk_rel,fk_rel,
31623164
new_tuple ?new_tuple :old_tuple,
31633165
NULL,
3164-
qkey->constr_queryno, false);
3166+
qkey->constr_queryno);
31653167

31663168
returnSPI_processed!=0;
31673169
}
@@ -3205,7 +3207,7 @@ static void
32053207
ri_ReportViolation(constRI_ConstraintInfo*riinfo,
32063208
Relationpk_rel,Relationfk_rel,
32073209
HeapTupleviolator,TupleDesctupdesc,
3208-
intqueryno,boolspi_err)
3210+
intqueryno)
32093211
{
32103212
StringInfoDatakey_names;
32113213
StringInfoDatakey_values;
@@ -3216,15 +3218,6 @@ ri_ReportViolation(const RI_ConstraintInfo *riinfo,
32163218
AclResultaclresult;
32173219
boolhas_perm= true;
32183220

3219-
if (spi_err)
3220-
ereport(ERROR,
3221-
(errcode(ERRCODE_INTERNAL_ERROR),
3222-
errmsg("referential integrity query on \"%s\" from constraint \"%s\" on \"%s\" gave unexpected result",
3223-
RelationGetRelationName(pk_rel),
3224-
NameStr(riinfo->conname),
3225-
RelationGetRelationName(fk_rel)),
3226-
errhint("This is most likely due to a rule having rewritten the query.")));
3227-
32283221
/*
32293222
* Determine which relation to complain about. If tupdesc wasn't passed
32303223
* by caller, assume the violator tuple came from there.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp