Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wSi8Q-0002ea-1S for pgsql-hackers@arkaria.postgresql.org; Thu, 28 May 2026 21:19:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wSi7O-000Vct-2F for pgsql-hackers@arkaria.postgresql.org; Thu, 28 May 2026 21:18:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wSi7N-000VWJ-2W for pgsql-hackers@lists.postgresql.org; Thu, 28 May 2026 21:18:18 +0000 Received: from fhigh-a2-smtp.messagingengine.com ([103.168.172.153]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wSi7I-000000001NQ-1oi5 for pgsql-hackers@lists.postgresql.org; Thu, 28 May 2026 21:18:17 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.phl.internal (Postfix) with ESMTP id AF6B0140008E; Thu, 28 May 2026 17:18:11 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Thu, 28 May 2026 17:18:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kurilemu.de; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to; s=fm2; t=1780003091; x= 1780089491; bh=zFTP547uzLG7gq+EpVrH9Cgwv7VvyzmF+qTPjPvEFIc=; b=P msJt3owk1dKLb/x6Wjsp4ZpjSsoeUVJgLSGShlNyKf5CULskOD7gYGahjYRw6jtB PmlYQR3Cfx4lYxld2OqPy3aeJrkW3js43BBkjT5/k+8BkPVxTYyIzInEXUsUxWBk K6dtnf2dlgnSz3ROk3R+ka/PsHig2aCm7V12mkJA0KC21EaXRnzarg9EZN27YJfF +rCn6B3B9LTpmOGkQZ8oBX+WdhtgQP0DKPZUDP1+aAXRJIUgMgfp30yDxC6UerpV 49sCJqs+SwDj2rdLrETsYye8vXIrQD5g6h7MDT+SYsi/8QPiA4Xg9Jl0Ev2s4C5j 7D4HII25o0OH9W64cRAfA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1780003091; x=1780089491; bh=z FTP547uzLG7gq+EpVrH9Cgwv7VvyzmF+qTPjPvEFIc=; b=m3Vmk/5C49JX+MGcx qldMsHXbiK97atzhVQFcSti+KF8VfYhxItJVmDiTDwFWLKlBHLh/vyTzZRRaTMMH OsO/DCmrcTlbSUbpAL/UG59zlI4fe3ArbogA2uBO71P9nM+1hiXsMRimNi2+68i9 vq3jEFCW6jBGxdw7dvSguQ2jIavoI8nTfywmEPDJ/PB784T67PJLYKYzOLHNaU/U OWXRlgDf5soZfc5ldKvGrm9ND9w3ti8hSpACBZpmcLuD5U3/QkVa1UXoLA+2QKPC jE7ufhNAB9OclNkpIWEWBjyh2cplj3L5tCIRHT0u+iacB4spua7F9N6DkxOCsk6J dVVJg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTGMYX7bKFoLCPeU3DMlPozpR5k1HSQwgmfvSjXQgo1xJETp+Uay27GxvmpuFwD5rW bSTKlhjbhDOED4DRmA8vsXhr6I1z5q19w0JdwLWsPHZbWTRUAXlsQadKCg1XWEzLETSLYO oFaaLroUrSPtFOvz3PkM8WNw6cQNZmnl5WP5nUzJjRR2ur4ZEpp6sAQftykB/2hbeeadVf lS6buX/FBFX3yLbzzdFTytnWW/qJ25cGBZYnhDZKzG+SY97DcBGaKtTFrgcdVssk27lglS Y9xse037vv1FF+J3Gr0OOsyOQkgS7t3sSuqpo1aM8DOiOpJy6/KD42tzo3j4KXUSn3iepy ZnLKC2UmYBgHcxEmF8uCDvW7h+6J0l7mn6vrJx3ruIAfyhbC5hBYnn3YaKqy3PHDSRpN4D e+WQbdBszaqZQQoR1q8UUkDfvKxtzqMA3rTHOktrBiTJlCCAtlAXL80Wb973bArLdNZXMG Uu2/VxF3k7aZgc/2VVIc+fzFZoVbw5XV5IvENwvgXUDrAwIf8WsxZMb1Q5MJcDejFot1Qx 1c+XmZdtBpvml3UHHA5JH7Tgfn4P9lrr/Onew/QZIoZb0MtiKkQU4JgiPf93ebaLKtsuY/ 6Xs0qQrQCOFuwNAXEzZYVnyFikX4/4rl7K3jhyS15P9JEX2HIPMHLjyaBGuQ X-ME-Proxy: Feedback-ID: ie3de48e3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 28 May 2026 17:18:11 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kurilemu.de; s=schmee; t=1780003088; bh=MN9ZvX7+5CwnfBoeHqVfevbDk3DgB8R3LjWYbJfhCDw=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=V+tUPdGxrpJ+GMxLCqmmahe0SbpkdIjx3e5F3s4q2wYNnnHzx8E5y5uz7OHQCRZq8 huZc/eUcOFgbIujsPXjwCwbfpif23/jXMiV9WOE7oPWLseJfiHZ9UUP8GTKep7eK28 jVUtSIISLpn17DDp9jiT2l1OUTjssbAqY7As/qjWei3/gVsECw/VSGigB/6HohOcyT v5XdhE9IoXnvG/Qvm8ZReKOsUwh+xblLBKCGCur/dS+QiZqGRmf/C+7dXW+hnh8jMK E31PK+c3FO7Q3x2NdAidHRB/rMecUtFpwhjbhPBrHZzZHdiaoj5esJcxhwaNemcEXW 6NbxSeRvw3FTg== Received: by ida.kurilemu.internal (Postfix, from userid 1000) id CD9CCB00632; Thu, 28 May 2026 23:18:08 +0200 (CEST) Date: Thu, 28 May 2026 23:18:08 +0200 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: Chao Li Cc: Baji Shaik , pgsql-hackers@lists.postgresql.org Subject: Re: [PATCH] Improve REPACK (CONCURRENTLY) error messages for unsupported configurations Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="yrl6wzxda7bokrre" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --yrl6wzxda7bokrre Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit While looking these patches over I noticed that we still have some error reports cases uncovered. Here's a quick attempt to try and complete that. After this patch I see only one uncovered error path, the one that prevents repacking a temp table of another session. That would require an isolation test. Not sure it's worth the trouble ... (There's a bunch of uncovered "elog(ERROR)" cases, but those are mostly just can't-happen conditions, as I understand). -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ --yrl6wzxda7bokrre Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0001-Cover-some-errors-and-corner-conditions-in-repack.c.patch" From 7eab30e74692ac023ed20bfc85d92e68f0d9db02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Herrera?= Date: Thu, 28 May 2026 11:20:19 +0200 Subject: [PATCH] Cover some errors and corner conditions in repack.c --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre--