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 1wlqZQ-000PwN-0o for pgsql-bugs@arkaria.postgresql.org; Mon, 20 Jul 2026 16:10:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wlqZP-0047Eh-2g for pgsql-bugs@arkaria.postgresql.org; Mon, 20 Jul 2026 16:10:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wlqZP-0047EY-1f for pgsql-bugs@lists.postgresql.org; Mon, 20 Jul 2026 16:10:19 +0000 Received: from fout-a8-smtp.messagingengine.com ([103.168.172.151]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wlqZM-00000000IUE-389e for pgsql-bugs@lists.postgresql.org; Mon, 20 Jul 2026 16:10:18 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.phl.internal (Postfix) with ESMTP id 966D6EC01C4; Mon, 20 Jul 2026 12:10:14 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Mon, 20 Jul 2026 12:10:14 -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=fm1; t=1784563814; x= 1784650214; bh=f/JxyLghLee9a/3u+RdziFhd+9HLd9yVNi89xPBmNbY=; b=H yor7cQUCAI/pP46Z8I7WSw2kW+1R50jhhjx4m53P5i2R5QurvEGp463ofrmrME4M J0f7ABxQtEZ+y27YHokEsIpUWY/kbNj1uGoXhb6xvObWxTw8SUxxcMd9ubPbtBki AORL0ws5C1I6HO335ggw7O9NmvYafmYB6F/ExVvVW70zrJsGQ7AIZbtI3hy/OGEj WfkDdhUTIPWRD3PFnbBVqyADosw0NQQxz3fY68oVoBpktQ8QMyrDFa+Q4w8qnbCl Jhg3Jwj9Omigw827zdBUggQzIo7zMyHGpUCGVz3ss45AxlsgABqr9QefmN7Dv2Mb 8ObiEGzY72f+wWJhWHMpQ== 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=fm2; t=1784563814; x=1784650214; bh=f /JxyLghLee9a/3u+RdziFhd+9HLd9yVNi89xPBmNbY=; b=GyTgbBFM8ACw8DU4H 8sGGWbjnGmyAHVGmTYAp5hHTJB3pkS7UqiMW/QF9kfD3x74i0TUgNsK1leZuTtIX 8+n5QMouDxrXLNIK9Y+mksH6fBXICrqUOCPYAJ5hrrOae7qSf9UPuCSV11BnOrxF yQWOfcE9AkV6d5No3UknT54K5YBcYt8wDmKOdq3VycXxoc1SKGIKO4fFwKMlloPd rwvvIAkOL4kK+OT3Fs8/4BAiJAfspDMqH/a6hfCDp15hq0uNBH/sV3NSOI7Ydffk wrmwookatchTY5UD6Iodc6ypy/mb9jgwvO12qnuwwaqtpBJyMAq58HERia3SDHWk nmM1A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFExOqyjkG7r7q5O2MJRg0Jb2hG8I9d+neoArQcJXDw1uhVv/mMHyBwtODen7j+gv gUe3gZWCe78WRxwEU+u4oQMWKsShzEBTjv1VIX3roGCgHo2vEF5I1lrdiF2/dh91kOXAe6 PkFvdmGXJW2IDIRyYRXAzgAok/YF1Egof2QKKlLqjGrJetC+RC+5Yew7wPT/RxARm9ErV2 7iKEyvIZb4DwGfz87+ESgONMG7cbYiefhtnbpxmBoSph2Mc4vS47u5WTyY661kidf1fKqX 05orgfGMtx/j9pVOLQ7AZ8GJ4IhkJeX/n8FaZbo9QFJ0ansxbnxnxA6hqKNz6HoBkuAxDA bQsxNu4i/fojR/I76wtT0/97J1fnxq8XSPrCLHGYm18zHCVUh9i58Pm3i28zQQrvnLJK0J YmiFQFJtsf0foAHBLahTwXIBsoSSd5Dezoydd0jQf4PvPPlF3D4MatCekC7h3Iz2mrBpwh bky75styQSgCVkB4KOLKx5QffeT7hlzyv2gaLRdmPZz/WH7x9hOn3gEeuhIlOZ2UN+KP6G A5INs9L83s5qISMdda+vYsOJwW99U7hbfxkdspaEZD5ZGtyycbUjFJ/8GwXlqdTCQf9hsK vpDqgLhmJnkGFqVPFsQyzEXhqPkQGGIA2+eqkUzbh0Ytq3S602V+cbasFkDw X-ME-Proxy: Feedback-ID: ie3de48e3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 20 Jul 2026 12:10:13 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kurilemu.de; s=schmee; t=1784563810; bh=WzTEKcjpUkjhYUmCqCPbaePWrP0SGYsXMPvTZxd+Zyc=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=3BbGrJoD53bN5tLcUqZGMl6f5L7ZADN3MpCkfiaYimN+vWcGKwB7r9wd4BtpQhwDp aKD9VfBxx6Zdb+gQUPABAkY8tNPGDRX79cpjKwFjIn6j96OHc87rVr1XRn3ScWraZQ JtYhGKWgarv35wXTcx4Fe3AJSwRRxYq/7Ih/YJGrRrtrAKcuUmndrfbrbBUBbsh3JB Rxf/KNgS3GpJccp8LtFE2vvoFr5trggbwNC+YvZQBYcLgVyPrKjS9PVSPAPa3xvuAF hkGpQVn0WGLcXCBFPTacJ1UZyJO8fsz0TlaFY6o3URF5tx7u8Ubjv59fXDILIN2kJ5 LPBgYV+QPHW3Q== Received: by ida.kurilemu.internal (Postfix, from userid 1000) id E9870B00009; Mon, 20 Jul 2026 18:10:10 +0200 (CEST) Date: Mon, 20 Jul 2026 18:10:10 +0200 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: Dag Lem Cc: pgsql-bugs@lists.postgresql.org Subject: Re: REINDEX (CONCURRENTLY) TABLE handles DEFERRED constraints as IMMEDIATE while processing Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 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 On 2026-Jun-05, Dag Lem wrote: > While processing, "REINDEX (CONCURRENTLY) TABLE table_name" temporarily > treats the DEFERRED constraints as IMMEDIATE, causing transactions to fail > with errors on the form 'ERROR: duplicate key value violates unique > constraint "uq_constraint_name"'. I would say that this is clearly an oversight. > Note how it is currently not possible to safely add a UNIQUE > DEFERRED constraint following the example in > https://www.postgresql.org/docs/18/sql-altertable.html > > CREATE UNIQUE INDEX CONCURRENTLY dist_id_temp_idx ON distributors (dist_id); > ALTER TABLE distributors DROP CONSTRAINT distributors_pkey, > ADD CONSTRAINT distributors_pkey PRIMARY KEY USING INDEX > dist_id_temp_idx; > > For this to work safely with UNIQUE DEFERRED constraints, I assume it would > be necessary to add an option to CREATE INDEX to make an index DEFERRED. I think this closely related problem is different. We'd probably want to fix the above in a backpatchable manner, but this one sounds like a new feature. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "Linux transformó mi computadora, de una `máquina para hacer cosas', en un aparato realmente entretenido, sobre el cual cada día aprendo algo nuevo" (Jaime Salinas)