agora inbox for pgsql-bugs@postgresql.org  
help / color / mirror / Atom feed
Should CUSTER (ANALYZE) work?
4+ messages / 3 participants
[nested] [flat]

* Should CUSTER (ANALYZE) work?
@ 2026-07-21 21:36  Zsolt Parragi <zsolt.parragi@percona.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Zsolt Parragi @ 2026-07-21 21:36 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org

Hello

CLUSTER (ANALYZE) seems to be accepted in 19b2, but it's missing from
the documentation. It could be a documentation bug, but since the
error message it prints also references REPACK, it seems more likely
that a check is missing.

Attached patch adds an error check similar to how CONCURRENTLY is handled.

Attachments:

  [application/octet-stream] 0001-Reject-the-ANALYZE-option-in-CLUSTER.patch (2.8K, ../../CAN4CZFMVcgv1b2G-i+khs2MDnzWSr7O_53j_x+uhAxUV5rwWqw@mail.gmail.com/2-0001-Reject-the-ANALYZE-option-in-CLUSTER.patch)
  download | inline diff:
From 3741ca47cf1fc3d3bef1a383d3ae565db519bdb9 Mon Sep 17 00:00:00 2001
From: Zsolt Parragi <zsolt.parragi@percona.com>
Date: Mon, 20 Jul 2026 21:32:08 +0000
Subject: [PATCH] Reject the ANALYZE option in CLUSTER

ExecRepack only restricted the CONCURRENTLY option by command, so
CLUSTER (ANALYZE) was silently accepted and ran an analyze after
clustering, although cluster.sgml documents only VERBOSE. It also made
database-wide CLUSTER (ANALYZE) error out with the wrong command name
in the message ('cannot execute REPACK (ANALYZE) on multiple tables').
Reject ANALYZE for CLUSTER the same way as CONCURRENTLY.
---
 src/backend/commands/repack.c         | 7 +++++++
 src/test/regress/expected/cluster.out | 3 +++
 src/test/regress/sql/cluster.sql      | 3 +++
 3 files changed, 13 insertions(+)

diff --git a/src/backend/commands/repack.c b/src/backend/commands/repack.c
index dde56fb1e8d..edff54e734e 100644
--- a/src/backend/commands/repack.c
+++ b/src/backend/commands/repack.c
@@ -265,7 +265,14 @@ ExecRepack(ParseState *pstate, RepackStmt *stmt, bool isTopLevel)
 			verbose = defGetBoolean(opt);
 		else if (strcmp(opt->defname, "analyze") == 0 ||
 				 strcmp(opt->defname, "analyse") == 0)
+		{
+			if (stmt->command != REPACK_COMMAND_REPACK)
+				ereport(ERROR,
+						errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+						errmsg("ANALYZE option not supported for %s",
+							   RepackCommandAsString(stmt->command)));
 			analyze = defGetBoolean(opt);
+		}
 		else if (strcmp(opt->defname, "concurrently") == 0)
 		{
 			if (stmt->command != REPACK_COMMAND_REPACK)
diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out
index d1bc8a13286..3ac5cfa73d9 100644
--- a/src/test/regress/expected/cluster.out
+++ b/src/test/regress/expected/cluster.out
@@ -801,6 +801,9 @@ REPACK (ANALYZE) clstr_tst (a);
 REPACK (ANALYZE) clstr_tst;
 REPACK (VERBOSE) clstr_tst (a);
 ERROR:  ANALYZE option must be specified when a column list is provided
+-- The ANALYZE option is for REPACK only
+CLUSTER (ANALYZE) clstr_tst USING clstr_tst_c;
+ERROR:  ANALYZE option not supported for CLUSTER
 -- REPACK w/o argument performs no ordering, so we can only check which tables
 -- have the relfilenode changed.
 RESET SESSION AUTHORIZATION;
diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql
index e7a62367adf..104cc19888b 100644
--- a/src/test/regress/sql/cluster.sql
+++ b/src/test/regress/sql/cluster.sql
@@ -385,6 +385,9 @@ REPACK (ANALYZE) clstr_tst (a);
 REPACK (ANALYZE) clstr_tst;
 REPACK (VERBOSE) clstr_tst (a);
 
+-- The ANALYZE option is for REPACK only
+CLUSTER (ANALYZE) clstr_tst USING clstr_tst_c;
+
 -- REPACK w/o argument performs no ordering, so we can only check which tables
 -- have the relfilenode changed.
 RESET SESSION AUTHORIZATION;
-- 
2.54.0



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Should CUSTER (ANALYZE) work?
@ 2026-08-12 19:50  Nathan Bossart <nathandbossart@gmail.com>
  parent: Zsolt Parragi <zsolt.parragi@percona.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Nathan Bossart @ 2026-08-12 19:50 UTC (permalink / raw)
  To: Zsolt Parragi <zsolt.parragi@percona.com>; +Cc: pgsql-bugs@lists.postgresql.org; alvherre@kurilemu.de

On Tue, Jul 21, 2026 at 10:36:55PM +0100, Zsolt Parragi wrote:
> CLUSTER (ANALYZE) seems to be accepted in 19b2, but it's missing from
> the documentation. It could be a documentation bug, but since the
> error message it prints also references REPACK, it seems more likely
> that a check is missing.
> 
> Attached patch adds an error check similar to how CONCURRENTLY is handled.

Your patch seems right to me.  If nobody objects in the next day or so,
I'll go ahead and apply it.

-- 
nathan






^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Should CUSTER (ANALYZE) work?
@ 2026-08-13 20:38  Nathan Bossart <nathandbossart@gmail.com>
  parent: Nathan Bossart <nathandbossart@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Nathan Bossart @ 2026-08-13 20:38 UTC (permalink / raw)
  To: Zsolt Parragi <zsolt.parragi@percona.com>; +Cc: pgsql-bugs@lists.postgresql.org; alvherre@kurilemu.de

On Wed, Aug 12, 2026 at 02:50:34PM -0500, Nathan Bossart wrote:
> Your patch seems right to me.  If nobody objects in the next day or so,
> I'll go ahead and apply it.

Committed.

-- 
nathan






^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Should CUSTER (ANALYZE) work?
@ 2026-08-15 09:12  Alvaro Herrera <alvherre@kurilemu.de>
  parent: Nathan Bossart <nathandbossart@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Alvaro Herrera @ 2026-08-15 09:12 UTC (permalink / raw)
  To: Nathan Bossart <nathandbossart@gmail.com>; +Cc: Zsolt Parragi <zsolt.parragi@percona.com>; pgsql-bugs@lists.postgresql.org

On 2026-Aug-13, Nathan Bossart wrote:

> On Wed, Aug 12, 2026 at 02:50:34PM -0500, Nathan Bossart wrote:
> > Your patch seems right to me.  If nobody objects in the next day or so,
> > I'll go ahead and apply it.
> 
> Committed.

Thanks!

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/
Maybe there's lots of data loss but the records of data loss are also lost.
(Lincoln Yeoh)






^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2026-08-15 09:12 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-07-21 21:36 Should CUSTER (ANALYZE) work? Zsolt Parragi <zsolt.parragi@percona.com>
2026-08-12 19:50 ` Nathan Bossart <nathandbossart@gmail.com>
2026-08-13 20:38   ` Nathan Bossart <nathandbossart@gmail.com>
2026-08-15 09:12     ` Alvaro Herrera <alvherre@kurilemu.de>

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