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 /sql/ha_ndbcluster_binlog.cc | |
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 'sql/ha_ndbcluster_binlog.cc')
-rw-r--r-- | sql/ha_ndbcluster_binlog.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index edb6aeebb5c..330891c1a10 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -263,7 +263,7 @@ static void run_query(THD *thd, char *buf, char *end, ulonglong save_thd_options= thd->variables.option_bits; DBUG_ASSERT(sizeof(save_thd_options) == sizeof(thd->variables.option_bits)); NET save_thd_net= thd->net; - const char* found_semicolon= NULL; + Parser_state parser_state(thd, thd->query(), thd->query_length()); bzero((char*) &thd->net, sizeof(NET)); thd->set_query(buf, (uint) (end - buf)); @@ -277,7 +277,7 @@ static void run_query(THD *thd, char *buf, char *end, DBUG_ASSERT(!thd->in_sub_stmt); DBUG_ASSERT(!thd->locked_tables_mode); - mysql_parse(thd, thd->query(), thd->query_length(), &found_semicolon); + mysql_parse(thd, thd->query(), thd->query_length(), &parser_state); if (no_print_error && thd->is_slave_error) { |