From: "n.pettik" <korablev@tarantool.org> To: tarantool-patches@freelists.org Cc: Konstantin Osipov <kostja@tarantool.org>, Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Subject: [tarantool-patches] Re: [PATCH 2/2] sql: compute resulting collation for concatenation Date: Thu, 17 Jan 2019 22:19:26 +0300 [thread overview] Message-ID: <F38A3A4A-73DB-4D82-985D-69D42C245C20@tarantool.org> (raw) In-Reply-To: <20190117133322.GO28204@chai> > On 17 Jan 2019, at 16:33, Konstantin Osipov <kostja@tarantool.org> wrote: > > * Nikita Pettik <korablev@tarantool.org> [19/01/16 17:06]: >> According to ANSI, result of concatenation operation should derive >> collation sequence from its operands. Now it is not true: result is >> always comes with no ("none") collation. > > Generally, it should be very cheap to introduce expression static > analysis phase by adding static analysis state to struct Expr. > Yes, it's a blasphemy from separation of concerns point of view > but it seems to be a lesser evil than invoking partial static > analysis here and there during code generation. > > What i mean is that instead of changing signature of > sql_expr_coll() one should be able to do: > > /** > * Fills expr->coll for every node in the expression tree or > * returns an appropriate error if there is a type error. *Type and collation analysis are slightly different things I guess.* > */ > int > sql_expr_static_analysis(struct Expr *expr); Implement decent static analysis pass could be not so easy as it seems to be. Firstly, I guess we should deal with https://github.com/tarantool/tarantool/issues/3861 In a nutshell, now walker uses recursive approach. Hence, due to very limited size of fiber’s stack we get stack overflow on not so giant expressions. One more recursive routine may make things even worse. Secondly, we should decide where to place this analysis. There is no one entry point before code generation as well as there is no strict separation between parsing and code generation. Moreover, complete AST may not be constructed at all. I’m simply inlining part of R. Hipp’s recent respond from SQLite maling list: > SQLite does not necessarily generate a complete AST, then hand > that AST off to a code generator for evaluation, all in one neat step. > Depending on the SQL statement, the byte code may be generated using > techniques reminiscent of "syntax directed translation". Control hops > back and forth between parsing and code generation. Sections of > bytecode might generated at multiple reduce actions within the parse. In case you bless me and allow to spend extra time I can attempt at investigating this issue. Current approach at least works now.
next prev parent reply other threads:[~2019-01-17 19:19 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-01-16 13:13 [tarantool-patches] [PATCH 0/2] Compute derived " Nikita Pettik 2019-01-16 13:13 ` [tarantool-patches] [PATCH 1/2] sql: refactor sql_expr_coll and sql_binary_compare_coll_seq functions Nikita Pettik 2019-01-17 13:28 ` [tarantool-patches] " Konstantin Osipov 2019-01-24 18:28 ` Vladislav Shpilevoy 2019-02-14 23:26 ` n.pettik 2019-01-16 13:13 ` [tarantool-patches] [PATCH 2/2] sql: compute resulting collation for concatenation Nikita Pettik 2019-01-17 13:33 ` [tarantool-patches] " Konstantin Osipov 2019-01-17 19:19 ` n.pettik [this message] 2019-01-18 9:59 ` Kirill Yukhin 2019-01-24 18:29 ` Vladislav Shpilevoy 2019-02-14 23:26 ` n.pettik 2019-02-22 11:23 ` Vladislav Shpilevoy 2019-02-22 13:40 ` n.pettik 2019-02-22 13:51 ` Vladislav Shpilevoy 2019-02-25 11:29 ` [tarantool-patches] Re: [PATCH 0/2] Compute derived " Kirill Yukhin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=F38A3A4A-73DB-4D82-985D-69D42C245C20@tarantool.org \ --to=korablev@tarantool.org \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='[tarantool-patches] Re: [PATCH 2/2] sql: compute resulting collation for concatenation' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox