From ff3da0f963b28d128005da8ca5d0c93a72d34b27 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 28 Feb 2011 12:48:50 +0200 Subject: Change TABLE->alias to String for less memory reallocation Changed some String.ptr() -> String.c_ptr() for String that are not guaranteed to end with \0 Removed some c_ptr() usage from parameters to functions that takes ptr & length Use preallocate buffers to avoid calling malloc() for most operations. sql/event_db_repository.cc: alias is now a String sql/event_scheduler.cc: c_ptr -> c_ptr_safe() to avoid warnings from valgrind. sql/events.cc: c_ptr -> c_ptr_safe() to avoid warnings from valgrind. c_ptr -> ptr() as function takes ptr & length sql/field.cc: alias is now a String sql/field.h: alias is now a String sql/ha_partition.cc: alias is now a String sql/handler.cc: alias is now a String ptr() -> c_ptr() as string is not guaranteed to be \0 terminated sql/item.cc: Store error parameter in separarte buffer to ensure correct error message sql/item_func.cc: ptr() -> c_ptr_safe() as string is not guaranteed to be \0 terminated sql/item_sum.h: Use my_strtod() instead of my_atof() to not have to make string \0 terminated sql/lock.cc: alias is now a String sql/log.cc: c_ptr() -> ptr() as function takes ptr & length sql/log_event.cc: c_ptr_quick() -> ptr() as we only want to get the pointer to String buffer sql/opt_range.cc: ptr() -> c_ptr() as string is not guaranteed to be \0 terminated sql/opt_table_elimination.cc: alias is now a String sql/set_var.cc: ptr() -> c_ptr() as string is not guaranteed to be \0 terminated c_ptr() -> c_ptr_safe() to avoid warnings from valgrind. c_ptr() -> ptr() as function takes ptr & length Simplify some code. sql/sp.cc: c_ptr() -> ptr() as function takes ptr & length sql/sp_rcontext.cc: alias is now a String sql/sql_base.cc: alias is now a String. Here we win a realloc() for most alias usage. sql/sql_class.cc: Use size descriptor for printf() to avoid accessing bytes outside of buffer sql/sql_insert.cc: Change allocation of TABLE as it's now contains a String _ptr() -> ptr() as function takes ptr & length sql/sql_load.cc: Use preallocate buffers to avoid calling malloc() for most operations. sql/sql_parse.cc: Use c_ptr_safe() to ensure string is \0 terminated. sql/sql_plugin.cc: c_ptr_quick() -> ptr() as function takes ptr & length sql/sql_select.cc: alias is now a String sql/sql_show.cc: alias is now a String sql/sql_string.h: Added move() function to change who owns the string (owner does the free) sql/sql_table.cc: alias is now a String c_ptr() -> c_ptr_safe() to avoid warnings from valgrind. sql/sql_test.cc: c_ptr() -> c_ptr_safe() to avoid warnings from valgrind. alias is now a String sql/sql_trigger.cc: c_ptr() -> c_ptr_safe() to avoid warnings from valgrind. Use field->init() to setup pointers to alias. sql/sql_update.cc: alias is now a String sql/sql_view.cc: ptr() -> c_ptr_safe() as string is not guaranteed to be \0 terminated sql/sql_yacc.yy: r() -> c_ptr() as string is not guaranteed to be \0 terminated sql/table.cc: alias is now a String sql/table.h: alias is now a String storage/federatedx/ha_federatedx.cc: Remove extra 1 byte alloc that is automaticly done by strmake() Ensure that error message ends with \0 storage/maria/ha_maria.cc: alias is now a String storage/myisam/ha_myisam.cc: alias is now a String --- sql/sp_rcontext.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sp_rcontext.cc') diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc index be8f705a53e..686e1a1346f 100644 --- a/sql/sp_rcontext.cc +++ b/sql/sp_rcontext.cc @@ -118,7 +118,7 @@ sp_rcontext::init_var_table(THD *thd) return TRUE; m_var_table->copy_blobs= TRUE; - m_var_table->alias= ""; + m_var_table->alias.set("", 0, table_alias_charset); return FALSE; } -- cgit v1.2.1 From e6b0be38f9ea03b4f657b210755f6891ce2a30f0 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Wed, 9 Mar 2011 19:45:48 +0200 Subject: Bug fix for lp:732124 union + limit returns wrong result mysql-test/r/union.result: Added test for lp:732124 mysql-test/t/union.test: Added test for lp:732124 sql/sp_rcontext.cc: Updated function definition for ::send_data() sql/sp_rcontext.h: Updated function definition for ::send_data() sql/sql_analyse.cc: Test if send_data() returned an error sql/sql_class.cc: Updated function definition for ::send_data() sql/sql_class.h: Changed select_result::send_data(List &items) to return -1 in case of duplicate row that should not be counted as part of LIMIT sql/sql_cursor.cc: Check if send_data returned error sql/sql_delete.cc: Updated function definition for ::send_data() sql/sql_insert.cc: Updated function definition for ::send_data() sql/sql_select.cc: Don't count rows which send_data() tells you to ignore sql/sql_union.cc: Inform caller that the row should be ignored. This is the real bug fix for lp:732124 sql/sql_update.cc: Updated function definition for ::send_data() --- sql/sp_rcontext.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sql/sp_rcontext.cc') diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc index be8f705a53e..68b392a1212 100644 --- a/sql/sp_rcontext.cc +++ b/sql/sp_rcontext.cc @@ -651,7 +651,7 @@ int Select_fetch_into_spvars::prepare(List &fields, SELECT_LEX_UNIT *u) } -bool Select_fetch_into_spvars::send_data(List &items) +int Select_fetch_into_spvars::send_data(List &items) { List_iterator_fast spvar_iter(*spvar_list); List_iterator_fast item_iter(items); @@ -668,7 +668,7 @@ bool Select_fetch_into_spvars::send_data(List &items) for (; spvar= spvar_iter++, item= item_iter++; ) { if (thd->spcont->set_variable(thd, spvar->offset, &item)) - return TRUE; + return 1; } - return FALSE; + return 0; } -- cgit v1.2.1