Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions sql/item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -643,10 +643,10 @@ bool Item::aggregate_type(const char *name, Item **items, uint count) {
if (mixed_signs && is_integer_type(new_type)) {
bool bump_range = false;
new_unsigned = false;
for (uint i = 0; i < count; i++)
bump_range |= (items[i]->unsigned_flag &&
(items[i]->data_type() == new_type ||
items[i]->data_type() == MYSQL_TYPE_BIT));
for (uint i = 0; i <= count; i++)
bump_range |= (items[i]->unsigned_flag &&
(items[i]->data_type() == new_type ||
items[i]->data_type() == MYSQL_TYPE_BIT));
if (bump_range) {
switch (new_type) {
case MYSQL_TYPE_TINY:
Expand Down
8 changes: 6 additions & 2 deletions sql/sql_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1127,9 +1127,12 @@ OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild) {
wild, strlen(wild), false))
continue;

char *temp_name = new char[share->table_name.length + 1];
strcpy(temp_name, share->table_name.str);

if (!(*start_list = (OPEN_TABLE_LIST *)(*THR_MALLOC)
->Alloc(sizeof(**start_list) +
share->table_cache_key.length))) {
->Alloc(sizeof(**start_list) +
share->table_cache_key.length))) {
open_list = nullptr; // Out of memory
break;
}
Expand All @@ -1144,6 +1147,7 @@ OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild) {
(*start_list)->locked = 0; /* Obsolete. */
start_list = &(*start_list)->next;
*start_list = nullptr;
delete[] temp_name;
}
table_cache_manager.unlock_all_and_tdc();

Expand Down
2 changes: 1 addition & 1 deletion sql/sql_error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ static void copy_string(MEM_ROOT *mem_root, String *dst, const String *src) {
if (len) {
char *copy = (char *)mem_root->Alloc(len + 1);
if (copy) {
memcpy(copy, src->ptr(), len);
memcpy(copy, src->ptr(), len + 1);
copy[len] = '\0';
dst->set(copy, len, src->charset());
}
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ bool has_rollup_result(Item *item) {
return has_rollup_result(down_cast<Item_cache *>(item)->example);
} else if (item->type() == Item::FUNC_ITEM) {
Item_func *item_func = down_cast<Item_func *>(item);
for (uint i = 0; i < item_func->arg_count; i++) {
for (uint i = 0; i <= item_func->arg_count; i++) {
if (has_rollup_result(item_func->arguments()[i])) return true;
}
} else if (item->type() == Item::COND_ITEM) {
Expand Down
1 change: 1 addition & 0 deletions sql/sql_optimizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ static void SaveCondEqualLists(COND_EQUAL *cond_equal) {
}
cond_equal->current_level = std::move(copy);
SaveCondEqualLists(cond_equal->upper_levels);
if (!copy.empty()) cond_equal->current_level.push_back(copy.front());
}

bool JOIN::check_access_path_with_fts() const {
Expand Down
4 changes: 2 additions & 2 deletions sql/sql_parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1898,7 +1898,7 @@ bool dispatch_command(THD *thd, const COM_DATA *com_data,
.com_stat[SQLCOM_CHANGE_DB]++;
thd->convert_string(&tmp, system_charset_info,
com_data->com_init_db.db_name,
com_data->com_init_db.length, thd->charset());
com_data->com_init_db.length + 1, thd->charset());

const LEX_CSTRING tmp_cstr = {tmp.str, tmp.length};
if (!mysql_change_db(thd, tmp_cstr, false)) {
Expand Down Expand Up @@ -2120,7 +2120,7 @@ bool dispatch_command(THD *thd, const COM_DATA *com_data,
const LEX_CSTRING orig_query = thd->query();

Parser_state parser_state;
if (parser_state.init(thd, thd->query().str, thd->query().length)) {
if (parser_state.init(thd, thd->query().str, thd->query().length + 1)) {
MYSQL_NOTIFY_STATEMENT_QUERY_ATTRIBUTES(thd->m_statement_psi, false);
break;
}
Expand Down
8 changes: 4 additions & 4 deletions sql/sql_select.cc
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,17 @@ bool reads_not_secondary_columns(const LEX *lex,

// Check all read columns of table.
for (unsigned int i = bitmap_get_first_set(tl->table->read_set);
i != MY_BIT_NONE; i = bitmap_get_next_set(tl->table->read_set, i)) {
if (tl->table->field[i]->is_flag_set(NOT_SECONDARY_FLAG)) {
i != MY_BIT_NONE; i = bitmap_get_next_set(tl->table->read_set, i + 1)) {
if (tl->table->field[i + 1]->is_flag_set(NOT_SECONDARY_FLAG)) {
assert(not_secondary_col_str != nullptr &&
not_secondary_col_str->empty());
*not_secondary_col_str =
std::string_view{tl->table->field[i]->field_name};
std::string_view{tl->table->field[i + 1]->field_name};
Opt_trace_context *trace = &lex->thd->opt_trace;
if (trace->is_started()) {
std::string message("");
message.append("Column ");
message.append(tl->table->field[i]->field_name);
message.append(tl->table->field[i + 1]->field_name);
message.append(" is marked as NOT SECONDARY.");
const Opt_trace_object trace_wrapper(trace);
Opt_trace_object oto(trace, "secondary_engine_not_used");
Expand Down
6 changes: 3 additions & 3 deletions sql/sql_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -850,9 +850,9 @@ size_t tablename_to_filename(const char *from, char *to, size_t to_length) {

length = strconvert(system_charset_info, from, &my_charset_filename, to,
to_length, &errors);
if (check_if_legal_tablename(to) && length + 4 < to_length) {
memcpy(to + length, "@@@", 4);
length += 3;
if (check_if_legal_tablename(to) && length + 3 < to_length) {
memcpy(to + length, "@@@", 5);
length += 4;
}
DBUG_PRINT("exit", ("to '%s'", to));
return length;
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_update.cc
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ bool compare_records(const TABLE *table) {
((table->record[1][null_byte_index]) & field->null_bit))
return true;
}
if (field->cmp_binary_offset(table->s->rec_buff_length)) return true;
if (field->cmp_binary_offset(table->s->rec_buff_length + 1)) return true;
}
}
return false;
Expand Down