diff --git a/mysql-test/extra/rpl_tests/rpl_log.test b/mysql-test/extra/rpl_tests/rpl_log.test index d87030ba531..cfbc8110d06 100644 --- a/mysql-test/extra/rpl_tests/rpl_log.test +++ b/mysql-test/extra/rpl_tests/rpl_log.test @@ -125,6 +125,12 @@ show slave status; --error 1220 show binlog events in 'slave-bin.000005' from 4; +# The table drops caused Cluster Replication wrapper to fail as event ID would never be the same.# Moving drops here. + +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; + # # Bug #6880: LAST_INSERT_ID() within a statement # @@ -135,13 +141,10 @@ reset master; set insert_id=5; insert into t1 values (NULL, last_insert_id()), (NULL, last_insert_id()); --replace_result $VERSION VERSION +--replace_column 2 # 5 # show binlog events; select * from t1; drop table t1; # End of 4.1 tests -# The table drops caused Cluster Replication wrapper to fail as event ID would never be the same.# Moving drops here. -DROP TABLE t1; -DROP TABLE t2; -DROP TABLE t3; diff --git a/mysql-test/r/rpl_stm_log.result b/mysql-test/r/rpl_stm_log.result index 23639cb7a99..e0b1aa12c9b 100644 --- a/mysql-test/r/rpl_stm_log.result +++ b/mysql-test/r/rpl_stm_log.result @@ -95,6 +95,9 @@ Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File # 127.0.0.1 root MASTER_PORT 1 master-bin.000002 388 # # master-bin.000002 Yes Yes # 0 0 388 # None 0 No # show binlog events in 'slave-bin.000005' from 4; ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not find target log +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; create table t1(a int auto_increment primary key, b int); insert into t1 values (NULL, 1); reset master; @@ -102,16 +105,13 @@ set insert_id=5; insert into t1 values (NULL, last_insert_id()), (NULL, last_insert_id()); show binlog events; Log_name Pos Event_type Server_id End_log_pos Info -slave-bin.000001 4 Format_desc 2 98 Server ver: VERSION, Binlog ver: 4 -slave-bin.000001 98 Intvar 2 126 LAST_INSERT_ID=1 -slave-bin.000001 126 Intvar 2 154 INSERT_ID=5 -slave-bin.000001 154 Query 2 289 use `test`; insert into t1 values (NULL, last_insert_id()), (NULL, last_insert_id()) +slave-bin.000001 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4 +slave-bin.000001 # Intvar 2 # LAST_INSERT_ID=1 +slave-bin.000001 # Intvar 2 # INSERT_ID=5 +slave-bin.000001 # Query 2 # use `test`; insert into t1 values (NULL, last_insert_id()), (NULL, last_insert_id()) select * from t1; a b 1 1 5 1 6 1 drop table t1; -DROP TABLE t1; -DROP TABLE t2; -DROP TABLE t3; diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 1e72d12ba06..7e54acfae2a 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2726,74 +2726,10 @@ EXPLAIN SELECT * FROM t1 IGNORE INDEX (idx); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 EXPLAIN SELECT * FROM t1 IGNORE INDEX (a); -ERROR HY000: Key 'a' doesn't exist in table 't1' +ERROR 42000: Key 'a' doesn't exist in table 't1' EXPLAIN SELECT * FROM t1 FORCE INDEX (a); -ERROR HY000: Key 'a' doesn't exist in table 't1' -DROP TABLE t1; -CREATE TABLE t1 (a int, INDEX idx(a)); -INSERT INTO t1 VALUES (2), (3), (1); -EXPLAIN SELECT * FROM t1 IGNORE INDEX (idx); -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 3 -EXPLAIN SELECT * FROM t1 IGNORE INDEX (a); -ERROR 42000: Key 'a' doesn't exist in table 't1' ERROR 42000: Key 'a' doesn't exist in table 't1' DROP TABLE t1; -CREATE TABLE t1 ( city char(30) ); -INSERT INTO t1 VALUES ('London'); -INSERT INTO t1 VALUES ('Paris'); -SELECT * FROM t1 WHERE city='London'; -city -London -SELECT * FROM t1 WHERE city='london'; -city -London -EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where -SELECT * FROM t1 WHERE city='London' AND city='london'; -city -London -EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where -SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; -city -London -DROP TABLE t1; -create table t1 (a int(11) unsigned, b int(11) unsigned); -insert into t1 values (1,0), (1,1), (1,2); -select a-b from t1 order by 1; -a-b -0 -1 -18446744073709551615 -select a-b , (a-b < 0) from t1 order by 1; -a-b (a-b < 0) -0 0 -1 0 -18446744073709551615 0 -select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0; -d (a-b >= 0) b -1 1 0 -0 1 1 -18446744073709551615 1 2 -select cast((a - b) as unsigned) from t1 order by 1; -cast((a - b) as unsigned) -0 -1 -18446744073709551615 -drop table t1; -create table t1 (a int(11)); -select all all * from t1; -a -select distinct distinct * from t1; -a -select all distinct * from t1; -ERROR HY000: Incorrect usage of ALL and DISTINCT -select distinct all * from t1; -ERROR HY000: Incorrect usage of ALL and DISTINCT -drop table t1; CREATE TABLE t1 ( K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000', diff --git a/sql/field.cc b/sql/field.cc index df735c59e08..af81214adda 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -50,8 +50,8 @@ const char field_separator=','; #define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \ ((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1))) -#define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table->read_set || bitmap_is_set(table->read_set, field_index)) -#define ASSERT_COLUMN_MARKED_FOR_WRITE DBUG_ASSERT(!table->write_set || bitmap_is_set(table->write_set, field_index)) +#define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))) +#define ASSERT_COLUMN_MARKED_FOR_WRITE DBUG_ASSERT(!table || (!table->write_set || bitmap_is_set(table->write_set, field_index))) /* Rules for merging different types of fields in UNION diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index a3464c3bc25..3bff7878f02 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -148,7 +148,7 @@ static void agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems) } else if (res == Item::FUNC_ITEM) { - field= items[i]->tmp_table_field_from_field_type(0); + field= items[i]->tmp_table_field_from_field_type(0, 0); if (field) field->move_field(buff, &null_byte, 0); break; @@ -354,9 +354,21 @@ longlong Item_func_nop_all::val_int() static bool convert_constant_item(THD *thd, Field *field, Item **item) { int result= 0; + if (!(*item)->with_subselect && (*item)->const_item()) { + TABLE *table= field->table; + ulong orig_sql_mode= thd->variables.sql_mode; + my_bitmap_map *old_write_map; + my_bitmap_map *old_read_map; + + if (table) + { + old_write_map= dbug_tmp_use_all_columns(table, table->write_set); + old_read_map= dbug_tmp_use_all_columns(table, table->read_set); + } /* For comparison purposes allow invalid dates like 2000-01-32 */ + thd->variables.sql_mode|= MODE_INVALID_DATES; if (!(*item)->save_in_field(field, 1) && !((*item)->null_value)) { Item *tmp= new Item_int_with_ref(field->val_int(), *item, @@ -365,9 +377,12 @@ static bool convert_constant_item(THD *thd, Field *field, Item **item) thd->change_item_tree(item, tmp); result= 1; // Item was replaced } - table->in_use->variables.sql_mode= orig_sql_mode; - dbug_tmp_restore_column_map(table->write_set, old_write_map); - dbug_tmp_restore_column_map(table->read_set, old_read_map); + thd->variables.sql_mode= orig_sql_mode; + if (table) + { + dbug_tmp_restore_column_map(table->write_set, old_write_map); + dbug_tmp_restore_column_map(table->read_set, old_read_map); + } } return result; }