Commit d8528630 authored by Tom Lane's avatar Tom Lane

Error message editing in backend/catalog.

parent da4ed8bf
This diff is collapsed.
This diff is collapsed.
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.247 2003/07/20 21:56:32 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.248 2003/07/21 01:59:08 tgl Exp $
*
*
* INTERFACE ROUTINES
......@@ -147,17 +147,16 @@ static Form_pg_attribute SysAtt[] = {&a1, &a2, &a3, &a4, &a5, &a6, &a7};
/*
* This function returns a Form_pg_attribute pointer for a system attribute.
* Note that we elog if the presented attno is invalid.
* Note that we elog if the presented attno is invalid, which would only
* happen if there's a problem upstream.
*/
Form_pg_attribute
SystemAttributeDefinition(AttrNumber attno, bool relhasoids)
{
if (attno >= 0 || attno < -(int) lengthof(SysAtt))
elog(ERROR, "SystemAttributeDefinition: invalid attribute number %d",
attno);
elog(ERROR, "invalid system attribute number %d", attno);
if (attno == ObjectIdAttributeNumber && !relhasoids)
elog(ERROR, "SystemAttributeDefinition: invalid attribute number %d",
attno);
elog(ERROR, "invalid system attribute number %d", attno);
return SysAtt[-attno - 1];
}
......@@ -223,9 +222,11 @@ heap_create(const char *relname,
if (!allow_system_table_mods &&
(IsSystemNamespace(relnamespace) || IsToastNamespace(relnamespace)) &&
IsNormalProcessingMode())
elog(ERROR, "cannot create %s.%s: "
"system catalog modifications are currently disallowed",
get_namespace_name(relnamespace), relname);
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("permission denied to create \"%s.%s\"",
get_namespace_name(relnamespace), relname),
errdetail("System catalog modifications are currently disallowed.")));
/*
* Real ugly stuff to assign the proper relid in the relation
......@@ -338,7 +339,7 @@ heap_storage_create(Relation rel)
*
* this is used to make certain the tuple descriptor contains a
* valid set of attribute names and datatypes. a problem simply
* generates elog(ERROR) which aborts the current transaction.
* generates ereport(ERROR) which aborts the current transaction.
* --------------------------------
*/
void
......@@ -367,8 +368,10 @@ CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind)
{
if (SystemAttributeByName(NameStr(tupdesc->attrs[i]->attname),
tupdesc->tdhasoid) != NULL)
elog(ERROR, "name of column \"%s\" conflicts with an existing system column",
NameStr(tupdesc->attrs[i]->attname));
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_COLUMN),
errmsg("column name \"%s\" conflicts with a system column name",
NameStr(tupdesc->attrs[i]->attname))));
}
}
......@@ -381,8 +384,10 @@ CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind)
{
if (strcmp(NameStr(tupdesc->attrs[j]->attname),
NameStr(tupdesc->attrs[i]->attname)) == 0)
elog(ERROR, "column name \"%s\" is duplicated",
NameStr(tupdesc->attrs[j]->attname));
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_COLUMN),
errmsg("column name \"%s\" is duplicated",
NameStr(tupdesc->attrs[j]->attname))));
}
}
......@@ -419,23 +424,28 @@ CheckAttributeType(const char *attname, Oid atttypid)
* Berkeley-derived code that thinks it can do this...)
*/
if (atttypid == UNKNOWNOID)
elog(WARNING, "Attribute \"%s\" has an unknown type"
"\n\tProceeding with relation creation anyway",
attname);
ereport(WARNING,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("attribute \"%s\" has type UNKNOWN", attname),
errdetail("Proceeding with relation creation anyway.")));
else if (att_typtype == 'p')
{
/* Special hack for pg_statistic: allow ANYARRAY during initdb */
if (atttypid != ANYARRAYOID || IsUnderPostmaster)
elog(ERROR, "Attribute \"%s\" has pseudo-type %s",
attname, format_type_be(atttypid));
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("attribute \"%s\" has pseudo-type %s",
attname, format_type_be(atttypid))));
}
else if (att_typtype == 'c')
{
Oid typrelid = get_typ_typrelid(atttypid);
if (get_rel_relkind(typrelid) == RELKIND_COMPOSITE_TYPE)
elog(ERROR, "Attribute \"%s\" has composite type %s",
attname, format_type_be(atttypid));
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("attribute \"%s\" has composite type %s",
attname, format_type_be(atttypid))));
}
}
......@@ -719,7 +729,9 @@ heap_create_with_catalog(const char *relname,
CheckAttributeNamesTypes(tupdesc, relkind);
if (get_relname_relid(relname, relnamespace))
elog(ERROR, "Relation '%s' already exists", relname);
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_TABLE),
errmsg("relation \"%s\" already exists", relname)));
/*
* Create the relcache entry (mostly dummy at this point) and the
......@@ -955,7 +967,7 @@ RemoveAttributeById(Oid relid, AttrNumber attnum)
Int16GetDatum(attnum),
0, 0);
if (!HeapTupleIsValid(tuple)) /* shouldn't happen */
elog(ERROR, "RemoveAttributeById: Failed to find attribute %d in relation %u",
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, relid);
attStruct = (Form_pg_attribute) GETSTRUCT(tuple);
......@@ -1047,7 +1059,7 @@ RemoveAttrDefault(Oid relid, AttrNumber attnum,
heap_close(attrdef_rel, RowExclusiveLock);
if (complain && !found)
elog(ERROR, "RemoveAttrDefault: no default found for rel %u attnum %d",
elog(ERROR, "could not find attrdef tuple for relation %u attnum %d",
relid, attnum);
}
......@@ -1160,8 +1172,7 @@ heap_drop_with_catalog(Oid rid)
*/
i = FlushRelationBuffers(rel, (BlockNumber) 0);
if (i < 0)
elog(ERROR, "heap_drop_with_catalog: FlushRelationBuffers returned %d",
i);
elog(ERROR, "FlushRelationBuffers returned %d", i);
/*
* remove inheritance information
......@@ -1539,8 +1550,10 @@ AddRelationRawConstraints(Relation rel,
RelationGetRelid(rel),
RelationGetNamespace(rel),
ccname))
elog(ERROR, "constraint \"%s\" for relation \"%s\" already exists",
ccname, RelationGetRelationName(rel));
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("constraint \"%s\" for relation \"%s\" already exists",
ccname, RelationGetRelationName(rel))));
/* Check against other new constraints */
/* Needed because we don't do CommandCounterIncrement in loop */
foreach(listptr2, rawConstraints)
......@@ -1553,8 +1566,10 @@ AddRelationRawConstraints(Relation rel,
cdef2->name == NULL)
continue;
if (strcmp(cdef2->name, ccname) == 0)
elog(ERROR, "Duplicate CHECK constraint name: '%s'",
ccname);
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("CHECK constraint \"%s\" already exists",
ccname)));
}
}
else
......@@ -1613,16 +1628,22 @@ AddRelationRawConstraints(Relation rel,
* Make sure no outside relations are referred to.
*/
if (length(pstate->p_rtable) != 1)
elog(ERROR, "Only relation \"%s\" can be referenced in CHECK constraint expression",
relname);
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("only relation \"%s\" can be referenced in CHECK constraint",
relname)));
/*
* No subplans or aggregates, either...
*/
if (pstate->p_hasSubLinks)
elog(ERROR, "cannot use subselect in CHECK constraint expression");
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot use sub-select in CHECK constraint")));
if (pstate->p_hasAggs)
elog(ERROR, "cannot use aggregate function in CHECK constraint expression");
ereport(ERROR,
(errcode(ERRCODE_GROUPING_ERROR),
errmsg("cannot use aggregate in CHECK constraint")));
/*
* Constraints are evaluated with execQual, which expects an
......@@ -1727,21 +1748,29 @@ cookDefault(ParseState *pstate,
* Make sure default expr does not refer to any vars.
*/
if (contain_var_clause(expr))
elog(ERROR, "cannot use column references in DEFAULT clause");
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("cannot use column references in DEFAULT clause")));
/*
* It can't return a set either.
*/
if (expression_returns_set(expr))
elog(ERROR, "DEFAULT clause must not return a set");
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("DEFAULT clause must not return a set")));
/*
* No subplans or aggregates, either...
*/
if (pstate->p_hasSubLinks)
elog(ERROR, "cannot use subselects in DEFAULT clause");
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot use sub-select in DEFAULT clause")));
if (pstate->p_hasAggs)
elog(ERROR, "cannot use aggregate functions in DEFAULT clause");
ereport(ERROR,
(errcode(ERRCODE_GROUPING_ERROR),
errmsg("cannot use aggregate in DEFAULT clause")));
/*
* Check that it will be possible to coerce the expression to the
......@@ -1762,12 +1791,14 @@ cookDefault(ParseState *pstate,
atttypid, atttypmod,
COERCION_ASSIGNMENT,
COERCE_IMPLICIT_CAST) == NULL)
elog(ERROR, "Column \"%s\" is of type %s"
" but default expression is of type %s"
"\n\tYou will need to rewrite or cast the expression",
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("column \"%s\" is of type %s"
" but default expression is of type %s",
attname,
format_type_be(atttypid),
format_type_be(type_id));
format_type_be(type_id)),
errhint("You will need to rewrite or cast the expression.")));
}
return (expr);
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.211 2003/05/29 00:54:42 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.212 2003/07/21 01:59:08 tgl Exp $
*
*
* INTERFACE ROUTINES
......@@ -156,9 +156,8 @@ ConstructTupleDescriptor(Relation heapRelation,
/*
* here we are indexing on a normal attribute (1...n)
*/
if (atnum > natts)
elog(ERROR, "cannot create index: column %d does not exist",
atnum);
if (atnum > natts) /* safety check */
elog(ERROR, "invalid column number %d", atnum);
from = heapTupDesc->attrs[AttrNumberGetAttrOffset(atnum)];
}
......@@ -186,7 +185,7 @@ ConstructTupleDescriptor(Relation heapRelation,
/* Expressional index */
Node *indexkey;
if (indexprs == NIL)
if (indexprs == NIL) /* shouldn't happen */
elog(ERROR, "too few entries in indexprs list");
indexkey = (Node *) lfirst(indexprs);
indexprs = lnext(indexprs);
......@@ -205,7 +204,7 @@ ConstructTupleDescriptor(Relation heapRelation,
ObjectIdGetDatum(keyType),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "Type %u does not exist", keyType);
elog(ERROR, "cache lookup failed for type %u", keyType);
typeTup = (Form_pg_type) GETSTRUCT(tuple);
/*
......@@ -239,7 +238,8 @@ ConstructTupleDescriptor(Relation heapRelation,
ObjectIdGetDatum(classObjectId[i]),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "Opclass %u does not exist", classObjectId[i]);
elog(ERROR, "cache lookup failed for opclass %u",
classObjectId[i]);
keyType = ((Form_pg_opclass) GETSTRUCT(tuple))->opckeytype;
ReleaseSysCache(tuple);
......@@ -250,7 +250,7 @@ ConstructTupleDescriptor(Relation heapRelation,
ObjectIdGetDatum(keyType),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "Type %u does not exist", keyType);
elog(ERROR, "cache lookup failed for type %u", keyType);
typeTup = (Form_pg_type) GETSTRUCT(tuple);
to->atttypid = keyType;
......@@ -520,7 +520,9 @@ index_create(Oid heapRelationId,
if (!allow_system_table_mods &&
IsSystemRelation(heapRelation) &&
IsNormalProcessingMode())
elog(ERROR, "User-defined indexes on system catalogs are not supported");
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("user-defined indexes on system catalogs are not supported")));
/*
* We cannot allow indexing a shared relation after initdb (because
......@@ -530,11 +532,15 @@ index_create(Oid heapRelationId,
* under normal multi-user operation.
*/
if (shared_relation && IsUnderPostmaster)
elog(ERROR, "Shared indexes cannot be created after initdb");
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("shared indexes cannot be created after initdb")));
if (get_relname_relid(indexRelationName, namespaceId))
elog(ERROR, "relation named \"%s\" already exists",
indexRelationName);
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_TABLE),
errmsg("relation \"%s\" already exists",
indexRelationName)));
/*
* construct tuple descriptor for index tuples
......@@ -639,7 +645,7 @@ index_create(Oid heapRelationId,
constraintType = CONSTRAINT_UNIQUE;
else
{
elog(ERROR, "index_create: constraint must be PRIMARY or UNIQUE");
elog(ERROR, "constraint must be PRIMARY or UNIQUE");
constraintType = 0; /* keep compiler quiet */
}
......@@ -807,8 +813,7 @@ index_drop(Oid indexId)
ObjectIdGetDatum(indexId),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "index_drop: cache lookup failed for index %u",
indexId);
elog(ERROR, "cache lookup failed for index %u", indexId);
simple_heap_delete(indexRelation, &tuple->t_self);
......@@ -820,7 +825,7 @@ index_drop(Oid indexId)
*/
i = FlushRelationBuffers(userIndexRelation, (BlockNumber) 0);
if (i < 0)
elog(ERROR, "index_drop: FlushRelationBuffers returned %d", i);
elog(ERROR, "FlushRelationBuffers returned %d", i);
smgrunlink(DEFAULT_SMGR, userIndexRelation);
......@@ -984,8 +989,10 @@ IndexesAreActive(Relation heaprel)
if (heaprel->rd_rel->relkind != RELKIND_RELATION &&
heaprel->rd_rel->relkind != RELKIND_TOASTVALUE)
elog(ERROR, "relation %s isn't an indexable relation",
RelationGetRelationName(heaprel));
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("relation \"%s\" isn't an indexable relation",
RelationGetRelationName(heaprel))));
/* If pg_class.relhasindex is set, indexes are active */
isactive = heaprel->rd_rel->relhasindex;
......@@ -1055,8 +1062,7 @@ setRelhasindex(Oid relid, bool hasindex, bool isprimary, Oid reltoastidxid)
}
if (!HeapTupleIsValid(tuple))
elog(ERROR, "setRelhasindex: cannot find relation %u in pg_class",
relid);
elog(ERROR, "could not find tuple for relation %u", relid);
/*
* Update fields in the pg_class tuple.
......@@ -1171,7 +1177,7 @@ setNewRelfilenode(Relation relation)
}
if (!HeapTupleIsValid(tuple))
elog(ERROR, "setNewRelfilenode: cannot find relation %u in pg_class",
elog(ERROR, "could not find tuple for relation %u",
RelationGetRelid(relation));
rd_rel = (Form_pg_class) GETSTRUCT(tuple);
......@@ -1283,8 +1289,7 @@ UpdateStats(Oid relid, double reltuples)
}
if (!HeapTupleIsValid(tuple))
elog(ERROR, "UpdateStats: cannot find relation %u in pg_class",
relid);
elog(ERROR, "could not find tuple for relation %u", relid);
/*
* Figure values to insert.
......@@ -1558,7 +1563,7 @@ IndexBuildHeapScan(Relation heapRelation,
*/
if (!TransactionIdIsCurrentTransactionId(
HeapTupleHeaderGetXmin(heapTuple->t_data)))
elog(ERROR, "IndexBuildHeapScan: concurrent insert in progress");
elog(ERROR, "concurrent insert in progress");
indexIt = true;
tupleIsAlive = true;
break;
......@@ -1573,12 +1578,12 @@ IndexBuildHeapScan(Relation heapRelation,
*/
if (!TransactionIdIsCurrentTransactionId(
HeapTupleHeaderGetXmax(heapTuple->t_data)))
elog(ERROR, "IndexBuildHeapScan: concurrent delete in progress");
elog(ERROR, "concurrent delete in progress");
indexIt = true;
tupleIsAlive = false;
break;
default:
elog(ERROR, "Unexpected HeapTupleSatisfiesVacuum result");
elog(ERROR, "unexpected HeapTupleSatisfiesVacuum result");
indexIt = tupleIsAlive = false; /* keep compiler quiet */
break;
}
......@@ -1673,8 +1678,7 @@ IndexGetRelation(Oid indexId)
ObjectIdGetDatum(indexId),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "IndexGetRelation: can't find index id %u",
indexId);
elog(ERROR, "cache lookup failed for index %u", indexId);
index = (Form_pg_index) GETSTRUCT(tuple);
Assert(index->indexrelid == indexId);
......@@ -1721,8 +1725,6 @@ reindex_index(Oid indexId, bool force, bool inplace)
* index is locked down.
*/
iRel = index_open(indexId);
if (iRel == NULL)
elog(ERROR, "reindex_index: can't open index relation");
LockRelation(iRel, AccessExclusiveLock);
old = SetReindexProcessing(true);
......@@ -1732,8 +1734,6 @@ reindex_index(Oid indexId, bool force, bool inplace)
/* Open the parent heap relation */
heapRelation = heap_open(heapId, AccessExclusiveLock);
if (heapRelation == NULL)
elog(ERROR, "reindex_index: can't open heap relation");
/*
* If it's a shared index, we must do inplace processing (because we
......@@ -1747,13 +1747,17 @@ reindex_index(Oid indexId, bool force, bool inplace)
if (iRel->rd_rel->relisshared)
{
if (!IsIgnoringSystemIndexes())
elog(ERROR, "the target relation %u is shared", indexId);
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("the target relation %u is shared", indexId)));
inplace = true;
}
if (iRel->rd_isnailed)
{
if (!IsIgnoringSystemIndexes())
elog(ERROR, "the target relation %u is nailed", indexId);
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("the target relation %u is nailed", indexId)));
inplace = true;
}
......@@ -1870,7 +1874,9 @@ reindex_relation(Oid relid, bool force)
deactivate_needed = true;
}
else
elog(ERROR, "the target relation %u is shared", relid);
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("the target relation %u is shared", relid)));
}
old = SetReindexProcessing(true);
......
......@@ -13,7 +13,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.53 2003/06/27 17:03:29 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.54 2003/07/21 01:59:09 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -162,7 +162,9 @@ RangeVarGetRelid(const RangeVar *relation, bool failOK)
if (relation->catalogname)
{
if (strcmp(relation->catalogname, get_database_name(MyDatabaseId)) != 0)
elog(ERROR, "Cross-database references are not implemented");
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cross-database references are not implemented")));
}
if (relation->schemaname)
......@@ -180,11 +182,15 @@ RangeVarGetRelid(const RangeVar *relation, bool failOK)
if (!OidIsValid(relId) && !failOK)
{
if (relation->schemaname)
elog(ERROR, "Relation \"%s\".\"%s\" does not exist",
relation->schemaname, relation->relname);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_TABLE),
errmsg("relation \"%s.%s\" does not exist",
relation->schemaname, relation->relname)));
else
elog(ERROR, "Relation \"%s\" does not exist",
relation->relname);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_TABLE),
errmsg("relation \"%s\" does not exist",
relation->relname)));
}
return relId;
}
......@@ -209,14 +215,18 @@ RangeVarGetCreationNamespace(const RangeVar *newRelation)
if (newRelation->catalogname)
{
if (strcmp(newRelation->catalogname, get_database_name(MyDatabaseId)) != 0)
elog(ERROR, "Cross-database references are not implemented");
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cross-database references are not implemented")));
}
if (newRelation->istemp)
{
/* TEMP tables are created in our backend-local temp namespace */
if (newRelation->schemaname)
elog(ERROR, "TEMP tables may not specify a namespace");
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("TEMP tables may not specify a schema name")));
/* Initialize temp namespace if first time through */
if (!OidIsValid(myTempNamespace))
InitTempTableNamespace();
......@@ -230,8 +240,10 @@ RangeVarGetCreationNamespace(const RangeVar *newRelation)
CStringGetDatum(newRelation->schemaname),
0, 0, 0);
if (!OidIsValid(namespaceId))
elog(ERROR, "Namespace \"%s\" does not exist",
newRelation->schemaname);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_SCHEMA),
errmsg("schema \"%s\" does not exist",
newRelation->schemaname)));
/* we do not check for USAGE rights here! */
}
else
......@@ -240,7 +252,9 @@ RangeVarGetCreationNamespace(const RangeVar *newRelation)
recomputeNamespacePath();
namespaceId = defaultCreationNamespace;
if (!OidIsValid(namespaceId))
elog(ERROR, "No namespace has been selected to create in");
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_SCHEMA),
errmsg("no schema has been selected to create in")));
}
/* Note: callers will check for CREATE rights when appropriate */
......@@ -293,7 +307,7 @@ RelationIsVisible(Oid relid)
ObjectIdGetDatum(relid),
0, 0, 0);
if (!HeapTupleIsValid(reltup))
elog(ERROR, "Cache lookup failed for relation %u", relid);
elog(ERROR, "cache lookup failed for relation %u", relid);
relform = (Form_pg_class) GETSTRUCT(reltup);
recomputeNamespacePath();
......@@ -375,7 +389,7 @@ TypeIsVisible(Oid typid)
ObjectIdGetDatum(typid),
0, 0, 0);
if (!HeapTupleIsValid(typtup))
elog(ERROR, "Cache lookup failed for type %u", typid);
elog(ERROR, "cache lookup failed for type %u", typid);
typform = (Form_pg_type) GETSTRUCT(typtup);
recomputeNamespacePath();
......@@ -576,7 +590,7 @@ FunctionIsVisible(Oid funcid)
ObjectIdGetDatum(funcid),
0, 0, 0);
if (!HeapTupleIsValid(proctup))
elog(ERROR, "Cache lookup failed for procedure %u", funcid);
elog(ERROR, "cache lookup failed for function %u", funcid);
procform = (Form_pg_proc) GETSTRUCT(proctup);
recomputeNamespacePath();
......@@ -788,7 +802,7 @@ OperatorIsVisible(Oid oprid)
ObjectIdGetDatum(oprid),
0, 0, 0);
if (!HeapTupleIsValid(oprtup))
elog(ERROR, "Cache lookup failed for operator %u", oprid);
elog(ERROR, "cache lookup failed for operator %u", oprid);
oprform = (Form_pg_operator) GETSTRUCT(oprtup);
recomputeNamespacePath();
......@@ -1001,7 +1015,7 @@ OpclassIsVisible(Oid opcid)
ObjectIdGetDatum(opcid),
0, 0, 0);
if (!HeapTupleIsValid(opctup))
elog(ERROR, "Cache lookup failed for opclass %u", opcid);
elog(ERROR, "cache lookup failed for opclass %u", opcid);
opcform = (Form_pg_opclass) GETSTRUCT(opctup);
recomputeNamespacePath();
......@@ -1082,7 +1096,7 @@ ConversionIsVisible(Oid conid)
ObjectIdGetDatum(conid),
0, 0, 0);
if (!HeapTupleIsValid(contup))
elog(ERROR, "Cache lookup failed for conversion %u", conid);
elog(ERROR, "cache lookup failed for conversion %u", conid);
conform = (Form_pg_conversion) GETSTRUCT(contup);
recomputeNamespacePath();
......@@ -1148,11 +1162,15 @@ DeconstructQualifiedName(List *names,
* We check the catalog name and then ignore it.
*/
if (strcmp(catalogname, get_database_name(MyDatabaseId)) != 0)
elog(ERROR, "Cross-database references are not implemented");
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cross-database references are not implemented")));
break;
default:
elog(ERROR, "Improper qualified name (too many dotted names): %s",
NameListToString(names));
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("improper qualified name (too many dotted names): %s",
NameListToString(names))));
break;
}
......@@ -1165,7 +1183,7 @@ DeconstructQualifiedName(List *names,
* Process an explicitly-specified schema name: look up the schema
* and verify we have USAGE (lookup) rights in it.
*
* Returns the namespace OID. Raises elog if any problem.
* Returns the namespace OID. Raises ereport if any problem.
*/
Oid
LookupExplicitNamespace(const char *nspname)
......@@ -1177,7 +1195,9 @@ LookupExplicitNamespace(const char *nspname)
CStringGetDatum(nspname),
0, 0, 0);
if (!OidIsValid(namespaceId))
elog(ERROR, "Namespace \"%s\" does not exist", nspname);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_SCHEMA),
errmsg("schema \"%s\" does not exist", nspname)));
aclresult = pg_namespace_aclcheck(namespaceId, GetUserId(), ACL_USAGE);
if (aclresult != ACLCHECK_OK)
......@@ -1212,8 +1232,9 @@ QualifiedNameGetCreationNamespace(List *names, char **objname_p)
CStringGetDatum(schemaname),
0, 0, 0);
if (!OidIsValid(namespaceId))
elog(ERROR, "Namespace \"%s\" does not exist",
schemaname);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_SCHEMA),
errmsg("schema \"%s\" does not exist", schemaname)));
/* we do not check for USAGE rights here! */
}
else
......@@ -1222,7 +1243,9 @@ QualifiedNameGetCreationNamespace(List *names, char **objname_p)
recomputeNamespacePath();
namespaceId = defaultCreationNamespace;
if (!OidIsValid(namespaceId))
elog(ERROR, "No namespace has been selected to create in");
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_SCHEMA),
errmsg("no schema has been selected to create in")));
}
/* Note: callers will check for CREATE rights when appropriate */
......@@ -1255,7 +1278,10 @@ makeRangeVarFromNameList(List *names)
rel->relname = strVal(lthird(names));
break;
default:
elog(ERROR, "Improper relation name (too many dotted names)");
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("improper relation name (too many dotted names): %s",
NameListToString(names))));
break;
}
......@@ -1467,7 +1493,7 @@ recomputeNamespacePath(void)
{
/* syntax error in name list */
/* this should not happen if GUC checked check_search_path */
elog(ERROR, "recomputeNamespacePath: invalid list syntax");
elog(ERROR, "invalid list syntax");
}
/*
......@@ -1596,8 +1622,10 @@ InitTempTableNamespace(void)
*/
if (pg_database_aclcheck(MyDatabaseId, GetSessionUserId(),
ACL_CREATE_TEMP) != ACLCHECK_OK)
elog(ERROR, "%s: not authorized to create temp tables",
get_database_name(MyDatabaseId));
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("not authorized to create temp tables in database \"%s\"",
get_database_name(MyDatabaseId))));
snprintf(namespaceName, sizeof(namespaceName), "pg_temp_%d", MyBackendId);
......@@ -1766,7 +1794,9 @@ assign_search_path(const char *newval, bool doit, bool interactive)
if (!SearchSysCacheExists(NAMESPACENAME,
CStringGetDatum(curname),
0, 0, 0))
elog(ERROR, "Namespace \"%s\" does not exist", curname);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_SCHEMA),
errmsg("schema \"%s\" does not exist", curname)));
}
}
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.60 2003/07/04 02:51:33 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.61 2003/07/21 01:59:10 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -62,7 +62,7 @@ AggregateCreate(const char *aggName,
ObjectAddress myself,
referenced;
/* sanity checks */
/* sanity checks (caller should have caught these) */
if (!aggName)
elog(ERROR, "no aggregate name supplied");
......@@ -75,8 +75,11 @@ AggregateCreate(const char *aggName,
*/
if ((aggTransType == ANYARRAYOID || aggTransType == ANYELEMENTOID) &&
!(aggBaseType == ANYARRAYOID || aggBaseType == ANYELEMENTOID))
elog(ERROR, "an aggregate using ANYARRAY or ANYELEMENT as trans type "
"must also have one of them as its base type");
ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("cannot determine transition datatype"),
errdetail("An aggregate using ANYARRAY or ANYELEMENT as "
"trans type must have one of them as its base type.")));
/* handle transfn */
MemSet(fnArgs, 0, FUNC_MAX_ARGS * sizeof(Oid));
......@@ -102,14 +105,17 @@ AggregateCreate(const char *aggName,
* polymorphic we *must* demand exact equality.
*/
if (rettype != aggTransType)
elog(ERROR, "return type of transition function %s is not %s",
NameListToString(aggtransfnName), format_type_be(aggTransType));
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("return type of transition function %s is not %s",
NameListToString(aggtransfnName),
format_type_be(aggTransType))));
tup = SearchSysCache(PROCOID,
ObjectIdGetDatum(transfn),
0, 0, 0);
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup of function %u failed", transfn);
elog(ERROR, "cache lookup failed for function %u", transfn);
proc = (Form_pg_proc) GETSTRUCT(tup);
/*
......@@ -121,7 +127,9 @@ AggregateCreate(const char *aggName,
if (proc->proisstrict && agginitval == NULL)
{
if (!IsBinaryCoercible(aggBaseType, aggTransType))
elog(ERROR, "must not omit initval when transfn is strict and transtype is not compatible with input type");
ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("must not omit initval when transfn is strict and transtype is not compatible with input type")));
}
ReleaseSysCache(tup);
......@@ -152,8 +160,11 @@ AggregateCreate(const char *aggName,
*/
if ((finaltype == ANYARRAYOID || finaltype == ANYELEMENTOID) &&
!(aggBaseType == ANYARRAYOID || aggBaseType == ANYELEMENTOID))
elog(ERROR, "an aggregate returning ANYARRAY or ANYELEMENT "
"must also have one of them as its base type");
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("cannot determine result datatype"),
errdetail("An aggregate returning ANYARRAY or ANYELEMENT "
"must have one of them as its base type.")));
/*
* Everything looks okay. Try to create the pg_proc entry for the
......@@ -264,11 +275,15 @@ lookup_agg_function(List *fnName,
/* only valid case is a normal function not returning a set */
if (fdresult != FUNCDETAIL_NORMAL || !OidIsValid(fnOid))
elog(ERROR, "function %s does not exist",
func_signature_string(fnName, nargs, input_types));
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("function %s does not exist",
func_signature_string(fnName, nargs, input_types))));
if (retset)
elog(ERROR, "function %s returns a set",
func_signature_string(fnName, nargs, input_types));
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("function %s returns a set",
func_signature_string(fnName, nargs, input_types))));
/*
* If the given type(s) are all polymorphic, there's nothing we
......@@ -296,15 +311,19 @@ lookup_agg_function(List *fnName,
if (true_oid_array[0] != ANYARRAYOID &&
true_oid_array[0] != ANYELEMENTOID &&
!IsBinaryCoercible(input_types[0], true_oid_array[0]))
elog(ERROR, "function %s requires run-time type coercion",
func_signature_string(fnName, nargs, true_oid_array));
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("function %s requires run-time type coercion",
func_signature_string(fnName, nargs, true_oid_array))));
if (nargs == 2 &&
true_oid_array[1] != ANYARRAYOID &&
true_oid_array[1] != ANYELEMENTOID &&
!IsBinaryCoercible(input_types[1], true_oid_array[1]))
elog(ERROR, "function %s requires run-time type coercion",
func_signature_string(fnName, nargs, true_oid_array));
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("function %s requires run-time type coercion",
func_signature_string(fnName, nargs, true_oid_array))));
return fnOid;
}
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_constraint.c,v 1.13 2003/05/28 16:03:56 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_constraint.c,v 1.14 2003/07/21 01:59:10 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -427,8 +427,7 @@ RemoveConstraintById(Oid conId)
tup = systable_getnext(conscan);
if (!HeapTupleIsValid(tup))
elog(ERROR, "RemoveConstraintById: constraint %u not found",
conId);
elog(ERROR, "could not find tuple for constraint %u", conId);
con = (Form_pg_constraint) GETSTRUCT(tup);
/*
......@@ -460,12 +459,12 @@ RemoveConstraintById(Oid conId)
ObjectIdGetDatum(con->conrelid),
0, 0, 0);
if (!HeapTupleIsValid(relTup))
elog(ERROR, "cache lookup of relation %u failed",
elog(ERROR, "cache lookup failed for relation %u",
con->conrelid);
classForm = (Form_pg_class) GETSTRUCT(relTup);
if (classForm->relchecks == 0)
elog(ERROR, "RemoveConstraintById: relation %s has relchecks = 0",
if (classForm->relchecks == 0) /* should not happen */
elog(ERROR, "relation \"%s\" has relchecks = 0",
RelationGetRelationName(rel));
classForm->relchecks--;
......@@ -492,8 +491,7 @@ RemoveConstraintById(Oid conId)
}
else
{
elog(ERROR, "RemoveConstraintById: Constraint %u is not a known type",
conId);
elog(ERROR, "constraint %u is not of a known type", conId);
}
/* Fry the constraint itself */
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_conversion.c,v 1.10 2003/01/27 00:45:19 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_conversion.c,v 1.11 2003/07/21 01:59:10 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -61,7 +61,9 @@ ConversionCreate(const char *conname, Oid connamespace,
PointerGetDatum(conname),
ObjectIdGetDatum(connamespace),
0, 0))
elog(ERROR, "conversion name \"%s\" already exists", conname);
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("conversion \"%s\" already exists", conname)));
if (def)
{
......@@ -72,9 +74,11 @@ ConversionCreate(const char *conname, Oid connamespace,
if (FindDefaultConversion(connamespace,
conforencoding,
contoencoding))
elog(ERROR, "default conversion for %s to %s already exists",
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("default conversion for \"%s\" to \"%s\" already exists",
pg_encoding_to_char(conforencoding),
pg_encoding_to_char(contoencoding));
pg_encoding_to_char(contoencoding))));
}
/* open pg_conversion */
......@@ -138,12 +142,13 @@ ConversionDrop(Oid conversionOid, DropBehavior behavior)
ObjectIdGetDatum(conversionOid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "Conversion %u search from syscache failed",
conversionOid);
elog(ERROR, "cache lookup failed for conversion %u", conversionOid);
if (!superuser() &&
((Form_pg_conversion) GETSTRUCT(tuple))->conowner != GetUserId())
elog(ERROR, "DROP CONVERSION: permission denied");
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("permission denied")));
ReleaseSysCache(tuple);
......@@ -189,7 +194,7 @@ RemoveConversionById(Oid conversionOid)
if (HeapTupleIsValid(tuple = heap_getnext(scan, ForwardScanDirection)))
simple_heap_delete(rel, &tuple->t_self);
else
elog(ERROR, "conversion %u does not exist", conversionOid);
elog(ERROR, "could not find tuple for conversion %u", conversionOid);
heap_endscan(scan);
heap_close(rel, RowExclusiveLock);
}
......@@ -299,13 +304,16 @@ pg_convert_using(PG_FUNCTION_ARGS)
parsed_name = textToQualifiedNameList(conv_name, "convert_using");
convoid = FindConversionByName(parsed_name);
if (!OidIsValid(convoid))
elog(ERROR, "conversion %s not found", NameListToString(parsed_name));
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("conversion \"%s\" does not exist",
NameListToString(parsed_name))));
tuple = SearchSysCache(CONOID,
ObjectIdGetDatum(convoid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "Conversion %u search from syscache failed", convoid);
elog(ERROR, "cache lookup failed for conversion %u", convoid);
body = (Form_pg_conversion) GETSTRUCT(tuple);
/* Temporary result area should be more than big enough */
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_largeobject.c,v 1.14 2002/08/05 03:29:16 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_largeobject.c,v 1.15 2003/07/21 01:59:10 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -105,7 +105,9 @@ LargeObjectDrop(Oid loid)
heap_close(pg_largeobject, RowShareLock);
if (!found)
elog(ERROR, "LargeObjectDrop: large object %u not found", loid);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("large object %u does not exist", loid)));
}
bool
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_namespace.c,v 1.5 2002/08/05 03:29:16 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_namespace.c,v 1.6 2003/07/21 01:59:10 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -46,7 +46,9 @@ NamespaceCreate(const char *nspName, int32 ownerSysId)
if (SearchSysCacheExists(NAMESPACENAME,
PointerGetDatum(nspName),
0, 0, 0))
elog(ERROR, "namespace \"%s\" already exists", nspName);
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_SCHEMA),
errmsg("schema \"%s\" already exists", nspName)));
/* initialize nulls and values */
for (i = 0; i < Natts_pg_namespace; i++)
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.79 2003/07/04 02:51:33 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.80 2003/07/21 01:59:11 tgl Exp $
*
* NOTES
* these routines moved here from commands/define.c and somewhat cleaned up.
......@@ -80,7 +80,7 @@ validOperatorName(const char *name)
/* Can't contain any invalid characters */
/* Test string here should match op_chars in scan.l */
if (strspn(name, "~!@#^&|`?$+-*/%<>=") != len)
if (strspn(name, "~!@#^&|`?+-*/%<>=") != len)
return false;
/* Can't contain slash-star or dash-dash (comment starts) */
......@@ -102,7 +102,7 @@ validOperatorName(const char *name)
for (ic = len - 2; ic >= 0; ic--)
{
if (strchr("~!@#^&|`?$%", name[ic]))
if (strchr("~!@#^&|`?%", name[ic]))
break;
}
if (ic < 0)
......@@ -212,7 +212,10 @@ OperatorShellMake(const char *operatorName,
* validate operator name
*/
if (!validOperatorName(operatorName))
elog(ERROR, "\"%s\" is not a valid operator name", operatorName);
ereport(ERROR,
(errcode(ERRCODE_INVALID_NAME),
errmsg("\"%s\" is not a valid operator name",
operatorName)));
/*
* initialize our *nulls and *values arrays
......@@ -398,22 +401,35 @@ OperatorCreate(const char *operatorName,
* Sanity checks
*/
if (!validOperatorName(operatorName))
elog(ERROR, "\"%s\" is not a valid operator name", operatorName);
ereport(ERROR,
(errcode(ERRCODE_INVALID_NAME),
errmsg("\"%s\" is not a valid operator name",
operatorName)));
if (!OidIsValid(leftTypeId) && !OidIsValid(rightTypeId))
elog(ERROR, "at least one of leftarg or rightarg must be specified");
ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("at least one of leftarg or rightarg must be specified")));
if (!(OidIsValid(leftTypeId) && OidIsValid(rightTypeId)))
{
/* If it's not a binary op, these things mustn't be set: */
if (commutatorName)
elog(ERROR, "only binary operators can have commutators");
ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("only binary operators can have commutators")));
if (joinName)
elog(ERROR, "only binary operators can have join selectivity");
ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("only binary operators can have join selectivity")));
if (canHash)
elog(ERROR, "only binary operators can hash");
ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("only binary operators can hash")));
if (leftSortName || rightSortName || ltCompareName || gtCompareName)
elog(ERROR, "only binary operators can mergejoin");
ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("only binary operators can mergejoin")));
}
operatorObjectId = OperatorGet(operatorName,
......@@ -423,8 +439,10 @@ OperatorCreate(const char *operatorName,
&operatorAlreadyDefined);
if (operatorAlreadyDefined)
elog(ERROR, "OperatorDef: operator \"%s\" already defined",
operatorName);
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_FUNCTION),
errmsg("operator %s already exists",
operatorName)));
/*
* At this point, if operatorObjectId is not InvalidOid then we are
......@@ -615,7 +633,7 @@ OperatorCreate(const char *operatorName,
ObjectIdGetDatum(operatorObjectId),
0, 0, 0);
if (!HeapTupleIsValid(tup))
elog(ERROR, "OperatorDef: operator %u not found",
elog(ERROR, "cache lookup failed for operator %u",
operatorObjectId);
tup = heap_modifytuple(tup,
......@@ -703,7 +721,9 @@ get_other_operator(List *otherOp, Oid otherLeftTypeId, Oid otherRightTypeId,
* only self-linkage for commutation makes sense.
*/
if (!isCommutator)
elog(ERROR, "operator cannot be its own negator or sort operator");
ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("operator cannot be its own negator or sort operator")));
return InvalidOid;
}
......@@ -718,10 +738,6 @@ get_other_operator(List *otherOp, Oid otherLeftTypeId, Oid otherRightTypeId,
otherNamespace,
otherLeftTypeId,
otherRightTypeId);
if (!OidIsValid(other_oid))
elog(ERROR,
"OperatorDef: can't create operator shell \"%s\"",
NameListToString(otherOp));
return other_oid;
}
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.100 2003/07/18 23:20:32 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.101 2003/07/21 01:59:11 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -108,7 +108,8 @@ ProcedureCreate(const char *procedureName,
if (!genericParam)
ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("functions returning ANYARRAY or ANYELEMENT must have at least one argument of either type")));
errmsg("cannot determine result datatype"),
errdetail("A function returning ANYARRAY or ANYELEMENT must have at least one argument of either type.")));
}
/* Make sure we have a zero-padded param type array */
......@@ -532,7 +533,8 @@ check_sql_fn_retval(Oid rettype, char fn_typtype, List *queryTreeList)
/* This should already have been caught ... */
ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("functions returning ANYARRAY or ANYELEMENT must have at least one argument of either type")));
errmsg("cannot determine result datatype"),
errdetail("A function returning ANYARRAY or ANYELEMENT must have at least one argument of either type.")));
}
else
ereport(ERROR,
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.87 2003/05/08 22:19:56 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.88 2003/07/21 01:59:11 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -190,16 +190,22 @@ TypeCreate(const char *typeName,
if (!(internalSize > 0 ||
internalSize == -1 ||
internalSize == -2))
elog(ERROR, "TypeCreate: invalid type internal size %d",
internalSize);
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("invalid type internal size %d",
internalSize)));
if (passedByValue &&
(internalSize <= 0 || internalSize > (int16) sizeof(Datum)))
elog(ERROR, "TypeCreate: invalid type internal size %d",
internalSize);
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("invalid type internal size %d",
internalSize)));
/* Only varlena types can be toasted */
if (storage != 'p' && internalSize != -1)
elog(ERROR, "TypeCreate: fixed size types must have storage PLAIN");
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("fixed-size types must have storage PLAIN")));
/*
* initialize arrays needed for heap_formtuple or heap_modifytuple
......@@ -278,7 +284,9 @@ TypeCreate(const char *typeName,
*/
if (((Form_pg_type) GETSTRUCT(tup))->typisdefined ||
assignedTypeOid != InvalidOid)
elog(ERROR, "type %s already exists", typeName);
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("type \"%s\" already exists", typeName)));
/*
* Okay to update existing "shell" type tuple
......@@ -489,13 +497,17 @@ TypeRename(const char *oldTypeName, Oid typeNamespace,
ObjectIdGetDatum(typeNamespace),
0, 0);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "type %s does not exist", oldTypeName);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("type \"%s\" does not exist", oldTypeName)));
if (SearchSysCacheExists(TYPENAMENSP,
CStringGetDatum(newTypeName),
ObjectIdGetDatum(typeNamespace),
0, 0))
elog(ERROR, "type named %s already exists", newTypeName);
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("type \"%s\" already exists", newTypeName)));
namestrcpy(&(((Form_pg_type) GETSTRUCT(tuple))->typname), newTypeName);
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: acl.h,v 1.56 2003/06/27 14:45:32 petere Exp $
* $Id: acl.h,v 1.57 2003/07/21 01:59:11 tgl Exp $
*
* NOTES
* For backward-compatibility purposes we have to allow there
......@@ -207,7 +207,7 @@ extern AclResult pg_proc_aclcheck(Oid proc_oid, AclId userid, AclMode mode);
extern AclResult pg_language_aclcheck(Oid lang_oid, AclId userid, AclMode mode);
extern AclResult pg_namespace_aclcheck(Oid nsp_oid, AclId userid, AclMode mode);
extern void aclcheck_error(AclResult errcode, const char *objectname);
extern void aclcheck_error(AclResult aclerr, const char *objectname);
/* ownercheck routines just return true (owner) or false (not) */
extern bool pg_class_ownercheck(Oid class_oid, AclId userid);
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: elog.h,v 1.50 2003/07/20 21:56:35 tgl Exp $
* $Id: elog.h,v 1.51 2003/07/21 01:59:11 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -83,7 +83,8 @@
#define ERRCODE_WARNING_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION MAKE_SQLSTATE('0','1', '0','0','3')
#define ERRCODE_WARNING_STRING_DATA_RIGHT_TRUNCATION MAKE_SQLSTATE('0','1', '0','0','4')
/* Class 02 - No Data */
/* Class 02 - No Data --- this is also a warning class per SQL99 */
/* (do not use this class for failure conditions!) */
#define ERRCODE_NO_DATA MAKE_SQLSTATE('0','2', '0','0','0')
#define ERRCODE_NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED MAKE_SQLSTATE('0','2', '0','0','1')
......@@ -111,6 +112,7 @@
/* Class 0L - Invalid Grantor */
#define ERRCODE_INVALID_GRANTOR MAKE_SQLSTATE('0','L', '0','0','0')
#define ERRCODE_INVALID_GRANT_OPERATION MAKE_SQLSTATE('0','L', 'P','0','1')
/* Class 0P - Invalid Role Specification */
#define ERRCODE_INVALID_ROLE_SPECIFICATION MAKE_SQLSTATE('0','P', '0','0','0')
......@@ -186,6 +188,7 @@
/* Class 2B - Dependent Privilege Descriptors Still Exist */
#define ERRCODE_DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST MAKE_SQLSTATE('2','B', '0','0','0')
#define ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST MAKE_SQLSTATE('2','B', 'P','0','1')
/* Class 2D - Invalid Transaction Termination */
#define ERRCODE_INVALID_TRANSACTION_TERMINATION MAKE_SQLSTATE('2','D', '0','0','0')
......
......@@ -358,8 +358,8 @@ NOTICE: ALTER TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable(ptest1);
NOTICE: ALTER TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
DROP TABLE pktable cascade;
NOTICE: Drop cascades to constraint $2 on table fktable
NOTICE: Drop cascades to constraint $1 on table fktable
NOTICE: drop cascades to constraint $2 on table fktable
NOTICE: drop cascades to constraint $1 on table fktable
DROP TABLE fktable;
CREATE TEMP TABLE PKTABLE (ptest1 int, ptest2 inet,
PRIMARY KEY(ptest1, ptest2));
......@@ -619,9 +619,9 @@ alter table pg_class alter relname set not null;
ERROR: "pg_class" is a system catalog
-- try altering non-existent table, should fail
alter table non_existent alter column bar set not null;
ERROR: Relation "non_existent" does not exist
ERROR: relation "non_existent" does not exist
alter table non_existent alter column bar drop not null;
ERROR: Relation "non_existent" does not exist
ERROR: relation "non_existent" does not exist
-- test setting columns to null and not null and vice versa
-- test checking for null values and primary key
create table atacc1 (test int not null);
......@@ -744,7 +744,7 @@ alter table pg_class drop column relname;
ERROR: "pg_class" is a system catalog
-- try altering non-existent table, should fail
alter table foo drop column bar;
ERROR: Relation "foo" does not exist
ERROR: relation "foo" does not exist
-- test dropping columns
create table atacc1 (a int4 not null, b int4, c int4 not null, d int4);
insert into atacc1 values (1, 2, 3, 4);
......@@ -1074,7 +1074,7 @@ alter table c1 drop column f1;
select f1 from c1;
ERROR: attribute "f1" not found
drop table p1 cascade;
NOTICE: Drop cascades to table c1
NOTICE: drop cascades to table c1
create table p1 (f1 int, f2 int);
create table c1 () inherits(p1);
-- should be rejected since c1.f1 is inherited
......@@ -1085,7 +1085,7 @@ alter table p1 drop column f1;
select f1 from c1;
ERROR: attribute "f1" not found
drop table p1 cascade;
NOTICE: Drop cascades to table c1
NOTICE: drop cascades to table c1
create table p1 (f1 int, f2 int);
create table c1 () inherits(p1);
-- should be rejected since c1.f1 is inherited
......@@ -1095,7 +1095,7 @@ alter table only p1 drop column f1;
-- c1.f1 is NOT dropped, but must now be considered non-inherited
alter table c1 drop column f1;
drop table p1 cascade;
NOTICE: Drop cascades to table c1
NOTICE: drop cascades to table c1
create table p1 (f1 int, f2 int);
create table c1 (f1 int not null) inherits(p1);
NOTICE: merging attribute "f1" with inherited definition
......@@ -1106,7 +1106,7 @@ alter table only p1 drop column f1;
-- c1.f1 is still there, but no longer inherited
alter table c1 drop column f1;
drop table p1 cascade;
NOTICE: Drop cascades to table c1
NOTICE: drop cascades to table c1
create table p1(id int, name text);
create table p2(id2 int, name text, height int);
create table c1(age int) inherits(p1,p2);
......@@ -1166,8 +1166,8 @@ order by relname, attnum;
(8 rows)
drop table p1, p2 cascade;
NOTICE: Drop cascades to table c1
NOTICE: Drop cascades to table gc1
NOTICE: drop cascades to table c1
NOTICE: drop cascades to table gc1
--
-- Test the ALTER TABLE WITHOUT OIDS command
--
......@@ -1250,8 +1250,8 @@ select * from p1;
(2 rows)
drop table p1 cascade;
NOTICE: Drop cascades to table c1
NOTICE: Drop cascades to constraint p1_a1 on table c1
NOTICE: drop cascades to table c1
NOTICE: drop cascades to constraint p1_a1 on table c1
-- test that operations with a dropped column do not try to reference
-- its datatype
create domain mytype as text;
......@@ -1264,7 +1264,7 @@ select * from foo;
(1 row)
drop domain mytype cascade;
NOTICE: Drop cascades to table foo column f2
NOTICE: drop cascades to table foo column f2
select * from foo;
f1 | f3
----+----
......
......@@ -8,7 +8,7 @@ CREATE CONVERSION myconv FOR 'LATIN1' TO 'UNICODE' FROM iso8859_1_to_utf8;
-- cannot make same name conversion in same schema
--
CREATE CONVERSION myconv FOR 'LATIN1' TO 'UNICODE' FROM iso8859_1_to_utf8;
ERROR: conversion name "myconv" already exists
ERROR: conversion "myconv" already exists
--
-- create default conversion with qualified name
--
......@@ -17,7 +17,7 @@ CREATE DEFAULT CONVERSION public.mydef FOR 'LATIN1' TO 'UNICODE' FROM iso8859_1_
-- cannot make default conversion with same shcema/for_encoding/to_encoding
--
CREATE DEFAULT CONVERSION public.mydef2 FOR 'LATIN1' TO 'UNICODE' FROM iso8859_1_to_utf8;
ERROR: default conversion for LATIN1 to UNICODE already exists
ERROR: default conversion for "LATIN1" to "UNICODE" already exists
--
-- drop user defined conversion
--
......
......@@ -72,5 +72,5 @@ SELECT * FROM get_default_test();
(1 row)
DROP TYPE default_test_row CASCADE;
NOTICE: Drop cascades to function get_default_test()
NOTICE: drop cascades to function get_default_test()
DROP TABLE default_test;
......@@ -214,8 +214,8 @@ alter domain dnotnulltest drop not null; -- fails
NOTICE: "dnotnulltest" is already set to NULL
update domnotnull set col1 = null;
drop domain dnotnulltest cascade;
NOTICE: Drop cascades to table domnotnull column col2
NOTICE: Drop cascades to table domnotnull column col1
NOTICE: drop cascades to table domnotnull column col2
NOTICE: drop cascades to table domnotnull column col1
-- Test ALTER DOMAIN .. DEFAULT ..
create table domdeftest (col1 ddef1);
insert into domdeftest default values;
......
......@@ -25,7 +25,7 @@ select;
ERROR: syntax error at or near ";" at character 7
-- no such relation
select * from nonesuch;
ERROR: Relation "nonesuch" does not exist
ERROR: relation "nonesuch" does not exist
-- missing target list
select from pg_database;
ERROR: syntax error at or near "from" at character 8
......@@ -52,7 +52,7 @@ delete from;
ERROR: syntax error at or near ";" at character 12
-- no such relation
delete from nonesuch;
ERROR: Relation "nonesuch" does not exist
ERROR: relation "nonesuch" does not exist
--
-- DROP
......@@ -71,10 +71,10 @@ alter table rename;
ERROR: syntax error at or near ";" at character 19
-- no such relation
alter table nonesuch rename to newnonesuch;
ERROR: Relation "nonesuch" does not exist
ERROR: relation "nonesuch" does not exist
-- no such relation
alter table nonesuch rename to stud_emp;
ERROR: Relation "nonesuch" does not exist
ERROR: relation "nonesuch" does not exist
-- conflict
alter table stud_emp rename to aggtest;
ERROR: relation "aggtest" already exists
......@@ -84,7 +84,7 @@ ERROR: relation "stud_emp" already exists
-- attribute renaming
-- no such relation
alter table nonesuchrel rename column nonesuchatt to newnonesuchatt;
ERROR: Relation "nonesuchrel" does not exist
ERROR: relation "nonesuchrel" does not exist
-- no such attribute
alter table emp rename column nonesuchatt to newnonesuchatt;
ERROR: attribute "nonesuchatt" does not exist
......@@ -227,7 +227,7 @@ drop rule 314159;
ERROR: syntax error at or near "314159" at character 11
-- no such rule
drop rule nonesuch on noplace;
ERROR: Relation "noplace" does not exist
ERROR: relation "noplace" does not exist
-- bad keyword
drop tuple rule nonesuch;
ERROR: syntax error at or near "tuple" at character 6
......
......@@ -138,7 +138,7 @@ SELECT * FROM FKTABLE;
(5 rows)
DROP TABLE PKTABLE CASCADE;
NOTICE: Drop cascades to constraint constrname on table fktable
NOTICE: drop cascades to constraint constrname on table fktable
DROP TABLE FKTABLE;
--
-- check set default and table constraint on multiple columns
......@@ -225,10 +225,10 @@ SELECT * FROM FKTABLE;
-- this should fail for lack of CASCADE
DROP TABLE PKTABLE;
NOTICE: constraint constrname2 on table fktable depends on table pktable
ERROR: Cannot drop table pktable because other objects depend on it
Use DROP ... CASCADE to drop the dependent objects too
ERROR: cannot drop table pktable because other objects depend on it
HINT: Use DROP ... CASCADE to drop the dependent objects too.
DROP TABLE PKTABLE CASCADE;
NOTICE: Drop cascades to constraint constrname2 on table fktable
NOTICE: drop cascades to constraint constrname2 on table fktable
DROP TABLE FKTABLE;
--
-- First test, check with no on delete or on update
......
......@@ -76,7 +76,8 @@ CREATE AGGREGATE myaggp01a(BASETYPE = "ANY", SFUNC = stfnp, STYPE = int4[],
-- should ERROR: stfnp(anyarray) not matched by stfnp(int[])
CREATE AGGREGATE myaggp02a(BASETYPE = "ANY", SFUNC = stfnp, STYPE = anyarray,
FINALFUNC = ffp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- N P
-- should CREATE
CREATE AGGREGATE myaggp03a(BASETYPE = "ANY", SFUNC = stfp, STYPE = int4[],
......@@ -87,10 +88,12 @@ CREATE AGGREGATE myaggp03b(BASETYPE = "ANY", SFUNC = stfp, STYPE = int4[],
-- should ERROR: we have no way to resolve S
CREATE AGGREGATE myaggp04a(BASETYPE = "ANY", SFUNC = stfp, STYPE = anyarray,
FINALFUNC = ffp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
CREATE AGGREGATE myaggp04b(BASETYPE = "ANY", SFUNC = stfp, STYPE = anyarray,
INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- Case2 (R = P) && ((B = P) || (B = N))
-- -------------------------------------
-- S tf1 B tf2
......@@ -144,12 +147,14 @@ ERROR: function tfp(integer[], anyelement) does not exist
-- should ERROR: tfnp(anyarray, int) not matched by tfnp(int[],int)
CREATE AGGREGATE myaggp13a(BASETYPE = int, SFUNC = tfnp, STYPE = anyarray,
FINALFUNC = ffp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- P N N P
-- should ERROR: tf2p(anyarray, int) not matched by tf2p(int[],anyelement)
CREATE AGGREGATE myaggp14a(BASETYPE = int, SFUNC = tf2p, STYPE = anyarray,
FINALFUNC = ffp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- P N P N
-- should ERROR: tfnp(anyarray, anyelement) not matched by tfnp(int[],int)
CREATE AGGREGATE myaggp15a(BASETYPE = anyelement, SFUNC = tfnp,
......@@ -164,18 +169,22 @@ ERROR: function tf2p(anyarray, anyelement) does not exist
-- should ERROR: we have no way to resolve S
CREATE AGGREGATE myaggp17a(BASETYPE = int, SFUNC = tf1p, STYPE = anyarray,
FINALFUNC = ffp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
CREATE AGGREGATE myaggp17b(BASETYPE = int, SFUNC = tf1p, STYPE = anyarray,
INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- P P N P
-- should ERROR: tfp(anyarray, int) not matched by tfp(anyarray, anyelement)
CREATE AGGREGATE myaggp18a(BASETYPE = int, SFUNC = tfp, STYPE = anyarray,
FINALFUNC = ffp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
CREATE AGGREGATE myaggp18b(BASETYPE = int, SFUNC = tfp, STYPE = anyarray,
INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- P P P N
-- should ERROR: tf1p(anyarray, anyelement) not matched by tf1p(anyarray, int)
CREATE AGGREGATE myaggp19a(BASETYPE = anyelement, SFUNC = tf1p,
......@@ -204,10 +213,12 @@ CREATE AGGREGATE myaggn01b(BASETYPE = "ANY", SFUNC = stfnp, STYPE = int4[],
-- should ERROR: stfnp(anyarray) not matched by stfnp(int[])
CREATE AGGREGATE myaggn02a(BASETYPE = "ANY", SFUNC = stfnp, STYPE = anyarray,
FINALFUNC = ffnp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
CREATE AGGREGATE myaggn02b(BASETYPE = "ANY", SFUNC = stfnp, STYPE = anyarray,
INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- N P
-- should CREATE
CREATE AGGREGATE myaggn03a(BASETYPE = "ANY", SFUNC = stfp, STYPE = int4[],
......@@ -216,7 +227,8 @@ CREATE AGGREGATE myaggn03a(BASETYPE = "ANY", SFUNC = stfp, STYPE = int4[],
-- should ERROR: ffnp(anyarray) not matched by ffnp(int[])
CREATE AGGREGATE myaggn04a(BASETYPE = "ANY", SFUNC = stfp, STYPE = anyarray,
FINALFUNC = ffnp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- Case4 (R = N) && ((B = P) || (B = N))
-- -------------------------------------
-- S tf1 B tf2
......@@ -269,18 +281,22 @@ ERROR: function tfp(integer[], anyelement) does not exist
-- should ERROR: tfnp(anyarray, int) not matched by tfnp(int[],int)
CREATE AGGREGATE myaggn13a(BASETYPE = int, SFUNC = tfnp, STYPE = anyarray,
FINALFUNC = ffnp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
CREATE AGGREGATE myaggn13b(BASETYPE = int, SFUNC = tfnp, STYPE = anyarray,
INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- P N N P
-- should ERROR: tf2p(anyarray, int) not matched by tf2p(int[],anyelement)
CREATE AGGREGATE myaggn14a(BASETYPE = int, SFUNC = tf2p, STYPE = anyarray,
FINALFUNC = ffnp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
CREATE AGGREGATE myaggn14b(BASETYPE = int, SFUNC = tf2p, STYPE = anyarray,
INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- P N P N
-- should ERROR: tfnp(anyarray, anyelement) not matched by tfnp(int[],int)
CREATE AGGREGATE myaggn15a(BASETYPE = anyelement, SFUNC = tfnp,
......@@ -301,12 +317,14 @@ ERROR: function tf2p(anyarray, anyelement) does not exist
-- should ERROR: ffnp(anyarray) not matched by ffnp(int[])
CREATE AGGREGATE myaggn17a(BASETYPE = int, SFUNC = tf1p, STYPE = anyarray,
FINALFUNC = ffnp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- P P N P
-- should ERROR: tfp(anyarray, int) not matched by tfp(anyarray, anyelement)
CREATE AGGREGATE myaggn18a(BASETYPE = int, SFUNC = tfp, STYPE = anyarray,
FINALFUNC = ffnp, INITCOND = '{}');
ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have one of them as its base type
ERROR: cannot determine transition datatype
DETAIL: An aggregate using ANYARRAY or ANYELEMENT as trans type must have one of them as its base type.
-- P P P N
-- should ERROR: tf1p(anyarray, anyelement) not matched by tf1p(anyarray, int)
CREATE AGGREGATE myaggn19a(BASETYPE = anyelement, SFUNC = tf1p,
......
......@@ -69,11 +69,11 @@ SELECT * FROM atest2; -- ok
INSERT INTO atest1 VALUES (2, 'two'); -- ok
INSERT INTO atest2 VALUES ('foo', true); -- fail
ERROR: atest2: permission denied
ERROR: permission denied for "atest2"
INSERT INTO atest1 SELECT 1, b FROM atest1; -- ok
UPDATE atest1 SET a = 1 WHERE a = 2; -- ok
UPDATE atest2 SET col2 = NOT col2; -- fail
ERROR: atest2: permission denied
ERROR: permission denied for "atest2"
SELECT * FROM atest1 FOR UPDATE; -- ok
a | b
---+-----
......@@ -82,15 +82,15 @@ SELECT * FROM atest1 FOR UPDATE; -- ok
(2 rows)
SELECT * FROM atest2 FOR UPDATE; -- fail
ERROR: atest2: permission denied
ERROR: permission denied for "atest2"
DELETE FROM atest2; -- fail
ERROR: atest2: permission denied
ERROR: permission denied for "atest2"
LOCK atest2 IN ACCESS EXCLUSIVE MODE; -- fail
ERROR: atest2: permission denied
ERROR: permission denied for "atest2"
COPY atest2 FROM stdin; -- fail
ERROR: atest2: permission denied
ERROR: permission denied for "atest2"
GRANT ALL ON atest1 TO PUBLIC; -- fail
ERROR: atest1: permission denied
ERROR: permission denied for "atest1"
-- checks in subquery, both ok
SELECT * FROM atest1 WHERE ( b IN ( SELECT col1 FROM atest2 ) );
a | b
......@@ -117,33 +117,33 @@ SELECT * FROM atest1; -- ok
(2 rows)
SELECT * FROM atest2; -- fail
ERROR: atest2: permission denied
ERROR: permission denied for "atest2"
INSERT INTO atest1 VALUES (2, 'two'); -- fail
ERROR: atest1: permission denied
ERROR: permission denied for "atest1"
INSERT INTO atest2 VALUES ('foo', true); -- fail
ERROR: atest2: permission denied
ERROR: permission denied for "atest2"
INSERT INTO atest1 SELECT 1, b FROM atest1; -- fail
ERROR: atest1: permission denied
ERROR: permission denied for "atest1"
UPDATE atest1 SET a = 1 WHERE a = 2; -- fail
ERROR: atest1: permission denied
ERROR: permission denied for "atest1"
UPDATE atest2 SET col2 = NULL; -- ok
UPDATE atest2 SET col2 = NOT col2; -- fails; requires SELECT on atest2
ERROR: atest2: permission denied
ERROR: permission denied for "atest2"
UPDATE atest2 SET col2 = true WHERE atest1.a = 5; -- ok
SELECT * FROM atest1 FOR UPDATE; -- fail
ERROR: atest1: permission denied
ERROR: permission denied for "atest1"
SELECT * FROM atest2 FOR UPDATE; -- fail
ERROR: atest2: permission denied
ERROR: permission denied for "atest2"
DELETE FROM atest2; -- fail
ERROR: atest2: permission denied
ERROR: permission denied for "atest2"
LOCK atest2 IN ACCESS EXCLUSIVE MODE; -- ok
COPY atest2 FROM stdin; -- fail
ERROR: atest2: permission denied
ERROR: permission denied for "atest2"
-- checks in subquery, both fail
SELECT * FROM atest1 WHERE ( b IN ( SELECT col1 FROM atest2 ) );
ERROR: atest2: permission denied
ERROR: permission denied for "atest2"
SELECT * FROM atest2 WHERE ( col1 IN ( SELECT b FROM atest1 ) );
ERROR: atest2: permission denied
ERROR: permission denied for "atest2"
SET SESSION AUTHORIZATION regressuser4;
COPY atest2 FROM stdin; -- ok
SELECT * FROM atest1; -- ok
......@@ -159,7 +159,7 @@ CREATE TABLE atest3 (one int, two int, three int);
GRANT DELETE ON atest3 TO GROUP regressgroup2;
SET SESSION AUTHORIZATION regressuser1;
SELECT * FROM atest3; -- fail
ERROR: atest3: permission denied
ERROR: permission denied for "atest3"
DELETE FROM atest3; -- ok
-- views
SET SESSION AUTHORIZATION regressuser3;
......@@ -175,7 +175,7 @@ SELECT * FROM atestv1; -- ok
(2 rows)
SELECT * FROM atestv2; -- fail
ERROR: atest2: permission denied
ERROR: permission denied for "atest2"
GRANT SELECT ON atestv1, atestv3 TO regressuser4;
GRANT SELECT ON atestv2 TO regressuser2;
SET SESSION AUTHORIZATION regressuser4;
......@@ -187,7 +187,7 @@ SELECT * FROM atestv1; -- ok
(2 rows)
SELECT * FROM atestv2; -- fail
ERROR: atestv2: permission denied
ERROR: permission denied for "atestv2"
SELECT * FROM atestv3; -- ok
one | two | three
-----+-----+-------
......@@ -203,7 +203,7 @@ GRANT SELECT ON atestv4 TO regressuser2;
SET SESSION AUTHORIZATION regressuser2;
-- Two complex cases:
SELECT * FROM atestv3; -- fail
ERROR: atestv3: permission denied
ERROR: permission denied for "atestv3"
SELECT * FROM atestv4; -- ok (even though regressuser2 cannot access underlying atestv3)
one | two | three
-----+-----+-------
......@@ -216,7 +216,7 @@ SELECT * FROM atest2; -- ok
(1 row)
SELECT * FROM atestv2; -- fail (even though regressuser2 can access underlying atest2)
ERROR: atest2: permission denied
ERROR: permission denied for "atest2"
-- privileges on functions, languages
-- switch to superuser
\c -
......@@ -226,13 +226,13 @@ GRANT USAGE ON LANGUAGE c TO PUBLIC; -- fail
ERROR: language "c" is not trusted
SET SESSION AUTHORIZATION regressuser1;
GRANT USAGE ON LANGUAGE sql TO regressuser2; -- fail
ERROR: sql: permission denied
ERROR: permission denied for "sql"
CREATE FUNCTION testfunc1(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sql;
CREATE FUNCTION testfunc2(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sql;
REVOKE ALL ON FUNCTION testfunc1(int), testfunc2(int) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION testfunc1(int), testfunc2(int) TO regressuser2;
GRANT USAGE ON FUNCTION testfunc1(int) TO regressuser3; -- semantic error
ERROR: invalid privilege type USAGE for function object
ERROR: invalid privilege type USAGE for function
GRANT ALL PRIVILEGES ON FUNCTION testfunc1(int) TO regressuser4;
GRANT ALL PRIVILEGES ON FUNCTION testfunc_nosuch(int) TO regressuser4;
ERROR: function testfunc_nosuch(integer) does not exist
......@@ -248,12 +248,12 @@ SELECT testfunc1(5), testfunc2(5); -- ok
(1 row)
CREATE FUNCTION testfunc3(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sql; -- fail
ERROR: sql: permission denied
ERROR: permission denied for "sql"
SET SESSION AUTHORIZATION regressuser3;
SELECT testfunc1(5); -- fail
ERROR: testfunc1: permission denied
ERROR: permission denied for "testfunc1"
SELECT col1 FROM atest2 WHERE col2 = true; -- fail
ERROR: atest2: permission denied
ERROR: permission denied for "atest2"
SELECT testfunc4(true); -- ok
testfunc4
-----------
......@@ -268,7 +268,7 @@ SELECT testfunc1(5); -- ok
(1 row)
DROP FUNCTION testfunc1(int); -- fail
ERROR: testfunc1: must be owner
ERROR: must be owner of "testfunc1"
\c -
DROP FUNCTION testfunc1(int); -- ok
-- restore to sanity
......@@ -282,15 +282,15 @@ select has_table_privilege(NULL,'pg_shadow','select');
(1 row)
select has_table_privilege('pg_shad','select');
ERROR: Relation "pg_shad" does not exist
ERROR: relation "pg_shad" does not exist
select has_table_privilege('nosuchuser','pg_shadow','select');
ERROR: user "nosuchuser" does not exist
select has_table_privilege('pg_shadow','sel');
ERROR: has_table_privilege: invalid privilege type sel
select has_table_privilege(-999999,'pg_shadow','update');
ERROR: pg_class_aclcheck: invalid user id 4293967297
ERROR: user with ID 4293967297 does not exist
select has_table_privilege(1,'rule');
ERROR: pg_class_aclcheck: relation 1 not found
ERROR: relation with OID 1 does not exist
-- superuser
\c -
select has_table_privilege(current_user,'pg_shadow','select');
......@@ -551,7 +551,7 @@ ERROR: grant options can only be granted to individual users
SET SESSION AUTHORIZATION regressuser2;
GRANT SELECT ON atest4 TO regressuser3;
GRANT UPDATE ON atest4 TO regressuser3; -- fail
ERROR: atest4: permission denied
ERROR: permission denied for "atest4"
SET SESSION AUTHORIZATION regressuser1;
REVOKE SELECT ON atest4 FROM regressuser3; -- does nothing
SELECT has_table_privilege('regressuser3', 'atest4', 'SELECT'); -- true
......@@ -589,8 +589,8 @@ DROP VIEW atestv1;
DROP VIEW atestv2;
-- this should cascade to drop atestv4
DROP VIEW atestv3 CASCADE;
NOTICE: Drop cascades to rule _RETURN on view atestv4
NOTICE: Drop cascades to view atestv4
NOTICE: drop cascades to rule _RETURN on view atestv4
NOTICE: drop cascades to view atestv4
-- this should complain "does not exist"
DROP VIEW atestv4;
ERROR: view "atestv4" does not exist
......
......@@ -44,7 +44,7 @@ DROP TABLE temptest;
CREATE TEMP TABLE temptest(col int);
\c regression
SELECT * FROM temptest;
ERROR: Relation "temptest" does not exist
ERROR: relation "temptest" does not exist
-- Test ON COMMIT DELETE ROWS
CREATE TEMP TABLE temptest(col int) ON COMMIT DELETE ROWS;
BEGIN;
......@@ -78,7 +78,7 @@ SELECT * FROM temptest;
COMMIT;
SELECT * FROM temptest;
ERROR: Relation "temptest" does not exist
ERROR: relation "temptest" does not exist
-- ON COMMIT is only allowed for TEMP
CREATE TABLE temptest(col int) ON COMMIT DELETE ROWS;
ERROR: ON COMMIT can only be used on TEMP tables
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