diff options
-rw-r--r-- | innobase/row/row0ins.c | 3 | ||||
-rw-r--r-- | myisam/mi_check.c | 2 | ||||
-rw-r--r-- | myisam/myisamchk.c | 6 | ||||
-rw-r--r-- | mysql-test/r/func_in.result | 9 | ||||
-rw-r--r-- | mysql-test/r/func_str.result | 6 | ||||
-rw-r--r-- | mysql-test/r/myisam.result | 4 | ||||
-rw-r--r-- | mysql-test/r/range.result | 19 | ||||
-rw-r--r-- | mysql-test/t/func_in.test | 7 | ||||
-rw-r--r-- | mysql-test/t/func_str.test | 10 | ||||
-rw-r--r-- | mysql-test/t/mysql.test | 10 | ||||
-rw-r--r-- | mysql-test/t/mysqlbinlog.test | 4 | ||||
-rw-r--r-- | mysql-test/t/range.test | 22 | ||||
-rw-r--r-- | sql/ha_myisam.cc | 2 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 2 | ||||
-rw-r--r-- | sql/mysqld.cc | 14 | ||||
-rw-r--r-- | sql/opt_range.cc | 8 | ||||
-rw-r--r-- | sql/sql_select.cc | 1 |
17 files changed, 102 insertions, 27 deletions
diff --git a/innobase/row/row0ins.c b/innobase/row/row0ins.c index 60d7a640f9a..db871a53c42 100644 --- a/innobase/row/row0ins.c +++ b/innobase/row/row0ins.c @@ -1253,9 +1253,10 @@ run_again: if (check_table == NULL || check_table->ibd_file_missing) { if (check_ref) { + FILE* ef = dict_foreign_err_file; + row_ins_set_detailed(trx, foreign); - FILE* ef = dict_foreign_err_file; mutex_enter(&dict_foreign_err_mutex); rewind(ef); ut_print_timestamp(ef); diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 1f453278eea..79fafd0cf5b 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -3994,7 +3994,7 @@ void update_auto_increment_key(MI_CHECK *param, MI_INFO *info, ... The 'unique' array is collected in one sequential scan through the entire index. This is done in two places: in chk_index() and in sort_key_write(). - Statistics collection may consider NULLs as either equal or inequal (see + Statistics collection may consider NULLs as either equal or unequal (see SEARCH_NULL_ARE_NOT_EQUAL, MI_STATS_METHOD_*). Output is an array: diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index 10308408b1f..4fc0e560911 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -67,7 +67,7 @@ static const char *field_pack[]= "no zeros", "blob", "constant", "table-lockup", "always zero","varchar","unique-hash","?","?"}; -static const char *myisam_stats_method_str="nulls_inequal"; +static const char *myisam_stats_method_str="nulls_unequal"; static void get_options(int *argc,char * * *argv); static void print_version(void); @@ -339,7 +339,7 @@ static struct my_option my_long_options[] = REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"stats_method", OPT_STATS_METHOD, "Specifies how index statistics collection code should threat NULLs. " - "Possible values of name are \"nulls_inequal\" (default behavior for 4.1/5.0), and \"nulls_equal\" (emulate 4.0 behavior).", + "Possible values of name are \"nulls_unequal\" (default behavior for 4.1/5.0), and \"nulls_equal\" (emulate 4.0 behavior).", (gptr*) &myisam_stats_method_str, (gptr*) &myisam_stats_method_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} @@ -471,7 +471,7 @@ static void usage(void) #include <help_end.h> -const char *myisam_stats_method_names[] = {"nulls_inequal", "nulls_equal", +const char *myisam_stats_method_names[] = {"nulls_unequal", "nulls_equal", NullS}; TYPELIB myisam_stats_method_typelib= { array_elements(myisam_stats_method_names) - 1, "", diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result index a0868d09242..8562937f1ac 100644 --- a/mysql-test/r/func_in.result +++ b/mysql-test/r/func_in.result @@ -193,6 +193,15 @@ select * from t1 where a in (NULL, 'aa'); a aa drop table t1; +create table t1 (id int, key(id)); +insert into t1 values (1),(2),(3); +select count(*) from t1 where id not in (1); +count(*) +2 +select count(*) from t1 where id not in (1,2); +count(*) +1 +drop table t1; CREATE TABLE t1 (a int PRIMARY KEY); INSERT INTO t1 VALUES (44), (45), (46); SELECT * FROM t1 WHERE a IN (45); diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 577f943ebde..3d7d693cdce 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -1011,3 +1011,9 @@ t 1000000 1 drop table t1; +create table t1 (d decimal default null); +insert into t1 values (null); +select format(d, 2) from t1; +format(d, 2) +NULL +drop table t1; diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 99f84f0a67b..0e5969ed83e 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -610,7 +610,7 @@ test.t2 984116287 drop table t1, t2; show variables like 'myisam_stats_method'; Variable_name Value -myisam_stats_method nulls_inequal +myisam_stats_method nulls_unequal create table t1 (a int, key(a)); insert into t1 values (0),(1),(2),(3),(4); insert into t1 select NULL from t1; @@ -651,7 +651,7 @@ t1 1 a 1 a A 5 NULL NULL YES BTREE set myisam_stats_method=DEFAULT; show variables like 'myisam_stats_method'; Variable_name Value -myisam_stats_method nulls_inequal +myisam_stats_method nulls_unequal insert into t1 values (11); delete from t1 where a=11; analyze table t1; diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index f490c2e1383..6adbea973df 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -768,3 +768,22 @@ SELECT * FROM t1; a 2 DROP TABLE t1; +create table t1 (a int, b int, primary key(a,b)); +create view v1 as select a, b from t1; +INSERT INTO `t1` VALUES +(0,0),(1,0),(2,0),(3,0),(4,0),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(11,2),(12,2) +,(13,2),(14,2),(15,3),(16,3),(17,3),(18,3),(19,3); +explain select * from t1 where a in (3,4) and b in (1,2,3); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index +explain select * from v1 where a in (3,4) and b in (1,2,3); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index +explain select * from t1 where a between 3 and 4 and b between 1 and 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index +explain select * from v1 where a between 3 and 4 and b between 1 and 2; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index +drop view v1; +drop table t1; diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test index 7bf737402ef..dd4edd8ca48 100644 --- a/mysql-test/t/func_in.test +++ b/mysql-test/t/func_in.test @@ -102,6 +102,13 @@ insert into t1 values ('aa'), ('bb'); select * from t1 where a in (NULL, 'aa'); drop table t1; +# BUG#13419 +create table t1 (id int, key(id)); +insert into t1 values (1),(2),(3); +select count(*) from t1 where id not in (1); +select count(*) from t1 where id not in (1,2); +drop table t1; + # End of 4.1 tests # diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 4a6c98c8d7f..5f32b7b2b49 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -665,3 +665,13 @@ select rpad(i, 7, ' ') as t from t1; drop table t1; # End of 4.1 tests + +# +# Bug #13361: SELECT FORMAT(<decimal field with null>, 2) crashes +# +create table t1 (d decimal default null); +insert into t1 values (null); +select format(d, 2) from t1; +drop table t1; + +# End of 5.0 tests diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index c1d9813ea39..0b031ea1be8 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -19,16 +19,16 @@ insert into t1 values(1); --disable_query_log # Test delimiter : supplied on the command line select "Test delimiter : from command line" as " "; ---exec $MYSQL test --delimiter=':' -e 'select * from t1:' +--exec $MYSQL test --delimiter=":" -e "select * from t1:" # Test delimiter :; supplied on the command line select "Test delimiter :; from command line" as " "; ---exec $MYSQL test --delimiter=':;' -e 'select * from t1:;' +--exec $MYSQL test --delimiter=":;" -e "select * from t1:;" # Test 'go' command (vertical output) \G select "Test 'go' command(vertical output) \G" as " "; ---exec $MYSQL test -e 'select * from t1\G' +--exec $MYSQL test -e "select * from t1\G" # Test 'go' command \g select "Test 'go' command \g" as " "; ---exec $MYSQL test -e 'select * from t1\g' +--exec $MYSQL test -e "select * from t1\g" --enable_query_log drop table t1; @@ -37,7 +37,7 @@ drop table t1; # create table t1(a int); lock tables t1 write; ---exec $MYSQL -e 'use test; select database();' +--exec $MYSQL -e "use test; select database();" unlock tables; drop table t1; diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index e5bd8c554cb..61d7d9994ba 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -102,10 +102,10 @@ select "--- --position --" as ""; select "--- reading stdin --" as ""; --enable_query_log --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec cat $MYSQL_TEST_DIR/std_data/trunc_binlog.000001 | $MYSQL_BINLOG --short-form - +--exec $MYSQL_BINLOG --short-form - < $MYSQL_TEST_DIR/std_data/trunc_binlog.000001 --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec cat $MYSQL_TEST_DIR/std_data/trunc_binlog.000001 | $MYSQL_BINLOG --short-form --position=79 - +--exec $MYSQL_BINLOG --short-form --position=79 - < $MYSQL_TEST_DIR/std_data/trunc_binlog.000001 # clean up drop table t1, t2; diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index bbe5798e7e5..d8b3f5ef953 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -578,3 +578,25 @@ DELETE FROM t1 WHERE NOT(a <=> 2); SELECT * FROM t1; DROP TABLE t1; + +# +# BUG#13317: range optimization doesn't work for IN over VIEW. +# +create table t1 (a int, b int, primary key(a,b)); +create view v1 as select a, b from t1; + +INSERT INTO `t1` VALUES +(0,0),(1,0),(2,0),(3,0),(4,0),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(11,2),(12,2) +,(13,2),(14,2),(15,3),(16,3),(17,3),(18,3),(19,3); + +--replace_column 9 # +explain select * from t1 where a in (3,4) and b in (1,2,3); +--replace_column 9 # +explain select * from v1 where a in (3,4) and b in (1,2,3); +--replace_column 9 # +explain select * from t1 where a between 3 and 4 and b between 1 and 2; +--replace_column 9 # +explain select * from v1 where a between 3 and 4 and b between 1 and 2; + +drop view v1; +drop table t1; diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 0198929033e..6b88656dd76 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -39,7 +39,7 @@ const char *myisam_recover_names[] = TYPELIB myisam_recover_typelib= {array_elements(myisam_recover_names)-1,"", myisam_recover_names, NULL}; -const char *myisam_stats_method_names[] = {"nulls_inequal", "nulls_equal", +const char *myisam_stats_method_names[] = {"nulls_unequal", "nulls_equal", NullS}; TYPELIB myisam_stats_method_typelib= { array_elements(myisam_stats_method_names) - 1, "", diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index f0486246a65..018afac3812 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1733,6 +1733,8 @@ String *Item_func_format::val_str(String *str) { my_decimal dec_val, rnd_dec, *res; res= args[0]->val_decimal(&dec_val); + if ((null_value=args[0]->null_value)) + return 0; /* purecov: inspected */ my_decimal_round(E_DEC_FATAL_ERROR, res, decimals, false, &rnd_dec); my_decimal2string(E_DEC_FATAL_ERROR, &rnd_dec, 0, 0, 0, str); str_length= str->length(); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 677b68ca946..103fcf20c11 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -432,7 +432,7 @@ char server_version[SERVER_VERSION_LENGTH]; char *mysqld_unix_port, *opt_mysql_tmpdir; const char **errmesg; /* Error messages */ const char *myisam_recover_options_str="OFF"; -const char *myisam_stats_method_str="nulls_inequal"; +const char *myisam_stats_method_str="nulls_unequal"; /* name of reference on left espression in rewritten IN subquery */ const char *in_left_expr_name= "<left expr>"; /* name of additional condition */ @@ -4016,8 +4016,8 @@ extern "C" pthread_handler_decl(handle_connections_namedpipes,arg) delete thd; continue; } - /* host name is unknown */ - thd->host = my_strdup(my_localhost,MYF(0)); /* Host is unknown */ + /* Host is unknown */ + thd->security_ctx->host= my_strdup(my_localhost, MYF(0)); create_new_thread(thd); } @@ -5519,7 +5519,7 @@ The minimum value for this variable is 4096.", GET_ULONG, REQUIRED_ARG, 8192*1024, 4, ~0L, 0, 1, 0}, {"myisam_stats_method", OPT_MYISAM_STATS_METHOD, "Specifies how MyISAM index statistics collection code should threat NULLs. " - "Possible values of name are \"nulls_inequal\" (default behavior for 4.1/5.0), and \"nulls_equal\" (emulate 4.0 behavior).", + "Possible values of name are \"nulls_unequal\" (default behavior for 4.1/5.0), and \"nulls_equal\" (emulate 4.0 behavior).", (gptr*) &myisam_stats_method_str, (gptr*) &myisam_stats_method_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"net_buffer_length", OPT_NET_BUFFER_LENGTH, @@ -5827,10 +5827,10 @@ struct show_var_st status_vars[]= { {"Com_show_fields", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_FIELDS]), SHOW_LONG_STATUS}, {"Com_show_grants", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_GRANTS]), SHOW_LONG_STATUS}, {"Com_show_innodb_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_INNODB_STATUS]), SHOW_LONG_STATUS}, - {"Com_show_ndb_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_NDBCLUSTER_STATUS]), SHOW_LONG_STATUS}, {"Com_show_keys", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_KEYS]), SHOW_LONG_STATUS}, {"Com_show_logs", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_LOGS]), SHOW_LONG_STATUS}, {"Com_show_master_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_MASTER_STAT]), SHOW_LONG_STATUS}, + {"Com_show_ndb_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_NDBCLUSTER_STATUS]), SHOW_LONG_STATUS}, {"Com_show_new_master", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_NEW_MASTER]), SHOW_LONG_STATUS}, {"Com_show_open_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_OPEN_TABLES]), SHOW_LONG_STATUS}, {"Com_show_privileges", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PRIVILEGES]), SHOW_LONG_STATUS}, @@ -6106,7 +6106,7 @@ static void mysql_init_variables(void) query_id= thread_id= 1L; strmov(server_version, MYSQL_SERVER_VERSION); myisam_recover_options_str= sql_mode_str= "OFF"; - myisam_stats_method_str= "nulls_inequal"; + myisam_stats_method_str= "nulls_unequal"; my_bind_addr = htonl(INADDR_ANY); threads.empty(); thread_cache.empty(); @@ -6157,7 +6157,7 @@ static void mysql_init_variables(void) global_system_variables.old_passwords= 0; /* - Default behavior for 4.1 and 5.0 is to treat NULL values as inequal + Default behavior for 4.1 and 5.0 is to treat NULL values as unequal when collecting index statistics for MyISAM tables. */ global_system_variables.myisam_stats_method= MI_STATS_METHOD_NULLS_NOT_EQUAL; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index edb4289e76f..caefdf92633 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -3533,17 +3533,17 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond) switch (cond_func->functype()) { case Item_func::BETWEEN: - if (cond_func->arguments()[0]->type() != Item::FIELD_ITEM) + if (cond_func->arguments()[0]->real_item()->type() != Item::FIELD_ITEM) DBUG_RETURN(0); - field_item= (Item_field*) (cond_func->arguments()[0]); + field_item= (Item_field*) (cond_func->arguments()[0]->real_item()); value= NULL; break; case Item_func::IN_FUNC: { Item_func_in *func=(Item_func_in*) cond_func; - if (func->key_item()->type() != Item::FIELD_ITEM) + if (func->key_item()->real_item()->type() != Item::FIELD_ITEM) DBUG_RETURN(0); - field_item= (Item_field*) (func->key_item()); + field_item= (Item_field*) (func->key_item()->real_item()); value= NULL; break; } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 38466582931..5fc97385f15 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2386,7 +2386,6 @@ merge_key_fields(KEY_FIELD *start,KEY_FIELD *new_fields,KEY_FIELD *end, field Field used in comparision eq_func True if we used =, <=> or IS NULL value Value used for comparison with field - Is NULL for BETWEEN and IN usable_tables Tables which can be used for key optimization NOTES |