pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: ipluta@wp.pl
Subject: BUG #15287: postgres_fdw: the "WHERE date_trunc('day', dt) = 'YYYY-MM-DD' does not push to remote.
Date: Fri, 20 Jul 2018 16:31:18 +0000
Message-ID: <153210427860.1404.15984608571673921883@wrigleys.postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      15287
Logged by:          Ireneusz Pluta
Email address:      ipluta@wp.pl
PostgreSQL version: 10.3
Operating system:   FreeBSD 11.1
Description:        

the clause:
WHERE date_trunc('day'::text, dt::timestamp without time zone) =
'yyyy-mm-dd' 
does not get shipped to the foreign server.

as seen on #postgresql:
[18:13] <RhodiumToad> date_trunc takes a mix of collatable and
non-collatable parameters (text is collatable, timestamp is not)
[18:13] <RhodiumToad> this is why I wanted the debug version of the query
tree, to see the collation ids
[18:14] <RhodiumToad> so given date_trunc('day', col), what happens is that
the walker first recurses into the args:
[18:14] <RhodiumToad> 'day' is a Const node with default collation, so the
inner_cxt.state gets set to NONE
[18:15] <RhodiumToad> "col" is a remote Var of a non-collatable type, so
inner_cxt.state still gets set to NONE
[18:15] <RhodiumToad> but then in the T_FuncExpr case in the walker, we get
to this line (468 in master):
[18:16] <RhodiumToad> if (fe->inputcollid == InvalidOid) ; else if
(inner_cxt.state != FDW_COLLATE_SAFE || ...) return false;
[18:17] <RhodiumToad> fe->inputcollid is DEFAULT_COLLATION_OID, not
InvalidOid, and inner_cxt.state is NONE, not SAFE, so the walker bails out
at that point
[18:17] <RhodiumToad> and reports the expression as "not safe for remote"
[18:18] <irqq_> should it be reported as a bug and expected to be
corrected?
[18:18] <RhodiumToad> basically this is confusion over the difference
between collid=InvalidOid, meaning "not of a collatable type", and
=DEFAULT_COLLATION_OID meaning "of a collatable type but no specified
collation"
[18:18] <RhodiumToad> yes it should be reported as a bug



view thread (11+ messages)  latest in thread

Message-ID: <153210427860.1404.15984608571673921883@wrigleys.postgresql.org>
Permalink:  ../153210427860.1404.15984608571673921883@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/153210427860.1404.15984608571673921883@wrigleys.postgresql.org

 · 

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: noreply@postgresql.org, ipluta@wp.pl
  Subject: Re: BUG #15287: postgres_fdw: the "WHERE date_trunc('day', dt) = 'YYYY-MM-DD' does not push to remote.
  In-Reply-To: <153210427860.1404.15984608571673921883@wrigleys.postgresql.org>
  References: <153210427860.1404.15984608571673921883@wrigleys.postgresql.org>

* 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