HI,

I have a mockup PHP interface for exactly such a thing.  There are 'filters' which feed into other filters.  A set of queries is created which are executed, and when queries can be executed in parallel the query is represented as an array of queries.  This query passed through two filters, each filter sees the whole rewritten query from the previous filter.  You would determine the order of filters when installing the plugin.

This is the input:
select a, count(*) from some_table st join c1 where c2 = 'open' group by a

This is what the directed acyclic graph (query plan) looks like:
Array
(
[has_rewrites] => 1
[plan] => Array
(
[0] => CREATE TABLE IF NOT EXISTS p303_agg_16a836807550a78ff9793b7636ee4cbe (UNIQUE KEY gb_key (`expr_51179`)) ENGINE= AS SELECT a AS expr$0,COUNT(*) AS expr_463809566,a AS `expr_51179`
FROM some_table PARTITION(p1) AS `st` JOIN table2 AS `t2` USING(c1) WHERE c2 = 'open' AND 0=1 GROUP BY `expr_51179`
[1] => Array
(
[0] => INSERT INTO p303_agg_16a836807550a78ff9793b7636ee4cbe SELECT a AS expr$0,COUNT(*) AS expr_463809566,a AS `expr_51179`
FROM some_table PARTITION(p1) AS `st` JOIN table2 AS `t2` USING(c1) WHERE c2 = 'open' AND 1=1 GROUP BY `expr_51179`
[1] => INSERT INTO p303_agg_16a836807550a78ff9793b7636ee4cbe SELECT a AS expr$0,COUNT(*) AS expr_463809566,a AS `expr_51179`
FROM some_table PARTITION(p2) AS `st` JOIN table2 AS `t2` USING(c1) WHERE c2 = 'open' AND 1=1 GROUP BY `expr_51179`
[2] => INSERT INTO p303_agg_16a836807550a78ff9793b7636ee4cbe SELECT a AS expr$0,COUNT(*) AS expr_463809566,a AS `expr_51179`
FROM some_table PARTITION(p3) AS `st` JOIN table2 AS `t2` USING(c1) WHERE c2 = 'open' AND 1=1 GROUP BY `expr_51179`
)
[2] => SELECT expr$0 AS `a`,SUM(expr_463809566) AS `count(*)`
FROM `p303_agg_16a836807550a78ff9793b7636ee4cbe` GROUP BY a
[4] => DROP TABLE IF EXISTS p303_agg_16a836807550a78ff9793b7636ee4cbe
)
[errors] => Array
(
)
)

On Tue, Mar 3, 2015 at 8:19 AM, Justin Swanhart <greenlion@gmail.com> wrote:
Hi,

What about providing an alternate parser in the server but only for plugins to use?  The plugins rewrite the whole query, not modify the syntax tree so there is no fiddling with the query on THD, it is rewritten before the bison parser gets it.

--Justin

On Tue, Mar 3, 2015 at 8:07 AM, Sergei Golubchik <serg@mariadb.org> wrote:
Hi, Justin!

On Mar 03, Justin Swanhart wrote:
> So uhmm, use a new parser.  Like the one antony wrote in LLVM? :)  I
> mean, we would like to have window functions, CTE, and all those other
> fun things. SQL-92 is a not relevant anymore.

In MySQL times we've tried to replace a parser. Twice.
Antony has spent a year on that - that was one of the attempts.

We're still using the old one, so neither project was a success.

And Oracle started "parser refactoring" in 5.7, but they're doing it
piece-wise now, not trying to replace everything at once. And they'll
have to stay with bison this way.

What I mean - we very much want to use a new parser. We really do.
But it's just such a huge project :(

Regards,
Sergei