* Copyright (c) 1996-2001, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.64 2003/07/04 02:51:33 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.65 2003/07/17 20:13:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
elog(ERROR, "CommentDatabase: database name may not be qualified");
database = strVal(lfirst(qualname));
+ /*
+ * We cannot currently support cross-database comments (since other DBs
+ * cannot see pg_description of this database). So, we reject attempts
+ * to comment on a database other than the current one. Someday this
+ * might be improved, but it would take a redesigned infrastructure.
+ *
+ * When loading a dump, we may see a COMMENT ON DATABASE for the old name
+ * of the database. Erroring out would prevent pg_restore from completing
+ * (which is really pg_restore's fault, but for now we will work around
+ * the problem here). Consensus is that the best fix is to treat wrong
+ * database name as a WARNING not an ERROR.
+ */
+
/* First get the database OID */
oid = get_database_oid(database);
if (!OidIsValid(oid))
- elog(ERROR, "database \"%s\" does not exist", database);
+ {
+ elog(WARNING, "database \"%s\" does not exist", database);
+ return;
+ }
- /* Allow if the user matches the database dba or is a superuser */
+ /* Only allow comments on the current database */
+ if (oid != MyDatabaseId)
+ {
+ elog(WARNING, "database comments may only be applied to the current database");
+ return;
+ }
+ /* Allow if the user matches the database dba or is a superuser */
if (!pg_database_ownercheck(oid, GetUserId()))
elog(ERROR, "you are not permitted to comment on database \"%s\"",
database);
- /* Only allow comments on the current database */
- if (oid != MyDatabaseId)
- elog(ERROR, "Database comments may only be applied to the current database");
-
/* Create the comment with the pg_database oid */
CreateComments(oid, RelOid_pg_database, 0, comment);
}