Re: CLUSTER on partitioned index

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

From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Justin Pryzby <pryzby@telsasoft.com>
Cc: Michael Paquier <michael@paquier.xyz>, 李杰(慎追) <adger.lj@alibaba-inc.com>, pgsql-hackers@lists.postgresql.org, 曾文旌(义从) <wenjing.zwj@alibaba-inc.com>, Zhihong Yu <zyu@yugabyte.com>
Date: 2022-03-31T10:54:36Z
Lists: pgsql-hackers
I realized after posting that we used to allow clustering toast tables,
but after my changes we no longer do.  (Justin's version had a
RELKIND_HAS_STORAGE test here instead, which seemed a little too lax.) I
don't know why we allowed it and I don't know of anyone who has ever
used that feature and we don't have any test coverage for it, but I
don't have any reason to explicitly disallow it either.  So I propose to
continue to allow it:

>From 05ba6124422fb7c2fd19575e905e444ba3eef1e5 Mon Sep 17 00:00:00 2001
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: Thu, 31 Mar 2022 12:49:57 +0200
Subject: [PATCH] allow to cluster toast tables

---
 src/backend/commands/cluster.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index 8417cbdb67..b391d7c434 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -451,7 +451,8 @@ cluster_rel(Oid tableOid, Oid indexOid, ClusterParams *params)
 	}
 
 	Assert(OldHeap->rd_rel->relkind == RELKIND_RELATION ||
-		   OldHeap->rd_rel->relkind == RELKIND_MATVIEW);
+		   OldHeap->rd_rel->relkind == RELKIND_MATVIEW ||
+		   OldHeap->rd_rel->relkind == RELKIND_TOASTVALUE);
 
 	/*
 	 * All predicate locks on the tuples or pages are about to be made
-- 
2.30.2

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/
"Java is clearly an example of money oriented programming"  (A. Stepanov)



Commits

  1. Add some isolation tests for CLUSTER

  2. Have CLUSTER ignore partitions not owned by caller

  3. Remove "recheck" argument from check_index_is_clusterable()

  4. Allow CLUSTER on partitioned tables

  5. doc: Add backlinks to progress reporting documentation