|
Currently the function check_and_do_in_subquery_rewrite() is called at the prepare phase. Here's what the function does:
/*
|
If
|
1) this join is inside a subquery (of any type except FROM-clause
|
subquery) and
|
2) we aren't just normalizing a VIEW
|
|
Then perform early unconditional subquery transformations:
|
- Convert subquery predicate into semi-join, or
|
- Mark the subquery for execution using materialization, or
|
- Perform IN->EXISTS transformation, or
|
- Perform more/less ALL/ANY -> MIN/MAX rewriter
|
- Substitute trivial scalar-context subquery with its value
|
|
*/
|
All the the rewrites above are actually an optimization re-writes. Most of them transform the query tree into a form that cannot be converted into a proper equivalent SQL query. This prevents usage of an external SQL parser after the prepare stage if any of such transformation has been performed.
From architectural point of view doing such re-writes in the middle of the prepare stage is also not a proper solution because some of the transformation may be rejected at the optimization stage.
|