mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +03:00
Error message editing in backend/access.
This commit is contained in:
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.83 2002/09/27 15:04:08 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.84 2003/07/21 20:29:37 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* The old interface functions have been converted to macros
|
||||
@ -173,13 +173,11 @@ heap_attisnull(HeapTuple tup, int attnum)
|
||||
case MinCommandIdAttributeNumber:
|
||||
case MaxTransactionIdAttributeNumber:
|
||||
case MaxCommandIdAttributeNumber:
|
||||
/* these are never null */
|
||||
break;
|
||||
|
||||
case 0:
|
||||
elog(ERROR, "heap_attisnull: zero attnum disallowed");
|
||||
|
||||
default:
|
||||
elog(ERROR, "heap_attisnull: undefined negative attnum");
|
||||
elog(ERROR, "invalid attnum: %d", attnum);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -457,7 +455,7 @@ heap_getsysattr(HeapTuple tup, int attnum, bool *isnull)
|
||||
result = ObjectIdGetDatum(tup->t_tableOid);
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "heap_getsysattr: invalid attnum %d", attnum);
|
||||
elog(ERROR, "invalid attnum: %d", attnum);
|
||||
result = 0; /* keep compiler quiet */
|
||||
break;
|
||||
}
|
||||
@ -581,8 +579,10 @@ heap_formtuple(TupleDesc tupleDescriptor,
|
||||
int numberOfAttributes = tupleDescriptor->natts;
|
||||
|
||||
if (numberOfAttributes > MaxTupleAttributeNumber)
|
||||
elog(ERROR, "heap_formtuple: numberOfAttributes %d exceeds limit %d",
|
||||
numberOfAttributes, MaxTupleAttributeNumber);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_TOO_MANY_COLUMNS),
|
||||
errmsg("number of attributes %d exceeds limit, %d",
|
||||
numberOfAttributes, MaxTupleAttributeNumber)));
|
||||
|
||||
for (i = 0; i < numberOfAttributes; i++)
|
||||
{
|
||||
@ -666,14 +666,11 @@ heap_modifytuple(HeapTuple tuple,
|
||||
* allocate and fill *value and *nulls arrays from either the tuple or
|
||||
* the repl information, as appropriate.
|
||||
*/
|
||||
value = (Datum *) palloc(numberOfAttributes * sizeof *value);
|
||||
nulls = (char *) palloc(numberOfAttributes * sizeof *nulls);
|
||||
value = (Datum *) palloc(numberOfAttributes * sizeof(Datum));
|
||||
nulls = (char *) palloc(numberOfAttributes * sizeof(char));
|
||||
|
||||
for (attoff = 0;
|
||||
attoff < numberOfAttributes;
|
||||
attoff += 1)
|
||||
for (attoff = 0; attoff < numberOfAttributes; attoff++)
|
||||
{
|
||||
|
||||
if (repl[attoff] == ' ')
|
||||
{
|
||||
value[attoff] = heap_getattr(tuple,
|
||||
@ -683,13 +680,13 @@ heap_modifytuple(HeapTuple tuple,
|
||||
nulls[attoff] = (isNull) ? 'n' : ' ';
|
||||
|
||||
}
|
||||
else if (repl[attoff] != 'r')
|
||||
elog(ERROR, "heap_modifytuple: repl is \\%3d", repl[attoff]);
|
||||
else
|
||||
{ /* == 'r' */
|
||||
else if (repl[attoff] == 'r')
|
||||
{
|
||||
value[attoff] = replValue[attoff];
|
||||
nulls[attoff] = replNull[attoff];
|
||||
}
|
||||
else
|
||||
elog(ERROR, "unrecognized replace flag: %d", (int) repl[attoff]);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -699,6 +696,9 @@ heap_modifytuple(HeapTuple tuple,
|
||||
value,
|
||||
nulls);
|
||||
|
||||
pfree(value);
|
||||
pfree(nulls);
|
||||
|
||||
/*
|
||||
* copy the identification info of the old tuple: t_ctid, t_self, and
|
||||
* OID (if any)
|
||||
|
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.64 2003/02/23 06:17:12 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.65 2003/07/21 20:29:37 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -52,8 +52,10 @@ index_formtuple(TupleDesc tupleDescriptor,
|
||||
#endif
|
||||
|
||||
if (numberOfAttributes > INDEX_MAX_KEYS)
|
||||
elog(ERROR, "index_formtuple: numberOfAttributes %d > %d",
|
||||
numberOfAttributes, INDEX_MAX_KEYS);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_TOO_MANY_COLUMNS),
|
||||
errmsg("number of index attributes %d exceeds limit, %d",
|
||||
numberOfAttributes, INDEX_MAX_KEYS)));
|
||||
|
||||
#ifdef TOAST_INDEX_HACK
|
||||
for (i = 0; i < numberOfAttributes; i++)
|
||||
@ -158,8 +160,11 @@ index_formtuple(TupleDesc tupleDescriptor,
|
||||
* it in t_info.
|
||||
*/
|
||||
if ((size & INDEX_SIZE_MASK) != size)
|
||||
elog(ERROR, "index_formtuple: data takes %lu bytes, max is %d",
|
||||
(unsigned long) size, INDEX_SIZE_MASK);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
||||
errmsg("index tuple requires %lu bytes, maximum size is %lu",
|
||||
(unsigned long) size,
|
||||
(unsigned long) INDEX_SIZE_MASK)));
|
||||
|
||||
infomask |= size;
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.74 2003/05/26 17:51:38 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.75 2003/07/21 20:29:38 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -273,7 +273,9 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs)
|
||||
fmgr_info(thisState->typsend, &thisState->finfo);
|
||||
}
|
||||
else
|
||||
elog(ERROR, "Unsupported format code %d", format);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("unsupported format code: %d", format)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.95 2003/06/15 17:59:10 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.96 2003/07/21 20:29:38 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* some of the executor utility code such as "ExecTypeFromTL" should be
|
||||
@ -417,7 +417,7 @@ TupleDescInitEntry(TupleDesc desc,
|
||||
ObjectIdGetDatum(oidtypeid),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
elog(ERROR, "Unable to look up type id %u", oidtypeid);
|
||||
elog(ERROR, "cache lookup failed for type %u", oidtypeid);
|
||||
|
||||
/*
|
||||
* type info exists so we initialize our attribute information from
|
||||
@ -643,7 +643,7 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases)
|
||||
int natts;
|
||||
|
||||
if (!OidIsValid(relid))
|
||||
elog(ERROR, "Invalid typrelid for complex type %u", typeoid);
|
||||
elog(ERROR, "invalid typrelid for complex type %u", typeoid);
|
||||
|
||||
rel = relation_open(relid, AccessShareLock);
|
||||
tupdesc = CreateTupleDescCopy(RelationGetDescr(rel));
|
||||
@ -657,7 +657,9 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases)
|
||||
|
||||
/* does the list length match the number of attributes? */
|
||||
if (length(colaliases) != natts)
|
||||
elog(ERROR, "TypeGetTupleDesc: number of aliases does not match number of attributes");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("number of aliases does not match number of attributes")));
|
||||
|
||||
/* OK, use the aliases instead */
|
||||
for (varattno = 0; varattno < natts; varattno++)
|
||||
@ -676,11 +678,15 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases)
|
||||
|
||||
/* the alias list is required for base types */
|
||||
if (colaliases == NIL)
|
||||
elog(ERROR, "TypeGetTupleDesc: no column alias was provided");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("no column alias was provided")));
|
||||
|
||||
/* the alias list length must be 1 */
|
||||
if (length(colaliases) != 1)
|
||||
elog(ERROR, "TypeGetTupleDesc: number of aliases does not match number of attributes");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("number of aliases does not match number of attributes")));
|
||||
|
||||
/* OK, get the column alias */
|
||||
attname = strVal(lfirst(colaliases));
|
||||
@ -695,7 +701,9 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases)
|
||||
false);
|
||||
}
|
||||
else if (functyptype == 'p' && typeoid == RECORDOID)
|
||||
elog(ERROR, "Unable to determine tuple description for function returning \"record\"");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("unable to determine tuple description for function returning record")));
|
||||
else
|
||||
{
|
||||
/* crummy error message, but parser should have caught this */
|
||||
|
Reference in New Issue
Block a user