public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: [email protected]
Subject: ALTER TYPE OWNER fails to recurse to multirange
Date: Mon, 15 Jan 2024 13:27:44 -0500
Message-ID: <[email protected]> (raw)

d=# create type varbitrange as range (subtype = varbit);
CREATE TYPE
d=# \dT+
                                             List of data types
 Schema |       Name       |  Internal name   | Size | Elements |  Owner   | Access privileges | Description 
--------+------------------+------------------+------+----------+----------+-------------------+-------------
 public | varbitmultirange | varbitmultirange | var  |          | postgres |                   | 
 public | varbitrange      | varbitrange      | var  |          | postgres |                   | 
(2 rows)

d=# create user joe;
CREATE ROLE
d=# alter type varbitrange owner to joe;
ALTER TYPE
d=# \dT+
                                             List of data types
 Schema |       Name       |  Internal name   | Size | Elements |  Owner   | Access privileges | Description 
--------+------------------+------------------+------+----------+----------+-------------------+-------------
 public | varbitmultirange | varbitmultirange | var  |          | postgres |                   | 
 public | varbitrange      | varbitrange      | var  |          | joe      |                   | 
(2 rows)

That's pretty broken, isn't it?  joe would own the multirange if he'd
created the range to start with.  Even if you think the ownerships
ideally should be separable, this behavior causes existing pg_dump
files to restore incorrectly, because pg_dump assumes it need not emit
any commands about the multirange.

A related issue is that you can manually alter the multirange's
ownership:

d=# alter type varbitmultirange owner to joe;
ALTER TYPE

which while it has some value in allowing recovery from this bug,
is inconsistent with our handling of other dependent types such
as arrays:

d=# alter type _varbitrange owner to joe;
ERROR:  cannot alter array type varbitrange[]
HINT:  You can alter type varbitrange, which will alter the array type as well.

Possibly the thing to do about that is to forbid it in HEAD
for consistency, while still allowing it in back branches
so that people can clean up inconsistent ownership if needed.

			regards, tom lane






view thread (8+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: ALTER TYPE OWNER fails to recurse to multirange
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox