Re: BUG #11617: issue with dump/restore involving view with hstore data type embedded in where condition

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: support(at)maerix(dot)com, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #11617: issue with dump/restore involving view with hstore data type embedded in where condition
Date: 2014-10-26 01:28:27
Message-ID: 22372.1414286907@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2014-10-26 20:46:13 Re: ltree::text not immutable?
Previous Message Heikki Linnakangas 2014-10-25 20:11:20 tsquery @> operator bugs