From 6facd4cb13170e8695d9ae4f1e30611af0b0a472 Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Fri, 14 May 2010 22:11:25 +0400 Subject: 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). --- sql/sql_parse.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_parse.h') diff --git a/sql/sql_parse.h b/sql/sql_parse.h index 3c34b063d91..e1543a09549 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -84,7 +84,7 @@ bool is_log_table_write_query(enum enum_sql_command command); bool alloc_query(THD *thd, const char *packet, uint packet_length); void mysql_init_select(LEX *lex); void mysql_parse(THD *thd, const char *inBuf, uint length, - const char ** semicolon); + Parser_state *parser_state); void mysql_reset_thd_for_next_command(THD *thd); bool mysql_new_select(LEX *lex, bool move_down); void create_select_for_variable(const char *var_name); -- cgit v1.2.1