From: Tom Lane <tgl@sss.pgh.pa.us>
To: Heikki Linnakangas <hlinnakangas@vmware.com>
Cc: support@maerix.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #11617: issue with dump/restore involving view with hstore data type embedded in where condition
Date: Fri, 24 Oct 2014 18:36:47 -0400
Message-ID: <11046.1414190207@sss.pgh.pa.us> (raw)
In-Reply-To: <544ACDAB.7060904@vmware.com>
References: <20141009200031.25464.53769@wrigleys.postgresql.org>
<544ACDAB.7060904@vmware.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Heikki Linnakangas <hlinnakangas@vmware.com> 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 <operator> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, hlinnakangas@vmware.com, support@maerix.com
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>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox