diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2018-01-30 20:42:42 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2018-01-30 20:47:12 +0200 |
commit | 0c1f22061177fab63274a4429e38a4652964d7b8 (patch) | |
tree | 70cf3ff2abd915034d879a4236860fa986e77dc5 /sql | |
parent | 6d390bab4a0695fedeead35e78111e1033f7b3df (diff) | |
parent | 0ba6aaf030f77af064a06bd033893491557eeee6 (diff) | |
download | mariadb-git-0c1f22061177fab63274a4429e38a4652964d7b8.tar.gz |
Merge 10.2 into bb-10.2-ext
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_partition.cc | 6 | ||||
-rw-r--r-- | sql/log.h | 1 | ||||
-rw-r--r-- | sql/sql_load.cc | 44 | ||||
-rw-r--r-- | sql/sql_table.cc | 4 |
4 files changed, 53 insertions, 2 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 843b854e5f7..4a40e0c1fc4 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2005, 2017, Oracle and/or its affiliates. - Copyright (c) 2009, 2017, MariaDB + Copyright (c) 2009, 2018, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -7260,6 +7260,10 @@ int ha_partition::extra(enum ha_extra_function operation) */ case HA_EXTRA_MARK_AS_LOG_TABLE: DBUG_RETURN(ER_UNSUPORTED_LOG_ENGINE); + case HA_EXTRA_BEGIN_ALTER_COPY: + case HA_EXTRA_END_ALTER_COPY: + case HA_EXTRA_FAKE_START_STMT: + DBUG_RETURN(loop_extra(operation)); default: { /* Temporary crash to discover what is wrong */ diff --git a/sql/log.h b/sql/log.h index a5548ef4e60..a7c28db4ac5 100644 --- a/sql/log.h +++ b/sql/log.h @@ -1103,6 +1103,7 @@ void make_default_log_name(char **out, const char* log_ext, bool once); void binlog_reset_cache(THD *thd); extern MYSQL_PLUGIN_IMPORT MYSQL_BIN_LOG mysql_bin_log; +extern handlerton *binlog_hton; extern LOGGER logger; extern const char *log_bin_index; diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 2a389d68ef9..2f061b8377d 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2010, 2017, MariaDB Corporation + Copyright (c) 2010, 2018, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -97,6 +97,45 @@ public: #define GET (stack_pos != stack ? *--stack_pos : my_b_get(&cache)) #define PUSH(A) *(stack_pos++)=(A) +#ifdef WITH_WSREP +/** If requested by wsrep_load_data_splitting, commit and restart +the transaction after every 10,000 inserted rows. */ + +static bool wsrep_load_data_split(THD *thd, const TABLE *table, + const COPY_INFO &info) +{ + extern struct handlerton* innodb_hton_ptr; + + DBUG_ENTER("wsrep_load_data_split"); + + if (wsrep_load_data_splitting && wsrep_on(thd) + && info.records && !(info.records % 10000) + && thd->transaction.stmt.ha_list + && thd->transaction.stmt.ha_list->ht() == binlog_hton + && thd->transaction.stmt.ha_list->next() + && thd->transaction.stmt.ha_list->next()->ht() == innodb_hton_ptr + && !thd->transaction.stmt.ha_list->next()->next()) + { + WSREP_DEBUG("intermediate transaction commit in LOAD DATA"); + if (wsrep_run_wsrep_commit(thd, true) != WSREP_TRX_OK) DBUG_RETURN(true); + if (binlog_hton->commit(binlog_hton, thd, true)) DBUG_RETURN(true); + wsrep_post_commit(thd, true); + innodb_hton_ptr->commit(innodb_hton_ptr, thd, true); + table->file->extra(HA_EXTRA_FAKE_START_STMT); + } + + DBUG_RETURN(false); +} +# define WSREP_LOAD_DATA_SPLIT(thd,table,info) \ + if (wsrep_load_data_split(thd,table,info)) \ + { \ + table->auto_increment_field_not_null= FALSE; \ + DBUG_RETURN(1); \ + } +#else /* WITH_WSREP */ +#define WSREP_LOAD_DATA_SPLIT(thd,table,info) /* empty */ +#endif /* WITH_WSREP */ + class READ_INFO { File file; String data; /* Read buffer */ @@ -989,6 +1028,7 @@ read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, DBUG_RETURN(-1); } + WSREP_LOAD_DATA_SPLIT(thd, table, info); err= write_record(thd, table, &info); table->auto_increment_field_not_null= FALSE; if (err) @@ -1194,6 +1234,7 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, DBUG_RETURN(-1); } + WSREP_LOAD_DATA_SPLIT(thd, table, info); err= write_record(thd, table, &info); table->auto_increment_field_not_null= FALSE; if (err) @@ -1348,6 +1389,7 @@ read_xml_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, DBUG_RETURN(-1); } + WSREP_LOAD_DATA_SPLIT(thd, table, info); err= write_record(thd, table, &info); table->auto_increment_field_not_null= false; if (err) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 944f4c2a0af..9aa9b7becdb 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -9794,6 +9794,8 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, thd->progress.max_counter= from->file->records(); time_to_report_progress= MY_HOW_OFTEN_TO_WRITE/10; + if (!ignore) /* for now, InnoDB needs the undo log for ALTER IGNORE */ + to->file->extra(HA_EXTRA_BEGIN_ALTER_COPY); while (!(error=info.read_record(&info))) { @@ -9918,6 +9920,8 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, to->file->print_error(my_errno,MYF(0)); error= 1; } + if (!ignore) + to->file->extra(HA_EXTRA_END_ALTER_COPY); to->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); if (mysql_trans_commit_alter_copy_data(thd)) |