Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH v2 1/1] sql: fix parser.parse_only mode for triggers
@ 2018-11-29 16:03 Kirill Shcherbatov
  2018-11-29 16:14 ` [tarantool-patches] " Kirill Shcherbatov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kirill Shcherbatov @ 2018-11-29 16:03 UTC (permalink / raw)
  To: tarantool-patches, v.shpilevoy; +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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-12-06 14:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-29 16:03 [tarantool-patches] [PATCH v2 1/1] sql: fix parser.parse_only mode for triggers Kirill Shcherbatov
2018-11-29 16:14 ` [tarantool-patches] " Kirill Shcherbatov
2018-11-30 17:42 ` Vladislav Shpilevoy
2018-12-06 14:56 ` Kirill Yukhin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox