pgsql: Have CLUSTER ignore partitions not owned by caller

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Have CLUSTER ignore partitions not owned by caller
Date: 2022-04-14 20:23:03
Message-ID: E1nf5zb-000Wt5-Na@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Have CLUSTER ignore partitions not owned by caller

If a partitioned table has partitions owned by roles other than the
owner of the partitioned table, don't include them in the to-be-
clustered list. This is similar to what VACUUM FULL does (except we do
it sooner, because there is no reason to postpone it). Add a simple
test to verify that only owned partitions are clustered.

While at it, change memory context switch-and-back to occur once per
partition instead of outside of the loop.

Author: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Reviewed-by: Zhihong Yu <zyu(at)yugabyte(dot)com>
Reviewed-by: Michael Paquier <michael(at)paquier(dot)xyz>
Discussion: https://postgr.es/m/20220411140609.GF26620@telsasoft.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3f19e176ae0f55a653d62e1504dbe5ad8c1006a0

Modified Files
--------------
src/backend/commands/cluster.c | 19 ++++++++++++-------
src/test/regress/expected/cluster.out | 25 +++++++++++++++++++++++++
src/test/regress/sql/cluster.sql | 19 +++++++++++++++++++
3 files changed, 56 insertions(+), 7 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2022-04-15 00:41:37 pgsql: pgstat: set timestamps of fixed-numbered stats after a crash.
Previous Message Alvaro Herrera 2022-04-14 19:55:56 pgsql: Reword text on ROW SHARE lock as acquired by SELECT FOR <lock>