[Commits] Rev 4351: MDEV-3940 Server crash or assertion `item->type() == Item::STRING_ITEM' failure on LOAD DATA through a view with statement binary logging in lp:~maria-captains/maria/5.5

Sergei Golubchik serg at mariadb.org
Thu Nov 13 19:37:29 EET 2014


At lp:~maria-captains/maria/5.5

------------------------------------------------------------
revno: 4351
revision-id: sergii at pisem.net-20141113173729-z2mb0j7j8aie16qf
parent: sergii at pisem.net-20141112093750-pu8ilsxoct0eb8jq
fixes bug: https://mariadb.atlassian.net/browse/MDEV-3940
committer: Sergei Golubchik <sergii at pisem.net>
branch nick: 5.5
timestamp: Thu 2014-11-13 18:37:29 +0100
message:
  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).
=== added file 'mysql-test/suite/binlog/r/load_data_stm_view.result'
--- a/mysql-test/suite/binlog/r/load_data_stm_view.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/binlog/r/load_data_stm_view.result	2014-11-13 17:37:29 +0000
@@ -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;

=== added file 'mysql-test/suite/binlog/t/load_data_stm_view.test'
--- a/mysql-test/suite/binlog/t/load_data_stm_view.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/binlog/t/load_data_stm_view.test	2014-11-13 17:37:29 +0000
@@ -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;

=== modified file 'sql/sql_load.cc'
--- a/sql/sql_load.cc	2014-06-03 07:55:08 +0000
+++ b/sql/sql_load.cc	2014-11-13 17:37:29 +0000
@@ -148,14 +148,8 @@ static int read_xml_field(THD *thd, COPY
                           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
 
   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
     {
       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
       {



More information about the commits mailing list