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 AACED21932 for ; Thu, 29 Nov 2018 11:03:52 -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 sW3r8STsIybL for ; Thu, 29 Nov 2018 11:03:52 -0500 (EST) Received: from smtp35.i.mail.ru (smtp35.i.mail.ru [94.100.177.95]) (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 1782A30099 for ; Thu, 29 Nov 2018 11:03:48 -0500 (EST) From: Kirill Shcherbatov Subject: [tarantool-patches] [PATCH v2 1/1] sql: fix parser.parse_only mode for triggers Date: Thu, 29 Nov 2018 19:03:45 +0300 Message-Id: <0943b4db119f16a30aad8198943568521508dfdb.1543507402.git.kshcherbatov@tarantool.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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, v.shpilevoy@tarantool.org Cc: Kirill Shcherbatov The sql_trigger_compile routine had a Vdbe leak as parser doesn't releases VM(it is not required in typical scenario). As the parse_only flag had not worked correctly for sql triggers sql_trigger_compile have had a memory leak. Closes #3838 --- src/box/sql.c | 1 + src/box/sql/tokenize.c | 3 +++ src/box/sql/trigger.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/box/sql.c b/src/box/sql.c index 7b41c9926..4ac55485f 100644 --- a/src/box/sql.c +++ b/src/box/sql.c @@ -1535,6 +1535,7 @@ sql_checks_resolve_space_def_reference(ExprList *expr_list, diag_set(ClientError, ER_SQL, parser.zErrMsg); rc = -1; } + assert(parser.pVdbe == NULL); sql_parser_destroy(&parser); return rc; } diff --git a/src/box/sql/tokenize.c b/src/box/sql/tokenize.c index 4eebfe527..38a90eaba 100644 --- a/src/box/sql/tokenize.c +++ b/src/box/sql/tokenize.c @@ -570,6 +570,7 @@ sql_expr_compile(sqlite3 *db, const char *expr, int expr_len) parser.parsed_ast.expr = NULL; } end: + assert(parser.pVdbe == NULL); sql_parser_destroy(&parser); return expression; } @@ -592,6 +593,7 @@ sql_view_compile(struct sqlite3 *db, const char *view_stmt) parser.parsed_ast.select = NULL; } + assert(parser.pVdbe == NULL); sql_parser_destroy(&parser); return select; } @@ -613,6 +615,7 @@ sql_trigger_compile(struct sqlite3 *db, const char *sql) parser.parsed_ast.trigger = NULL; } + assert(parser.pVdbe == NULL); sql_parser_destroy(&parser); return trigger; } diff --git a/src/box/sql/trigger.c b/src/box/sql/trigger.c index c38f9cd9d..593504d38 100644 --- a/src/box/sql/trigger.c +++ b/src/box/sql/trigger.c @@ -249,6 +249,8 @@ sql_trigger_finish(struct Parse *parse, struct TriggerStep *step_list, parse->parsed_ast.trigger = trigger; parse->parsed_ast_type = AST_TYPE_TRIGGER; trigger = NULL; + sqlite3VdbeDelete(parse->pVdbe); + parse->pVdbe = NULL; } cleanup: -- 2.19.2