summaryrefslogtreecommitdiff
path: root/sql/sql_load.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_load.cc')
-rw-r--r--sql/sql_load.cc50
1 files changed, 29 insertions, 21 deletions
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index afc2f121167..2869011e313 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, 2018, MariaDB Corporation.
+ Copyright (c) 2010, 2020, 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
@@ -190,7 +190,7 @@ class READ_INFO: public Load_data_param
bool read_mbtail(String *str)
{
int chlen;
- if ((chlen= my_charlen(charset(), str->end() - 1, str->end())) == 1)
+ if ((chlen= charset()->charlen(str->end() - 1, str->end())) == 1)
return false; // Single byte character found
for (uint32 length0= str->length() - 1 ; MY_CS_IS_TOOSMALL(chlen); )
{
@@ -201,7 +201,7 @@ class READ_INFO: public Load_data_param
return true; // EOF
}
str->append(chr);
- chlen= my_charlen(charset(), str->ptr() + length0, str->end());
+ chlen= charset()->charlen(str->ptr() + length0, str->end());
if (chlen == MY_CS_ILSEQ)
{
/**
@@ -391,6 +391,7 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list,
DBUG_RETURN(TRUE);
if (thd->lex->handle_list_of_derived(table_list, DT_PREPARE))
DBUG_RETURN(TRUE);
+
if (setup_tables_and_check_access(thd,
&thd->lex->first_select_lex()->context,
&thd->lex->first_select_lex()->
@@ -435,11 +436,14 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list,
}
table= table_list->table;
- transactional_table= table->file->has_transactions();
+ transactional_table= table->file->has_transactions_and_rollback();
#ifndef EMBEDDED_LIBRARY
is_concurrent= (table_list->lock_type == TL_WRITE_CONCURRENT_INSERT);
#endif
+ if (check_duplic_insert_without_overlaps(thd, table, handle_duplicates) != 0)
+ DBUG_RETURN(true);
+
if (!fields_vars.elements)
{
Field_iterator_table_ref field_iterator;
@@ -647,10 +651,14 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list,
thd->abort_on_warning= !ignore && thd->is_strict_mode();
- if ((table_list->table->file->ha_table_flags() & HA_DUPLICATE_POS) &&
- (error= table_list->table->file->ha_rnd_init_with_error(0)))
- goto err;
-
+ bool create_lookup_handler= handle_duplicates != DUP_ERROR;
+ if ((table_list->table->file->ha_table_flags() & HA_DUPLICATE_POS))
+ {
+ create_lookup_handler= true;
+ if ((error= table_list->table->file->ha_rnd_init_with_error(0)))
+ goto err;
+ }
+ table->file->prepare_for_insert(create_lookup_handler);
thd_progress_init(thd, 2);
if (table_list->table->validate_default_values_of_unset_fields(thd))
{
@@ -731,7 +739,7 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list,
/* since there is already an error, the possible error of
writing binary log will be ignored */
- if (thd->transaction.stmt.modified_non_trans_table)
+ if (thd->transaction->stmt.modified_non_trans_table)
(void) write_execute_load_query_log_event(thd, ex,
table_list->db.str,
table_list->table_name.str,
@@ -756,10 +764,10 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list,
(ulong) (info.records - info.copied),
(long) thd->get_stmt_da()->current_statement_warn_count());
- if (thd->transaction.stmt.modified_non_trans_table)
- thd->transaction.all.modified_non_trans_table= TRUE;
- thd->transaction.all.m_unsafe_rollback_flags|=
- (thd->transaction.stmt.m_unsafe_rollback_flags & THD_TRANS::DID_WAIT);
+ if (thd->transaction->stmt.modified_non_trans_table)
+ thd->transaction->all.modified_non_trans_table= TRUE;
+ thd->transaction->all.m_unsafe_rollback_flags|=
+ (thd->transaction->stmt.m_unsafe_rollback_flags & THD_TRANS::DID_WAIT);
#ifndef EMBEDDED_LIBRARY
if (mysql_bin_log.is_open())
{
@@ -808,7 +816,7 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list,
my_ok(thd, info.copied + info.deleted, 0L, name);
err:
DBUG_ASSERT(transactional_table || !(info.copied || info.deleted) ||
- thd->transaction.stmt.modified_non_trans_table);
+ thd->transaction->stmt.modified_non_trans_table);
table->file->ha_release_auto_increment();
table->auto_increment_field_not_null= FALSE;
thd->abort_on_warning= 0;
@@ -1204,7 +1212,7 @@ read_xml_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
bool no_trans_update_stmt;
DBUG_ENTER("read_xml_field");
- no_trans_update_stmt= !table->file->has_transactions();
+ no_trans_update_stmt= !table->file->has_transactions_and_rollback();
for ( ; ; it.rewind())
{
@@ -1292,7 +1300,7 @@ read_xml_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
We don't need to reset auto-increment field since we are restoring
its default value at the beginning of each loop iteration.
*/
- thd->transaction.stmt.modified_non_trans_table= no_trans_update_stmt;
+ thd->transaction->stmt.modified_non_trans_table= no_trans_update_stmt;
thd->get_stmt_da()->inc_current_row_for_warning();
continue_loop:;
}
@@ -1587,7 +1595,7 @@ int READ_INFO::read_field()
}
}
data.append(chr);
- if (use_mb(charset()) && read_mbtail(&data))
+ if (charset()->use_mb() && read_mbtail(&data))
goto found_eof;
}
/*
@@ -1686,8 +1694,8 @@ int READ_INFO::next_line()
if (getbyte(&buf[0]))
return 1; // EOF
- if (use_mb(charset()) &&
- (chlen= my_charlen(charset(), buf, buf + 1)) != 1)
+ if (charset()->use_mb() &&
+ (chlen= charset()->charlen(buf, buf + 1)) != 1)
{
uint i;
for (i= 1; MY_CS_IS_TOOSMALL(chlen); )
@@ -1696,7 +1704,7 @@ int READ_INFO::next_line()
DBUG_ASSERT(chlen != 1);
if (getbyte(&buf[i++]))
return 1; // EOF
- chlen= my_charlen(charset(), buf, buf + i);
+ chlen= charset()->charlen(buf, buf + i);
}
/*
@@ -1867,7 +1875,7 @@ int READ_INFO::read_value(int delim, String *val)
else
{
val->append(chr);
- if (use_mb(charset()) && read_mbtail(val))
+ if (charset()->use_mb() && read_mbtail(val))
return my_b_EOF;
}
}