postgres.git / summary / log / commit / refs

commit    d7db169fa13a7e4db9013816c7a2c498bd304fba
Author:   Nathan Bossart <nathan@postgresql.org>
Date:     Thu Aug 13 20:28:34 2026 +0000

    Reject CLUSTER (ANALYZE).
    
    The introduction of the REPACK command also added support for
    CLUSTER (ANALYZE).  Presumably this was unintentional, as the
    CLUSTER docs make no mention of it.  CLUSTER (ANALYZE) on an
    ordinary table succeeds and does indeed analyze the table, but a
    database-wide CLUSTER (ANALYZE) or one on a partitioned table
    fails with an error like:
    
        ERROR:  cannot execute REPACK (ANALYZE) on multiple tables
    
    Rather than improving support for CLUSTER (ANALYZE) and thereby
    encouraging folks to use CLUSTER instead of REPACK, let's just
    reject it.  This commit does so by teaching ExecRepack() to ERROR
    for the ANALYZE option in anything except REPACK commands.  Note
    that VACUUM (FULL, ANALYZE) does not go through ExecRepack() and
    therefore is unaffected by this change.
    
    Oversight in commit ac58465e06.
    
    Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>
    Author: Zsolt Parragi <zsolt.parragi@percona.com>
    Discussion: https://postgr.es/m/CAN4CZFMVcgv1b2G-i%2Bkhs2MDnzWSr7O_53j_x%2BuhAxUV5rwWqw%40mail.gmail.com
    Backpatch-through: 19


src/backend/commands/repack.c | 7 +++++++ 1 file changed, 7 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) [parent: 5185e64ae0b2]