diff options
author | Alexander Nozdrin <alik@sun.com> | 2010-05-14 22:11:25 +0400 |
---|---|---|
committer | Alexander Nozdrin <alik@sun.com> | 2010-05-14 22:11:25 +0400 |
commit | 6facd4cb13170e8695d9ae4f1e30611af0b0a472 (patch) | |
tree | 288d8745f229bd71630b65bb9f3cbd594db8d7e8 /mysql-test/t/parser_stack.test | |
parent | 4333980a493e7062e108899b34cc809b03862c34 (diff) | |
download | mariadb-git-6facd4cb13170e8695d9ae4f1e30611af0b0a472.tar.gz |
Patch for Bug#27863 (excessive memory usage for many small queries in a
multiquery packet).
Background:
- a query can contain multiple SQL statements;
- the server frees resources allocated to process a query when the
whole query is handled. In other words, resources allocated to process
one SQL statement from a multi-statement query are freed when all SQL
statements are handled.
The problem was that the parser allocated a buffer of size of the whole
query for each SQL statement in a multi-statement query. Thus, if a query
had many SQL-statements (so, the query was long), but each SQL statement
was short, ther parser tried to allocate huge amount of memory (number of
small SQL statements * length of the whole query).
The memory was allocated for a so-called "cpp buffer", which is intended to
store pre-processed SQL statement -- SQL text without version specific
comments.
The fix is to allocate memory for the "cpp buffer" once for all SQL
statements (once for a query).
Diffstat (limited to 'mysql-test/t/parser_stack.test')
-rw-r--r-- | mysql-test/t/parser_stack.test | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/mysql-test/t/parser_stack.test b/mysql-test/t/parser_stack.test index 3330ef41833..bdcad5aa1b4 100644 --- a/mysql-test/t/parser_stack.test +++ b/mysql-test/t/parser_stack.test @@ -399,4 +399,12 @@ delimiter ;$$ drop procedure p_37228; +# +# Bug#27863 (excessive memory usage for many small queries in a multiquery +# packet). +# +let $i=`select repeat("set @a=1;", 65535)`; +--disable_query_log +eval $i; +--enable_query_log |