Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XiCdM-0001Zd-VS for pgsql-bugs@arkaria.postgresql.org; Sun, 26 Oct 2014 01:28:41 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XiCdL-0002wn-R9 for pgsql-bugs@arkaria.postgresql.org; Sun, 26 Oct 2014 01:28:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XiCdJ-0002we-TF for pgsql-bugs@postgresql.org; Sun, 26 Oct 2014 01:28:37 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XiCdC-0000Y5-HY for pgsql-bugs@postgresql.org; Sun, 26 Oct 2014 01:28:36 +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 s9Q1SRhh022373; Sat, 25 Oct 2014 21:28:27 -0400 From: Tom Lane To: Heikki Linnakangas cc: support@maerix.com, pgsql-bugs@postgresql.org Subject: Re: BUG #11617: issue with dump/restore involving view with hstore data type embedded in where condition In-reply-to: <11046.1414190207@sss.pgh.pa.us> References: <20141009200031.25464.53769@wrigleys.postgresql.org> <544ACDAB.7060904@vmware.com> <11046.1414190207@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Fri, 24 Oct 2014 18:36:47 -0400" Date: Sat, 25 Oct 2014 21:28:27 -0400 Message-ID: <22372.1414286907@sss.pgh.pa.us> X-Pg-Spam-Score: -3.4 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org I wrote: > I wonder whether we couldn't fix this better by insisting that these > operations depend on default btree opclasses instead of looking up > "=" by name. Upthread I whined that this wouldn't work for comparisons > of nonidentical datatypes, but could we insist for cross-type cases that > both types have default btree opclasses belonging to the same opfamily? I thought a bit more about this, and that idea isn't going to work, at least not by itself. Right now you can do, eg, "integer IS DISTINCT FROM numeric", and it works, but the way it works is that the integer is promoted to numeric and we use the "numeric = numeric" operator. int and numeric do not have an opfamily in common, so this case would fail with the rule above. A reasonable way to handle that sort of case is to do select_common_type (ie, UNION-like type promotion) and then insist that the common type have a default btree opclass. However, the common-opfamily approach seems like a better idea when it works, since it would avoid a runtime type coercion in cases where there is a suitable cross-type comparison operator. So what I now suggest is: 1. If the two inputs are of types that have default btree opclasses in the same opfamily, and that opfamily has an equality operator that accepts these input types, use that operator. 2. Otherwise, do select_common_type(), and see if the common type has a default btree opclass. If so, use that opclass's equality operator after coercing both inputs to the common type. 3. If neither of those work, fail. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs