*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.83 2003/07/04 02:51:33 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.84 2003/07/21 01:59:07 tgl Exp $
*
* NOTES
* See acl.h.
* the situation is impossible to clean up.
*/
if (is_grant && idtype != ACL_IDTYPE_UID && grant_option)
- elog(ERROR, "grant options can only be granted to individual users");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_GRANT_OPERATION),
+ errmsg("grant options can only be granted to individual users")));
aclitem.ai_grantor = GetUserId();
ExecuteGrantStmt_Namespace(stmt);
break;
default:
- elog(ERROR, "bogus GrantStmt.objtype %d", (int) stmt->objtype);
+ elog(ERROR, "unrecognized GrantStmt.objtype: %d",
+ (int) stmt->objtype);
}
}
AclMode priv = lfirsti(i);
if (priv & ~((AclMode) ACL_ALL_RIGHTS_RELATION))
- elog(ERROR, "invalid privilege type %s for table object",
- privilege_to_string(priv));
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_GRANT_OPERATION),
+ errmsg("invalid privilege type %s for table",
+ privilege_to_string(priv))));
privileges |= priv;
}
}
ObjectIdGetDatum(relOid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
- elog(ERROR, "relation %u not found", relOid);
+ elog(ERROR, "cache lookup failed for relation %u", relOid);
pg_class_tuple = (Form_pg_class) GETSTRUCT(tuple);
if (stmt->is_grant
&& pg_class_aclcheck(relOid, GetUserId(), ACL_GRANT_OPTION_FOR(privileges)) != ACLCHECK_OK)
aclcheck_error(ACLCHECK_NO_PRIV, relvar->relname);
+ /* Not sensible to grant on an index */
if (pg_class_tuple->relkind == RELKIND_INDEX)
- elog(ERROR, "\"%s\" is an index",
- relvar->relname);
+ ereport(ERROR,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("\"%s\" is an index",
+ relvar->relname)));
/*
* If there's no ACL, create a default using the pg_class.relowner
AclMode priv = lfirsti(i);
if (priv & ~((AclMode) ACL_ALL_RIGHTS_DATABASE))
- elog(ERROR, "invalid privilege type %s for database object",
- privilege_to_string(priv));
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_GRANT_OPERATION),
+ errmsg("invalid privilege type %s for database",
+ privilege_to_string(priv))));
privileges |= priv;
}
}
scan = heap_beginscan(relation, SnapshotNow, 1, entry);
tuple = heap_getnext(scan, ForwardScanDirection);
if (!HeapTupleIsValid(tuple))
- elog(ERROR, "database \"%s\" not found", dbname);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_DATABASE),
+ errmsg("database \"%s\" does not exist", dbname)));
pg_database_tuple = (Form_pg_database) GETSTRUCT(tuple);
if (stmt->is_grant
AclMode priv = lfirsti(i);
if (priv & ~((AclMode) ACL_ALL_RIGHTS_FUNCTION))
- elog(ERROR, "invalid privilege type %s for function object",
- privilege_to_string(priv));
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_GRANT_OPERATION),
+ errmsg("invalid privilege type %s for function",
+ privilege_to_string(priv))));
privileges |= priv;
}
}
ObjectIdGetDatum(oid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
- elog(ERROR, "function %u not found", oid);
+ elog(ERROR, "cache lookup failed for function %u", oid);
pg_proc_tuple = (Form_pg_proc) GETSTRUCT(tuple);
if (stmt->is_grant
AclMode priv = lfirsti(i);
if (priv & ~((AclMode) ACL_ALL_RIGHTS_LANGUAGE))
- elog(ERROR, "invalid privilege type %s for language object",
- privilege_to_string(priv));
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_GRANT_OPERATION),
+ errmsg("invalid privilege type %s for language",
+ privilege_to_string(priv))));
privileges |= priv;
}
}
PointerGetDatum(langname),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
- elog(ERROR, "language \"%s\" not found", langname);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("language \"%s\" does not exist", langname)));
pg_language_tuple = (Form_pg_language) GETSTRUCT(tuple);
if (!pg_language_tuple->lanpltrusted && stmt->is_grant)
- elog(ERROR, "language \"%s\" is not trusted", langname);
+ ereport(ERROR,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("language \"%s\" is not trusted", langname)));
if (stmt->is_grant
&& !superuser()
AclMode priv = lfirsti(i);
if (priv & ~((AclMode) ACL_ALL_RIGHTS_NAMESPACE))
- elog(ERROR, "invalid privilege type %s for namespace object",
- privilege_to_string(priv));
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_GRANT_OPERATION),
+ errmsg("invalid privilege type %s for schema",
+ privilege_to_string(priv))));
privileges |= priv;
}
}
CStringGetDatum(nspname),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
- elog(ERROR, "namespace \"%s\" not found", nspname);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_SCHEMA),
+ errmsg("schema \"%s\" does not exist", nspname)));
pg_namespace_tuple = (Form_pg_namespace) GETSTRUCT(tuple);
if (stmt->is_grant
case ACL_CREATE_TEMP:
return "TEMP";
default:
- elog(ERROR, "privilege_to_string: unrecognized privilege %d",
- privilege);
+ elog(ERROR, "unrecognized privilege: %d", (int) privilege);
}
return NULL; /* appease compiler */
}
ReleaseSysCache(tuple);
}
else
- elog(ERROR, "non-existent group \"%s\"", groname);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("group \"%s\" does not exist", groname)));
return id;
}
ReleaseSysCache(tuple);
}
else
- elog(WARNING, "in_group: group %u not found", gid);
+ ereport(WARNING,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("group with ID %u does not exist", gid)));
return result;
}
*/
if (acl == NULL)
{
- elog(ERROR, "aclcheck: internal error -- null ACL");
+ elog(ERROR, "null ACL");
return ACLCHECK_NO_PRIV;
}
* Standardized reporting of aclcheck permissions failures.
*/
void
-aclcheck_error(AclResult errcode, const char *objectname)
+aclcheck_error(AclResult aclerr, const char *objectname)
{
- switch (errcode)
+ switch (aclerr)
{
case ACLCHECK_OK:
/* no error, so return to caller */
break;
case ACLCHECK_NO_PRIV:
- elog(ERROR, "%s: permission denied", objectname);
+ ereport(ERROR,
+ (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+ errmsg("permission denied for \"%s\"", objectname)));
break;
case ACLCHECK_NOT_OWNER:
- elog(ERROR, "%s: must be owner", objectname);
+ ereport(ERROR,
+ (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+ errmsg("must be owner of \"%s\"", objectname)));
break;
default:
- elog(ERROR, "%s: unexpected AclResult %d",
- objectname, (int) errcode);
+ elog(ERROR, "unrecognized AclResult: %d", (int) aclerr);
break;
}
}
/*
* Exported routine for checking a user's access privileges to a table
+ *
+ * Note: we give lookup failure the full ereport treatment because the
+ * has_table_privilege() family of functions allow users to pass
+ * any random OID to this function. Likewise for the sibling functions
+ * below.
*/
AclResult
pg_class_aclcheck(Oid table_oid, AclId userid, AclMode mode)
ObjectIdGetDatum(userid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
- elog(ERROR, "pg_class_aclcheck: invalid user id %u", userid);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("user with ID %u does not exist", userid)));
usecatupd = ((Form_pg_shadow) GETSTRUCT(tuple))->usecatupd;
ObjectIdGetDatum(table_oid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
- elog(ERROR, "pg_class_aclcheck: relation %u not found", table_oid);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_TABLE),
+ errmsg("relation with OID %u does not exist", table_oid)));
/*
* Deny anyone permission to update a system catalog unless
!usecatupd)
{
#ifdef ACLDEBUG
- elog(DEBUG2, "pg_class_aclcheck: catalog update: permission denied");
+ elog(DEBUG2, "permission denied for system catalog update");
#endif
ReleaseSysCache(tuple);
return ACLCHECK_NO_PRIV;
if (usesuper)
{
#ifdef ACLDEBUG
- elog(DEBUG2, "pg_class_aclcheck: %u is superuser", userid);
+ elog(DEBUG2, "%u is superuser, home free", userid);
#endif
ReleaseSysCache(tuple);
return ACLCHECK_OK;
scan = heap_beginscan(pg_database, SnapshotNow, 1, entry);
tuple = heap_getnext(scan, ForwardScanDirection);
if (!HeapTupleIsValid(tuple))
- elog(ERROR, "pg_database_aclcheck: database %u not found", db_oid);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_DATABASE),
+ errmsg("database with OID %u does not exist", db_oid)));
aclDatum = heap_getattr(tuple, Anum_pg_database_datacl,
RelationGetDescr(pg_database), &isNull);
ObjectIdGetDatum(proc_oid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
- elog(ERROR, "pg_proc_aclcheck: function %u not found", proc_oid);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_FUNCTION),
+ errmsg("function with OID %u does not exist", proc_oid)));
aclDatum = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_proacl,
&isNull);
return ACLCHECK_OK;
/*
- * Get the function's ACL from pg_language
+ * Get the language's ACL from pg_language
*/
tuple = SearchSysCache(LANGOID,
ObjectIdGetDatum(lang_oid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
- elog(ERROR, "pg_language_aclcheck: language %u not found", lang_oid);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("language with OID %u does not exist", lang_oid)));
aclDatum = SysCacheGetAttr(LANGOID, tuple, Anum_pg_language_lanacl,
&isNull);
return ACLCHECK_OK;
/*
- * Get the function's ACL from pg_namespace
+ * Get the schema's ACL from pg_namespace
*/
tuple = SearchSysCache(NAMESPACEOID,
ObjectIdGetDatum(nsp_oid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
- elog(ERROR, "pg_namespace_aclcheck: namespace %u not found", nsp_oid);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_SCHEMA),
+ errmsg("schema with OID %u does not exist", nsp_oid)));
aclDatum = SysCacheGetAttr(NAMESPACEOID, tuple, Anum_pg_namespace_nspacl,
&isNull);
ObjectIdGetDatum(class_oid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
- elog(ERROR, "pg_class_ownercheck: relation %u not found", class_oid);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_TABLE),
+ errmsg("relation with OID %u does not exist", class_oid)));
owner_id = ((Form_pg_class) GETSTRUCT(tuple))->relowner;
ObjectIdGetDatum(type_oid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
- elog(ERROR, "pg_type_ownercheck: type %u not found", type_oid);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("type with OID %u does not exist", type_oid)));
owner_id = ((Form_pg_type) GETSTRUCT(tuple))->typowner;
ObjectIdGetDatum(oper_oid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
- elog(ERROR, "pg_oper_ownercheck: operator %u not found", oper_oid);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_FUNCTION),
+ errmsg("operator with OID %u does not exist", oper_oid)));
owner_id = ((Form_pg_operator) GETSTRUCT(tuple))->oprowner;
ObjectIdGetDatum(proc_oid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
- elog(ERROR, "pg_proc_ownercheck: function %u not found", proc_oid);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_FUNCTION),
+ errmsg("function with OID %u does not exist", proc_oid)));
owner_id = ((Form_pg_proc) GETSTRUCT(tuple))->proowner;
ObjectIdGetDatum(nsp_oid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
- elog(ERROR, "pg_namespace_ownercheck: namespace %u not found",
- nsp_oid);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_SCHEMA),
+ errmsg("schema with OID %u does not exist", nsp_oid)));
owner_id = ((Form_pg_namespace) GETSTRUCT(tuple))->nspowner;
ObjectIdGetDatum(opc_oid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
- elog(ERROR, "pg_opclass_ownercheck: operator class %u not found",
- opc_oid);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("operator class with OID %u does not exist",
+ opc_oid)));
owner_id = ((Form_pg_opclass) GETSTRUCT(tuple))->opcowner;
dbtuple = heap_getnext(scan, ForwardScanDirection);
if (!HeapTupleIsValid(dbtuple))
- elog(ERROR, "database %u does not exist", db_oid);
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_DATABASE),
+ errmsg("database with OID %u does not exist", db_oid)));
dba = ((Form_pg_database) GETSTRUCT(dbtuple))->datdba;
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/dependency.c,v 1.26 2003/06/29 00:33:42 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/dependency.c,v 1.27 2003/07/21 01:59:07 tgl Exp $
*
*-------------------------------------------------------------------------
*/
if (!recursiveDeletion(object, behavior, NOTICE,
NULL, &oktodelete, depRel))
- elog(ERROR, "Cannot drop %s because other objects depend on it"
- "\n\tUse DROP ... CASCADE to drop the dependent objects too",
- objDescription);
+ ereport(ERROR,
+ (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),
+ errmsg("cannot drop %s because other objects depend on it",
+ objDescription),
+ errhint("Use DROP ... CASCADE to drop the dependent objects too.")));
term_object_addresses(&oktodelete);
DROP_CASCADE,
showNotices ? NOTICE : DEBUG2,
&oktodelete, depRel))
- elog(ERROR, "Failed to drop all objects depending on %s",
- objDescription);
+ ereport(ERROR,
+ (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),
+ errmsg("failed to drop all objects depending on %s",
+ objDescription)));
/*
* We do not need CommandCounterIncrement here, since if step 2 did
break;
case DEPENDENCY_PIN:
/*
- * For a PIN dependency we just elog immediately; there
+ * For a PIN dependency we just ereport immediately; there
* won't be any others to examine, and we aren't ever
* going to let the user delete it.
*/
- elog(ERROR, "Cannot drop %s because it is required by the database system",
- getObjectDescription(object));
+ ereport(ERROR,
+ (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),
+ errmsg("cannot drop %s because it is required by the database system",
+ getObjectDescription(object))));
break;
default:
- elog(ERROR, "findAutoDeletableObjects: unknown dependency type '%c' for %s",
+ elog(ERROR, "unrecognized dependency type '%c' for %s",
foundDep->deptype, getObjectDescription(object));
break;
}
* depRel is the already-open pg_depend relation.
*
*
- * In RESTRICT mode, we perform all the deletions anyway, but elog a message
+ * In RESTRICT mode, we perform all the deletions anyway, but ereport a message
* and return FALSE if we find a restriction violation. performDeletion
* will then abort the transaction to nullify the deletions. We have to
* do it this way to (a) report all the direct and indirect dependencies
* another object. We have three cases:
*
* 1. At the outermost recursion level, disallow the DROP.
- * (We just elog here, rather than proceeding, since no
+ * (We just ereport here, rather than proceeding, since no
* other dependencies are likely to be interesting.)
*/
if (callingObject == NULL)
{
char *otherObjDesc = getObjectDescription(&otherObject);
- elog(ERROR, "Cannot drop %s because %s requires it"
- "\n\tYou may drop %s instead",
- objDescription, otherObjDesc, otherObjDesc);
+ ereport(ERROR,
+ (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),
+ errmsg("cannot drop %s because %s requires it",
+ objDescription, otherObjDesc),
+ errhint("You may drop %s instead.",
+ otherObjDesc)));
}
/*
* owning object to recurse back to me.
*/
if (amOwned) /* shouldn't happen */
- elog(ERROR, "recursiveDeletion: multiple INTERNAL dependencies for %s",
+ elog(ERROR, "multiple INTERNAL dependencies for %s",
objDescription);
owningObject = otherObject;
amOwned = true;
* Should not happen; PIN dependencies should have zeroes
* in the depender fields...
*/
- elog(ERROR, "recursiveDeletion: incorrect use of PIN dependency with %s",
+ elog(ERROR, "incorrect use of PIN dependency with %s",
objDescription);
break;
default:
- elog(ERROR, "recursiveDeletion: unknown dependency type '%c' for %s",
+ elog(ERROR, "unrecognized dependency type '%c' for %s",
foundDep->deptype, objDescription);
break;
}
if (amOwned)
{
if (object_address_present(&owningObject, oktodelete))
- elog(DEBUG2, "Drop auto-cascades to %s",
- getObjectDescription(&owningObject));
+ ereport(DEBUG2,
+ (errmsg("drop auto-cascades to %s",
+ getObjectDescription(&owningObject))));
else if (behavior == DROP_RESTRICT)
{
- elog(msglevel, "%s depends on %s",
- getObjectDescription(&owningObject),
- objDescription);
+ ereport(msglevel,
+ (errmsg("%s depends on %s",
+ getObjectDescription(&owningObject),
+ objDescription)));
ok = false;
}
else
- elog(msglevel, "Drop cascades to %s",
- getObjectDescription(&owningObject));
+ ereport(msglevel,
+ (errmsg("drop cascades to %s",
+ getObjectDescription(&owningObject))));
if (!recursiveDeletion(&owningObject, behavior, msglevel,
object, oktodelete, depRel))
* In that case, act like this link is AUTO, too.
*/
if (object_address_present(&otherObject, oktodelete))
- elog(DEBUG2, "Drop auto-cascades to %s",
- getObjectDescription(&otherObject));
+ ereport(DEBUG2,
+ (errmsg("drop auto-cascades to %s",
+ getObjectDescription(&otherObject))));
else if (behavior == DROP_RESTRICT)
{
- elog(msglevel, "%s depends on %s",
- getObjectDescription(&otherObject),
- objDescription);
+ ereport(msglevel,
+ (errmsg("%s depends on %s",
+ getObjectDescription(&otherObject),
+ objDescription)));
ok = false;
}
else
- elog(msglevel, "Drop cascades to %s",
- getObjectDescription(&otherObject));
+ ereport(msglevel,
+ (errmsg("drop cascades to %s",
+ getObjectDescription(&otherObject))));
if (!recursiveDeletion(&otherObject, behavior, msglevel,
object, oktodelete, depRel))
* RESTRICT case. (However, normal dependencies on the
* component object could still cause failure.)
*/
- elog(DEBUG2, "Drop auto-cascades to %s",
- getObjectDescription(&otherObject));
+ ereport(DEBUG2,
+ (errmsg("drop auto-cascades to %s",
+ getObjectDescription(&otherObject))));
if (!recursiveDeletion(&otherObject, behavior, msglevel,
object, oktodelete, depRel))
case DEPENDENCY_PIN:
/*
- * For a PIN dependency we just elog immediately; there
+ * For a PIN dependency we just ereport immediately; there
* won't be any others to report.
*/
- elog(ERROR, "Cannot drop %s because it is required by the database system",
- objDescription);
+ ereport(ERROR,
+ (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),
+ errmsg("cannot drop %s because it is required by the database system",
+ objDescription)));
break;
default:
- elog(ERROR, "recursiveDeletion: unknown dependency type '%c' for %s",
+ elog(ERROR, "unrecognized dependency type '%c' for %s",
foundDep->deptype, objDescription);
break;
}
break;
default:
- elog(ERROR, "doDeletion: Unsupported object class %u",
+ elog(ERROR, "unrecognized object class: %u",
object->classId);
}
}
rtables = lnext(rtables);
}
if (rtables == NIL)
- elog(ERROR, "find_expr_references_walker: bogus varlevelsup %d",
- var->varlevelsup);
+ elog(ERROR, "invalid varlevelsup %d", var->varlevelsup);
rtable = lfirst(rtables);
if (var->varno <= 0 || var->varno > length(rtable))
- elog(ERROR, "find_expr_references_walker: bogus varno %d",
- var->varno);
+ elog(ERROR, "invalid varno %d", var->varno);
rte = rt_fetch(var->varno, rtable);
if (rte->rtekind == RTE_RELATION)
{
context->rtables = rtables;
if (var->varattno <= 0 ||
var->varattno > length(rte->joinaliasvars))
- elog(ERROR, "find_expr_references_walker: bogus varattno %d",
- var->varattno);
+ elog(ERROR, "invalid varattno %d", var->varattno);
find_expr_references_walker((Node *) nth(var->varattno - 1,
rte->joinaliasvars),
context);
if (is_subplan(node))
{
/* Extra work needed here if we ever need this case */
- elog(ERROR, "find_expr_references_walker: already-planned subqueries not supported");
+ elog(ERROR, "already-planned subqueries not supported");
}
if (IsA(node, Query))
{
return OCLASS_SCHEMA;
}
- elog(ERROR, "getObjectClass: Unknown object class %u",
- object->classId);
+ elog(ERROR, "unrecognized object class: %u", object->classId);
return OCLASS_CLASS; /* keep compiler quiet */
}
tup = systable_getnext(rcscan);
if (!HeapTupleIsValid(tup))
- elog(ERROR, "getObjectDescription: Cast %u does not exist",
+ elog(ERROR, "could not find tuple for cast %u",
object->objectId);
castForm = (Form_pg_cast) GETSTRUCT(tup);
tup = systable_getnext(rcscan);
if (!HeapTupleIsValid(tup))
- elog(ERROR, "getObjectDescription: Constraint %u does not exist",
+ elog(ERROR, "could not find tuple for constraint %u",
object->objectId);
con = (Form_pg_constraint) GETSTRUCT(tup);
ObjectIdGetDatum(object->objectId),
0, 0, 0);
if (!HeapTupleIsValid(conTup))
- elog(ERROR, "getObjectDescription: Conversion %u does not exist",
+ elog(ERROR, "cache lookup failed for conversion %u",
object->objectId);
appendStringInfo(&buffer, "conversion %s",
NameStr(((Form_pg_conversion) GETSTRUCT(conTup))->conname));
tup = systable_getnext(adscan);
if (!HeapTupleIsValid(tup))
- elog(ERROR, "getObjectDescription: Default %u does not exist",
+ elog(ERROR, "could not find tuple for attrdef %u",
object->objectId);
attrdef = (Form_pg_attrdef) GETSTRUCT(tup);
ObjectIdGetDatum(object->objectId),
0, 0, 0);
if (!HeapTupleIsValid(langTup))
- elog(ERROR, "getObjectDescription: Language %u does not exist",
+ elog(ERROR, "cache lookup failed for language %u",
object->objectId);
appendStringInfo(&buffer, "language %s",
NameStr(((Form_pg_language) GETSTRUCT(langTup))->lanname));
ObjectIdGetDatum(object->objectId),
0, 0, 0);
if (!HeapTupleIsValid(opcTup))
- elog(ERROR, "cache lookup of opclass %u failed",
+ elog(ERROR, "cache lookup failed for opclass %u",
object->objectId);
opcForm = (Form_pg_opclass) GETSTRUCT(opcTup);
ObjectIdGetDatum(opcForm->opcamid),
0, 0, 0);
if (!HeapTupleIsValid(amTup))
- elog(ERROR, "syscache lookup for AM %u failed",
+ elog(ERROR, "cache lookup failed for access method %u",
opcForm->opcamid);
amForm = (Form_pg_am) GETSTRUCT(amTup);
tup = systable_getnext(rcscan);
if (!HeapTupleIsValid(tup))
- elog(ERROR, "getObjectDescription: Rule %u does not exist",
+ elog(ERROR, "could not find tuple for rule %u",
object->objectId);
rule = (Form_pg_rewrite) GETSTRUCT(tup);
tup = systable_getnext(tgscan);
if (!HeapTupleIsValid(tup))
- elog(ERROR, "getObjectDescription: Trigger %u does not exist",
+ elog(ERROR, "could not find tuple for trigger %u",
object->objectId);
trig = (Form_pg_trigger) GETSTRUCT(tup);
nspname = get_namespace_name(object->objectId);
if (!nspname)
- elog(ERROR, "getObjectDescription: Schema %u does not exist",
+ elog(ERROR, "cache lookup failed for namespace %u",
object->objectId);
appendStringInfo(&buffer, "schema %s", nspname);
break;
ObjectIdGetDatum(relid),
0, 0, 0);
if (!HeapTupleIsValid(relTup))
- elog(ERROR, "cache lookup of relation %u failed", relid);
+ elog(ERROR, "cache lookup failed for relation %u", relid);
relForm = (Form_pg_class) GETSTRUCT(relTup);
/* Qualify the name if not visible in search path */
*
*
* 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
/*
* 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];
}
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
*
* 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
{
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))));
}
}
{
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))));
}
}
* 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))));
}
}
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
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);
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);
}
*/
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
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)
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
* 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
* 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
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",
- attname,
- format_type_be(atttypid),
- format_type_be(type_id));
+ 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)),
+ errhint("You will need to rewrite or cast the expression.")));
}
return (expr);
*
*
* 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
/*
* 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)];
}
/* 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);
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);
/*
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);
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;
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
* 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
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 */
}
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);
*/
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);
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;
}
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.
}
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);
}
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.
*/
if (!TransactionIdIsCurrentTransactionId(
HeapTupleHeaderGetXmin(heapTuple->t_data)))
- elog(ERROR, "IndexBuildHeapScan: concurrent insert in progress");
+ elog(ERROR, "concurrent insert in progress");
indexIt = true;
tupleIsAlive = true;
break;
*/
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;
}
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);
* 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);
/* 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
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;
}
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);
* 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 $
*
*-------------------------------------------------------------------------
*/
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)
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;
}
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();
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
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 */
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();
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();
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();
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();
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();
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();
* 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;
}
* 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)
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)
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
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 */
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;
}
{
/* 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");
}
/*
*/
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);
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)));
}
}
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
ObjectAddress myself,
referenced;
- /* sanity checks */
+ /* sanity checks (caller should have caught these) */
if (!aggName)
elog(ERROR, "no aggregate name supplied");
*/
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));
* 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);
/*
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);
*/
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
/* 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
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;
}
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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);
/*
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--;
}
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 */
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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)
{
if (FindDefaultConversion(connamespace,
conforencoding,
contoencoding))
- elog(ERROR, "default conversion for %s to %s already exists",
- pg_encoding_to_char(conforencoding),
- pg_encoding_to_char(contoencoding));
+ 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))));
}
/* open pg_conversion */
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);
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);
}
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 */
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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++)
*
*
* 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.
/* 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) */
for (ic = len - 2; ic >= 0; ic--)
{
- if (strchr("~!@#^&|`?$%", name[ic]))
+ if (strchr("~!@#^&|`?%", name[ic]))
break;
}
if (ic < 0)
* 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
* 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,
&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
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,
* 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;
}
otherNamespace,
otherLeftTypeId,
otherRightTypeId);
- if (!OidIsValid(other_oid))
- elog(ERROR,
- "OperatorDef: can't create operator shell \"%s\"",
- NameListToString(otherOp));
return other_oid;
}
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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 */
/* 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,
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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
*/
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
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);
* 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
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);
* 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 $
*
*-------------------------------------------------------------------------
*/
#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')
/* 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')
/* 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')
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));
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);
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);
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
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
-- 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
-- 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);
(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
--
(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;
(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
----+----
-- 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
--
-- 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
--
(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;
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;
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
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
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
-- 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
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
(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
-- 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
-- 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[],
-- 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
-- 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,
-- 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,
-- 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[],
-- 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
-- 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,
-- 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,
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
---+-----
(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
(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
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;
(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;
(2 rows)
SELECT * FROM atestv2; -- fail
-ERROR: atestv2: permission denied
+ERROR: permission denied for "atestv2"
SELECT * FROM atestv3; -- ok
one | two | three
-----+-----+-------
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
-----+-----+-------
(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 -
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
(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
-----------
(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
(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');
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
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
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;
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