From: Nikita Pettik <korablev@tarantool.org>
To: Timur Safin <tsafin@tarantool.org>
Cc: m.semkin@corp.mail.ru, mons@tarantool.org,
tarantool-discussions@dev.tarantool.org,
Alexander Turenko <alexander.turenko@tarantool.org>
Subject: Re: [Tarantool-discussions] RFC - distributed SQL, step #1 - AST
Date: Wed, 25 Nov 2020 09:44:56 +0000 [thread overview]
Message-ID: <20201125094456.GA23894@tarantool.org> (raw)
In-Reply-To: <07e101d6c2ae$0607c980$12175c80$@tarantool.org>
On 25 Nov 01:06, Timur Safin wrote:
>
> Exporting AST as cdata is easy to do, but in this case it will be
> inconvenient to manipulate AST nodes, before sending to cluster nodes.
> So there is 2nd, more idiomatic approach suggested - to convert AST
> to nested Lua object/tables.
Hm, why do you need those tables? Serialization into msgpack can
be done inside SQL internals.
> Which should simplify some massaging
> and provide natural way to serialization to msgpack.
>
>
> SYNOPSIS
> ~~~~~~~~
>
> .. code-block:: lua
>
> local sql = require `sqlparser`
>
> -- parse, return ast, pass it back unmodified for execution
>
> local ast = sql.parse [[ select * from "table" where id > 10 limit 10 ]]
Should this be public API? Alternatively, we can hide it in sql.internals.
> assert(type(ast) == 'cdata')
> local ok = sql.execute(ast)
>
> -- free allocated memory, like box.unprepare but for ast
> sql.unparse(ast)
I don't like unparse name. In fact even unprepare is a bad name,
it should be called sort of deallocate. I suggest sql.release_ast()/
sql.free_ast() naming.
> -- raw access to cdata structures
> local cdata = ast.as_cdata()
> if cdata.ast_type == ffi.C.AST_TYPE_SELECT
> handle_select_stmt(cdata.select)
> end
>
> -- Lua access to structurs as Lua tables
> local tree = ast.as_table()
> if tree.type == AST_TYPE_SELECT
> handle_columns_list(tree.select.columns)
> handle_where_clause(tree.select.where)
> limit = tree.select.limit
What's the purpose of these handles?
> end
> -- massaging with tree data
>
> -- serialization
> local msgpack = require 'msgpack'
> local to_wire = msgpack.encode(tree)
>
> -- networking magics ...
> -- ... deserialization
> local table = msgpack.decode(from_wire)
> ast.set_tree(tree)
> sql.execute(ast)
>
>
> Regards,
> Timur
>
> P.S.
>
next prev parent reply other threads:[~2020-11-25 9:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-13 10:06 Timur Safin
2020-11-13 18:59 ` m.semkin
2020-11-24 21:52 ` Timur Safin
2020-11-20 0:05 ` Peter Gulutzan
2020-11-24 21:55 ` Timur Safin
2020-11-24 22:06 ` Timur Safin
2020-11-25 9:44 ` Nikita Pettik [this message]
2020-11-26 7:45 ` Timur Safin
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=20201125094456.GA23894@tarantool.org \
--to=korablev@tarantool.org \
--cc=alexander.turenko@tarantool.org \
--cc=m.semkin@corp.mail.ru \
--cc=mons@tarantool.org \
--cc=tarantool-discussions@dev.tarantool.org \
--cc=tsafin@tarantool.org \
--subject='Re: [Tarantool-discussions] RFC - distributed SQL, step #1 - AST' \
/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