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

Commit5e6d691

Browse files
committed
Error message editing in backend/executor.
1 parent82f18c4 commit5e6d691

28 files changed

+397
-297
lines changed

‎src/backend/commands/copy.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.202 2003/07/20 21:56:32 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.203 2003/07/21 17:04:58 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1581,7 +1581,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
15811581
* Check the constraints of the tuple
15821582
*/
15831583
if (rel->rd_att->constr)
1584-
ExecConstraints("CopyFrom",resultRelInfo,slot,estate);
1584+
ExecConstraints(resultRelInfo,slot,estate);
15851585

15861586
/*
15871587
* OK, store the tuple and create index entries for it

‎src/backend/executor/execAmi.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
*$Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.71 2003/05/27 17:49:45 momjian Exp $
9+
*$Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.72 2003/07/21 17:05:00 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -160,9 +160,8 @@ ExecReScan(PlanState *node, ExprContext *exprCtxt)
160160
break;
161161

162162
default:
163-
elog(ERROR,"ExecReScan: node type %d not supported",
164-
nodeTag(node));
165-
return;
163+
elog(ERROR,"unrecognized node type: %d", (int)nodeTag(node));
164+
break;
166165
}
167166

168167
if (node->chgParam!=NULL)
@@ -208,8 +207,7 @@ ExecMarkPos(PlanState *node)
208207

209208
default:
210209
/* don't make hard error unless caller asks to restore... */
211-
elog(DEBUG2,"ExecMarkPos: node type %d not supported",
212-
nodeTag(node));
210+
elog(DEBUG2,"unrecognized node type: %d", (int)nodeTag(node));
213211
break;
214212
}
215213
}
@@ -249,8 +247,7 @@ ExecRestrPos(PlanState *node)
249247
break;
250248

251249
default:
252-
elog(ERROR,"ExecRestrPos: node type %d not supported",
253-
nodeTag(node));
250+
elog(ERROR,"unrecognized node type: %d", (int)nodeTag(node));
254251
break;
255252
}
256253
}

‎src/backend/executor/execGrouping.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/executor/execGrouping.c,v 1.3 2003/06/22 22:04:54 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/executor/execGrouping.c,v 1.4 2003/07/21 17:05:08 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -249,8 +249,8 @@ execTuplesHashPrepare(TupleDesc tupdesc,
249249
eq_function=oprfuncid(optup);
250250
ReleaseSysCache(optup);
251251
hash_function=get_op_hash_function(eq_opr);
252-
if (!OidIsValid(hash_function))
253-
elog(ERROR,"Could not find hash function for hash operator %u",
252+
if (!OidIsValid(hash_function))/* should not happen */
253+
elog(ERROR,"could not find hash function for hash operator %u",
254254
eq_opr);
255255
fmgr_info(eq_function,&(*eqfunctions)[i]);
256256
fmgr_info(hash_function,&(*hashfunctions)[i]);

‎src/backend/executor/execMain.c

Lines changed: 55 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
*
2828
* IDENTIFICATION
29-
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.209 2003/05/08 18:16:36 tgl Exp $
29+
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.210 2003/07/21 17:05:08 tgl Exp $
3030
*
3131
*-------------------------------------------------------------------------
3232
*/
@@ -410,8 +410,8 @@ ExecCheckRTEPerms(RangeTblEntry *rte, CmdType operation)
410410
aclcheck_result=CHECK(ACL_DELETE);
411411
break;
412412
default:
413-
elog(ERROR,"ExecCheckRTEPerms: bogusoperation %d",
414-
operation);
413+
elog(ERROR,"unrecognizedoperation code: %d",
414+
(int)operation);
415415
aclcheck_result=ACLCHECK_OK;/* keep compiler quiet */
416416
break;
417417
}
@@ -455,7 +455,9 @@ ExecCheckXactReadOnly(Query *parsetree, CmdType operation)
455455
return;
456456

457457
fail:
458-
elog(ERROR,"transaction is read-only");
458+
ereport(ERROR,
459+
(errcode(ERRCODE_READ_ONLY_SQL_TRANSACTION),
460+
errmsg("transaction is read-only")));
459461
}
460462

461463

@@ -833,16 +835,22 @@ initResultRelInfo(ResultRelInfo *resultRelInfo,
833835
switch (resultRelationDesc->rd_rel->relkind)
834836
{
835837
caseRELKIND_SEQUENCE:
836-
elog(ERROR,"You can't change sequence relation %s",
837-
RelationGetRelationName(resultRelationDesc));
838+
ereport(ERROR,
839+
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
840+
errmsg("cannot change sequence relation \"%s\"",
841+
RelationGetRelationName(resultRelationDesc))));
838842
break;
839843
caseRELKIND_TOASTVALUE:
840-
elog(ERROR,"You can't change toast relation %s",
841-
RelationGetRelationName(resultRelationDesc));
844+
ereport(ERROR,
845+
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
846+
errmsg("cannot change toast relation \"%s\"",
847+
RelationGetRelationName(resultRelationDesc))));
842848
break;
843849
caseRELKIND_VIEW:
844-
elog(ERROR,"You can't change view relation %s",
845-
RelationGetRelationName(resultRelationDesc));
850+
ereport(ERROR,
851+
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
852+
errmsg("cannot change view relation \"%s\"",
853+
RelationGetRelationName(resultRelationDesc))));
846854
break;
847855
}
848856

@@ -1056,11 +1064,11 @@ lnext:;
10561064
"ctid",
10571065
&datum,
10581066
&isNull))
1059-
elog(ERROR,"ExecutePlan: NO (junk) `ctid' was found!");
1067+
elog(ERROR,"could not findjunkctid column");
10601068

10611069
/* shouldn't ever get a null result... */
10621070
if (isNull)
1063-
elog(ERROR,"ExecutePlan: (junk) `ctid' is NULL!");
1071+
elog(ERROR,"ctid is NULL");
10641072

10651073
tupleid= (ItemPointer)DatumGetPointer(datum);
10661074
tuple_ctid=*tupleid;/* make sure we don't free the
@@ -1085,13 +1093,12 @@ lnext:;
10851093
erm->resname,
10861094
&datum,
10871095
&isNull))
1088-
elog(ERROR,"ExecutePlan: NO (junk) `%s' was found!",
1096+
elog(ERROR,"could not findjunk \"%s\" column",
10891097
erm->resname);
10901098

10911099
/* shouldn't ever get a null result... */
10921100
if (isNull)
1093-
elog(ERROR,"ExecutePlan: (junk) `%s' is NULL!",
1094-
erm->resname);
1101+
elog(ERROR,"\"%s\" is NULL",erm->resname);
10951102

10961103
tuple.t_self=*((ItemPointer)DatumGetPointer(datum));
10971104
test=heap_mark4update(erm->relation,&tuple,&buffer,
@@ -1108,7 +1115,9 @@ lnext:;
11081115

11091116
caseHeapTupleUpdated:
11101117
if (XactIsoLevel==XACT_SERIALIZABLE)
1111-
elog(ERROR,"Can't serialize access due to concurrent update");
1118+
ereport(ERROR,
1119+
(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
1120+
errmsg("cannot serialize access due to concurrent update")));
11121121
if (!(ItemPointerEquals(&(tuple.t_self),
11131122
(ItemPointer)DatumGetPointer(datum))))
11141123
{
@@ -1129,7 +1138,8 @@ lnext:;
11291138
gotolnext;
11301139

11311140
default:
1132-
elog(ERROR,"Unknown status %u from heap_mark4update",test);
1141+
elog(ERROR,"unrecognized heap_mark4update status: %u",
1142+
test);
11331143
return (NULL);
11341144
}
11351145
}
@@ -1178,7 +1188,8 @@ lnext:;
11781188
break;
11791189

11801190
default:
1181-
elog(LOG,"ExecutePlan: unknown operation in queryDesc");
1191+
elog(ERROR,"unrecognized operation code: %d",
1192+
(int)operation);
11821193
result=NULL;
11831194
break;
11841195
}
@@ -1321,7 +1332,7 @@ ExecInsert(TupleTableSlot *slot,
13211332
* Check the constraints of the tuple
13221333
*/
13231334
if (resultRelationDesc->rd_att->constr)
1324-
ExecConstraints("ExecInsert",resultRelInfo,slot,estate);
1335+
ExecConstraints(resultRelInfo,slot,estate);
13251336

13261337
/*
13271338
* insert the tuple
@@ -1403,7 +1414,9 @@ ldelete:;
14031414

14041415
caseHeapTupleUpdated:
14051416
if (XactIsoLevel==XACT_SERIALIZABLE)
1406-
elog(ERROR,"Can't serialize access due to concurrent update");
1417+
ereport(ERROR,
1418+
(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
1419+
errmsg("cannot serialize access due to concurrent update")));
14071420
elseif (!(ItemPointerEquals(tupleid,&ctid)))
14081421
{
14091422
TupleTableSlot*epqslot=EvalPlanQual(estate,
@@ -1419,7 +1432,7 @@ ldelete:;
14191432
return;
14201433

14211434
default:
1422-
elog(ERROR,"Unknownstatus %u from heap_delete",result);
1435+
elog(ERROR,"unrecognized heap_deletestatus: %u",result);
14231436
return;
14241437
}
14251438

@@ -1466,10 +1479,7 @@ ExecUpdate(TupleTableSlot *slot,
14661479
* abort the operation if not running transactions
14671480
*/
14681481
if (IsBootstrapProcessingMode())
1469-
{
1470-
elog(WARNING,"ExecUpdate: UPDATE can't run without transactions");
1471-
return;
1472-
}
1482+
elog(ERROR,"cannot UPDATE during bootstrap");
14731483

14741484
/*
14751485
* get the heap tuple out of the tuple table slot
@@ -1519,7 +1529,7 @@ ExecUpdate(TupleTableSlot *slot,
15191529
*/
15201530
lreplace:;
15211531
if (resultRelationDesc->rd_att->constr)
1522-
ExecConstraints("ExecUpdate",resultRelInfo,slot,estate);
1532+
ExecConstraints(resultRelInfo,slot,estate);
15231533

15241534
/*
15251535
* replace the heap tuple
@@ -1538,7 +1548,9 @@ lreplace:;
15381548

15391549
caseHeapTupleUpdated:
15401550
if (XactIsoLevel==XACT_SERIALIZABLE)
1541-
elog(ERROR,"Can't serialize access due to concurrent update");
1551+
ereport(ERROR,
1552+
(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
1553+
errmsg("cannot serialize access due to concurrent update")));
15421554
elseif (!(ItemPointerEquals(tupleid,&ctid)))
15431555
{
15441556
TupleTableSlot*epqslot=EvalPlanQual(estate,
@@ -1558,7 +1570,7 @@ lreplace:;
15581570
return;
15591571

15601572
default:
1561-
elog(ERROR,"Unknownstatus %u from heap_update",result);
1573+
elog(ERROR,"unrecognized heap_updatestatus: %u",result);
15621574
return;
15631575
}
15641576

@@ -1591,7 +1603,7 @@ lreplace:;
15911603
ExecARUpdateTriggers(estate,resultRelInfo,tupleid,tuple);
15921604
}
15931605

1594-
staticchar*
1606+
staticconstchar*
15951607
ExecRelCheck(ResultRelInfo*resultRelInfo,
15961608
TupleTableSlot*slot,EState*estate)
15971609
{
@@ -1646,11 +1658,11 @@ ExecRelCheck(ResultRelInfo *resultRelInfo,
16461658
}
16471659

16481660
/* NULL result means no error */
1649-
return(char*)NULL;
1661+
returnNULL;
16501662
}
16511663

16521664
void
1653-
ExecConstraints(constchar*caller,ResultRelInfo*resultRelInfo,
1665+
ExecConstraints(ResultRelInfo*resultRelInfo,
16541666
TupleTableSlot*slot,EState*estate)
16551667
{
16561668
Relationrel=resultRelInfo->ri_RelationDesc;
@@ -1668,18 +1680,22 @@ ExecConstraints(const char *caller, ResultRelInfo *resultRelInfo,
16681680
{
16691681
if (rel->rd_att->attrs[attrChk-1]->attnotnull&&
16701682
heap_attisnull(tuple,attrChk))
1671-
elog(ERROR,"%s: Fail to add null value in not null attribute %s",
1672-
caller,NameStr(rel->rd_att->attrs[attrChk-1]->attname));
1683+
ereport(ERROR,
1684+
(errcode(ERRCODE_NOT_NULL_VIOLATION),
1685+
errmsg("null value for attribute \"%s\" violates NOT NULL constraint",
1686+
NameStr(rel->rd_att->attrs[attrChk-1]->attname))));
16731687
}
16741688
}
16751689

16761690
if (constr->num_check>0)
16771691
{
1678-
char*failed;
1692+
constchar*failed;
16791693

16801694
if ((failed=ExecRelCheck(resultRelInfo,slot,estate))!=NULL)
1681-
elog(ERROR,"%s: rejected due to CHECK constraint \"%s\" on \"%s\"",
1682-
caller,failed,RelationGetRelationName(rel));
1695+
ereport(ERROR,
1696+
(errcode(ERRCODE_CHECK_VIOLATION),
1697+
errmsg("new row for relation \"%s\" violates CHECK constraint \"%s\"",
1698+
RelationGetRelationName(rel),failed)));
16831699
}
16841700
}
16851701

@@ -1721,7 +1737,7 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid)
17211737
}
17221738
}
17231739
if (relation==NULL)
1724-
elog(ERROR,"EvalPlanQual: can'tfindRTE %d", (int)rti);
1740+
elog(ERROR,"cannotfindRowMark for RT index %u",rti);
17251741
}
17261742

17271743
/*
@@ -1738,8 +1754,9 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid)
17381754
{
17391755
TransactionIdxwait=SnapshotDirty->xmax;
17401756

1757+
/* xmin should not be dirty... */
17411758
if (TransactionIdIsValid(SnapshotDirty->xmin))
1742-
elog(ERROR,"EvalPlanQual:t_xmin is uncommitted?!");
1759+
elog(ERROR,"t_xmin is uncommittedin tuple to be updated");
17431760

17441761
/*
17451762
* If tuple is being updated by other transaction then we have

‎src/backend/executor/execProcnode.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*
1414
* IDENTIFICATION
15-
* $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.36 2003/05/05 17:57:47 tgl Exp $
15+
* $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.37 2003/07/21 17:05:08 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -214,8 +214,7 @@ ExecInitNode(Plan *node, EState *estate)
214214
break;
215215

216216
default:
217-
elog(ERROR,"ExecInitNode: node type %d unsupported",
218-
(int)nodeTag(node));
217+
elog(ERROR,"unrecognized node type: %d", (int)nodeTag(node));
219218
result=NULL;/* keep compiler quiet */
220219
break;
221220
}
@@ -374,8 +373,7 @@ ExecProcNode(PlanState *node)
374373
break;
375374

376375
default:
377-
elog(ERROR,"ExecProcNode: node type %d unsupported",
378-
(int)nodeTag(node));
376+
elog(ERROR,"unrecognized node type: %d", (int)nodeTag(node));
379377
result=NULL;
380378
break;
381379
}
@@ -467,8 +465,7 @@ ExecCountSlotsNode(Plan *node)
467465
returnExecCountSlotsLimit((Limit*)node);
468466

469467
default:
470-
elog(ERROR,"ExecCountSlotsNode: node type %d unsupported",
471-
(int)nodeTag(node));
468+
elog(ERROR,"unrecognized node type: %d", (int)nodeTag(node));
472469
break;
473470
}
474471

@@ -596,8 +593,7 @@ ExecEndNode(PlanState *node)
596593
break;
597594

598595
default:
599-
elog(ERROR,"ExecEndNode: node type %d unsupported",
600-
(int)nodeTag(node));
596+
elog(ERROR,"unrecognized node type: %d", (int)nodeTag(node));
601597
break;
602598
}
603599
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp