Re: Add support to COMMENT ON CURRENT DATABASE

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: fabriziomello(at)gmail(dot)com, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add support to COMMENT ON CURRENT DATABASE
Date: 2017-01-03 15:48:42
Message-ID: f8c4c3c4-5afa-38bd-02f3-b20378b4faa2@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 12/30/16 9:28 PM, Fabrízio de Royes Mello wrote:
> The attached patch is reworked from a previous one [1] to better deal
> with get_object_address and pg_get_object_address.
>
> Regards,
>
> [1] https://www.postgresql.org/message-id/20150317171836.GC10492@momjian.us

The syntax we have used for the user/role case is ALTER USER
CURRENT_USER, not ALTER CURRENT USER, so this should be done in the same
way for databases. Eventually, we'll also want ALTER DATABASE
current_database, and probably not ALTER CURRENT DATABASE, etc.

It's also curious that we don't support COMMENT on whatever CURRENT_USER
yet. It looks like the previous patch to allow ALTER USER CURRENT_USER
etc. was not even applied to pg_dump.

I think this patch is a good direction to move in, and it seems everyone
else agreed, but I'm looking for a bit more of a holistic solution than
one command at a time here and there. Define a goal such as, allow
restoring into a differently-named database, and then see what needs to
happen to achieve that.

The implementation looks generally OK, but I'm not sure why you need
this part:

diff --git a/src/backend/catalog/objectaddress.c
b/src/backend/catalog/objectaddress.c
index bb4b080..71bffae 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -621,6 +621,9 @@ static const struct object_type_map
{
"database", OBJECT_DATABASE
},
+ {
+ "current database", OBJECT_DATABASE
+ },
/* OCLASS_TBLSPACE */
{
"tablespace", OBJECT_TABLESPACE

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2017-01-03 15:50:54 Re: Proposal for changes to recovery.conf API
Previous Message Robert Haas 2017-01-03 15:48:37 Re: An isolation test for SERIALIZABLE READ ONLY DEFERRABLE