Commit da4ed8bf authored by Tom Lane's avatar Tom Lane

Another round of error message editing, covering backend/commands/.

parent 46bc5870
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.246 2003/06/06 15:04:01 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.247 2003/07/20 21:56:32 tgl Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
...@@ -350,8 +350,10 @@ CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind) ...@@ -350,8 +350,10 @@ CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind)
/* Sanity check on column count */ /* Sanity check on column count */
if (natts < 0 || natts > MaxHeapAttributeNumber) if (natts < 0 || natts > MaxHeapAttributeNumber)
elog(ERROR, "Number of columns is out of range (0 to %d)", ereport(ERROR,
MaxHeapAttributeNumber); (errcode(ERRCODE_TOO_MANY_COLUMNS),
errmsg("tables can have at most %d columns",
MaxHeapAttributeNumber)));
/* /*
* first check for collision with system attribute names * first check for collision with system attribute names
...@@ -874,8 +876,7 @@ DeleteRelationTuple(Oid relid) ...@@ -874,8 +876,7 @@ DeleteRelationTuple(Oid relid)
ObjectIdGetDatum(relid), ObjectIdGetDatum(relid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(tup)) if (!HeapTupleIsValid(tup))
elog(ERROR, "DeleteRelationTuple: cache lookup failed for relation %u", elog(ERROR, "cache lookup failed for relation %u", relid);
relid);
/* delete the relation tuple from pg_class, and finish up */ /* delete the relation tuple from pg_class, and finish up */
simple_heap_delete(pg_class_desc, &tup->t_self); simple_heap_delete(pg_class_desc, &tup->t_self);
...@@ -1082,8 +1083,7 @@ RemoveAttrDefaultById(Oid attrdefId) ...@@ -1082,8 +1083,7 @@ RemoveAttrDefaultById(Oid attrdefId)
tuple = systable_getnext(scan); tuple = systable_getnext(scan);
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))
elog(ERROR, "RemoveAttrDefaultById: cache lookup failed for attrdef %u", elog(ERROR, "could not find tuple for attrdef %u", attrdefId);
attrdefId);
myrelid = ((Form_pg_attrdef) GETSTRUCT(tuple))->adrelid; myrelid = ((Form_pg_attrdef) GETSTRUCT(tuple))->adrelid;
myattnum = ((Form_pg_attrdef) GETSTRUCT(tuple))->adnum; myattnum = ((Form_pg_attrdef) GETSTRUCT(tuple))->adnum;
...@@ -1105,8 +1105,8 @@ RemoveAttrDefaultById(Oid attrdefId) ...@@ -1105,8 +1105,8 @@ RemoveAttrDefaultById(Oid attrdefId)
Int16GetDatum(myattnum), Int16GetDatum(myattnum),
0, 0); 0, 0);
if (!HeapTupleIsValid(tuple)) /* shouldn't happen */ if (!HeapTupleIsValid(tuple)) /* shouldn't happen */
elog(ERROR, "RemoveAttrDefaultById: cache lookup failed for rel %u attr %d", elog(ERROR, "cache lookup failed for attribute %d of relation %u",
myrelid, myattnum); myattnum, myrelid);
((Form_pg_attribute) GETSTRUCT(tuple))->atthasdef = false; ((Form_pg_attribute) GETSTRUCT(tuple))->atthasdef = false;
...@@ -1281,7 +1281,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin) ...@@ -1281,7 +1281,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin)
Int16GetDatum(attnum), Int16GetDatum(attnum),
0, 0); 0, 0);
if (!HeapTupleIsValid(atttup)) if (!HeapTupleIsValid(atttup))
elog(ERROR, "cache lookup of attribute %d in relation %u failed", elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, RelationGetRelid(rel)); attnum, RelationGetRelid(rel));
attStruct = (Form_pg_attribute) GETSTRUCT(atttup); attStruct = (Form_pg_attribute) GETSTRUCT(atttup);
if (!attStruct->atthasdef) if (!attStruct->atthasdef)
...@@ -1539,7 +1539,7 @@ AddRelationRawConstraints(Relation rel, ...@@ -1539,7 +1539,7 @@ AddRelationRawConstraints(Relation rel,
RelationGetRelid(rel), RelationGetRelid(rel),
RelationGetNamespace(rel), RelationGetNamespace(rel),
ccname)) ccname))
elog(ERROR, "constraint \"%s\" already exists for relation \"%s\"", elog(ERROR, "constraint \"%s\" for relation \"%s\" already exists",
ccname, RelationGetRelationName(rel)); ccname, RelationGetRelationName(rel));
/* Check against other new constraints */ /* Check against other new constraints */
/* Needed because we don't do CommandCounterIncrement in loop */ /* Needed because we don't do CommandCounterIncrement in loop */
...@@ -1672,7 +1672,7 @@ SetRelationNumChecks(Relation rel, int numchecks) ...@@ -1672,7 +1672,7 @@ SetRelationNumChecks(Relation rel, int numchecks)
ObjectIdGetDatum(RelationGetRelid(rel)), ObjectIdGetDatum(RelationGetRelid(rel)),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(reltup)) if (!HeapTupleIsValid(reltup))
elog(ERROR, "cache lookup of relation %u failed", elog(ERROR, "cache lookup failed for relation %u",
RelationGetRelid(rel)); RelationGetRelid(rel));
relStruct = (Form_pg_class) GETSTRUCT(reltup); relStruct = (Form_pg_class) GETSTRUCT(reltup);
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/aggregatecmds.c,v 1.10 2003/07/04 02:51:33 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/aggregatecmds.c,v 1.11 2003/07/20 21:56:32 tgl Exp $
* *
* DESCRIPTION * DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the * The "DefineFoo" routines take the parse tree and pick out the
...@@ -91,19 +91,27 @@ DefineAggregate(List *names, List *parameters) ...@@ -91,19 +91,27 @@ DefineAggregate(List *names, List *parameters)
else if (strcasecmp(defel->defname, "initcond1") == 0) else if (strcasecmp(defel->defname, "initcond1") == 0)
initval = defGetString(defel); initval = defGetString(defel);
else else
elog(WARNING, "DefineAggregate: attribute \"%s\" not recognized", ereport(WARNING,
defel->defname); (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("aggregate attribute \"%s\" not recognized",
defel->defname)));
} }
/* /*
* make sure we have our required definitions * make sure we have our required definitions
*/ */
if (baseType == NULL) if (baseType == NULL)
elog(ERROR, "Define: \"basetype\" unspecified"); ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("aggregate basetype must be specified")));
if (transType == NULL) if (transType == NULL)
elog(ERROR, "Define: \"stype\" unspecified"); ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("aggregate stype must be specified")));
if (transfuncName == NIL) if (transfuncName == NIL)
elog(ERROR, "Define: \"sfunc\" unspecified"); ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("aggregate sfunc must be specified")));
/* /*
* look up the aggregate's base type (input datatype) and transtype. * look up the aggregate's base type (input datatype) and transtype.
...@@ -112,7 +120,8 @@ DefineAggregate(List *names, List *parameters) ...@@ -112,7 +120,8 @@ DefineAggregate(List *names, List *parameters)
* so we must do a case-insensitive comparison for the name ANY. Ugh. * so we must do a case-insensitive comparison for the name ANY. Ugh.
* *
* basetype can be a pseudo-type, but transtype can't, since we need to * basetype can be a pseudo-type, but transtype can't, since we need to
* be able to store values of the transtype. * be able to store values of the transtype. However, we can allow
* polymorphic transtype in some cases (AggregateCreate will check).
*/ */
if (strcasecmp(TypeNameToString(baseType), "ANY") == 0) if (strcasecmp(TypeNameToString(baseType), "ANY") == 0)
baseTypeId = ANYOID; baseTypeId = ANYOID;
...@@ -123,8 +132,10 @@ DefineAggregate(List *names, List *parameters) ...@@ -123,8 +132,10 @@ DefineAggregate(List *names, List *parameters)
if (get_typtype(transTypeId) == 'p' && if (get_typtype(transTypeId) == 'p' &&
transTypeId != ANYARRAYOID && transTypeId != ANYARRAYOID &&
transTypeId != ANYELEMENTOID) transTypeId != ANYELEMENTOID)
elog(ERROR, "Aggregate transition datatype cannot be %s", ereport(ERROR,
format_type_be(transTypeId)); (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("aggregate transition datatype cannot be %s",
format_type_be(transTypeId))));
/* /*
* Most of the argument-checking is done inside of AggregateCreate * Most of the argument-checking is done inside of AggregateCreate
...@@ -174,8 +185,7 @@ RemoveAggregate(RemoveAggrStmt *stmt) ...@@ -174,8 +185,7 @@ RemoveAggregate(RemoveAggrStmt *stmt)
ObjectIdGetDatum(procOid), ObjectIdGetDatum(procOid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(tup)) /* should not happen */ if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "RemoveAggregate: couldn't find pg_proc tuple for %s", elog(ERROR, "cache lookup failed for function %u", procOid);
NameListToString(aggName));
/* Permission check: must own agg or its namespace */ /* Permission check: must own agg or its namespace */
if (!pg_proc_ownercheck(procOid, GetUserId()) && if (!pg_proc_ownercheck(procOid, GetUserId()) &&
...@@ -204,8 +214,8 @@ RenameAggregate(List *name, TypeName *basetype, const char *newname) ...@@ -204,8 +214,8 @@ RenameAggregate(List *name, TypeName *basetype, const char *newname)
Oid basetypeOid; Oid basetypeOid;
Oid procOid; Oid procOid;
Oid namespaceOid; Oid namespaceOid;
Oid oid_array[FUNC_MAX_ARGS];
HeapTuple tup; HeapTuple tup;
Form_pg_proc procForm;
Relation rel; Relation rel;
AclResult aclresult; AclResult aclresult;
...@@ -229,26 +239,32 @@ RenameAggregate(List *name, TypeName *basetype, const char *newname) ...@@ -229,26 +239,32 @@ RenameAggregate(List *name, TypeName *basetype, const char *newname)
ObjectIdGetDatum(procOid), ObjectIdGetDatum(procOid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(tup)) /* should not happen */ if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "RenameAggregate: couldn't find pg_proc tuple for %s", elog(ERROR, "cache lookup failed for function %u", procOid);
NameListToString(name)); procForm = (Form_pg_proc) GETSTRUCT(tup);
namespaceOid = ((Form_pg_proc) GETSTRUCT(tup))->pronamespace; namespaceOid = procForm->pronamespace;
/* make sure the new name doesn't exist */ /* make sure the new name doesn't exist */
MemSet(oid_array, 0, sizeof(oid_array));
oid_array[0] = basetypeOid;
if (SearchSysCacheExists(PROCNAMENSP, if (SearchSysCacheExists(PROCNAMENSP,
CStringGetDatum(newname), CStringGetDatum(newname),
Int16GetDatum(1), Int16GetDatum(procForm->pronargs),
PointerGetDatum(oid_array), PointerGetDatum(procForm->proargtypes),
ObjectIdGetDatum(namespaceOid))) ObjectIdGetDatum(namespaceOid)))
{ {
if (basetypeOid == ANYOID) if (basetypeOid == ANYOID)
elog(ERROR, "function %s(*) already exists in schema %s", ereport(ERROR,
newname, get_namespace_name(namespaceOid)); (errcode(ERRCODE_DUPLICATE_FUNCTION),
errmsg("function %s(*) already exists in schema \"%s\"",
newname,
get_namespace_name(namespaceOid))));
else else
elog(ERROR, "function %s(%s) already exists in schema %s", ereport(ERROR,
newname, format_type_be(basetypeOid), get_namespace_name(namespaceOid)); (errcode(ERRCODE_DUPLICATE_FUNCTION),
errmsg("function %s already exists in schema \"%s\"",
funcname_signature_string(newname,
procForm->pronargs,
procForm->proargtypes),
get_namespace_name(namespaceOid))));
} }
/* must be owner */ /* must be owner */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/alter.c,v 1.1 2003/06/27 14:45:27 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/alter.c,v 1.2 2003/07/20 21:56:32 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -44,8 +44,8 @@ CheckOwnership(RangeVar *rel, bool noCatalogs) ...@@ -44,8 +44,8 @@ CheckOwnership(RangeVar *rel, bool noCatalogs)
tuple = SearchSysCache(RELOID, tuple = SearchSysCache(RELOID,
ObjectIdGetDatum(relOid), ObjectIdGetDatum(relOid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple)) /* should not happen */
elog(ERROR, "Relation \"%s\" does not exist", rel->relname); elog(ERROR, "cache lookup failed for relation %u", relOid);
if (!pg_class_ownercheck(relOid, GetUserId())) if (!pg_class_ownercheck(relOid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, rel->relname); aclcheck_error(ACLCHECK_NOT_OWNER, rel->relname);
...@@ -54,8 +54,10 @@ CheckOwnership(RangeVar *rel, bool noCatalogs) ...@@ -54,8 +54,10 @@ CheckOwnership(RangeVar *rel, bool noCatalogs)
{ {
if (!allowSystemTableMods && if (!allowSystemTableMods &&
IsSystemClass((Form_pg_class) GETSTRUCT(tuple))) IsSystemClass((Form_pg_class) GETSTRUCT(tuple)))
elog(ERROR, "relation \"%s\" is a system catalog", ereport(ERROR,
rel->relname); (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("relation \"%s\" is a system catalog",
rel->relname)));
} }
ReleaseSysCache(tuple); ReleaseSysCache(tuple);
...@@ -154,6 +156,7 @@ ExecRenameStmt(RenameStmt *stmt) ...@@ -154,6 +156,7 @@ ExecRenameStmt(RenameStmt *stmt)
} }
default: default:
elog(ERROR, "invalid object type for RenameStmt: %d", stmt->renameType); elog(ERROR, "unrecognized rename stmt type: %d",
(int) stmt->renameType);
} }
} }
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.55 2003/06/27 14:45:27 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.56 2003/07/20 21:56:32 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -196,8 +196,9 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) ...@@ -196,8 +196,9 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt)
{ {
/* No need for a WARNING if we already complained during VACUUM */ /* No need for a WARNING if we already complained during VACUUM */
if (!vacstmt->vacuum) if (!vacstmt->vacuum)
elog(WARNING, "Skipping \"%s\" --- only table or database owner can ANALYZE it", ereport(WARNING,
RelationGetRelationName(onerel)); (errmsg("skipping \"%s\" --- only table or database owner can ANALYZE it",
RelationGetRelationName(onerel))));
relation_close(onerel, AccessShareLock); relation_close(onerel, AccessShareLock);
return; return;
} }
...@@ -210,8 +211,9 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) ...@@ -210,8 +211,9 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt)
{ {
/* No need for a WARNING if we already complained during VACUUM */ /* No need for a WARNING if we already complained during VACUUM */
if (!vacstmt->vacuum) if (!vacstmt->vacuum)
elog(WARNING, "Skipping \"%s\" --- can not process indexes, views or special system tables", ereport(WARNING,
RelationGetRelationName(onerel)); (errmsg("skipping \"%s\" --- cannot ANALYZE indexes, views or special system tables",
RelationGetRelationName(onerel))));
relation_close(onerel, AccessShareLock); relation_close(onerel, AccessShareLock);
return; return;
} }
...@@ -239,9 +241,10 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) ...@@ -239,9 +241,10 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt)
return; return;
} }
elog(elevel, "Analyzing %s.%s", ereport(elevel,
(errmsg("analyzing \"%s.%s\"",
get_namespace_name(RelationGetNamespace(onerel)), get_namespace_name(RelationGetNamespace(onerel)),
RelationGetRelationName(onerel)); RelationGetRelationName(onerel))));
/* /*
* Determine which columns to analyze * Determine which columns to analyze
...@@ -429,7 +432,7 @@ examine_attribute(Relation onerel, int attnum) ...@@ -429,7 +432,7 @@ examine_attribute(Relation onerel, int attnum)
ObjectIdGetDatum(attr->atttypid), ObjectIdGetDatum(attr->atttypid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(typtuple)) if (!HeapTupleIsValid(typtuple))
elog(ERROR, "cache lookup of type %u failed", attr->atttypid); elog(ERROR, "cache lookup failed for type %u", attr->atttypid);
stats->attrtype = (Form_pg_type) palloc(sizeof(FormData_pg_type)); stats->attrtype = (Form_pg_type) palloc(sizeof(FormData_pg_type));
memcpy(stats->attrtype, GETSTRUCT(typtuple), sizeof(FormData_pg_type)); memcpy(stats->attrtype, GETSTRUCT(typtuple), sizeof(FormData_pg_type));
ReleaseSysCache(typtuple); ReleaseSysCache(typtuple);
...@@ -636,8 +639,7 @@ pageloop:; ...@@ -636,8 +639,7 @@ pageloop:;
*/ */
targbuffer = ReadBuffer(onerel, targblock); targbuffer = ReadBuffer(onerel, targblock);
if (!BufferIsValid(targbuffer)) if (!BufferIsValid(targbuffer))
elog(ERROR, "acquire_sample_rows: ReadBuffer(%s,%u) failed", elog(ERROR, "ReadBuffer failed");
RelationGetRelationName(onerel), targblock);
LockBuffer(targbuffer, BUFFER_LOCK_SHARE); LockBuffer(targbuffer, BUFFER_LOCK_SHARE);
targpage = BufferGetPage(targbuffer); targpage = BufferGetPage(targbuffer);
maxoffset = PageGetMaxOffsetNumber(targpage); maxoffset = PageGetMaxOffsetNumber(targpage);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.95 2003/05/27 17:49:45 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.96 2003/07/20 21:56:32 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -150,7 +150,7 @@ void ...@@ -150,7 +150,7 @@ void
Async_Notify(char *relname) Async_Notify(char *relname)
{ {
if (Trace_notify) if (Trace_notify)
elog(DEBUG1, "Async_Notify: %s", relname); elog(DEBUG1, "Async_Notify(%s)", relname);
/* no point in making duplicate entries in the list ... */ /* no point in making duplicate entries in the list ... */
if (!AsyncExistsPendingNotify(relname)) if (!AsyncExistsPendingNotify(relname))
...@@ -198,7 +198,7 @@ Async_Listen(char *relname, int pid) ...@@ -198,7 +198,7 @@ Async_Listen(char *relname, int pid)
bool alreadyListener = false; bool alreadyListener = false;
if (Trace_notify) if (Trace_notify)
elog(DEBUG1, "Async_Listen: %s", relname); elog(DEBUG1, "Async_Listen(%s,%d)", relname, pid);
lRel = heap_openr(ListenerRelationName, AccessExclusiveLock); lRel = heap_openr(ListenerRelationName, AccessExclusiveLock);
...@@ -221,7 +221,8 @@ Async_Listen(char *relname, int pid) ...@@ -221,7 +221,8 @@ Async_Listen(char *relname, int pid)
if (alreadyListener) if (alreadyListener)
{ {
heap_close(lRel, AccessExclusiveLock); heap_close(lRel, AccessExclusiveLock);
elog(WARNING, "Async_Listen: We are already listening on %s", relname); ereport(WARNING,
(errmsg("already listening on \"%s\"", relname)));
return; return;
} }
...@@ -293,7 +294,7 @@ Async_Unlisten(char *relname, int pid) ...@@ -293,7 +294,7 @@ Async_Unlisten(char *relname, int pid)
} }
if (Trace_notify) if (Trace_notify)
elog(DEBUG1, "Async_Unlisten %s", relname); elog(DEBUG1, "Async_Unlisten(%s,%d)", relname, pid);
lRel = heap_openr(ListenerRelationName, AccessExclusiveLock); lRel = heap_openr(ListenerRelationName, AccessExclusiveLock);
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.110 2003/05/28 16:03:56 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.111 2003/07/20 21:56:32 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -116,8 +116,9 @@ cluster(ClusterStmt *stmt) ...@@ -116,8 +116,9 @@ cluster(ClusterStmt *stmt)
/* Check permissions */ /* Check permissions */
if (!check_cluster_permitted(tableOid)) if (!check_cluster_permitted(tableOid))
elog(ERROR, "CLUSTER: You do not own relation %s", ereport(ERROR,
stmt->relation->relname); (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("permission denied")));
if (stmt->indexname == NULL) if (stmt->indexname == NULL)
{ {
...@@ -134,8 +135,7 @@ cluster(ClusterStmt *stmt) ...@@ -134,8 +135,7 @@ cluster(ClusterStmt *stmt)
ObjectIdGetDatum(indexOid), ObjectIdGetDatum(indexOid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(idxtuple)) if (!HeapTupleIsValid(idxtuple))
elog(ERROR, "Cache lookup failed for index %u", elog(ERROR, "cache lookup failed for index %u", indexOid);
indexOid);
indexForm = (Form_pg_index) GETSTRUCT(idxtuple); indexForm = (Form_pg_index) GETSTRUCT(idxtuple);
if (indexForm->indisclustered) if (indexForm->indisclustered)
{ {
...@@ -147,8 +147,10 @@ cluster(ClusterStmt *stmt) ...@@ -147,8 +147,10 @@ cluster(ClusterStmt *stmt)
} }
if (!OidIsValid(indexOid)) if (!OidIsValid(indexOid))
elog(ERROR, "CLUSTER: No previously clustered index found on table \"%s\"", ereport(ERROR,
stmt->relation->relname); (errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("there is no previously clustered index for table \"%s\"",
stmt->relation->relname)));
} }
else else
{ {
...@@ -156,8 +158,10 @@ cluster(ClusterStmt *stmt) ...@@ -156,8 +158,10 @@ cluster(ClusterStmt *stmt)
indexOid = get_relname_relid(stmt->indexname, indexOid = get_relname_relid(stmt->indexname,
rel->rd_rel->relnamespace); rel->rd_rel->relnamespace);
if (!OidIsValid(indexOid)) if (!OidIsValid(indexOid))
elog(ERROR, "CLUSTER: cannot find index \"%s\" for table \"%s\"", ereport(ERROR,
stmt->indexname, stmt->relation->relname); (errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("index \"%s\" for table \"%s\" does not exist",
stmt->indexname, stmt->relation->relname)));
} }
/* All other checks are done in cluster_rel() */ /* All other checks are done in cluster_rel() */
...@@ -310,9 +314,11 @@ cluster_rel(RelToCluster *rvtc, bool recheck) ...@@ -310,9 +314,11 @@ cluster_rel(RelToCluster *rvtc, bool recheck)
*/ */
if (OldIndex->rd_index == NULL || if (OldIndex->rd_index == NULL ||
OldIndex->rd_index->indrelid != rvtc->tableOid) OldIndex->rd_index->indrelid != rvtc->tableOid)
elog(ERROR, "CLUSTER: \"%s\" is not an index for table \"%s\"", ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not an index for table \"%s\"",
RelationGetRelationName(OldIndex), RelationGetRelationName(OldIndex),
RelationGetRelationName(OldHeap)); RelationGetRelationName(OldHeap))));
/* /*
* Disallow clustering on incomplete indexes (those that might not index * Disallow clustering on incomplete indexes (those that might not index
...@@ -321,7 +327,9 @@ cluster_rel(RelToCluster *rvtc, bool recheck) ...@@ -321,7 +327,9 @@ cluster_rel(RelToCluster *rvtc, bool recheck)
* expensive and tedious. * expensive and tedious.
*/ */
if (!heap_attisnull(OldIndex->rd_indextuple, Anum_pg_index_indpred)) if (!heap_attisnull(OldIndex->rd_indextuple, Anum_pg_index_indpred))
elog(ERROR, "CLUSTER: cannot cluster on partial index"); ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot cluster on partial index")));
if (!OldIndex->rd_am->amindexnulls) if (!OldIndex->rd_am->amindexnulls)
{ {
AttrNumber colno; AttrNumber colno;
...@@ -337,9 +345,11 @@ cluster_rel(RelToCluster *rvtc, bool recheck) ...@@ -337,9 +345,11 @@ cluster_rel(RelToCluster *rvtc, bool recheck)
{ {
/* ordinary user attribute */ /* ordinary user attribute */
if (!OldHeap->rd_att->attrs[colno - 1]->attnotnull) if (!OldHeap->rd_att->attrs[colno - 1]->attnotnull)
elog(ERROR, "CLUSTER: cannot cluster when index access method does not handle nulls" ereport(ERROR,
"\n\tYou may be able to work around this by marking column \"%s\" NOT NULL", (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
NameStr(OldHeap->rd_att->attrs[colno - 1]->attname)); errmsg("cannot cluster when index access method does not handle nulls"),
errhint("You may be able to work around this by marking column \"%s\" NOT NULL.",
NameStr(OldHeap->rd_att->attrs[colno - 1]->attname))));
} }
else if (colno < 0) else if (colno < 0)
{ {
...@@ -348,7 +358,9 @@ cluster_rel(RelToCluster *rvtc, bool recheck) ...@@ -348,7 +358,9 @@ cluster_rel(RelToCluster *rvtc, bool recheck)
else else
{ {
/* index expression, lose... */ /* index expression, lose... */
elog(ERROR, "CLUSTER: cannot cluster on expressional index when index access method does not handle nulls"); ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot cluster on expressional index when index access method does not handle nulls")));
} }
} }
...@@ -360,15 +372,19 @@ cluster_rel(RelToCluster *rvtc, bool recheck) ...@@ -360,15 +372,19 @@ cluster_rel(RelToCluster *rvtc, bool recheck)
* might work for other system relations, but I ain't gonna risk it. * might work for other system relations, but I ain't gonna risk it.
*/ */
if (IsSystemRelation(OldHeap)) if (IsSystemRelation(OldHeap))
elog(ERROR, "CLUSTER: cannot cluster system relation \"%s\"", ereport(ERROR,
RelationGetRelationName(OldHeap)); (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("\"%s\" is a system catalog",
RelationGetRelationName(OldHeap))));
/* /*
* Don't allow cluster on temp tables of other backends ... their * Don't allow cluster on temp tables of other backends ... their
* local buffer manager is not going to cope. * local buffer manager is not going to cope.
*/ */
if (isOtherTempNamespace(RelationGetNamespace(OldHeap))) if (isOtherTempNamespace(RelationGetNamespace(OldHeap)))
elog(ERROR, "CLUSTER cannot be used on temp tables of other processes"); ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot cluster temp tables of other processes")));
/* Drop relcache refcnt on OldIndex, but keep lock */ /* Drop relcache refcnt on OldIndex, but keep lock */
index_close(OldIndex); index_close(OldIndex);
...@@ -697,14 +713,14 @@ swap_relfilenodes(Oid r1, Oid r2) ...@@ -697,14 +713,14 @@ swap_relfilenodes(Oid r1, Oid r2)
ObjectIdGetDatum(r1), ObjectIdGetDatum(r1),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(reltup1)) if (!HeapTupleIsValid(reltup1))
elog(ERROR, "CLUSTER: Cannot find tuple for relation %u", r1); elog(ERROR, "cache lookup failed for relation %u", r1);
relform1 = (Form_pg_class) GETSTRUCT(reltup1); relform1 = (Form_pg_class) GETSTRUCT(reltup1);
reltup2 = SearchSysCacheCopy(RELOID, reltup2 = SearchSysCacheCopy(RELOID,
ObjectIdGetDatum(r2), ObjectIdGetDatum(r2),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(reltup2)) if (!HeapTupleIsValid(reltup2))
elog(ERROR, "CLUSTER: Cannot find tuple for relation %u", r2); elog(ERROR, "cache lookup failed for relation %u", r2);
relform2 = (Form_pg_class) GETSTRUCT(reltup2); relform2 = (Form_pg_class) GETSTRUCT(reltup2);
/* /*
...@@ -716,13 +732,13 @@ swap_relfilenodes(Oid r1, Oid r2) ...@@ -716,13 +732,13 @@ swap_relfilenodes(Oid r1, Oid r2)
rel = relation_open(r1, NoLock); rel = relation_open(r1, NoLock);
i = FlushRelationBuffers(rel, 0); i = FlushRelationBuffers(rel, 0);
if (i < 0) if (i < 0)
elog(ERROR, "CLUSTER: FlushRelationBuffers returned %d", i); elog(ERROR, "FlushRelationBuffers returned %d", i);
relation_close(rel, NoLock); relation_close(rel, NoLock);
rel = relation_open(r2, NoLock); rel = relation_open(r2, NoLock);
i = FlushRelationBuffers(rel, 0); i = FlushRelationBuffers(rel, 0);
if (i < 0) if (i < 0)
elog(ERROR, "CLUSTER: FlushRelationBuffers returned %d", i); elog(ERROR, "FlushRelationBuffers returned %d", i);
relation_close(rel, NoLock); relation_close(rel, NoLock);
/* /*
...@@ -784,18 +800,18 @@ swap_relfilenodes(Oid r1, Oid r2) ...@@ -784,18 +800,18 @@ swap_relfilenodes(Oid r1, Oid r2)
long count; long count;
if (!(relform1->reltoastrelid && relform2->reltoastrelid)) if (!(relform1->reltoastrelid && relform2->reltoastrelid))
elog(ERROR, "CLUSTER: expected both swapped tables to have TOAST tables"); elog(ERROR, "expected both swapped tables to have TOAST tables");
/* Delete old dependencies */ /* Delete old dependencies */
count = deleteDependencyRecordsFor(RelOid_pg_class, count = deleteDependencyRecordsFor(RelOid_pg_class,
relform1->reltoastrelid); relform1->reltoastrelid);
if (count != 1) if (count != 1)
elog(ERROR, "CLUSTER: expected one dependency record for TOAST table, found %ld", elog(ERROR, "expected one dependency record for TOAST table, found %ld",
count); count);
count = deleteDependencyRecordsFor(RelOid_pg_class, count = deleteDependencyRecordsFor(RelOid_pg_class,
relform2->reltoastrelid); relform2->reltoastrelid);
if (count != 1) if (count != 1)
elog(ERROR, "CLUSTER: expected one dependency record for TOAST table, found %ld", elog(ERROR, "expected one dependency record for TOAST table, found %ld",
count); count);
/* Register new dependencies */ /* Register new dependencies */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Copyright (c) 1996-2001, PostgreSQL Global Development Group * Copyright (c) 1996-2001, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.65 2003/07/17 20:13:57 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.66 2003/07/20 21:56:32 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -108,8 +108,8 @@ CommentObject(CommentStmt *stmt) ...@@ -108,8 +108,8 @@ CommentObject(CommentStmt *stmt)
CommentConstraint(stmt->objname, stmt->comment); CommentConstraint(stmt->objname, stmt->comment);
break; break;
default: default:
elog(ERROR, "An attempt was made to comment on a unknown type: %d", elog(ERROR, "unrecognized object type: %d",
stmt->objtype); (int) stmt->objtype);
} }
} }
...@@ -303,23 +303,31 @@ CommentRelation(int objtype, List *relname, char *comment) ...@@ -303,23 +303,31 @@ CommentRelation(int objtype, List *relname, char *comment)
{ {
case OBJECT_INDEX: case OBJECT_INDEX:
if (relation->rd_rel->relkind != RELKIND_INDEX) if (relation->rd_rel->relkind != RELKIND_INDEX)
elog(ERROR, "relation \"%s\" is not an index", ereport(ERROR,
RelationGetRelationName(relation)); (errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("relation \"%s\" is not an index",
RelationGetRelationName(relation))));
break; break;
case OBJECT_SEQUENCE: case OBJECT_SEQUENCE:
if (relation->rd_rel->relkind != RELKIND_SEQUENCE) if (relation->rd_rel->relkind != RELKIND_SEQUENCE)
elog(ERROR, "relation \"%s\" is not a sequence", ereport(ERROR,
RelationGetRelationName(relation)); (errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("relation \"%s\" is not a sequence",
RelationGetRelationName(relation))));
break; break;
case OBJECT_TABLE: case OBJECT_TABLE:
if (relation->rd_rel->relkind != RELKIND_RELATION) if (relation->rd_rel->relkind != RELKIND_RELATION)
elog(ERROR, "relation \"%s\" is not a table", ereport(ERROR,
RelationGetRelationName(relation)); (errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("relation \"%s\" is not a table",
RelationGetRelationName(relation))));
break; break;
case OBJECT_VIEW: case OBJECT_VIEW:
if (relation->rd_rel->relkind != RELKIND_VIEW) if (relation->rd_rel->relkind != RELKIND_VIEW)
elog(ERROR, "relation \"%s\" is not a view", ereport(ERROR,
RelationGetRelationName(relation)); (errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("relation \"%s\" is not a view",
RelationGetRelationName(relation))));
break; break;
} }
...@@ -338,8 +346,8 @@ CommentRelation(int objtype, List *relname, char *comment) ...@@ -338,8 +346,8 @@ CommentRelation(int objtype, List *relname, char *comment)
* such as a table's column. The routine will check security * such as a table's column. The routine will check security
* restrictions and then attempt to look up the specified * restrictions and then attempt to look up the specified
* attribute. If successful, a comment is added/dropped, else an * attribute. If successful, a comment is added/dropped, else an
* elog() exception is thrown. The parameters are the relation * ereport() exception is thrown. The parameters are the relation
* and attribute names, and the comments * and attribute names, and the comment
*/ */
static void static void
CommentAttribute(List *qualname, char *comment) CommentAttribute(List *qualname, char *comment)
...@@ -353,8 +361,8 @@ CommentAttribute(List *qualname, char *comment) ...@@ -353,8 +361,8 @@ CommentAttribute(List *qualname, char *comment)
/* Separate relname and attr name */ /* Separate relname and attr name */
nnames = length(qualname); nnames = length(qualname);
if (nnames < 2) if (nnames < 2) /* parser messed up */
elog(ERROR, "CommentAttribute: must specify relation.attribute"); elog(ERROR, "must specify relation and attribute");
relname = ltruncate(nnames - 1, listCopy(qualname)); relname = ltruncate(nnames - 1, listCopy(qualname));
attrname = strVal(nth(nnames - 1, qualname)); attrname = strVal(nth(nnames - 1, qualname));
...@@ -371,8 +379,10 @@ CommentAttribute(List *qualname, char *comment) ...@@ -371,8 +379,10 @@ CommentAttribute(List *qualname, char *comment)
attnum = get_attnum(RelationGetRelid(relation), attrname); attnum = get_attnum(RelationGetRelid(relation), attrname);
if (attnum == InvalidAttrNumber) if (attnum == InvalidAttrNumber)
elog(ERROR, "Relation \"%s\" has no column \"%s\"", ereport(ERROR,
RelationGetRelationName(relation), attrname); (errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("attribute \"%s\" of relation \"%s\" does not exist",
attrname, RelationGetRelationName(relation))));
/* Create the comment using the relation's oid */ /* Create the comment using the relation's oid */
...@@ -400,7 +410,9 @@ CommentDatabase(List *qualname, char *comment) ...@@ -400,7 +410,9 @@ CommentDatabase(List *qualname, char *comment)
Oid oid; Oid oid;
if (length(qualname) != 1) if (length(qualname) != 1)
elog(ERROR, "CommentDatabase: database name may not be qualified"); ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("database name may not be qualified")));
database = strVal(lfirst(qualname)); database = strVal(lfirst(qualname));
/* /*
...@@ -420,21 +432,24 @@ CommentDatabase(List *qualname, char *comment) ...@@ -420,21 +432,24 @@ CommentDatabase(List *qualname, char *comment)
oid = get_database_oid(database); oid = get_database_oid(database);
if (!OidIsValid(oid)) if (!OidIsValid(oid))
{ {
elog(WARNING, "database \"%s\" does not exist", database); ereport(WARNING,
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist", database)));
return; return;
} }
/* Only allow comments on the current database */ /* Only allow comments on the current database */
if (oid != MyDatabaseId) if (oid != MyDatabaseId)
{ {
elog(WARNING, "database comments may only be applied to the current database"); ereport(WARNING,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("database comments may only be applied to the current database")));
return; return;
} }
/* Allow if the user matches the database dba or is a superuser */ /* Check object security */
if (!pg_database_ownercheck(oid, GetUserId())) if (!pg_database_ownercheck(oid, GetUserId()))
elog(ERROR, "you are not permitted to comment on database \"%s\"", aclcheck_error(ACLCHECK_NOT_OWNER, database);
database);
/* Create the comment with the pg_database oid */ /* Create the comment with the pg_database oid */
CreateComments(oid, RelOid_pg_database, 0, comment); CreateComments(oid, RelOid_pg_database, 0, comment);
...@@ -457,15 +472,18 @@ CommentNamespace(List *qualname, char *comment) ...@@ -457,15 +472,18 @@ CommentNamespace(List *qualname, char *comment)
char *namespace; char *namespace;
if (length(qualname) != 1) if (length(qualname) != 1)
elog(ERROR, "CommentSchema: schema name may not be qualified"); ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("schema name may not be qualified")));
namespace = strVal(lfirst(qualname)); namespace = strVal(lfirst(qualname));
oid = GetSysCacheOid(NAMESPACENAME, oid = GetSysCacheOid(NAMESPACENAME,
CStringGetDatum(namespace), CStringGetDatum(namespace),
0, 0, 0); 0, 0, 0);
if (!OidIsValid(oid)) if (!OidIsValid(oid))
elog(ERROR, "CommentSchema: Schema \"%s\" could not be found", ereport(ERROR,
namespace); (errcode(ERRCODE_UNDEFINED_SCHEMA),
errmsg("schema \"%s\" does not exist", namespace)));
/* Check object security */ /* Check object security */
if (!pg_namespace_ownercheck(oid, GetUserId())) if (!pg_namespace_ownercheck(oid, GetUserId()))
...@@ -536,15 +554,18 @@ CommentRule(List *qualname, char *comment) ...@@ -536,15 +554,18 @@ CommentRule(List *qualname, char *comment)
} }
else else
{ {
elog(ERROR, "rule \"%s\" does not exist", rulename); ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("rule \"%s\" does not exist", rulename)));
reloid = ruleoid = 0; /* keep compiler quiet */ reloid = ruleoid = 0; /* keep compiler quiet */
} }
if (HeapTupleIsValid(tuple = heap_getnext(scanDesc, if (HeapTupleIsValid(tuple = heap_getnext(scanDesc,
ForwardScanDirection))) ForwardScanDirection)))
elog(ERROR, "There are multiple rules \"%s\"" ereport(ERROR,
"\n\tPlease specify a relation name as well as a rule name", (errcode(ERRCODE_DUPLICATE_OBJECT),
rulename); errmsg("there are multiple rules \"%s\"", rulename),
errhint("Specify a relation name as well as a rule name.")));
heap_endscan(scanDesc); heap_endscan(scanDesc);
heap_close(RewriteRelation, AccessShareLock); heap_close(RewriteRelation, AccessShareLock);
...@@ -570,7 +591,7 @@ CommentRule(List *qualname, char *comment) ...@@ -570,7 +591,7 @@ CommentRule(List *qualname, char *comment)
PointerGetDatum(rulename), PointerGetDatum(rulename),
0, 0); 0, 0);
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))
elog(ERROR, "rule \"%s\" does not exist", rulename); elog(ERROR, "cache lookup failed for rule \"%s\"", rulename);
Assert(reloid == ((Form_pg_rewrite) GETSTRUCT(tuple))->ev_class); Assert(reloid == ((Form_pg_rewrite) GETSTRUCT(tuple))->ev_class);
ruleoid = HeapTupleGetOid(tuple); ruleoid = HeapTupleGetOid(tuple);
ReleaseSysCache(tuple); ReleaseSysCache(tuple);
...@@ -744,8 +765,8 @@ CommentTrigger(List *qualname, char *comment) ...@@ -744,8 +765,8 @@ CommentTrigger(List *qualname, char *comment)
/* Separate relname and trig name */ /* Separate relname and trig name */
nnames = length(qualname); nnames = length(qualname);
if (nnames < 2) if (nnames < 2) /* parser messed up */
elog(ERROR, "CommentTrigger: must specify relation and trigger"); elog(ERROR, "must specify relation and trigger");
relname = ltruncate(nnames - 1, listCopy(qualname)); relname = ltruncate(nnames - 1, listCopy(qualname));
trigname = strVal(nth(nnames - 1, qualname)); trigname = strVal(nth(nnames - 1, qualname));
...@@ -778,8 +799,10 @@ CommentTrigger(List *qualname, char *comment) ...@@ -778,8 +799,10 @@ CommentTrigger(List *qualname, char *comment)
/* If no trigger exists for the relation specified, notify user */ /* If no trigger exists for the relation specified, notify user */
if (!HeapTupleIsValid(triggertuple)) if (!HeapTupleIsValid(triggertuple))
elog(ERROR, "trigger \"%s\" for relation \"%s\" does not exist", ereport(ERROR,
trigname, RelationGetRelationName(relation)); (errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("trigger \"%s\" for relation \"%s\" does not exist",
trigname, RelationGetRelationName(relation))));
oid = HeapTupleGetOid(triggertuple); oid = HeapTupleGetOid(triggertuple);
...@@ -819,8 +842,8 @@ CommentConstraint(List *qualname, char *comment) ...@@ -819,8 +842,8 @@ CommentConstraint(List *qualname, char *comment)
/* Separate relname and constraint name */ /* Separate relname and constraint name */
nnames = length(qualname); nnames = length(qualname);
if (nnames < 2) if (nnames < 2) /* parser messed up */
elog(ERROR, "CommentConstraint: must specify relation and constraint"); elog(ERROR, "must specify relation and constraint");
relName = ltruncate(nnames - 1, listCopy(qualname)); relName = ltruncate(nnames - 1, listCopy(qualname));
conName = strVal(nth(nnames - 1, qualname)); conName = strVal(nth(nnames - 1, qualname));
...@@ -854,8 +877,10 @@ CommentConstraint(List *qualname, char *comment) ...@@ -854,8 +877,10 @@ CommentConstraint(List *qualname, char *comment)
if (strcmp(NameStr(con->conname), conName) == 0) if (strcmp(NameStr(con->conname), conName) == 0)
{ {
if (OidIsValid(conOid)) if (OidIsValid(conOid))
elog(ERROR, "Relation \"%s\" has multiple constraints named \"%s\"", ereport(ERROR,
RelationGetRelationName(relation), conName); (errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("relation \"%s\" has multiple constraints named \"%s\"",
RelationGetRelationName(relation), conName)));
conOid = HeapTupleGetOid(tuple); conOid = HeapTupleGetOid(tuple);
} }
} }
...@@ -864,8 +889,10 @@ CommentConstraint(List *qualname, char *comment) ...@@ -864,8 +889,10 @@ CommentConstraint(List *qualname, char *comment)
/* If no constraint exists for the relation specified, notify user */ /* If no constraint exists for the relation specified, notify user */
if (!OidIsValid(conOid)) if (!OidIsValid(conOid))
elog(ERROR, "constraint \"%s\" for relation \"%s\" does not exist", ereport(ERROR,
conName, RelationGetRelationName(relation)); (errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("constraint \"%s\" for relation \"%s\" does not exist",
conName, RelationGetRelationName(relation))));
/* Create the comment with the pg_constraint oid */ /* Create the comment with the pg_constraint oid */
CreateComments(conOid, RelationGetRelid(pg_constraint), 0, comment); CreateComments(conOid, RelationGetRelid(pg_constraint), 0, comment);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/conversioncmds.c,v 1.7 2003/07/04 02:51:33 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/conversioncmds.c,v 1.8 2003/07/20 21:56:32 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -40,10 +40,10 @@ CreateConversionCommand(CreateConversionStmt *stmt) ...@@ -40,10 +40,10 @@ CreateConversionCommand(CreateConversionStmt *stmt)
Oid namespaceId; Oid namespaceId;
char *conversion_name; char *conversion_name;
AclResult aclresult; AclResult aclresult;
int for_encoding; int from_encoding;
int to_encoding; int to_encoding;
Oid funcoid; Oid funcoid;
const char *for_encoding_name = stmt->for_encoding_name; const char *from_encoding_name = stmt->for_encoding_name;
const char *to_encoding_name = stmt->to_encoding_name; const char *to_encoding_name = stmt->to_encoding_name;
List *func_name = stmt->func_name; List *func_name = stmt->func_name;
static Oid funcargs[] = {INT4OID, INT4OID, CSTRINGOID, CSTRINGOID, INT4OID}; static Oid funcargs[] = {INT4OID, INT4OID, CSTRINGOID, CSTRINGOID, INT4OID};
...@@ -58,13 +58,19 @@ CreateConversionCommand(CreateConversionStmt *stmt) ...@@ -58,13 +58,19 @@ CreateConversionCommand(CreateConversionStmt *stmt)
aclcheck_error(aclresult, get_namespace_name(namespaceId)); aclcheck_error(aclresult, get_namespace_name(namespaceId));
/* Check the encoding names */ /* Check the encoding names */
for_encoding = pg_char_to_encoding(for_encoding_name); from_encoding = pg_char_to_encoding(from_encoding_name);
if (for_encoding < 0) if (from_encoding < 0)
elog(ERROR, "Invalid for encoding name: %s", for_encoding_name); ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("source encoding \"%s\" does not exist",
from_encoding_name)));
to_encoding = pg_char_to_encoding(to_encoding_name); to_encoding = pg_char_to_encoding(to_encoding_name);
if (to_encoding < 0) if (to_encoding < 0)
elog(ERROR, "Invalid to encoding name: %s", to_encoding_name); ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("destination encoding \"%s\" does not exist",
to_encoding_name)));
/* /*
* Check the existence of the conversion function. Function name could * Check the existence of the conversion function. Function name could
...@@ -83,7 +89,7 @@ CreateConversionCommand(CreateConversionStmt *stmt) ...@@ -83,7 +89,7 @@ CreateConversionCommand(CreateConversionStmt *stmt)
* conversion name) * conversion name)
*/ */
ConversionCreate(conversion_name, namespaceId, GetUserId(), ConversionCreate(conversion_name, namespaceId, GetUserId(),
for_encoding, to_encoding, funcoid, stmt->def); from_encoding, to_encoding, funcoid, stmt->def);
} }
/* /*
...@@ -95,9 +101,11 @@ DropConversionCommand(List *name, DropBehavior behavior) ...@@ -95,9 +101,11 @@ DropConversionCommand(List *name, DropBehavior behavior)
Oid conversionOid; Oid conversionOid;
conversionOid = FindConversionByName(name); conversionOid = FindConversionByName(name);
if (!OidIsValid(conversionOid)) if (!OidIsValid(conversionOid))
elog(ERROR, "conversion %s not found", NameListToString(name)); ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("conversion \"%s\" does not exist",
NameListToString(name))));
ConversionDrop(conversionOid, behavior); ConversionDrop(conversionOid, behavior);
} }
...@@ -118,14 +126,16 @@ RenameConversion(List *name, const char *newname) ...@@ -118,14 +126,16 @@ RenameConversion(List *name, const char *newname)
conversionOid = FindConversionByName(name); conversionOid = FindConversionByName(name);
if (!OidIsValid(conversionOid)) if (!OidIsValid(conversionOid))
elog(ERROR, "conversion %s not found", NameListToString(name)); ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("conversion \"%s\" does not exist",
NameListToString(name))));
tup = SearchSysCacheCopy(CONOID, tup = SearchSysCacheCopy(CONOID,
ObjectIdGetDatum(conversionOid), ObjectIdGetDatum(conversionOid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(tup)) /* should not happen */ if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "couldn't find pg_conversion tuple for %s", elog(ERROR, "cache lookup failed for conversion %u", conversionOid);
NameListToString(name));
namespaceOid = ((Form_pg_conversion) GETSTRUCT(tup))->connamespace; namespaceOid = ((Form_pg_conversion) GETSTRUCT(tup))->connamespace;
...@@ -134,10 +144,10 @@ RenameConversion(List *name, const char *newname) ...@@ -134,10 +144,10 @@ RenameConversion(List *name, const char *newname)
CStringGetDatum(newname), CStringGetDatum(newname),
ObjectIdGetDatum(namespaceOid), ObjectIdGetDatum(namespaceOid),
0, 0)) 0, 0))
{ ereport(ERROR,
elog(ERROR, "conversion %s already exists in schema %s", (errcode(ERRCODE_DUPLICATE_OBJECT),
newname, get_namespace_name(namespaceOid)); errmsg("conversion \"%s\" already exists in schema \"%s\"",
} newname, get_namespace_name(namespaceOid))));
/* must be owner */ /* must be owner */
if (!superuser() && ((Form_pg_conversion) GETSTRUCT(tup))->conowner != GetUserId()) if (!superuser() && ((Form_pg_conversion) GETSTRUCT(tup))->conowner != GetUserId())
......
This diff is collapsed.
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.81 2002/09/21 18:39:25 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.82 2003/07/20 21:56:32 tgl Exp $
* *
* DESCRIPTION * DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the * The "DefineFoo" routines take the parse tree and pick out the
...@@ -65,8 +65,10 @@ char * ...@@ -65,8 +65,10 @@ char *
defGetString(DefElem *def) defGetString(DefElem *def)
{ {
if (def->arg == NULL) if (def->arg == NULL)
elog(ERROR, "Define: \"%s\" requires a parameter", ereport(ERROR,
def->defname); (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("%s requires a parameter",
def->defname)));
switch (nodeTag(def->arg)) switch (nodeTag(def->arg))
{ {
case T_Integer: case T_Integer:
...@@ -90,8 +92,7 @@ defGetString(DefElem *def) ...@@ -90,8 +92,7 @@ defGetString(DefElem *def)
case T_List: case T_List:
return NameListToString((List *) def->arg); return NameListToString((List *) def->arg);
default: default:
elog(ERROR, "Define: cannot interpret argument of \"%s\"", elog(ERROR, "unrecognized node type: %d", (int) nodeTag(def->arg));
def->defname);
} }
return NULL; /* keep compiler quiet */ return NULL; /* keep compiler quiet */
} }
...@@ -103,8 +104,10 @@ double ...@@ -103,8 +104,10 @@ double
defGetNumeric(DefElem *def) defGetNumeric(DefElem *def)
{ {
if (def->arg == NULL) if (def->arg == NULL)
elog(ERROR, "Define: \"%s\" requires a numeric value", ereport(ERROR,
def->defname); (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("%s requires a numeric value",
def->defname)));
switch (nodeTag(def->arg)) switch (nodeTag(def->arg))
{ {
case T_Integer: case T_Integer:
...@@ -112,8 +115,10 @@ defGetNumeric(DefElem *def) ...@@ -112,8 +115,10 @@ defGetNumeric(DefElem *def)
case T_Float: case T_Float:
return floatVal(def->arg); return floatVal(def->arg);
default: default:
elog(ERROR, "Define: \"%s\" requires a numeric value", ereport(ERROR,
def->defname); (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("%s requires a numeric value",
def->defname)));
} }
return 0; /* keep compiler quiet */ return 0; /* keep compiler quiet */
} }
...@@ -125,8 +130,10 @@ int64 ...@@ -125,8 +130,10 @@ int64
defGetInt64(DefElem *def) defGetInt64(DefElem *def)
{ {
if (def->arg == NULL) if (def->arg == NULL)
elog(ERROR, "Define: \"%s\" requires a numeric value", ereport(ERROR,
def->defname); (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("%s requires a numeric value",
def->defname)));
switch (nodeTag(def->arg)) switch (nodeTag(def->arg))
{ {
case T_Integer: case T_Integer:
...@@ -141,8 +148,10 @@ defGetInt64(DefElem *def) ...@@ -141,8 +148,10 @@ defGetInt64(DefElem *def)
return DatumGetInt64(DirectFunctionCall1(int8in, return DatumGetInt64(DirectFunctionCall1(int8in,
CStringGetDatum(strVal(def->arg)))); CStringGetDatum(strVal(def->arg))));
default: default:
elog(ERROR, "Define: \"%s\" requires a numeric value", ereport(ERROR,
def->defname); (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("%s requires a numeric value",
def->defname)));
} }
return 0; /* keep compiler quiet */ return 0; /* keep compiler quiet */
} }
...@@ -154,8 +163,10 @@ List * ...@@ -154,8 +163,10 @@ List *
defGetQualifiedName(DefElem *def) defGetQualifiedName(DefElem *def)
{ {
if (def->arg == NULL) if (def->arg == NULL)
elog(ERROR, "Define: \"%s\" requires a parameter", ereport(ERROR,
def->defname); (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("%s requires a parameter",
def->defname)));
switch (nodeTag(def->arg)) switch (nodeTag(def->arg))
{ {
case T_TypeName: case T_TypeName:
...@@ -166,8 +177,10 @@ defGetQualifiedName(DefElem *def) ...@@ -166,8 +177,10 @@ defGetQualifiedName(DefElem *def)
/* Allow quoted name for backwards compatibility */ /* Allow quoted name for backwards compatibility */
return makeList1(def->arg); return makeList1(def->arg);
default: default:
elog(ERROR, "Define: argument of \"%s\" must be a name", ereport(ERROR,
def->defname); (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("argument of %s must be a name",
def->defname)));
} }
return NIL; /* keep compiler quiet */ return NIL; /* keep compiler quiet */
} }
...@@ -182,8 +195,10 @@ TypeName * ...@@ -182,8 +195,10 @@ TypeName *
defGetTypeName(DefElem *def) defGetTypeName(DefElem *def)
{ {
if (def->arg == NULL) if (def->arg == NULL)
elog(ERROR, "Define: \"%s\" requires a parameter", ereport(ERROR,
def->defname); (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("%s requires a parameter",
def->defname)));
switch (nodeTag(def->arg)) switch (nodeTag(def->arg))
{ {
case T_TypeName: case T_TypeName:
...@@ -198,8 +213,10 @@ defGetTypeName(DefElem *def) ...@@ -198,8 +213,10 @@ defGetTypeName(DefElem *def)
return n; return n;
} }
default: default:
elog(ERROR, "Define: argument of \"%s\" must be a type name", ereport(ERROR,
def->defname); (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("argument of %s must be a type name",
def->defname)));
} }
return NULL; /* keep compiler quiet */ return NULL; /* keep compiler quiet */
} }
...@@ -212,15 +229,19 @@ int ...@@ -212,15 +229,19 @@ int
defGetTypeLength(DefElem *def) defGetTypeLength(DefElem *def)
{ {
if (def->arg == NULL) if (def->arg == NULL)
elog(ERROR, "Define: \"%s\" requires a parameter", ereport(ERROR,
def->defname); (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("%s requires a parameter",
def->defname)));
switch (nodeTag(def->arg)) switch (nodeTag(def->arg))
{ {
case T_Integer: case T_Integer:
return intVal(def->arg); return intVal(def->arg);
case T_Float: case T_Float:
elog(ERROR, "Define: \"%s\" requires an integral value", ereport(ERROR,
def->defname); (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("%s requires an integer value",
def->defname)));
break; break;
case T_String: case T_String:
if (strcasecmp(strVal(def->arg), "variable") == 0) if (strcasecmp(strVal(def->arg), "variable") == 0)
...@@ -236,10 +257,11 @@ defGetTypeLength(DefElem *def) ...@@ -236,10 +257,11 @@ defGetTypeLength(DefElem *def)
/* must be an operator name */ /* must be an operator name */
break; break;
default: default:
elog(ERROR, "Define: cannot interpret argument of \"%s\"", elog(ERROR, "unrecognized node type: %d", (int) nodeTag(def->arg));
def->defname);
} }
elog(ERROR, "Define: invalid argument for \"%s\": \"%s\"", ereport(ERROR,
def->defname, defGetString(def)); (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("invalid argument for %s: \"%s\"",
def->defname, defGetString(def))));
return 0; /* keep compiler quiet */ return 0; /* keep compiler quiet */
} }
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994-5, Regents of the University of California * Portions Copyright (c) 1994-5, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.110 2003/05/28 23:06:16 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.111 2003/07/20 21:56:32 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -157,7 +157,7 @@ ExplainOneQuery(Query *query, ExplainStmt *stmt, TupOutputState *tstate) ...@@ -157,7 +157,7 @@ ExplainOneQuery(Query *query, ExplainStmt *stmt, TupOutputState *tstate)
Assert(query->commandType == CMD_SELECT); Assert(query->commandType == CMD_SELECT);
rewritten = QueryRewrite(query); rewritten = QueryRewrite(query);
if (length(rewritten) != 1) if (length(rewritten) != 1)
elog(ERROR, "ExplainOneQuery: unexpected rewrite result"); elog(ERROR, "unexpected rewrite result");
query = (Query *) lfirst(rewritten); query = (Query *) lfirst(rewritten);
Assert(query->commandType == CMD_SELECT); Assert(query->commandType == CMD_SELECT);
/* do not actually execute the underlying query! */ /* do not actually execute the underlying query! */
...@@ -1013,8 +1013,7 @@ show_sort_keys(List *tlist, int nkeys, AttrNumber *keycols, ...@@ -1013,8 +1013,7 @@ show_sort_keys(List *tlist, int nkeys, AttrNumber *keycols,
} }
} }
if (tl == NIL) if (tl == NIL)
elog(ERROR, "show_sort_keys: no tlist entry for key %d", elog(ERROR, "no tlist entry for key %d", keyresno);
keyresno);
} }
appendStringInfo(str, "\n"); appendStringInfo(str, "\n");
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.28 2003/07/18 23:20:32 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.29 2003/07/20 21:56:32 tgl Exp $
* *
* DESCRIPTION * DESCRIPTION
* These routines take the parse tree and pick out the * These routines take the parse tree and pick out the
...@@ -672,10 +672,11 @@ RenameFunction(List *name, List *argtypes, const char *newname) ...@@ -672,10 +672,11 @@ RenameFunction(List *name, List *argtypes, const char *newname)
{ {
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_FUNCTION), (errcode(ERRCODE_DUPLICATE_FUNCTION),
errmsg("function %s already exists", errmsg("function %s already exists in schema \"%s\"",
func_signature_string(name, funcname_signature_string(newname,
procForm->pronargs, procForm->pronargs,
procForm->proargtypes)))); procForm->proargtypes),
get_namespace_name(namespaceOid))));
} }
/* must be owner */ /* must be owner */
......
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/lockcmds.c,v 1.4 2002/09/04 20:31:15 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/lockcmds.c,v 1.5 2003/07/20 21:56:32 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -62,8 +62,10 @@ LockTableCommand(LockStmt *lockstmt) ...@@ -62,8 +62,10 @@ LockTableCommand(LockStmt *lockstmt)
/* Currently, we only allow plain tables to be locked */ /* Currently, we only allow plain tables to be locked */
if (rel->rd_rel->relkind != RELKIND_RELATION) if (rel->rd_rel->relkind != RELKIND_RELATION)
elog(ERROR, "LOCK TABLE: %s is not a table", ereport(ERROR,
relation->relname); (errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not a table",
relation->relname)));
relation_close(rel, NoLock); /* close rel, keep lock */ relation_close(rel, NoLock); /* close rel, keep lock */
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/opclasscmds.c,v 1.12 2003/07/18 23:20:32 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/opclasscmds.c,v 1.13 2003/07/20 21:56:32 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -252,7 +252,7 @@ DefineOpClass(CreateOpClassStmt *stmt) ...@@ -252,7 +252,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
0)) 0))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT), (errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("operator class \"%s\" already exists for access method \"%s\"", errmsg("operator class \"%s\" for access method \"%s\" already exists",
opcname, stmt->amname))); opcname, stmt->amname)));
/* /*
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/operatorcmds.c,v 1.8 2003/07/04 02:51:33 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/operatorcmds.c,v 1.9 2003/07/20 21:56:32 tgl Exp $
* *
* DESCRIPTION * DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the * The "DefineFoo" routines take the parse tree and pick out the
...@@ -100,13 +100,17 @@ DefineOperator(List *names, List *parameters) ...@@ -100,13 +100,17 @@ DefineOperator(List *names, List *parameters)
{ {
typeName1 = defGetTypeName(defel); typeName1 = defGetTypeName(defel);
if (typeName1->setof) if (typeName1->setof)
elog(ERROR, "setof type not implemented for leftarg"); ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("setof type not allowed for operator argument")));
} }
else if (strcasecmp(defel->defname, "rightarg") == 0) else if (strcasecmp(defel->defname, "rightarg") == 0)
{ {
typeName2 = defGetTypeName(defel); typeName2 = defGetTypeName(defel);
if (typeName2->setof) if (typeName2->setof)
elog(ERROR, "setof type not implemented for rightarg"); ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("setof type not allowed for operator argument")));
} }
else if (strcasecmp(defel->defname, "procedure") == 0) else if (strcasecmp(defel->defname, "procedure") == 0)
functionName = defGetQualifiedName(defel); functionName = defGetQualifiedName(defel);
...@@ -131,17 +135,19 @@ DefineOperator(List *names, List *parameters) ...@@ -131,17 +135,19 @@ DefineOperator(List *names, List *parameters)
else if (strcasecmp(defel->defname, "gtcmp") == 0) else if (strcasecmp(defel->defname, "gtcmp") == 0)
gtCompareName = defGetQualifiedName(defel); gtCompareName = defGetQualifiedName(defel);
else else
{ ereport(WARNING,
elog(WARNING, "DefineOperator: attribute \"%s\" not recognized", (errcode(ERRCODE_SYNTAX_ERROR),
defel->defname); errmsg("operator attribute \"%s\" not recognized",
} defel->defname)));
} }
/* /*
* make sure we have our required definitions * make sure we have our required definitions
*/ */
if (functionName == NIL) if (functionName == NIL)
elog(ERROR, "Define: \"procedure\" unspecified"); ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("operator procedure must be specified")));
/* Transform type names to type OIDs */ /* Transform type names to type OIDs */
if (typeName1) if (typeName1)
...@@ -212,7 +218,7 @@ RemoveOperator(RemoveOperStmt *stmt) ...@@ -212,7 +218,7 @@ RemoveOperator(RemoveOperStmt *stmt)
ObjectIdGetDatum(operOid), ObjectIdGetDatum(operOid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(tup)) /* should not happen */ if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup of operator %u failed", operOid); elog(ERROR, "cache lookup failed for operator %u", operOid);
/* Permission check: must own operator or its namespace */ /* Permission check: must own operator or its namespace */
if (!pg_oper_ownercheck(operOid, GetUserId()) && if (!pg_oper_ownercheck(operOid, GetUserId()) &&
...@@ -247,8 +253,7 @@ RemoveOperatorById(Oid operOid) ...@@ -247,8 +253,7 @@ RemoveOperatorById(Oid operOid)
ObjectIdGetDatum(operOid), ObjectIdGetDatum(operOid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(tup)) /* should not happen */ if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "RemoveOperatorById: failed to find tuple for operator %u", elog(ERROR, "cache lookup failed for operator %u", operOid);
operOid);
simple_heap_delete(relation, &tup->t_self); simple_heap_delete(relation, &tup->t_self);
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/portalcmds.c,v 1.16 2003/05/08 18:16:36 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/portalcmds.c,v 1.17 2003/07/20 21:56:32 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -49,7 +49,9 @@ PerformCursorOpen(DeclareCursorStmt *stmt) ...@@ -49,7 +49,9 @@ PerformCursorOpen(DeclareCursorStmt *stmt)
* unnamed portal). * unnamed portal).
*/ */
if (!stmt->portalname || stmt->portalname[0] == '\0') if (!stmt->portalname || stmt->portalname[0] == '\0')
elog(ERROR, "Invalid cursor name: must not be empty"); ereport(ERROR,
(errcode(ERRCODE_INVALID_CURSOR_NAME),
errmsg("invalid cursor name: must not be empty")));
/* /*
* If this is a non-holdable cursor, we require that this statement * If this is a non-holdable cursor, we require that this statement
...@@ -66,16 +68,20 @@ PerformCursorOpen(DeclareCursorStmt *stmt) ...@@ -66,16 +68,20 @@ PerformCursorOpen(DeclareCursorStmt *stmt)
*/ */
rewritten = QueryRewrite((Query *) stmt->query); rewritten = QueryRewrite((Query *) stmt->query);
if (length(rewritten) != 1 || !IsA(lfirst(rewritten), Query)) if (length(rewritten) != 1 || !IsA(lfirst(rewritten), Query))
elog(ERROR, "PerformCursorOpen: unexpected rewrite result"); elog(ERROR, "unexpected rewrite result");
query = (Query *) lfirst(rewritten); query = (Query *) lfirst(rewritten);
if (query->commandType != CMD_SELECT) if (query->commandType != CMD_SELECT)
elog(ERROR, "PerformCursorOpen: unexpected rewrite result"); elog(ERROR, "unexpected rewrite result");
if (query->into) if (query->into)
elog(ERROR, "DECLARE CURSOR may not specify INTO"); ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("DECLARE CURSOR may not specify INTO")));
if (query->rowMarks != NIL) if (query->rowMarks != NIL)
elog(ERROR, "DECLARE/UPDATE is not supported" ereport(ERROR,
"\n\tCursors must be READ ONLY"); (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("DECLARE CURSOR ... FOR UPDATE is not supported"),
errdetail("Cursors must be READ ONLY.")));
plan = planner(query, true, stmt->options); plan = planner(query, true, stmt->options);
...@@ -152,15 +158,19 @@ PerformPortalFetch(FetchStmt *stmt, ...@@ -152,15 +158,19 @@ PerformPortalFetch(FetchStmt *stmt,
* unnamed portal). * unnamed portal).
*/ */
if (!stmt->portalname || stmt->portalname[0] == '\0') if (!stmt->portalname || stmt->portalname[0] == '\0')
elog(ERROR, "Invalid cursor name: must not be empty"); ereport(ERROR,
(errcode(ERRCODE_INVALID_CURSOR_NAME),
errmsg("invalid cursor name: must not be empty")));
/* get the portal from the portal name */ /* get the portal from the portal name */
portal = GetPortalByName(stmt->portalname); portal = GetPortalByName(stmt->portalname);
if (!PortalIsValid(portal)) if (!PortalIsValid(portal))
{ {
/* FIXME: shouldn't this be an ERROR? */ /* FIXME: shouldn't this be an ERROR? */
elog(WARNING, "PerformPortalFetch: portal \"%s\" not found", ereport(WARNING,
stmt->portalname); (errcode(ERRCODE_UNDEFINED_CURSOR),
errmsg("portal \"%s\" does not exist", stmt->portalname),
errfunction("PerformPortalFetch"))); /* for ecpg */
if (completionTag) if (completionTag)
strcpy(completionTag, stmt->ismove ? "MOVE 0" : "FETCH 0"); strcpy(completionTag, stmt->ismove ? "MOVE 0" : "FETCH 0");
return; return;
...@@ -197,7 +207,9 @@ PerformPortalClose(const char *name) ...@@ -197,7 +207,9 @@ PerformPortalClose(const char *name)
* unnamed portal). * unnamed portal).
*/ */
if (!name || name[0] == '\0') if (!name || name[0] == '\0')
elog(ERROR, "Invalid cursor name: must not be empty"); ereport(ERROR,
(errcode(ERRCODE_INVALID_CURSOR_NAME),
errmsg("invalid cursor name: must not be empty")));
/* /*
* get the portal from the portal name * get the portal from the portal name
...@@ -205,8 +217,10 @@ PerformPortalClose(const char *name) ...@@ -205,8 +217,10 @@ PerformPortalClose(const char *name)
portal = GetPortalByName(name); portal = GetPortalByName(name);
if (!PortalIsValid(portal)) if (!PortalIsValid(portal))
{ {
elog(WARNING, "PerformPortalClose: portal \"%s\" not found", ereport(WARNING,
name); (errcode(ERRCODE_UNDEFINED_CURSOR),
errmsg("portal \"%s\" does not exist", name),
errfunction("PerformPortalClose"))); /* for ecpg */
return; return;
} }
...@@ -292,7 +306,9 @@ PersistHoldablePortal(Portal portal) ...@@ -292,7 +306,9 @@ PersistHoldablePortal(Portal portal)
* Check for improper portal use, and mark portal active. * Check for improper portal use, and mark portal active.
*/ */
if (portal->portalActive) if (portal->portalActive)
elog(ERROR, "Portal \"%s\" already active", portal->name); ereport(ERROR,
(errcode(ERRCODE_OBJECT_IN_USE),
errmsg("portal \"%s\" already active", portal->name)));
portal->portalActive = true; portal->portalActive = true;
/* /*
...@@ -347,7 +363,9 @@ PersistHoldablePortal(Portal portal) ...@@ -347,7 +363,9 @@ PersistHoldablePortal(Portal portal)
long store_pos; long store_pos;
if (portal->posOverflow) /* oops, cannot trust portalPos */ if (portal->posOverflow) /* oops, cannot trust portalPos */
elog(ERROR, "Unable to reposition held cursor"); ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("unable to reposition held cursor")));
tuplestore_rescan(portal->holdStore); tuplestore_rescan(portal->holdStore);
...@@ -360,8 +378,7 @@ PersistHoldablePortal(Portal portal) ...@@ -360,8 +378,7 @@ PersistHoldablePortal(Portal portal)
&should_free); &should_free);
if (tup == NULL) if (tup == NULL)
elog(ERROR, elog(ERROR, "unexpected end of tuple stream");
"PersistHoldablePortal: unexpected end of tuple stream");
if (should_free) if (should_free)
pfree(tup); pfree(tup);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* Copyright (c) 2002-2003, PostgreSQL Global Development Group * Copyright (c) 2002-2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/prepare.c,v 1.19 2003/07/01 00:04:31 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/prepare.c,v 1.20 2003/07/20 21:56:32 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -56,7 +56,9 @@ PrepareQuery(PrepareStmt *stmt) ...@@ -56,7 +56,9 @@ PrepareQuery(PrepareStmt *stmt)
* unnamed statement). * unnamed statement).
*/ */
if (!stmt->name || stmt->name[0] == '\0') if (!stmt->name || stmt->name[0] == '\0')
elog(ERROR, "Invalid statement name: must not be empty"); ereport(ERROR,
(errcode(ERRCODE_INVALID_PSTATEMENT_DEFINITION),
errmsg("invalid statement name: must not be empty")));
switch (stmt->query->commandType) switch (stmt->query->commandType)
{ {
...@@ -73,7 +75,9 @@ PrepareQuery(PrepareStmt *stmt) ...@@ -73,7 +75,9 @@ PrepareQuery(PrepareStmt *stmt)
commandTag = "DELETE"; commandTag = "DELETE";
break; break;
default: default:
elog(ERROR, "Utility statements cannot be prepared"); ereport(ERROR,
(errcode(ERRCODE_INVALID_PSTATEMENT_DEFINITION),
errmsg("utility statements cannot be prepared")));
commandTag = NULL; /* keep compiler quiet */ commandTag = NULL; /* keep compiler quiet */
break; break;
} }
...@@ -159,10 +163,14 @@ ExecuteQuery(ExecuteStmt *stmt, DestReceiver *dest) ...@@ -159,10 +163,14 @@ ExecuteQuery(ExecuteStmt *stmt, DestReceiver *dest)
qcontext = PortalGetHeapMemory(portal); qcontext = PortalGetHeapMemory(portal);
if (length(query_list) != 1) if (length(query_list) != 1)
elog(ERROR, "prepared statement is not a SELECT"); ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("prepared statement is not a SELECT")));
query = (Query *) lfirst(query_list); query = (Query *) lfirst(query_list);
if (query->commandType != CMD_SELECT) if (query->commandType != CMD_SELECT)
elog(ERROR, "prepared statement is not a SELECT"); ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("prepared statement is not a SELECT")));
query->into = copyObject(stmt->into); query->into = copyObject(stmt->into);
MemoryContextSwitchTo(oldContext); MemoryContextSwitchTo(oldContext);
...@@ -206,9 +214,9 @@ EvaluateParams(EState *estate, List *params, List *argtypes) ...@@ -206,9 +214,9 @@ EvaluateParams(EState *estate, List *params, List *argtypes)
List *l; List *l;
int i = 0; int i = 0;
/* Parser should have caught this error, but check anyway */ /* Parser should have caught this error, but check for safety */
if (length(params) != nargs) if (length(params) != nargs)
elog(ERROR, "EvaluateParams: wrong number of arguments"); elog(ERROR, "wrong number of arguments");
exprstates = (List *) ExecPrepareExpr((Expr *) params, estate); exprstates = (List *) ExecPrepareExpr((Expr *) params, estate);
...@@ -256,7 +264,7 @@ InitQueryHashTable(void) ...@@ -256,7 +264,7 @@ InitQueryHashTable(void)
HASH_ELEM); HASH_ELEM);
if (!prepared_queries) if (!prepared_queries)
elog(ERROR, "InitQueryHashTable: unable to create hash table"); elog(ERROR, "unable to create hash table");
} }
/* /*
...@@ -295,8 +303,10 @@ StorePreparedStatement(const char *stmt_name, ...@@ -295,8 +303,10 @@ StorePreparedStatement(const char *stmt_name,
hash_search(prepared_queries, key, HASH_FIND, &found); hash_search(prepared_queries, key, HASH_FIND, &found);
if (found) if (found)
elog(ERROR, "Prepared statement with name \"%s\" already exists", ereport(ERROR,
stmt_name); (errcode(ERRCODE_DUPLICATE_PSTATEMENT),
errmsg("prepared statement \"%s\" already exists",
stmt_name)));
/* Make a permanent memory context for the hashtable entry */ /* Make a permanent memory context for the hashtable entry */
entrycxt = AllocSetContextCreate(TopMemoryContext, entrycxt = AllocSetContextCreate(TopMemoryContext,
...@@ -326,7 +336,7 @@ StorePreparedStatement(const char *stmt_name, ...@@ -326,7 +336,7 @@ StorePreparedStatement(const char *stmt_name,
/* Shouldn't get a failure, nor a duplicate entry */ /* Shouldn't get a failure, nor a duplicate entry */
if (!entry || found) if (!entry || found)
elog(ERROR, "Unable to store prepared statement \"%s\"!", elog(ERROR, "unable to store prepared statement \"%s\"",
stmt_name); stmt_name);
/* Fill in the hash table entry with copied data */ /* Fill in the hash table entry with copied data */
...@@ -342,7 +352,7 @@ StorePreparedStatement(const char *stmt_name, ...@@ -342,7 +352,7 @@ StorePreparedStatement(const char *stmt_name,
/* /*
* Lookup an existing query in the hash table. If the query does not * Lookup an existing query in the hash table. If the query does not
* actually exist, throw elog(ERROR) or return NULL per second parameter. * actually exist, throw ereport(ERROR) or return NULL per second parameter.
*/ */
PreparedStatement * PreparedStatement *
FetchPreparedStatement(const char *stmt_name, bool throwError) FetchPreparedStatement(const char *stmt_name, bool throwError)
...@@ -373,8 +383,10 @@ FetchPreparedStatement(const char *stmt_name, bool throwError) ...@@ -373,8 +383,10 @@ FetchPreparedStatement(const char *stmt_name, bool throwError)
entry = NULL; entry = NULL;
if (!entry && throwError) if (!entry && throwError)
elog(ERROR, "Prepared statement with name \"%s\" does not exist", ereport(ERROR,
stmt_name); (errcode(ERRCODE_UNDEFINED_PSTATEMENT),
errmsg("prepared statement \"%s\" does not exist",
stmt_name)));
return entry; return entry;
} }
...@@ -519,7 +531,9 @@ ExplainExecuteQuery(ExplainStmt *stmt, TupOutputState *tstate) ...@@ -519,7 +531,9 @@ ExplainExecuteQuery(ExplainStmt *stmt, TupOutputState *tstate)
if (execstmt->into) if (execstmt->into)
{ {
if (query->commandType != CMD_SELECT) if (query->commandType != CMD_SELECT)
elog(ERROR, "prepared statement is not a SELECT"); ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("prepared statement is not a SELECT")));
/* Copy the query so we can modify it */ /* Copy the query so we can modify it */
query = copyObject(query); query = copyObject(query);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.119 2003/07/18 23:20:32 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.120 2003/07/20 21:56:34 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -180,7 +180,8 @@ write_group_file(Relation grel) ...@@ -180,7 +180,8 @@ write_group_file(Relation grel)
i = strcspn(groname, "\n"); i = strcspn(groname, "\n");
if (groname[i] != '\0') if (groname[i] != '\0')
{ {
elog(LOG, "invalid group name \"%s\"", groname); ereport(LOG,
(errmsg("invalid group name \"%s\"", groname)));
continue; continue;
} }
...@@ -210,7 +211,8 @@ write_group_file(Relation grel) ...@@ -210,7 +211,8 @@ write_group_file(Relation grel)
j = strcspn(usename, "\n"); j = strcspn(usename, "\n");
if (usename[j] != '\0') if (usename[j] != '\0')
{ {
elog(LOG, "invalid user name \"%s\"", usename); ereport(LOG,
(errmsg("invalid user name \"%s\"", usename)));
continue; continue;
} }
...@@ -341,13 +343,15 @@ write_user_file(Relation urel) ...@@ -341,13 +343,15 @@ write_user_file(Relation urel)
i = strcspn(usename, "\n"); i = strcspn(usename, "\n");
if (usename[i] != '\0') if (usename[i] != '\0')
{ {
elog(LOG, "invalid user name \"%s\"", usename); ereport(LOG,
(errmsg("invalid user name \"%s\"", usename)));
continue; continue;
} }
i = strcspn(passwd, "\n"); i = strcspn(passwd, "\n");
if (passwd[i] != '\0') if (passwd[i] != '\0')
{ {
elog(LOG, "invalid user password \"%s\"", passwd); ereport(LOG,
(errmsg("invalid user password \"%s\"", passwd)));
continue; continue;
} }
......
This diff is collapsed.
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/vacuumlazy.c,v 1.28 2003/05/27 17:49:45 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/vacuumlazy.c,v 1.29 2003/07/20 21:56:34 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -190,8 +190,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, ...@@ -190,8 +190,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
blkno; blkno;
HeapTupleData tuple; HeapTupleData tuple;
char *relname; char *relname;
BlockNumber empty_pages, BlockNumber empty_pages;
changed_pages;
double num_tuples, double num_tuples,
tups_vacuumed, tups_vacuumed,
nkeep, nkeep,
...@@ -202,11 +201,12 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, ...@@ -202,11 +201,12 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
vac_init_rusage(&ru0); vac_init_rusage(&ru0);
relname = RelationGetRelationName(onerel); relname = RelationGetRelationName(onerel);
elog(elevel, "--Relation %s.%s--", ereport(elevel,
(errmsg("vacuuming \"%s.%s\"",
get_namespace_name(RelationGetNamespace(onerel)), get_namespace_name(RelationGetNamespace(onerel)),
relname); relname)));
empty_pages = changed_pages = 0; empty_pages = 0;
num_tuples = tups_vacuumed = nkeep = nunused = 0; num_tuples = tups_vacuumed = nkeep = nunused = 0;
nblocks = RelationGetNumberOfBlocks(onerel); nblocks = RelationGetNumberOfBlocks(onerel);
...@@ -259,9 +259,11 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, ...@@ -259,9 +259,11 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE); LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE);
if (PageIsNew(page)) if (PageIsNew(page))
{ {
elog(WARNING, "Rel %s: Uninitialized page %u - fixing", ereport(WARNING,
relname, blkno); (errmsg("relation \"%s\" page %u is uninitialized --- fixing",
relname, blkno)));
PageInit(page, BufferGetPageSize(buf), 0); PageInit(page, BufferGetPageSize(buf), 0);
empty_pages++;
lazy_record_free_space(vacrelstats, blkno, lazy_record_free_space(vacrelstats, blkno,
PageGetFreeSpace(page)); PageGetFreeSpace(page));
} }
...@@ -350,7 +352,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, ...@@ -350,7 +352,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
/* This is an expected case during concurrent vacuum */ /* This is an expected case during concurrent vacuum */
break; break;
default: default:
elog(ERROR, "Unexpected HeapTupleSatisfiesVacuum result"); elog(ERROR, "unexpected HeapTupleSatisfiesVacuum result");
break; break;
} }
...@@ -363,8 +365,8 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, ...@@ -363,8 +365,8 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
*/ */
if (onerel->rd_rel->relhasoids && if (onerel->rd_rel->relhasoids &&
!OidIsValid(HeapTupleGetOid(&tuple))) !OidIsValid(HeapTupleGetOid(&tuple)))
elog(WARNING, "Rel %s: TID %u/%u: OID IS INVALID. TUPGONE %d.", elog(WARNING, "relation \"%s\" TID %u/%u: OID is invalid",
relname, blkno, offnum, (int) tupgone); relname, blkno, offnum);
if (tupgone) if (tupgone)
{ {
...@@ -397,10 +399,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, ...@@ -397,10 +399,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
LockBuffer(buf, BUFFER_LOCK_UNLOCK); LockBuffer(buf, BUFFER_LOCK_UNLOCK);
if (pgchanged) if (pgchanged)
{
SetBufferCommitInfoNeedsSave(buf); SetBufferCommitInfoNeedsSave(buf);
changed_pages++;
}
ReleaseBuffer(buf); ReleaseBuffer(buf);
} }
...@@ -425,10 +424,18 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, ...@@ -425,10 +424,18 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
lazy_scan_index(Irel[i], vacrelstats); lazy_scan_index(Irel[i], vacrelstats);
} }
elog(elevel, "Pages %u: Changed %u, Empty %u; Tup %.0f: Vac %.0f, Keep %.0f, UnUsed %.0f.\n\tTotal %s", ereport(elevel,
nblocks, changed_pages, empty_pages, (errmsg("\"%s\": found %.0f removable, %.0f nonremovable tuples in %u pages",
num_tuples, tups_vacuumed, nkeep, nunused, RelationGetRelationName(onerel),
vac_show_rusage(&ru0)); tups_vacuumed, num_tuples, nblocks),
errdetail("%.0f dead tuples cannot be removed yet.\n"
"There were %.0f unused item pointers.\n"
"%u pages are entirely empty.\n"
"%s",
nkeep,
nunused,
empty_pages,
vac_show_rusage(&ru0))));
} }
...@@ -475,8 +482,12 @@ lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats) ...@@ -475,8 +482,12 @@ lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats)
npages++; npages++;
} }
elog(elevel, "Removed %d tuples in %d pages.\n\t%s", tupindex, npages, ereport(elevel,
vac_show_rusage(&ru0)); (errmsg("\"%s\": removed %d tuples in %d pages",
RelationGetRelationName(onerel),
tupindex, npages),
errdetail("%s",
vac_show_rusage(&ru0))));
} }
/* /*
...@@ -582,11 +593,15 @@ lazy_scan_index(Relation indrel, LVRelStats *vacrelstats) ...@@ -582,11 +593,15 @@ lazy_scan_index(Relation indrel, LVRelStats *vacrelstats)
stats->num_pages, stats->num_index_tuples, stats->num_pages, stats->num_index_tuples,
false); false);
elog(elevel, "Index %s: Pages %u, %u deleted, %u free; Tuples %.0f.\n\t%s", ereport(elevel,
(errmsg("index \"%s\" now contains %.0f tuples in %u pages",
RelationGetRelationName(indrel), RelationGetRelationName(indrel),
stats->num_pages, stats->pages_deleted, stats->pages_free,
stats->num_index_tuples, stats->num_index_tuples,
vac_show_rusage(&ru0)); stats->num_pages),
errdetail("%u index pages have been deleted, %u are currently reusable.\n"
"%s",
stats->pages_deleted, stats->pages_free,
vac_show_rusage(&ru0))));
pfree(stats); pfree(stats);
} }
...@@ -638,11 +653,17 @@ lazy_vacuum_index(Relation indrel, LVRelStats *vacrelstats) ...@@ -638,11 +653,17 @@ lazy_vacuum_index(Relation indrel, LVRelStats *vacrelstats)
stats->num_pages, stats->num_index_tuples, stats->num_pages, stats->num_index_tuples,
false); false);
elog(elevel, "Index %s: Pages %u, %u deleted, %u free; Tuples %.0f: Deleted %.0f.\n\t%s", ereport(elevel,
(errmsg("index \"%s\" now contains %.0f tuples in %u pages",
RelationGetRelationName(indrel), RelationGetRelationName(indrel),
stats->num_pages, stats->pages_deleted, stats->pages_free, stats->num_index_tuples,
stats->num_index_tuples, stats->tuples_removed, stats->num_pages),
vac_show_rusage(&ru0)); errdetail("%.0f index tuples were removed.\n"
"%u index pages have been deleted, %u are currently reusable.\n"
"%s",
stats->tuples_removed,
stats->pages_deleted, stats->pages_free,
vac_show_rusage(&ru0))));
pfree(stats); pfree(stats);
} }
...@@ -712,8 +733,7 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats) ...@@ -712,8 +733,7 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
*/ */
i = FlushRelationBuffers(onerel, new_rel_pages); i = FlushRelationBuffers(onerel, new_rel_pages);
if (i < 0) if (i < 0)
elog(ERROR, "VACUUM (lazy_truncate_heap): FlushRelationBuffers returned %d", elog(ERROR, "FlushRelationBuffers returned %d", i);
i);
/* /*
* Do the physical truncation. * Do the physical truncation.
...@@ -747,8 +767,12 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats) ...@@ -747,8 +767,12 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
* We keep the exclusive lock until commit (perhaps not necessary)? * We keep the exclusive lock until commit (perhaps not necessary)?
*/ */
elog(elevel, "Truncated %u --> %u pages.\n\t%s", old_rel_pages, ereport(elevel,
new_rel_pages, vac_show_rusage(&ru0)); (errmsg("\"%s\": truncated %u to %u pages",
RelationGetRelationName(onerel),
old_rel_pages, new_rel_pages),
errdetail("%s",
vac_show_rusage(&ru0))));
} }
/* /*
...@@ -838,7 +862,7 @@ count_nondeletable_pages(Relation onerel, LVRelStats *vacrelstats) ...@@ -838,7 +862,7 @@ count_nondeletable_pages(Relation onerel, LVRelStats *vacrelstats)
/* This is an expected case during concurrent vacuum */ /* This is an expected case during concurrent vacuum */
break; break;
default: default:
elog(ERROR, "Unexpected HeapTupleSatisfiesVacuum result"); elog(ERROR, "unexpected HeapTupleSatisfiesVacuum result");
break; break;
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.82 2003/07/17 00:55:37 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.83 2003/07/20 21:56:34 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -70,7 +70,9 @@ assign_datestyle(const char *value, bool doit, bool interactive) ...@@ -70,7 +70,9 @@ assign_datestyle(const char *value, bool doit, bool interactive)
pfree(rawstring); pfree(rawstring);
freeList(elemlist); freeList(elemlist);
if (interactive) if (interactive)
elog(ERROR, "SET DATESTYLE: invalid list syntax"); ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid list syntax for datestyle")));
return NULL; return NULL;
} }
...@@ -149,7 +151,10 @@ assign_datestyle(const char *value, bool doit, bool interactive) ...@@ -149,7 +151,10 @@ assign_datestyle(const char *value, bool doit, bool interactive)
else else
{ {
if (interactive) if (interactive)
elog(ERROR, "SET DATESTYLE: unrecognized keyword %s", tok); ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("unrecognized datestyle keyword: \"%s\"",
tok)));
ok = false; ok = false;
break; break;
} }
...@@ -164,7 +169,9 @@ assign_datestyle(const char *value, bool doit, bool interactive) ...@@ -164,7 +169,9 @@ assign_datestyle(const char *value, bool doit, bool interactive)
if (!ok) if (!ok)
{ {
if (interactive) if (interactive)
elog(ERROR, "SET DATESTYLE: conflicting specifications"); ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("conflicting datestyle specifications")));
return NULL; return NULL;
} }
...@@ -235,7 +242,7 @@ set_tz(const char *tz) ...@@ -235,7 +242,7 @@ set_tz(const char *tz)
strcpy(tzbuf, "TZ="); strcpy(tzbuf, "TZ=");
strncpy(tzbuf + 3, tz, sizeof(tzbuf) - 4); strncpy(tzbuf + 3, tz, sizeof(tzbuf) - 4);
if (putenv(tzbuf) != 0) /* shouldn't happen? */ if (putenv(tzbuf) != 0) /* shouldn't happen? */
elog(LOG, "Unable to set TZ environment variable"); elog(LOG, "unable to set TZ environment variable");
tzset(); tzset();
} }
...@@ -261,7 +268,7 @@ clear_tz(void) ...@@ -261,7 +268,7 @@ clear_tz(void)
{ {
strcpy(tzbuf, "="); strcpy(tzbuf, "=");
if (putenv(tzbuf) != 0) if (putenv(tzbuf) != 0)
elog(LOG, "Unable to clear TZ environment variable"); elog(LOG, "unable to clear TZ environment variable");
tzset(); tzset();
} }
} }
...@@ -293,7 +300,7 @@ clear_tz(void) ...@@ -293,7 +300,7 @@ clear_tz(void)
* failure mode of adopting the system-wide default is much better than * failure mode of adopting the system-wide default is much better than
* a silent failure mode of adopting UTC. * a silent failure mode of adopting UTC.
* *
* NB: this must NOT elog(ERROR). The caller must get control back so that * NB: this must NOT ereport(ERROR). The caller must get control back so that
* it can restore the old value of TZ if we don't like the new one. * it can restore the old value of TZ if we don't like the new one.
*/ */
static bool static bool
...@@ -334,7 +341,7 @@ tzset_succeeded(const char *tz) ...@@ -334,7 +341,7 @@ tzset_succeeded(const char *tz)
* We need to reject such TZ settings because they'll wreak havoc with our * We need to reject such TZ settings because they'll wreak havoc with our
* date/time arithmetic. * date/time arithmetic.
* *
* NB: this must NOT elog(ERROR). The caller must get control back so that * NB: this must NOT ereport(ERROR). The caller must get control back so that
* it can restore the old value of TZ if we don't like the new one. * it can restore the old value of TZ if we don't like the new one.
*/ */
static bool static bool
...@@ -411,7 +418,7 @@ assign_timezone(const char *value, bool doit, bool interactive) ...@@ -411,7 +418,7 @@ assign_timezone(const char *value, bool doit, bool interactive)
/* /*
* Try to parse it. XXX an invalid interval format will result in * Try to parse it. XXX an invalid interval format will result in
* elog, which is not desirable for GUC. We did what we could to * ereport, which is not desirable for GUC. We did what we could to
* guard against this in flatten_set_variable_args, but a string * guard against this in flatten_set_variable_args, but a string
* coming in from postgresql.conf might contain anything. * coming in from postgresql.conf might contain anything.
*/ */
...@@ -423,7 +430,9 @@ assign_timezone(const char *value, bool doit, bool interactive) ...@@ -423,7 +430,9 @@ assign_timezone(const char *value, bool doit, bool interactive)
if (interval->month != 0) if (interval->month != 0)
{ {
if (interactive) if (interactive)
elog(ERROR, "SET TIME ZONE: illegal INTERVAL; month not allowed"); ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid INTERVAL for time zone: month not allowed")));
pfree(interval); pfree(interval);
return NULL; return NULL;
} }
...@@ -528,17 +537,19 @@ assign_timezone(const char *value, bool doit, bool interactive) ...@@ -528,17 +537,19 @@ assign_timezone(const char *value, bool doit, bool interactive)
/* Complain if it was bad */ /* Complain if it was bad */
if (!known) if (!known)
{ {
elog(interactive ? ERROR : LOG, ereport(interactive ? ERROR : LOG,
"unrecognized timezone name \"%s\"", (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
value); errmsg("unrecognized timezone name: \"%s\"",
value)));
return NULL; return NULL;
} }
if (!acceptable) if (!acceptable)
{ {
elog(interactive ? ERROR : LOG, ereport(interactive ? ERROR : LOG,
"timezone \"%s\" appears to use leap seconds" (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
"\n\tPostgreSQL does not support leap seconds", errmsg("timezone \"%s\" appears to use leap seconds",
value); value),
errdetail("PostgreSQL does not support leap seconds")));
return NULL; return NULL;
} }
} }
...@@ -605,7 +616,9 @@ const char * ...@@ -605,7 +616,9 @@ const char *
assign_XactIsoLevel(const char *value, bool doit, bool interactive) assign_XactIsoLevel(const char *value, bool doit, bool interactive)
{ {
if (doit && interactive && SerializableSnapshot != NULL) if (doit && interactive && SerializableSnapshot != NULL)
elog(ERROR, "SET TRANSACTION ISOLATION LEVEL must be called before any query"); ereport(ERROR,
(errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
errmsg("SET TRANSACTION ISOLATION LEVEL must be called before any query")));
if (strcmp(value, "serializable") == 0) if (strcmp(value, "serializable") == 0)
{ {
...@@ -680,8 +693,10 @@ assign_client_encoding(const char *value, bool doit, bool interactive) ...@@ -680,8 +693,10 @@ assign_client_encoding(const char *value, bool doit, bool interactive)
if (SetClientEncoding(encoding, doit) < 0) if (SetClientEncoding(encoding, doit) < 0)
{ {
if (interactive) if (interactive)
elog(ERROR, "Conversion between %s and %s is not supported", ereport(ERROR,
value, GetDatabaseEncodingName()); (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("conversion between \"%s\" and \"%s\" is not supported",
value, GetDatabaseEncodingName())));
return NULL; return NULL;
} }
return value; return value;
...@@ -743,7 +758,9 @@ assign_session_authorization(const char *value, bool doit, bool interactive) ...@@ -743,7 +758,9 @@ assign_session_authorization(const char *value, bool doit, bool interactive)
if (!HeapTupleIsValid(userTup)) if (!HeapTupleIsValid(userTup))
{ {
if (interactive) if (interactive)
elog(ERROR, "user \"%s\" does not exist", value); ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("user \"%s\" does not exist", value)));
return NULL; return NULL;
} }
......
This diff is collapsed.
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.98 2003/07/16 17:25:48 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.99 2003/07/20 21:56:34 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -816,8 +816,8 @@ adjust_inherited_attrs_mutator(Node *node, ...@@ -816,8 +816,8 @@ adjust_inherited_attrs_mutator(Node *node,
var->varattno = get_attnum(context->new_relid, attname); var->varattno = get_attnum(context->new_relid, attname);
if (var->varattno == InvalidAttrNumber) if (var->varattno == InvalidAttrNumber)
elog(ERROR, "Relation \"%s\" has no column \"%s\"", elog(ERROR, "attribute \"%s\" of relation \"%s\" does not exist",
get_rel_name(context->new_relid), attname); attname, get_rel_name(context->new_relid));
var->varoattno = var->varattno; var->varoattno = var->varattno;
pfree(attname); pfree(attname);
} }
...@@ -994,8 +994,8 @@ adjust_inherited_tlist(List *tlist, Oid new_relid) ...@@ -994,8 +994,8 @@ adjust_inherited_tlist(List *tlist, Oid new_relid)
attrno = get_attnum(new_relid, resdom->resname); attrno = get_attnum(new_relid, resdom->resname);
if (attrno == InvalidAttrNumber) if (attrno == InvalidAttrNumber)
elog(ERROR, "Relation \"%s\" has no column \"%s\"", elog(ERROR, "attribute \"%s\" of relation \"%s\" does not exist",
get_rel_name(new_relid), resdom->resname); resdom->resname, get_rel_name(new_relid));
if (resdom->resno != attrno) if (resdom->resno != attrno)
{ {
resdom = (Resdom *) copyObject((Node *) resdom); resdom = (Resdom *) copyObject((Node *) resdom);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment