Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fy2RS-0000gP-E3 for pgsql-bugs@arkaria.postgresql.org; Thu, 06 Sep 2018 22:07:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fy2RQ-0007ZG-6x for pgsql-bugs@arkaria.postgresql.org; Thu, 06 Sep 2018 22:07:56 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fy2RP-0007Z9-Tk for pgsql-bugs@lists.postgresql.org; Thu, 06 Sep 2018 22:07:56 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fy2RN-0005TF-0f for pgsql-bugs@postgresql.org; Thu, 06 Sep 2018 22:07:54 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w86M7pNn023060; Thu, 6 Sep 2018 18:07:51 -0400 From: Tom Lane To: Peter Eisentraut cc: Andrew Gierth , =?UTF-8?B?QW5kcsOpIEjDpG5zZWw=?= , pgsql-bugs@postgresql.org Subject: Re: Two constraints with the same name not always allowed In-reply-to: <4a963af1-b199-ceae-6e55-804535bbf09b@2ndquadrant.com> References: <0c1001d4428f$0942b430$1bc81c90$@webkr.de> <87in3ovy0r.fsf@news-spur.riddles.org.uk> <10110.1535907645@sss.pgh.pa.us> <4a963af1-b199-ceae-6e55-804535bbf09b@2ndquadrant.com> Comments: In-reply-to Peter Eisentraut message dated "Thu, 06 Sep 2018 23:53:47 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <23058.1536271671.1@sss.pgh.pa.us> Date: Thu, 06 Sep 2018 18:07:51 -0400 Message-ID: <23059.1536271671@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Peter Eisentraut writes: > On 02/09/2018 19:00, Tom Lane wrote: >> This also points up the lack of a suitable unique index on pg_constraint. >> It's sort of difficult to figure out what that should look like given that >> pg_constraint contains two quasi-independent collections of constraints, >> but maybe UNIQUE(conrelid,contypid,conname) would serve given the >> reasonable assumption that exactly one of conrelid and contypid is zero. > Sketches for assertions set both conrelid and contypid to zero. I think > the unique constraint would have to include connamespace to support that > properly. Well, as I said in the commit message, I'm now of the opinion that assertions should go in some new catalog. It was a mistake to put domain and relation constraints into the same catalog, and I don't think we ought to double down on that mistake by confusing the question of "what's this catalog's primary key?" still more. But yes, *if* we bull ahead and do it the wrong way, that would be a necessary change. I don't like it much, because it would fuzz up the question of whether the unique index actually guarantees only one instance of a constraint name per relid or typid. regards, tom lane