diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index de2aff5dd1..07b52d9201 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.202 2003/07/20 21:56:32 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.203 2003/07/21 17:04:58 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1581,7 +1581,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, * Check the constraints of the tuple */ if (rel->rd_att->constr) - ExecConstraints("CopyFrom", resultRelInfo, slot, estate); + ExecConstraints(resultRelInfo, slot, estate); /* * OK, store the tuple and create index entries for it diff --git a/src/backend/executor/execAmi.c b/src/backend/executor/execAmi.c index e463b6bc70..61974827b3 100644 --- a/src/backend/executor/execAmi.c +++ b/src/backend/executor/execAmi.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.71 2003/05/27 17:49:45 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.72 2003/07/21 17:05:00 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -160,9 +160,8 @@ ExecReScan(PlanState *node, ExprContext *exprCtxt) break; default: - elog(ERROR, "ExecReScan: node type %d not supported", - nodeTag(node)); - return; + elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node)); + break; } if (node->chgParam != NULL) @@ -208,8 +207,7 @@ ExecMarkPos(PlanState *node) default: /* don't make hard error unless caller asks to restore... */ - elog(DEBUG2, "ExecMarkPos: node type %d not supported", - nodeTag(node)); + elog(DEBUG2, "unrecognized node type: %d", (int) nodeTag(node)); break; } } @@ -249,8 +247,7 @@ ExecRestrPos(PlanState *node) break; default: - elog(ERROR, "ExecRestrPos: node type %d not supported", - nodeTag(node)); + elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node)); break; } } diff --git a/src/backend/executor/execGrouping.c b/src/backend/executor/execGrouping.c index b41c75e926..3f9c6d0d47 100644 --- a/src/backend/executor/execGrouping.c +++ b/src/backend/executor/execGrouping.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execGrouping.c,v 1.3 2003/06/22 22:04:54 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execGrouping.c,v 1.4 2003/07/21 17:05:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -249,8 +249,8 @@ execTuplesHashPrepare(TupleDesc tupdesc, eq_function = oprfuncid(optup); ReleaseSysCache(optup); hash_function = get_op_hash_function(eq_opr); - if (!OidIsValid(hash_function)) - elog(ERROR, "Could not find hash function for hash operator %u", + if (!OidIsValid(hash_function)) /* should not happen */ + elog(ERROR, "could not find hash function for hash operator %u", eq_opr); fmgr_info(eq_function, &(*eqfunctions)[i]); fmgr_info(hash_function, &(*hashfunctions)[i]); diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index 8b720c110f..7f6c825380 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -26,7 +26,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.209 2003/05/08 18:16:36 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.210 2003/07/21 17:05:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -410,8 +410,8 @@ ExecCheckRTEPerms(RangeTblEntry *rte, CmdType operation) aclcheck_result = CHECK(ACL_DELETE); break; default: - elog(ERROR, "ExecCheckRTEPerms: bogus operation %d", - operation); + elog(ERROR, "unrecognized operation code: %d", + (int) operation); aclcheck_result = ACLCHECK_OK; /* keep compiler quiet */ break; } @@ -455,7 +455,9 @@ ExecCheckXactReadOnly(Query *parsetree, CmdType operation) return; fail: - elog(ERROR, "transaction is read-only"); + ereport(ERROR, + (errcode(ERRCODE_READ_ONLY_SQL_TRANSACTION), + errmsg("transaction is read-only"))); } @@ -833,16 +835,22 @@ initResultRelInfo(ResultRelInfo *resultRelInfo, switch (resultRelationDesc->rd_rel->relkind) { case RELKIND_SEQUENCE: - elog(ERROR, "You can't change sequence relation %s", - RelationGetRelationName(resultRelationDesc)); + ereport(ERROR, + (errcode(ERRCODE_WRONG_OBJECT_TYPE), + errmsg("cannot change sequence relation \"%s\"", + RelationGetRelationName(resultRelationDesc)))); break; case RELKIND_TOASTVALUE: - elog(ERROR, "You can't change toast relation %s", - RelationGetRelationName(resultRelationDesc)); + ereport(ERROR, + (errcode(ERRCODE_WRONG_OBJECT_TYPE), + errmsg("cannot change toast relation \"%s\"", + RelationGetRelationName(resultRelationDesc)))); break; case RELKIND_VIEW: - elog(ERROR, "You can't change view relation %s", - RelationGetRelationName(resultRelationDesc)); + ereport(ERROR, + (errcode(ERRCODE_WRONG_OBJECT_TYPE), + errmsg("cannot change view relation \"%s\"", + RelationGetRelationName(resultRelationDesc)))); break; } @@ -1056,11 +1064,11 @@ lnext: ; "ctid", &datum, &isNull)) - elog(ERROR, "ExecutePlan: NO (junk) `ctid' was found!"); + elog(ERROR, "could not find junk ctid column"); /* shouldn't ever get a null result... */ if (isNull) - elog(ERROR, "ExecutePlan: (junk) `ctid' is NULL!"); + elog(ERROR, "ctid is NULL"); tupleid = (ItemPointer) DatumGetPointer(datum); tuple_ctid = *tupleid; /* make sure we don't free the @@ -1085,13 +1093,12 @@ lnext: ; erm->resname, &datum, &isNull)) - elog(ERROR, "ExecutePlan: NO (junk) `%s' was found!", + elog(ERROR, "could not find junk \"%s\" column", erm->resname); /* shouldn't ever get a null result... */ if (isNull) - elog(ERROR, "ExecutePlan: (junk) `%s' is NULL!", - erm->resname); + elog(ERROR, "\"%s\" is NULL", erm->resname); tuple.t_self = *((ItemPointer) DatumGetPointer(datum)); test = heap_mark4update(erm->relation, &tuple, &buffer, @@ -1108,7 +1115,9 @@ lnext: ; case HeapTupleUpdated: if (XactIsoLevel == XACT_SERIALIZABLE) - elog(ERROR, "Can't serialize access due to concurrent update"); + ereport(ERROR, + (errcode(ERRCODE_T_R_SERIALIZATION_FAILURE), + errmsg("cannot serialize access due to concurrent update"))); if (!(ItemPointerEquals(&(tuple.t_self), (ItemPointer) DatumGetPointer(datum)))) { @@ -1129,7 +1138,8 @@ lnext: ; goto lnext; default: - elog(ERROR, "Unknown status %u from heap_mark4update", test); + elog(ERROR, "unrecognized heap_mark4update status: %u", + test); return (NULL); } } @@ -1178,7 +1188,8 @@ lnext: ; break; default: - elog(LOG, "ExecutePlan: unknown operation in queryDesc"); + elog(ERROR, "unrecognized operation code: %d", + (int) operation); result = NULL; break; } @@ -1321,7 +1332,7 @@ ExecInsert(TupleTableSlot *slot, * Check the constraints of the tuple */ if (resultRelationDesc->rd_att->constr) - ExecConstraints("ExecInsert", resultRelInfo, slot, estate); + ExecConstraints(resultRelInfo, slot, estate); /* * insert the tuple @@ -1403,7 +1414,9 @@ ldelete:; case HeapTupleUpdated: if (XactIsoLevel == XACT_SERIALIZABLE) - elog(ERROR, "Can't serialize access due to concurrent update"); + ereport(ERROR, + (errcode(ERRCODE_T_R_SERIALIZATION_FAILURE), + errmsg("cannot serialize access due to concurrent update"))); else if (!(ItemPointerEquals(tupleid, &ctid))) { TupleTableSlot *epqslot = EvalPlanQual(estate, @@ -1419,7 +1432,7 @@ ldelete:; return; default: - elog(ERROR, "Unknown status %u from heap_delete", result); + elog(ERROR, "unrecognized heap_delete status: %u", result); return; } @@ -1466,10 +1479,7 @@ ExecUpdate(TupleTableSlot *slot, * abort the operation if not running transactions */ if (IsBootstrapProcessingMode()) - { - elog(WARNING, "ExecUpdate: UPDATE can't run without transactions"); - return; - } + elog(ERROR, "cannot UPDATE during bootstrap"); /* * get the heap tuple out of the tuple table slot @@ -1519,7 +1529,7 @@ ExecUpdate(TupleTableSlot *slot, */ lreplace:; if (resultRelationDesc->rd_att->constr) - ExecConstraints("ExecUpdate", resultRelInfo, slot, estate); + ExecConstraints(resultRelInfo, slot, estate); /* * replace the heap tuple @@ -1538,7 +1548,9 @@ lreplace:; case HeapTupleUpdated: if (XactIsoLevel == XACT_SERIALIZABLE) - elog(ERROR, "Can't serialize access due to concurrent update"); + ereport(ERROR, + (errcode(ERRCODE_T_R_SERIALIZATION_FAILURE), + errmsg("cannot serialize access due to concurrent update"))); else if (!(ItemPointerEquals(tupleid, &ctid))) { TupleTableSlot *epqslot = EvalPlanQual(estate, @@ -1558,7 +1570,7 @@ lreplace:; return; default: - elog(ERROR, "Unknown status %u from heap_update", result); + elog(ERROR, "unrecognized heap_update status: %u", result); return; } @@ -1591,7 +1603,7 @@ lreplace:; ExecARUpdateTriggers(estate, resultRelInfo, tupleid, tuple); } -static char * +static const char * ExecRelCheck(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate) { @@ -1646,11 +1658,11 @@ ExecRelCheck(ResultRelInfo *resultRelInfo, } /* NULL result means no error */ - return (char *) NULL; + return NULL; } void -ExecConstraints(const char *caller, ResultRelInfo *resultRelInfo, +ExecConstraints(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate) { Relation rel = resultRelInfo->ri_RelationDesc; @@ -1668,18 +1680,22 @@ ExecConstraints(const char *caller, ResultRelInfo *resultRelInfo, { if (rel->rd_att->attrs[attrChk - 1]->attnotnull && heap_attisnull(tuple, attrChk)) - elog(ERROR, "%s: Fail to add null value in not null attribute %s", - caller, NameStr(rel->rd_att->attrs[attrChk - 1]->attname)); + ereport(ERROR, + (errcode(ERRCODE_NOT_NULL_VIOLATION), + errmsg("null value for attribute \"%s\" violates NOT NULL constraint", + NameStr(rel->rd_att->attrs[attrChk - 1]->attname)))); } } if (constr->num_check > 0) { - char *failed; + const char *failed; if ((failed = ExecRelCheck(resultRelInfo, slot, estate)) != NULL) - elog(ERROR, "%s: rejected due to CHECK constraint \"%s\" on \"%s\"", - caller, failed, RelationGetRelationName(rel)); + ereport(ERROR, + (errcode(ERRCODE_CHECK_VIOLATION), + errmsg("new row for relation \"%s\" violates CHECK constraint \"%s\"", + RelationGetRelationName(rel), failed))); } } @@ -1721,7 +1737,7 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid) } } if (relation == NULL) - elog(ERROR, "EvalPlanQual: can't find RTE %d", (int) rti); + elog(ERROR, "cannot find RowMark for RT index %u", rti); } /* @@ -1738,8 +1754,9 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid) { TransactionId xwait = SnapshotDirty->xmax; + /* xmin should not be dirty... */ if (TransactionIdIsValid(SnapshotDirty->xmin)) - elog(ERROR, "EvalPlanQual: t_xmin is uncommitted ?!"); + elog(ERROR, "t_xmin is uncommitted in tuple to be updated"); /* * If tuple is being updated by other transaction then we have diff --git a/src/backend/executor/execProcnode.c b/src/backend/executor/execProcnode.c index f8dbb019c5..f73f2d7185 100644 --- a/src/backend/executor/execProcnode.c +++ b/src/backend/executor/execProcnode.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.36 2003/05/05 17:57:47 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.37 2003/07/21 17:05:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -214,8 +214,7 @@ ExecInitNode(Plan *node, EState *estate) break; default: - elog(ERROR, "ExecInitNode: node type %d unsupported", - (int) nodeTag(node)); + elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node)); result = NULL; /* keep compiler quiet */ break; } @@ -374,8 +373,7 @@ ExecProcNode(PlanState *node) break; default: - elog(ERROR, "ExecProcNode: node type %d unsupported", - (int) nodeTag(node)); + elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node)); result = NULL; break; } @@ -467,8 +465,7 @@ ExecCountSlotsNode(Plan *node) return ExecCountSlotsLimit((Limit *) node); default: - elog(ERROR, "ExecCountSlotsNode: node type %d unsupported", - (int) nodeTag(node)); + elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node)); break; } @@ -596,8 +593,7 @@ ExecEndNode(PlanState *node) break; default: - elog(ERROR, "ExecEndNode: node type %d unsupported", - (int) nodeTag(node)); + elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node)); break; } } diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c index bba9a6e49c..dad12acb78 100644 --- a/src/backend/executor/execQual.c +++ b/src/backend/executor/execQual.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.134 2003/06/29 00:33:42 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.135 2003/07/21 17:05:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -175,8 +175,10 @@ ExecEvalArrayRef(ArrayRefExprState *astate, foreach(elt, astate->refupperindexpr) { if (i >= MAXDIM) - elog(ERROR, "ExecEvalArrayRef: can only handle %d dimensions", - MAXDIM); + ereport(ERROR, + (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), + errmsg("number of array dimensions exceeds the maximum allowed, %d", + MAXDIM))); upper.indx[i++] = DatumGetInt32(ExecEvalExpr((ExprState *) lfirst(elt), econtext, @@ -197,8 +199,10 @@ ExecEvalArrayRef(ArrayRefExprState *astate, foreach(elt, astate->reflowerindexpr) { if (j >= MAXDIM) - elog(ERROR, "ExecEvalArrayRef: can only handle %d dimensions", - MAXDIM); + ereport(ERROR, + (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), + errmsg("number of array dimensions exceeds the maximum allowed, %d", + MAXDIM))); lower.indx[j++] = DatumGetInt32(ExecEvalExpr((ExprState *) lfirst(elt), econtext, @@ -217,9 +221,9 @@ ExecEvalArrayRef(ArrayRefExprState *astate, return PointerGetDatum(array_source); } } + /* this can't happen unless parser messed up */ if (i != j) - elog(ERROR, - "ExecEvalArrayRef: upper and lower indices mismatch"); + elog(ERROR, "upper and lower index lists are not same length"); lIndex = lower.indx; } else @@ -300,7 +304,7 @@ static Datum ExecEvalAggref(AggrefExprState *aggref, ExprContext *econtext, bool *isNull) { if (econtext->ecxt_aggvalues == NULL) /* safety check */ - elog(ERROR, "ExecEvalAggref: no aggregates in this expression context"); + elog(ERROR, "no aggregates in this expression context"); *isNull = econtext->ecxt_aggnulls[aggref->aggno]; return econtext->ecxt_aggvalues[aggref->aggno]; @@ -478,7 +482,7 @@ ExecEvalParam(Param *expression, ExprContext *econtext, bool *isNull) matchFound = true; break; default: - elog(ERROR, "ExecEvalParam: invalid paramkind %d", + elog(ERROR, "unrecognized paramkind: %d", thisParamKind); } } @@ -490,11 +494,15 @@ ExecEvalParam(Param *expression, ExprContext *econtext, bool *isNull) if (!matchFound) { if (thisParamKind == PARAM_NAMED) - elog(ERROR, "ExecEvalParam: Unknown value for parameter %s", - thisParamName); + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_OBJECT), + errmsg("no value found for parameter \"%s\"", + thisParamName))); else - elog(ERROR, "ExecEvalParam: Unknown value for parameter %d", - thisParamId); + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_OBJECT), + errmsg("no value found for parameter %d", + thisParamId))); } *isNull = paramList->isnull; @@ -525,13 +533,10 @@ GetAttributeByNum(TupleTableSlot *slot, Datum retval; if (!AttributeNumberIsValid(attrno)) - elog(ERROR, "GetAttributeByNum: Invalid attribute number"); - - if (!AttrNumberIsForUserDefinedAttr(attrno)) - elog(ERROR, "GetAttributeByNum: cannot access system attributes here"); + elog(ERROR, "invalid attribute number: %d", attrno); if (isNull == (bool *) NULL) - elog(ERROR, "GetAttributeByNum: a NULL isNull flag was passed"); + elog(ERROR, "a NULL isNull pointer was passed"); if (TupIsNull(slot)) { @@ -559,10 +564,10 @@ GetAttributeByName(TupleTableSlot *slot, char *attname, bool *isNull) int i; if (attname == NULL) - elog(ERROR, "GetAttributeByName: Invalid attribute name"); + elog(ERROR, "invalid attribute name"); if (isNull == (bool *) NULL) - elog(ERROR, "GetAttributeByName: a NULL isNull flag was passed"); + elog(ERROR, "a NULL isNull pointer was passed"); if (TupIsNull(slot)) { @@ -584,7 +589,7 @@ GetAttributeByName(TupleTableSlot *slot, char *attname, bool *isNull) } if (attrno == InvalidAttrNumber) - elog(ERROR, "GetAttributeByName: attribute %s not found", attname); + elog(ERROR, "attribute \"%s\" does not exist", attname); retval = heap_getattr(slot->val, attrno, @@ -611,7 +616,7 @@ init_fcache(Oid foid, FuncExprState *fcache, MemoryContext fcacheCxt) /* Safety check (should never fail, as parser should check sooner) */ if (length(fcache->args) > FUNC_MAX_ARGS) - elog(ERROR, "init_fcache: too many arguments"); + elog(ERROR, "too many arguments to function"); /* Set up the primary fmgr lookup information */ fmgr_info_cxt(foid, &(fcache->func), fcacheCxt); @@ -654,7 +659,9 @@ ExecEvalFuncArgs(FunctionCallInfo fcinfo, * it. */ if (argIsDone != ExprSingleResult) - elog(ERROR, "Functions and operators can take only one set argument"); + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("functions and operators can take at most one set argument"))); argIsDone = thisArgIsDone; } i++; @@ -704,7 +711,9 @@ ExecMakeFunctionResult(FuncExprState *fcache, if (isDone) *isDone = ExprEndResult; else - elog(ERROR, "Set-valued function called in context that cannot accept a set"); + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("set-valued function called in context that cannot accept a set"))); return (Datum) 0; } hasSetArg = (argDone != ExprSingleResult); @@ -746,7 +755,9 @@ ExecMakeFunctionResult(FuncExprState *fcache, * to accept one. */ if (isDone == NULL) - elog(ERROR, "Set-valued function called in context that cannot accept a set"); + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("set-valued function called in context that cannot accept a set"))); /* * This loop handles the situation where we have both a set @@ -931,7 +942,9 @@ ExecMakeTableFunctionResult(ExprState *funcexpr, argDone = ExecEvalFuncArgs(&fcinfo, fcache->args, econtext); /* We don't allow sets in the arguments of the table function */ if (argDone != ExprSingleResult) - elog(ERROR, "Set-valued function called in context that cannot accept a set"); + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("set-valued function called in context that cannot accept a set"))); /* * If function is strict, and there are any NULL arguments, skip @@ -1038,11 +1051,15 @@ ExecMakeTableFunctionResult(ExprState *funcexpr, * TupleTableSlot; use its descriptor */ slot = (TupleTableSlot *) DatumGetPointer(result); - if (fcinfo.isnull || - !slot || - !IsA(slot, TupleTableSlot) || + if (fcinfo.isnull || !slot) + ereport(ERROR, + (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), + errmsg("function returning tuple cannot return NULL"))); + if (!IsA(slot, TupleTableSlot) || !slot->ttc_tupleDescriptor) - elog(ERROR, "ExecMakeTableFunctionResult: Invalid result from function returning tuple"); + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("function returning tuple did not return a valid tuple slot"))); tupdesc = CreateTupleDescCopy(slot->ttc_tupleDescriptor); returnsTuple = true; } @@ -1076,7 +1093,9 @@ ExecMakeTableFunctionResult(ExprState *funcexpr, !slot || !IsA(slot, TupleTableSlot) || TupIsNull(slot)) - elog(ERROR, "ExecMakeTableFunctionResult: Invalid result from function returning tuple"); + ereport(ERROR, + (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), + errmsg("function returning tuple cannot return NULL"))); tuple = slot->val; } else @@ -1101,13 +1120,17 @@ ExecMakeTableFunctionResult(ExprState *funcexpr, { /* check we're on the same page as the function author */ if (!first_time || rsinfo.isDone != ExprSingleResult) - elog(ERROR, "ExecMakeTableFunctionResult: Materialize-mode protocol not followed"); + ereport(ERROR, + (errcode(ERRCODE_E_R_I_E_SRF_PROTOCOL_VIOLATED), + errmsg("table-function protocol for materialize mode was not followed"))); /* Done evaluating the set result */ break; } else - elog(ERROR, "ExecMakeTableFunctionResult: unknown returnMode %d", - (int) rsinfo.returnMode); + ereport(ERROR, + (errcode(ERRCODE_E_R_I_E_SRF_PROTOCOL_VIOLATED), + errmsg("unrecognized table-function returnMode: %d", + (int) rsinfo.returnMode))); first_time = false; } @@ -1217,7 +1240,9 @@ ExecEvalDistinct(FuncExprState *fcache, fcinfo.flinfo = &(fcache->func); argDone = ExecEvalFuncArgs(&fcinfo, argList, econtext); if (argDone != ExprSingleResult) - elog(ERROR, "IS DISTINCT FROM does not support set arguments"); + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("IS DISTINCT FROM does not support set arguments"))); Assert(fcinfo.nargs == 2); if (fcinfo.argnull[0] && fcinfo.argnull[1]) @@ -1283,7 +1308,9 @@ ExecEvalScalarArrayOp(ScalarArrayOpExprState *sstate, fcinfo.flinfo = &(sstate->fxprstate.func); argDone = ExecEvalFuncArgs(&fcinfo, sstate->fxprstate.args, econtext); if (argDone != ExprSingleResult) - elog(ERROR, "op ANY/ALL (array) does not support set arguments"); + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("op ANY/ALL (array) does not support set arguments"))); Assert(fcinfo.nargs == 2); /* @@ -1615,7 +1642,9 @@ ExecEvalArray(ArrayExprState *astate, ExprContext *econtext, dvalues[i++] = ExecEvalExpr(e, econtext, &eisnull, NULL); if (eisnull) - elog(ERROR, "Arrays cannot have NULL elements"); + ereport(ERROR, + (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), + errmsg("arrays cannot have NULL elements"))); } /* setup for 1-D array of the given length */ @@ -1641,7 +1670,10 @@ ExecEvalArray(ArrayExprState *astate, ExprContext *econtext, int i; if (ndims <= 0 || ndims > MAXDIM) - elog(ERROR, "Arrays cannot have more than %d dimensions", MAXDIM); + ereport(ERROR, + (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), + errmsg("number of array dimensions exceeds the maximum allowed, %d", + MAXDIM))); /* loop through and get data area from each element */ foreach(element, astate->elements) @@ -1654,7 +1686,9 @@ ExecEvalArray(ArrayExprState *astate, ExprContext *econtext, arraydatum = ExecEvalExpr(e, econtext, &eisnull, NULL); if (eisnull) - elog(ERROR, "Arrays cannot have NULL elements"); + ereport(ERROR, + (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), + errmsg("arrays cannot have NULL elements"))); array = DatumGetArrayTypeP(arraydatum); @@ -1671,19 +1705,15 @@ ExecEvalArray(ArrayExprState *astate, ExprContext *econtext, else { /* Check other sub-arrays are compatible */ - if (elem_ndims != ARR_NDIM(array)) - elog(ERROR, "Multidimensional arrays must have array " - "expressions with matching number of dimensions"); - - if (memcmp(elem_dims, ARR_DIMS(array), + if (elem_ndims != ARR_NDIM(array) || + memcmp(elem_dims, ARR_DIMS(array), + elem_ndims * sizeof(int)) != 0 || + memcmp(elem_lbs, ARR_LBOUND(array), elem_ndims * sizeof(int)) != 0) - elog(ERROR, "Multidimensional arrays must have array " - "expressions with matching dimensions"); - - if (memcmp(elem_lbs, ARR_LBOUND(array), - elem_ndims * sizeof(int)) != 0) - elog(ERROR, "Multidimensional arrays must have array " - "expressions with matching dimensions"); + ereport(ERROR, + (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), + errmsg("multidimensional arrays must have array " + "expressions with matching dimensions"))); } elem_ndatabytes = ARR_SIZE(array) - ARR_OVERHEAD(elem_ndims); @@ -1790,7 +1820,9 @@ ExecEvalNullIf(FuncExprState *fcache, ExprContext *econtext, fcinfo.flinfo = &(fcache->func); argDone = ExecEvalFuncArgs(&fcinfo, argList, econtext); if (argDone != ExprSingleResult) - elog(ERROR, "NULLIF does not support set arguments"); + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("NULLIF does not support set arguments"))); Assert(fcinfo.nargs == 2); /* if either argument is NULL they can't be equal */ @@ -1850,7 +1882,7 @@ ExecEvalNullTest(GenericExprState *nstate, else return BoolGetDatum(true); default: - elog(ERROR, "ExecEvalNullTest: unexpected nulltesttype %d", + elog(ERROR, "unrecognized nulltesttype: %d", (int) ntest->nulltesttype); return (Datum) 0; /* keep compiler quiet */ } @@ -1935,7 +1967,7 @@ ExecEvalBooleanTest(GenericExprState *bstate, else return BoolGetDatum(true); default: - elog(ERROR, "ExecEvalBooleanTest: unexpected booltesttype %d", + elog(ERROR, "unrecognized booltesttype: %d", (int) btest->booltesttype); return (Datum) 0; /* keep compiler quiet */ } @@ -1969,8 +2001,10 @@ ExecEvalCoerceToDomain(CoerceToDomainState *cstate, ExprContext *econtext, { case DOM_CONSTRAINT_NOTNULL: if (*isNull) - elog(ERROR, "Domain %s does not allow NULL values", - format_type_be(ctest->resulttype)); + ereport(ERROR, + (errcode(ERRCODE_NOT_NULL_VIOLATION), + errmsg("domain %s does not allow NULL values", + format_type_be(ctest->resulttype)))); break; case DOM_CONSTRAINT_CHECK: { @@ -1996,16 +2030,19 @@ ExecEvalCoerceToDomain(CoerceToDomainState *cstate, ExprContext *econtext, if (!conIsNull && !DatumGetBool(conResult)) - elog(ERROR, "ExecEvalCoerceToDomain: Domain %s constraint %s failed", - format_type_be(ctest->resulttype), con->name); - + ereport(ERROR, + (errcode(ERRCODE_CHECK_VIOLATION), + errmsg("value for domain %s violates CHECK constraint \"%s\"", + format_type_be(ctest->resulttype), + con->name))); econtext->domainValue_datum = save_datum; econtext->domainValue_isNull = save_isNull; break; } default: - elog(ERROR, "ExecEvalCoerceToDomain: Constraint type unknown"); + elog(ERROR, "unrecognized constraint type: %d", + (int) con->constrainttype); break; } } @@ -2074,9 +2111,9 @@ ExecEvalFieldSelect(GenericExprState *fstate, * *isDone: set to indicator of set-result status * * A caller that can only accept a singleton (non-set) result should pass - * NULL for isDone; if the expression computes a set result then an elog() - * error will be reported. If the caller does pass an isDone pointer then - * *isDone is set to one of these three states: + * NULL for isDone; if the expression computes a set result then an error + * will be reported via ereport. If the caller does pass an isDone pointer + * then *isDone is set to one of these three states: * ExprSingleResult singleton result (not a set) * ExprMultipleResult return value is one element of a set * ExprEndResult there are no more elements in the set @@ -2182,8 +2219,8 @@ ExecEvalExpr(ExprState *expression, retDatum = ExecEvalNot(state, econtext, isNull); break; default: - elog(ERROR, "ExecEvalExpr: unknown boolop %d", - ((BoolExpr *) expr)->boolop); + elog(ERROR, "unrecognized boolop: %d", + (int) ((BoolExpr *) expr)->boolop); retDatum = 0; /* keep compiler quiet */ break; } @@ -2251,8 +2288,8 @@ ExecEvalExpr(ExprState *expression, isNull); break; default: - elog(ERROR, "ExecEvalExpr: unknown expression type %d", - nodeTag(expression)); + elog(ERROR, "unrecognized node type: %d", + (int) nodeTag(expression)); retDatum = 0; /* keep compiler quiet */ break; } @@ -2346,14 +2383,19 @@ ExecInitExpr(Expr *node, PlanState *parent) /* * Complain if the aggregate's argument contains any * aggregates; nested agg functions are semantically - * nonsensical. (This probably was caught earlier, + * nonsensical. (This should have been caught earlier, * but we defend against it here anyway.) */ if (naggs != aggstate->numaggs) - elog(ERROR, "Aggregate function calls may not be nested"); + ereport(ERROR, + (errcode(ERRCODE_GROUPING_ERROR), + errmsg("aggregate function calls may not be nested"))); } else - elog(ERROR, "ExecInitExpr: Aggref not expected here"); + { + /* planner messed up */ + elog(ERROR, "aggref found in non-Agg plan node"); + } state = (ExprState *) astate; } break; @@ -2440,7 +2482,7 @@ ExecInitExpr(Expr *node, PlanState *parent) SubPlanState *sstate = makeNode(SubPlanState); if (!parent) - elog(ERROR, "ExecInitExpr: SubPlan not expected here"); + elog(ERROR, "SubPlan found with no parent plan"); /* * Here we just add the SubPlanState nodes to @@ -2611,8 +2653,8 @@ ExecInitExpr(Expr *node, PlanState *parent) return (ExprState *) FastListValue(&outlist); } default: - elog(ERROR, "ExecInitExpr: unknown expression type %d", - nodeTag(node)); + elog(ERROR, "unrecognized node type: %d", + (int) nodeTag(node)); state = NULL; /* keep compiler quiet */ break; } @@ -2635,7 +2677,7 @@ ExecInitExprInitPlan(SubPlan *node, PlanState *parent) SubPlanState *sstate = makeNode(SubPlanState); if (!parent) - elog(ERROR, "ExecInitExpr: SubPlan not expected here"); + elog(ERROR, "SubPlan found with no parent plan"); /* The subplan's state will be initialized later */ sstate->sub_estate = NULL; @@ -2886,7 +2928,9 @@ ExecTargetList(List *targetlist, { /* We have a set-valued expression in the tlist */ if (isDone == NULL) - elog(ERROR, "Set-valued function called in context that cannot accept a set"); + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("set-valued function called in context that cannot accept a set"))); if (itemIsDone[resind] == ExprMultipleResult) { /* we have undone sets in the tlist, set flag */ diff --git a/src/backend/executor/execTuples.c b/src/backend/executor/execTuples.c index cb85be630f..976c152236 100644 --- a/src/backend/executor/execTuples.c +++ b/src/backend/executor/execTuples.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.66 2003/05/08 18:16:36 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.67 2003/07/21 17:05:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -256,8 +256,7 @@ ExecAllocTableSlot(TupleTable table) * -mer 4 Aug 1992 */ if (table->next >= table->size) - elog(ERROR, "Plan requires more slots than are available" - "\n\tsend mail to your local executor guru to fix this"); + elog(ERROR, "plan requires more slots than are available"); /* * at this point, space in the table is guaranteed so we reserve the diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c index e0ab9e92d5..bda57fa321 100644 --- a/src/backend/executor/functions.c +++ b/src/backend/executor/functions.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.67 2003/07/01 00:04:37 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.68 2003/07/21 17:05:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -165,8 +165,7 @@ init_sql_fcache(FmgrInfo *finfo) ObjectIdGetDatum(foid), 0, 0, 0); if (!HeapTupleIsValid(procedureTuple)) - elog(ERROR, "init_sql_fcache: Cache lookup failed for procedure %u", - foid); + elog(ERROR, "cache lookup failed for function %u", foid); procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple); /* @@ -178,9 +177,11 @@ init_sql_fcache(FmgrInfo *finfo) if (rettype == ANYARRAYOID || rettype == ANYELEMENTOID) { rettype = get_fn_expr_rettype(finfo); - if (rettype == InvalidOid) - elog(ERROR, "could not determine actual result type for function declared %s", - format_type_be(procedureStruct->prorettype)); + if (rettype == InvalidOid) /* this probably should not happen */ + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("could not determine actual result type for function declared %s", + format_type_be(procedureStruct->prorettype)))); } /* Now look up the actual result type */ @@ -188,8 +189,7 @@ init_sql_fcache(FmgrInfo *finfo) ObjectIdGetDatum(rettype), 0, 0, 0); if (!HeapTupleIsValid(typeTuple)) - elog(ERROR, "init_sql_fcache: Cache lookup failed for type %u", - rettype); + elog(ERROR, "cache lookup failed for type %u", rettype); typeStruct = (Form_pg_type) GETSTRUCT(typeTuple); /* @@ -249,8 +249,10 @@ init_sql_fcache(FmgrInfo *finfo) { argtype = get_fn_expr_argtype(finfo, argnum); if (argtype == InvalidOid) - elog(ERROR, "could not determine actual type of argument declared %s", - format_type_be(argOidVect[argnum])); + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("could not determine actual type of argument declared %s", + format_type_be(argOidVect[argnum])))); argOidVect[argnum] = argtype; haspolyarg = true; } @@ -264,8 +266,7 @@ init_sql_fcache(FmgrInfo *finfo) Anum_pg_proc_prosrc, &isNull); if (isNull) - elog(ERROR, "init_sql_fcache: null prosrc for procedure %u", - foid); + elog(ERROR, "null prosrc for function %u", foid); src = DatumGetCString(DirectFunctionCall1(textout, tmp)); fcache->func_state = init_execution_state(src, argOidVect, nargs, @@ -563,7 +564,9 @@ fmgr_sql(PG_FUNCTION_ARGS) if (rsi && IsA(rsi, ReturnSetInfo)) rsi->isDone = ExprEndResult; else - elog(ERROR, "Set-valued function called in context that cannot accept a set"); + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("set-valued function called in context that cannot accept a set"))); fcinfo->isnull = true; result = (Datum) 0; @@ -598,7 +601,9 @@ fmgr_sql(PG_FUNCTION_ARGS) if (rsi && IsA(rsi, ReturnSetInfo)) rsi->isDone = ExprMultipleResult; else - elog(ERROR, "Set-valued function called in context that cannot accept a set"); + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("set-valued function called in context that cannot accept a set"))); /* * Ensure we will get shut down cleanly if the exprcontext is not diff --git a/src/backend/executor/instrument.c b/src/backend/executor/instrument.c index 3b95544706..0061f7ccc7 100644 --- a/src/backend/executor/instrument.c +++ b/src/backend/executor/instrument.c @@ -7,7 +7,7 @@ * Copyright (c) 2001, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/instrument.c,v 1.3 2002/03/02 21:39:25 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/instrument.c,v 1.4 2003/07/21 17:05:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -37,7 +37,7 @@ InstrStartNode(Instrumentation *instr) return; if (instr->starttime.tv_sec != 0 || instr->starttime.tv_usec != 0) - elog(LOG, "InstrStartTimer called twice in a row"); + elog(DEBUG2, "InstrStartTimer called twice in a row"); else gettimeofday(&instr->starttime, NULL); } @@ -53,7 +53,7 @@ InstrStopNode(Instrumentation *instr, bool returnedTuple) if (instr->starttime.tv_sec == 0 && instr->starttime.tv_usec == 0) { - elog(LOG, "InstrStopNode without start"); + elog(DEBUG2, "InstrStopNode without start"); return; } diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index b54d528eea..9c3481379a 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -45,7 +45,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.110 2003/07/01 19:10:52 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.111 2003/07/21 17:05:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1233,7 +1233,7 @@ ExecInitAgg(Agg *node, EState *estate) ObjectIdGetDatum(aggref->aggfnoid), 0, 0, 0); if (!HeapTupleIsValid(aggTuple)) - elog(ERROR, "ExecAgg: cache lookup failed for aggregate %u", + elog(ERROR, "cache lookup failed for aggregate %u", aggref->aggfnoid); aggform = (Form_pg_aggregate) GETSTRUCT(aggTuple); @@ -1311,8 +1311,10 @@ ExecInitAgg(Agg *node, EState *estate) if (peraggstate->transfn.fn_strict && peraggstate->initValueIsNull) { if (!IsBinaryCoercible(inputType, aggtranstype)) - elog(ERROR, "Aggregate %u needs to have compatible input type and transition type", - aggref->aggfnoid); + ereport(ERROR, + (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), + errmsg("aggregate %u needs to have compatible input type and transition type", + aggref->aggfnoid))); } if (aggref->aggdistinct) @@ -1357,7 +1359,7 @@ GetAggInitVal(Datum textInitVal, Oid transtype) ObjectIdGetDatum(transtype), 0, 0, 0); if (!HeapTupleIsValid(tup)) - elog(ERROR, "GetAggInitVal: cache lookup failed on aggregate transition function return type %u", transtype); + elog(ERROR, "cache lookup failed for type %u", transtype); typinput = ((Form_pg_type) GETSTRUCT(tup))->typinput; typelem = ((Form_pg_type) GETSTRUCT(tup))->typelem; @@ -1494,7 +1496,7 @@ ExecReScanAgg(AggState *node, ExprContext *exprCtxt) Datum aggregate_dummy(PG_FUNCTION_ARGS) { - elog(ERROR, "Aggregate function %u called as normal function", + elog(ERROR, "aggregate function %u called as normal function", fcinfo->flinfo->fn_oid); return (Datum) 0; /* keep compiler quiet */ } diff --git a/src/backend/executor/nodeFunctionscan.c b/src/backend/executor/nodeFunctionscan.c index 282993ee4e..36c43d7309 100644 --- a/src/backend/executor/nodeFunctionscan.c +++ b/src/backend/executor/nodeFunctionscan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeFunctionscan.c,v 1.18 2003/06/15 17:59:10 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeFunctionscan.c,v 1.19 2003/07/21 17:05:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -88,7 +88,9 @@ FunctionNext(FunctionScanState *node) */ if (funcTupdesc && tupledesc_mismatch(node->tupdesc, funcTupdesc)) - elog(ERROR, "Query-specified return tuple and actual function return tuple do not match"); + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("query-specified return tuple and actual function return tuple do not match"))); } /* @@ -201,7 +203,7 @@ ExecInitFunctionScan(FunctionScan *node, EState *estate) funcrelid = typeidTypeRelid(funcrettype); if (!OidIsValid(funcrelid)) - elog(ERROR, "Invalid typrelid for complex type %u", + elog(ERROR, "invalid typrelid for complex type %u", funcrettype); rel = relation_open(funcrelid, AccessShareLock); tupdesc = CreateTupleDescCopy(RelationGetDescr(rel)); diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c index f00cc28684..69053708cd 100644 --- a/src/backend/executor/nodeHash.c +++ b/src/backend/executor/nodeHash.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.76 2003/06/22 22:04:54 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.77 2003/07/21 17:05:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -248,7 +248,7 @@ ExecHashTableCreate(Hash *node, List *hashOperators) hashfn = get_op_hash_function(lfirsto(ho)); if (!OidIsValid(hashfn)) - elog(ERROR, "Could not find hash function for hash operator %u", + elog(ERROR, "could not find hash function for hash operator %u", lfirsto(ho)); fmgr_info(hashfn, &hashtable->hashfunctions[i]); i++; diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c index 9a0071f018..bc3ecdfeed 100644 --- a/src/backend/executor/nodeHashjoin.c +++ b/src/backend/executor/nodeHashjoin.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.52 2003/06/22 22:04:54 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.53 2003/07/21 17:05:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -368,7 +368,7 @@ ExecInitHashJoin(HashJoin *node, EState *estate) ExecGetResultType(innerPlanState(hjstate))); break; default: - elog(ERROR, "ExecInitHashJoin: unsupported join type %d", + elog(ERROR, "unrecognized join type: %d", (int) node->join.jointype); } @@ -553,7 +553,9 @@ ExecHashJoinGetSavedTuple(HashJoinState *hjstate, if (nread == 0) return NULL; /* end of file */ if (nread != sizeof(HeapTupleData)) - elog(ERROR, "Read from hashjoin temp file failed"); + ereport(ERROR, + (errcode_for_file_access(), + errmsg("read from hashjoin temp file failed: %m"))); heapTuple = palloc(HEAPTUPLESIZE + htup.t_len); memcpy((char *) heapTuple, (char *) &htup, sizeof(HeapTupleData)); heapTuple->t_datamcxt = CurrentMemoryContext; @@ -561,7 +563,9 @@ ExecHashJoinGetSavedTuple(HashJoinState *hjstate, ((char *) heapTuple + HEAPTUPLESIZE); nread = BufFileRead(file, (void *) heapTuple->t_data, htup.t_len); if (nread != (size_t) htup.t_len) - elog(ERROR, "Read from hashjoin temp file failed"); + ereport(ERROR, + (errcode_for_file_access(), + errmsg("read from hashjoin temp file failed: %m"))); return ExecStoreTuple(heapTuple, tupleSlot, InvalidBuffer, true); } @@ -617,12 +621,16 @@ ExecHashJoinNewBatch(HashJoinState *hjstate) * start reading them. */ if (BufFileSeek(hashtable->outerBatchFile[newbatch - 1], 0, 0L, SEEK_SET)) - elog(ERROR, "Failed to rewind hash temp file"); + ereport(ERROR, + (errcode_for_file_access(), + errmsg("failed to rewind hashjoin temp file: %m"))); innerFile = hashtable->innerBatchFile[newbatch - 1]; if (BufFileSeek(innerFile, 0, 0L, SEEK_SET)) - elog(ERROR, "Failed to rewind hash temp file"); + ereport(ERROR, + (errcode_for_file_access(), + errmsg("failed to rewind hashjoin temp file: %m"))); /* * Reload the hash table with the new inner batch @@ -671,10 +679,14 @@ ExecHashJoinSaveTuple(HeapTuple heapTuple, written = BufFileWrite(file, (void *) heapTuple, sizeof(HeapTupleData)); if (written != sizeof(HeapTupleData)) - elog(ERROR, "Write to hashjoin temp file failed"); + ereport(ERROR, + (errcode_for_file_access(), + errmsg("write to hashjoin temp file failed: %m"))); written = BufFileWrite(file, (void *) heapTuple->t_data, heapTuple->t_len); if (written != (size_t) heapTuple->t_len) - elog(ERROR, "Write to hashjoin temp file failed"); + ereport(ERROR, + (errcode_for_file_access(), + errmsg("write to hashjoin temp file failed: %m"))); } void diff --git a/src/backend/executor/nodeIndexscan.c b/src/backend/executor/nodeIndexscan.c index 51692b35bd..017a378f9d 100644 --- a/src/backend/executor/nodeIndexscan.c +++ b/src/backend/executor/nodeIndexscan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.79 2003/02/09 06:56:27 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.80 2003/07/21 17:05:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -666,7 +666,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate) listscan = lnext(listscan); if (!IsA(clause, OpExpr)) - elog(ERROR, "ExecInitIndexScan: indxqual not an opclause!"); + elog(ERROR, "indxqual is not an OpExpr"); opfuncid = clause->opfuncid; @@ -768,8 +768,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate) * scan-attribute... */ if (scanvar == LEFT_OP) - elog(ERROR, "ExecInitIndexScan: %s", - "both left and right op's are rel-vars"); + elog(ERROR, "both left and right operands are rel-vars"); /* * if the rightop is a "rel-var", then it means that it is @@ -805,8 +804,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate) * attribute... */ if (scanvar == NO_OP) - elog(ERROR, "ExecInitIndexScan: %s", - "neither leftop nor rightop refer to scan relation"); + elog(ERROR, "neither left nor right operand refer to scan relation"); /* * initialize the scan key's fields appropriately @@ -878,7 +876,10 @@ ExecInitIndexScan(IndexScan *node, EState *estate) currentRelation = heap_open(reloid, AccessShareLock); if (!RelationGetForm(currentRelation)->relhasindex) - elog(ERROR, "indexes of the relation %u was inactivated", reloid); + ereport(ERROR, + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("indexes of relation %u were deactivated", + reloid))); indexstate->ss.ss_currentRelation = currentRelation; indexstate->ss.ss_currentScanDesc = NULL; /* no heap scan here */ diff --git a/src/backend/executor/nodeLimit.c b/src/backend/executor/nodeLimit.c index 39d09331ce..4b1145e258 100644 --- a/src/backend/executor/nodeLimit.c +++ b/src/backend/executor/nodeLimit.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeLimit.c,v 1.14 2002/12/15 16:17:46 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeLimit.c,v 1.15 2003/07/21 17:05:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -149,7 +149,7 @@ ExecLimit(LimitState *node) */ slot = ExecProcNode(outerPlan); if (TupIsNull(slot)) - elog(ERROR, "ExecLimit: subplan failed to run backwards"); + elog(ERROR, "LIMIT subplan failed to run backwards"); node->subSlot = slot; node->position--; } @@ -164,7 +164,7 @@ ExecLimit(LimitState *node) */ slot = ExecProcNode(outerPlan); if (TupIsNull(slot)) - elog(ERROR, "ExecLimit: subplan failed to run backwards"); + elog(ERROR, "LIMIT subplan failed to run backwards"); node->subSlot = slot; node->lstate = LIMIT_INWINDOW; /* position does not change 'cause we didn't advance it before */ @@ -195,7 +195,7 @@ ExecLimit(LimitState *node) break; default: - elog(ERROR, "ExecLimit: impossible state %d", + elog(ERROR, "impossible LIMIT state: %d", (int) node->lstate); slot = NULL; /* keep compiler quiet */ break; diff --git a/src/backend/executor/nodeMergejoin.c b/src/backend/executor/nodeMergejoin.c index 864008dd17..57249d7d97 100644 --- a/src/backend/executor/nodeMergejoin.c +++ b/src/backend/executor/nodeMergejoin.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.57 2003/05/05 17:57:47 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.58 2003/07/21 17:05:10 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -129,7 +129,7 @@ MJFormSkipQuals(List *qualList, List **ltQuals, List **gtQuals, * The two ops should be identical, so use either one for lookup. */ if (!IsA(ltop, OpExpr)) - elog(ERROR, "MJFormSkipQuals: op not an OpExpr!"); + elog(ERROR, "mergejoin clause is not an OpExpr"); /* * Lookup the operators, and replace the data in the copied @@ -398,7 +398,7 @@ ExecMergeJoin(MergeJoinState *node) doFillInner = true; break; default: - elog(ERROR, "ExecMergeJoin: unsupported join type %d", + elog(ERROR, "unrecognized join type: %d", (int) node->js.jointype); doFillOuter = false; /* keep compiler quiet */ doFillInner = false; @@ -1384,13 +1384,11 @@ ExecMergeJoin(MergeJoinState *node) break; /* - * if we get here it means our code is fouled up and so we - * just end the join prematurely. + * broken state value? */ default: - elog(WARNING, "ExecMergeJoin: invalid join state %d, aborting", - node->mj_JoinState); - return NULL; + elog(ERROR, "unrecognized mergejoin state: %d", + (int) node->mj_JoinState); } } } @@ -1473,10 +1471,12 @@ ExecInitMergeJoin(MergeJoin *node, EState *estate) /* * Can't handle right or full join with non-nil extra - * joinclauses. + * joinclauses. This should have been caught by planner. */ if (node->join.joinqual != NIL) - elog(ERROR, "RIGHT JOIN is only supported with mergejoinable join conditions"); + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("RIGHT JOIN is only supported with mergejoinable join conditions"))); break; case JOIN_FULL: mergestate->mj_NullOuterTupleSlot = @@ -1491,10 +1491,12 @@ ExecInitMergeJoin(MergeJoin *node, EState *estate) * joinclauses. */ if (node->join.joinqual != NIL) - elog(ERROR, "FULL JOIN is only supported with mergejoinable join conditions"); + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("FULL JOIN is only supported with mergejoinable join conditions"))); break; default: - elog(ERROR, "ExecInitMergeJoin: unsupported join type %d", + elog(ERROR, "unrecognized join type: %d", (int) node->join.jointype); } diff --git a/src/backend/executor/nodeNestloop.c b/src/backend/executor/nodeNestloop.c index bddce76b43..2b69da95e8 100644 --- a/src/backend/executor/nodeNestloop.c +++ b/src/backend/executor/nodeNestloop.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeNestloop.c,v 1.32 2003/05/05 17:57:47 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeNestloop.c,v 1.33 2003/07/21 17:05:10 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -333,7 +333,7 @@ ExecInitNestLoop(NestLoop *node, EState *estate) ExecGetResultType(innerPlanState(nlstate))); break; default: - elog(ERROR, "ExecInitNestLoop: unsupported join type %d", + elog(ERROR, "unrecognized join type: %d", (int) node->join.jointype); } diff --git a/src/backend/executor/nodeSetOp.c b/src/backend/executor/nodeSetOp.c index 3946cd0024..7917744dd9 100644 --- a/src/backend/executor/nodeSetOp.c +++ b/src/backend/executor/nodeSetOp.c @@ -21,7 +21,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeSetOp.c,v 1.9 2003/01/10 23:54:24 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeSetOp.c,v 1.10 2003/07/21 17:05:10 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -170,7 +170,7 @@ ExecSetOp(SetOpState *node) 0 : (node->numLeft - node->numRight); break; default: - elog(ERROR, "ExecSetOp: bogus command code %d", + elog(ERROR, "unrecognized setop code: %d", (int) plannode->cmd); break; } diff --git a/src/backend/executor/nodeSubplan.c b/src/backend/executor/nodeSubplan.c index 5999ef7077..a42e8f18e2 100644 --- a/src/backend/executor/nodeSubplan.c +++ b/src/backend/executor/nodeSubplan.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeSubplan.c,v 1.50 2003/06/27 00:33:25 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeSubplan.c,v 1.51 2003/07/21 17:05:10 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -52,7 +52,7 @@ ExecSubPlan(SubPlanState *node, SubPlan *subplan = (SubPlan *) node->xprstate.expr; if (subplan->setParam != NIL) - elog(ERROR, "ExecSubPlan: can't set parent params from subquery"); + elog(ERROR, "cannot set parent params from subquery"); if (subplan->useHashTable) return ExecHashSubPlan(node, econtext, isNull); @@ -76,7 +76,7 @@ ExecHashSubPlan(SubPlanState *node, /* Shouldn't have any direct correlation Vars */ if (subplan->parParam != NIL || node->args != NIL) - elog(ERROR, "ExecHashSubPlan: direct correlation not supported"); + elog(ERROR, "hashed subplan with direct correlation not supported"); /* * If first time through or we need to rescan the subplan, build @@ -284,7 +284,9 @@ ExecScanSubPlan(SubPlanState *node, { /* cannot allow multiple input tuples for EXPR sublink */ if (found) - elog(ERROR, "More than one tuple returned by a subselect used as an expression."); + ereport(ERROR, + (errcode(ERRCODE_CARDINALITY_VIOLATION), + errmsg("more than one tuple returned by a subselect used as an expression"))); found = true; /* @@ -324,7 +326,9 @@ ExecScanSubPlan(SubPlanState *node, /* cannot allow multiple input tuples for MULTIEXPR sublink either */ if (subLinkType == MULTIEXPR_SUBLINK && found) - elog(ERROR, "More than one tuple returned by a subselect used as an expression."); + ereport(ERROR, + (errcode(ERRCODE_CARDINALITY_VIOLATION), + errmsg("more than one tuple returned by a subselect used as an expression"))); found = true; @@ -836,7 +840,7 @@ ExecInitSubPlan(SubPlanState *node, EState *estate) /* Lookup the associated hash function */ hashfn = get_op_hash_function(opexpr->opno); if (!OidIsValid(hashfn)) - elog(ERROR, "Could not find hash function for hash operator %u", + elog(ERROR, "could not find hash function for hash operator %u", opexpr->opno); fmgr_info(hashfn, &node->hashfunctions[i-1]); @@ -908,7 +912,7 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext) if (subLinkType == ANY_SUBLINK || subLinkType == ALL_SUBLINK) - elog(ERROR, "ExecSetParamPlan: ANY/ALL subselect unsupported"); + elog(ERROR, "ANY/ALL subselect unsupported as initplan"); if (planstate->chgParam != NULL) ExecReScan(planstate, NULL); @@ -952,7 +956,9 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext) if (found && (subLinkType == EXPR_SUBLINK || subLinkType == MULTIEXPR_SUBLINK)) - elog(ERROR, "More than one tuple returned by a subselect used as an expression."); + ereport(ERROR, + (errcode(ERRCODE_CARDINALITY_VIOLATION), + errmsg("more than one tuple returned by a subselect used as an expression"))); found = true; @@ -1046,6 +1052,9 @@ ExecEndSubPlan(SubPlanState *node) } } +/* + * Mark an initplan as needing recalculation + */ void ExecReScanSetParamPlan(SubPlanState *node, PlanState *parent) { @@ -1054,12 +1063,13 @@ ExecReScanSetParamPlan(SubPlanState *node, PlanState *parent) EState *estate = parent->state; List *lst; + /* sanity checks */ if (subplan->parParam != NIL) - elog(ERROR, "ExecReScanSetParamPlan: direct correlated subquery unsupported, yet"); + elog(ERROR, "direct correlated subquery unsupported as initplan"); if (subplan->setParam == NIL) - elog(ERROR, "ExecReScanSetParamPlan: setParam list is empty"); + elog(ERROR, "setParam list of initplan is empty"); if (bms_is_empty(planstate->plan->extParam)) - elog(ERROR, "ExecReScanSetParamPlan: extParam set of plan is empty"); + elog(ERROR, "extParam set of initplan is empty"); /* * Don't actually re-scan: ExecSetParamPlan does it if needed. diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index 785170b0c5..4d554aef1e 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.98 2003/05/09 18:08:48 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.99 2003/07/21 17:05:10 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -66,19 +66,21 @@ SPI_connect(void) if (_SPI_stack == NULL) { if (_SPI_connected != -1) - elog(FATAL, "SPI_connect: no connection(s) expected"); + elog(ERROR, "SPI stack corrupted"); new_SPI_stack = (_SPI_connection *) malloc(sizeof(_SPI_connection)); } else { - if (_SPI_connected <= -1) - elog(FATAL, "SPI_connect: some connection(s) expected"); + if (_SPI_connected < 0) + elog(ERROR, "SPI stack corrupted"); new_SPI_stack = (_SPI_connection *) realloc(_SPI_stack, (_SPI_connected + 2) * sizeof(_SPI_connection)); } if (new_SPI_stack == NULL) - elog(ERROR, "Memory exhausted in SPI_connect"); + ereport(ERROR, + (errcode(ERRCODE_OUT_OF_MEMORY), + errmsg("out of memory"))); /* * We' returning to procedure where _SPI_curid == _SPI_connected - 1 @@ -158,7 +160,9 @@ SPI_finish(void) (_SPI_connected + 1) * sizeof(_SPI_connection)); /* This could only fail with a pretty stupid malloc package ... */ if (new_SPI_stack == NULL) - elog(ERROR, "Memory exhausted in SPI_finish"); + ereport(ERROR, + (errcode(ERRCODE_OUT_OF_MEMORY), + errmsg("out of memory"))); _SPI_stack = new_SPI_stack; _SPI_current = &(_SPI_stack[_SPI_connected]); } @@ -320,7 +324,7 @@ SPI_copytuple(HeapTuple tuple) if (_SPI_curid + 1 == _SPI_connected) /* connected */ { if (_SPI_current != &(_SPI_stack[_SPI_curid + 1])) - elog(FATAL, "SPI: stack corrupted"); + elog(ERROR, "SPI stack corrupted"); oldcxt = MemoryContextSwitchTo(_SPI_current->savedcxt); } @@ -347,7 +351,7 @@ SPI_copytupledesc(TupleDesc tupdesc) if (_SPI_curid + 1 == _SPI_connected) /* connected */ { if (_SPI_current != &(_SPI_stack[_SPI_curid + 1])) - elog(FATAL, "SPI: stack corrupted"); + elog(ERROR, "SPI stack corrupted"); oldcxt = MemoryContextSwitchTo(_SPI_current->savedcxt); } @@ -376,7 +380,7 @@ SPI_copytupleintoslot(HeapTuple tuple, TupleDesc tupdesc) if (_SPI_curid + 1 == _SPI_connected) /* connected */ { if (_SPI_current != &(_SPI_stack[_SPI_curid + 1])) - elog(FATAL, "SPI: stack corrupted"); + elog(ERROR, "SPI stack corrupted"); oldcxt = MemoryContextSwitchTo(_SPI_current->savedcxt); } @@ -414,7 +418,7 @@ SPI_modifytuple(Relation rel, HeapTuple tuple, int natts, int *attnum, if (_SPI_curid + 1 == _SPI_connected) /* connected */ { if (_SPI_current != &(_SPI_stack[_SPI_curid + 1])) - elog(FATAL, "SPI: stack corrupted"); + elog(ERROR, "SPI stack corrupted"); oldcxt = MemoryContextSwitchTo(_SPI_current->savedcxt); } SPI_result = 0; @@ -654,7 +658,7 @@ SPI_palloc(Size size) if (_SPI_curid + 1 == _SPI_connected) /* connected */ { if (_SPI_current != &(_SPI_stack[_SPI_curid + 1])) - elog(FATAL, "SPI: stack corrupted"); + elog(ERROR, "SPI stack corrupted"); oldcxt = MemoryContextSwitchTo(_SPI_current->savedcxt); } @@ -716,14 +720,20 @@ SPI_cursor_open(const char *name, void *plan, Datum *Values, const char *Nulls) /* Ensure that the plan contains only one regular SELECT query */ if (length(ptlist) != 1 || length(qtlist) != 1) - elog(ERROR, "cannot open multi-query plan as cursor"); + ereport(ERROR, + (errcode(ERRCODE_INVALID_CURSOR_DEFINITION), + errmsg("cannot open multi-query plan as cursor"))); queryTree = (Query *) lfirst((List *) lfirst(qtlist)); planTree = (Plan *) lfirst(ptlist); if (queryTree->commandType != CMD_SELECT) - elog(ERROR, "plan in SPI_cursor_open() is not a SELECT"); + ereport(ERROR, + (errcode(ERRCODE_INVALID_CURSOR_DEFINITION), + errmsg("cannot open non-SELECT query as cursor"))); if (queryTree->into != NULL) - elog(ERROR, "plan in SPI_cursor_open() must NOT be a SELECT INTO"); + ereport(ERROR, + (errcode(ERRCODE_INVALID_CURSOR_DEFINITION), + errmsg("cannot open SELECT INTO query as cursor"))); /* Increment CommandCounter to see changes made by now */ CommandCounterIncrement(); @@ -888,12 +898,12 @@ spi_dest_startup(DestReceiver *self, int operation, TupleDesc typeinfo) * _SPI_connected */ if (_SPI_curid != _SPI_connected || _SPI_connected < 0) - elog(FATAL, "SPI: improper call to spi_dest_startup"); + elog(ERROR, "improper call to spi_dest_startup"); if (_SPI_current != &(_SPI_stack[_SPI_curid])) - elog(FATAL, "SPI: stack corrupted in spi_dest_startup"); + elog(ERROR, "SPI stack corrupted"); if (_SPI_current->tuptable != NULL) - elog(FATAL, "SPI: improper call to spi_dest_startup"); + elog(ERROR, "improper call to spi_dest_startup"); oldcxt = _SPI_procmem(); /* switch to procedure memory context */ @@ -930,13 +940,13 @@ spi_printtup(HeapTuple tuple, TupleDesc tupdesc, DestReceiver *self) * _SPI_connected */ if (_SPI_curid != _SPI_connected || _SPI_connected < 0) - elog(FATAL, "SPI: improper call to spi_printtup"); + elog(ERROR, "improper call to spi_printtup"); if (_SPI_current != &(_SPI_stack[_SPI_curid])) - elog(FATAL, "SPI: stack corrupted in spi_printtup"); + elog(ERROR, "SPI stack corrupted"); tuptable = _SPI_current->tuptable; if (tuptable == NULL) - elog(FATAL, "SPI: improper call to spi_printtup"); + elog(ERROR, "improper call to spi_printtup"); oldcxt = MemoryContextSwitchTo(tuptable->tuptabcxt); @@ -1217,7 +1227,7 @@ _SPI_pquery(QueryDesc *queryDesc, bool runit, int tcount) if (operation == CMD_SELECT && queryDesc->dest->mydest == SPI) { if (_SPI_checktuples()) - elog(FATAL, "SPI_select: # of processed tuples check failed"); + elog(ERROR, "consistency check on SPI tuple count failed"); } if (queryDesc->dest->mydest == SPI) @@ -1274,7 +1284,7 @@ _SPI_cursor_operation(Portal portal, bool forward, int count, dest); if (dest->mydest == SPI && _SPI_checktuples()) - elog(FATAL, "SPI_fetch: # of processed tuples check failed"); + elog(ERROR, "consistency check on SPI tuple count failed"); /* Put the result into place for access by caller */ SPI_processed = _SPI_current->processed; @@ -1308,7 +1318,7 @@ _SPI_begin_call(bool execmem) return SPI_ERROR_UNCONNECTED; _SPI_curid++; if (_SPI_current != &(_SPI_stack[_SPI_curid])) - elog(FATAL, "SPI: stack corrupted"); + elog(ERROR, "SPI stack corrupted"); if (execmem) /* switch to the Executor memory context */ _SPI_execmem(); diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index 04e630451f..741b99c75f 100644 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: executor.h,v 1.95 2003/06/22 22:04:55 tgl Exp $ + * $Id: executor.h,v 1.96 2003/07/21 17:05:10 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -94,7 +94,7 @@ extern void ExecutorEnd(QueryDesc *queryDesc); extern void ExecutorRewind(QueryDesc *queryDesc); extern void ExecCheckRTPerms(List *rangeTable, CmdType operation); extern void ExecEndPlan(PlanState *planstate, EState *estate); -extern void ExecConstraints(const char *caller, ResultRelInfo *resultRelInfo, +extern void ExecConstraints(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate); extern TupleTableSlot *EvalPlanQual(EState *estate, Index rti, ItemPointer tid); diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h index 74476c77b0..438612db44 100644 --- a/src/include/utils/elog.h +++ b/src/include/utils/elog.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: elog.h,v 1.51 2003/07/21 01:59:11 tgl Exp $ + * $Id: elog.h,v 1.52 2003/07/21 17:05:11 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -124,6 +124,8 @@ /* Class 22 - Data Exception */ #define ERRCODE_DATA_EXCEPTION MAKE_SQLSTATE('2','2', '0','0','0') #define ERRCODE_ARRAY_ELEMENT_ERROR MAKE_SQLSTATE('2','2', '0','2','E') +/* SQL99's actual definition of "array element error" is subscript error */ +#define ERRCODE_ARRAY_SUBSCRIPT_ERROR ERRCODE_ARRAY_ELEMENT_ERROR #define ERRCODE_CHARACTER_NOT_IN_REPERTOIRE MAKE_SQLSTATE('2','2', '0','2','1') #define ERRCODE_DATETIME_FIELD_OVERFLOW MAKE_SQLSTATE('2','2', '0','0','8') #define ERRCODE_DIVISION_BY_ZERO MAKE_SQLSTATE('2','2', '0','1','2') @@ -215,6 +217,7 @@ #define ERRCODE_E_R_I_E_INVALID_SQLSTATE_RETURNED MAKE_SQLSTATE('3','9', '0','0','1') #define ERRCODE_E_R_I_E_NULL_VALUE_NOT_ALLOWED MAKE_SQLSTATE('3','9', '0','0','4') #define ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED MAKE_SQLSTATE('3','9', 'P','0','1') +#define ERRCODE_E_R_I_E_SRF_PROTOCOL_VIOLATED MAKE_SQLSTATE('3','9', 'P','0','2') /* Class 3D - Invalid Catalog Name */ #define ERRCODE_INVALID_CATALOG_NAME MAKE_SQLSTATE('3','D', '0','0','0') diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out index 7ade401290..ea4524dd54 100644 --- a/src/test/regress/expected/alter_table.out +++ b/src/test/regress/expected/alter_table.out @@ -399,7 +399,7 @@ create table atacc1 ( test int ); alter table atacc1 add constraint atacc_test1 check (test>3); -- should fail insert into atacc1 (test) values (2); -ERROR: ExecInsert: rejected due to CHECK constraint "atacc_test1" on "atacc1" +ERROR: new row for relation "atacc1" violates CHECK constraint "atacc_test1" -- should succeed insert into atacc1 (test) values (4); drop table atacc1; @@ -424,7 +424,7 @@ create table atacc1 ( test int, test2 int, test3 int); alter table atacc1 add constraint atacc_test1 check (test+test23), test2 int); alter table atacc1 add check (test2>test); -- should fail for $2 insert into atacc1 (test2, test) values (3, 4); -ERROR: ExecInsert: rejected due to CHECK constraint "$1" on "atacc1" +ERROR: new row for relation "atacc1" violates CHECK constraint "$1" drop table atacc1; -- inheritance related tests create table atacc1 (test int); @@ -442,11 +442,11 @@ create table atacc3 (test3 int) inherits (atacc1, atacc2); alter table atacc2 add constraint foo check (test2>0); -- fail and then succeed on atacc2 insert into atacc2 (test2) values (-3); -ERROR: ExecInsert: rejected due to CHECK constraint "foo" on "atacc2" +ERROR: new row for relation "atacc2" violates CHECK constraint "foo" insert into atacc2 (test2) values (3); -- fail and then succeed on atacc3 insert into atacc3 (test2) values (-3); -ERROR: ExecInsert: rejected due to CHECK constraint "foo" on "atacc3" +ERROR: new row for relation "atacc3" violates CHECK constraint "foo" insert into atacc3 (test2) values (3); drop table atacc3; drop table atacc2; @@ -458,7 +458,7 @@ create table atacc3 (test3 int) inherits (atacc1, atacc2); alter table only atacc2 add constraint foo check (test2>0); -- fail and then succeed on atacc2 insert into atacc2 (test2) values (-3); -ERROR: ExecInsert: rejected due to CHECK constraint "foo" on "atacc2" +ERROR: new row for relation "atacc2" violates CHECK constraint "foo" insert into atacc2 (test2) values (3); -- both succeed on atacc3 insert into atacc3 (test2) values (-3); @@ -539,7 +539,7 @@ ERROR: Cannot insert a duplicate key into unique index atacc_test1 insert into atacc1 (test) values (4); -- inserting NULL should fail insert into atacc1 (test) values(NULL); -ERROR: ExecInsert: Fail to add null value in not null attribute test +ERROR: null value for attribute "test" violates NOT NULL constraint -- try adding a second primary key (should fail) alter table atacc1 add constraint atacc_oid1 primary key(oid); ERROR: multiple primary keys for table "atacc1" are not allowed @@ -591,11 +591,11 @@ insert into atacc1 (test,test2) values (4,4); insert into atacc1 (test,test2) values (4,4); ERROR: Cannot insert a duplicate key into unique index atacc_test1 insert into atacc1 (test,test2) values (NULL,3); -ERROR: ExecInsert: Fail to add null value in not null attribute test +ERROR: null value for attribute "test" violates NOT NULL constraint insert into atacc1 (test,test2) values (3, NULL); -ERROR: ExecInsert: Fail to add null value in not null attribute test2 +ERROR: null value for attribute "test2" violates NOT NULL constraint insert into atacc1 (test,test2) values (NULL,NULL); -ERROR: ExecInsert: Fail to add null value in not null attribute test +ERROR: null value for attribute "test" violates NOT NULL constraint -- should all succeed insert into atacc1 (test,test2) values (4,5); insert into atacc1 (test,test2) values (5,4); @@ -609,7 +609,7 @@ insert into atacc1 (test2, test) values (3, 3); insert into atacc1 (test2, test) values (2, 3); ERROR: Cannot insert a duplicate key into unique index atacc1_pkey insert into atacc1 (test2, test) values (1, NULL); -ERROR: ExecInsert: Fail to add null value in not null attribute test +ERROR: null value for attribute "test" violates NOT NULL constraint drop table atacc1; -- alter table / alter column [set/drop] not null tests -- try altering system catalogs, should fail @@ -659,9 +659,9 @@ create table parent (a int); create table child (b varchar(255)) inherits (parent); alter table parent alter a set not null; insert into parent values (NULL); -ERROR: ExecInsert: Fail to add null value in not null attribute a +ERROR: null value for attribute "a" violates NOT NULL constraint insert into child (a, b) values (NULL, 'foo'); -ERROR: ExecInsert: Fail to add null value in not null attribute a +ERROR: null value for attribute "a" violates NOT NULL constraint alter table parent alter a drop not null; insert into parent values (NULL); insert into child (a, b) values (NULL, 'foo'); @@ -672,14 +672,14 @@ ERROR: attribute "a" contains NULL values delete from parent; alter table only parent alter a set not null; insert into parent values (NULL); -ERROR: ExecInsert: Fail to add null value in not null attribute a +ERROR: null value for attribute "a" violates NOT NULL constraint alter table child alter a set not null; insert into child (a, b) values (NULL, 'foo'); -ERROR: ExecInsert: Fail to add null value in not null attribute a +ERROR: null value for attribute "a" violates NOT NULL constraint delete from child; alter table child alter a set not null; insert into child (a, b) values (NULL, 'foo'); -ERROR: ExecInsert: Fail to add null value in not null attribute a +ERROR: null value for attribute "a" violates NOT NULL constraint drop table child; drop table parent; -- test setting and removing default values @@ -1232,7 +1232,7 @@ alter table p1 add column f2 text; NOTICE: merging definition of column "f2" for child "c1" insert into p1 values (1,2,'abc'); insert into c1 values(11,'xyz',33,0); -- should fail -ERROR: ExecInsert: rejected due to CHECK constraint "p1_a1" on "c1" +ERROR: new row for relation "c1" violates CHECK constraint "p1_a1" insert into c1 values(11,'xyz',33,22); select * from p1; f1 | a1 | f2 diff --git a/src/test/regress/expected/domain.out b/src/test/regress/expected/domain.out index 68e3e7a963..0823bc69df 100644 --- a/src/test/regress/expected/domain.out +++ b/src/test/regress/expected/domain.out @@ -111,26 +111,26 @@ create table nulltest , col5 dcheck CHECK (col5 IN ('c', 'd')) ); INSERT INTO nulltest DEFAULT VALUES; -ERROR: Domain dnotnull does not allow NULL values +ERROR: domain dnotnull does not allow NULL values INSERT INTO nulltest values ('a', 'b', 'c', 'd', 'c'); -- Good insert into nulltest values ('a', 'b', 'c', 'd', NULL); -ERROR: Domain dcheck does not allow NULL values +ERROR: domain dcheck does not allow NULL values insert into nulltest values ('a', 'b', 'c', 'd', 'a'); -ERROR: ExecInsert: rejected due to CHECK constraint "nulltest_col5" on "nulltest" +ERROR: new row for relation "nulltest" violates CHECK constraint "nulltest_col5" INSERT INTO nulltest values (NULL, 'b', 'c', 'd', 'd'); -ERROR: Domain dnotnull does not allow NULL values +ERROR: domain dnotnull does not allow NULL values INSERT INTO nulltest values ('a', NULL, 'c', 'd', 'c'); -ERROR: Domain dnotnull does not allow NULL values +ERROR: domain dnotnull does not allow NULL values INSERT INTO nulltest values ('a', 'b', NULL, 'd', 'c'); -ERROR: ExecInsert: Fail to add null value in not null attribute col3 +ERROR: null value for attribute "col3" violates NOT NULL constraint INSERT INTO nulltest values ('a', 'b', 'c', NULL, 'd'); -- Good -- Test copy COPY nulltest FROM stdin; --fail -ERROR: Domain dcheck does not allow NULL values +ERROR: domain dcheck does not allow NULL values CONTEXT: COPY FROM, line 1 -- Last row is bad COPY nulltest FROM stdin; -ERROR: CopyFrom: rejected due to CHECK constraint "nulltest_col5" on "nulltest" +ERROR: new row for relation "nulltest" violates CHECK constraint "nulltest_col5" CONTEXT: COPY FROM, line 3 select * from nulltest; col1 | col2 | col3 | col4 | col5 @@ -147,11 +147,11 @@ SELECT cast('1' as dnotnull); (1 row) SELECT cast(NULL as dnotnull); -- fail -ERROR: Domain dnotnull does not allow NULL values +ERROR: domain dnotnull does not allow NULL values SELECT cast(cast(NULL as dnull) as dnotnull); -- fail -ERROR: Domain dnotnull does not allow NULL values +ERROR: domain dnotnull does not allow NULL values SELECT cast(col4 as dnotnull) from nulltest; -- fail -ERROR: Domain dnotnull does not allow NULL values +ERROR: domain dnotnull does not allow NULL values -- cleanup drop table nulltest; drop domain dnotnull restrict; @@ -208,7 +208,7 @@ alter domain dnotnulltest set not null; alter domain dnotnulltest set not null; -- fails NOTICE: "dnotnulltest" is already set to NOT NULL update domnotnull set col1 = null; -- fails -ERROR: Domain dnotnulltest does not allow NULL values +ERROR: domain dnotnulltest does not allow NULL values alter domain dnotnulltest drop not null; alter domain dnotnulltest drop not null; -- fails NOTICE: "dnotnulltest" is already set to NULL @@ -255,13 +255,13 @@ ERROR: relation "domcontest" attribute "col1" contains values that violate the alter domain con add constraint t check (VALUE < 34); alter domain con add check (VALUE > 0); insert into domcontest values (-5); -- fails -ERROR: ExecEvalCoerceToDomain: Domain con constraint $1 failed +ERROR: value for domain con violates CHECK constraint "$1" insert into domcontest values (42); -- fails -ERROR: ExecEvalCoerceToDomain: Domain con constraint t failed +ERROR: value for domain con violates CHECK constraint "t" insert into domcontest values (5); alter domain con drop constraint t; insert into domcontest values (-5); --fails -ERROR: ExecEvalCoerceToDomain: Domain con constraint $1 failed +ERROR: value for domain con violates CHECK constraint "$1" insert into domcontest values (42); -- Confirm ALTER DOMAIN with RULES. create table domtab (col1 integer); @@ -278,7 +278,7 @@ select * from domview; alter domain dom set not null; select * from domview; -- fail -ERROR: Domain dom does not allow NULL values +ERROR: domain dom does not allow NULL values alter domain dom drop not null; select * from domview; col1 @@ -289,7 +289,7 @@ select * from domview; alter domain dom add constraint domchkgt6 check(value > 6); select * from domview; --fail -ERROR: ExecEvalCoerceToDomain: Domain dom constraint domchkgt6 failed +ERROR: value for domain dom violates CHECK constraint "domchkgt6" alter domain dom drop constraint domchkgt6 restrict; select * from domview; col1 diff --git a/src/test/regress/expected/inherit.out b/src/test/regress/expected/inherit.out index 8b7a631815..28c9a785ca 100644 --- a/src/test/regress/expected/inherit.out +++ b/src/test/regress/expected/inherit.out @@ -538,7 +538,7 @@ SELECT relname, d.* FROM ONLY d, pg_class where d.tableoid = pg_class.oid; CREATE TEMP TABLE z (b TEXT, PRIMARY KEY(aa, b)) inherits (a); NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "z_pkey" for table "z" INSERT INTO z VALUES (NULL, 'text'); -- should fail -ERROR: ExecInsert: Fail to add null value in not null attribute aa +ERROR: null value for attribute "aa" violates NOT NULL constraint -- Check UPDATE with inherited target and an inherited source table create temp table foo(f1 int, f2 int); create temp table foo2(f3 int) inherits (foo); diff --git a/src/test/regress/expected/insert.out b/src/test/regress/expected/insert.out index 1a5225b0a3..758e319ab0 100644 --- a/src/test/regress/expected/insert.out +++ b/src/test/regress/expected/insert.out @@ -3,7 +3,7 @@ -- create table inserttest (col1 int4, col2 int4 NOT NULL, col3 text default 'testing'); insert into inserttest (col1, col2, col3) values (DEFAULT, DEFAULT, DEFAULT); -ERROR: ExecInsert: Fail to add null value in not null attribute col2 +ERROR: null value for attribute "col2" violates NOT NULL constraint insert into inserttest (col2, col3) values (3, DEFAULT); insert into inserttest (col1, col2, col3) values (DEFAULT, 5, DEFAULT); insert into inserttest values (DEFAULT, 5, 'test'); diff --git a/src/test/regress/expected/sequence.out b/src/test/regress/expected/sequence.out index a8f4cc96f1..fe102adab8 100644 --- a/src/test/regress/expected/sequence.out +++ b/src/test/regress/expected/sequence.out @@ -9,7 +9,7 @@ INSERT INTO serialTest VALUES ('foo'); INSERT INTO serialTest VALUES ('bar'); INSERT INTO serialTest VALUES ('force', 100); INSERT INTO serialTest VALUES ('wrong', NULL); -ERROR: ExecInsert: Fail to add null value in not null attribute f2 +ERROR: null value for attribute "f2" violates NOT NULL constraint SELECT * FROM serialTest; f1 | f2 diff --git a/src/test/regress/output/constraints.source b/src/test/regress/output/constraints.source index a2911f190a..c35bc8b3f2 100644 --- a/src/test/regress/output/constraints.source +++ b/src/test/regress/output/constraints.source @@ -62,12 +62,12 @@ CREATE TABLE CHECK_TBL (x int, INSERT INTO CHECK_TBL VALUES (5); INSERT INTO CHECK_TBL VALUES (4); INSERT INTO CHECK_TBL VALUES (3); -ERROR: ExecInsert: rejected due to CHECK constraint "check_con" on "check_tbl" +ERROR: new row for relation "check_tbl" violates CHECK constraint "check_con" INSERT INTO CHECK_TBL VALUES (2); -ERROR: ExecInsert: rejected due to CHECK constraint "check_con" on "check_tbl" +ERROR: new row for relation "check_tbl" violates CHECK constraint "check_con" INSERT INTO CHECK_TBL VALUES (6); INSERT INTO CHECK_TBL VALUES (1); -ERROR: ExecInsert: rejected due to CHECK constraint "check_con" on "check_tbl" +ERROR: new row for relation "check_tbl" violates CHECK constraint "check_con" SELECT '' AS three, * FROM CHECK_TBL; three | x -------+--- @@ -82,13 +82,13 @@ CREATE TABLE CHECK2_TBL (x int, y text, z int, CHECK (x > 3 and y <> 'check failed' and z < 8)); INSERT INTO CHECK2_TBL VALUES (4, 'check ok', -2); INSERT INTO CHECK2_TBL VALUES (1, 'x check failed', -2); -ERROR: ExecInsert: rejected due to CHECK constraint "sequence_con" on "check2_tbl" +ERROR: new row for relation "check2_tbl" violates CHECK constraint "sequence_con" INSERT INTO CHECK2_TBL VALUES (5, 'z check failed', 10); -ERROR: ExecInsert: rejected due to CHECK constraint "sequence_con" on "check2_tbl" +ERROR: new row for relation "check2_tbl" violates CHECK constraint "sequence_con" INSERT INTO CHECK2_TBL VALUES (0, 'check failed', -2); -ERROR: ExecInsert: rejected due to CHECK constraint "sequence_con" on "check2_tbl" +ERROR: new row for relation "check2_tbl" violates CHECK constraint "sequence_con" INSERT INTO CHECK2_TBL VALUES (6, 'check failed', 11); -ERROR: ExecInsert: rejected due to CHECK constraint "sequence_con" on "check2_tbl" +ERROR: new row for relation "check2_tbl" violates CHECK constraint "sequence_con" INSERT INTO CHECK2_TBL VALUES (7, 'check ok', 7); SELECT '' AS two, * from CHECK2_TBL; two | x | y | z @@ -107,7 +107,7 @@ CREATE TABLE INSERT_TBL (x INT DEFAULT nextval('insert_seq'), CONSTRAINT INSERT_CON CHECK (x >= 3 AND y <> 'check failed' AND x < 8), CHECK (x + z = 0)); INSERT INTO INSERT_TBL(x,z) VALUES (2, -2); -ERROR: ExecInsert: rejected due to CHECK constraint "insert_con" on "insert_tbl" +ERROR: new row for relation "insert_tbl" violates CHECK constraint "insert_con" SELECT '' AS zero, * FROM INSERT_TBL; zero | x | y | z ------+---+---+--- @@ -120,13 +120,13 @@ SELECT 'one' AS one, nextval('insert_seq'); (1 row) INSERT INTO INSERT_TBL(y) VALUES ('Y'); -ERROR: ExecInsert: rejected due to CHECK constraint "insert_con" on "insert_tbl" +ERROR: new row for relation "insert_tbl" violates CHECK constraint "insert_con" INSERT INTO INSERT_TBL(y) VALUES ('Y'); INSERT INTO INSERT_TBL(x,z) VALUES (1, -2); -ERROR: ExecInsert: rejected due to CHECK constraint "$1" on "insert_tbl" +ERROR: new row for relation "insert_tbl" violates CHECK constraint "$1" INSERT INTO INSERT_TBL(z,x) VALUES (-7, 7); INSERT INTO INSERT_TBL VALUES (5, 'check failed', -5); -ERROR: ExecInsert: rejected due to CHECK constraint "insert_con" on "insert_tbl" +ERROR: new row for relation "insert_tbl" violates CHECK constraint "insert_con" INSERT INTO INSERT_TBL VALUES (7, '!check failed', -7); INSERT INTO INSERT_TBL(y) VALUES ('-!NULL-'); SELECT '' AS four, * FROM INSERT_TBL; @@ -139,9 +139,9 @@ SELECT '' AS four, * FROM INSERT_TBL; (4 rows) INSERT INTO INSERT_TBL(y,z) VALUES ('check failed', 4); -ERROR: ExecInsert: rejected due to CHECK constraint "$1" on "insert_tbl" +ERROR: new row for relation "insert_tbl" violates CHECK constraint "$1" INSERT INTO INSERT_TBL(x,y) VALUES (5, 'check failed'); -ERROR: ExecInsert: rejected due to CHECK constraint "insert_con" on "insert_tbl" +ERROR: new row for relation "insert_tbl" violates CHECK constraint "insert_con" INSERT INTO INSERT_TBL(x,y) VALUES (5, '!check failed'); INSERT INTO INSERT_TBL(y) VALUES ('-!NULL-'); SELECT '' AS six, * FROM INSERT_TBL; @@ -162,7 +162,7 @@ SELECT 'seven' AS one, nextval('insert_seq'); (1 row) INSERT INTO INSERT_TBL(y) VALUES ('Y'); -ERROR: ExecInsert: rejected due to CHECK constraint "insert_con" on "insert_tbl" +ERROR: new row for relation "insert_tbl" violates CHECK constraint "insert_con" SELECT 'eight' AS one, currval('insert_seq'); one | currval -------+--------- @@ -193,11 +193,11 @@ CREATE TABLE INSERT_CHILD (cx INT default 42, INHERITS (INSERT_TBL); INSERT INTO INSERT_CHILD(x,z,cy) VALUES (7,-7,11); INSERT INTO INSERT_CHILD(x,z,cy) VALUES (7,-7,6); -ERROR: ExecInsert: rejected due to CHECK constraint "insert_child_cy" on "insert_child" +ERROR: new row for relation "insert_child" violates CHECK constraint "insert_child_cy" INSERT INTO INSERT_CHILD(x,z,cy) VALUES (6,-7,7); -ERROR: ExecInsert: rejected due to CHECK constraint "$1" on "insert_child" +ERROR: new row for relation "insert_child" violates CHECK constraint "$1" INSERT INTO INSERT_CHILD(x,y,z,cy) VALUES (6,'check failed',-6,7); -ERROR: ExecInsert: rejected due to CHECK constraint "insert_con" on "insert_child" +ERROR: new row for relation "insert_child" violates CHECK constraint "insert_con" SELECT * FROM INSERT_CHILD; x | y | z | cx | cy ---+--------+----+----+---- @@ -227,7 +227,7 @@ SELECT '' AS three, * FROM INSERT_TBL; INSERT INTO INSERT_TBL SELECT * FROM tmp WHERE yd = 'try again'; INSERT INTO INSERT_TBL(y,z) SELECT yd, -7 FROM tmp WHERE yd = 'try again'; INSERT INTO INSERT_TBL(y,z) SELECT yd, -8 FROM tmp WHERE yd = 'try again'; -ERROR: ExecInsert: rejected due to CHECK constraint "insert_con" on "insert_tbl" +ERROR: new row for relation "insert_tbl" violates CHECK constraint "insert_con" SELECT '' AS four, * FROM INSERT_TBL; four | x | y | z ------+---+---------------+---- @@ -246,7 +246,7 @@ UPDATE INSERT_TBL SET x = NULL WHERE x = 5; UPDATE INSERT_TBL SET x = 6 WHERE x = 6; UPDATE INSERT_TBL SET x = -z, z = -x; UPDATE INSERT_TBL SET x = z, z = x; -ERROR: ExecUpdate: rejected due to CHECK constraint "insert_con" on "insert_tbl" +ERROR: new row for relation "insert_tbl" violates CHECK constraint "insert_con" SELECT * FROM INSERT_TBL; x | y | z ---+---------------+---- @@ -273,7 +273,7 @@ SELECT '' AS two, * FROM COPY_TBL; (2 rows) COPY COPY_TBL FROM '@abs_srcdir@/data/constrf.data'; -ERROR: CopyFrom: rejected due to CHECK constraint "copy_con" on "copy_tbl" +ERROR: new row for relation "copy_tbl" violates CHECK constraint "copy_con" CONTEXT: COPY FROM, line 2 SELECT * FROM COPY_TBL; x | y | z @@ -294,7 +294,7 @@ ERROR: Cannot insert a duplicate key into unique index primary_tbl_pkey INSERT INTO PRIMARY_TBL VALUES (4, 'three'); INSERT INTO PRIMARY_TBL VALUES (5, 'one'); INSERT INTO PRIMARY_TBL (t) VALUES ('six'); -ERROR: ExecInsert: Fail to add null value in not null attribute i +ERROR: null value for attribute "i" violates NOT NULL constraint SELECT '' AS four, * FROM PRIMARY_TBL; four | i | t ------+---+------- @@ -314,7 +314,7 @@ INSERT INTO PRIMARY_TBL VALUES (1, 'three'); INSERT INTO PRIMARY_TBL VALUES (4, 'three'); INSERT INTO PRIMARY_TBL VALUES (5, 'one'); INSERT INTO PRIMARY_TBL (t) VALUES ('six'); -ERROR: ExecInsert: Fail to add null value in not null attribute i +ERROR: null value for attribute "i" violates NOT NULL constraint SELECT '' AS three, * FROM PRIMARY_TBL; three | i | t -------+---+-------