diff options
author | Monty <monty@mariadb.org> | 2020-07-03 23:31:12 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2020-07-03 23:31:12 +0300 |
commit | 0fd89a1a89da73cec8e87e1f007637eaec51dcc0 (patch) | |
tree | 2198830733091087ae4d342d56c93540698ec325 /sql | |
parent | 70684afef2ce6d797f78db192c4472260cd22660 (diff) | |
parent | e9f06b19e09319d11c346943871254aaf755af24 (diff) | |
download | mariadb-git-0fd89a1a89da73cec8e87e1f007637eaec51dcc0.tar.gz |
Merge remote-tracking branch 'origin/10.4' into 10.5
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.cc | 2 | ||||
-rw-r--r-- | sql/field.h | 4 | ||||
-rw-r--r-- | sql/session_tracker.cc | 14 | ||||
-rw-r--r-- | sql/sql_load.cc | 4 | ||||
-rw-r--r-- | sql/sql_parse.cc | 6 | ||||
-rw-r--r-- | sql/sql_select.cc | 53 | ||||
-rw-r--r-- | sql/table.cc | 9 | ||||
-rw-r--r-- | sql/unireg.cc | 4 |
8 files changed, 61 insertions, 35 deletions
diff --git a/sql/field.cc b/sql/field.cc index 9b6f117a82e..e73cc380196 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -7698,7 +7698,7 @@ my_decimal *Field_varstring::val_decimal(my_decimal *decimal_value) } -#ifdef HAVE_valgrind_or_MSAN +#ifdef HAVE_valgrind void Field_varstring::mark_unused_memory_as_defined() { uint used_length= get_length(); diff --git a/sql/field.h b/sql/field.h index 420ff6866bd..72c99c37fb7 100644 --- a/sql/field.h +++ b/sql/field.h @@ -997,7 +997,7 @@ public: */ virtual int store_from_statistical_minmax_field(Field *field, String *str); -#ifdef HAVE_valgrind_or_MSAN +#ifdef HAVE_valgrind /** Mark unused memory in the field as defined. Mainly used to ensure that if we write full field to disk (for example in @@ -4136,7 +4136,7 @@ public: } int store(const char *to,size_t length,CHARSET_INFO *charset) override; using Field_str::store; -#ifdef HAVE_valgrind_or_MSAN +#ifdef HAVE_valgrind void mark_unused_memory_as_defined() override; #endif double val_real() override; diff --git a/sql/session_tracker.cc b/sql/session_tracker.cc index d94ecdc2b24..4cee6cb0dfa 100644 --- a/sql/session_tracker.cc +++ b/sql/session_tracker.cc @@ -381,16 +381,14 @@ bool Session_sysvars_tracker::enable(THD *thd) bool Session_sysvars_tracker::update(THD *thd, set_var *var) { vars_list tool_list; - void *copy; size_t length= 1; - if (var->save_result.string_value.str) - copy= my_memdup(PSI_INSTRUMENT_ME, var->save_result.string_value.str, - (length= var->save_result.string_value.length + 1), - MYF(MY_WME | MY_THREAD_SPECIFIC)); - else - copy= my_strdup(PSI_INSTRUMENT_ME, "", MYF(MY_WME | MY_THREAD_SPECIFIC)); - + void *copy= var->save_result.string_value.str ? + my_memdup(PSI_INSTRUMENT_ME, var->save_result.string_value.str, + (length= var->save_result.string_value.length + 1), + MYF(MY_WME | MY_THREAD_SPECIFIC)) : + my_strdup(PSI_INSTRUMENT_ME, "", + MYF(MY_WME | MY_THREAD_SPECIFIC)); if (!copy) return true; diff --git a/sql/sql_load.cc b/sql/sql_load.cc index c3e301cd39d..2869011e313 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -2029,8 +2029,8 @@ int READ_INFO::read_xml(THD *thd) case '=': /* attribute name end - read the value */ //check for tag field and attribute name - if(!memcmp(tag.c_ptr_safe(), STRING_WITH_LEN("field")) && - !memcmp(attribute.c_ptr_safe(), STRING_WITH_LEN("name"))) + if(!strcmp(tag.c_ptr_safe(), "field") && + !strcmp(attribute.c_ptr_safe(), "name")) { /* this is format <field name="xx">xx</field> diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 167aefee7a6..8d074e13d1f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5058,6 +5058,12 @@ mysql_execute_command(THD *thd) if (res) goto error; +#ifdef WITH_WSREP + /* Clean up the previous transaction on implicit commit. */ + if (wsrep_on(thd) && !wsrep_not_committed(thd) && wsrep_after_statement(thd)) + goto error; +#endif + /* We can't have any kind of table locks while backup is active */ if (thd->current_backup_stage != BACKUP_FINISHED) { diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 896e7fdf5e7..9cc4a9c4626 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -6562,6 +6562,7 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array, keyuse.keypart= FT_KEYPART; keyuse.used_tables=cond_func->key_item()->used_tables(); keyuse.optimize= 0; + keyuse.ref_table_rows= 0; keyuse.keypart_map= 0; keyuse.sj_pred_no= UINT_MAX; keyuse.validity_ref= 0; @@ -18641,17 +18642,15 @@ bool Create_tmp_table::finalize(THD *thd, uint null_pack_length[2]; uint null_pack_base[2]; uint null_counter[2]= {0, 0}; - uint whole_null_pack_length; - bool use_packed_rows= false; + bool save_abort_on_warning; uchar *pos; uchar *null_flags; KEY *keyinfo; TMP_ENGINE_COLUMNDEF *recinfo; TABLE_SHARE *share= table->s; Copy_field *copy= param->copy_field; - MEM_ROOT *mem_root_save= thd->mem_root; thd->mem_root= &table->mem_root; @@ -18752,6 +18751,11 @@ bool Create_tmp_table::finalize(THD *thd, { null_counter[(m_field_count[other] ? other : distinct)]++; } + + /* Protect against warnings in field_conv() in the next loop*/ + save_abort_on_warning= thd->abort_on_warning; + thd->abort_on_warning= 0; + for (uint i= 0; i < share->fields; i++, recinfo++) { Field *field= table->field[i]; @@ -18795,25 +18799,31 @@ bool Create_tmp_table::finalize(THD *thd, inherit the default value that is defined for the field referred by the Item_field object from which 'field' has been created. */ - const Field *orig_field= m_default_field[i]; + Field *orig_field= m_default_field[i]; /* Get the value from default_values */ if (orig_field->is_null_in_record(orig_field->table->s->default_values)) field->set_null(); else { + /* + Copy default value. We have to use field_conv() for copy, instead of + memcpy(), because bit_fields may be stored differently + */ + my_ptrdiff_t ptr_diff= (orig_field->table->s->default_values - + orig_field->table->record[0]); field->set_notnull(); - memcpy(field->ptr, - orig_field->ptr_in_record(orig_field->table->s->default_values), - field->pack_length_in_rec()); + orig_field->move_field_offset(ptr_diff); + field_conv(field, orig_field); + orig_field->move_field_offset(-ptr_diff); } - } + } if (m_from_field[i]) { /* Not a table Item */ copy->set(field, m_from_field[i], m_save_sum_fields); copy++; } - length=field->pack_length(); + length=field->pack_length_in_rec(); pos+= length; /* Make entry for create table */ @@ -18823,7 +18833,11 @@ bool Create_tmp_table::finalize(THD *thd, // fix table name in field entry field->set_table_name(&table->alias); } + /* Handle group_null_items */ + bzero(pos, table->s->reclength - (pos - table->record[0])); + MEM_CHECK_DEFINED(table->record[0], table->s->reclength); + thd->abort_on_warning= save_abort_on_warning; param->copy_field_end= copy; param->recinfo= recinfo; // Pointer to after last field store_record(table,s->default_values); // Make empty default record @@ -19086,8 +19100,9 @@ bool Create_tmp_table::finalize(THD *thd, goto err; } - // Make empty record so random data is not written to disk - empty_record(table); + /* record[0] and share->default_values should now have been set up */ + MEM_CHECK_DEFINED(table->record[0], table->s->reclength); + MEM_CHECK_DEFINED(share->default_values, table->s->reclength); thd->mem_root= mem_root_save; @@ -19483,7 +19498,11 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo, (*recinfo)->type= FIELD_CHECK; (*recinfo)->length= MARIA_UNIQUE_HASH_LENGTH; (*recinfo)++; - share->reclength+= MARIA_UNIQUE_HASH_LENGTH; + + /* Avoid warnings from valgrind */ + bzero(table->record[0]+ share->reclength, MARIA_UNIQUE_HASH_LENGTH); + bzero(share->default_values+ share->reclength, MARIA_UNIQUE_HASH_LENGTH); + share->reclength+= MARIA_UNIQUE_HASH_LENGTH; } else { @@ -19677,7 +19696,10 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo, (*recinfo)->type= FIELD_CHECK; (*recinfo)->length=MI_UNIQUE_HASH_LENGTH; (*recinfo)++; - share->reclength+=MI_UNIQUE_HASH_LENGTH; + /* Avoid warnings from valgrind */ + bzero(table->record[0]+ share->reclength, MI_UNIQUE_HASH_LENGTH); + bzero(share->default_values+ share->reclength, MI_UNIQUE_HASH_LENGTH); + share->reclength+= MI_UNIQUE_HASH_LENGTH; } else { @@ -20269,11 +20291,11 @@ bool instantiate_tmp_table(TABLE *table, KEY *keyinfo, If it is not heap (in-memory) table then convert index to unique constrain. */ + MEM_CHECK_DEFINED(table->record[0], table->s->reclength); if (create_internal_tmp_table(table, keyinfo, start_recinfo, recinfo, options)) return TRUE; - // Make empty record so random data is not written to disk - empty_record(table); + MEM_CHECK_DEFINED(table->record[0], table->s->reclength); } if (open_tmp_table(table)) return TRUE; @@ -28795,7 +28817,6 @@ AGGR_OP::prepare_tmp_table() join->select_options)) return true; (void) table->file->extra(HA_EXTRA_WRITE_CACHE); - empty_record(table); } /* If it wasn't already, start index scan for grouping using table index. */ if (!table->file->inited && table->group && diff --git a/sql/table.cc b/sql/table.cc index 9e7592e4b97..06178f8e789 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -2109,8 +2109,8 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, share->rec_buff_length= rec_buff_length; if (!(record= (uchar *) alloc_root(&share->mem_root, rec_buff_length))) goto err; /* purecov: inspected */ - MEM_NOACCESS(record, rec_buff_length); - MEM_UNDEFINED(record, share->reclength); + /* Mark bytes after record as not accessable to catch overrun bugs */ + MEM_NOACCESS(record + share->reclength, rec_buff_length - share->reclength); share->default_values= record; memcpy(record, frm_image + record_offset, share->reclength); @@ -3959,7 +3959,6 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share, if (!(record= (uchar*) alloc_root(&outparam->mem_root, share->rec_buff_length * records))) goto err; /* purecov: inspected */ - MEM_NOACCESS(record, share->rec_buff_length * records); } for (i= 0; i < 3;) @@ -3968,8 +3967,10 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share, if (++i < records) record+= share->rec_buff_length; } + /* Mark bytes between records as not accessable to catch overrun bugs */ for (i= 0; i < records; i++) - MEM_UNDEFINED(outparam->record[i], share->reclength); + MEM_NOACCESS(outparam->record[i] + share->reclength, + share->rec_buff_length - share->reclength); if (!(field_ptr = (Field **) alloc_root(&outparam->mem_root, (uint) ((share->fields+1)* diff --git a/sql/unireg.cc b/sql/unireg.cc index fa193a7712d..525e7a8a56a 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -592,8 +592,8 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING &table, pos+= create_info->comment.length; } - memcpy(frm_ptr + filepos, forminfo, 288); - pos= frm_ptr + filepos + 288; + memcpy(frm_ptr + filepos, forminfo, FRM_FORMINFO_SIZE); + pos= frm_ptr + filepos + FRM_FORMINFO_SIZE; if (pack_fields(&pos, create_fields, create_info, data_offset)) goto err; |