Tarantool development patches archive
 help / color / mirror / Atom feed
From: Kirill Shcherbatov <kshcherbatov@tarantool.org>
To: tarantool-patches@freelists.org, v.shpilevoy@tarantool.org
Cc: Kirill Shcherbatov <kshcherbatov@tarantool.org>
Subject: [tarantool-patches] [PATCH v2 1/1] sql: fix parser.parse_only mode for triggers
Date: Thu, 29 Nov 2018 19:03:45 +0300	[thread overview]
Message-ID: <0943b4db119f16a30aad8198943568521508dfdb.1543507402.git.kshcherbatov@tarantool.org> (raw)

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

             reply	other threads:[~2018-11-29 16:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-29 16:03 Kirill Shcherbatov [this message]
2018-11-29 16:14 ` [tarantool-patches] " Kirill Shcherbatov
2018-11-30 17:42 ` Vladislav Shpilevoy
2018-12-06 14:56 ` Kirill Yukhin

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=0943b4db119f16a30aad8198943568521508dfdb.1543507402.git.kshcherbatov@tarantool.org \
    --to=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [tarantool-patches] [PATCH v2 1/1] sql: fix parser.parse_only mode for triggers' \
    /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