pg_dump fails on domain constraint comments

Started by Elvis Pranskevichusabout 10 years ago4 messages
#1Elvis Pranskevichus
elprans@gmail.com
1 attachment(s)

Hello Alvaro,

It looks like pg_dump emits incorrect text for domain constraint comments:

Assuming the following structure,

CREATE DOMAIN "dom" AS integer
CONSTRAINT "dom_constraint" CHECK ((VALUE > 10));

COMMENT ON CONSTRAINT "dom_constraint" ON DOMAIN "dom" IS 'domain constraint comment'

pg_dump will dump the COMMENT as follow:

COMMENT ON CONSTRAINT "dom_constraint" ON DOMAIN """dom""" IS 'domain constraint comment'

Note the double-quoting issue of the domain name.

Attached patch fixes that.

Elvis

Attachments:

0001-pg_dump-Fix-dumping-of-comments-on-domain-constraint.patchtext/x-patch; charset=UTF-8; name=0001-pg_dump-Fix-dumping-of-comments-on-domain-constraint.patchDownload
>From ce1d4984dc0fb12082d89282acb674f5597404f1 Mon Sep 17 00:00:00 2001
From: Elvis Pranskevichus <elvis@magic.io>
Date: Mon, 11 Jan 2016 17:30:54 -0500
Subject: [PATCH] pg_dump: Fix dumping of comments on domain constraints

---
 src/bin/pg_dump/pg_dump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 56c0528..00ffcac 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -9485,7 +9485,7 @@ dumpDomain(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
 		appendPQExpBuffer(labelq, "CONSTRAINT %s ",
 						  fmtId(domcheck->dobj.name));
 		appendPQExpBuffer(labelq, "ON DOMAIN %s",
-						  fmtId(qtypname));
+						  qtypname);
 		dumpComment(fout, dopt, labelq->data,
 					tyinfo->dobj.namespace->dobj.name,
 					tyinfo->rolname,
-- 
2.4.10

#2Michael Paquier
michael.paquier@gmail.com
In reply to: Elvis Pranskevichus (#1)
Re: pg_dump fails on domain constraint comments

On Tue, Jan 12, 2016 at 7:56 AM, Elvis Pranskevichus <elprans@gmail.com> wrote:

It looks like pg_dump emits incorrect text for domain constraint comments:

Assuming the following structure,

Nice catch! qtypname already has fmtId applied to it, so quotes are
applied twice to it in this case. I am adding an entry in the next CF
with patch marked as ready for committer so as this does not fail into
oblivion. A backpatch would be welcome as well.

Here is the patch entry:
https://commitfest.postgresql.org/9/481/
I could not add your name as an author as you visibly do not have a
community account. That's no big deal, I am just mentioning it here to
avoid confusion.
--
Michael

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Michael Paquier (#2)
Re: pg_dump fails on domain constraint comments

Michael Paquier wrote:

On Tue, Jan 12, 2016 at 7:56 AM, Elvis Pranskevichus <elprans@gmail.com> wrote:

It looks like pg_dump emits incorrect text for domain constraint comments:

Assuming the following structure,

Nice catch! qtypname already has fmtId applied to it, so quotes are
applied twice to it in this case. I am adding an entry in the next CF
with patch marked as ready for committer so as this does not fail into
oblivion. A backpatch would be welcome as well.

Yeah, evidently I didn't test that part. Thanks Elvis, applied and
backpatched to 9.5.

... Oh, I just noticed you requested this feature back in 2013,
/messages/by-id/5310157.yWWCtg2qIU@klinga.prans.org
I hope that it's doing what you wanted!

--
�lvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4Elvis Pranskevichus
elprans@gmail.com
In reply to: Alvaro Herrera (#3)
Re: pg_dump fails on domain constraint comments

On January 22, 2016 08:09:36 PM Alvaro Herrera wrote:

Michael Paquier wrote:

On Tue, Jan 12, 2016 at 7:56 AM, Elvis Pranskevichus <elprans@gmail.com>

wrote:

It looks like pg_dump emits incorrect text for domain constraint
comments:

Assuming the following structure,

Nice catch! qtypname already has fmtId applied to it, so quotes are
applied twice to it in this case. I am adding an entry in the next CF
with patch marked as ready for committer so as this does not fail into
oblivion. A backpatch would be welcome as well.

Yeah, evidently I didn't test that part. Thanks Elvis, applied and
backpatched to 9.5.

... Oh, I just noticed you requested this feature back in 2013,
/messages/by-id/5310157.yWWCtg2qIU@klinga.prans.org
I hope that it's doing what you wanted!

Yes, works like a charm! Thanks for implementing this.

Elvis

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers