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 1fnqeZ-0002jg-Qt for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Aug 2018 19:31:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fnqeX-00071Q-AH for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Aug 2018 19:31:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fnqeX-00071J-3I for pgsql-hackers@lists.postgresql.org; Thu, 09 Aug 2018 19:31:21 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fnqeT-00087W-Vx for pgsql-hackers@postgresql.org; Thu, 09 Aug 2018 19:31:20 +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 w79JV9xZ025607; Thu, 9 Aug 2018 15:31:09 -0400 From: Tom Lane To: Bruce Momjian cc: KES , PostgreSQL-development Subject: Re: Typo in doc or wrong EXCLUDE implementation In-reply-to: <20180809190913.GB14011@momjian.us> References: <153121527691.1408.5686988620817799073@wrigleys.postgresql.org> <20180807173659.GD7297@momjian.us> <31616681533725753@sas1-d856b3d759c7.qloud-c.yandex.net> <20180808130040.GA2611@momjian.us> <12107.1533736288@sss.pgh.pa.us> <37593701533809465@sas1-87f9feb8d943.qloud-c.yandex.net> <20180809190913.GB14011@momjian.us> Comments: In-reply-to Bruce Momjian message dated "Thu, 09 Aug 2018 15:09:13 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <25605.1533843069.1@sss.pgh.pa.us> Date: Thu, 09 Aug 2018 15:31:09 -0400 Message-ID: <25606.1533843069@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Bruce Momjian writes: > On Thu, Aug 9, 2018 at 01:11:05PM +0300, KES wrote: >> Why surprising? It is >> [documented](https://www.postgresql.org/docs/current/static/sql-create >> table.html#sql-createtable-exclude): >>> If all of the specified operators test for equality, this is >>> equivalent to a UNIQUE constraint, although an ordinary unique >>> constraint will be faster. >> Thus the UNIQUE constraint is just particular case of exclusion >> constraint, is not? > Well, for me a UNIQUE constraint guarantees each discrete value is > unique, while exclusion constraint says discrete or ranges or geometric > types don't overlap. I realize equality is a special case of discrete, > but having such cases be marked as UNIQUE seems too confusing. I think the OP is reading "equivalent" literally, as meaning that an EXCLUDE with operators that act like equality is treated as being the same as UNIQUE for *every* purpose. We're not going there, IMO, so probably we need to tweak the doc wording a little. Perhaps writing "functionally equivalent" would be better? Or instead of "is equivalent to", write "imposes the same restriction as"? regards, tom lane