merge with 5.1

This commit is contained in:
Sergei Golubchik 2010-07-25 17:09:21 +02:00
commit 68f02c65ef
22 changed files with 44 additions and 38 deletions

View File

@ -452,7 +452,7 @@ my_bool maria_test_if_sort_rep(MARIA_HA *info, ha_rows rows, ulonglong key_map,
int maria_init_bulk_insert(MARIA_HA *info, ulong cache_size, ha_rows rows); int maria_init_bulk_insert(MARIA_HA *info, ulong cache_size, ha_rows rows);
void maria_flush_bulk_insert(MARIA_HA *info, uint inx); void maria_flush_bulk_insert(MARIA_HA *info, uint inx);
void maria_end_bulk_insert(MARIA_HA *info, my_bool table_will_be_deleted); void maria_end_bulk_insert(MARIA_HA *info);
int maria_assign_to_pagecache(MARIA_HA *info, ulonglong key_map, int maria_assign_to_pagecache(MARIA_HA *info, ulonglong key_map,
PAGECACHE *key_cache); PAGECACHE *key_cache);
void maria_change_pagecache(PAGECACHE *old_key_cache, void maria_change_pagecache(PAGECACHE *old_key_cache,

View File

@ -4232,7 +4232,7 @@ void ha_ndbcluster::start_bulk_insert(ha_rows rows)
/** /**
End of an insert. End of an insert.
*/ */
int ha_ndbcluster::end_bulk_insert(bool abort) int ha_ndbcluster::end_bulk_insert()
{ {
int error= 0; int error= 0;
DBUG_ENTER("end_bulk_insert"); DBUG_ENTER("end_bulk_insert");

View File

@ -322,7 +322,7 @@ class ha_ndbcluster: public handler
double scan_time(); double scan_time();
ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key); ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key);
void start_bulk_insert(ha_rows rows); void start_bulk_insert(ha_rows rows);
int end_bulk_insert(bool abort); int end_bulk_insert();
static Thd_ndb* seize_thd_ndb(); static Thd_ndb* seize_thd_ndb();
static void release_thd_ndb(Thd_ndb* thd_ndb); static void release_thd_ndb(Thd_ndb* thd_ndb);

View File

@ -3416,18 +3416,17 @@ ha_rows ha_partition::guess_bulk_insert_rows()
SYNOPSIS SYNOPSIS
end_bulk_insert() end_bulk_insert()
abort 1 if table will be deleted (error condition)
RETURN VALUE RETURN VALUE
>0 Error code >0 Error code
0 Success 0 Success
Note: end_bulk_insert can be called without start_bulk_insert Note: end_bulk_insert can be called without start_bulk_insert
being called, see bug¤44108. being called, see bug#44108.
*/ */
int ha_partition::end_bulk_insert(bool abort) int ha_partition::end_bulk_insert()
{ {
int error= 0; int error= 0;
uint i; uint i;
@ -3440,7 +3439,7 @@ int ha_partition::end_bulk_insert(bool abort)
{ {
int tmp; int tmp;
if (bitmap_is_set(&m_bulk_insert_started, i) && if (bitmap_is_set(&m_bulk_insert_started, i) &&
(tmp= m_file[i]->ha_end_bulk_insert(abort))) (tmp= m_file[i]->ha_end_bulk_insert()))
error= tmp; error= tmp;
} }
bitmap_clear_all(&m_bulk_insert_started); bitmap_clear_all(&m_bulk_insert_started);

View File

@ -364,7 +364,7 @@ public:
virtual int delete_row(const uchar * buf); virtual int delete_row(const uchar * buf);
virtual int delete_all_rows(void); virtual int delete_all_rows(void);
virtual void start_bulk_insert(ha_rows rows); virtual void start_bulk_insert(ha_rows rows);
virtual int end_bulk_insert(bool); virtual int end_bulk_insert();
private: private:
ha_rows guess_bulk_insert_rows(); ha_rows guess_bulk_insert_rows();
void start_part_bulk_insert(THD *thd, uint part_id); void start_part_bulk_insert(THD *thd, uint part_id);

View File

@ -1382,10 +1382,10 @@ public:
estimation_rows_to_insert= rows; estimation_rows_to_insert= rows;
start_bulk_insert(rows); start_bulk_insert(rows);
} }
int ha_end_bulk_insert(bool abort) int ha_end_bulk_insert()
{ {
estimation_rows_to_insert= 0; estimation_rows_to_insert= 0;
return end_bulk_insert(abort); return end_bulk_insert();
} }
int ha_bulk_update_row(const uchar *old_data, uchar *new_data, int ha_bulk_update_row(const uchar *old_data, uchar *new_data,
uint *dup_key_found); uint *dup_key_found);
@ -2062,7 +2062,7 @@ private:
virtual int repair(THD* thd, HA_CHECK_OPT* check_opt) virtual int repair(THD* thd, HA_CHECK_OPT* check_opt)
{ return HA_ADMIN_NOT_IMPLEMENTED; } { return HA_ADMIN_NOT_IMPLEMENTED; }
virtual void start_bulk_insert(ha_rows rows) {} virtual void start_bulk_insert(ha_rows rows) {}
virtual int end_bulk_insert(bool abort) { return 0; } virtual int end_bulk_insert() { return 0; }
virtual int index_read(uchar * buf, const uchar * key, uint key_len, virtual int index_read(uchar * buf, const uchar * key, uint key_len,
enum ha_rkey_function find_flag) enum ha_rkey_function find_flag)
{ return HA_ERR_WRONG_COMMAND; } { return HA_ERR_WRONG_COMMAND; }

View File

@ -8521,7 +8521,7 @@ Write_rows_log_event::do_after_row_operations(const Slave_reporting_capability *
ultimately. Still todo: fix ultimately. Still todo: fix
*/ */
} }
if ((local_error= m_table->file->ha_end_bulk_insert(0))) if ((local_error= m_table->file->ha_end_bulk_insert()))
{ {
m_table->file->print_error(local_error, MYF(0)); m_table->file->print_error(local_error, MYF(0));
} }

View File

@ -948,7 +948,7 @@ int Write_rows_log_event_old::do_after_row_operations(TABLE *table, int error)
fires bug#27077 fires bug#27077
todo: explain or fix todo: explain or fix
*/ */
if ((local_error= table->file->ha_end_bulk_insert(0))) if ((local_error= table->file->ha_end_bulk_insert()))
{ {
table->file->print_error(local_error, MYF(0)); table->file->print_error(local_error, MYF(0));
} }
@ -2644,7 +2644,7 @@ Write_rows_log_event_old::do_after_row_operations(const Slave_reporting_capabili
fires bug#27077 fires bug#27077
todo: explain or fix todo: explain or fix
*/ */
if ((local_error= m_table->file->ha_end_bulk_insert(0))) if ((local_error= m_table->file->ha_end_bulk_insert()))
{ {
m_table->file->print_error(local_error, MYF(0)); m_table->file->print_error(local_error, MYF(0));
} }

View File

@ -881,7 +881,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
auto_inc values from the delayed_insert thread as they share TABLE. auto_inc values from the delayed_insert thread as they share TABLE.
*/ */
table->file->ha_release_auto_increment(); table->file->ha_release_auto_increment();
if (using_bulk_insert && table->file->ha_end_bulk_insert(0) && !error) if (using_bulk_insert && table->file->ha_end_bulk_insert() && !error)
{ {
table->file->print_error(my_errno,MYF(0)); table->file->print_error(my_errno,MYF(0));
error=1; error=1;
@ -3288,7 +3288,7 @@ bool select_insert::send_eof()
DBUG_PRINT("enter", ("trans_table=%d, table_type='%s'", DBUG_PRINT("enter", ("trans_table=%d, table_type='%s'",
trans_table, table->file->table_type())); trans_table, table->file->table_type()));
error= (!thd->prelocked_mode) ? table->file->ha_end_bulk_insert(0) : 0; error= (!thd->prelocked_mode) ? table->file->ha_end_bulk_insert() : 0;
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE); table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE);
@ -3371,7 +3371,7 @@ void select_insert::abort() {
before. before.
*/ */
if (!thd->prelocked_mode) if (!thd->prelocked_mode)
table->file->ha_end_bulk_insert(0); table->file->ha_end_bulk_insert();
/* /*
If at least one row has been inserted/modified and will stay in If at least one row has been inserted/modified and will stay in

View File

@ -432,7 +432,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
error= read_sep_field(thd, info, table_list, fields_vars, error= read_sep_field(thd, info, table_list, fields_vars,
set_fields, set_values, read_info, set_fields, set_values, read_info,
*enclosed, skip_lines, ignore); *enclosed, skip_lines, ignore);
if (!thd->prelocked_mode && table->file->ha_end_bulk_insert(0) && !error) if (!thd->prelocked_mode && table->file->ha_end_bulk_insert() && !error)
{ {
table->file->print_error(my_errno, MYF(0)); table->file->print_error(my_errno, MYF(0));
error= 1; error= 1;

View File

@ -7959,7 +7959,7 @@ err:
if (error > 0) if (error > 0)
to->file->extra(HA_EXTRA_PREPARE_FOR_DROP); to->file->extra(HA_EXTRA_PREPARE_FOR_DROP);
if (errpos >= 3 && to->file->ha_end_bulk_insert(error > 1) && error <= 0) if (errpos >= 3 && to->file->ha_end_bulk_insert() && error <= 0)
{ {
to->file->print_error(my_errno,MYF(0)); to->file->print_error(my_errno,MYF(0));
error= 1; error= 1;

View File

@ -1555,7 +1555,7 @@ void ha_archive::start_bulk_insert(ha_rows rows)
Other side of start_bulk_insert, is end_bulk_insert. Here we turn off the bulk insert Other side of start_bulk_insert, is end_bulk_insert. Here we turn off the bulk insert
flag, and set the share dirty so that the next select will call sync for us. flag, and set the share dirty so that the next select will call sync for us.
*/ */
int ha_archive::end_bulk_insert(bool table_will_be_deleted) int ha_archive::end_bulk_insert()
{ {
DBUG_ENTER("ha_archive::end_bulk_insert"); DBUG_ENTER("ha_archive::end_bulk_insert");
bulk_insert= FALSE; bulk_insert= FALSE;

View File

@ -134,7 +134,7 @@ public:
int optimize(THD* thd, HA_CHECK_OPT* check_opt); int optimize(THD* thd, HA_CHECK_OPT* check_opt);
int repair(THD* thd, HA_CHECK_OPT* check_opt); int repair(THD* thd, HA_CHECK_OPT* check_opt);
void start_bulk_insert(ha_rows rows); void start_bulk_insert(ha_rows rows);
int end_bulk_insert(bool table_will_be_deleted); int end_bulk_insert();
enum row_type get_row_type() const enum row_type get_row_type() const
{ {
return ROW_TYPE_COMPRESSED; return ROW_TYPE_COMPRESSED;

View File

@ -1983,12 +1983,12 @@ void ha_federated::start_bulk_insert(ha_rows rows)
@retval != 0 Error occured at remote server. Also sets my_errno. @retval != 0 Error occured at remote server. Also sets my_errno.
*/ */
int ha_federated::end_bulk_insert(bool abort) int ha_federated::end_bulk_insert()
{ {
int error= 0; int error= 0;
DBUG_ENTER("ha_federated::end_bulk_insert"); DBUG_ENTER("ha_federated::end_bulk_insert");
if (!abort && bulk_insert.str && bulk_insert.length) if (!table_will_be_deleted && bulk_insert.str && bulk_insert.length)
{ {
if (real_query(bulk_insert.str, bulk_insert.length)) if (real_query(bulk_insert.str, bulk_insert.length))
error= stash_remote_error(); error= stash_remote_error();
@ -2905,6 +2905,8 @@ int ha_federated::extra(ha_extra_function operation)
case HA_EXTRA_INSERT_WITH_UPDATE: case HA_EXTRA_INSERT_WITH_UPDATE:
insert_dup_update= TRUE; insert_dup_update= TRUE;
break; break;
case HA_EXTRA_PREPARE_FOR_DROP:
table_will_be_deleted = TRUE;
default: default:
/* do nothing */ /* do nothing */
DBUG_PRINT("info",("unhandled operation: %d", (uint) operation)); DBUG_PRINT("info",("unhandled operation: %d", (uint) operation));
@ -3305,6 +3307,7 @@ int ha_federated::external_lock(THD *thd, int lock_type)
} }
} }
#endif /* XXX_SUPERCEDED_BY_WL2952 */ #endif /* XXX_SUPERCEDED_BY_WL2952 */
table_will_be_deleted = FALSE;
DBUG_RETURN(error); DBUG_RETURN(error);
} }

View File

@ -88,7 +88,7 @@ class ha_federated: public handler
Array of all stored results we get during a query execution. Array of all stored results we get during a query execution.
*/ */
DYNAMIC_ARRAY results; DYNAMIC_ARRAY results;
bool position_called; bool position_called, table_will_be_deleted;
uint fetch_num; // stores the fetch num uint fetch_num; // stores the fetch num
MYSQL_ROW_OFFSET current_position; // Current position used by ::position() MYSQL_ROW_OFFSET current_position; // Current position used by ::position()
int remote_error_number; int remote_error_number;
@ -210,7 +210,7 @@ public:
int close(void); // required int close(void); // required
void start_bulk_insert(ha_rows rows); void start_bulk_insert(ha_rows rows);
int end_bulk_insert(bool abort); int end_bulk_insert();
int write_row(uchar *buf); int write_row(uchar *buf);
int update_row(const uchar *old_data, uchar *new_data); int update_row(const uchar *old_data, uchar *new_data);
int delete_row(const uchar *buf); int delete_row(const uchar *buf);

View File

@ -2143,12 +2143,12 @@ void ha_federatedx::start_bulk_insert(ha_rows rows)
@retval != 0 Error occured at remote server. Also sets my_errno. @retval != 0 Error occured at remote server. Also sets my_errno.
*/ */
int ha_federatedx::end_bulk_insert(bool abort) int ha_federatedx::end_bulk_insert()
{ {
int error= 0; int error= 0;
DBUG_ENTER("ha_federatedx::end_bulk_insert"); DBUG_ENTER("ha_federatedx::end_bulk_insert");
if (bulk_insert.str && bulk_insert.length && !abort) if (bulk_insert.str && bulk_insert.length && !table_will_be_deleted)
{ {
if ((error= txn->acquire(share, FALSE, &io))) if ((error= txn->acquire(share, FALSE, &io)))
DBUG_RETURN(error); DBUG_RETURN(error);
@ -3082,6 +3082,9 @@ int ha_federatedx::extra(ha_extra_function operation)
case HA_EXTRA_INSERT_WITH_UPDATE: case HA_EXTRA_INSERT_WITH_UPDATE:
insert_dup_update= TRUE; insert_dup_update= TRUE;
break; break;
case HA_EXTRA_PREPARE_FOR_DROP:
table_will_be_deleted = TRUE;
break;
default: default:
/* do nothing */ /* do nothing */
DBUG_PRINT("info",("unhandled operation: %d", (uint) operation)); DBUG_PRINT("info",("unhandled operation: %d", (uint) operation));
@ -3391,6 +3394,7 @@ int ha_federatedx::external_lock(MYSQL_THD thd, int lock_type)
txn->release(&io); txn->release(&io);
else else
{ {
table_will_be_deleted = FALSE;
txn= get_txn(thd); txn= get_txn(thd);
if (!(error= txn->acquire(share, lock_type == F_RDLCK, &io)) && if (!(error= txn->acquire(share, lock_type == F_RDLCK, &io)) &&
(lock_type == F_WRLCK || !io->is_autocommit())) (lock_type == F_WRLCK || !io->is_autocommit()))

View File

@ -259,7 +259,7 @@ class ha_federatedx: public handler
int remote_error_number; int remote_error_number;
char remote_error_buf[FEDERATEDX_QUERY_BUFFER_SIZE]; char remote_error_buf[FEDERATEDX_QUERY_BUFFER_SIZE];
bool ignore_duplicates, replace_duplicates; bool ignore_duplicates, replace_duplicates;
bool insert_dup_update; bool insert_dup_update, table_will_be_deleted;
DYNAMIC_STRING bulk_insert; DYNAMIC_STRING bulk_insert;
private: private:
@ -379,7 +379,7 @@ public:
int close(void); // required int close(void); // required
void start_bulk_insert(ha_rows rows); void start_bulk_insert(ha_rows rows);
int end_bulk_insert(bool abort); int end_bulk_insert();
int write_row(uchar *buf); int write_row(uchar *buf);
int update_row(const uchar *old_data, uchar *new_data); int update_row(const uchar *old_data, uchar *new_data);
int delete_row(const uchar *buf); int delete_row(const uchar *buf);

View File

@ -1980,14 +1980,14 @@ void ha_maria::start_bulk_insert(ha_rows rows)
!= 0 Error != 0 Error
*/ */
int ha_maria::end_bulk_insert(bool table_will_be_deleted) int ha_maria::end_bulk_insert()
{ {
int err; int err;
DBUG_ENTER("ha_maria::end_bulk_insert"); DBUG_ENTER("ha_maria::end_bulk_insert");
maria_end_bulk_insert(file, table_will_be_deleted); maria_end_bulk_insert(file);
if ((err= maria_extra(file, HA_EXTRA_NO_CACHE, 0))) if ((err= maria_extra(file, HA_EXTRA_NO_CACHE, 0)))
goto end; goto end;
if (can_enable_indexes && !table_will_be_deleted) if (can_enable_indexes && !file->s->deleting)
err= enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); err= enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
end: end:
if (bulk_insert_single_undo != BULK_INSERT_NONE) if (bulk_insert_single_undo != BULK_INSERT_NONE)

View File

@ -123,7 +123,7 @@ public:
int enable_indexes(uint mode); int enable_indexes(uint mode);
int indexes_are_disabled(void); int indexes_are_disabled(void);
void start_bulk_insert(ha_rows rows); void start_bulk_insert(ha_rows rows);
int end_bulk_insert(bool abort); int end_bulk_insert();
ha_rows records_in_range(uint inx, key_range * min_key, key_range * max_key); ha_rows records_in_range(uint inx, key_range * min_key, key_range * max_key);
void update_create_info(HA_CREATE_INFO * create_info); void update_create_info(HA_CREATE_INFO * create_info);
int create(const char *name, TABLE * form, HA_CREATE_INFO * create_info); int create(const char *name, TABLE * form, HA_CREATE_INFO * create_info);

View File

@ -1755,7 +1755,7 @@ void maria_flush_bulk_insert(MARIA_HA *info, uint inx)
} }
} }
void maria_end_bulk_insert(MARIA_HA *info, my_bool abort) void maria_end_bulk_insert(MARIA_HA *info)
{ {
DBUG_ENTER("maria_end_bulk_insert"); DBUG_ENTER("maria_end_bulk_insert");
if (info->bulk_insert) if (info->bulk_insert)
@ -1765,7 +1765,7 @@ void maria_end_bulk_insert(MARIA_HA *info, my_bool abort)
{ {
if (is_tree_inited(&info->bulk_insert[i])) if (is_tree_inited(&info->bulk_insert[i]))
{ {
if (abort) if (info->s->deleting)
reset_free_element(&info->bulk_insert[i]); reset_free_element(&info->bulk_insert[i]);
delete_tree(&info->bulk_insert[i]); delete_tree(&info->bulk_insert[i]);
} }

View File

@ -1589,11 +1589,11 @@ void ha_myisam::start_bulk_insert(ha_rows rows)
!= 0 Error != 0 Error
*/ */
int ha_myisam::end_bulk_insert(bool abort) int ha_myisam::end_bulk_insert()
{ {
mi_end_bulk_insert(file); mi_end_bulk_insert(file);
int err=mi_extra(file, HA_EXTRA_NO_CACHE, 0); int err=mi_extra(file, HA_EXTRA_NO_CACHE, 0);
if (!err && !abort) if (!err && !file->s->deleting)
{ {
if (can_enable_indexes) if (can_enable_indexes)
{ {

View File

@ -107,7 +107,7 @@ class ha_myisam: public handler
int enable_indexes(uint mode); int enable_indexes(uint mode);
int indexes_are_disabled(void); int indexes_are_disabled(void);
void start_bulk_insert(ha_rows rows); void start_bulk_insert(ha_rows rows);
int end_bulk_insert(bool abort); int end_bulk_insert();
ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key); ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key);
void update_create_info(HA_CREATE_INFO *create_info); void update_create_info(HA_CREATE_INFO *create_info);
int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info);