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.94.2) (envelope-from ) id 1uxFb8-00CQlr-Ld for pgsql-hackers@arkaria.postgresql.org; Sat, 13 Sep 2025 02:02:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uxFb6-004wnG-Gl for pgsql-hackers@arkaria.postgresql.org; Sat, 13 Sep 2025 02:02:41 +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.94.2) (envelope-from ) id 1uxFb5-004wn1-Vx for pgsql-hackers@lists.postgresql.org; Sat, 13 Sep 2025 02:02:41 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uxFb2-000WMn-1K for pgsql-hackers@lists.postgresql.org; Sat, 13 Sep 2025 02:02:40 +0000 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-772627dd50aso4221176b3a.1 for ; Fri, 12 Sep 2025 19:02:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1757728956; x=1758333756; darn=lists.postgresql.org; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=hUZhSIit71QU+s/6z8TdrpcHrVpT0e0gyxK6OGtG3VY=; b=R1j6fCx4jhcpY+Y4Vm5YcGRYgcd+eBeBXU5P/7zTBWLSYYO3S3aFp+oTplZDC+N9Nx 28dblTJIdm+LKOFIY+GcLwV5mPiMcBQUhY1E93mzMuNnQyoL1yfhUKAse6g4ns0TybOj p7PNPaFm5rJ2PJwF6WdIVyePVn9p/T42MjXsQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757728956; x=1758333756; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hUZhSIit71QU+s/6z8TdrpcHrVpT0e0gyxK6OGtG3VY=; b=Am2r7ln+43s+6F258QYTQVL8qyJlpnSt7N2yzR9waJ3QI+JaEk/k0loFz4KS6U6IhF Bkyvma6zlMRMK/8BqYAuEw8K7r+qyJyMN/Ptw38halj7P44oqtIovc8cTTroJTTgcSO6 n/TQ1XWlbJP1vIdQIAu/9hB8tN1QUxMxcpi4umRtoeqv92YUCePqd8xcrfCguKwWrj2G xP47efvysJTbwiymJpesRwS4xGcpLpUpMZf3LA1JA5cSdJj05Gd4ZElmGqvdPr4klap1 Hd5FpOXQ/wEfwgNl9axPtDDIRilVgkE0djh9RVL/cdf5k0AVEtTwxoDzkYsz5zic1Pjf jtng== X-Forwarded-Encrypted: i=1; AJvYcCXlv4vq+ZvPe0FZDEq0bw5LwE72krKMJ0YVXe0O83TH9EnArJ4C6GCCa2iFg82kq+lRSwnEoV73Ujhch+gz@lists.postgresql.org X-Gm-Message-State: AOJu0Yy5Cm9LadEYeD0bPh0wAhh0ygVOWWv0+zGy5lmULRSYqWiQIWLA Tc+L3oHtX17QDoyE5Nb8fpr3gCHdkXkEo49A3jhnn0bGPoQoKGaqJco65amwmZHgAw== X-Gm-Gg: ASbGnctu1+Z9iKcP+Qx3m1FYL+edGdh3hD6QuOmG1eEb8mtlAEBS/Wd2Uq8Os24pcmz U96/a6k6U3izWcbeM1w8b8WwRnHjh1xk9XOLJxXPHlWM1Srzi1FyhGpjHOy1WWvXQddhCzStM24 wRcgfE3xMDJHpn8lYTVm0KmDZqfbR53t+7fcE4l1xvYoM1MV2kbgVDhoEZO7aWTNprpzSznoKTR RSRN/J+1NP7+aE9yop7yF6gmD+GdNQwPeeh6TjjYurf/B0AZCimceVzkmHwyvZj1yhKLB86mxdB rEdVbeOJO5/8VuhpgAEO3ICNCoqqCvh/Whh0OHHDNMQHjd+GBTTNxPyZU6d/hVhXTsn/j/Uwc1e 9LP7ey6y4oQE0ha4nskSFVqSBFGbArecYCMfWE5+ZfOzI68eftbQ= X-Google-Smtp-Source: AGHT+IHMgQdVv12AflZxnPpNBRFgfZtz+ICLROA+W/98WuUTFPxfwyZe7aB0cg0Ctbxqn0ynRDE2eA== X-Received: by 2002:a05:6a20:7293:b0:248:f6f1:200a with SMTP id adf61e73a8af0-25cf5c13facmr9951382637.1.1757728955777; Fri, 12 Sep 2025 19:02:35 -0700 (PDT) Received: from google.com (c-73-15-160-255.hsd1.ca.comcast.net. [73.15.160.255]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-b54a3a9e9ddsm5878166a12.51.2025.09.12.19.02.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Sep 2025 19:02:35 -0700 (PDT) Date: Fri, 12 Sep 2025 19:02:33 -0700 From: Noah Misch To: =?iso-8859-1?Q?=C1lvaro?= Herrera Cc: jian he , PostgreSQL Hackers Subject: Re: pg_dump does not dump domain not-null constraint's comments Message-ID: <20250913020233.fa.nmisch@google.com> References: <202507151340.d4jyrbdae5af@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202507151340.d4jyrbdae5af@alvherre.pgsql> User-Agent: Mutt/2.2.12 (2023-09-09) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Jul 15, 2025 at 03:40:38PM +0200, Álvaro Herrera wrote: > On 2025-Jul-15, jian he wrote: > > we should let: > > dumpConstraint handles dumping separate "NOT VALID" domain constraints along > > with their comments. > > dumpDomain: handles dumping "inlined" valid (not separate) domain constraints > > together with their comments. This became commit 0858f0f. > @@ -18487,8 +18493,25 @@ dumpConstraint(Archive *fout, const ConstraintInfo *coninfo) > .description = "CHECK CONSTRAINT", > .section = SECTION_POST_DATA, > .createStmt = q->data, > .dropStmt = delq->data)); > + > + if (coninfo->dobj.dump & DUMP_COMPONENT_COMMENT) > + { > + char *qtypname; > + > + PQExpBuffer conprefix = createPQExpBuffer(); > + qtypname = pg_strdup(fmtId(tyinfo->dobj.name)); > + > + appendPQExpBuffer(conprefix, "CONSTRAINT %s ON DOMAIN", > + fmtId(coninfo->dobj.name)); > + > + dumpComment(fout, conprefix->data, qtypname, > + tyinfo->dobj.namespace->dobj.name, > + tyinfo->rolname, > + coninfo->dobj.catId, 0, tyinfo->dobj.dumpId); The last argument gives the dump object on which the comment has a dependency. Since this is the case of a separately-dumped constraint, the comment needs to depend on that constraint (coninfo), not on the domain (tyinfo): - coninfo->dobj.catId, 0, tyinfo->dobj.dumpId); + coninfo->dobj.catId, 0, coninfo->dobj.dumpId); I didn't encounter a failure from this, but sufficient restore parallelism might reach a failure. A failure would look like a "does not exist" error in the COMMENT command, due to the constraint not yet existing. dumpTableConstraintComment() is an older case that optimally handles the last dumpComment() arg. In the absence of objections, I'll make it so.