From: Kirill Shcherbatov <kshcherbatov@tarantool.org> To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org, Kirill Shcherbatov <kshcherbatov@tarantool.org> Subject: [tarantool-patches] [PATCH v1 1/1] lua: make semicolon as default SQL terminator Date: Tue, 19 Jun 2018 18:26:00 +0300 [thread overview] Message-ID: <e692d6021ab508cc77b5f94bff7227401910fcdd.1529421840.git.kshcherbatov@tarantool.org> (raw) Branch: http://github.com/tarantool/tarantool/tree/kshch/gh-2125-semi-terminator Issue: https://github.com/tarantool/tarantool/issues/2125 Now semicolon sets as a default terminator on entering "set language sql". Resolves #2125. --- src/box/lua/console.lua | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/box/lua/console.lua b/src/box/lua/console.lua index e7cb50a..31e220f 100644 --- a/src/box/lua/console.lua +++ b/src/box/lua/console.lua @@ -67,6 +67,7 @@ local function set_language(storage, value) local msg = 'Invalid language "%s", supported languages: lua and sql.' return error(msg:format(value)) end + set_delimiter(storage, value == 'sql' and ';' or nil) storage.language = value return true end @@ -316,7 +317,11 @@ local function local_read(self) break end elseif #buf >= #delim and buf:sub(#buf - #delim + 1) == delim then - buf = buf:sub(0, #buf - #delim) + local sub_len = #buf - #delim + if box.session.language == 'sql' and delim == ';' then + sub_len = sub_len + 1 + end + buf = buf:sub(0, sub_len) break end buf = buf.."\n" @@ -354,8 +359,12 @@ local function client_read(self) -- Escape sequence to close current connection (like SSH) return nil end - -- remove trailing delimiter - return buf:sub(1, -#delim-1) + -- remove trailing delimiter if it is not SQL ; + if box.session.language == 'sql' and delim == ';' then + return buf + else + return buf:sub(1, -#delim-1) + end end -- -- 2.7.4
next reply other threads:[~2018-06-19 15:26 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-06-19 15:26 Kirill Shcherbatov [this message] 2018-06-22 15:04 ` [tarantool-patches] " Vladislav Shpilevoy
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=e692d6021ab508cc77b5f94bff7227401910fcdd.1529421840.git.kshcherbatov@tarantool.org \ --to=kshcherbatov@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [tarantool-patches] [PATCH v1 1/1] lua: make semicolon as default SQL terminator' \ /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