Skip to content

Commit da4ed8b

Browse files
committed
Another round of error message editing, covering backend/commands/.
1 parent 46bc587 commit da4ed8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2052
-1310
lines changed

src/backend/catalog/heap.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.246 2003/06/06 15:04:01 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.247 2003/07/20 21:56:32 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -350,8 +350,10 @@ CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind)
350350

351351
/* Sanity check on column count */
352352
if (natts < 0 || natts > MaxHeapAttributeNumber)
353-
elog(ERROR, "Number of columns is out of range (0 to %d)",
354-
MaxHeapAttributeNumber);
353+
ereport(ERROR,
354+
(errcode(ERRCODE_TOO_MANY_COLUMNS),
355+
errmsg("tables can have at most %d columns",
356+
MaxHeapAttributeNumber)));
355357

356358
/*
357359
* first check for collision with system attribute names
@@ -874,8 +876,7 @@ DeleteRelationTuple(Oid relid)
874876
ObjectIdGetDatum(relid),
875877
0, 0, 0);
876878
if (!HeapTupleIsValid(tup))
877-
elog(ERROR, "DeleteRelationTuple: cache lookup failed for relation %u",
878-
relid);
879+
elog(ERROR, "cache lookup failed for relation %u", relid);
879880

880881
/* delete the relation tuple from pg_class, and finish up */
881882
simple_heap_delete(pg_class_desc, &tup->t_self);
@@ -1082,8 +1083,7 @@ RemoveAttrDefaultById(Oid attrdefId)
10821083

10831084
tuple = systable_getnext(scan);
10841085
if (!HeapTupleIsValid(tuple))
1085-
elog(ERROR, "RemoveAttrDefaultById: cache lookup failed for attrdef %u",
1086-
attrdefId);
1086+
elog(ERROR, "could not find tuple for attrdef %u", attrdefId);
10871087

10881088
myrelid = ((Form_pg_attrdef) GETSTRUCT(tuple))->adrelid;
10891089
myattnum = ((Form_pg_attrdef) GETSTRUCT(tuple))->adnum;
@@ -1105,8 +1105,8 @@ RemoveAttrDefaultById(Oid attrdefId)
11051105
Int16GetDatum(myattnum),
11061106
0, 0);
11071107
if (!HeapTupleIsValid(tuple)) /* shouldn't happen */
1108-
elog(ERROR, "RemoveAttrDefaultById: cache lookup failed for rel %u attr %d",
1109-
myrelid, myattnum);
1108+
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
1109+
myattnum, myrelid);
11101110

11111111
((Form_pg_attribute) GETSTRUCT(tuple))->atthasdef = false;
11121112

@@ -1281,7 +1281,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin)
12811281
Int16GetDatum(attnum),
12821282
0, 0);
12831283
if (!HeapTupleIsValid(atttup))
1284-
elog(ERROR, "cache lookup of attribute %d in relation %u failed",
1284+
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
12851285
attnum, RelationGetRelid(rel));
12861286
attStruct = (Form_pg_attribute) GETSTRUCT(atttup);
12871287
if (!attStruct->atthasdef)
@@ -1539,7 +1539,7 @@ AddRelationRawConstraints(Relation rel,
15391539
RelationGetRelid(rel),
15401540
RelationGetNamespace(rel),
15411541
ccname))
1542-
elog(ERROR, "constraint \"%s\" already exists for relation \"%s\"",
1542+
elog(ERROR, "constraint \"%s\" for relation \"%s\" already exists",
15431543
ccname, RelationGetRelationName(rel));
15441544
/* Check against other new constraints */
15451545
/* Needed because we don't do CommandCounterIncrement in loop */
@@ -1672,7 +1672,7 @@ SetRelationNumChecks(Relation rel, int numchecks)
16721672
ObjectIdGetDatum(RelationGetRelid(rel)),
16731673
0, 0, 0);
16741674
if (!HeapTupleIsValid(reltup))
1675-
elog(ERROR, "cache lookup of relation %u failed",
1675+
elog(ERROR, "cache lookup failed for relation %u",
16761676
RelationGetRelid(rel));
16771677
relStruct = (Form_pg_class) GETSTRUCT(reltup);
16781678

src/backend/commands/aggregatecmds.c

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/commands/aggregatecmds.c,v 1.10 2003/07/04 02:51:33 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/commands/aggregatecmds.c,v 1.11 2003/07/20 21:56:32 tgl Exp $
1313
*
1414
* DESCRIPTION
1515
* The "DefineFoo" routines take the parse tree and pick out the
@@ -91,19 +91,27 @@ DefineAggregate(List *names, List *parameters)
9191
else if (strcasecmp(defel->defname, "initcond1") == 0)
9292
initval = defGetString(defel);
9393
else
94-
elog(WARNING, "DefineAggregate: attribute \"%s\" not recognized",
95-
defel->defname);
94+
ereport(WARNING,
95+
(errcode(ERRCODE_SYNTAX_ERROR),
96+
errmsg("aggregate attribute \"%s\" not recognized",
97+
defel->defname)));
9698
}
9799

98100
/*
99101
* make sure we have our required definitions
100102
*/
101103
if (baseType == NULL)
102-
elog(ERROR, "Define: \"basetype\" unspecified");
104+
ereport(ERROR,
105+
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
106+
errmsg("aggregate basetype must be specified")));
103107
if (transType == NULL)
104-
elog(ERROR, "Define: \"stype\" unspecified");
108+
ereport(ERROR,
109+
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
110+
errmsg("aggregate stype must be specified")));
105111
if (transfuncName == NIL)
106-
elog(ERROR, "Define: \"sfunc\" unspecified");
112+
ereport(ERROR,
113+
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
114+
errmsg("aggregate sfunc must be specified")));
107115

108116
/*
109117
* look up the aggregate's base type (input datatype) and transtype.
@@ -112,7 +120,8 @@ DefineAggregate(List *names, List *parameters)
112120
* so we must do a case-insensitive comparison for the name ANY. Ugh.
113121
*
114122
* basetype can be a pseudo-type, but transtype can't, since we need to
115-
* be able to store values of the transtype.
123+
* be able to store values of the transtype. However, we can allow
124+
* polymorphic transtype in some cases (AggregateCreate will check).
116125
*/
117126
if (strcasecmp(TypeNameToString(baseType), "ANY") == 0)
118127
baseTypeId = ANYOID;
@@ -123,8 +132,10 @@ DefineAggregate(List *names, List *parameters)
123132
if (get_typtype(transTypeId) == 'p' &&
124133
transTypeId != ANYARRAYOID &&
125134
transTypeId != ANYELEMENTOID)
126-
elog(ERROR, "Aggregate transition datatype cannot be %s",
127-
format_type_be(transTypeId));
135+
ereport(ERROR,
136+
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
137+
errmsg("aggregate transition datatype cannot be %s",
138+
format_type_be(transTypeId))));
128139

129140
/*
130141
* Most of the argument-checking is done inside of AggregateCreate
@@ -174,8 +185,7 @@ RemoveAggregate(RemoveAggrStmt *stmt)
174185
ObjectIdGetDatum(procOid),
175186
0, 0, 0);
176187
if (!HeapTupleIsValid(tup)) /* should not happen */
177-
elog(ERROR, "RemoveAggregate: couldn't find pg_proc tuple for %s",
178-
NameListToString(aggName));
188+
elog(ERROR, "cache lookup failed for function %u", procOid);
179189

180190
/* Permission check: must own agg or its namespace */
181191
if (!pg_proc_ownercheck(procOid, GetUserId()) &&
@@ -204,8 +214,8 @@ RenameAggregate(List *name, TypeName *basetype, const char *newname)
204214
Oid basetypeOid;
205215
Oid procOid;
206216
Oid namespaceOid;
207-
Oid oid_array[FUNC_MAX_ARGS];
208217
HeapTuple tup;
218+
Form_pg_proc procForm;
209219
Relation rel;
210220
AclResult aclresult;
211221

@@ -229,26 +239,32 @@ RenameAggregate(List *name, TypeName *basetype, const char *newname)
229239
ObjectIdGetDatum(procOid),
230240
0, 0, 0);
231241
if (!HeapTupleIsValid(tup)) /* should not happen */
232-
elog(ERROR, "RenameAggregate: couldn't find pg_proc tuple for %s",
233-
NameListToString(name));
242+
elog(ERROR, "cache lookup failed for function %u", procOid);
243+
procForm = (Form_pg_proc) GETSTRUCT(tup);
234244

235-
namespaceOid = ((Form_pg_proc) GETSTRUCT(tup))->pronamespace;
245+
namespaceOid = procForm->pronamespace;
236246

237247
/* make sure the new name doesn't exist */
238-
MemSet(oid_array, 0, sizeof(oid_array));
239-
oid_array[0] = basetypeOid;
240248
if (SearchSysCacheExists(PROCNAMENSP,
241249
CStringGetDatum(newname),
242-
Int16GetDatum(1),
243-
PointerGetDatum(oid_array),
250+
Int16GetDatum(procForm->pronargs),
251+
PointerGetDatum(procForm->proargtypes),
244252
ObjectIdGetDatum(namespaceOid)))
245253
{
246254
if (basetypeOid == ANYOID)
247-
elog(ERROR, "function %s(*) already exists in schema %s",
248-
newname, get_namespace_name(namespaceOid));
255+
ereport(ERROR,
256+
(errcode(ERRCODE_DUPLICATE_FUNCTION),
257+
errmsg("function %s(*) already exists in schema \"%s\"",
258+
newname,
259+
get_namespace_name(namespaceOid))));
249260
else
250-
elog(ERROR, "function %s(%s) already exists in schema %s",
251-
newname, format_type_be(basetypeOid), get_namespace_name(namespaceOid));
261+
ereport(ERROR,
262+
(errcode(ERRCODE_DUPLICATE_FUNCTION),
263+
errmsg("function %s already exists in schema \"%s\"",
264+
funcname_signature_string(newname,
265+
procForm->pronargs,
266+
procForm->proargtypes),
267+
get_namespace_name(namespaceOid))));
252268
}
253269

254270
/* must be owner */

src/backend/commands/alter.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/alter.c,v 1.1 2003/06/27 14:45:27 petere Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/alter.c,v 1.2 2003/07/20 21:56:32 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -44,8 +44,8 @@ CheckOwnership(RangeVar *rel, bool noCatalogs)
4444
tuple = SearchSysCache(RELOID,
4545
ObjectIdGetDatum(relOid),
4646
0, 0, 0);
47-
if (!HeapTupleIsValid(tuple))
48-
elog(ERROR, "Relation \"%s\" does not exist", rel->relname);
47+
if (!HeapTupleIsValid(tuple)) /* should not happen */
48+
elog(ERROR, "cache lookup failed for relation %u", relOid);
4949

5050
if (!pg_class_ownercheck(relOid, GetUserId()))
5151
aclcheck_error(ACLCHECK_NOT_OWNER, rel->relname);
@@ -54,8 +54,10 @@ CheckOwnership(RangeVar *rel, bool noCatalogs)
5454
{
5555
if (!allowSystemTableMods &&
5656
IsSystemClass((Form_pg_class) GETSTRUCT(tuple)))
57-
elog(ERROR, "relation \"%s\" is a system catalog",
58-
rel->relname);
57+
ereport(ERROR,
58+
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
59+
errmsg("relation \"%s\" is a system catalog",
60+
rel->relname)));
5961
}
6062

6163
ReleaseSysCache(tuple);
@@ -154,6 +156,7 @@ ExecRenameStmt(RenameStmt *stmt)
154156
}
155157

156158
default:
157-
elog(ERROR, "invalid object type for RenameStmt: %d", stmt->renameType);
159+
elog(ERROR, "unrecognized rename stmt type: %d",
160+
(int) stmt->renameType);
158161
}
159162
}

src/backend/commands/analyze.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.55 2003/06/27 14:45:27 petere Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.56 2003/07/20 21:56:32 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -196,8 +196,9 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt)
196196
{
197197
/* No need for a WARNING if we already complained during VACUUM */
198198
if (!vacstmt->vacuum)
199-
elog(WARNING, "Skipping \"%s\" --- only table or database owner can ANALYZE it",
200-
RelationGetRelationName(onerel));
199+
ereport(WARNING,
200+
(errmsg("skipping \"%s\" --- only table or database owner can ANALYZE it",
201+
RelationGetRelationName(onerel))));
201202
relation_close(onerel, AccessShareLock);
202203
return;
203204
}
@@ -210,8 +211,9 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt)
210211
{
211212
/* No need for a WARNING if we already complained during VACUUM */
212213
if (!vacstmt->vacuum)
213-
elog(WARNING, "Skipping \"%s\" --- can not process indexes, views or special system tables",
214-
RelationGetRelationName(onerel));
214+
ereport(WARNING,
215+
(errmsg("skipping \"%s\" --- cannot ANALYZE indexes, views or special system tables",
216+
RelationGetRelationName(onerel))));
215217
relation_close(onerel, AccessShareLock);
216218
return;
217219
}
@@ -239,9 +241,10 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt)
239241
return;
240242
}
241243

242-
elog(elevel, "Analyzing %s.%s",
243-
get_namespace_name(RelationGetNamespace(onerel)),
244-
RelationGetRelationName(onerel));
244+
ereport(elevel,
245+
(errmsg("analyzing \"%s.%s\"",
246+
get_namespace_name(RelationGetNamespace(onerel)),
247+
RelationGetRelationName(onerel))));
245248

246249
/*
247250
* Determine which columns to analyze
@@ -429,7 +432,7 @@ examine_attribute(Relation onerel, int attnum)
429432
ObjectIdGetDatum(attr->atttypid),
430433
0, 0, 0);
431434
if (!HeapTupleIsValid(typtuple))
432-
elog(ERROR, "cache lookup of type %u failed", attr->atttypid);
435+
elog(ERROR, "cache lookup failed for type %u", attr->atttypid);
433436
stats->attrtype = (Form_pg_type) palloc(sizeof(FormData_pg_type));
434437
memcpy(stats->attrtype, GETSTRUCT(typtuple), sizeof(FormData_pg_type));
435438
ReleaseSysCache(typtuple);
@@ -636,8 +639,7 @@ pageloop:;
636639
*/
637640
targbuffer = ReadBuffer(onerel, targblock);
638641
if (!BufferIsValid(targbuffer))
639-
elog(ERROR, "acquire_sample_rows: ReadBuffer(%s,%u) failed",
640-
RelationGetRelationName(onerel), targblock);
642+
elog(ERROR, "ReadBuffer failed");
641643
LockBuffer(targbuffer, BUFFER_LOCK_SHARE);
642644
targpage = BufferGetPage(targbuffer);
643645
maxoffset = PageGetMaxOffsetNumber(targpage);

src/backend/commands/async.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.95 2003/05/27 17:49:45 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.96 2003/07/20 21:56:32 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -150,7 +150,7 @@ void
150150
Async_Notify(char *relname)
151151
{
152152
if (Trace_notify)
153-
elog(DEBUG1, "Async_Notify: %s", relname);
153+
elog(DEBUG1, "Async_Notify(%s)", relname);
154154

155155
/* no point in making duplicate entries in the list ... */
156156
if (!AsyncExistsPendingNotify(relname))
@@ -198,7 +198,7 @@ Async_Listen(char *relname, int pid)
198198
bool alreadyListener = false;
199199

200200
if (Trace_notify)
201-
elog(DEBUG1, "Async_Listen: %s", relname);
201+
elog(DEBUG1, "Async_Listen(%s,%d)", relname, pid);
202202

203203
lRel = heap_openr(ListenerRelationName, AccessExclusiveLock);
204204

@@ -221,7 +221,8 @@ Async_Listen(char *relname, int pid)
221221
if (alreadyListener)
222222
{
223223
heap_close(lRel, AccessExclusiveLock);
224-
elog(WARNING, "Async_Listen: We are already listening on %s", relname);
224+
ereport(WARNING,
225+
(errmsg("already listening on \"%s\"", relname)));
225226
return;
226227
}
227228

@@ -293,7 +294,7 @@ Async_Unlisten(char *relname, int pid)
293294
}
294295

295296
if (Trace_notify)
296-
elog(DEBUG1, "Async_Unlisten %s", relname);
297+
elog(DEBUG1, "Async_Unlisten(%s,%d)", relname, pid);
297298

298299
lRel = heap_openr(ListenerRelationName, AccessExclusiveLock);
299300

0 commit comments

Comments
 (0)