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 4677320E77 for ; Sun, 9 Dec 2018 16:30:42 -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 WOC06oaQoLbP for ; Sun, 9 Dec 2018 16:30:42 -0500 (EST) Received: from smtp52.i.mail.ru (smtp52.i.mail.ru [94.100.177.112]) (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 BD74020E66 for ; Sun, 9 Dec 2018 16:30:40 -0500 (EST) From: Nikita Pettik Subject: [tarantool-patches] [PATCH 1/6] sql: avoid calling sql_encode_table_opts() during trigger creation Date: Mon, 10 Dec 2018 00:30:21 +0300 Message-Id: <3c4a6fd745c0a651a164cdc155404e3555078a56.1544387419.git.korablev@tarantool.org> In-Reply-To: References: 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: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org, Nikita Pettik At the last stage of trigger creation, trigger's create statement ("CREATE TRIGGER ...") is encoded to msgpack. Since only this string is only member of a map to be encoded, is makes no sense to call whole sql_encode_table_opts() function, which in turn processes table's checks, opts for VIEW etc. Needed for #2647 --- src/box/sql/trigger.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/box/sql/trigger.c b/src/box/sql/trigger.c index c38f9cd9d..c7d22b9d0 100644 --- a/src/box/sql/trigger.c +++ b/src/box/sql/trigger.c @@ -212,19 +212,17 @@ sql_trigger_finish(struct Parse *parse, struct TriggerStep *step_list, parse->nMem += 3; int record = ++parse->nMem; - uint32_t opts_buff_sz = 0; - char *data = sql_encode_table_opts(&fiber()->gc, NULL, sql_str, - &opts_buff_sz); - sqlite3DbFree(db, sql_str); - if (data == NULL) { - parse->nErr++; - parse->rc = SQL_TARANTOOL_ERROR; - goto cleanup; - } - char *opts_buff = sqlite3DbMallocRaw(db, opts_buff_sz); + uint32_t opts_buff_sz = mp_sizeof_map(1) + + mp_sizeof_str(strlen("sql")) + + mp_sizeof_str(strlen(sql_str)); + char *opts_buff = (char *) sqlite3DbMallocRaw(db, opts_buff_sz); if (opts_buff == NULL) goto cleanup; - memcpy(opts_buff, data, opts_buff_sz); + + char *data = mp_encode_map(opts_buff, 1); + data = mp_encode_str(data, "sql", strlen("sql")); + data = mp_encode_str(data, sql_str, strlen(sql_str)); + sqlite3DbFree(db, sql_str); trigger_name = sqlite3DbStrDup(db, trigger_name); if (trigger_name == NULL) { -- 2.15.1