Re: BUG #16577: Segfault on altering a table located in a dropped tablespace

Alvaro Herrera <alvherre@alvh.no-ip.org>

From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Michael Paquier <michael@paquier.xyz>
Cc: Tomas Vondra <tomas.vondra@2ndquadrant.com>, Tom Lane <tgl@sss.pgh.pa.us>, exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2021-01-12T15:08:04Z
Lists: pgsql-bugs
On 2021-Jan-12, Michael Paquier wrote:

> +       /*
> +        * If a tablespace is specified, removal of that tablespace is normally
> +        * protected by the existence of a physical file; but for relations with
> +        * no files, add a pg_shdepend entry to account for that.
> +        */
> +       if (!create_storage && reltablespace != InvalidOid)
>
> On HEAD, could we consider using this dependency link even for
> relations that have physical files, and remove the physical file
> check?  Could that make the dependency handling cleaner?

That would bloat the catalog with a lot of entries for stuff that can be
detected with the current method.  Did you notice that the code is
removing an "#ifdef NOT_USED" line to enable existing code?  Well, when
I wrote this code in 2005 (59d1b3d99e69) it was doing things as you
suggest, but in the end we decided that it wasn't necessary so it was
taken out.

-- 
Álvaro Herrera                            39°49'30"S 73°17'W
"Someone said that it is at least an order of magnitude more work to do
production software than a prototype. I think he is wrong by at least
an order of magnitude."                              (Brian Kernighan)



Commits

  1. Prevent drop of tablespaces used by partitioned relations

  2. Don't create relfilenode for relations without storage