mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
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
This commit is contained in:
@ -65,7 +65,7 @@ print_where(COND *cond,const char *info, enum_query_type query_type)
|
||||
str.append('\0');
|
||||
DBUG_LOCK_FILE;
|
||||
(void) fprintf(DBUG_FILE,"\nWHERE:(%s) ",info);
|
||||
(void) fputs(str.ptr(),DBUG_FILE);
|
||||
(void) fputs(str.c_ptr_safe(),DBUG_FILE);
|
||||
(void) fputc('\n',DBUG_FILE);
|
||||
DBUG_UNLOCK_FILE;
|
||||
}
|
||||
@ -157,7 +157,7 @@ void TEST_filesort(SORT_FIELD *sortorder,uint s_length)
|
||||
out.append('\0'); // Purify doesn't like c_ptr()
|
||||
DBUG_LOCK_FILE;
|
||||
VOID(fputs("\nInfo about FILESORT\n",DBUG_FILE));
|
||||
fprintf(DBUG_FILE,"Sortorder: %s\n",out.ptr());
|
||||
fprintf(DBUG_FILE,"Sortorder: %s\n",out.c_ptr_safe());
|
||||
DBUG_UNLOCK_FILE;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
@ -192,7 +192,7 @@ TEST_join(JOIN *join)
|
||||
TABLE *form=tab->table;
|
||||
char key_map_buff[128];
|
||||
fprintf(DBUG_FILE,"%-16.16s type: %-7s q_keys: %s refs: %d key: %d len: %d\n",
|
||||
form->alias,
|
||||
form->alias.c_ptr(),
|
||||
join_type_str[tab->type],
|
||||
tab->keys.print(key_map_buff),
|
||||
tab->ref.key_parts,
|
||||
@ -216,7 +216,7 @@ TEST_join(JOIN *join)
|
||||
if (tab->ref.key_parts)
|
||||
{
|
||||
fprintf(DBUG_FILE,
|
||||
" refs: %s\n", ref_key_parts[i].ptr());
|
||||
" refs: %s\n", ref_key_parts[i].c_ptr_safe());
|
||||
}
|
||||
}
|
||||
DBUG_UNLOCK_FILE;
|
||||
|
Reference in New Issue
Block a user