pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
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: Sat, 25 Oct 2014 21:28:27 -0400
Message-ID: <22372.1414286907@sss.pgh.pa.us> (raw)
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>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (7+ messages)  latest in thread

Message-ID: <22372.1414286907@sss.pgh.pa.us>
Permalink:  ../22372.1414286907@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/22372.1414286907@sss.pgh.pa.us

 · 

reply

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: <22372.1414286907@sss.pgh.pa.us>
  References: <20141009200031.25464.53769@wrigleys.postgresql.org> <544ACDAB.7060904@vmware.com> <11046.1414190207@sss.pgh.pa.us> <22372.1414286907@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