diff options
| author | Michael Paquier | 2024-07-04 00:48:40 +0000 |
|---|---|---|
| committer | Michael Paquier | 2024-07-04 00:48:40 +0000 |
| commit | b81a71aa05f294705e1b1d4fe24548f175f9bfe9 (patch) | |
| tree | 8d1c94fdfd570891b7b2e5b7f079eaf252e018b8 /src/backend/commands/tablecmds.c | |
| parent | 6897f0ec024582a570868939d3f34a6853374723 (diff) | |
Assign error codes where missing for user-facing failures
All the errors triggered in the code paths patched here would cause the
backend to issue an internal_error errcode, which is a state that should
be used only for "can't happen" situations. However, these code paths
are reachable by the regression tests, and could be seen by users in
valid cases. Some regression tests expect internal errcodes as they
manipulate the backend state to cause corruption (like checksums), or
use elog() because it is more convenient (like injection points), these
have no need to change.
This reduces the number of internal failures triggered in a check-world
by more than half, while providing correct errcodes for these valid
cases.
Reviewed-by: Robert Haas
Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/backend/commands/tablecmds.c')
| -rw-r--r-- | src/backend/commands/tablecmds.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 9e9dc5c2c13..dbfe0d6b1c1 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -11363,7 +11363,8 @@ ATExecAlterConstraint(Relation rel, AlterTableCmd *cmd, bool recurse, } ereport(ERROR, - (errmsg("cannot alter constraint \"%s\" on relation \"%s\"", + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("cannot alter constraint \"%s\" on relation \"%s\"", cmdcon->conname, RelationGetRelationName(rel)), ancestorname && ancestortable ? errdetail("Constraint \"%s\" is derived from constraint \"%s\" of relation \"%s\".", |
