cleanup: lex_string_set3()

This commit is contained in:
Sergei Golubchik 2024-01-27 09:31:44 +01:00
parent 32e6f8ff2e
commit ae59127158
9 changed files with 21 additions and 34 deletions

View file

@ -242,12 +242,6 @@ static inline void lex_string_set(LEX_CSTRING *lex_str, const char *c_str)
lex_str->str= c_str;
lex_str->length= strlen(c_str);
}
static inline void lex_string_set3(LEX_CSTRING *lex_str, const char *c_str,
size_t len)
{
lex_str->str= c_str;
lex_str->length= len;
}
/**
Copies a string.

View file

@ -2212,8 +2212,7 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root,
mysql_mutex_unlock(&LOCK_gdl);
save_db= thd->db;
lex_string_set3(&thd->db, recovery_state.db.ptr(),
recovery_state.db.length());
thd->db= recovery_state.db.to_lex_cstring();
(void) thd->binlog_query(THD::STMT_QUERY_TYPE,
recovery_state.query.ptr(),
recovery_state.query.length(),

View file

@ -144,9 +144,9 @@ int ha_partition::notify_tabledef_changed(LEX_CSTRING *db,
if (create_partition_name(from_buff, sizeof(from_buff), from_path,
name_buffer_ptr, NORMAL_PART_NAME, FALSE))
res=1;
table_name_ptr= from_buff + dirname_length(from_buff);
lex_string_set3(&table_name, table_name_ptr, strlen(table_name_ptr));
table_name_ptr= from_buff + dirname_length(from_buff);
lex_string_set(&table_name, table_name_ptr);
if (((*file)->ht)->notify_tabledef_changed((*file)->ht, db, &table_name,
frm, version, *file))

View file

@ -1062,19 +1062,19 @@ int Json_table_column::On_response::print(const char *name, String *str) const
switch (m_response)
{
case Json_table_column::RESPONSE_NULL:
lex_string_set3(&resp, STRING_WITH_LEN("NULL"));
resp= { STRING_WITH_LEN("NULL") };
break;
case Json_table_column::RESPONSE_ERROR:
lex_string_set3(&resp, STRING_WITH_LEN("ERROR"));
resp= { STRING_WITH_LEN("ERROR") };
break;
case Json_table_column::RESPONSE_DEFAULT:
{
lex_string_set3(&resp, STRING_WITH_LEN("DEFAULT"));
resp= { STRING_WITH_LEN("DEFAULT") };
ds= m_default->val_str(&val);
break;
}
default:
lex_string_set3(&resp, "", 0);
resp= { "", 0 };
DBUG_ASSERT(FALSE); /* should never happen. */
}
@ -1477,5 +1477,3 @@ table_map add_table_function_dependencies(List<TABLE_LIST> *join_list,
return res;
}

View file

@ -16823,17 +16823,17 @@ const char *dbug_print_sel_arg(SEL_ARG *sel_arg)
}
if (sel_arg->min_flag & NEAR_MIN)
lex_string_set3(&tmp, "<", 1);
tmp = { STRING_WITH_LEN("<") };
else
lex_string_set3(&tmp, "<=", 2);
tmp = { STRING_WITH_LEN("<=") };
out.append(&tmp);
out.append(sel_arg->field->field_name);
if (sel_arg->min_flag & NEAR_MAX)
lex_string_set3(&tmp, "<", 1);
tmp = { STRING_WITH_LEN("<") };
else
lex_string_set3(&tmp, "<=", 2);
tmp = { STRING_WITH_LEN("<=") };
out.append(&tmp);
if (sel_arg->max_flag & NO_MAX_RANGE)

View file

@ -540,21 +540,20 @@ uint Explain_union::make_union_table_name(char *buf)
switch (operation)
{
case OP_MIX:
lex_string_set3(&type, STRING_WITH_LEN("<unit"));
type= { STRING_WITH_LEN("<unit") };
break;
case OP_UNION:
lex_string_set3(&type, STRING_WITH_LEN("<union"));
type= { STRING_WITH_LEN("<union") };
break;
case OP_INTERSECT:
lex_string_set3(&type, STRING_WITH_LEN("<intersect"));
type= { STRING_WITH_LEN("<intersect") };
break;
case OP_EXCEPT:
lex_string_set3(&type, STRING_WITH_LEN("<except"));
type= { STRING_WITH_LEN("<except") };
break;
default:
DBUG_ASSERT(0);
type.str= NULL;
type.length= 0;
type= { NULL, 0 };
}
memcpy(buf, type.str, (len= (uint)type.length));

View file

@ -4711,7 +4711,6 @@ int mysql_create_table_no_lock(THD *thd,
int res;
uint path_length;
char path[FN_REFLEN + 1];
LEX_CSTRING cpath;
const Lex_ident_db *db= &table_list->db;
const Lex_ident_table *table_name= &table_list->table_name;
LEX_CUSTRING frm= {0,0};
@ -4734,8 +4733,8 @@ int mysql_create_table_no_lock(THD *thd,
return true;
}
}
lex_string_set3(&cpath, path, path_length);
LEX_CSTRING cpath= { path, path_length };
res= create_table_impl(thd, ddl_log_state_create, ddl_log_state_rm, *db,
*table_name, *db, *table_name, cpath, *create_info,
create_info, alter_info, create_table_mode,

View file

@ -1383,7 +1383,7 @@ bool Table_triggers_list::drop_trigger(THD *thd, TABLE_LIST *tables,
if (stmt_query)
{
/* This code is executed in case of DROP TRIGGER */
lex_string_set3(&query, thd->query(), thd->query_length());
query = { thd->query(), thd->query_length() };
}
if (ddl_log_drop_trigger(ddl_log_state, &tables->db, &tables->table_name,
sp_name, &query))

View file

@ -1945,12 +1945,10 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
for (view= views; view; view= view->next_local)
{
LEX_CSTRING cpath;
bool not_exist;
size_t length;
length= build_table_filename(path, sizeof(path) - 1,
view->db.str, view->table_name.str, reg_ext, 0);
lex_string_set3(&cpath, path, length);
size_t length= build_table_filename(path, sizeof(path) - 1, view->db.str,
view->table_name.str, reg_ext, 0);
LEX_CSTRING cpath= { path, length };
if ((not_exist= my_access(path, F_OK)) || !dd_frm_is_view(thd, path))
{