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 629D62F02D for ; Tue, 27 Nov 2018 14:25:21 -0500 (EST) 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 yhUcTCd2cQsx for ; Tue, 27 Nov 2018 14:25:21 -0500 (EST) Received: from smtp45.i.mail.ru (smtp45.i.mail.ru [94.100.177.105]) (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 1824F2EFF9 for ; Tue, 27 Nov 2018 14:25:20 -0500 (EST) From: imeevma@tarantool.org Subject: [tarantool-patches] [PATCH v3 1/7] box: store sql text and length in sql_request Date: Tue, 27 Nov 2018 22:25:18 +0300 Message-Id: <58aa507b0bcb6bb884c1247c0b1ee52ffc0938b2.1543344471.git.imeevma@gmail.com> In-Reply-To: References: 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: v.shpilevoy@tarantool.org, tarantool-patches@freelists.org Refactored sql_request structure to store pointer to sql string data and it's length instead of pointer to msgpack representation. This is required to use this structure in sql.c where the query has a different semantics and can be obtained from stack as a C string. Needed for #3505. --- src/box/execute.c | 6 +++--- src/box/execute.h | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/box/execute.c b/src/box/execute.c index fb3e08b..72fcd6c 100644 --- a/src/box/execute.c +++ b/src/box/execute.c @@ -284,7 +284,8 @@ error: if (sql_bind_list_decode(request, value, region) != 0) return -1; } else { - request->sql_text = value; + request->sql_text = + mp_decode_str(&value, &request->sql_text_len); } } if (request->sql_text == NULL) { @@ -596,8 +597,7 @@ sql_prepare_and_execute(const struct sql_request *request, struct sql_response *response, struct region *region) { const char *sql = request->sql_text; - uint32_t len; - sql = mp_decode_str(&sql, &len); + uint32_t len = request->sql_text_len; struct sqlite3_stmt *stmt; sqlite3 *db = sql_get(); if (db == NULL) { diff --git a/src/box/execute.h b/src/box/execute.h index 77bfd79..79cee69 100644 --- a/src/box/execute.h +++ b/src/box/execute.h @@ -58,6 +58,8 @@ struct sql_request { uint64_t sync; /** SQL statement text. */ const char *sql_text; + /** Length of the SQL statement text. */ + uint32_t sql_text_len; /** Array of parameters. */ struct sql_bind *bind; /** Length of the @bind. */ -- 2.7.4