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

Commitec7aa4b

Browse files
committed
Error message editing in backend/access.
1 parentc6106d9 commitec7aa4b

33 files changed

+702
-533
lines changed

‎src/backend/access/common/heaptuple.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.83 2002/09/27 15:04:08 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.84 2003/07/21 20:29:37 tgl Exp $
1313
*
1414
* NOTES
1515
* The old interface functions have been converted to macros
@@ -173,13 +173,11 @@ heap_attisnull(HeapTuple tup, int attnum)
173173
caseMinCommandIdAttributeNumber:
174174
caseMaxTransactionIdAttributeNumber:
175175
caseMaxCommandIdAttributeNumber:
176+
/* these are never null */
176177
break;
177178

178-
case0:
179-
elog(ERROR,"heap_attisnull: zero attnum disallowed");
180-
181179
default:
182-
elog(ERROR,"heap_attisnull: undefined negativeattnum");
180+
elog(ERROR,"invalid attnum: %d",attnum);
183181
}
184182

185183
return0;
@@ -457,7 +455,7 @@ heap_getsysattr(HeapTuple tup, int attnum, bool *isnull)
457455
result=ObjectIdGetDatum(tup->t_tableOid);
458456
break;
459457
default:
460-
elog(ERROR,"heap_getsysattr:invalid attnum %d",attnum);
458+
elog(ERROR,"invalid attnum: %d",attnum);
461459
result=0;/* keep compiler quiet */
462460
break;
463461
}
@@ -581,8 +579,10 @@ heap_formtuple(TupleDesc tupleDescriptor,
581579
intnumberOfAttributes=tupleDescriptor->natts;
582580

583581
if (numberOfAttributes>MaxTupleAttributeNumber)
584-
elog(ERROR,"heap_formtuple: numberOfAttributes %d exceeds limit %d",
585-
numberOfAttributes,MaxTupleAttributeNumber);
582+
ereport(ERROR,
583+
(errcode(ERRCODE_TOO_MANY_COLUMNS),
584+
errmsg("number of attributes %d exceeds limit, %d",
585+
numberOfAttributes,MaxTupleAttributeNumber)));
586586

587587
for (i=0;i<numberOfAttributes;i++)
588588
{
@@ -666,14 +666,11 @@ heap_modifytuple(HeapTuple tuple,
666666
* allocate and fill *value and *nulls arrays from either the tuple or
667667
* the repl information, as appropriate.
668668
*/
669-
value= (Datum*)palloc(numberOfAttributes*sizeof*value);
670-
nulls= (char*)palloc(numberOfAttributes*sizeof*nulls);
669+
value= (Datum*)palloc(numberOfAttributes*sizeof(Datum));
670+
nulls= (char*)palloc(numberOfAttributes*sizeof(char));
671671

672-
for (attoff=0;
673-
attoff<numberOfAttributes;
674-
attoff+=1)
672+
for (attoff=0;attoff<numberOfAttributes;attoff++)
675673
{
676-
677674
if (repl[attoff]==' ')
678675
{
679676
value[attoff]=heap_getattr(tuple,
@@ -683,13 +680,13 @@ heap_modifytuple(HeapTuple tuple,
683680
nulls[attoff]= (isNull) ?'n' :' ';
684681

685682
}
686-
elseif (repl[attoff]!='r')
687-
elog(ERROR,"heap_modifytuple: repl is \\%3d",repl[attoff]);
688-
else
689-
{/* == 'r' */
683+
elseif (repl[attoff]=='r')
684+
{
690685
value[attoff]=replValue[attoff];
691686
nulls[attoff]=replNull[attoff];
692687
}
688+
else
689+
elog(ERROR,"unrecognized replace flag: %d", (int)repl[attoff]);
693690
}
694691

695692
/*
@@ -699,6 +696,9 @@ heap_modifytuple(HeapTuple tuple,
699696
value,
700697
nulls);
701698

699+
pfree(value);
700+
pfree(nulls);
701+
702702
/*
703703
* copy the identification info of the old tuple: t_ctid, t_self, and
704704
* OID (if any)

‎src/backend/access/common/indextuple.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.64 2003/02/23 06:17:12 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.65 2003/07/21 20:29:37 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -52,8 +52,10 @@ index_formtuple(TupleDesc tupleDescriptor,
5252
#endif
5353

5454
if (numberOfAttributes>INDEX_MAX_KEYS)
55-
elog(ERROR,"index_formtuple: numberOfAttributes %d > %d",
56-
numberOfAttributes,INDEX_MAX_KEYS);
55+
ereport(ERROR,
56+
(errcode(ERRCODE_TOO_MANY_COLUMNS),
57+
errmsg("number of index attributes %d exceeds limit, %d",
58+
numberOfAttributes,INDEX_MAX_KEYS)));
5759

5860
#ifdefTOAST_INDEX_HACK
5961
for (i=0;i<numberOfAttributes;i++)
@@ -158,8 +160,11 @@ index_formtuple(TupleDesc tupleDescriptor,
158160
* it in t_info.
159161
*/
160162
if ((size&INDEX_SIZE_MASK)!=size)
161-
elog(ERROR,"index_formtuple: data takes %lu bytes, max is %d",
162-
(unsigned long)size,INDEX_SIZE_MASK);
163+
ereport(ERROR,
164+
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
165+
errmsg("index tuple requires %lu bytes, maximum size is %lu",
166+
(unsigned long)size,
167+
(unsigned long)INDEX_SIZE_MASK)));
163168

164169
infomask |=size;
165170

‎src/backend/access/common/printtup.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.74 2003/05/26 17:51:38 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.75 2003/07/21 20:29:38 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -273,7 +273,9 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs)
273273
fmgr_info(thisState->typsend,&thisState->finfo);
274274
}
275275
else
276-
elog(ERROR,"Unsupported format code %d",format);
276+
ereport(ERROR,
277+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
278+
errmsg("unsupported format code: %d",format)));
277279
}
278280
}
279281

‎src/backend/access/common/tupdesc.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.95 2003/06/15 17:59:10 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.96 2003/07/21 20:29:38 tgl Exp $
1212
*
1313
* NOTES
1414
* some of the executor utility code such as "ExecTypeFromTL" should be
@@ -417,7 +417,7 @@ TupleDescInitEntry(TupleDesc desc,
417417
ObjectIdGetDatum(oidtypeid),
418418
0,0,0);
419419
if (!HeapTupleIsValid(tuple))
420-
elog(ERROR,"Unable to look up type id %u",oidtypeid);
420+
elog(ERROR,"cache lookup failed for type %u",oidtypeid);
421421

422422
/*
423423
* type info exists so we initialize our attribute information from
@@ -643,7 +643,7 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases)
643643
intnatts;
644644

645645
if (!OidIsValid(relid))
646-
elog(ERROR,"Invalid typrelid for complex type %u",typeoid);
646+
elog(ERROR,"invalid typrelid for complex type %u",typeoid);
647647

648648
rel=relation_open(relid,AccessShareLock);
649649
tupdesc=CreateTupleDescCopy(RelationGetDescr(rel));
@@ -657,7 +657,9 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases)
657657

658658
/* does the list length match the number of attributes? */
659659
if (length(colaliases)!=natts)
660-
elog(ERROR,"TypeGetTupleDesc: number of aliases does not match number of attributes");
660+
ereport(ERROR,
661+
(errcode(ERRCODE_DATATYPE_MISMATCH),
662+
errmsg("number of aliases does not match number of attributes")));
661663

662664
/* OK, use the aliases instead */
663665
for (varattno=0;varattno<natts;varattno++)
@@ -676,11 +678,15 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases)
676678

677679
/* the alias list is required for base types */
678680
if (colaliases==NIL)
679-
elog(ERROR,"TypeGetTupleDesc: no column alias was provided");
681+
ereport(ERROR,
682+
(errcode(ERRCODE_DATATYPE_MISMATCH),
683+
errmsg("no column alias was provided")));
680684

681685
/* the alias list length must be 1 */
682686
if (length(colaliases)!=1)
683-
elog(ERROR,"TypeGetTupleDesc: number of aliases does not match number of attributes");
687+
ereport(ERROR,
688+
(errcode(ERRCODE_DATATYPE_MISMATCH),
689+
errmsg("number of aliases does not match number of attributes")));
684690

685691
/* OK, get the column alias */
686692
attname=strVal(lfirst(colaliases));
@@ -695,7 +701,9 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases)
695701
false);
696702
}
697703
elseif (functyptype=='p'&&typeoid==RECORDOID)
698-
elog(ERROR,"Unable to determine tuple description for function returning \"record\"");
704+
ereport(ERROR,
705+
(errcode(ERRCODE_DATATYPE_MISMATCH),
706+
errmsg("unable to determine tuple description for function returning record")));
699707
else
700708
{
701709
/* crummy error message, but parser should have caught this */

‎src/backend/access/gist/gist.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.103 2003/05/27 17:49:45 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.104 2003/07/21 20:29:38 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -168,7 +168,7 @@ gistbuild(PG_FUNCTION_ARGS)
168168
* that's not the case, big trouble's what we have.
169169
*/
170170
if (RelationGetNumberOfBlocks(index)!=0)
171-
elog(ERROR,"%s already contains data",
171+
elog(ERROR,"index \"%s\" already contains data",
172172
RelationGetRelationName(index));
173173

174174
/* initialize the root page */
@@ -396,7 +396,7 @@ gistPageAddItem(GISTSTATE *giststate,
396396
retval=PageAddItem(page, (Item)*newtup,IndexTupleSize(*newtup),
397397
offsetNumber,flags);
398398
if (retval==InvalidOffsetNumber)
399-
elog(ERROR,"gist:failed to add index item to%s",
399+
elog(ERROR,"failed to add index item to\"%s\"",
400400
RelationGetRelationName(r));
401401
/* be tidy */
402402
if (DatumGetPointer(tmpcentry.key)!=NULL&&
@@ -603,7 +603,7 @@ gistwritebuffer(Relation r, Page page, IndexTuple *itup,
603603
l=PageAddItem(page, (Item)itup[i],IndexTupleSize(itup[i]),
604604
off,LP_USED);
605605
if (l==InvalidOffsetNumber)
606-
elog(ERROR,"gist:failed to add index item to%s",
606+
elog(ERROR,"failed to add index item to\"%s\"",
607607
RelationGetRelationName(r));
608608
#endif
609609
}
@@ -1663,7 +1663,7 @@ initGISTstate(GISTSTATE *giststate, Relation index)
16631663
inti;
16641664

16651665
if (index->rd_att->natts>INDEX_MAX_KEYS)
1666-
elog(ERROR,"initGISTstate:numberOfAttributes %d > %d",
1666+
elog(ERROR,"numberOfAttributes %d > %d",
16671667
index->rd_att->natts,INDEX_MAX_KEYS);
16681668

16691669
giststate->tupdesc=index->rd_att;

‎src/backend/access/hash/hash.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/access/hash/hash.c,v 1.63 2003/03/23 23:01:03 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.64 2003/07/21 20:29:38 tgl Exp $
1212
*
1313
* NOTES
1414
* This file contains only the public interface routines.
@@ -69,7 +69,7 @@ hashbuild(PG_FUNCTION_ARGS)
6969
* that's not the case, big trouble's what we have.
7070
*/
7171
if (RelationGetNumberOfBlocks(index)!=0)
72-
elog(ERROR,"%s already contains data",
72+
elog(ERROR,"index \"%s\" already contains data",
7373
RelationGetRelationName(index));
7474

7575
/* initialize the hash index metadata page */

‎src/backend/access/hash/hashinsert.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/access/hash/hashinsert.c,v 1.25 2002/06/20 20:29:24 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashinsert.c,v 1.26 2003/07/21 20:29:38 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -48,7 +48,7 @@ _hash_doinsert(Relation rel, HashItem hitem)
4848
/* we need a scan key to do our search, so build one */
4949
itup=&(hitem->hash_itup);
5050
if ((natts=rel->rd_rel->relnatts)!=1)
51-
elog(ERROR,"Hashindices valid foronly one index key.");
51+
elog(ERROR,"Hashindexes supportonly one index key");
5252
itup_scankey=_hash_mkscankey(rel,itup);
5353

5454
/*
@@ -228,7 +228,7 @@ _hash_pgaddtup(Relation rel,
228228
itup_off=OffsetNumberNext(PageGetMaxOffsetNumber(page));
229229
if (PageAddItem(page, (Item)hitem,itemsize,itup_off,LP_USED)
230230
==InvalidOffsetNumber)
231-
elog(ERROR,"_hash_pgaddtup:failed to add index item to%s",
231+
elog(ERROR,"failed to add index item to\"%s\"",
232232
RelationGetRelationName(rel));
233233

234234
/* write the buffer, but hold our lock */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp