Thread: pgsql: Restructure CLUSTER/newstyle VACUUM FULL/ALTER TABLE support so

pgsql: Restructure CLUSTER/newstyle VACUUM FULL/ALTER TABLE support so

From
tgl@postgresql.org (Tom Lane)
Date:
Log Message:
-----------
Restructure CLUSTER/newstyle VACUUM FULL/ALTER TABLE support so that swapping
of old and new toast tables can be done either at the logical level (by
swapping the heaps' reltoastrelid links) or at the physical level (by swapping
the relfilenodes of the toast tables and their indexes).  This is necessary
infrastructure for upcoming changes to support CLUSTER/VAC FULL on shared
system catalogs, where we cannot change reltoastrelid.  The physical swap
saves a few catalog updates too.

We unfortunately have to keep the logical-level swap logic because in some
cases we will be adding or deleting a toast table, so there's no possibility
of a physical swap.  However, that only happens as a consequence of schema
changes in the table, which we do not need to support for system catalogs,
so such cases aren't an obstacle for that.

In passing, refactor the cluster support functions a little bit to eliminate
unnecessarily-duplicated code; and fix the problem that while CLUSTER had
been taught to rename the final toast table at need, ALTER TABLE had not.

Modified Files:
--------------
    pgsql/src/backend/access/heap:
        tuptoaster.c (r1.96 -> r1.97)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/heap/tuptoaster.c?r1=1.96&r2=1.97)
    pgsql/src/backend/commands:
        cluster.c (r1.196 -> r1.197)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/cluster.c?r1=1.196&r2=1.197)
        tablecmds.c (r1.323 -> r1.324)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/tablecmds.c?r1=1.323&r2=1.324)
    pgsql/src/backend/utils/cache:
        relcache.c (r1.301 -> r1.302)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/cache/relcache.c?r1=1.301&r2=1.302)
    pgsql/src/include/commands:
        cluster.h (r1.38 -> r1.39)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/commands/cluster.h?r1=1.38&r2=1.39)
    pgsql/src/include/utils:
        rel.h (r1.120 -> r1.121)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/utils/rel.h?r1=1.120&r2=1.121)