summaryrefslogtreecommitdiff
path: root/sql/sql_load.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-03-19 16:04:59 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2019-03-19 16:04:59 +0200
commit117291db8b35ddb4cd8c89ee4d8de888160b7163 (patch)
tree05041fcbc5a4c5c14531d148505216cb88add73c /sql/sql_load.cc
parent26e5bff00318272c717561e7b980036df3332d7b (diff)
parenta77e2668667e46d96c445a4a9a8325b7fe9461b3 (diff)
downloadmariadb-git-117291db8b35ddb4cd8c89ee4d8de888160b7163.tar.gz
Merge 10.2 into 10.3
Diffstat (limited to 'sql/sql_load.cc')
-rw-r--r--sql/sql_load.cc48
1 files changed, 29 insertions, 19 deletions
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index b7e110e4b95..92ef222c8b7 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -41,6 +41,7 @@
#include "sql_trigger.h"
#include "sql_derived.h"
#include "sql_show.h"
+#include "debug_sync.h"
extern "C" int _my_b_net_read(IO_CACHE *info, uchar *Buffer, size_t Count);
@@ -119,16 +120,26 @@ static bool wsrep_load_data_split(THD *thd, const TABLE *table,
if (hton->db_type != DB_TYPE_INNODB)
DBUG_RETURN(false);
WSREP_DEBUG("intermediate transaction commit in LOAD DATA");
+ wsrep_set_load_multi_commit(thd, true);
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);
hton->commit(hton, thd, true);
+ wsrep_set_load_multi_commit(thd, false);
+ DEBUG_SYNC(thd, "intermediate_transaction_commit");
table->file->extra(HA_EXTRA_FAKE_START_STMT);
}
DBUG_RETURN(false);
}
-# define WSREP_LOAD_DATA_SPLIT(thd,table,info) \
+/*
+ If the commit fails, then an early return from
+ the function occurs there and therefore we need
+ to reset the table->auto_increment_field_not_null
+ flag, which is usually reset after calling
+ the write_record():
+*/
+#define WSREP_LOAD_DATA_SPLIT(thd,table,info) \
if (wsrep_load_data_split(thd,table,info)) \
{ \
table->auto_increment_field_not_null= FALSE; \
@@ -138,6 +149,14 @@ static bool wsrep_load_data_split(THD *thd, const TABLE *table,
#define WSREP_LOAD_DATA_SPLIT(thd,table,info) /* empty */
#endif /* WITH_WSREP */
+#define WRITE_RECORD(thd,table,info) \
+ do { \
+ int err_= write_record(thd, table, &info); \
+ table->auto_increment_field_not_null= FALSE; \
+ if (err_) \
+ DBUG_RETURN(1); \
+ } while (0)
+
class READ_INFO: public Load_data_param
{
File file;
@@ -918,7 +937,7 @@ read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
List_iterator_fast<Item> it(fields_vars);
Item *item;
TABLE *table= table_list->table;
- bool err, progress_reports;
+ bool progress_reports;
ulonglong counter, time_to_report_progress;
DBUG_ENTER("read_fixed_length");
@@ -1010,11 +1029,8 @@ read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
}
WSREP_LOAD_DATA_SPLIT(thd, table, info);
- err= write_record(thd, table, &info);
- table->auto_increment_field_not_null= FALSE;
- if (err)
- DBUG_RETURN(1);
-
+ WRITE_RECORD(thd, table, info);
+
/*
We don't need to reset auto-increment field since we are restoring
its default value at the beginning of each loop iteration.
@@ -1047,7 +1063,7 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
Item *item;
TABLE *table= table_list->table;
uint enclosed_length;
- bool err, progress_reports;
+ bool progress_reports;
ulonglong counter, time_to_report_progress;
DBUG_ENTER("read_sep_field");
@@ -1153,10 +1169,8 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
}
WSREP_LOAD_DATA_SPLIT(thd, table, info);
- err= write_record(thd, table, &info);
- table->auto_increment_field_not_null= FALSE;
- if (err)
- DBUG_RETURN(1);
+ WRITE_RECORD(thd, table, info);
+
/*
We don't need to reset auto-increment field since we are restoring
its default value at the beginning of each loop iteration.
@@ -1200,7 +1214,6 @@ read_xml_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
for ( ; ; it.rewind())
{
- bool err;
if (thd->killed)
{
thd->send_kill_message();
@@ -1274,13 +1287,10 @@ read_xml_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
case VIEW_CHECK_ERROR:
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)
- DBUG_RETURN(1);
-
+ WRITE_RECORD(thd, table, info);
+
/*
We don't need to reset auto-increment field since we are restoring
its default value at the beginning of each loop iteration.