mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
MDEV-3940 Server crash or assertion `item->type() == Item::STRING_ITEM' failure on LOAD DATA through a view with statement binary logging
A "field" could be either an Item_field or (if loading into a view) an Item_direct_ref that references Item_field. Also: when iterating fields, use fields of the TABLE_LIST (table or view), not fields of a TABLE (actual underlying table - might have more columns).
This commit is contained in:
parent
241294b53a
commit
84f25c25f2
3 changed files with 54 additions and 12 deletions
22
mysql-test/suite/binlog/r/load_data_stm_view.result
Normal file
22
mysql-test/suite/binlog/r/load_data_stm_view.result
Normal file
|
@ -0,0 +1,22 @@
|
|||
create table t1 (i int, j int);
|
||||
create view v1 as select i from t1;
|
||||
LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/3940.data' INTO TABLE v1 (i);
|
||||
LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/3940.data' INTO TABLE v1;
|
||||
select * from v1;
|
||||
i
|
||||
1
|
||||
1
|
||||
show binlog events from <binlog_start>;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin.000001 # Query # # use `test`; create table t1 (i int, j int)
|
||||
master-bin.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select i from t1
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
|
||||
master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/3940.data' IGNORE INTO TABLE `v1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`i`) ;file_id=#
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
|
||||
master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/3940.data' IGNORE INTO TABLE `v1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`i`) ;file_id=#
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
drop view v1;
|
||||
drop table t1;
|
20
mysql-test/suite/binlog/t/load_data_stm_view.test
Normal file
20
mysql-test/suite/binlog/t/load_data_stm_view.test
Normal file
|
@ -0,0 +1,20 @@
|
|||
#
|
||||
# MDEV-3940 Server crash or assertion `item->type() == Item::STRING_ITEM' failure on LOAD DATA through a view with statement binary logging
|
||||
#
|
||||
|
||||
--source include/have_binlog_format_statement.inc
|
||||
|
||||
--write_file $MYSQLTEST_VARDIR/3940.data
|
||||
1
|
||||
EOF
|
||||
|
||||
create table t1 (i int, j int);
|
||||
create view v1 as select i from t1;
|
||||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||
--eval LOAD DATA LOCAL INFILE '$MYSQLTEST_VARDIR/3940.data' INTO TABLE v1 (i)
|
||||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||
--eval LOAD DATA LOCAL INFILE '$MYSQLTEST_VARDIR/3940.data' INTO TABLE v1
|
||||
select * from v1;
|
||||
--source include/show_binlog_events.inc
|
||||
drop view v1;
|
||||
drop table t1;
|
|
@ -148,14 +148,8 @@ static int read_xml_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
|
|||
bool ignore_check_option_errors);
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex,
|
||||
const char* db_arg, /* table's database */
|
||||
const char* table_name_arg,
|
||||
bool is_concurrent,
|
||||
enum enum_duplicates duplicates,
|
||||
bool ignore,
|
||||
bool transactional_table,
|
||||
int errocode);
|
||||
static bool write_execute_load_query_log_event(THD *, sql_exchange*, const
|
||||
char*, const char*, bool, enum enum_duplicates, bool, bool, int);
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
||||
/*
|
||||
|
@ -283,9 +277,15 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
|
|||
|
||||
if (!fields_vars.elements)
|
||||
{
|
||||
Field **field;
|
||||
for (field=table->field; *field ; field++)
|
||||
fields_vars.push_back(new Item_field(*field));
|
||||
Field_iterator_table_ref field_iterator;
|
||||
field_iterator.set(table_list);
|
||||
for (; !field_iterator.end_of_fields(); field_iterator.next())
|
||||
{
|
||||
Item *item;
|
||||
if (!(item= field_iterator.create_item(thd)))
|
||||
DBUG_RETURN(TRUE);
|
||||
fields_vars.push_back(item->real_item());
|
||||
}
|
||||
bitmap_set_all(table->write_set);
|
||||
table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
|
||||
/*
|
||||
|
@ -737,7 +737,7 @@ static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex,
|
|||
{
|
||||
if (n++)
|
||||
query_str.append(", ");
|
||||
if (item->type() == Item::FIELD_ITEM)
|
||||
if (item->real_type() == Item::FIELD_ITEM)
|
||||
append_identifier(thd, &query_str, item->name, strlen(item->name));
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue