pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ireneusz Pluta <ipluta@wp.pl>
Cc: Andres Freund <andres@anarazel.de>
Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15287: postgres_fdw: the "WHERE date_trunc('day', dt) = 'YYYY-MM-DD' does not push to remote.
Date: Fri, 20 Jul 2018 13:07:11 -0400
Message-ID: <23967.1532106431@sss.pgh.pa.us> (raw)
In-Reply-To: <9d6b978a-1aff-4f9e-03c6-0489836570d8@wp.pl>
References: <153210427860.1404.15984608571673921883@wrigleys.postgresql.org>
	<20180720163945.exro5xgl7skq3kzo@alap3.anarazel.de>
	<9d6b978a-1aff-4f9e-03c6-0489836570d8@wp.pl>

Ireneusz Pluta <ipluta@wp.pl> writes:
> W dniu 2018-07-20 o 18:39, Andres Freund pisze:
>> You're probably going to have a higher likelihood of getting the bug
>> fixed quickly if you'd include a full reproducer.

> Sure, but RhodiumToad was so kind promising to follow up on this, so I skipped that chore :-).

It may be a bug, but I'm afraid it's a can't-fix one, at least for the
foreseeable future.  postgres_fdw is correctly determining that the
date_trunc function's input collation is being chosen on the basis of a
defaultly-collated literal, and that makes it unsafe to ship.  The
situation is not different from the case of, say,
	'foo'::text > 'bar'::text
(ignoring the likelihood that that'd get const-folded before it got here).
If that expression is evaluated locally, the result will depend on the
local database's default collation; whereas if we send it for remote
execution, the result will depend on the remote database's default
collation, and could very well be different.

In reality, date_trunc() pays no attention to its input collation; but
postgres_fdw has no way to know that, so it can't safely ship this
expression.

If we had a way to know that the remote database's default collation acts
the same as the local one's, we could use different and more forgiving
rules about what can be shipped; but I'm not sure how we could know that
reliably.  (We could perhaps check that it was named the same, but in
cross-platform situations that proves little.)

Alternatively, if postgres_fdw could know which functions don't really
pay attention to their input collation, it could skip this check for
those functions.  But that's not an easy thing to fix either.

			regards, tom lane




view thread (11+ messages)  latest in thread

Message-ID: <23967.1532106431@sss.pgh.pa.us>
Permalink:  ../23967.1532106431@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/23967.1532106431@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, ipluta@wp.pl, andres@anarazel.de, andrew@tao11.riddles.org.uk
  Subject: Re: BUG #15287: postgres_fdw: the "WHERE date_trunc('day', dt) = 'YYYY-MM-DD' does not push to remote.
  In-Reply-To: <23967.1532106431@sss.pgh.pa.us>
  References: <153210427860.1404.15984608571673921883@wrigleys.postgresql.org> <20180720163945.exro5xgl7skq3kzo@alap3.anarazel.de> <9d6b978a-1aff-4f9e-03c6-0489836570d8@wp.pl> <23967.1532106431@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