diff options
author | Alexander Barkov <bar@mariadb.org> | 2017-05-05 11:05:55 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2017-05-05 11:05:55 +0400 |
commit | db0917f68f2681882974afd53935aa8cba29c6b8 (patch) | |
tree | 32a9f600b1913a5193e94c09ec442ea2cac14e19 /sql/sql_load.cc | |
parent | 96247be1a0dfa3035580b53b1c27a7247a410713 (diff) | |
download | mariadb-git-db0917f68f2681882974afd53935aa8cba29c6b8.tar.gz |
MDEV-12696 Crash with LOAD XML and non-updatable VIEW column
Diffstat (limited to 'sql/sql_load.cc')
-rw-r--r-- | sql/sql_load.cc | 61 |
1 files changed, 24 insertions, 37 deletions
diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 6f0e97a61c9..95da65a1c63 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -431,7 +431,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, else tot_length+= field->field_length; } - else if (item->type() == Item::STRING_ITEM) + else if (item->get_load_data_out_param()) use_vars= 1; } if (use_blobs && !ex->line_term->length() && !field_term->length()) @@ -814,11 +814,7 @@ static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex, if (item->real_type() == Item::FIELD_ITEM) append_identifier(thd, &query_str, item->name, strlen(item->name)); else - { - /* Actually Item_user_var_as_out_param despite claiming STRING_ITEM. */ - DBUG_ASSERT(item->type() == Item::STRING_ITEM); - ((Item_user_var_as_out_param *)item)->print_for_load(thd, &query_str); - } + item->get_load_data_out_param()->load_data_print(thd, &query_str); } query_str.append(")"); } @@ -1062,6 +1058,7 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, uint length; uchar *pos; Item *real_item; + Load_data_out_param *out_param; if (read_info.read_field()) break; @@ -1104,18 +1101,11 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, } /* Do not auto-update this field. */ field->set_has_explicit_value(); - } - else if (item->type() == Item::STRING_ITEM) - { - ((Item_user_var_as_out_param *)item)->set_null_value( - read_info.read_charset); } + else if ((out_param= item->get_load_data_out_param_or_error())) + out_param->load_data_set_null_value(read_info.read_charset); else - { - my_error(ER_LOAD_DATA_INVALID_COLUMN, MYF(0), item->full_name()); DBUG_RETURN(1); - } - continue; } @@ -1129,16 +1119,11 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, field->store((char*) pos, length, read_info.read_charset); field->set_has_explicit_value(); } - else if (item->type() == Item::STRING_ITEM) - { - ((Item_user_var_as_out_param *)item)->set_value((char*) pos, length, - read_info.read_charset); - } + else if ((out_param= item->get_load_data_out_param_or_error())) + out_param->load_data_set_value((const char *) pos, length, + read_info.read_charset); else - { - my_error(ER_LOAD_DATA_INVALID_COLUMN, MYF(0), item->full_name()); DBUG_RETURN(1); - } } if (thd->is_error()) @@ -1158,6 +1143,7 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, break; for (; item ; item= it++) { + Load_data_out_param *out_param; Item *real_item= item->real_item(); if (real_item->type() == Item::FIELD_ITEM) { @@ -1183,16 +1169,10 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, ER_THD(thd, ER_WARN_TOO_FEW_RECORDS), thd->get_stmt_da()->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 if ((out_param= item->get_load_data_out_param_or_error())) + out_param->load_data_set_null_value(read_info.read_charset); else - { - my_error(ER_LOAD_DATA_INVALID_COLUMN, MYF(0), item->full_name()); DBUG_RETURN(1); - } } } @@ -1288,6 +1268,7 @@ read_xml_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, while ((item= it++)) { + Load_data_out_param *out_param; /* If this line is to be skipped we don't want to fill field or var */ if (skip_lines) continue; @@ -1319,14 +1300,15 @@ read_xml_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, /* Do not auto-update this field. */ field->set_has_explicit_value(); } + else if ((out_param= item->get_load_data_out_param_or_error())) + out_param->load_data_set_null_value(cs); else - ((Item_user_var_as_out_param *) item)->set_null_value(cs); + DBUG_RETURN(1); continue; } if (item->type() == Item::FIELD_ITEM) { - Field *field= ((Item_field *)item)->field; field->set_notnull(); if (field == table->next_number_field) @@ -1334,10 +1316,12 @@ read_xml_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, field->store((char *) tag->value.ptr(), tag->value.length(), cs); field->set_has_explicit_value(); } + else if ((out_param= item->get_load_data_out_param_or_error())) + out_param->load_data_set_value((const char *) tag->value.ptr(), + tag->value.length(), cs); else - ((Item_user_var_as_out_param *) item)->set_value( - (char *) tag->value.ptr(), - tag->value.length(), cs); + DBUG_RETURN(1); + } if (read_info.error) @@ -1357,6 +1341,7 @@ read_xml_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, for ( ; item; item= it++) { + Load_data_out_param *out_param; if (item->type() == Item::FIELD_ITEM) { /* @@ -1371,8 +1356,10 @@ read_xml_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, ER_THD(thd, ER_WARN_TOO_FEW_RECORDS), thd->get_stmt_da()->current_row_for_warning()); } + else if ((out_param= item->get_load_data_out_param_or_error())) + out_param->load_data_set_null_value(cs); else - ((Item_user_var_as_out_param *)item)->set_null_value(cs); + DBUG_RETURN(1); } } |