Restrict comment to the current database in order to prevent them from
authorBruce Momjian <bruce@momjian.us>
Wed, 24 Apr 2002 02:50:30 +0000 (02:50 +0000)
committerBruce Momjian <bruce@momjian.us>
Wed, 24 Apr 2002 02:50:30 +0000 (02:50 +0000)
mysteriously disappearing.

ie.  \d+ will only ever show the comment for the current database --
which is appropriate since it can only pull comments from the current
database.

Won't break pgadmin functionality as it enforces this behaviour already.

I didn't find any regression tests for COMMENT.

Rod Taylor

src/backend/commands/comment.c

index f77dab0d39ab12a35e90a78c8126e1f6fdde278e..869919900d4b31997dcb92e943931f4cd11c4743 100644 (file)
@@ -438,6 +438,10 @@ CommentDatabase(List *qualname, char *comment)
                elog(ERROR, "CommentDatabase: database name may not be qualified");
        database = strVal(lfirst(qualname));
 
+       /* Only allow comments on the current database */
+       if (strcmp(database, DatabaseName) != 0)
+               elog(ERROR, "Database comments may only be applied to the current database");
+
        /* First find the tuple in pg_database for the database */
 
        pg_database = heap_openr(DatabaseRelationName, AccessShareLock);