From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 5F38025FDD for ; Tue, 19 Jun 2018 11:26:07 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id m5lUhM6rNPM7 for ; Tue, 19 Jun 2018 11:26:07 -0400 (EDT) Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 1AAEB24A86 for ; Tue, 19 Jun 2018 11:26:07 -0400 (EDT) From: Kirill Shcherbatov Subject: [tarantool-patches] [PATCH v1 1/1] lua: make semicolon as default SQL terminator Date: Tue, 19 Jun 2018 18:26:00 +0300 Message-Id: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org, Kirill Shcherbatov 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