Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ab117a6

Browse files
committed
Restrict comment to the current database in order to prevent them from
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
1 parent a02f834 commit ab117a6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/backend/commands/comment.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Copyright (c) 1999-2001, PostgreSQL Global Development Group
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.43 2002/04/19 16:36:08 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.44 2002/04/24 02:50:30 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -438,6 +438,10 @@ CommentDatabase(List *qualname, char *comment)
438438
elog(ERROR, "CommentDatabase: database name may not be qualified");
439439
database = strVal(lfirst(qualname));
440440

441+
/* Only allow comments on the current database */
442+
if (strcmp(database, DatabaseName) != 0)
443+
elog(ERROR, "Database comments may only be applied to the current database");
444+
441445
/* First find the tuple in pg_database for the database */
442446

443447
pg_database = heap_openr(DatabaseRelationName, AccessShareLock);

0 commit comments

Comments
 (0)