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.cc32
1 files changed, 20 insertions, 12 deletions
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 89cc3f8da64..3ce37170b48 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()->
@@ -440,6 +441,9 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list,
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))
{
@@ -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;
}
}