diff options
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 248 |
1 files changed, 148 insertions, 100 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 869ae42c98c..b648a9b933e 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1585,7 +1585,9 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) { if (!(part_syntax_buf= generate_partition_syntax(part_info, &syntax_len, - TRUE, TRUE))) + TRUE, TRUE, + lpt->create_info, + lpt->alter_info))) { DBUG_RETURN(TRUE); } @@ -1677,7 +1679,9 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) char *tmp_part_syntax_str; if (!(part_syntax_buf= generate_partition_syntax(part_info, &syntax_len, - TRUE, TRUE))) + TRUE, TRUE, + lpt->create_info, + lpt->alter_info))) { error= 1; goto err; @@ -2056,6 +2060,12 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, } DBUG_PRINT("table", ("table: 0x%lx s: 0x%lx", (long) table->table, table->table ? (long) table->table->s : (long) -1)); + + DBUG_EXECUTE_IF("bug43138", + my_printf_error(ER_BAD_TABLE_ERROR, + ER(ER_BAD_TABLE_ERROR), MYF(0), + table->table_name);); + } /* It's safe to unlock LOCK_open: we have an exclusive lock @@ -2269,17 +2279,19 @@ bool check_duplicates_in_interval(const char *set_or_name, tmp.count--; if (find_type2(&tmp, (const char*)*cur_value, *cur_length, cs)) { + THD *thd= current_thd; + ErrConvString err(*cur_value, *cur_length, cs); if ((current_thd->variables.sql_mode & (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES))) { my_error(ER_DUPLICATED_VALUE_IN_TYPE, MYF(0), - name,*cur_value,set_or_name); + name, err.ptr(), set_or_name); return 1; } - push_warning_printf(current_thd,MYSQL_ERROR::WARN_LEVEL_NOTE, - ER_DUPLICATED_VALUE_IN_TYPE, - ER(ER_DUPLICATED_VALUE_IN_TYPE), - name,*cur_value,set_or_name); + push_warning_printf(thd,MYSQL_ERROR::WARN_LEVEL_NOTE, + ER_DUPLICATED_VALUE_IN_TYPE, + ER(ER_DUPLICATED_VALUE_IN_TYPE), + name, err.ptr(), set_or_name); (*dup_val_count)++; } } @@ -2496,6 +2508,39 @@ int prepare_create_field(Create_field *sql_field, DBUG_RETURN(0); } + +/* + Get character set from field object generated by parser using + default values when not set. + + SYNOPSIS + get_sql_field_charset() + sql_field The sql_field object + create_info Info generated by parser + + RETURN VALUES + cs Character set +*/ + +CHARSET_INFO* get_sql_field_charset(Create_field *sql_field, + HA_CREATE_INFO *create_info) +{ + CHARSET_INFO *cs= sql_field->charset; + + if (!cs) + cs= create_info->default_table_charset; + /* + table_charset is set only in ALTER TABLE t1 CONVERT TO CHARACTER SET csname + if we want change character set for all varchar/char columns. + But the table charset must not affect the BLOB fields, so don't + allow to change my_charset_bin to somethig else. + */ + if (create_info->table_charset && cs != &my_charset_bin) + cs= create_info->table_charset; + return cs; +} + + /* Preparation for table creation @@ -2559,18 +2604,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, executing a prepared statement for the second time. */ sql_field->length= sql_field->char_length; - if (!sql_field->charset) - sql_field->charset= create_info->default_table_charset; - /* - table_charset is set in ALTER TABLE if we want change character set - for all varchar/char columns. - But the table charset must not affect the BLOB fields, so don't - allow to change my_charset_bin to somethig else. - */ - if (create_info->table_charset && sql_field->charset != &my_charset_bin) - sql_field->charset= create_info->table_charset; - - save_cs= sql_field->charset; + save_cs= sql_field->charset= get_sql_field_charset(sql_field, + create_info); if ((sql_field->flags & BINCMP_FLAG) && !(sql_field->charset= get_charset_by_csname(sql_field->charset->csname, MY_CS_BINSORT,MYF(0)))) @@ -2665,7 +2700,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, interval->type_lengths[i], comma_buf, comma_length, NULL, 0)) { - my_error(ER_ILLEGAL_VALUE_FOR_TYPE, MYF(0), "set", tmp->ptr()); + ErrConvString err(tmp->ptr(), tmp->length(), cs); + my_error(ER_ILLEGAL_VALUE_FOR_TYPE, MYF(0), "set", err.ptr()); DBUG_RETURN(TRUE); } } @@ -2879,9 +2915,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, while ((key=key_iterator++)) { - DBUG_PRINT("info", ("key name: '%s' type: %d", key->name ? key->name : + DBUG_PRINT("info", ("key name: '%s' type: %d", key->name.str ? key->name.str : "(none)" , key->type)); - LEX_STRING key_name_str; if (key->type == Key::FOREIGN_KEY) { fk_key_count++; @@ -2890,7 +2925,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, fk_key->ref_columns.elements != fk_key->columns.elements) { my_error(ER_WRONG_FK_DEF, MYF(0), - (fk_key->name ? fk_key->name : "foreign key without name"), + (fk_key->name.str ? fk_key->name.str : + "foreign key without name"), ER(ER_KEY_REF_DO_NOT_MATCH_TABLE_REF)); DBUG_RETURN(TRUE); } @@ -2903,12 +2939,10 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, my_error(ER_TOO_MANY_KEY_PARTS,MYF(0),tmp); DBUG_RETURN(TRUE); } - key_name_str.str= (char*) key->name; - key_name_str.length= key->name ? strlen(key->name) : 0; - if (check_string_char_length(&key_name_str, "", NAME_CHAR_LEN, + if (check_string_char_length(&key->name, "", NAME_CHAR_LEN, system_charset_info, 1)) { - my_error(ER_TOO_LONG_IDENT, MYF(0), key->name); + my_error(ER_TOO_LONG_IDENT, MYF(0), key->name.str); DBUG_RETURN(TRUE); } key_iterator2.rewind (); @@ -2922,7 +2956,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, Then we do not need the generated shorter key. */ if ((key2->type != Key::FOREIGN_KEY && - key2->name != ignore_key && + key2->name.str != ignore_key && !foreign_key_prefix(key, key2))) { /* TODO: issue warning message */ @@ -2930,10 +2964,10 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, if (!key2->generated || (key->generated && key->columns.elements < key2->columns.elements)) - key->name= ignore_key; + key->name.str= ignore_key; else { - key2->name= ignore_key; + key2->name.str= ignore_key; key_parts-= key2->columns.elements; (*key_count)--; } @@ -2941,14 +2975,14 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, } } } - if (key->name != ignore_key) + if (key->name.str != ignore_key) key_parts+=key->columns.elements; else (*key_count)--; - if (key->name && !tmp_table && (key->type != Key::PRIMARY) && - !my_strcasecmp(system_charset_info,key->name,primary_key_name)) + if (key->name.str && !tmp_table && (key->type != Key::PRIMARY) && + !my_strcasecmp(system_charset_info, key->name.str, primary_key_name)) { - my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key->name); + my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key->name.str); DBUG_RETURN(TRUE); } } @@ -2971,12 +3005,12 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, uint key_length=0; Key_part_spec *column; - if (key->name == ignore_key) + if (key->name.str == ignore_key) { /* ignore redundant keys */ do key=key_iterator++; - while (key && key->name == ignore_key); + while (key && key->name.str == ignore_key); if (!key) break; } @@ -3089,22 +3123,22 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, field=0; while ((sql_field=it++) && my_strcasecmp(system_charset_info, - column->field_name, + column->field_name.str, sql_field->field_name)) field++; if (!sql_field) { - my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), column->field_name); + my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), column->field_name.str); DBUG_RETURN(TRUE); } while ((dup_column= cols2++) != column) { if (!my_strcasecmp(system_charset_info, - column->field_name, dup_column->field_name)) + column->field_name.str, dup_column->field_name.str)) { my_printf_error(ER_DUP_FIELDNAME, ER(ER_DUP_FIELDNAME),MYF(0), - column->field_name); + column->field_name.str); DBUG_RETURN(TRUE); } } @@ -3118,7 +3152,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, sql_field->charset->mbminlen > 1 || // ucs2 doesn't work yet (ft_key_charset && sql_field->charset != ft_key_charset)) { - my_error(ER_BAD_FT_COLUMN, MYF(0), column->field_name); + my_error(ER_BAD_FT_COLUMN, MYF(0), column->field_name.str); DBUG_RETURN(-1); } ft_key_charset=sql_field->charset; @@ -3146,7 +3180,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, { if (!(file->ha_table_flags() & HA_CAN_INDEX_BLOBS)) { - my_error(ER_BLOB_USED_AS_KEY, MYF(0), column->field_name); + my_error(ER_BLOB_USED_AS_KEY, MYF(0), column->field_name.str); DBUG_RETURN(TRUE); } if (f_is_geom(sql_field->pack_flag) && sql_field->geom_type == @@ -3154,7 +3188,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, column->length= 25; if (!column->length) { - my_error(ER_BLOB_KEY_WITHOUT_LENGTH, MYF(0), column->field_name); + my_error(ER_BLOB_KEY_WITHOUT_LENGTH, MYF(0), column->field_name.str); DBUG_RETURN(TRUE); } } @@ -3185,7 +3219,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, key_info->flags|= HA_NULL_PART_KEY; if (!(file->ha_table_flags() & HA_NULL_IN_KEY)) { - my_error(ER_NULL_COLUMN_IN_INDEX, MYF(0), column->field_name); + my_error(ER_NULL_COLUMN_IN_INDEX, MYF(0), column->field_name.str); DBUG_RETURN(TRUE); } if (key->type == Key::SPATIAL) @@ -3235,13 +3269,21 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, } } else if (!f_is_geom(sql_field->pack_flag) && - (column->length > length || - !Field::type_can_have_key_part (sql_field->sql_type) || - ((f_is_packed(sql_field->pack_flag) || - ((file->ha_table_flags() & HA_NO_PREFIX_CHAR_KEYS) && - (key_info->flags & HA_NOSAME))) && - column->length != length))) - { + ((column->length > length && + !Field::type_can_have_key_part (sql_field->sql_type)) || + ((f_is_packed(sql_field->pack_flag) || + ((file->ha_table_flags() & HA_NO_PREFIX_CHAR_KEYS) && + (key_info->flags & HA_NOSAME))) && + column->length != length))) + { + /* Catch invalid uses of partial keys. + A key is identified as 'partial' if column->length != length. + A partial key is invalid if they data type does + not allow it, or the field is packed (as in MyISAM), + or the storage engine doesn't allow prefixed search and + the key is primary key. + */ + my_message(ER_WRONG_SUB_KEY, ER(ER_WRONG_SUB_KEY), MYF(0)); DBUG_RETURN(TRUE); } @@ -3250,7 +3292,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, } else if (length == 0) { - my_error(ER_WRONG_KEY_COLUMN, MYF(0), column->field_name); + my_error(ER_WRONG_KEY_COLUMN, MYF(0), column->field_name.str); DBUG_RETURN(TRUE); } if (length > file->max_key_part_length() && key->type != Key::FULLTEXT) @@ -3308,7 +3350,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, key_name=primary_key_name; primary_key=1; } - else if (!(key_name = key->name)) + else if (!(key_name= key->name.str)) key_name=make_unique_key_name(sql_field->field_name, *key_info_buffer, key_info); if (check_if_keyname_exists(key_name, *key_info_buffer, key_info)) @@ -3619,6 +3661,9 @@ bool mysql_create_table_no_lock(THD *thd, } if (check_engine(thd, table_name, create_info)) DBUG_RETURN(TRUE); + + set_table_default_charset(thd, create_info, (char*) db); + db_options= create_info->table_options; if (create_info->row_type == ROW_TYPE_DYNAMIC) db_options|=HA_OPTION_PACK_RECORD; @@ -3712,7 +3757,7 @@ bool mysql_create_table_no_lock(THD *thd, ha_resolve_storage_engine_name(part_info->default_engine_type), ha_resolve_storage_engine_name(create_info->db_type))); if (part_info->check_partition_info(thd, &engine_type, file, - create_info, TRUE)) + create_info, FALSE)) goto err; part_info->default_engine_type= engine_type; @@ -3722,7 +3767,9 @@ bool mysql_create_table_no_lock(THD *thd, */ if (!(part_syntax_buf= generate_partition_syntax(part_info, &syntax_len, - TRUE, TRUE))) + TRUE, TRUE, + create_info, + alter_info))) goto err; part_info->part_info_string= part_syntax_buf; part_info->part_info_len= syntax_len; @@ -3748,9 +3795,9 @@ bool mysql_create_table_no_lock(THD *thd, creates a proper .par file. The current part_info object is only used to create the frm-file and .par-file. */ - if (part_info->use_default_no_partitions && - part_info->no_parts && - (int)part_info->no_parts != + if (part_info->use_default_num_partitions && + part_info->num_parts && + (int)part_info->num_parts != file->get_default_no_partitions(create_info)) { uint i; @@ -3761,13 +3808,13 @@ bool mysql_create_table_no_lock(THD *thd, (part_it++)->part_state= PART_TO_BE_DROPPED; } else if (part_info->is_sub_partitioned() && - part_info->use_default_no_subpartitions && - part_info->no_subparts && - (int)part_info->no_subparts != + part_info->use_default_num_subpartitions && + part_info->num_subparts && + (int)part_info->num_subparts != file->get_default_no_partitions(create_info)) { DBUG_ASSERT(thd->lex->sql_command != SQLCOM_CREATE_TABLE); - part_info->no_subparts= file->get_default_no_partitions(create_info); + part_info->num_subparts= file->get_default_no_partitions(create_info); } } else if (create_info->db_type != engine_type) @@ -3789,8 +3836,6 @@ bool mysql_create_table_no_lock(THD *thd, } #endif - set_table_default_charset(thd, create_info, (char*) db); - if (mysql_prepare_create_table(thd, create_info, alter_info, internal_tmp_table, &db_options, file, @@ -3846,7 +3891,7 @@ bool mysql_create_table_no_lock(THD *thd, Then she could create the table. This case is pretty obscure and therefore we don't introduce a new error message only for it. */ - if (get_cached_table_share(db, alias)) + if (get_cached_table_share(db, table_name)) { my_error(ER_TABLE_EXISTS_ERROR, MYF(0), table_name); goto unlock_and_end; @@ -3980,7 +4025,7 @@ bool mysql_create_table(THD *thd, const char *db, const char *table_name, /* Wait for any database locks */ pthread_mutex_lock(&LOCK_lock_db); while (!thd->killed && - hash_search(&lock_db_cache,(uchar*) db, strlen(db))) + my_hash_search(&lock_db_cache,(uchar*) db, strlen(db))) { wait_for_condition(thd, &LOCK_lock_db, &COND_refresh); pthread_mutex_lock(&LOCK_lock_db); @@ -4520,7 +4565,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, item->maybe_null = 1; field_list.push_back(item = new Item_empty_string("Msg_text", 255)); item->maybe_null = 1; - if (protocol->send_fields(&field_list, + if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) DBUG_RETURN(TRUE); @@ -4569,6 +4614,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, /* Set up which partitions that should be processed if ALTER TABLE t ANALYZE/CHECK/OPTIMIZE/REPAIR PARTITION .. + CACHE INDEX/LOAD INDEX for specified partitions */ Alter_info *alter_info= &lex->alter_info; @@ -4579,11 +4625,11 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, my_error(ER_PARTITION_MGMT_ON_NONPARTITIONED, MYF(0)); DBUG_RETURN(TRUE); } - uint no_parts_found; - uint no_parts_opt= alter_info->partition_names.elements; - no_parts_found= set_part_state(alter_info, table->table->part_info, - PART_CHANGED); - if (no_parts_found != no_parts_opt && + uint num_parts_found; + uint num_parts_opt= alter_info->partition_names.elements; + num_parts_found= set_part_state(alter_info, table->table->part_info, + PART_ADMIN); + if (num_parts_found != num_parts_opt && (!(alter_info->flags & ALTER_ALL_PARTITION))) { char buff[FN_REFLEN + MYSQL_ERRMSG_SIZE]; @@ -4640,17 +4686,17 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, if (!table->table) { DBUG_PRINT("admin", ("open table failed")); - if (!thd->warn_list.elements) - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + if (thd->warning_info->is_empty()) + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_CHECK_NO_SUCH_TABLE, ER(ER_CHECK_NO_SUCH_TABLE)); /* if it was a view will check md5 sum */ if (table->view && view_checksum(thd, table) == HA_ADMIN_WRONG_CHECKSUM) - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_VIEW_CHECKSUM, ER(ER_VIEW_CHECKSUM)); - if (thd->main_da.is_error() && - (thd->main_da.sql_errno() == ER_NO_SUCH_TABLE || - thd->main_da.sql_errno() == ER_FILE_NOT_FOUND)) + if (thd->stmt_da->is_error() && + (thd->stmt_da->sql_errno() == ER_NO_SUCH_TABLE || + thd->stmt_da->sql_errno() == ER_FILE_NOT_FOUND)) /* A missing table is just issued as a failed command */ result_code= HA_ADMIN_FAILED; else @@ -4692,7 +4738,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, table->table=0; // For query cache if (protocol->write()) goto err; - thd->main_da.reset_diagnostics_area(); + thd->stmt_da->reset_diagnostics_area(); continue; /* purecov: end */ } @@ -4752,8 +4798,8 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, we will store the error message in a result set row and then clear. */ - if (thd->main_da.is_ok()) - thd->main_da.reset_diagnostics_area(); + if (thd->stmt_da->is_ok()) + thd->stmt_da->reset_diagnostics_area(); goto send_result; } } @@ -4767,21 +4813,21 @@ send_result: lex->cleanup_after_one_table_open(); thd->clear_error(); // these errors shouldn't get client { - List_iterator_fast<MYSQL_ERROR> it(thd->warn_list); + List_iterator_fast<MYSQL_ERROR> it(thd->warning_info->warn_list()); MYSQL_ERROR *err; while ((err= it++)) { protocol->prepare_for_resend(); protocol->store(table_name, system_charset_info); protocol->store((char*) operator_name, system_charset_info); - protocol->store(warning_level_names[err->level].str, - warning_level_names[err->level].length, + protocol->store(warning_level_names[err->get_level()].str, + warning_level_names[err->get_level()].length, system_charset_info); - protocol->store(err->msg, system_charset_info); + protocol->store(err->get_message_text(), system_charset_info); if (protocol->write()) goto err; } - mysql_reset_errors(thd, true); + thd->warning_info->clear_warning_info(thd->query_id); } protocol->prepare_for_resend(); protocol->store(table_name, system_charset_info); @@ -4876,8 +4922,8 @@ send_result_message: we will store the error message in a result set row and then clear. */ - if (thd->main_da.is_ok()) - thd->main_da.reset_diagnostics_area(); + if (thd->stmt_da->is_ok()) + thd->stmt_da->reset_diagnostics_area(); ha_autocommit_or_rollback(thd, 0); close_thread_tables(thd); if (!result_code) // recreation went ok @@ -4895,7 +4941,7 @@ send_result_message: DBUG_ASSERT(thd->is_error()); if (thd->is_error()) { - const char *err_msg= thd->main_da.message(); + const char *err_msg= thd->stmt_da->message(); if (!thd->vio_ok()) { sql_print_error("%s", err_msg); @@ -5426,7 +5472,7 @@ binlog: */ if (!table->view) { - IF_DBUG(int result=) + int result __attribute__((unused))= store_create_info(thd, table, &query, create_info, FALSE /* show_database */); @@ -6245,6 +6291,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, } key_part_length /= key_part->field->charset()->mbmaxlen; key_parts.push_back(new Key_part_spec(cfield->field_name, + strlen(cfield->field_name), key_part_length)); } if (key_parts.elements) @@ -6274,7 +6321,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, else key_type= Key::MULTIPLE; - key= new Key(key_type, key_name, + key= new Key(key_type, key_name, strlen(key_name), &key_create_info, test(key_info->flags & HA_GENERATED_KEY), key_parts); @@ -6287,10 +6334,10 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, { if (key->type != Key::FOREIGN_KEY) new_key_list.push_back(key); - if (key->name && - !my_strcasecmp(system_charset_info,key->name,primary_key_name)) + if (key->name.str && + !my_strcasecmp(system_charset_info, key->name.str, primary_key_name)) { - my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key->name); + my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key->name.str); goto err; } } @@ -7489,7 +7536,7 @@ view_err: end_temporary: my_snprintf(tmp_name, sizeof(tmp_name), ER(ER_INSERT_INFO), (ulong) (copied + deleted), (ulong) deleted, - (ulong) thd->cuted_fields); + (ulong) thd->warning_info->statement_warn_count()); my_ok(thd, copied + deleted, 0L, tmp_name); thd->some_tables_deleted=0; DBUG_RETURN(FALSE); @@ -7513,7 +7560,8 @@ err: the table to be altered isn't empty. Report error here. */ - if (alter_info->error_if_not_empty && thd->row_count) + if (alter_info->error_if_not_empty && + thd->warning_info->current_row_for_warning()) { const char *f_val= 0; enum enum_mysql_timestamp_type t_type= MYSQL_TIMESTAMP_DATE; @@ -7534,7 +7582,7 @@ err: } bool save_abort_on_warning= thd->abort_on_warning; thd->abort_on_warning= TRUE; - make_truncated_value_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + make_truncated_value_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, f_val, strlength(f_val), t_type, alter_info->datetime_field->field_name); thd->abort_on_warning= save_abort_on_warning; @@ -7681,7 +7729,7 @@ copy_data_between_tables(TABLE *from,TABLE *to, init_read_record(&info, thd, from, (SQL_SELECT *) 0, 1, 1, FALSE); if (ignore) to->file->extra(HA_EXTRA_IGNORE_DUP_KEY); - thd->row_count= 0; + thd->warning_info->reset_current_row_for_warning(); restore_record(to, s->default_values); // Create empty record while (!(error=info.read_record(&info))) { @@ -7691,7 +7739,6 @@ copy_data_between_tables(TABLE *from,TABLE *to, error= 1; break; } - thd->row_count++; /* Return error if source table isn't empty. */ if (error_if_not_empty) { @@ -7741,6 +7788,7 @@ copy_data_between_tables(TABLE *from,TABLE *to, } else found_count++; + thd->warning_info->inc_current_row_for_warning(); } end_read_record(&info); free_io_cache(from); @@ -7830,7 +7878,7 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, field_list.push_back(item= new Item_int("Checksum", (longlong) 1, MY_INT64_NUM_DECIMAL_DIGITS)); item->maybe_null= 1; - if (protocol->send_fields(&field_list, + if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) DBUG_RETURN(TRUE); |