summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2004-11-08 01:13:54 +0200
committerunknown <monty@mysql.com>2004-11-08 01:13:54 +0200
commit435b20aa6897b142f90267ea3ed7a7cef1cc385a (patch)
tree7a3852793309c847d2ee83023b9429b28913b390 /sql/sql_parse.cc
parent43c6c27c905a47e062bfbf3e8908a8919d61b391 (diff)
downloadmariadb-git-435b20aa6897b142f90267ea3ed7a7cef1cc385a.tar.gz
Simpler arena swapping code
Now thd->mem_root is a pointer to thd->main_mem_root and THR_MALLOC is a pointer to thd->mem_root. This gives us the following benefits: - Allow us to easily detect if arena has already been swapped before (this fixes a bug in setup_conds() where arena was swaped twice in some cases) - Faster swaps of arenas (as we don't have to copy the whole MEM_ROOT) - We don't anymore have to call my_pthread_setspecific_ptr(THR_MALLOC,...) to change where memory is alloced. Now it's enough to set thd->mem_root client/mysqltest.c: Remove some not needed defines (Things like this should be done in config-win.h) include/config-win.h: Added popen() and pclose() compatibility macros mysql-test/t/rpl_failed_optimize-master.opt: Portability fix sql/ha_berkeley.cc: New thd->memroot handling sql/item_cmpfunc.cc: Simpler arena swapping code sql/item_func.cc: Simpler arena swapping code sql/item_subselect.cc: Simpler arena swapping code New thd->mem_root handling sql/item_sum.cc: New thd->mem_root handling sql/item_timefunc.cc: Fixed not-initalized usage errors found by valgrind sql/log_event.cc: New thd->mem_root handling sql/mysql_priv.h: New thd->mem_root handling sql/mysqld.cc: New thd->mem_root handling sql/opt_range.cc: New thd->mem_root handling sql/repl_failsafe.cc: New thd->mem_root handling sql/set_var.cc: New thd->mem_root handling sql/sql_acl.cc: New thd->mem_root handling sql/sql_base.cc: Simpler arena swapping code New thd->mem_root handling sql/sql_class.cc: New thd->mem_root handling sql/sql_class.h: Simpler arena swapping code New thd->mem_root handling sql/sql_db.cc: New thd->mem_root handling sql/sql_error.cc: New thd->mem_root handling sql/sql_help.cc: New thd->mem_root handling sql/sql_insert.cc: New thd->mem_root handling sql/sql_parse.cc: New thd->mem_root handling Added some extra checking of return value of new sql/sql_prepare.cc: New thd->mem_root handling sql/sql_select.cc: New thd->mem_root handling sql/sql_select.h: New thd->mem_root handling sql/sql_union.cc: Simpler arena swapping code sql/sql_yacc.yy: New thd->mem_root handling sql/table.cc: New thd->mem_root handling sql/thr_malloc.cc: New thd->mem_root handling tests/client_test.c: Added drop table to some tests Changed some table names to 't1'
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc24
1 files changed, 13 insertions, 11 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index f5b9bc0638f..2bf977804af 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1026,7 +1026,7 @@ pthread_handler_decl(handle_one_connection,arg)
}
if (thd->user_connect)
decrease_user_connections(thd->user_connect);
- free_root(&thd->mem_root,MYF(0));
+ free_root(thd->mem_root,MYF(0));
if (net->error && net->vio != 0 && net->report_error)
{
if (!thd->killed && thd->variables.log_warnings > 1)
@@ -1121,14 +1121,14 @@ extern "C" pthread_handler_decl(handle_bootstrap,arg)
{
thd->net.error = 0;
close_thread_tables(thd); // Free tables
- free_root(&thd->mem_root,MYF(MY_KEEP_PREALLOC));
+ free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC));
break;
}
mysql_parse(thd,thd->query,length);
close_thread_tables(thd); // Free tables
if (thd->is_fatal_error)
break;
- free_root(&thd->mem_root,MYF(MY_KEEP_PREALLOC));
+ free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC));
free_root(&thd->transaction.mem_root,MYF(MY_KEEP_PREALLOC));
}
@@ -1681,7 +1681,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
#endif
close_connection(thd, 0, 1);
close_thread_tables(thd); // Free before kill
- free_root(&thd->mem_root,MYF(0));
+ free_root(thd->mem_root,MYF(0));
free_root(&thd->transaction.mem_root,MYF(0));
kill_mysql();
error=TRUE;
@@ -1808,7 +1808,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
thread_running--;
VOID(pthread_mutex_unlock(&LOCK_thread_count));
thd->packet.shrink(thd->variables.net_buffer_length); // Reclaim some memory
- free_root(&thd->mem_root,MYF(MY_KEEP_PREALLOC));
+ free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC));
DBUG_RETURN(error);
}
@@ -2062,7 +2062,7 @@ mysql_execute_command(THD *thd)
query_len= need_conversion? (pstr->length() * to_cs->mbmaxlen) :
pstr->length();
- if (!(query_str= alloc_root(&thd->mem_root, query_len+1)))
+ if (!(query_str= alloc_root(thd->mem_root, query_len+1)))
{
res= -1;
break; // EOM (error should be reported by allocator)
@@ -3937,8 +3937,8 @@ mysql_init_select(LEX *lex)
bool
mysql_new_select(LEX *lex, bool move_down)
{
- SELECT_LEX *select_lex = new(&lex->thd->mem_root) SELECT_LEX();
- if (!select_lex)
+ SELECT_LEX *select_lex;
+ if (!(select_lex= new(lex->thd->mem_root) SELECT_LEX()))
return 1;
select_lex->select_number= ++lex->thd->select_number;
select_lex->init_query();
@@ -3946,9 +3946,10 @@ mysql_new_select(LEX *lex, bool move_down)
if (move_down)
{
/* first select_lex of subselect or derived table */
- SELECT_LEX_UNIT *unit= new(&lex->thd->mem_root) SELECT_LEX_UNIT();
- if (!unit)
+ SELECT_LEX_UNIT *unit;
+ if (!(unit= new(lex->thd->mem_root) SELECT_LEX_UNIT()))
return 1;
+
unit->init_query();
unit->init_select();
unit->thd= lex->thd;
@@ -3970,7 +3971,8 @@ mysql_new_select(LEX *lex, bool move_down)
as far as we included SELECT_LEX for UNION unit should have
fake SELECT_LEX for UNION processing
*/
- fake= unit->fake_select_lex= new(&lex->thd->mem_root) SELECT_LEX();
+ if (!(fake= unit->fake_select_lex= new(lex->thd->mem_root) SELECT_LEX()))
+ return 1;
fake->include_standalone(unit,
(SELECT_LEX_NODE**)&unit->fake_select_lex);
fake->select_number= INT_MAX;