summaryrefslogtreecommitdiff
path: root/sql/sql_load.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2017-04-11 10:18:04 -0400
committerSergei Golubchik <serg@mariadb.org>2017-04-11 10:18:04 -0400
commit663068c6eea736a38eff9ac183326d6c7e4e239b (patch)
tree54927ab8209a73403320aac67b6172508caed7d6 /sql/sql_load.cc
parent5c579482eb2dd33c7fea80ea1ab412977606458a (diff)
parent6fa5e0814662d691be1a29bf88332348ec7c50c9 (diff)
downloadmariadb-git-663068c6eea736a38eff9ac183326d6c7e4e239b.tar.gz
Merge remote-tracking branch 'mysql/5.5' into 5.5mariadb-5.5.55
Diffstat (limited to 'sql/sql_load.cc')
-rw-r--r--sql/sql_load.cc78
1 files changed, 39 insertions, 39 deletions
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 4723c2b643d..dcbd9f180d1 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -979,7 +979,7 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
{
uint length;
uchar *pos;
- Item *real_item;
+ Item_field *real_item;
if (read_info.read_field())
break;
@@ -991,16 +991,26 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
pos=read_info.row_start;
length=(uint) (read_info.row_end-pos);
- real_item= item->real_item();
+ real_item= item->filed_for_view_update();
if ((!read_info.enclosed &&
(enclosed_length && length == 4 &&
!memcmp(pos, STRING_WITH_LEN("NULL")))) ||
(length == 1 && read_info.found_null))
{
- if (real_item->type() == Item::FIELD_ITEM)
+ if (item->type() == Item::STRING_ITEM)
{
- Field *field= ((Item_field *)real_item)->field;
+ ((Item_user_var_as_out_param *)item)->set_null_value(
+ read_info.read_charset);
+ }
+ else if (!real_item)
+ {
+ my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->name);
+ DBUG_RETURN(1);
+ }
+ else
+ {
+ Field *field= real_item->field;
if (field->reset())
{
my_error(ER_WARN_NULL_TO_NOTNULL, MYF(0), field->field_name,
@@ -1017,39 +1027,29 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
ER_WARN_NULL_TO_NOTNULL, 1);
}
}
- else if (item->type() == Item::STRING_ITEM)
- {
- ((Item_user_var_as_out_param *)item)->set_null_value(
- read_info.read_charset);
- }
- else
- {
- my_error(ER_LOAD_DATA_INVALID_COLUMN, MYF(0), item->full_name());
- DBUG_RETURN(1);
- }
continue;
}
- if (real_item->type() == Item::FIELD_ITEM)
- {
- Field *field= ((Item_field *)real_item)->field;
- field->set_notnull();
- read_info.row_end[0]=0; // Safe to change end marker
- if (field == table->next_number_field)
- table->auto_increment_field_not_null= TRUE;
- field->store((char*) pos, length, read_info.read_charset);
- }
- else if (item->type() == Item::STRING_ITEM)
+ if (item->type() == Item::STRING_ITEM)
{
((Item_user_var_as_out_param *)item)->set_value((char*) pos, length,
read_info.read_charset);
}
- else
+ else if (!real_item)
{
- my_error(ER_LOAD_DATA_INVALID_COLUMN, MYF(0), item->full_name());
+ my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->name);
DBUG_RETURN(1);
}
+ else
+ {
+ Field *field= real_item->field;
+ field->set_notnull();
+ read_info.row_end[0]=0; // Safe to change end marker
+ if (field == table->next_number_field)
+ table->auto_increment_field_not_null= TRUE;
+ field->store((char*) pos, length, read_info.read_charset);
+ }
}
if (thd->is_error())
@@ -1069,10 +1069,20 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
break;
for (; item ; item= it++)
{
- Item *real_item= item->real_item();
- if (real_item->type() == Item::FIELD_ITEM)
+ Item_field *real_item= item->filed_for_view_update();
+ if (item->type() == Item::STRING_ITEM)
+ {
+ ((Item_user_var_as_out_param *)item)->set_null_value(
+ read_info.read_charset);
+ }
+ else if (!real_item)
{
- Field *field= ((Item_field *)real_item)->field;
+ my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->name);
+ DBUG_RETURN(1);
+ }
+ else
+ {
+ Field *field= real_item->field;
if (field->reset())
{
my_error(ER_WARN_NULL_TO_NOTNULL, MYF(0),field->field_name,
@@ -1093,16 +1103,6 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
ER(ER_WARN_TOO_FEW_RECORDS),
thd->warning_info->current_row_for_warning());
}
- else if (item->type() == Item::STRING_ITEM)
- {
- ((Item_user_var_as_out_param *)item)->set_null_value(
- read_info.read_charset);
- }
- else
- {
- my_error(ER_LOAD_DATA_INVALID_COLUMN, MYF(0), item->full_name());
- DBUG_RETURN(1);
- }
}
}