EnterpriseDB / mysql_fdw

PostgreSQL foreign data wrapper for MySQL
Other
530 stars 162 forks source link

ERROR: failed to execute the MySQL query #152

Closed trourance closed 3 weeks ago

trourance commented 6 years ago

Hi, I'm trying to execute the following query: SELECT count(*) FROM table1 a WHERE EXISTS (SELECT 1 FROM table2 WHERE id::VARCHAR = (SELECT id FROM table3 b WHERE b.column = a.column))

table1 and table3 are both remote mysql tables. But I get the following error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?))' at line 1

If I execute the query directly with a value, it succeeds. SELECT EXISTS (SELECT 1 FROM table2 WHERE id::VARCHAR = (SELECT id FROM table3 b WHERE b.column = 1234));

mr-russ commented 6 years ago

Can you provide the output from explain analyze verbose SELECT count(*) FROM table1 a WHERE EXISTS (SELECT 1 FROM table2 WHERE id::VARCHAR = (SELECT id FROM table3 b WHERE b.column = a.column))

if that fails explain verbose SELECT count(*) FROM table1 a WHERE EXISTS (SELECT 1 FROM table2 WHERE id::VARCHAR = (SELECT id FROM table3 b WHERE b.column = a.column))

That will indicate what SQL it's trying to run on the remote server and will provide a clearer indication of the issue.