-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Truncating casts are not pushed down correctly #298
Comments
Hi @smilingthax, If I understand your issue correctly, you are trying to say that cast operations should push down to the remote server to get the correct result. So, considering this PG query -
should be deparsed as
to get the correct result? I executed the above query on MySQL and got syntax error:
|
AFAIUI, mysql_fdw decides whether it can "handle" a certain operation, otherwise postgres will execute it locally. This is problematic, because (e.g.) truncating cast + group by cannot always "simply be done" after reading a result from mysql. Also, currently the expected (integer) vs. obtained values (potentially "0.1") disagree, which leads to the Either mysql_fdw MUST NOT claim to be able to handle them in non-trivial cases (and let postgres do the correct thing instead),
This would do the correct thing here, yes.
The statement does not error on MariaDB 10.11.2; Replacing
I'm not sure, if that's enough to formulate a fixed postgres->mysql type mapping which works for as many mysql/mariadb versions as possible...?
That's a separate issue: Currently, casts and function calls are treated as "the same" thing (
Therefore |
val float
column, two rows with values0
and0.1
.val
becomesreal
mysql_fdw_pushdown.config
allowsROUTINE pg_catalog.int4(real)
to be pushed down(My original encounter with this issue was with
::date
, resp.CAST(... AS date)
, when I tried to addto
mysql_fdw_pushdown.config
to allow it to be pushed down – w/o this entry, the grouping was (correctly) not pushed down, but performed by postgres. With the entry, the cast would be (wrongly) pushed down only partially, as described above. Usingdate(...)
instead pushes both that and the GROUP BY down correctly then (date
also exists as mysql function, whereint4
doesn't) ...)The text was updated successfully, but these errors were encountered: