aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-08-02 23:49:19 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2015-08-02 23:49:19 -0400
commit89e80b03297555277473fc3978b83c68ec9847b8 (patch)
tree3d83744f8f80cc85eb31864340760df7029f6e3b /src/backend/executor
parentc75b1f75b3d159c0e71c1ec7f42c922bce448d89 (diff)
downloadpostgresql-89e80b03297555277473fc3978b83c68ec9847b8.tar.gz
postgresql-89e80b03297555277473fc3978b83c68ec9847b8.zip
Fix a number of places that produced XX000 errors in the regression tests.
It's against project policy to use elog() for user-facing errors, or to omit an errcode() selection for errors that aren't supposed to be "can't happen" cases. Fix all the violations of this policy that result in ERRCODE_INTERNAL_ERROR log entries during the standard regression tests, as errors that can reliably be triggered from SQL surely should be considered user-facing. I also looked through all the files touched by this commit and fixed other nearby problems of the same ilk. I do not claim to have fixed all violations of the policy, just the ones in these files. In a few places I also changed existing ERRCODE choices that didn't seem particularly appropriate; mainly replacing ERRCODE_SYNTAX_ERROR by something more specific. Back-patch to 9.5, but no further; changing ERRCODE assignments in stable branches doesn't seem like a good idea.
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/execQual.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c
index 0f911f210bf..16bc8fa5f6c 100644
--- a/src/backend/executor/execQual.c
+++ b/src/backend/executor/execQual.c
@@ -631,7 +631,8 @@ ExecEvalScalarVar(ExprState *exprstate, ExprContext *econtext,
{
if (variable->vartype != attr->atttypid)
ereport(ERROR,
- (errmsg("attribute %d has wrong type", attnum),
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
+ errmsg("attribute %d has wrong type", attnum),
errdetail("Table has type %s, but query expects %s.",
format_type_be(attr->atttypid),
format_type_be(variable->vartype))));
@@ -4111,7 +4112,8 @@ ExecEvalFieldSelect(FieldSelectState *fstate,
/* As in ExecEvalScalarVar, we should but can't check typmod */
if (fselect->resulttype != attr->atttypid)
ereport(ERROR,
- (errmsg("attribute %d has wrong type", fieldnum),
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
+ errmsg("attribute %d has wrong type", fieldnum),
errdetail("Table has type %s, but query expects %s.",
format_type_be(attr->atttypid),
format_type_be(fselect->resulttype))));