summaryrefslogtreecommitdiff
path: root/sql/sql_insert.cc
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2010-11-24 00:08:48 +0200
committerMichael Widenius <monty@askmonty.org>2010-11-24 00:08:48 +0200
commit52090a443493f5a8410094b43bfa5cdde8c32f5d (patch)
tree3590baf00af1abf3a0d2b898fc43dee4c6880397 /sql/sql_insert.cc
parent0543e2e34e4e5e7dbfb89cf69e8e044e1884b07d (diff)
downloadmariadb-git-52090a443493f5a8410094b43bfa5cdde8c32f5d.tar.gz
Code cleanup to get fewer reallocs() during execution.
- Changed TABLE->alias to String to get fewer reallocs when alias are used. - Preallocate some buffers Changed some String->c_ptr() -> String->ptr() when \0 is not needed. Fixed wrong usage of String->ptr() when we need a \0 terminated string. Use my_strtod() instead of my_atof() to avoid having to add \0 to string. c_ptr() -> c_ptr_safe() to avoid warnings from valgrind. zr sql/event_db_repository.cc: Update usage of TABLE->alias sql/event_scheduler.cc: c_ptr() -> c_ptr_safe() sql/events.cc: c_ptr() -> ptr() as \0 was not needed sql/field.cc: Update usage of TABLE->alias sql/field.h: Update usage of TABLE->alias sql/ha_partition.cc: Update usage of TABLE->alias sql/handler.cc: Update usage of TABLE->alias Fixed wrong usage of str.ptr() sql/item.cc: Fixed error where code wrongly assumed string was \0 terminated. sql/item_func.cc: c_ptr() -> c_ptr_safe() Update usage of TABLE->alias sql/item_sum.h: Use my_strtod() instead of my_atof() to avoid having to add \0 to string sql/lock.cc: Update usage of TABLE->alias sql/log.cc: c_ptr() -> ptr() as \0 was not needed sql/log_event.cc: c_ptr_quick() -> ptr() as \0 was not needed sql/opt_range.cc: ptr() -> c_ptr() as \0 is needed sql/opt_subselect.cc: Update usage of TABLE->alias sql/opt_table_elimination.cc: Update usage of TABLE->alias sql/set_var.cc: ptr() -> c_ptr() as \0 is needed c_ptr() -> c_ptr_safe() sql/sp.cc: c_ptr() -> ptr() as \0 was not needed sql/sp_rcontext.cc: Update usage of TABLE->alias sql/sql_base.cc: Preallocate buffers Update usage of TABLE->alias sql/sql_class.cc: Fix arguments to sprintf() to work even if string is not \0 terminated sql/sql_insert.cc: Update usage of TABLE->alias c_ptr() -> ptr() as \0 was not needed sql/sql_load.cc: Preallocate buffers Trivial optimizations sql/sql_parse.cc: Trivial optimization sql/sql_plugin.cc: c_ptr() -> ptr() as \0 was not needed sql/sql_select.cc: Update usage of TABLE->alias sql/sql_show.cc: Update usage of TABLE->alias sql/sql_string.h: Added move() function to move allocated memory from one object to another. sql/sql_table.cc: Update usage of TABLE->alias c_ptr() -> c_ptr_safe() sql/sql_test.cc: ptr() -> c_ptr_safe() sql/sql_trigger.cc: Update usage of TABLE->alias c_ptr() -> c_ptr_safe() sql/sql_update.cc: Update usage of TABLE->alias sql/sql_view.cc: ptr() -> c_ptr_safe() sql/sql_yacc.yy: ptr() -> c_ptr() sql/table.cc: Update usage of TABLE->alias sql/table.h: Changed TABLE->alias to String to get fewer reallocs when alias are used. storage/federatedx/ha_federatedx.cc: Use c_ptr_safe() to ensure strings are \0 terminated. storage/maria/ha_maria.cc: Update usage of TABLE->alias storage/myisam/ha_myisam.cc: Update usage of TABLE->alias storage/xtradb/row/row0sel.c: Ensure that null bits in record are properly reset. (Old code didn't work as row_search_for_mysql() can be called twice while reading fields from one row.
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r--sql/sql_insert.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 3c2f90e8080..9477d2ca971 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -2074,6 +2074,7 @@ TABLE *Delayed_insert::get_local_table(THD* client_thd)
TABLE *copy;
TABLE_SHARE *share;
uchar *bitmap;
+ char *copy_tmp;
DBUG_ENTER("Delayed_insert::get_local_table");
/* First request insert thread to get a lock */
@@ -2106,14 +2107,15 @@ TABLE *Delayed_insert::get_local_table(THD* client_thd)
the other record buffers and alignment are unnecessary.
*/
thd_proc_info(client_thd, "allocating local table");
- copy= (TABLE*) client_thd->alloc(sizeof(*copy)+
- (share->fields+1)*sizeof(Field**)+
- share->reclength +
- share->column_bitmap_size*3);
- if (!copy)
+ copy_tmp= (char*) client_thd->alloc(sizeof(*copy)+
+ (share->fields+1)*sizeof(Field**)+
+ share->reclength +
+ share->column_bitmap_size*3);
+ if (!copy_tmp)
goto error;
/* Copy the TABLE object. */
+ copy= new (copy_tmp) TABLE;
*copy= *table;
/* We don't need to change the file handler here */
/* Assign the pointers for the field pointers array and the record. */
@@ -3502,7 +3504,7 @@ int select_create::write_to_binlog(bool is_trans, int errcode)
Avoid to use thd->binlog_query() twice, otherwise it will print the unsafe
warning twice.
*/
- Query_log_event ev(thd, query.c_ptr_safe(), query.length(), is_trans,
+ Query_log_event ev(thd, query.ptr(), query.length(), is_trans,
FALSE, errcode);
return mysql_bin_log.write(&ev);
}