Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XhnTe-00059B-5n for pgsql-bugs@arkaria.postgresql.org; Fri, 24 Oct 2014 22:36:58 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XhnTd-0002Hu-MF for pgsql-bugs@arkaria.postgresql.org; Fri, 24 Oct 2014 22:36:57 +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 1XhnTc-0002Hn-Ml for pgsql-bugs@postgresql.org; Fri, 24 Oct 2014 22:36:56 +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 1XhnTY-0005VJ-G3 for pgsql-bugs@postgresql.org; Fri, 24 Oct 2014 22:36:55 +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 s9OMalVA011047; Fri, 24 Oct 2014 18:36:48 -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: <544ACDAB.7060904@vmware.com> References: <20141009200031.25464.53769@wrigleys.postgresql.org> <544ACDAB.7060904@vmware.com> Comments: In-reply-to Heikki Linnakangas message dated "Sat, 25 Oct 2014 01:07:39 +0300" Date: Fri, 24 Oct 2014 18:36:47 -0400 Message-ID: <11046.1414190207@sss.pgh.pa.us> X-Pg-Spam-Score: -3.3 (---) 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 Heikki Linnakangas writes: > In the catalogs, we store the OID of the equality operator used in a > NULLIF or IS DISTINCT FROM expression. But when you try to deparse that > back to an SQL statement, it's impossible to construct an equivalent SQL > statement that would refer to the same operator, when that operator is > not in search_path. In essence, it's not possible to schema-qualify the > equality operator used. Right. > I don't think this can be solved without some additional syntax, for > specifying the equality operator explicitly. I propose that we add an > optional USING after the problematic expressions: > a IS DISTINCT FROM b USING myschema.= > NULLIF(a, b) USING myschema.= > ... Meh. When would this be used? I don't think we'd want ruleutils to deparse this way all the time. Also, in the case of IS DISTINCT FROM on composite values, it's not clear that one operator name is enough. 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? It's possible that such a redefinition would lead to rejecting some cases that work today, but I think they'd be strange corner cases. A quick look through pg_operator suggests that there are no built-in operators named "=" that link input types that aren't in the same opfamily. The big-picture situation is that right now, we have a weird mixture of cases where we do equality or sorting on the basis of operators looked up with an implicitly-assumed operator name, and cases where we do it based on finding a suitable member of a default btree opclass. The second way is on far more solid ground theoretically IMO. The only defense of the first way is that the SQL spec frequently says in so many words "this syntax is equivalent to A = B", and if you take that in a very literal fashion then looking up an operator named "=" is the thing to do. But I think a reasonable case could be made that they mean "A equals B" in some more abstract sense than "what is the operator named?". 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