We should care about statements like this: /* bla-bla */ CREATE TABLE So naive "startsWith(...)" will not work in some scenarios.
:) On Fri, Jan 27, 2017 at 7:06 PM, Vladimir Ozerov <voze...@gridgain.com> wrote: > Folks, > > H2 has nice and powerful SQL parser, and we pass all incoming SQL commands > through it. However it doesn't support custom SQL syntax, which we are > likely to need in DDL at some point in future. > > As DDL statements are relatively easy to parse comparing to SELECTs and > they do not involve optimizer, we can easily create object model of DDL > command without invoking H2 at all. > > I propose to introduce small change into our parsing logic as follows: > > if (req.startsWith("CREATE" or "ALTER" or "DELETE") > parseDdlManually(req); > else > parseWithH2(req); > > It should be enough to support any custom syntax for our DDL with any > limitations and without any dependencies on H2 folks. > > For instance, see H2 "CREATE TABLE" [1] and "CREATE INDEX" [2] structure. > It is already very simple. But provided that Ignite doesn't support most of > H2 DDL features, Ignite DDL structure will be even simpler. > > it should take no more than 1-2 days to implement fully-fledged parsing for > these two commands. > > Thoughts? > > Vladimir. > > [1] http://www.h2database.com/html/grammar.html#create_table > [2] http://www.h2database.com/html/grammar.html#create_index > -- Alexey Kuznetsov