EnterpriseDB / mysql_fdw

PostgreSQL foreign data wrapper for MySQL
Other
521 stars 160 forks source link

[Feature Support] Support push down some nested function #249

Open khieuvm opened 2 years ago

khieuvm commented 2 years ago

In MYSQL FDW, the current implementation uses the variable can_skip_cast to indicate if we can ignore casting checking inside a function and it can be used to ignore the casting in this case while minimizing the impact change to the system.

When ignoring the casting function inside a nested function, it can push down the nested function:

EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE round(abs(c1), 0) = 1; -- FuncExpr
                                                              QUERY PLAN                                                               
---------------------------------------------------------------------------------------------------------------------------------------
 Foreign Scan on public.ft1 t1
   Output: c1, c2, c3, c4, c5, c6, c7, c8
   Local server startup cost: 10
   Remote query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM `mysql_fdw_post`.`T 1` WHERE ((round(abs(`C 1`), 0) = 1))
(4 rows)

I would like to contribute them to the repository and community. I will create a pull request to share this feature if you have any interest.