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 @@
*
*
* 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
......@@ -350,8 +350,10 @@ CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind)
/* Sanity check on column count */
if (natts < 0 || natts > MaxHeapAttributeNumber)
elog(ERROR, "Number of columns is out of range (0 to %d)",
MaxHeapAttributeNumber);
ereport(ERROR,
(errcode(ERRCODE_TOO_MANY_COLUMNS),
errmsg("tables can have at most %d columns",
MaxHeapAttributeNumber)));
/*
* first check for collision with system attribute names
......@@ -874,8 +876,7 @@ DeleteRelationTuple(Oid relid)
ObjectIdGetDatum(relid),
0, 0, 0);
if (!HeapTupleIsValid(tup))
elog(ERROR, "DeleteRelationTuple: cache lookup failed for relation %u",
relid);
elog(ERROR, "cache lookup failed for relation %u", relid);
/* delete the relation tuple from pg_class, and finish up */
simple_heap_delete(pg_class_desc, &tup->t_self);
......@@ -1082,8 +1083,7 @@ RemoveAttrDefaultById(Oid attrdefId)
tuple = systable_getnext(scan);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "RemoveAttrDefaultById: cache lookup failed for attrdef %u",
attrdefId);
elog(ERROR, "could not find tuple for attrdef %u", attrdefId);
myrelid = ((Form_pg_attrdef) GETSTRUCT(tuple))->adrelid;
myattnum = ((Form_pg_attrdef) GETSTRUCT(tuple))->adnum;
......@@ -1105,8 +1105,8 @@ RemoveAttrDefaultById(Oid attrdefId)
Int16GetDatum(myattnum),
0, 0);
if (!HeapTupleIsValid(tuple)) /* shouldn't happen */
elog(ERROR, "RemoveAttrDefaultById: cache lookup failed for rel %u attr %d",
myrelid, myattnum);
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
myattnum, myrelid);
((Form_pg_attribute) GETSTRUCT(tuple))->atthasdef = false;
......@@ -1281,7 +1281,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin)
Int16GetDatum(attnum),
0, 0);
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));
attStruct = (Form_pg_attribute) GETSTRUCT(atttup);
if (!attStruct->atthasdef)
......@@ -1539,7 +1539,7 @@ AddRelationRawConstraints(Relation rel,
RelationGetRelid(rel),
RelationGetNamespace(rel),
ccname))
elog(ERROR, "constraint \"%s\" already exists for relation \"%s\"",
elog(ERROR, "constraint \"%s\" for relation \"%s\" already exists",
ccname, RelationGetRelationName(rel));
/* Check against other new constraints */
/* Needed because we don't do CommandCounterIncrement in loop */
......@@ -1672,7 +1672,7 @@ SetRelationNumChecks(Relation rel, int numchecks)
ObjectIdGetDatum(RelationGetRelid(rel)),
0, 0, 0);
if (!HeapTupleIsValid(reltup))
elog(ERROR, "cache lookup of relation %u failed",
elog(ERROR, "cache lookup failed for relation %u",
RelationGetRelid(rel));
relStruct = (Form_pg_class) GETSTRUCT(reltup);
......
......@@ -9,7 +9,7 @@
*
*
* 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
* The "DefineFoo" routines take the parse tree and pick out the
......@@ -91,19 +91,27 @@ DefineAggregate(List *names, List *parameters)
else if (strcasecmp(defel->defname, "initcond1") == 0)
initval = defGetString(defel);
else
elog(WARNING, "DefineAggregate: attribute \"%s\" not recognized",
defel->defname);
ereport(WARNING,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("aggregate attribute \"%s\" not recognized",
defel->defname)));
}
/*
* make sure we have our required definitions
*/
if (baseType == NULL)
elog(ERROR, "Define: \"basetype\" unspecified");
ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("aggregate basetype must be specified")));
if (transType == NULL)
elog(ERROR, "Define: \"stype\" unspecified");
ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("aggregate stype must be specified")));
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.
......@@ -112,7 +120,8 @@ DefineAggregate(List *names, List *parameters)
* 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
* 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)
baseTypeId = ANYOID;
......@@ -123,8 +132,10 @@ DefineAggregate(List *names, List *parameters)
if (get_typtype(transTypeId) == 'p' &&
transTypeId != ANYARRAYOID &&
transTypeId != ANYELEMENTOID)
elog(ERROR, "Aggregate transition datatype cannot be %s",
format_type_be(transTypeId));
ereport(ERROR,
(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
......@@ -174,8 +185,7 @@ RemoveAggregate(RemoveAggrStmt *stmt)
ObjectIdGetDatum(procOid),
0, 0, 0);
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "RemoveAggregate: couldn't find pg_proc tuple for %s",
NameListToString(aggName));
elog(ERROR, "cache lookup failed for function %u", procOid);
/* Permission check: must own agg or its namespace */
if (!pg_proc_ownercheck(procOid, GetUserId()) &&
......@@ -204,8 +214,8 @@ RenameAggregate(List *name, TypeName *basetype, const char *newname)
Oid basetypeOid;
Oid procOid;
Oid namespaceOid;
Oid oid_array[FUNC_MAX_ARGS];
HeapTuple tup;
Form_pg_proc procForm;
Relation rel;
AclResult aclresult;
......@@ -229,26 +239,32 @@ RenameAggregate(List *name, TypeName *basetype, const char *newname)
ObjectIdGetDatum(procOid),
0, 0, 0);
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "RenameAggregate: couldn't find pg_proc tuple for %s",
NameListToString(name));
elog(ERROR, "cache lookup failed for function %u", procOid);
procForm = (Form_pg_proc) GETSTRUCT(tup);
namespaceOid = ((Form_pg_proc) GETSTRUCT(tup))->pronamespace;
namespaceOid = procForm->pronamespace;
/* make sure the new name doesn't exist */
MemSet(oid_array, 0, sizeof(oid_array));
oid_array[0] = basetypeOid;
if (SearchSysCacheExists(PROCNAMENSP,
CStringGetDatum(newname),
Int16GetDatum(1),
PointerGetDatum(oid_array),
Int16GetDatum(procForm->pronargs),
PointerGetDatum(procForm->proargtypes),
ObjectIdGetDatum(namespaceOid)))
{
if (basetypeOid == ANYOID)
elog(ERROR, "function %s(*) already exists in schema %s",
newname, get_namespace_name(namespaceOid));
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_FUNCTION),
errmsg("function %s(*) already exists in schema \"%s\"",
newname,
get_namespace_name(namespaceOid))));
else
elog(ERROR, "function %s(%s) already exists in schema %s",
newname, format_type_be(basetypeOid), get_namespace_name(namespaceOid));
ereport(ERROR,
(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 */
......
......@@ -8,7 +8,7 @@
*
*
* 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)
tuple = SearchSysCache(RELOID,
ObjectIdGetDatum(relOid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "Relation \"%s\" does not exist", rel->relname);
if (!HeapTupleIsValid(tuple)) /* should not happen */
elog(ERROR, "cache lookup failed for relation %u", relOid);
if (!pg_class_ownercheck(relOid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, rel->relname);
......@@ -54,8 +54,10 @@ CheckOwnership(RangeVar *rel, bool noCatalogs)
{
if (!allowSystemTableMods &&
IsSystemClass((Form_pg_class) GETSTRUCT(tuple)))
elog(ERROR, "relation \"%s\" is a system catalog",
rel->relname);
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("relation \"%s\" is a system catalog",
rel->relname)));
}
ReleaseSysCache(tuple);
......@@ -154,6 +156,7 @@ ExecRenameStmt(RenameStmt *stmt)
}
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 @@
*
*
* 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)
{
/* No need for a WARNING if we already complained during VACUUM */
if (!vacstmt->vacuum)
elog(WARNING, "Skipping \"%s\" --- only table or database owner can ANALYZE it",
RelationGetRelationName(onerel));
ereport(WARNING,
(errmsg("skipping \"%s\" --- only table or database owner can ANALYZE it",
RelationGetRelationName(onerel))));
relation_close(onerel, AccessShareLock);
return;
}
......@@ -210,8 +211,9 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt)
{
/* No need for a WARNING if we already complained during VACUUM */
if (!vacstmt->vacuum)
elog(WARNING, "Skipping \"%s\" --- can not process indexes, views or special system tables",
RelationGetRelationName(onerel));
ereport(WARNING,
(errmsg("skipping \"%s\" --- cannot ANALYZE indexes, views or special system tables",
RelationGetRelationName(onerel))));
relation_close(onerel, AccessShareLock);
return;
}
......@@ -239,9 +241,10 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt)
return;
}
elog(elevel, "Analyzing %s.%s",
get_namespace_name(RelationGetNamespace(onerel)),
RelationGetRelationName(onerel));
ereport(elevel,
(errmsg("analyzing \"%s.%s\"",
get_namespace_name(RelationGetNamespace(onerel)),
RelationGetRelationName(onerel))));
/*
* Determine which columns to analyze
......@@ -429,7 +432,7 @@ examine_attribute(Relation onerel, int attnum)
ObjectIdGetDatum(attr->atttypid),
0, 0, 0);
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));
memcpy(stats->attrtype, GETSTRUCT(typtuple), sizeof(FormData_pg_type));
ReleaseSysCache(typtuple);
......@@ -636,8 +639,7 @@ pageloop:;
*/
targbuffer = ReadBuffer(onerel, targblock);
if (!BufferIsValid(targbuffer))
elog(ERROR, "acquire_sample_rows: ReadBuffer(%s,%u) failed",
RelationGetRelationName(onerel), targblock);
elog(ERROR, "ReadBuffer failed");
LockBuffer(targbuffer, BUFFER_LOCK_SHARE);
targpage = BufferGetPage(targbuffer);
maxoffset = PageGetMaxOffsetNumber(targpage);
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* 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
Async_Notify(char *relname)
{
if (Trace_notify)
elog(DEBUG1, "Async_Notify: %s", relname);
elog(DEBUG1, "Async_Notify(%s)", relname);
/* no point in making duplicate entries in the list ... */
if (!AsyncExistsPendingNotify(relname))
......@@ -198,7 +198,7 @@ Async_Listen(char *relname, int pid)
bool alreadyListener = false;
if (Trace_notify)
elog(DEBUG1, "Async_Listen: %s", relname);
elog(DEBUG1, "Async_Listen(%s,%d)", relname, pid);
lRel = heap_openr(ListenerRelationName, AccessExclusiveLock);
......@@ -221,7 +221,8 @@ Async_Listen(char *relname, int pid)
if (alreadyListener)
{
heap_close(lRel, AccessExclusiveLock);
elog(WARNING, "Async_Listen: We are already listening on %s", relname);
ereport(WARNING,
(errmsg("already listening on \"%s\"", relname)));
return;
}
......@@ -293,7 +294,7 @@ Async_Unlisten(char *relname, int pid)
}
if (Trace_notify)
elog(DEBUG1, "Async_Unlisten %s", relname);
elog(DEBUG1, "Async_Unlisten(%s,%d)", relname, pid);
lRel = heap_openr(ListenerRelationName, AccessExclusiveLock);
......
......@@ -11,7 +11,7 @@
*
*
* 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)
/* Check permissions */
if (!check_cluster_permitted(tableOid))
elog(ERROR, "CLUSTER: You do not own relation %s",
stmt->relation->relname);
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("permission denied")));
if (stmt->indexname == NULL)
{
......@@ -134,8 +135,7 @@ cluster(ClusterStmt *stmt)
ObjectIdGetDatum(indexOid),
0, 0, 0);
if (!HeapTupleIsValid(idxtuple))
elog(ERROR, "Cache lookup failed for index %u",
indexOid);
elog(ERROR, "cache lookup failed for index %u", indexOid);
indexForm = (Form_pg_index) GETSTRUCT(idxtuple);
if (indexForm->indisclustered)
{
......@@ -147,8 +147,10 @@ cluster(ClusterStmt *stmt)
}
if (!OidIsValid(indexOid))
elog(ERROR, "CLUSTER: No previously clustered index found on table \"%s\"",
stmt->relation->relname);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("there is no previously clustered index for table \"%s\"",
stmt->relation->relname)));
}
else
{
......@@ -156,8 +158,10 @@ cluster(ClusterStmt *stmt)
indexOid = get_relname_relid(stmt->indexname,
rel->rd_rel->relnamespace);
if (!OidIsValid(indexOid))
elog(ERROR, "CLUSTER: cannot find index \"%s\" for table \"%s\"",
stmt->indexname, stmt->relation->relname);
ereport(ERROR,
(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() */
......@@ -310,9 +314,11 @@ cluster_rel(RelToCluster *rvtc, bool recheck)
*/
if (OldIndex->rd_index == NULL ||
OldIndex->rd_index->indrelid != rvtc->tableOid)
elog(ERROR, "CLUSTER: \"%s\" is not an index for table \"%s\"",
RelationGetRelationName(OldIndex),
RelationGetRelationName(OldHeap));
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not an index for table \"%s\"",
RelationGetRelationName(OldIndex),
RelationGetRelationName(OldHeap))));
/*
* Disallow clustering on incomplete indexes (those that might not index
......@@ -321,7 +327,9 @@ cluster_rel(RelToCluster *rvtc, bool recheck)
* expensive and tedious.
*/
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)
{
AttrNumber colno;
......@@ -337,9 +345,11 @@ cluster_rel(RelToCluster *rvtc, bool recheck)
{
/* ordinary user attribute */
if (!OldHeap->rd_att->attrs[colno - 1]->attnotnull)
elog(ERROR, "CLUSTER: cannot cluster when index access method does not handle nulls"
"\n\tYou may be able to work around this by marking column \"%s\" NOT NULL",
NameStr(OldHeap->rd_att->attrs[colno - 1]->attname));
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
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)
{
......@@ -348,7 +358,9 @@ cluster_rel(RelToCluster *rvtc, bool recheck)
else
{
/* 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)
* might work for other system relations, but I ain't gonna risk it.
*/
if (IsSystemRelation(OldHeap))
elog(ERROR, "CLUSTER: cannot cluster system relation \"%s\"",
RelationGetRelationName(OldHeap));
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("\"%s\" is a system catalog",
RelationGetRelationName(OldHeap))));
/*
* Don't allow cluster on temp tables of other backends ... their
* local buffer manager is not going to cope.
*/
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 */
index_close(OldIndex);
......@@ -697,14 +713,14 @@ swap_relfilenodes(Oid r1, Oid r2)
ObjectIdGetDatum(r1),
0, 0, 0);
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);
reltup2 = SearchSysCacheCopy(RELOID,
ObjectIdGetDatum(r2),
0, 0, 0);
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);
/*
......@@ -716,13 +732,13 @@ swap_relfilenodes(Oid r1, Oid r2)
rel = relation_open(r1, NoLock);
i = FlushRelationBuffers(rel, 0);
if (i < 0)
elog(ERROR, "CLUSTER: FlushRelationBuffers returned %d", i);
elog(ERROR, "FlushRelationBuffers returned %d", i);
relation_close(rel, NoLock);
rel = relation_open(r2, NoLock);
i = FlushRelationBuffers(rel, 0);
if (i < 0)
elog(ERROR, "CLUSTER: FlushRelationBuffers returned %d", i);
elog(ERROR, "FlushRelationBuffers returned %d", i);
relation_close(rel, NoLock);
/*
......@@ -784,18 +800,18 @@ swap_relfilenodes(Oid r1, Oid r2)
long count;
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 */
count = deleteDependencyRecordsFor(RelOid_pg_class,
relform1->reltoastrelid);
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 = deleteDependencyRecordsFor(RelOid_pg_class,
relform2->reltoastrelid);
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);
/* Register new dependencies */
......
......@@ -7,7 +7,7 @@
* Copyright (c) 1996-2001, PostgreSQL Global Development Group
*
* 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)
CommentConstraint(stmt->objname, stmt->comment);
break;
default:
elog(ERROR, "An attempt was made to comment on a unknown type: %d",
stmt->objtype);
elog(ERROR, "unrecognized object type: %d",
(int) stmt->objtype);
}
}
......@@ -303,23 +303,31 @@ CommentRelation(int objtype, List *relname, char *comment)
{
case OBJECT_INDEX:
if (relation->rd_rel->relkind != RELKIND_INDEX)
elog(ERROR, "relation \"%s\" is not an index",
RelationGetRelationName(relation));
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("relation \"%s\" is not an index",
RelationGetRelationName(relation))));
break;
case OBJECT_SEQUENCE:
if (relation->rd_rel->relkind != RELKIND_SEQUENCE)
elog(ERROR, "relation \"%s\" is not a sequence",
RelationGetRelationName(relation));
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("relation \"%s\" is not a sequence",
RelationGetRelationName(relation))));
break;
case OBJECT_TABLE:
if (relation->rd_rel->relkind != RELKIND_RELATION)
elog(ERROR, "relation \"%s\" is not a table",
RelationGetRelationName(relation));
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("relation \"%s\" is not a table",
RelationGetRelationName(relation))));
break;
case OBJECT_VIEW:
if (relation->rd_rel->relkind != RELKIND_VIEW)
elog(ERROR, "relation \"%s\" is not a view",
RelationGetRelationName(relation));
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("relation \"%s\" is not a view",
RelationGetRelationName(relation))));
break;
}
......@@ -338,8 +346,8 @@ CommentRelation(int objtype, List *relname, char *comment)
* such as a table's column. The routine will check security
* restrictions and then attempt to look up the specified
* attribute. If successful, a comment is added/dropped, else an
* elog() exception is thrown. The parameters are the relation
* and attribute names, and the comments
* ereport() exception is thrown. The parameters are the relation
* and attribute names, and the comment
*/
static void
CommentAttribute(List *qualname, char *comment)
......@@ -353,8 +361,8 @@ CommentAttribute(List *qualname, char *comment)
/* Separate relname and attr name */
nnames = length(qualname);
if (nnames < 2)
elog(ERROR, "CommentAttribute: must specify relation.attribute");
if (nnames < 2) /* parser messed up */
elog(ERROR, "must specify relation and attribute");
relname = ltruncate(nnames - 1, listCopy(qualname));
attrname = strVal(nth(nnames - 1, qualname));
......@@ -371,8 +379,10 @@ CommentAttribute(List *qualname, char *comment)
attnum = get_attnum(RelationGetRelid(relation), attrname);
if (attnum == InvalidAttrNumber)
elog(ERROR, "Relation \"%s\" has no column \"%s\"",
RelationGetRelationName(relation), attrname);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("attribute \"%s\" of relation \"%s\" does not exist",
attrname, RelationGetRelationName(relation))));
/* Create the comment using the relation's oid */
......@@ -400,7 +410,9 @@ CommentDatabase(List *qualname, char *comment)
Oid oid;
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));
/*
......@@ -420,21 +432,24 @@ CommentDatabase(List *qualname, char *comment)
oid = get_database_oid(database);
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;
}
/* Only allow comments on the current database */
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;
}
/* Allow if the user matches the database dba or is a superuser */
/* Check object security */
if (!pg_database_ownercheck(oid, GetUserId()))
elog(ERROR, "you are not permitted to comment on database \"%s\"",
database);
aclcheck_error(ACLCHECK_NOT_OWNER, database);
/* Create the comment with the pg_database oid */
CreateComments(oid, RelOid_pg_database, 0, comment);
......@@ -457,15 +472,18 @@ CommentNamespace(List *qualname, char *comment)
char *namespace;
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));
oid = GetSysCacheOid(NAMESPACENAME,
CStringGetDatum(namespace),
0, 0, 0);
if (!OidIsValid(oid))
elog(ERROR, "CommentSchema: Schema \"%s\" could not be found",
namespace);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_SCHEMA),
errmsg("schema \"%s\" does not exist", namespace)));
/* Check object security */
if (!pg_namespace_ownercheck(oid, GetUserId()))
......@@ -536,15 +554,18 @@ CommentRule(List *qualname, char *comment)
}
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 */
}
if (HeapTupleIsValid(tuple = heap_getnext(scanDesc,
ForwardScanDirection)))
elog(ERROR, "There are multiple rules \"%s\""
"\n\tPlease specify a relation name as well as a rule name",
rulename);
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("there are multiple rules \"%s\"", rulename),
errhint("Specify a relation name as well as a rule name.")));
heap_endscan(scanDesc);
heap_close(RewriteRelation, AccessShareLock);
......@@ -570,7 +591,7 @@ CommentRule(List *qualname, char *comment)
PointerGetDatum(rulename),
0, 0);
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);
ruleoid = HeapTupleGetOid(tuple);
ReleaseSysCache(tuple);
......@@ -744,8 +765,8 @@ CommentTrigger(List *qualname, char *comment)
/* Separate relname and trig name */
nnames = length(qualname);
if (nnames < 2)
elog(ERROR, "CommentTrigger: must specify relation and trigger");
if (nnames < 2) /* parser messed up */
elog(ERROR, "must specify relation and trigger");
relname = ltruncate(nnames - 1, listCopy(qualname));
trigname = strVal(nth(nnames - 1, qualname));
......@@ -778,8 +799,10 @@ CommentTrigger(List *qualname, char *comment)
/* If no trigger exists for the relation specified, notify user */
if (!HeapTupleIsValid(triggertuple))
elog(ERROR, "trigger \"%s\" for relation \"%s\" does not exist",
trigname, RelationGetRelationName(relation));
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("trigger \"%s\" for relation \"%s\" does not exist",
trigname, RelationGetRelationName(relation))));
oid = HeapTupleGetOid(triggertuple);
......@@ -819,8 +842,8 @@ CommentConstraint(List *qualname, char *comment)
/* Separate relname and constraint name */
nnames = length(qualname);
if (nnames < 2)
elog(ERROR, "CommentConstraint: must specify relation and constraint");
if (nnames < 2) /* parser messed up */
elog(ERROR, "must specify relation and constraint");
relName = ltruncate(nnames - 1, listCopy(qualname));
conName = strVal(nth(nnames - 1, qualname));
......@@ -854,8 +877,10 @@ CommentConstraint(List *qualname, char *comment)
if (strcmp(NameStr(con->conname), conName) == 0)
{
if (OidIsValid(conOid))
elog(ERROR, "Relation \"%s\" has multiple constraints named \"%s\"",
RelationGetRelationName(relation), conName);
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("relation \"%s\" has multiple constraints named \"%s\"",
RelationGetRelationName(relation), conName)));
conOid = HeapTupleGetOid(tuple);
}
}
......@@ -864,8 +889,10 @@ CommentConstraint(List *qualname, char *comment)
/* If no constraint exists for the relation specified, notify user */
if (!OidIsValid(conOid))
elog(ERROR, "constraint \"%s\" for relation \"%s\" does not exist",
conName, RelationGetRelationName(relation));
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("constraint \"%s\" for relation \"%s\" does not exist",
conName, RelationGetRelationName(relation))));
/* Create the comment with the pg_constraint oid */
CreateComments(conOid, RelationGetRelid(pg_constraint), 0, comment);
......
......@@ -8,7 +8,7 @@
*
*
* 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)
Oid namespaceId;
char *conversion_name;
AclResult aclresult;
int for_encoding;
int from_encoding;
int to_encoding;
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;
List *func_name = stmt->func_name;
static Oid funcargs[] = {INT4OID, INT4OID, CSTRINGOID, CSTRINGOID, INT4OID};
......@@ -58,13 +58,19 @@ CreateConversionCommand(CreateConversionStmt *stmt)
aclcheck_error(aclresult, get_namespace_name(namespaceId));
/* Check the encoding names */
for_encoding = pg_char_to_encoding(for_encoding_name);
if (for_encoding < 0)
elog(ERROR, "Invalid for encoding name: %s", for_encoding_name);
from_encoding = pg_char_to_encoding(from_encoding_name);
if (from_encoding < 0)
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);
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
......@@ -83,7 +89,7 @@ CreateConversionCommand(CreateConversionStmt *stmt)
* conversion name)
*/
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)
Oid conversionOid;
conversionOid = FindConversionByName(name);
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);
}
......@@ -118,14 +126,16 @@ RenameConversion(List *name, const char *newname)
conversionOid = FindConversionByName(name);
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,
ObjectIdGetDatum(conversionOid),
0, 0, 0);
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "couldn't find pg_conversion tuple for %s",
NameListToString(name));
elog(ERROR, "cache lookup failed for conversion %u", conversionOid);
namespaceOid = ((Form_pg_conversion) GETSTRUCT(tup))->connamespace;
......@@ -134,10 +144,10 @@ RenameConversion(List *name, const char *newname)
CStringGetDatum(newname),
ObjectIdGetDatum(namespaceOid),
0, 0))
{
elog(ERROR, "conversion %s already exists in schema %s",
newname, get_namespace_name(namespaceOid));
}
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("conversion \"%s\" already exists in schema \"%s\"",
newname, get_namespace_name(namespaceOid))));
/* must be owner */
if (!superuser() && ((Form_pg_conversion) GETSTRUCT(tup))->conowner != GetUserId())
......
This diff is collapsed.
......@@ -9,7 +9,7 @@
*
*
* 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
* The "DefineFoo" routines take the parse tree and pick out the
......@@ -65,8 +65,10 @@ char *
defGetString(DefElem *def)
{
if (def->arg == NULL)
elog(ERROR, "Define: \"%s\" requires a parameter",
def->defname);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("%s requires a parameter",
def->defname)));
switch (nodeTag(def->arg))
{
case T_Integer:
......@@ -90,8 +92,7 @@ defGetString(DefElem *def)
case T_List:
return NameListToString((List *) def->arg);
default:
elog(ERROR, "Define: cannot interpret argument of \"%s\"",
def->defname);
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(def->arg));
}
return NULL; /* keep compiler quiet */
}
......@@ -103,8 +104,10 @@ double
defGetNumeric(DefElem *def)
{
if (def->arg == NULL)
elog(ERROR, "Define: \"%s\" requires a numeric value",
def->defname);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("%s requires a numeric value",
def->defname)));
switch (nodeTag(def->arg))
{
case T_Integer:
......@@ -112,8 +115,10 @@ defGetNumeric(DefElem *def)
case T_Float:
return floatVal(def->arg);
default:
elog(ERROR, "Define: \"%s\" requires a numeric value",
def->defname);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("%s requires a numeric value",
def->defname)));
}
return 0; /* keep compiler quiet */
}
......@@ -125,8 +130,10 @@ int64
defGetInt64(DefElem *def)
{
if (def->arg == NULL)
elog(ERROR, "Define: \"%s\" requires a numeric value",
def->defname);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("%s requires a numeric value",
def->defname)));
switch (nodeTag(def->arg))
{
case T_Integer:
......@@ -141,8 +148,10 @@ defGetInt64(DefElem *def)
return DatumGetInt64(DirectFunctionCall1(int8in,
CStringGetDatum(strVal(def->arg))));
default:
elog(ERROR, "Define: \"%s\" requires a numeric value",
def->defname);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("%s requires a numeric value",
def->defname)));
}
return 0; /* keep compiler quiet */
}
......@@ -154,8 +163,10 @@ List *
defGetQualifiedName(DefElem *def)
{
if (def->arg == NULL)
elog(ERROR, "Define: \"%s\" requires a parameter",
def->defname);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("%s requires a parameter",
def->defname)));
switch (nodeTag(def->arg))
{
case T_TypeName:
......@@ -166,8 +177,10 @@ defGetQualifiedName(DefElem *def)
/* Allow quoted name for backwards compatibility */
return makeList1(def->arg);
default:
elog(ERROR, "Define: argument of \"%s\" must be a name",
def->defname);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("argument of %s must be a name",
def->defname)));
}
return NIL; /* keep compiler quiet */
}
......@@ -182,8 +195,10 @@ TypeName *
defGetTypeName(DefElem *def)
{
if (def->arg == NULL)
elog(ERROR, "Define: \"%s\" requires a parameter",
def->defname);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("%s requires a parameter",
def->defname)));
switch (nodeTag(def->arg))
{
case T_TypeName:
......@@ -198,8 +213,10 @@ defGetTypeName(DefElem *def)
return n;
}
default:
elog(ERROR, "Define: argument of \"%s\" must be a type name",
def->defname);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("argument of %s must be a type name",
def->defname)));
}
return NULL; /* keep compiler quiet */
}
......@@ -212,15 +229,19 @@ int
defGetTypeLength(DefElem *def)
{
if (def->arg == NULL)
elog(ERROR, "Define: \"%s\" requires a parameter",
def->defname);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("%s requires a parameter",
def->defname)));
switch (nodeTag(def->arg))
{
case T_Integer:
return intVal(def->arg);
case T_Float:
elog(ERROR, "Define: \"%s\" requires an integral value",
def->defname);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("%s requires an integer value",
def->defname)));
break;
case T_String:
if (strcasecmp(strVal(def->arg), "variable") == 0)
......@@ -236,10 +257,11 @@ defGetTypeLength(DefElem *def)
/* must be an operator name */
break;
default:
elog(ERROR, "Define: cannot interpret argument of \"%s\"",
def->defname);
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(def->arg));
}
elog(ERROR, "Define: invalid argument for \"%s\": \"%s\"",
def->defname, defGetString(def));
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("invalid argument for %s: \"%s\"",
def->defname, defGetString(def))));
return 0; /* keep compiler quiet */
}
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994-5, Regents of the University of California
*
* 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)
Assert(query->commandType == CMD_SELECT);
rewritten = QueryRewrite(query);
if (length(rewritten) != 1)
elog(ERROR, "ExplainOneQuery: unexpected rewrite result");
elog(ERROR, "unexpected rewrite result");
query = (Query *) lfirst(rewritten);
Assert(query->commandType == CMD_SELECT);
/* do not actually execute the underlying query! */
......@@ -1013,8 +1013,7 @@ show_sort_keys(List *tlist, int nkeys, AttrNumber *keycols,
}
}
if (tl == NIL)
elog(ERROR, "show_sort_keys: no tlist entry for key %d",
keyresno);
elog(ERROR, "no tlist entry for key %d", keyresno);
}
appendStringInfo(str, "\n");
......
......@@ -9,7 +9,7 @@
*
*
* 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
* These routines take the parse tree and pick out the
......@@ -672,10 +672,11 @@ RenameFunction(List *name, List *argtypes, const char *newname)
{
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_FUNCTION),
errmsg("function %s already exists",
func_signature_string(name,
procForm->pronargs,
procForm->proargtypes))));
errmsg("function %s already exists in schema \"%s\"",
funcname_signature_string(newname,
procForm->pronargs,
procForm->proargtypes),
get_namespace_name(namespaceOid))));
}
/* must be owner */
......
This diff is collapsed.
......@@ -8,7 +8,7 @@
*
*
* 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)
/* Currently, we only allow plain tables to be locked */
if (rel->rd_rel->relkind != RELKIND_RELATION)
elog(ERROR, "LOCK TABLE: %s is not a table",
relation->relname);
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not a table",
relation->relname)));
relation_close(rel, NoLock); /* close rel, keep lock */
}
......
......@@ -9,7 +9,7 @@
*
*
* 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)
0))
ereport(ERROR,
(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)));
/*
......
......@@ -9,7 +9,7 @@
*
*
* 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
* The "DefineFoo" routines take the parse tree and pick out the
......@@ -100,13 +100,17 @@ DefineOperator(List *names, List *parameters)
{
typeName1 = defGetTypeName(defel);
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)
{
typeName2 = defGetTypeName(defel);
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)
functionName = defGetQualifiedName(defel);
......@@ -131,17 +135,19 @@ DefineOperator(List *names, List *parameters)
else if (strcasecmp(defel->defname, "gtcmp") == 0)
gtCompareName = defGetQualifiedName(defel);
else
{
elog(WARNING, "DefineOperator: attribute \"%s\" not recognized",
defel->defname);
}
ereport(WARNING,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("operator attribute \"%s\" not recognized",
defel->defname)));
}
/*
* make sure we have our required definitions
*/
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 */
if (typeName1)
......@@ -212,7 +218,7 @@ RemoveOperator(RemoveOperStmt *stmt)
ObjectIdGetDatum(operOid),
0, 0, 0);
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 */
if (!pg_oper_ownercheck(operOid, GetUserId()) &&
......@@ -247,8 +253,7 @@ RemoveOperatorById(Oid operOid)
ObjectIdGetDatum(operOid),
0, 0, 0);
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "RemoveOperatorById: failed to find tuple for operator %u",
operOid);
elog(ERROR, "cache lookup failed for operator %u", operOid);
simple_heap_delete(relation, &tup->t_self);
......
......@@ -14,7 +14,7 @@
*
*
* 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)
* unnamed portal).
*/
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
......@@ -66,16 +68,20 @@ PerformCursorOpen(DeclareCursorStmt *stmt)
*/
rewritten = QueryRewrite((Query *) stmt->query);
if (length(rewritten) != 1 || !IsA(lfirst(rewritten), Query))
elog(ERROR, "PerformCursorOpen: unexpected rewrite result");
elog(ERROR, "unexpected rewrite result");
query = (Query *) lfirst(rewritten);
if (query->commandType != CMD_SELECT)
elog(ERROR, "PerformCursorOpen: unexpected rewrite result");
elog(ERROR, "unexpected rewrite result");
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)
elog(ERROR, "DECLARE/UPDATE is not supported"
"\n\tCursors must be READ ONLY");
ereport(ERROR,
(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);
......@@ -152,15 +158,19 @@ PerformPortalFetch(FetchStmt *stmt,
* unnamed portal).
*/
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 */
portal = GetPortalByName(stmt->portalname);
if (!PortalIsValid(portal))
{
/* FIXME: shouldn't this be an ERROR? */
elog(WARNING, "PerformPortalFetch: portal \"%s\" not found",
stmt->portalname);
ereport(WARNING,
(errcode(ERRCODE_UNDEFINED_CURSOR),
errmsg("portal \"%s\" does not exist", stmt->portalname),
errfunction("PerformPortalFetch"))); /* for ecpg */
if (completionTag)
strcpy(completionTag, stmt->ismove ? "MOVE 0" : "FETCH 0");
return;
......@@ -197,7 +207,9 @@ PerformPortalClose(const char *name)
* unnamed portal).
*/
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
......@@ -205,8 +217,10 @@ PerformPortalClose(const char *name)
portal = GetPortalByName(name);
if (!PortalIsValid(portal))
{
elog(WARNING, "PerformPortalClose: portal \"%s\" not found",
name);
ereport(WARNING,
(errcode(ERRCODE_UNDEFINED_CURSOR),
errmsg("portal \"%s\" does not exist", name),
errfunction("PerformPortalClose"))); /* for ecpg */
return;
}
......@@ -292,7 +306,9 @@ PersistHoldablePortal(Portal portal)
* Check for improper portal use, and mark portal active.
*/
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;
/*
......@@ -347,7 +363,9 @@ PersistHoldablePortal(Portal portal)
long store_pos;
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);
......@@ -360,8 +378,7 @@ PersistHoldablePortal(Portal portal)
&should_free);
if (tup == NULL)
elog(ERROR,
"PersistHoldablePortal: unexpected end of tuple stream");
elog(ERROR, "unexpected end of tuple stream");
if (should_free)
pfree(tup);
......
......@@ -10,7 +10,7 @@
* Copyright (c) 2002-2003, PostgreSQL Global Development Group
*
* 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)
* unnamed statement).
*/
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)
{
......@@ -73,7 +75,9 @@ PrepareQuery(PrepareStmt *stmt)
commandTag = "DELETE";
break;
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 */
break;
}
......@@ -159,10 +163,14 @@ ExecuteQuery(ExecuteStmt *stmt, DestReceiver *dest)
qcontext = PortalGetHeapMemory(portal);
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);
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);
MemoryContextSwitchTo(oldContext);
......@@ -206,9 +214,9 @@ EvaluateParams(EState *estate, List *params, List *argtypes)
List *l;
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)
elog(ERROR, "EvaluateParams: wrong number of arguments");
elog(ERROR, "wrong number of arguments");
exprstates = (List *) ExecPrepareExpr((Expr *) params, estate);
......@@ -256,7 +264,7 @@ InitQueryHashTable(void)
HASH_ELEM);
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,
hash_search(prepared_queries, key, HASH_FIND, &found);
if (found)
elog(ERROR, "Prepared statement with name \"%s\" already exists",
stmt_name);
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_PSTATEMENT),
errmsg("prepared statement \"%s\" already exists",
stmt_name)));
/* Make a permanent memory context for the hashtable entry */
entrycxt = AllocSetContextCreate(TopMemoryContext,
......@@ -326,7 +336,7 @@ StorePreparedStatement(const char *stmt_name,
/* Shouldn't get a failure, nor a duplicate entry */
if (!entry || found)
elog(ERROR, "Unable to store prepared statement \"%s\"!",
elog(ERROR, "unable to store prepared statement \"%s\"",
stmt_name);
/* Fill in the hash table entry with copied data */
......@@ -342,7 +352,7 @@ StorePreparedStatement(const char *stmt_name,
/*
* 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 *
FetchPreparedStatement(const char *stmt_name, bool throwError)
......@@ -373,8 +383,10 @@ FetchPreparedStatement(const char *stmt_name, bool throwError)
entry = NULL;
if (!entry && throwError)
elog(ERROR, "Prepared statement with name \"%s\" does not exist",
stmt_name);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_PSTATEMENT),
errmsg("prepared statement \"%s\" does not exist",
stmt_name)));
return entry;
}
......@@ -519,7 +531,9 @@ ExplainExecuteQuery(ExplainStmt *stmt, TupOutputState *tstate)
if (execstmt->into)
{
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 */
query = copyObject(query);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* 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)
i = strcspn(groname, "\n");
if (groname[i] != '\0')
{
elog(LOG, "invalid group name \"%s\"", groname);
ereport(LOG,
(errmsg("invalid group name \"%s\"", groname)));
continue;
}
......@@ -210,7 +211,8 @@ write_group_file(Relation grel)
j = strcspn(usename, "\n");
if (usename[j] != '\0')
{
elog(LOG, "invalid user name \"%s\"", usename);
ereport(LOG,
(errmsg("invalid user name \"%s\"", usename)));
continue;
}
......@@ -341,13 +343,15 @@ write_user_file(Relation urel)
i = strcspn(usename, "\n");
if (usename[i] != '\0')
{
elog(LOG, "invalid user name \"%s\"", usename);
ereport(LOG,
(errmsg("invalid user name \"%s\"", usename)));
continue;
}
i = strcspn(passwd, "\n");
if (passwd[i] != '\0')
{
elog(LOG, "invalid user password \"%s\"", passwd);
ereport(LOG,
(errmsg("invalid user password \"%s\"", passwd)));
continue;
}
......
This diff is collapsed.
......@@ -31,7 +31,7 @@
*
*
* 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,
blkno;
HeapTupleData tuple;
char *relname;
BlockNumber empty_pages,
changed_pages;
BlockNumber empty_pages;
double num_tuples,
tups_vacuumed,
nkeep,
......@@ -202,11 +201,12 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
vac_init_rusage(&ru0);
relname = RelationGetRelationName(onerel);
elog(elevel, "--Relation %s.%s--",
get_namespace_name(RelationGetNamespace(onerel)),
relname);
ereport(elevel,
(errmsg("vacuuming \"%s.%s\"",
get_namespace_name(RelationGetNamespace(onerel)),
relname)));
empty_pages = changed_pages = 0;
empty_pages = 0;
num_tuples = tups_vacuumed = nkeep = nunused = 0;
nblocks = RelationGetNumberOfBlocks(onerel);
......@@ -259,9 +259,11 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE);
if (PageIsNew(page))
{
elog(WARNING, "Rel %s: Uninitialized page %u - fixing",
relname, blkno);
ereport(WARNING,
(errmsg("relation \"%s\" page %u is uninitialized --- fixing",
relname, blkno)));
PageInit(page, BufferGetPageSize(buf), 0);
empty_pages++;
lazy_record_free_space(vacrelstats, blkno,
PageGetFreeSpace(page));
}
......@@ -350,7 +352,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
/* This is an expected case during concurrent vacuum */
break;
default:
elog(ERROR, "Unexpected HeapTupleSatisfiesVacuum result");
elog(ERROR, "unexpected HeapTupleSatisfiesVacuum result");
break;
}
......@@ -363,8 +365,8 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
*/
if (onerel->rd_rel->relhasoids &&
!OidIsValid(HeapTupleGetOid(&tuple)))
elog(WARNING, "Rel %s: TID %u/%u: OID IS INVALID. TUPGONE %d.",
relname, blkno, offnum, (int) tupgone);
elog(WARNING, "relation \"%s\" TID %u/%u: OID is invalid",
relname, blkno, offnum);
if (tupgone)
{
......@@ -397,10 +399,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
if (pgchanged)
{
SetBufferCommitInfoNeedsSave(buf);
changed_pages++;
}
ReleaseBuffer(buf);
}
......@@ -425,10 +424,18 @@ lazy_scan_heap(Relation onerel, LVRelStats *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",
nblocks, changed_pages, empty_pages,
num_tuples, tups_vacuumed, nkeep, nunused,
vac_show_rusage(&ru0));
ereport(elevel,
(errmsg("\"%s\": found %.0f removable, %.0f nonremovable tuples in %u pages",
RelationGetRelationName(onerel),
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)
npages++;
}
elog(elevel, "Removed %d tuples in %d pages.\n\t%s", tupindex, npages,
vac_show_rusage(&ru0));
ereport(elevel,
(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)
stats->num_pages, stats->num_index_tuples,
false);
elog(elevel, "Index %s: Pages %u, %u deleted, %u free; Tuples %.0f.\n\t%s",
RelationGetRelationName(indrel),
stats->num_pages, stats->pages_deleted, stats->pages_free,
stats->num_index_tuples,
vac_show_rusage(&ru0));
ereport(elevel,
(errmsg("index \"%s\" now contains %.0f tuples in %u pages",
RelationGetRelationName(indrel),
stats->num_index_tuples,
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);
}
......@@ -638,11 +653,17 @@ lazy_vacuum_index(Relation indrel, LVRelStats *vacrelstats)
stats->num_pages, stats->num_index_tuples,
false);
elog(elevel, "Index %s: Pages %u, %u deleted, %u free; Tuples %.0f: Deleted %.0f.\n\t%s",
RelationGetRelationName(indrel),
stats->num_pages, stats->pages_deleted, stats->pages_free,
stats->num_index_tuples, stats->tuples_removed,
vac_show_rusage(&ru0));
ereport(elevel,
(errmsg("index \"%s\" now contains %.0f tuples in %u pages",
RelationGetRelationName(indrel),
stats->num_index_tuples,
stats->num_pages),
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);
}
......@@ -712,8 +733,7 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
*/
i = FlushRelationBuffers(onerel, new_rel_pages);
if (i < 0)
elog(ERROR, "VACUUM (lazy_truncate_heap): FlushRelationBuffers returned %d",
i);
elog(ERROR, "FlushRelationBuffers returned %d", i);
/*
* Do the physical truncation.
......@@ -747,8 +767,12 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
* We keep the exclusive lock until commit (perhaps not necessary)?
*/
elog(elevel, "Truncated %u --> %u pages.\n\t%s", old_rel_pages,
new_rel_pages, vac_show_rusage(&ru0));
ereport(elevel,
(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)
/* This is an expected case during concurrent vacuum */
break;
default:
elog(ERROR, "Unexpected HeapTupleSatisfiesVacuum result");
elog(ERROR, "unexpected HeapTupleSatisfiesVacuum result");
break;
}
......
......@@ -9,7 +9,7 @@
*
*
* 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)
pfree(rawstring);
freeList(elemlist);
if (interactive)
elog(ERROR, "SET DATESTYLE: invalid list syntax");
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid list syntax for datestyle")));
return NULL;
}
......@@ -149,7 +151,10 @@ assign_datestyle(const char *value, bool doit, bool interactive)
else
{
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;
break;
}
......@@ -164,7 +169,9 @@ assign_datestyle(const char *value, bool doit, bool interactive)
if (!ok)
{
if (interactive)
elog(ERROR, "SET DATESTYLE: conflicting specifications");
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("conflicting datestyle specifications")));
return NULL;
}
......@@ -235,7 +242,7 @@ set_tz(const char *tz)
strcpy(tzbuf, "TZ=");
strncpy(tzbuf + 3, tz, sizeof(tzbuf) - 4);
if (putenv(tzbuf) != 0) /* shouldn't happen? */
elog(LOG, "Unable to set TZ environment variable");
elog(LOG, "unable to set TZ environment variable");
tzset();
}
......@@ -261,7 +268,7 @@ clear_tz(void)
{
strcpy(tzbuf, "=");
if (putenv(tzbuf) != 0)
elog(LOG, "Unable to clear TZ environment variable");
elog(LOG, "unable to clear TZ environment variable");
tzset();
}
}
......@@ -293,7 +300,7 @@ clear_tz(void)
* failure mode of adopting the system-wide default is much better than
* 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.
*/
static bool
......@@ -334,7 +341,7 @@ tzset_succeeded(const char *tz)
* We need to reject such TZ settings because they'll wreak havoc with our
* 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.
*/
static bool
......@@ -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
* 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
* coming in from postgresql.conf might contain anything.
*/
......@@ -423,7 +430,9 @@ assign_timezone(const char *value, bool doit, bool interactive)
if (interval->month != 0)
{
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);
return NULL;
}
......@@ -528,17 +537,19 @@ assign_timezone(const char *value, bool doit, bool interactive)
/* Complain if it was bad */
if (!known)
{
elog(interactive ? ERROR : LOG,
"unrecognized timezone name \"%s\"",
value);
ereport(interactive ? ERROR : LOG,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("unrecognized timezone name: \"%s\"",
value)));
return NULL;
}
if (!acceptable)
{
elog(interactive ? ERROR : LOG,
"timezone \"%s\" appears to use leap seconds"
"\n\tPostgreSQL does not support leap seconds",
value);
ereport(interactive ? ERROR : LOG,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("timezone \"%s\" appears to use leap seconds",
value),
errdetail("PostgreSQL does not support leap seconds")));
return NULL;
}
}
......@@ -605,7 +616,9 @@ const char *
assign_XactIsoLevel(const char *value, bool doit, bool interactive)
{
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)
{
......@@ -680,8 +693,10 @@ assign_client_encoding(const char *value, bool doit, bool interactive)
if (SetClientEncoding(encoding, doit) < 0)
{
if (interactive)
elog(ERROR, "Conversion between %s and %s is not supported",
value, GetDatabaseEncodingName());
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("conversion between \"%s\" and \"%s\" is not supported",
value, GetDatabaseEncodingName())));
return NULL;
}
return value;
......@@ -743,7 +758,9 @@ assign_session_authorization(const char *value, bool doit, bool interactive)
if (!HeapTupleIsValid(userTup))
{
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;
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: parse_func.h,v 1.47 2003/07/04 02:51:34 tgl Exp $
* $Id: parse_func.h,v 1.48 2003/07/20 21:56:35 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -66,6 +66,8 @@ extern void make_fn_arguments(ParseState *pstate,
Oid *actual_arg_types,
Oid *declared_arg_types);
extern const char *funcname_signature_string(const char *funcname,
int nargs, const Oid *argtypes);
extern const char *func_signature_string(List *funcname,
int nargs, const Oid *argtypes);
......
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