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.98.2) (envelope-from ) id 1xQiUd-00000000K4K-3W3X for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Nov 2026 09:50:19 +0000 Received: from localhost ([127.0.0.1]:54270 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xQiUc-00000004oAu-14zK for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Nov 2026 09:50:18 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]:33246) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xQPL1-00000001EIC-0P5T for pgsql-bugs@lists.postgresql.org; Mon, 09 Nov 2026 13:23:07 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xQPKz-0000000024f-2b7B for pgsql-bugs@lists.postgresql.org; Mon, 09 Nov 2026 13:23:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=hzdB87JTuzdj/qx1qKEtiNx+bGmmsIuk311nAVQRNpI=; b=xnvKWjwxWlHQpP6XfyXIOtdr1C /xl0bUTQtl1JHhy/hNKgTRmaMzStFDRnWSgjgSPV0rZNc4G7HM0FlgtrkWRHOFlY5weJWDXQsaGex TkVu3PHwBzhuo+jvx1MLIIswiX0718BWs85RfqXaG7r+Y75SZX9OUTdZvYnEDeq51pBRECjZT94Ll qtDvxoJqOcbgbutNUsN2FL9fe0OBWGuRRRp7E3oKPPpREMQi+kA/r2NpLYA5Vhufkx0PMDCQo1vRp 9ulp3bYuaVqII4Fqnhodwr7P3DhDB/lUvEwdHPBfz3i6KrdMI0tA0IOC3N59GiFeTjPEKJOu2qzRI hcMyafTQ==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xQPKy-00000000567-2WdC for pgsql-bugs@lists.postgresql.org; Mon, 09 Nov 2026 13:23:05 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xQPKx-00000000JK7-3Z4T for pgsql-bugs@lists.postgresql.org; Mon, 09 Nov 2026 13:23:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19858: pg_dump --clean --if-exists fails on NOT VALID domain constraint To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: 125atishprak@gmail.com Reply-To: 125atishprak@gmail.com, pgsql-bugs@lists.postgresql.org Date: Mon, 09 Nov 2026 13:22:08 +0000 Message-ID: <19858-5a734f08714a5c73@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The following bug has been logged on the website: Bug reference: 19858 Logged by: Atish Prakash Email address: 125atishprak@gmail.com PostgreSQL version: 18.6 Operating system: Linux x86_64 Description: =20 The pg_dump documentation says --if-exists suppresses "does not exist" errors when restoring with --clean. A separately dumped domain constraint is not covered, because the command it generates has no guard on the domain itself. CREATE DOMAIN d AS int; ALTER DOMAIN d ADD CONSTRAINT k CHECK (VALUE > 0) NOT VALID; pg_dump --clean --if-exists mydb > dump.sql The dump starts with: ALTER DOMAIN public.d DROP CONSTRAINT IF EXISTS k; DROP DOMAIN IF EXISTS public.d; Restoring into an empty database gives: ERROR: type "public.d" does not exist With psql -v ON_ERROR_STOP=3D1 the restore stops at that point, before creating anything. Other objects in the same test, using ALTER TABLE IF EXISTS and DROP ... IF EXISTS, gave no such error. Expected: no "does not exist" error with --if-exists. ALTER DOMAIN has no IF EXISTS form for the domain, so the fix could be to add one, or to skip the constraint drop since DROP DOMAIN follows it. I have not written a patch. Found with dump and restore differential tests. I reproduced and checked the result myself.