pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: mark.manley@tapad.com
To: pgsql-bugs@postgresql.org
Subject: BUG #14709: inconsistent answers with foreign data wrappers to mysql
Date: Thu, 15 Jun 2017 22:06:06 +0000
Message-ID: <20170615220606.1424.97802@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      14709
Logged by:          Mark Manley
Email address:      mark.manley@tapad.com
PostgreSQL version: 9.6.2
Operating system:   CentOS 7.3
Description:        

Greetings.

When using a foreign data wrapper from our 9.6.2 database to a MySQL 5.7
database, we get inconsistent results.  We're joining two tables from
another server:

dsp_users
dsp_accounts

This table is local in our Postgres server:

audiences

This query returns only the first record, which is using simple joins:

select audiences.* FROM audiences
INNER JOIN dsp_users ON dsp_users.id = audiences.created_by
INNER JOIN dsp_accounts ON dsp_accounts.id = audiences.account_id
WHERE audiences.name like '%Test%'

and I get only the first hit.

When I run the composite queries under it, removing the like clause from the
predicate, I get all the results I would expect:

1  |23842583561190673   |XXXXXXXX                  |sg1      |Test audience 
                      |            |1012       |269        |2017-05-03
15:04:57 |
2  |23842583562050673   |XXXXXXXX                  |sg1      |Test audience 
                      |            |1012       |269        |2017-05-03
15:25:59 |
10 |23842688223720004   |XXXXXXXX                  |sg1      |Audience DTAC
Test 1                 |            |1013       |307        |2017-06-09
16:40:54 |

with the clause:

1  |23842583561190673   |XXXXXXXX                  |sg1      |Test audience 
                      |            |1012       |269        |2017-05-03
15:04:57 |

If I rewrite the query to turn the foreign MySQL tables into a subselect,
then I get the correct results:

select a.* from audiences a
where exists (select 1 from audiences a, dsp_users du, dsp_accounts da
 where
 a.created_by = du.id
 and a.account_id = da.id)

1  |23842583561190673   |XXXXXXXX                  |sg1      |Test audience 
                      |            |1012       |269        |2017-05-03
15:04:57 |
2  |23842583562050673   |XXXXXXXX                  |sg1      |Test audience 
                      |            |1012       |269        |2017-05-03
15:25:59 |
10 |23842688223720004   |XXXXXXXX                  |sg1      |Audience DTAC
Test 1                 |            |1013       |307        |2017-06-09
16:40:54 |

As you can see, I get inconsistent results if I use a normal join versus a
subselect.  It's as though the like filter in the predicate is breaking. 
This behaviour does not happen with using likes joining local tables only. 


Anyway, wanted you guys to know.

Thanks!


-- 
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 (8+ messages)  latest in thread

Message-ID: <20170615220606.1424.97802@wrigleys.postgresql.org>
Permalink:  ../20170615220606.1424.97802@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20170615220606.1424.97802@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: mark.manley@tapad.com
  Subject: Re: BUG #14709: inconsistent answers with foreign data wrappers to mysql
  In-Reply-To: <20170615220606.1424.97802@wrigleys.postgresql.org>
  References: <20170615220606.1424.97802@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