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.
This commit is contained in:
Michael Widenius 2010-11-24 00:08:48 +02:00
parent 0543e2e34e
commit 52090a4434
40 changed files with 206 additions and 156 deletions

View File

@ -212,7 +212,7 @@ mysql_event_fill_row(THD *thd,
Safety: this can only happen if someone started the server
and then altered mysql.event.
*/
my_error(ER_COL_COUNT_DOESNT_MATCH_CORRUPTED, MYF(0), table->alias,
my_error(ER_COL_COUNT_DOESNT_MATCH_CORRUPTED, MYF(0), table->alias.c_ptr(),
(int) ET_FIELD_COUNT, table->s->fields);
DBUG_RETURN(TRUE);
}

View File

@ -100,7 +100,7 @@ Event_worker_thread::print_warnings(THD *thd, Event_job_data *et)
err_msg.append(err->msg, strlen(err->msg), system_charset_info);
DBUG_ASSERT(err->level < 3);
(sql_print_message_handlers[err->level])("%*s", err_msg.length(),
err_msg.c_ptr());
err_msg.c_ptr_safe());
}
DBUG_VOID_RETURN;
}

View File

@ -480,7 +480,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data,
}
/* If the definer is not set or set to CURRENT_USER, the value of CURRENT_USER
will be written into the binary log as the definer for the SQL thread. */
ret= write_bin_log(thd, TRUE, log_query.c_ptr(), log_query.length());
ret= write_bin_log(thd, TRUE, log_query.ptr(), log_query.length());
}
}
pthread_mutex_unlock(&LOCK_event_metadata);
@ -779,7 +779,7 @@ send_show_create_event(THD *thd, Event_timed *et, Protocol *protocol)
protocol->store(et->name.str, et->name.length, system_charset_info);
protocol->store(sql_mode.str, sql_mode.length, system_charset_info);
protocol->store(tz_name->ptr(), tz_name->length(), system_charset_info);
protocol->store(show_str.c_ptr(), show_str.length(),
protocol->store(show_str.ptr(), show_str.length(),
et->creation_ctx->get_client_cs());
protocol->store(et->creation_ctx->get_client_cs()->csname,
strlen(et->creation_ctx->get_client_cs()->csname),

View File

@ -1536,9 +1536,9 @@ void Field::make_field(Send_field *field)
}
else
field->org_table_name= field->db_name= "";
if (orig_table && orig_table->alias)
if (orig_table && orig_table->alias.ptr())
{
field->table_name= orig_table->alias;
field->table_name= orig_table->alias.ptr();
field->org_col_name= field_name;
}
else

View File

@ -131,7 +131,8 @@ public:
*/
struct st_table *table; // Pointer for table
struct st_table *orig_table; // Pointer to original table
const char **table_name, *field_name;
const char * const *table_name;
const char *field_name;
/** reference to the list of options or NULL */
engine_option_value *option_list;
void *option_struct; /* structure with parsed options */
@ -551,10 +552,14 @@ public:
return (op_result == E_DEC_OVERFLOW);
}
int warn_if_overflow(int op_result);
void set_table_name(String *alias)
{
table_name= &alias->Ptr;
}
void init(TABLE *table_arg)
{
orig_table= table= table_arg;
table_name= &table_arg->alias;
set_table_name(&table_arg->alias);
}
/* maximum possible display length */

View File

@ -1097,7 +1097,8 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt,
error != HA_ADMIN_ALREADY_DONE &&
error != HA_ADMIN_TRY_ALTER)
{
print_admin_msg(thd, "error", table_share->db.str, table->alias,
print_admin_msg(thd, "error", table_share->db.str,
table->alias.c_ptr(),
opt_op_name[flag],
"Subpartition %s returned error",
sub_elem->partition_name);
@ -1124,7 +1125,8 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt,
error != HA_ADMIN_ALREADY_DONE &&
error != HA_ADMIN_TRY_ALTER)
{
print_admin_msg(thd, "error", table_share->db.str, table->alias,
print_admin_msg(thd, "error", table_share->db.str,
table->alias.c_ptr(),
opt_op_name[flag], "Partition %s returned error",
part_elem->partition_name);
}

View File

@ -2009,7 +2009,8 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path,
dummy_share.db.length= strlen(db);
dummy_share.table_name.str= (char*) alias;
dummy_share.table_name.length= strlen(alias);
dummy_table.alias= alias;
dummy_table.alias.set(alias, dummy_share.table_name.length,
table_alias_charset);
file->change_table_ptr(&dummy_table, &dummy_share);
@ -2852,11 +2853,12 @@ void handler::print_error(int error, myf errflag)
{
const char* engine= table_type();
if (temporary)
my_error(ER_GET_TEMPORARY_ERRMSG, MYF(0), error, str.ptr(), engine);
my_error(ER_GET_TEMPORARY_ERRMSG, MYF(0), error, str.c_ptr(),
engine);
else
{
SET_FATAL_ERROR;
my_error(ER_GET_ERRMSG, MYF(0), error, str.ptr(), engine);
my_error(ER_GET_ERRMSG, MYF(0), error, str.c_ptr(), engine);
}
}
else

View File

@ -781,7 +781,8 @@ void Item::set_name(const char *str, uint length, CHARSET_INFO *cs)
}
if (cs->ctype)
{
uint orig_len= length;
const char *str_start= str;
/*
This will probably need a better implementation in the future:
a function in CHARSET_INFO structure.
@ -791,16 +792,20 @@ void Item::set_name(const char *str, uint length, CHARSET_INFO *cs)
length--;
str++;
}
if (orig_len != length && !is_autogenerated_name)
if (str != str_start && !is_autogenerated_name)
{
char buff[SAFE_NAME_LEN];
strmake(buff, str_start,
min(sizeof(buff)-1, length + (int) (str-str_start)));
if (length == 0)
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_NAME_BECOMES_EMPTY, ER(ER_NAME_BECOMES_EMPTY),
str + length - orig_len);
buff);
else
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_REMOVED_SPACES, ER(ER_REMOVED_SPACES),
str + length - orig_len);
buff);
}
}
if (!my_charset_same(cs, system_charset_info))
@ -2566,14 +2571,12 @@ double_from_string_with_check (CHARSET_INFO *cs, const char *cptr, char *end)
tmp= my_strntod(cs, (char*) cptr, end - cptr, &end, &error);
if (error || (end != org_end && !check_if_only_end_space(cs, end, org_end)))
{
/*
We can use str_value.ptr() here as Item_string is gurantee to put an
end \0 here.
*/
char buff[80];
strmake(buff, cptr, min(sizeof(buff)-1, (size_t) (org_end-cptr)));
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_TRUNCATED_WRONG_VALUE,
ER(ER_TRUNCATED_WRONG_VALUE), "DOUBLE",
cptr);
buff);
}
return tmp;
}
@ -2582,8 +2585,10 @@ double_from_string_with_check (CHARSET_INFO *cs, const char *cptr, char *end)
double Item_string::val_real()
{
DBUG_ASSERT(fixed == 1);
return double_from_string_with_check (str_value.charset(), str_value.ptr(),
(char *) str_value.ptr() + str_value.length());
return double_from_string_with_check(str_value.charset(),
str_value.ptr(),
(char *) str_value.ptr() +
str_value.length());
}

View File

@ -5812,7 +5812,7 @@ Item_func_sp::func_name() const
qname.append('.');
}
append_identifier(thd, &qname, m_name->m_name.str, m_name->m_name.length);
return qname.ptr();
return qname.c_ptr_safe();
}
@ -5868,7 +5868,7 @@ Item_func_sp::init_result_field(THD *thd)
*/
share= dummy_table->s;
dummy_table->alias = "";
dummy_table->alias.set("", 0, table_alias_charset);
dummy_table->maybe_null = maybe_null;
dummy_table->in_use= thd;
dummy_table->copy_blobs= TRUE;

View File

@ -1274,8 +1274,13 @@ public:
void make_unique();
double val_real()
{
String *res; res=val_str(&str_value);
return res ? my_atof(res->c_ptr()) : 0.0;
int error;
const char *end;
String *res;
if (!(res= val_str(&str_value)))
return 0.0;
end= res->ptr() + res->length();
return (my_strtod(res->ptr(), (char**) &end, &error));
}
longlong val_int()
{

View File

@ -903,7 +903,7 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count,
*write_lock_used=table;
if (table->db_stat & HA_READ_ONLY)
{
my_error(ER_OPEN_AS_READONLY,MYF(0),table->alias);
my_error(ER_OPEN_AS_READONLY,MYF(0),table->alias.c_ptr());
/* Clear the lock type of the lock data that are stored already. */
sql_lock->lock_count= (uint) (locks - sql_lock->locks);
reset_lock_data(sql_lock);

View File

@ -1751,7 +1751,7 @@ static int binlog_savepoint_set(handlerton *hton, THD *thd, void *sv)
log_query.append(thd->lex->ident.str, thd->lex->ident.length))
DBUG_RETURN(1);
int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);
Query_log_event qinfo(thd, log_query.c_ptr_safe(), log_query.length(),
Query_log_event qinfo(thd, log_query.ptr(), log_query.length(),
TRUE, TRUE, errcode);
DBUG_RETURN(mysql_bin_log.write(&qinfo));
}
@ -1773,7 +1773,7 @@ static int binlog_savepoint_rollback(handlerton *hton, THD *thd, void *sv)
log_query.append(thd->lex->ident.str, thd->lex->ident.length))
DBUG_RETURN(1);
int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);
Query_log_event qinfo(thd, log_query.c_ptr_safe(), log_query.length(),
Query_log_event qinfo(thd, log_query.ptr(), log_query.length(),
TRUE, TRUE, errcode);
DBUG_RETURN(mysql_bin_log.write(&qinfo));
}

View File

@ -568,7 +568,7 @@ append_query_string(CHARSET_INFO *csinfo,
if (to->reserve(orig_len + from->length()*2+3))
return 1;
beg= to->c_ptr_quick() + to->length();
beg= (char*) to->ptr() + to->length();
ptr= beg;
if (csinfo->escape_with_backslash_is_dangerous)
ptr= str_to_hex(ptr, from->ptr(), from->length());

View File

@ -11130,7 +11130,8 @@ static void print_sel_tree(PARAM *param, SEL_TREE *tree, key_map *tree_map,
if (!tmp.length())
tmp.append(STRING_WITH_LEN("(empty)"));
DBUG_PRINT("info", ("SEL_TREE: 0x%lx (%s) scans: %s", (long) tree, msg, tmp.ptr()));
DBUG_PRINT("info", ("SEL_TREE: 0x%lx (%s) scans: %s", (long) tree, msg,
tmp.c_ptr()));
DBUG_VOID_RETURN;
}
@ -11153,7 +11154,7 @@ static void print_ror_scans_arr(TABLE *table, const char *msg,
}
if (!tmp.length())
tmp.append(STRING_WITH_LEN("(empty)"));
DBUG_PRINT("info", ("ROR key scans (%s): %s", msg, tmp.ptr()));
DBUG_PRINT("info", ("ROR key scans (%s): %s", msg, tmp.c_ptr()));
DBUG_VOID_RETURN;
}

View File

@ -1030,7 +1030,7 @@ int pull_out_semijoin_tables(JOIN *join)
pulled_a_table= TRUE;
pulled_tables |= tbl->table->map;
DBUG_PRINT("info", ("Table %s pulled out (reason: func dep)",
tbl->table->alias));
tbl->table->alias.c_ptr()));
/*
Pulling a table out of uncorrelated subquery in general makes
makes it correlated. See the NOTE to this funtion.
@ -2605,7 +2605,8 @@ TABLE *create_duplicate_weedout_tmp_table(THD *thd,
thd->mem_root= &table->mem_root;
table->field=reg_field;
table->alias= "weedout-tmp";
table->alias.set("weedout-tmp", sizeof("weedout-tmp")-1,
table_alias_charset);
table->reginfo.lock_type=TL_WRITE; /* Will be updated */
table->db_stat=HA_OPEN_KEYFILE+HA_OPEN_RNDFILE;
table->map=1;
@ -2737,7 +2738,7 @@ TABLE *create_duplicate_weedout_tmp_table(THD *thd,
else
recinfo->type=FIELD_NORMAL;
field->table_name= &table->alias;
field->set_table_name(&table->alias);
}
//param->recinfo=recinfo;

View File

@ -1783,7 +1783,7 @@ static void mark_as_eliminated(JOIN *join, TABLE_LIST *tbl)
JOIN_TAB *tab= tbl->table->reginfo.join_tab;
if (!(join->const_table_map & tab->table->map))
{
DBUG_PRINT("info", ("Eliminated table %s", table->alias));
DBUG_PRINT("info", ("Eliminated table %s", table->alias.c_ptr()));
tab->type= JT_CONST;
join->eliminated_tables |= table->map;
join->const_table_map|= table->map;
@ -1818,7 +1818,7 @@ void Dep_analysis_context::dbug_print_deps()
fprintf(DBUG_FILE, " equality%ld: %s -> %s.%s\n",
(long)(eq_mod - equality_mods),
str.c_ptr(),
eq_mod->field->table->table->alias,
eq_mod->field->table->table->alias.c_ptr(),
eq_mod->field->field->field_name);
}
else
@ -1836,12 +1836,13 @@ void Dep_analysis_context::dbug_print_deps()
if ((table_dep= table_deps[i]))
{
/* Print table */
fprintf(DBUG_FILE, " table %s\n", table_dep->table->alias);
fprintf(DBUG_FILE, " table %s\n", table_dep->table->alias.c_ptr());
/* Print fields */
for (Dep_value_field *field_dep= table_dep->fields; field_dep;
field_dep= field_dep->next_table_field)
{
fprintf(DBUG_FILE, " field %s.%s ->", table_dep->table->alias,
fprintf(DBUG_FILE, " field %s.%s ->",
table_dep->table->alias.c_ptr(),
field_dep->field->field_name);
uint ofs= field_dep->bitmap_offset;
for (uint bit= ofs; bit < ofs + n_equality_mods; bit++)

View File

@ -990,7 +990,7 @@ bool sys_var_str::check(THD *thd, set_var *var)
if ((res=(*check_func)(thd, var)) < 0)
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0),
name, var->value->str_value.ptr());
name, var->value->str_value.c_ptr());
return res;
}
@ -2281,11 +2281,15 @@ bool sys_var_character_set::check(THD *thd, set_var *var)
}
tmp= NULL;
}
else if (!(tmp=get_charset_by_csname(res->c_ptr(),MY_CS_PRIMARY,MYF(0))) &&
!(tmp=get_old_charset_by_name(res->c_ptr())))
else
{
my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), res->c_ptr());
return 1;
const char *name= res->c_ptr_safe();
if (!(tmp=get_charset_by_csname(name,MY_CS_PRIMARY,MYF(0))) &&
!(tmp=get_old_charset_by_name(name)))
{
my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), res->c_ptr());
return 1;
}
}
}
else // INT_RESULT
@ -2622,7 +2626,7 @@ static int sys_check_log_path(THD *thd, set_var *var)
if (!(res= var->value->val_str(&str)))
goto err;
log_file_str= res->c_ptr();
log_file_str= res->c_ptr_safe();
bzero(&f_stat, sizeof(MY_STAT));
path_length= unpack_filename(path, log_file_str);
@ -3085,7 +3089,7 @@ bool sys_var_thd_lc_time_names::check(THD *thd, set_var *var)
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL");
return 1;
}
const char *locale_str= res->c_ptr();
const char *locale_str= res->c_ptr_safe();
if (!(locale_match= my_locale_by_name(locale_str)))
{
my_printf_error(ER_UNKNOWN_ERROR,
@ -4117,7 +4121,7 @@ bool sys_var_thd_optimizer_switch::check(THD *thd, set_var *var)
optimizer_switch_typelib.count,
thd->variables.optimizer_switch,
global_system_variables.optimizer_switch,
res->c_ptr_safe(), res->length(), NULL,
res->ptr(), res->length(), NULL,
&error, &error_len, &not_used);
if (error_len)
{

View File

@ -1104,7 +1104,7 @@ sp_create_routine(THD *thd, int type, sp_head *sp)
(sp->m_explicit_name ? sp->m_db.length : 0),
sp->m_name.str, sp->m_name.length,
sp->m_params.str, sp->m_params.length,
retstr.c_ptr(), retstr.length(),
retstr.ptr(), retstr.length(),
sp->m_body.str, sp->m_body.length,
sp->m_chistics, &(thd->lex->definer->user),
&(thd->lex->definer->host)))
@ -1116,7 +1116,7 @@ sp_create_routine(THD *thd, int type, sp_head *sp)
thd->variables.sql_mode= saved_mode;
/* Such a statement can always go directly to binlog, no trans cache */
if (thd->binlog_query(THD::MYSQL_QUERY_TYPE,
log_query.c_ptr(), log_query.length(),
log_query.ptr(), log_query.length(),
FALSE, FALSE, 0))
ret= SP_INTERNAL_ERROR;
thd->variables.sql_mode= 0;

View File

@ -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;
}

View File

@ -1474,12 +1474,11 @@ void close_temporary_tables(THD *thd)
/* Better add "if exists", in case a RESET MASTER has been done */
const char stub[]= "DROP /*!40005 TEMPORARY */ TABLE IF EXISTS ";
uint stub_len= sizeof(stub) - 1;
char buf[256];
String s_query= String(buf, sizeof(buf), system_charset_info);
char buf[FN_REFLEN];
String s_query(buf, sizeof(buf), system_charset_info);
bool found_user_tables= FALSE;
memcpy(buf, stub, stub_len);
s_query.copy(stub, sizeof(stub)-1, system_charset_info);
/*
Insertion sort of temp tables by pseudo_thread_id to build ordered list
@ -1533,19 +1532,24 @@ void close_temporary_tables(THD *thd)
{
bool save_thread_specific_used= thd->thread_specific_used;
my_thread_id save_pseudo_thread_id= thd->variables.pseudo_thread_id;
char db_buf[FN_REFLEN];
String db(db_buf, sizeof(db_buf), system_charset_info);
/* Set pseudo_thread_id to be that of the processed table */
thd->variables.pseudo_thread_id= tmpkeyval(thd, table);
String db;
db.append(table->s->db.str);
db.copy(table->s->db.str, table->s->db.length, system_charset_info);
s_query.length(sizeof(stub)-1);
/* Loop forward through all tables that belong to a common database
within the sublist of common pseudo_thread_id to create single
DROP query
*/
for (s_query.length(stub_len);
for (;
table && is_user_table(table) &&
tmpkeyval(thd, table) == thd->variables.pseudo_thread_id &&
table->s->db.length == db.length() &&
strcmp(table->s->db.str, db.ptr()) == 0;
memcmp(table->s->db.str, db.ptr(), db.length()) == 0;
table= next)
{
/*
@ -1849,7 +1853,7 @@ int drop_temporary_table(THD *thd, TABLE_LIST *table_list)
/* Table might be in use by some outer statement. */
if (table->query_id && table->query_id != thd->query_id)
{
my_error(ER_CANT_REOPEN_TABLE, MYF(0), table->alias);
my_error(ER_CANT_REOPEN_TABLE, MYF(0), table->alias.c_ptr());
DBUG_RETURN(-1);
}
@ -1872,7 +1876,7 @@ void close_temporary_table(THD *thd, TABLE *table,
DBUG_ENTER("close_temporary_table");
DBUG_PRINT("tmptable", ("closing table: '%s'.'%s' 0x%lx alias: '%s'",
table->s->db.str, table->s->table_name.str,
(long) table, table->alias));
(long) table, table->alias.c_ptr()));
/*
When closing a MERGE parent or child table, detach the children
@ -2606,7 +2610,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
("query_id: %lu server_id: %u pseudo_thread_id: %lu",
(ulong) table->query_id, (uint) thd->server_id,
(ulong) thd->variables.pseudo_thread_id));
my_error(ER_CANT_REOPEN_TABLE, MYF(0), table->alias);
my_error(ER_CANT_REOPEN_TABLE, MYF(0), table->alias.c_ptr());
DBUG_RETURN(0);
}
table->query_id= thd->query_id;
@ -2643,7 +2647,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
When looking for a usable TABLE, ignore MERGE children, as they
belong to their parent and cannot be used explicitly.
*/
if (!my_strcasecmp(system_charset_info, table->alias, alias) &&
if (!my_strcasecmp(system_charset_info, table->alias.c_ptr(), alias) &&
table->query_id != thd->query_id && /* skip tables already used */
!(thd->prelocked_mode && table->query_id) &&
!table->parent)
@ -2999,13 +3003,9 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
table->alias_name_used= my_strcasecmp(table_alias_charset,
table->s->table_name.str, alias);
/* Fix alias if table name changes */
if (strcmp(table->alias, alias))
{
uint length=(uint) strlen(alias)+1;
table->alias= (char*) my_realloc((char*) table->alias, length,
MYF(MY_WME));
memcpy((char*) table->alias, alias, length);
}
if (strcmp(table->alias.c_ptr(), alias))
table->alias.copy(alias, strlen(alias), table->alias.charset());
/* These variables are also set in reopen_table() */
table->tablenr=thd->current_tablenr++;
table->used_fields=0;
@ -3089,7 +3089,7 @@ bool reopen_table(TABLE *table)
#ifdef EXTRA_DEBUG
if (table->db_stat)
sql_print_error("Table %s had a open data handler in reopen_table",
table->alias);
table->alias.c_ptr());
#endif
bzero((char*) &table_list, sizeof(TABLE_LIST));
table_list.db= table->s->db.str;
@ -3100,7 +3100,7 @@ bool reopen_table(TABLE *table)
DBUG_RETURN(1); // Thread was killed
if (open_unireg_entry(thd, &tmp, &table_list,
table->alias,
table->alias.c_ptr(),
table->s->table_cache_key.str,
table->s->table_cache_key.length,
thd->mem_root, 0))
@ -3141,14 +3141,14 @@ bool reopen_table(TABLE *table)
VOID(closefrm(table, 1)); // close file, free everything
*table= tmp;
table->alias.move(tmp.alias);
table->default_column_bitmaps();
table->file->change_table_ptr(table, table->s);
DBUG_ASSERT(table->alias != 0);
DBUG_ASSERT(table->alias.ptr() != 0);
for (field=table->field ; *field ; field++)
{
(*field)->table= (*field)->orig_table= table;
(*field)->table_name= &table->alias;
(*field)->init(table);
}
for (key=0 ; key < table->s->keys ; key++)
{
@ -3275,7 +3275,7 @@ static bool reattach_merge(THD *thd, TABLE **err_tables_p)
DBUG_PRINT("tcache", ("MERGE parent, attach children"));
if(table->file->extra(HA_EXTRA_ATTACH_CHILDREN))
{
my_error(ER_CANT_REOPEN_TABLE, MYF(0), table->alias);
my_error(ER_CANT_REOPEN_TABLE, MYF(0), table->alias.c_ptr());
error= TRUE;
/* Remove table from open_tables. */
*prv_p= next;
@ -3368,7 +3368,8 @@ bool reopen_tables(THD *thd, bool get_locks, bool mark_share_as_old)
if (!tables || (!db_stat && reopen_table(table)))
{
my_error(ER_CANT_REOPEN_TABLE, MYF(0),
table->alias ? table->alias : table->s->table_name.str);
table->alias.ptr() ? table->alias.c_ptr() :
table->s->table_name.str);
/*
If we could not allocate 'tables', we may close open tables
here. If a MERGE table is affected, detach the children first.
@ -3565,7 +3566,8 @@ bool table_is_used(TABLE *table, bool wait_for_name_lock)
char *key= table->s->table_cache_key.str;
uint key_length= table->s->table_cache_key.length;
DBUG_PRINT("loop", ("table_name: %s", table->alias ? table->alias : ""));
DBUG_PRINT("loop", ("table_name: %s",
table->alias.ptr() ? table->alias.c_ptr() : ""));
HASH_SEARCH_STATE state;
for (TABLE *search= (TABLE*) hash_first(&open_cache, (uchar*) key,
key_length, &state);
@ -4359,7 +4361,7 @@ void detach_merge_children(TABLE *table, bool clear_refs)
Set alias to "" to ensure that table is not used if we are in
LOCK TABLES
*/
((char*) child_l->table->alias)[0]= 0;
child_l->table->alias.copy("", 0, child_l->table->alias.charset());
/* Clear the table reference to force new assignment at next open. */
child_l->table= NULL;
@ -4912,7 +4914,7 @@ static bool check_lock_and_start_stmt(THD *thd, TABLE *table,
if ((int) lock_type >= (int) TL_WRITE_ALLOW_READ &&
(int) table->reginfo.lock_type < (int) TL_WRITE_ALLOW_READ)
{
my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE, MYF(0),table->alias);
my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE, MYF(0),table->alias.c_ptr());
DBUG_RETURN(1);
}
if ((error=table->file->start_stmt(thd, lock_type)))
@ -6024,7 +6026,8 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, uint length,
Field **field_ptr, *field;
uint cached_field_index= *cached_field_index_ptr;
DBUG_ENTER("find_field_in_table");
DBUG_PRINT("enter", ("table: '%s', field name: '%s'", table->alias, name));
DBUG_PRINT("enter", ("table: '%s', field name: '%s'", table->alias.c_ptr(),
name));
/* We assume here that table->field < NO_CACHED_FIELD_INDEX = UINT_MAX */
if (cached_field_index < table->s->fields &&

View File

@ -4115,8 +4115,8 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
int errcode)
{
DBUG_ENTER("THD::binlog_query");
DBUG_PRINT("enter", ("qtype: %s query: '%s'",
show_query_type(qtype), query_arg));
DBUG_PRINT("enter", ("qtype: %s query: '%-.*s'",
show_query_type(qtype), (int) query_len, query_arg));
DBUG_ASSERT(query_arg && mysql_bin_log.is_open());
/*
@ -4152,7 +4152,7 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
{
sql_print_warning("%s Statement: %.*s",
ER(ER_BINLOG_UNSAFE_STATEMENT),
MYSQL_ERRMSG_SIZE, query_arg);
(int) min(MYSQL_ERRMSG_SIZE, query_len), query_arg);
binlog_flags|= BINLOG_FLAG_UNSAFE_STMT_PRINTED;
}
}

View File

@ -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);
}

View File

@ -604,11 +604,15 @@ static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex,
size_t pl= 0;
List<Item> fv;
Item *item, *val;
String pfield, pfields;
int n;
const char *tbl= table_name_arg;
const char *tdb= (thd->db != NULL ? thd->db : db_arg);
String string_buf;
char name_buffer[SAFE_NAME_LEN*2];
char command_buffer[1024];
String string_buf(name_buffer, sizeof(name_buffer),
system_charset_info);
String pfields(command_buffer, sizeof(command_buffer),
system_charset_info);
if (!thd->db || strcmp(db_arg, thd->db))
{
@ -617,7 +621,7 @@ static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex,
prefix table name with database name so that it
becomes a FQ name.
*/
string_buf.set_charset(system_charset_info);
string_buf.length(0);
string_buf.append(db_arg);
string_buf.append("`");
string_buf.append(".");
@ -638,6 +642,7 @@ static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex,
/*
prepare fields-list and SET if needed; print_query won't do that for us.
*/
pfields.length(0);
if (!thd->lex->field_list.is_empty())
{
List_iterator<Item> li(thd->lex->field_list);
@ -682,8 +687,8 @@ static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex,
}
}
p= pfields.c_ptr_safe();
pl= strlen(p);
p= pfields.c_ptr_safe();
pl= pfields.length();
if (!(load_data_query= (char *)thd->alloc(lle.get_query_buffer_length() + 1 + pl)))
return TRUE;

View File

@ -5084,9 +5084,8 @@ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables)
String str(buff,(uint32) sizeof(buff), system_charset_info);
str.length(0);
thd->lex->unit.print(&str, QT_ORDINARY);
str.append('\0');
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_YES, str.ptr());
ER_YES, str.c_ptr_safe());
}
if (res)
result->abort();

View File

@ -303,7 +303,7 @@ static const char *item_val_str(struct st_mysql_value *value,
Lets be nice and create a temporary string since the
buffer was too small
*/
return current_thd->strmake(res->c_ptr_quick(), res->length());
return current_thd->strmake(res->ptr(), res->length());
}

View File

@ -6477,7 +6477,7 @@ static void add_not_null_conds(JOIN *join)
if (notnull->fix_fields(join->thd, &notnull))
DBUG_VOID_RETURN;
DBUG_EXECUTE("where",print_where(notnull,
referred_tab->table->alias,
referred_tab->table->alias.c_ptr(),
QT_ORDINARY););
COND *new_cond= referred_tab->select_cond;
add_cond_and_fix(&new_cond, notnull);
@ -6786,7 +6786,9 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
if (tmp || !cond || tab->type == JT_REF || tab->type == JT_REF_OR_NULL ||
tab->type == JT_EQ_REF || first_inner_tab)
{
DBUG_EXECUTE("where",print_where(tmp,tab->table->alias, QT_ORDINARY););
DBUG_EXECUTE("where",
print_where(tmp,tab->table->alias.c_ptr(),
QT_ORDINARY););
SQL_SELECT *sel= tab->select= ((SQL_SELECT*)
thd->memdup((uchar*) select,
sizeof(*select)));
@ -6830,7 +6832,9 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
}
sel->head=tab->table;
DBUG_EXECUTE("where",print_where(tmp,tab->table->alias, QT_ORDINARY););
DBUG_EXECUTE("where",
print_where(tmp,tab->table->alias.c_ptr(),
QT_ORDINARY););
if (tab->quick)
{
/* Use quick key read if it's a constant and it's not used
@ -11289,7 +11293,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
thd->mem_root= &table->mem_root;
table->field=reg_field;
table->alias= table_alias;
table->alias.set(table_alias, strlen(table_alias), table_alias_charset);
table->reginfo.lock_type=TL_WRITE; /* Will be updated */
table->db_stat=HA_OPEN_KEYFILE+HA_OPEN_RNDFILE;
table->map=1;
@ -11665,7 +11670,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
null_count=(null_count+7) & ~7; // move to next byte
// fix table name in field entry
field->table_name= &table->alias;
field->set_table_name(&table->alias);
}
param->copy_field_end=copy;
@ -12482,7 +12487,7 @@ free_tmp_table(THD *thd, TABLE *entry)
MEM_ROOT own_root= entry->mem_root;
const char *save_proc_info;
DBUG_ENTER("free_tmp_table");
DBUG_PRINT("enter",("table: %s",entry->alias));
DBUG_PRINT("enter",("table: %s",entry->alias.c_ptr()));
save_proc_info=thd->proc_info;
thd_proc_info(thd, "removing tmp table");

View File

@ -816,7 +816,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
protocol->store(table_list->schema_table->table_name,
system_charset_info);
else
protocol->store(table_list->table->alias, system_charset_info);
protocol->store(table_list->table->alias.c_ptr(), system_charset_info);
}
if (table_list->view)
@ -1305,7 +1305,7 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
else
{
if (lower_case_table_names == 2)
alias= table->alias;
alias= table->alias.c_ptr();
else
{
alias= share->table_name.str;
@ -5662,7 +5662,7 @@ copy_event_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table)
if (et.load_from_row(thd, event_table))
{
my_error(ER_CANNOT_LOAD_FROM_TABLE, MYF(0), event_table->alias);
my_error(ER_CANNOT_LOAD_FROM_TABLE, MYF(0), event_table->alias.c_ptr());
DBUG_RETURN(1);
}

View File

@ -274,6 +274,14 @@ public:
bool set_or_copy_aligned(const char *s, uint32 arg_length, CHARSET_INFO *cs);
bool copy(const char*s,uint32 arg_length, CHARSET_INFO *csfrom,
CHARSET_INFO *csto, uint *errors);
void move(String &s)
{
free();
Ptr=s.Ptr ; str_length=s.str_length ; Alloced_length=s.Alloced_length;
extra_alloc= s.extra_alloc;
alloced= s.alloced;
s.alloced= 0;
}
bool append(const String &s);
bool append(const char *s);
bool append(const char *s,uint32 arg_length);
@ -304,6 +312,7 @@ public:
friend int sortcmp(const String *a,const String *b, CHARSET_INFO *cs);
friend int stringcmp(const String *a,const String *b);
friend String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
friend class Field;
uint32 numchars();
int charpos(int i,uint32 offset=0);

View File

@ -2113,7 +2113,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
{
if (!foreign_key_error)
my_printf_error(ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR), MYF(0),
wrong_tables.c_ptr());
wrong_tables.c_ptr_safe());
else
my_message(ER_ROW_IS_REFERENCED, ER(ER_ROW_IS_REFERENCED), MYF(0));
error= 1;
@ -6955,7 +6955,7 @@ view_err:
error= 0;
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA),
table->alias);
table->alias.c_ptr());
}
VOID(pthread_mutex_lock(&LOCK_open));
@ -7023,7 +7023,7 @@ view_err:
error= 0;
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA),
table->alias);
table->alias.c_ptr());
}
if (!error)

View File

@ -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;

View File

@ -802,7 +802,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables,
stmt_query->append(stmt_definition.str, stmt_definition.length);
trg_def->str= stmt_query->c_ptr();
trg_def->str= stmt_query->c_ptr_safe();
trg_def->length= stmt_query->length();
/* Create trigger definition file. */
@ -1039,10 +1039,7 @@ void Table_triggers_list::set_table(TABLE *new_table)
{
trigger_table= new_table;
for (Field **field= new_table->triggers->record1_field ; *field ; field++)
{
(*field)->table= (*field)->orig_table= new_table;
(*field)->table_name= &new_table->alias;
}
(*field)->init(new_table);
}

View File

@ -1602,7 +1602,8 @@ loop_end:
do
{
Field_string *field= new Field_string(tbl->file->ref_length, 0,
tbl->alias, &my_charset_bin);
tbl->alias.c_ptr(),
&my_charset_bin);
if (!field)
DBUG_RETURN(1);
field->init(tbl);

View File

@ -848,7 +848,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
thd->variables.sql_mode|= sql_mode;
}
DBUG_PRINT("info", ("View: %s", view_query.ptr()));
DBUG_PRINT("info", ("View: %s", view_query.c_ptr_safe()));
/* fill structure */
view->source= thd->lex->create_view_select;
@ -1675,7 +1675,7 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
}
if (non_existant_views.length())
{
my_error(ER_BAD_TABLE_ERROR, MYF(0), non_existant_views.c_ptr());
my_error(ER_BAD_TABLE_ERROR, MYF(0), non_existant_views.c_ptr_safe());
}
something_wrong= error || wrong_object_name || non_existant_views.length();

View File

@ -13111,7 +13111,7 @@ column_list_id:
while ((point=iter++))
{
if (!my_strcasecmp(system_charset_info,
point->column.ptr(), new_str->ptr()))
point->column.c_ptr(), new_str->c_ptr()))
break;
}
lex->grant_tot_col|= lex->which_columns;

View File

@ -2085,7 +2085,7 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
init_sql_alloc(&outparam->mem_root, TABLE_ALLOC_BLOCK_SIZE, 0);
if (!(outparam->alias= my_strdup(alias, MYF(MY_WME))))
if (outparam->alias.copy(alias, strlen(alias), table_alias_charset))
goto err;
outparam->quick_keys.init();
outparam->covering_keys.init();
@ -2422,7 +2422,7 @@ partititon_err:
outparam->db_stat=0;
thd->lex->view_prepare_mode= save_view_prepare_mode;
free_root(&outparam->mem_root, MYF(0)); // Safe to call on bzero'd root
my_free((char*) outparam->alias, MYF(MY_ALLOW_ZERO_PTR));
outparam->alias.free();
DBUG_RETURN (error);
}
@ -2448,8 +2448,7 @@ int closefrm(register TABLE *table, bool free_share)
table->file->extra(HA_EXTRA_PREPARE_FOR_DROP);
error=table->file->close();
}
my_free((char*) table->alias, MYF(MY_ALLOW_ZERO_PTR));
table->alias= 0;
table->alias.free();
if (table->expr_arena)
table->expr_arena->free_items();
if (table->field)
@ -3286,7 +3285,7 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def)
const TABLE_FIELD_TYPE *field_def= table_def->field;
DBUG_ENTER("table_check_intact");
DBUG_PRINT("info",("table: %s expected_count: %d",
table->alias, table_def->count));
table->alias.c_ptr(), table_def->count));
/* Whether the table definition has already been validated. */
if (table->s->table_field_def_cache == table_def)
@ -3301,14 +3300,15 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def)
{
report_error(ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE,
ER(ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE),
table->alias, table_def->count, table->s->fields,
table->alias.c_ptr(), table_def->count, table->s->fields,
table->s->mysql_version, MYSQL_VERSION_ID);
DBUG_RETURN(TRUE);
}
else if (MYSQL_VERSION_ID == table->s->mysql_version)
{
report_error(ER_COL_COUNT_DOESNT_MATCH_CORRUPTED,
ER(ER_COL_COUNT_DOESNT_MATCH_CORRUPTED), table->alias,
ER(ER_COL_COUNT_DOESNT_MATCH_CORRUPTED),
table->alias.c_ptr(),
table_def->count, table->s->fields);
DBUG_RETURN(TRUE);
}
@ -3341,7 +3341,8 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def)
*/
report_error(0, "Incorrect definition of table %s.%s: "
"expected column '%s' at position %d, found '%s'.",
table->s->db.str, table->alias, field_def->name.str, i,
table->s->db.str, table->alias.c_ptr(),
field_def->name.str, i,
field->field_name);
}
field->sql_type(sql_type);
@ -3367,7 +3368,8 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def)
{
report_error(0, "Incorrect definition of table %s.%s: "
"expected column '%s' at position %d to have type "
"%s, found type %s.", table->s->db.str, table->alias,
"%s, found type %s.", table->s->db.str,
table->alias.c_ptr(),
field_def->name.str, i, field_def->type.str,
sql_type.c_ptr_safe());
error= TRUE;
@ -3377,7 +3379,8 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def)
report_error(0, "Incorrect definition of table %s.%s: "
"expected the type of column '%s' at position %d "
"to have character set '%s' but the type has no "
"character set.", table->s->db.str, table->alias,
"character set.", table->s->db.str,
table->alias.c_ptr(),
field_def->name.str, i, field_def->cset.str);
error= TRUE;
}
@ -3387,7 +3390,8 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def)
report_error(0, "Incorrect definition of table %s.%s: "
"expected the type of column '%s' at position %d "
"to have character set '%s' but found "
"character set '%s'.", table->s->db.str, table->alias,
"character set '%s'.", table->s->db.str,
table->alias.c_ptr(),
field_def->name.str, i, field_def->cset.str,
field->charset()->csname);
error= TRUE;
@ -3398,7 +3402,7 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def)
report_error(0, "Incorrect definition of table %s.%s: "
"expected column '%s' at position %d to have type %s "
" but the column is not found.",
table->s->db.str, table->alias,
table->s->db.str, table->alias.c_ptr(),
field_def->name.str, i, field_def->type.str);
error= TRUE;
}

View File

@ -720,7 +720,7 @@ struct st_table {
Table_triggers_list *triggers;
TABLE_LIST *pos_in_table_list;/* Element referring to this table */
ORDER *group;
const char *alias; /* alias or table name */
String alias; /* alias or table name */
uchar *null_flags;
my_bitmap_map *bitmap_init_value;
MY_BITMAP def_read_set, def_write_set, def_vcol_set, tmp_set;

View File

@ -1453,7 +1453,8 @@ static void fill_server(MEM_ROOT *mem_root, FEDERATEDX_SERVER *server,
key.q_append('\0');
server->password= (const char *) (intptr) key.length();
key.append(password);
key.c_ptr_safe(); // Ensure we have end \0
server->key_length= key.length();
server->key= (uchar *) memdup_root(mem_root, key.ptr(), key.length()+1);
@ -1583,7 +1584,7 @@ static FEDERATEDX_SHARE *get_share(const char *table_name, TABLE *table)
tmp_share.table_name_length, ident_quote_char);
if (!(share= (FEDERATEDX_SHARE *) memdup_root(&mem_root, (char*)&tmp_share, sizeof(*share))) ||
!(share->select_query= (char*) strmake_root(&mem_root, query.ptr(), query.length() + 1)))
!(share->select_query= (char*) strmake_root(&mem_root, query.ptr(), query.length())))
goto error;
share->mem_root= mem_root;
@ -3435,11 +3436,13 @@ bool ha_federatedx::get_error_message(int error, String* buf)
buf->qs_append(remote_error_number);
buf->append(STRING_WITH_LEN(": "));
buf->append(remote_error_buf);
/* Ensure string ends with \0 */
(void) buf->c_ptr_safe();
remote_error_number= 0;
remote_error_buf[0]= '\0';
}
DBUG_PRINT("exit", ("message: %s", buf->ptr()));
DBUG_PRINT("exit", ("message: %s", buf->c_ptr_safe()));
DBUG_RETURN(FALSE);
}

View File

@ -1095,7 +1095,7 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt)
param.thd= thd;
param.op_name= "check";
param.db_name= table->s->db.str;
param.table_name= table->alias;
param.table_name= table->alias.c_ptr();
param.testflag= check_opt->flags | T_CHECK | T_SILENT;
param.stats_method= (enum_handler_stats_method)THDVAR(thd,stats_method);
@ -1194,7 +1194,7 @@ int ha_maria::analyze(THD *thd, HA_CHECK_OPT * check_opt)
param.thd= thd;
param.op_name= "analyze";
param.db_name= table->s->db.str;
param.table_name= table->alias;
param.table_name= table->alias.c_ptr();
param.testflag= (T_FAST | T_CHECK | T_SILENT | T_STATISTICS |
T_DONT_CHECK_CHECKSUM);
param.using_global_keycache= 1;
@ -1488,7 +1488,7 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize)
_ma_copy_nontrans_state_information(file);
param->db_name= table->s->db.str;
param->table_name= table->alias;
param->table_name= table->alias.c_ptr();
param->tmpfile_createflag= O_RDWR | O_TRUNC;
param->using_global_keycache= 1;
param->thd= thd;

View File

@ -811,7 +811,7 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
param.thd = thd;
param.op_name = "check";
param.db_name= table->s->db.str;
param.table_name= table->alias;
param.table_name= table->alias.c_ptr();
param.testflag = check_opt->flags | T_CHECK | T_SILENT;
param.stats_method= (enum_handler_stats_method)thd->variables.myisam_stats_method;
@ -904,7 +904,7 @@ int ha_myisam::analyze(THD *thd, HA_CHECK_OPT* check_opt)
param.thd = thd;
param.op_name= "analyze";
param.db_name= table->s->db.str;
param.table_name= table->alias;
param.table_name= table->alias.c_ptr();
param.testflag= (T_FAST | T_CHECK | T_SILENT | T_STATISTICS |
T_DONT_CHECK_CHECKSUM);
param.using_global_keycache = 1;
@ -1129,7 +1129,7 @@ int ha_myisam::repair(THD *thd, HA_CHECK &param, bool do_optimize)
DBUG_ENTER("ha_myisam::repair");
param.db_name= table->s->db.str;
param.table_name= table->alias;
param.table_name= table->alias.c_ptr();
param.tmpfile_createflag = O_RDWR | O_TRUNC;
param.using_global_keycache = 1;
param.thd= thd;

View File

@ -2698,16 +2698,6 @@ row_sel_store_mysql_rec(
prebuilt->blob_heap = NULL;
}
// psergey@askmonty.org: don't take the following:
#if 0
/* init null bytes with default values as they might be
left uninitialized in some cases and these uninited bytes
might be copied into mysql record buffer that leads to
valgrind warnings */
memcpy(mysql_rec, prebuilt->default_rec, prebuilt->null_bitmap_len);
#endif
for (i = start_field_no; i < end_field_no /* prebuilt->n_template */ ; i++) {
templ = prebuilt->mysql_template + i;
@ -3445,6 +3435,12 @@ row_search_for_mysql(
ut_error;
}
/* init null bytes with default values as they might be
left uninitialized in some cases and these uninited bytes
might be copied into mysql record buffer that leads to
valgrind warnings */
memcpy(buf, prebuilt->default_rec, prebuilt->null_bitmap_len);
#if 0
/* August 19, 2005 by Heikki: temporarily disable this error
print until the cursor lock count is done correctly.