diff options
author | unknown <sanja@montyprogram.com> | 2013-08-20 14:48:29 +0300 |
---|---|---|
committer | unknown <sanja@montyprogram.com> | 2013-08-20 14:48:29 +0300 |
commit | 35b2883643e337a8ec9c3cf7494363ae9889119c (patch) | |
tree | eb2e7d833ed965b30f8b8485cfdac31abfea6c97 | |
parent | dafa458262fb47a2c9534bcc36088b15e26307c2 (diff) | |
parent | b59738a598569ace75be5e63b7ed6ca69afe6ebc (diff) | |
download | mariadb-git-35b2883643e337a8ec9c3cf7494363ae9889119c.tar.gz |
merge 5.5 -> 10.0-base
60 files changed, 730 insertions, 246 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index d411c35285f..4e41dbadca6 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -3510,6 +3510,7 @@ print_table_data(MYSQL_RES *result) if (length < 4 && !IS_NOT_NULL(field->flags)) length=4; // Room for "NULL" field->max_length=length; + num_flag[mysql_field_tell(result) - 1]= IS_NUM(field->type); separator.fill(separator.length()+length+2,'-'); separator.append('+'); } @@ -3529,7 +3530,6 @@ print_table_data(MYSQL_RES *result) tee_fprintf(PAGER, " %-*s |",(int) min(display_length, MAX_COLUMN_LENGTH), field->name); - num_flag[off]= IS_NUM(field->type); } (void) tee_fputs("\n", PAGER); tee_puts((char*) separator.ptr(), PAGER); diff --git a/dbug/dbug.c b/dbug/dbug.c index b285b32fa17..db5ecb7b95e 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -1642,6 +1642,7 @@ void _db_end_() cs->stack= &init_settings; FreeState(cs, 0); + init_done= 0; } diff --git a/mysql-test/r/dyncol.result b/mysql-test/r/dyncol.result index 172179bd7f4..7316a1c2d17 100644 --- a/mysql-test/r/dyncol.result +++ b/mysql-test/r/dyncol.result @@ -1404,6 +1404,27 @@ v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VI drop view v1; drop table t1; # +# MDEV-4811: Assertion `offset < 0x1f' fails in type_and_offset_store +# on COLUMN_ADD +# +CREATE TABLE t1 (dyn TINYBLOB) ENGINE=MyISAM; +INSERT INTO t1 SET dyn = COLUMN_CREATE( 40, REPEAT('a', 233), 4, REPEAT('b', 322) ); +Warnings: +Warning 1265 Data truncated for column 'dyn' at row 1 +SELECT COLUMN_ADD( dyn, 6, REPEAT('x',80), 4, REPEAT('y',215) AS INTEGER ) FROM t1; +ERROR HY000: Encountered illegal format of dynamic column string +DROP table t1; +# +# MDEV-4812: Valgrind warnings (Invalid write) in +# dynamic_column_update_many on COLUMN_ADD +# +CREATE TABLE t1 (dyncol TINYBLOB) ENGINE=MyISAM; +INSERT INTO t1 SET dyncol = COLUMN_CREATE( 7, REPEAT('k',487), 209, REPEAT('x',464) ); +Warnings: +Warning 1265 Data truncated for column 'dyncol' at row 1 +SELECT COLUMN_ADD( dyncol, 7, '22:22:22', 8, REPEAT('x',270) AS CHAR ) FROM t1; +DROP table t1; +# # end of 5.3 tests # # diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 38aa3f49c4d..ba90707ca40 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -1971,6 +1971,7 @@ MIN(t2.pk) NULL Warnings: Warning 1292 Truncated incorrect INTEGER value: 'j' +Warning 1292 Truncated incorrect INTEGER value: 'j' EXPLAIN SELECT MIN(t2.pk) @@ -1984,6 +1985,7 @@ id select_type table type possible_keys key key_len ref rows Extra 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Warnings: Warning 1292 Truncated incorrect INTEGER value: 'j' +Warning 1292 Truncated incorrect INTEGER value: 'j' # # 2) Test that subquery materialization is setup for query with diff --git a/mysql-test/r/func_set.result b/mysql-test/r/func_set.result index 492349fab2d..93757800505 100644 --- a/mysql-test/r/func_set.result +++ b/mysql-test/r/func_set.result @@ -160,6 +160,25 @@ CONVERT( a USING latin1 ) DROP TABLE t1, t2; # +# Start of 5.3 tests +# +# +# MDEV-4512 Valgrind warnings in my_long10_to_str_8bit on INTERVAL and DATE_ADD with incorrect types +# +CREATE TABLE t1 (pk INT PRIMARY KEY); +INSERT INTO t1 VALUES (10),(11); +SELECT INTERVAL( 9, 1, DATE_ADD( pk, INTERVAL pk MINUTE_SECOND ), 9, 8, 3, 5, 2, 1 ) FROM t1; +INTERVAL( 9, 1, DATE_ADD( pk, INTERVAL pk MINUTE_SECOND ), 9, 8, 3, 5, 2, 1 ) +8 +8 +Warnings: +Warning 1292 Incorrect datetime value: '10' +Warning 1292 Incorrect datetime value: '11' +DROP TABLE t1; +# +# End of 5.3 tests +# +# # BUG#59405: FIND_IN_SET won't work normaly after upgrade from 5.1 to 5.5 # CREATE TABLE t1(days set('1','2','3','4','5','6','7')); diff --git a/mysql-test/r/insert.result b/mysql-test/r/insert.result index 7110f541fb7..a722ab8d97f 100644 --- a/mysql-test/r/insert.result +++ b/mysql-test/r/insert.result @@ -663,9 +663,10 @@ Warning 1365 Division by 0 Warning 1048 Column 'data' cannot be null update t1 set data='envelope' where 1/0 or 1; affected rows: 2 -info: Rows matched: 2 Changed: 2 Warnings: 3 +info: Rows matched: 2 Changed: 2 Warnings: 4 Warnings: Warning 1365 Division by 0 +Warning 1365 Division by 0 Warning 1265 Data truncated for column 'data' at row 1 Warning 1265 Data truncated for column 'data' at row 2 insert t1 (data) values (default), (1/0), ('dead beef'); diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 8920539ef2e..fb4cc58d607 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -2117,4 +2117,25 @@ SELECT a.* FROM t1 a LEFT JOIN t1 b ON a.id = b.id WHERE a.modified > b.modified or b.modified IS NULL; id modified DROP TABLE t1; +# +# MDEV-4817: Optimizer fails to optimize expression of the form 'FOO' IS NULL +# +create table t0 (a int not null); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +alter table t0 add person_id varchar(255) not null; +create table t1 (pk int not null primary key); +insert into t1 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo' or 'xyz' IS NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 Using index +explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 Using index +explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo' or t0.person_id='bar'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 Using index +drop table t0, t1; SET optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/r/join_outer_innodb.result b/mysql-test/r/join_outer_innodb.result index 1081fc0eed3..336fb5ee6b6 100644 --- a/mysql-test/r/join_outer_innodb.result +++ b/mysql-test/r/join_outer_innodb.result @@ -14,8 +14,8 @@ EXPLAIN SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id WHERE t1.name LIKE 'A%' OR FALSE; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 index NULL fkey 5 NULL 5 Using index -1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.fkey 1 Using where +1 SIMPLE t1 index PRIMARY,name name 23 NULL 3 Using where; Using index +1 SIMPLE t2 ref fkey fkey 5 test.t1.id 1 Using index DROP TABLE t1,t2; # # BUG#58456: Assertion 0 in QUICK_INDEX_MERGE_SELECT::need_sorted_output diff --git a/mysql-test/r/join_outer_jcl6.result b/mysql-test/r/join_outer_jcl6.result index 43443aa2fef..b5460d43e2b 100644 --- a/mysql-test/r/join_outer_jcl6.result +++ b/mysql-test/r/join_outer_jcl6.result @@ -2128,6 +2128,27 @@ SELECT a.* FROM t1 a LEFT JOIN t1 b ON a.id = b.id WHERE a.modified > b.modified or b.modified IS NULL; id modified DROP TABLE t1; +# +# MDEV-4817: Optimizer fails to optimize expression of the form 'FOO' IS NULL +# +create table t0 (a int not null); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +alter table t0 add person_id varchar(255) not null; +create table t1 (pk int not null primary key); +insert into t1 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo' or 'xyz' IS NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 Using index +explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 Using index +explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo' or t0.person_id='bar'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 Using index +drop table t0, t1; SET optimizer_switch=@save_optimizer_switch; set join_cache_level=default; show variables like 'join_cache_level'; diff --git a/mysql-test/r/lock_multi.result b/mysql-test/r/lock_multi.result index 67712ccabe6..f9e4a88fe95 100644 --- a/mysql-test/r/lock_multi.result +++ b/mysql-test/r/lock_multi.result @@ -18,7 +18,7 @@ n 4 drop table t1; create table t1(n int); -insert into t1 values (1); +insert into t1 values (1),(2); select get_lock("mysqltest_lock", 100); get_lock("mysqltest_lock", 100) 1 @@ -27,11 +27,13 @@ update low_priority t1 set n = 4; select n from t1; n 1 +2 select release_lock("mysqltest_lock"); release_lock("mysqltest_lock") 1 n 1 +2 select release_lock("mysqltest_lock"); release_lock("mysqltest_lock") 1 diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index 4d2ac25a0eb..cb705d285fe 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -515,5 +515,9 @@ aa`bb``cc drop database `aa``bb````cc`; a >>\ndelimiter\n<< ++-------------------+ +| a | +| aaaaaaaaaaaaaaaaa | ++-------------------+ End of tests diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index 146d250d687..86d98fdcc54 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -1590,6 +1590,8 @@ NULL Warnings: Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date +Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date +Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date SELECT str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20'; str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20' 1 diff --git a/mysql-test/r/range_mrr_icp.result b/mysql-test/r/range_mrr_icp.result index 3769ceb9145..0527449fa9b 100644 --- a/mysql-test/r/range_mrr_icp.result +++ b/mysql-test/r/range_mrr_icp.result @@ -1592,6 +1592,8 @@ NULL Warnings: Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date +Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date +Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date SELECT str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20'; str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20' 1 diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index c086a62275a..806afb1c843 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -5358,3 +5358,38 @@ WHERE c = a AND a b c DROP TABLE t1, t2; End of 5.3 tests +# +# mysql BUG#1271 Undefined variable in PASSWORD() +# function is not handled correctly +# +create table t1 ( +name VARCHAR(50) NOT NULL PRIMARY KEY, +pw VARCHAR(41) NOT NULL); +INSERT INTO t1 (name, pw) +VALUES ('tom', PASSWORD('my_pw')); +SET @pass='my_pw'; +SET @wrong='incorrect'; +select * from t1; +name pw +tom *F305E8EC27734F687F2EB6EC03CF0F7AF27C18E1 +select length(PASSWORD(@pass)); +length(PASSWORD(@pass)) +41 +SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@pass); +name +tom +SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@wrong); +name +SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@undefined); +name +select (SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@pass)); +(SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@pass)) +tom +select (SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@wrong)); +(SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@wrong)) +NULL +select (SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@undefined)); +(SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@undefined)) +NULL +drop table t1; +End of 10.0 tests diff --git a/mysql-test/r/select_jcl6.result b/mysql-test/r/select_jcl6.result index 00b356fc1c0..97ffa8413cb 100644 --- a/mysql-test/r/select_jcl6.result +++ b/mysql-test/r/select_jcl6.result @@ -5369,6 +5369,41 @@ WHERE c = a AND a b c DROP TABLE t1, t2; End of 5.3 tests +# +# mysql BUG#1271 Undefined variable in PASSWORD() +# function is not handled correctly +# +create table t1 ( +name VARCHAR(50) NOT NULL PRIMARY KEY, +pw VARCHAR(41) NOT NULL); +INSERT INTO t1 (name, pw) +VALUES ('tom', PASSWORD('my_pw')); +SET @pass='my_pw'; +SET @wrong='incorrect'; +select * from t1; +name pw +tom *F305E8EC27734F687F2EB6EC03CF0F7AF27C18E1 +select length(PASSWORD(@pass)); +length(PASSWORD(@pass)) +41 +SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@pass); +name +tom +SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@wrong); +name +SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@undefined); +name +select (SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@pass)); +(SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@pass)) +tom +select (SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@wrong)); +(SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@wrong)) +NULL +select (SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@undefined)); +(SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@undefined)) +NULL +drop table t1; +End of 10.0 tests set join_cache_level=default; show variables like 'join_cache_level'; Variable_name Value diff --git a/mysql-test/r/select_pkeycache.result b/mysql-test/r/select_pkeycache.result index c086a62275a..806afb1c843 100644 --- a/mysql-test/r/select_pkeycache.result +++ b/mysql-test/r/select_pkeycache.result @@ -5358,3 +5358,38 @@ WHERE c = a AND a b c DROP TABLE t1, t2; End of 5.3 tests +# +# mysql BUG#1271 Undefined variable in PASSWORD() +# function is not handled correctly +# +create table t1 ( +name VARCHAR(50) NOT NULL PRIMARY KEY, +pw VARCHAR(41) NOT NULL); +INSERT INTO t1 (name, pw) +VALUES ('tom', PASSWORD('my_pw')); +SET @pass='my_pw'; +SET @wrong='incorrect'; +select * from t1; +name pw +tom *F305E8EC27734F687F2EB6EC03CF0F7AF27C18E1 +select length(PASSWORD(@pass)); +length(PASSWORD(@pass)) +41 +SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@pass); +name +tom +SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@wrong); +name +SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@undefined); +name +select (SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@pass)); +(SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@pass)) +tom +select (SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@wrong)); +(SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@wrong)) +NULL +select (SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@undefined)); +(SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@undefined)) +NULL +drop table t1; +End of 10.0 tests diff --git a/mysql-test/r/sp_notembedded.result b/mysql-test/r/sp_notembedded.result index 540a66e7508..d34d57450d8 100644 --- a/mysql-test/r/sp_notembedded.result +++ b/mysql-test/r/sp_notembedded.result @@ -169,7 +169,7 @@ drop procedure if exists p1; create table t1 (value varchar(15)); create procedure p1() update t1 set value='updated' where value='old'; call p1(); -insert into t1 (value) values ("old"); +insert into t1 (value) values ("old"),("irrelevant"); select get_lock('b26162',120); get_lock('b26162',120) 1 @@ -179,11 +179,13 @@ call p1();; select 'rl_contender', value from t1; rl_contender value rl_contender old +rl_contender irrelevant select release_lock('b26162'); release_lock('b26162') 1 rl_acquirer value rl_acquirer old +rl_acquirer irrelevant drop procedure p1; drop table t1; set session low_priority_updates=default; diff --git a/mysql-test/r/subselect_cache.result b/mysql-test/r/subselect_cache.result index 7bd10dc11a6..95f935981c2 100644 --- a/mysql-test/r/subselect_cache.result +++ b/mysql-test/r/subselect_cache.result @@ -3129,6 +3129,7 @@ WHERE table1 .`col_varchar_key` ) field10 1 NULL f Warnings: Warning 1292 Truncated incorrect DOUBLE value: 'f' +Warning 1292 Truncated incorrect DOUBLE value: 'f' SET @@optimizer_switch = 'subquery_cache=on'; /* cache is on */ SELECT COUNT( DISTINCT table2 .`col_int_key` ) , ( SELECT SUBQUERY2_t1 .`col_int_key` @@ -3144,6 +3145,7 @@ WHERE table1 .`col_varchar_key` ) field10 1 NULL f Warnings: Warning 1292 Truncated incorrect DOUBLE value: 'f' +Warning 1292 Truncated incorrect DOUBLE value: 'f' drop table t1,t2,t3,t4; set @@optimizer_switch= default; #launchpad BUG#611625 diff --git a/mysql-test/r/timezone2.result b/mysql-test/r/timezone2.result index e2e337628ce..70f5ef9edc1 100644 --- a/mysql-test/r/timezone2.result +++ b/mysql-test/r/timezone2.result @@ -309,3 +309,22 @@ CONVERT_TZ(1, 1, a) NULL DROP TABLE t1; End of 5.1 tests +# +# Start of 5.3 tests +# +# +# MDEV-4653 Wrong result for CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5') +# +SELECT CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5'); +CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '00:00:00' +SELECT CONVERT_TZ(TIME('2010-01-01 00:00:00'),'+00:00','+7:5'); +CONVERT_TZ(TIME('2010-01-01 00:00:00'),'+00:00','+7:5') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '00:00:00' +# +# End of 5.3 tests +# diff --git a/mysql-test/r/type_time.result b/mysql-test/r/type_time.result index 4167cbbe252..5a04913553b 100644 --- a/mysql-test/r/type_time.result +++ b/mysql-test/r/type_time.result @@ -183,6 +183,15 @@ NULL Warnings: Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' # +# MDEV-4652 Wrong result for CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00'))) +# +SELECT CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00'))); +CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00'))) +00:00:01.000000 +SELECT CONCAT(GREATEST(TIME('32 00:00:01'),TIME('00:00:00'))); +CONCAT(GREATEST(TIME('32 00:00:01'),TIME('00:00:00'))) +768:00:01.000000 +# # End of 5.3 tests # CREATE TABLE t1 (f1 TIME); diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index 78ed5bb65d5..178f9fb7db4 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -126,14 +126,14 @@ select @a+0, @a:=@a+0+count(*), count(*), @a+0 from t1 group by i; set @a=0; select @a,@a:="hello",@a,@a:=3,@a,@a:="hello again" from t1 group by i; @a @a:="hello" @a @a:=3 @a @a:="hello again" -0 hello 0 3 0 hello again -0 hello 0 3 0 hello again -0 hello 0 3 0 hello again +0 hello 0 3 3 hello again +0 hello 0 3 3 hello again +0 hello 0 3 3 hello again select @a,@a:="hello",@a,@a:=3,@a,@a:="hello again" from t1 group by i; @a @a:="hello" @a @a:=3 @a @a:="hello again" -hello again hello hello again 3 hello again hello again -hello again hello hello again 3 hello again hello again -hello again hello hello again 3 hello again hello again +hello again hello hello 3 3 hello again +hello again hello hello 3 3 hello again +hello again hello hello 3 3 hello again drop table t1; set @a=_latin2'test'; select charset(@a),collation(@a),coercibility(@a); diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index d907e18b932..083a5e92a8e 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -1549,7 +1549,7 @@ one 1 explain SELECT 1 as 'one' FROM t1 GROUP BY @a:= (SELECT ROUND(f1) FROM t1 WHERE f1 = 0); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort 2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where SELECT 1 as 'one' FROM t1 GROUP BY @a:= (SELECT ROUND(f1) FROM t1 WHERE f1 = 0); one @@ -1560,7 +1560,7 @@ one set sql_buffer_result=1; explain SELECT 1 as 'one' FROM t1 GROUP BY @a:= (SELECT ROUND(f1) FROM t1 WHERE f1 = 0); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort 2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where SELECT 1 as 'one' FROM t1 GROUP BY @a:= (SELECT ROUND(f1) FROM t1 WHERE f1 = 0); one diff --git a/mysql-test/suite/innodb/r/innodb_mysql.result b/mysql-test/suite/innodb/r/innodb_mysql.result index 7247b26e86b..11a2321b0f4 100644 --- a/mysql-test/suite/innodb/r/innodb_mysql.result +++ b/mysql-test/suite/innodb/r/innodb_mysql.result @@ -361,8 +361,8 @@ EXPLAIN SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id WHERE t1.name LIKE 'A%' OR FALSE; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 index NULL fkey 5 NULL 5 Using index -1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.fkey 1 Using where +1 SIMPLE t1 index PRIMARY,name name 23 NULL 3 Using where; Using index +1 SIMPLE t2 ref fkey fkey 5 test.t1.id 1 Using index DROP TABLE t1,t2; CREATE TABLE t1 ( id int NOT NULL, diff --git a/mysql-test/suite/plugins/r/cassandra.result b/mysql-test/suite/plugins/r/cassandra.result index e26df069f93..65a81c429b0 100644 --- a/mysql-test/suite/plugins/r/cassandra.result +++ b/mysql-test/suite/plugins/r/cassandra.result @@ -74,8 +74,8 @@ Variable_name Value cassandra_insert_batch_size 100 show status like 'cassandra_row_insert%'; Variable_name Value -Cassandra_row_insert_batches 7 Cassandra_row_inserts 8 +Cassandra_row_insert_batches 7 CREATE TABLE t1 (rowkey BIGINT PRIMARY KEY, a BIGINT) ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf2'; delete from t1; @@ -84,14 +84,14 @@ DELETE FROM t1 ORDER BY a LIMIT 1; DROP TABLE t1; show status like 'cassandra_row_insert%'; Variable_name Value -Cassandra_row_insert_batches 8 Cassandra_row_inserts 10 +Cassandra_row_insert_batches 8 # FLUSH STATUS doesn't work for our variables, just like with InnoDB. flush status; show status like 'cassandra_row_insert%'; Variable_name Value -Cassandra_row_insert_batches 0 -Cassandra_row_inserts 0 +Cassandra_row_inserts 10 +Cassandra_row_insert_batches 8 # # Batched Key Access # diff --git a/mysql-test/suite/storage_engine/alter_table_online.test b/mysql-test/suite/storage_engine/alter_table_online.test index 94dec2a72bb..c19ec0199eb 100644 --- a/mysql-test/suite/storage_engine/alter_table_online.test +++ b/mysql-test/suite/storage_engine/alter_table_online.test @@ -112,7 +112,7 @@ if ($mysql_errname!=ER_CANT_DO_ONLINE) --let $alter_definition = MODIFY b BIGINT $default_col_opts --source alter_table.inc ---let $alternative_engine = `SELECT engine FROM information_schema.engines WHERE engine != '$storage_engine' AND support IN ('YES','DEFAULT')` +--let $alternative_engine = `SELECT engine FROM information_schema.engines WHERE engine IN ('MEMORY','MyISAM') AND engine != '$storage_engine' ORDER BY engine LIMIT 1` --let $error_codes = ER_CANT_DO_ONLINE --let $online = 1 diff --git a/mysql-test/suite/storage_engine/type_spatial.result b/mysql-test/suite/storage_engine/type_spatial.result index 94e3b22fd3c..6c2f5a4d50f 100644 --- a/mysql-test/suite/storage_engine/type_spatial.result +++ b/mysql-test/suite/storage_engine/type_spatial.result @@ -414,20 +414,20 @@ FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second first second w c o e d t i r 120 120 1 1 0 1 0 1 1 0 120 121 0 0 1 0 0 0 1 0 -120 122 0 1 NULL 0 NULL 0 NULL 0 -120 123 0 1 NULL 0 NULL 0 NULL 0 +120 122 NULL NULL NULL NULL NULL NULL NULL NULL +120 123 NULL NULL NULL NULL NULL NULL NULL NULL 121 120 0 0 1 0 0 0 1 0 121 121 1 1 0 1 0 1 1 0 -121 122 0 1 NULL 0 NULL 0 NULL 0 -121 123 0 1 NULL 0 NULL 0 NULL 0 -122 120 1 0 NULL 0 NULL 0 NULL 0 -122 121 1 0 NULL 0 NULL 0 NULL 0 -122 122 1 1 NULL 1 NULL 0 NULL 0 -122 123 1 1 NULL 1 NULL 0 NULL 0 -123 120 1 0 NULL 0 NULL 0 NULL 0 -123 121 1 0 NULL 0 NULL 0 NULL 0 -123 122 1 1 NULL 1 NULL 0 NULL 0 -123 123 1 1 NULL 1 NULL 0 NULL 0 +121 122 NULL NULL NULL NULL NULL NULL NULL NULL +121 123 NULL NULL NULL NULL NULL NULL NULL NULL +122 120 NULL NULL NULL NULL NULL NULL NULL NULL +122 121 NULL NULL NULL NULL NULL NULL NULL NULL +122 122 NULL NULL NULL NULL NULL NULL NULL NULL +122 123 NULL NULL NULL NULL NULL NULL NULL NULL +123 120 NULL NULL NULL NULL NULL NULL NULL NULL +123 121 NULL NULL NULL NULL NULL NULL NULL NULL +123 122 NULL NULL NULL NULL NULL NULL NULL NULL +123 123 NULL NULL NULL NULL NULL NULL NULL NULL DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry; USE gis_ogs; # Lakes diff --git a/mysql-test/suite/storage_engine/type_spatial_indexes.result b/mysql-test/suite/storage_engine/type_spatial_indexes.result index cebcb80d14f..93bb4c617e5 100644 --- a/mysql-test/suite/storage_engine/type_spatial_indexes.result +++ b/mysql-test/suite/storage_engine/type_spatial_indexes.result @@ -414,20 +414,20 @@ FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second first second w c o e d t i r 120 120 1 1 0 1 0 1 1 0 120 121 0 0 1 0 0 0 1 0 -120 122 0 1 NULL 0 NULL 0 NULL 0 -120 123 0 1 NULL 0 NULL 0 NULL 0 +120 122 NULL NULL NULL NULL NULL NULL NULL NULL +120 123 NULL NULL NULL NULL NULL NULL NULL NULL 121 120 0 0 1 0 0 0 1 0 121 121 1 1 0 1 0 1 1 0 -121 122 0 1 NULL 0 NULL 0 NULL 0 -121 123 0 1 NULL 0 NULL 0 NULL 0 -122 120 1 0 NULL 0 NULL 0 NULL 0 -122 121 1 0 NULL 0 NULL 0 NULL 0 -122 122 1 1 NULL 1 NULL 0 NULL 0 -122 123 1 1 NULL 1 NULL 0 NULL 0 -123 120 1 0 NULL 0 NULL 0 NULL 0 -123 121 1 0 NULL 0 NULL 0 NULL 0 -123 122 1 1 NULL 1 NULL 0 NULL 0 -123 123 1 1 NULL 1 NULL 0 NULL 0 +121 122 NULL NULL NULL NULL NULL NULL NULL NULL +121 123 NULL NULL NULL NULL NULL NULL NULL NULL +122 120 NULL NULL NULL NULL NULL NULL NULL NULL +122 121 NULL NULL NULL NULL NULL NULL NULL NULL +122 122 NULL NULL NULL NULL NULL NULL NULL NULL +122 123 NULL NULL NULL NULL NULL NULL NULL NULL +123 120 NULL NULL NULL NULL NULL NULL NULL NULL +123 121 NULL NULL NULL NULL NULL NULL NULL NULL +123 122 NULL NULL NULL NULL NULL NULL NULL NULL +123 123 NULL NULL NULL NULL NULL NULL NULL NULL DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry; USE gis_ogs; # Lakes @@ -1114,20 +1114,20 @@ FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second first second w c o e d t i r 120 120 1 1 0 1 0 1 1 0 120 121 0 0 1 0 0 0 1 0 -120 122 0 1 NULL 0 NULL 0 NULL 0 -120 123 0 1 NULL 0 NULL 0 NULL 0 +120 122 NULL NULL NULL NULL NULL NULL NULL NULL +120 123 NULL NULL NULL NULL NULL NULL NULL NULL 121 120 0 0 1 0 0 0 1 0 121 121 1 1 0 1 0 1 1 0 -121 122 0 1 NULL 0 NULL 0 NULL 0 -121 123 0 1 NULL 0 NULL 0 NULL 0 -122 120 1 0 NULL 0 NULL 0 NULL 0 -122 121 1 0 NULL 0 NULL 0 NULL 0 -122 122 1 1 NULL 1 NULL 0 NULL 0 -122 123 1 1 NULL 1 NULL 0 NULL 0 -123 120 1 0 NULL 0 NULL 0 NULL 0 -123 121 1 0 NULL 0 NULL 0 NULL 0 -123 122 1 1 NULL 1 NULL 0 NULL 0 -123 123 1 1 NULL 1 NULL 0 NULL 0 +121 122 NULL NULL NULL NULL NULL NULL NULL NULL +121 123 NULL NULL NULL NULL NULL NULL NULL NULL +122 120 NULL NULL NULL NULL NULL NULL NULL NULL +122 121 NULL NULL NULL NULL NULL NULL NULL NULL +122 122 NULL NULL NULL NULL NULL NULL NULL NULL +122 123 NULL NULL NULL NULL NULL NULL NULL NULL +123 120 NULL NULL NULL NULL NULL NULL NULL NULL +123 121 NULL NULL NULL NULL NULL NULL NULL NULL +123 122 NULL NULL NULL NULL NULL NULL NULL NULL +123 123 NULL NULL NULL NULL NULL NULL NULL NULL DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry; USE gis_ogs; # Lakes diff --git a/mysql-test/t/dyncol.test b/mysql-test/t/dyncol.test index c817e7209f6..12bb2f0690a 100644 --- a/mysql-test/t/dyncol.test +++ b/mysql-test/t/dyncol.test @@ -604,6 +604,29 @@ drop view v1; drop table t1; --echo # +--echo # MDEV-4811: Assertion `offset < 0x1f' fails in type_and_offset_store +--echo # on COLUMN_ADD +--echo # + +CREATE TABLE t1 (dyn TINYBLOB) ENGINE=MyISAM; +INSERT INTO t1 SET dyn = COLUMN_CREATE( 40, REPEAT('a', 233), 4, REPEAT('b', 322) ); +--error ER_DYN_COL_WRONG_FORMAT +SELECT COLUMN_ADD( dyn, 6, REPEAT('x',80), 4, REPEAT('y',215) AS INTEGER ) FROM t1; + +DROP table t1; + +--echo # +--echo # MDEV-4812: Valgrind warnings (Invalid write) in +--echo # dynamic_column_update_many on COLUMN_ADD +--echo # +CREATE TABLE t1 (dyncol TINYBLOB) ENGINE=MyISAM; + +INSERT INTO t1 SET dyncol = COLUMN_CREATE( 7, REPEAT('k',487), 209, REPEAT('x',464) ); +--error 0,ER_DYN_COL_WRONG_FORMAT +SELECT COLUMN_ADD( dyncol, 7, '22:22:22', 8, REPEAT('x',270) AS CHAR ) FROM t1; +DROP table t1; + +--echo # --echo # end of 5.3 tests --echo # diff --git a/mysql-test/t/func_set.test b/mysql-test/t/func_set.test index c3428c2a868..13f8661db49 100644 --- a/mysql-test/t/func_set.test +++ b/mysql-test/t/func_set.test @@ -99,6 +99,23 @@ SELECT CONVERT( a USING latin1 ) FROM t2; DROP TABLE t1, t2; --echo # +--echo # Start of 5.3 tests +--echo # + +--echo # +--echo # MDEV-4512 Valgrind warnings in my_long10_to_str_8bit on INTERVAL and DATE_ADD with incorrect types +--echo # +CREATE TABLE t1 (pk INT PRIMARY KEY); +INSERT INTO t1 VALUES (10),(11); +SELECT INTERVAL( 9, 1, DATE_ADD( pk, INTERVAL pk MINUTE_SECOND ), 9, 8, 3, 5, 2, 1 ) FROM t1; +DROP TABLE t1; + +--echo # +--echo # End of 5.3 tests +--echo # + + +--echo # --echo # BUG#59405: FIND_IN_SET won't work normaly after upgrade from 5.1 to 5.5 --echo # diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index 24885c056b8..b0000b2b943 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -1670,4 +1670,21 @@ SELECT a.* FROM t1 a LEFT JOIN t1 b ON a.id = b.id DROP TABLE t1; +--echo # +--echo # MDEV-4817: Optimizer fails to optimize expression of the form 'FOO' IS NULL +--echo # +create table t0 (a int not null); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +alter table t0 add person_id varchar(255) not null; +create table t1 (pk int not null primary key); +insert into t1 select A.a + 10*B.a from t0 A, t0 B; + +explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo' or 'xyz' IS NULL; +explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo'; +explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo' or t0.person_id='bar'; + +drop table t0, t1; + + SET optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test index fc507608bdb..753b6bd6379 100644 --- a/mysql-test/t/lock_multi.test +++ b/mysql-test/t/lock_multi.test @@ -57,7 +57,7 @@ drop table t1; connection locker; create table t1(n int); -insert into t1 values (1); +insert into t1 values (1),(2); connection locker2; select get_lock("mysqltest_lock", 100); connection locker; diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index 662cd4c7c0c..2b4b1e69ab6 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -603,5 +603,10 @@ delimiter EOF --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/13639125.sql +# +# --skip-column-names and alignment +# +--exec $MYSQL -t -N -e "SELECT 'a' union select 'aaaaaaaaaaaaaaaaa'" + --echo --echo End of tests diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 6a82a2901c5..80ca862b74e 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -4518,3 +4518,34 @@ DROP TABLE t1, t2; --echo End of 5.3 tests +--echo # +--echo # mysql BUG#1271 Undefined variable in PASSWORD() +--echo # function is not handled correctly +--echo # + +create table t1 ( +name VARCHAR(50) NOT NULL PRIMARY KEY, +pw VARCHAR(41) NOT NULL); + +INSERT INTO t1 (name, pw) +VALUES ('tom', PASSWORD('my_pw')); + +SET @pass='my_pw'; +SET @wrong='incorrect'; + +select * from t1; +select length(PASSWORD(@pass)); + + +SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@pass); +SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@wrong); +SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@undefined); + + +select (SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@pass)); +select (SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@wrong)); +select (SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@undefined)); + +drop table t1; + +--echo End of 10.0 tests diff --git a/mysql-test/t/sp_notembedded.test b/mysql-test/t/sp_notembedded.test index 447a1db762e..c950af7eb1b 100644 --- a/mysql-test/t/sp_notembedded.test +++ b/mysql-test/t/sp_notembedded.test @@ -248,7 +248,7 @@ create procedure p1() update t1 set value='updated' where value='old'; # load the procedure into sp cache and execute once call p1(); -insert into t1 (value) values ("old"); +insert into t1 (value) values ("old"),("irrelevant"); connect (rl_holder, localhost, root,,); connect (rl_acquirer, localhost, root,,); diff --git a/mysql-test/t/timezone2.test b/mysql-test/t/timezone2.test index c4445da107c..7764b39bf33 100644 --- a/mysql-test/t/timezone2.test +++ b/mysql-test/t/timezone2.test @@ -284,3 +284,19 @@ SELECT CONVERT_TZ(1, 1, a) FROM t1; DROP TABLE t1; --echo End of 5.1 tests + + +--echo # +--echo # Start of 5.3 tests +--echo # + +--echo # +--echo # MDEV-4653 Wrong result for CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5') +--echo # + +SELECT CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5'); +SELECT CONVERT_TZ(TIME('2010-01-01 00:00:00'),'+00:00','+7:5'); + +--echo # +--echo # End of 5.3 tests +--echo # diff --git a/mysql-test/t/type_time.test b/mysql-test/t/type_time.test index 19e0c45fbc0..1dd0f4363b9 100644 --- a/mysql-test/t/type_time.test +++ b/mysql-test/t/type_time.test @@ -129,6 +129,12 @@ drop table t1; SELECT CONVERT_TZ(GREATEST(TIME('00:00:00'),TIME('00:00:00')),'+00:00','+7:5'); --echo # +--echo # MDEV-4652 Wrong result for CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00'))) +--echo # +SELECT CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00'))); +SELECT CONCAT(GREATEST(TIME('32 00:00:01'),TIME('00:00:00'))); + +--echo # --echo # End of 5.3 tests --echo # diff --git a/mysys/ma_dyncol.c b/mysys/ma_dyncol.c index 71ceceaf162..2ab5f443233 100644 --- a/mysys/ma_dyncol.c +++ b/mysys/ma_dyncol.c @@ -1913,7 +1913,8 @@ static size_t get_length_interval(uchar *entry, uchar *entry_next, if (entry_next >= header_end) return (last_offset - offset); if (type_and_offset_read_num(&type_next, &offset_next, - entry_next + COLUMN_NUMBER_SIZE, offset_size)) + entry_next + COLUMN_NUMBER_SIZE, offset_size) || + (offset_next > last_offset)) return DYNCOL_OFFSET_ERROR; return (offset_next - offset); } diff --git a/mysys/waiting_threads.c b/mysys/waiting_threads.c index 56125f8951e..1fe6a0f9a1c 100644 --- a/mysys/waiting_threads.c +++ b/mysys/waiting_threads.c @@ -476,6 +476,7 @@ void wt_end() my_atomic_rwlock_destroy(&cycle_stats_lock); my_atomic_rwlock_destroy(&success_stats_lock); my_atomic_rwlock_destroy(&wait_stats_lock); + reshash.alloc.constructor= NULL; wt_init_done= 0; DBUG_VOID_RETURN; } diff --git a/sql/item.cc b/sql/item.cc index f90469a66a7..d99f5ff46ea 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -297,7 +297,8 @@ String *Item::val_string_from_decimal(String *str) String *Item::val_string_from_date(String *str) { MYSQL_TIME ltime; - if (get_date(<ime, 0) || + if (get_date(<ime, + field_type() == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0) || str->alloc(MAX_DATE_STRING_REP_LENGTH)) { null_value= 1; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 155a9afdafe..706b47618da 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -4341,12 +4341,40 @@ Item_cond::fix_fields(THD *thd, Item **ref) return TRUE; /* purecov: inspected */ used_tables_cache|= item->used_tables(); if (item->const_item()) - and_tables_cache= (table_map) 0; + { + if (!item->is_expensive() && item->val_int() == 0) + { + /* + This is "... OR false_cond OR ..." + In this case, false_cond has no effect on cond_or->not_null_tables() + */ + } + else + { + /* + This is "... OR const_cond OR ..." + In this case, cond_or->not_null_tables()=0, because the condition + some_cond_or might be true regardless of what tables are + NULL-complemented. + */ + and_tables_cache= (table_map) 0; + } + } else { - table_map tmp_table_map= item->not_null_tables(); - not_null_tables_cache|= tmp_table_map; - and_tables_cache&= tmp_table_map; + /* + If an item is a + - constant + - inexpensive + - its value is 0 + then we don't need to account it in not_null_tables_cache + */ + //if (!(item->const_item() && !item->is_expensive() )) + { + table_map tmp_table_map= item->not_null_tables(); + not_null_tables_cache|= tmp_table_map; + and_tables_cache&= tmp_table_map; + } const_item_cache= FALSE; } @@ -4374,7 +4402,25 @@ Item_cond::eval_not_null_tables(uchar *opt_arg) { table_map tmp_table_map; if (item->const_item()) - and_tables_cache= (table_map) 0; + { + if (!item->is_expensive() && item->val_int() == 0) + { + /* + This is "... OR false_cond OR ..." + In this case, false_cond has no effect on cond_or->not_null_tables() + */ + } + else + { + /* + This is "... OR const_cond OR ..." + In this case, cond_or->not_null_tables()=0, because the condition + some_cond_or might be true regardless of what tables are + NULL-complemented. + */ + and_tables_cache= (table_map) 0; + } + } else { tmp_table_map= item->not_null_tables(); diff --git a/sql/item_func.cc b/sql/item_func.cc index 1bd288fc4b0..4c7b8fce98b 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2791,6 +2791,13 @@ bool Item_func_min_max::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) ltime->time_type= MYSQL_TIMESTAMP_DATE; ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0; } + else if (compare_as_dates->field_type() == MYSQL_TYPE_TIME) + { + ltime->time_type= MYSQL_TIMESTAMP_TIME; + ltime->hour+= (ltime->month * 32 + ltime->day) * 24; + ltime->month= ltime->day= 0; + } + return (null_value= 0); } @@ -4067,9 +4074,7 @@ longlong Item_func_get_lock::val_int() if (!ull_name_ok(res)) DBUG_RETURN(0); - - DBUG_PRINT("info", ("lock %.*s, thd=%ld", res->length(), res->ptr(), - (long) thd->real_id)); + DBUG_PRINT("enter", ("lock: %.*s", res->length(), res->ptr())); /* HASH entries are of type User_level_lock. */ if (! my_hash_inited(&thd->ull_hash) && my_hash_init(&thd->ull_hash, &my_charset_bin, @@ -4090,6 +4095,7 @@ longlong Item_func_get_lock::val_int() /* Recursive lock */ ull->refs++; null_value = 0; + DBUG_PRINT("info", ("recursive lock, ref-count: %d", (int) ull->refs)); DBUG_RETURN(1); } @@ -4146,7 +4152,7 @@ longlong Item_func_release_lock::val_int() if (!ull_name_ok(res)) DBUG_RETURN(0); - DBUG_PRINT("info", ("lock %.*s", res->length(), res->ptr())); + DBUG_PRINT("enter", ("lock: %.*s", res->length(), res->ptr())); MDL_key ull_key; ull_key.mdl_key_init(MDL_key::USER_LOCK, res->c_ptr_safe(), ""); @@ -4160,6 +4166,7 @@ longlong Item_func_release_lock::val_int() null_value= thd->mdl_context.get_lock_owner(&ull_key) == 0; DBUG_RETURN(0); } + DBUG_PRINT("info", ("ref count: %d", (int) ull->refs)); null_value= 0; if (--ull->refs == 0) { diff --git a/sql/item_func.h b/sql/item_func.h index bbe70724f79..499ad9f1893 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -43,7 +43,14 @@ protected: bool persistent_maybe_null; public: uint arg_count; - table_map used_tables_cache, not_null_tables_cache; + /* + In some cases used_tables_cache is not what used_tables() return + so the method should be used where one need used tables bit map + (even internally in Item_func_* code). + */ + table_map used_tables_cache; + table_map not_null_tables_cache; + bool const_item_cache; enum Functype { UNKNOWN_FUNC,EQ_FUNC,EQUAL_FUNC,NE_FUNC,LT_FUNC,LE_FUNC, GE_FUNC,GT_FUNC,FT_FUNC, @@ -1269,11 +1276,11 @@ public: Item_func_sleep(Item *a) :Item_int_func(a) {} bool const_item() const { return 0; } const char *func_name() const { return "sleep"; } - void update_used_tables() + table_map used_tables() const { - Item_int_func::update_used_tables(); - used_tables_cache|= RAND_TABLE_BIT; + return Item_int_func::used_tables() | RAND_TABLE_BIT; } + bool is_expensive() { return 1; } longlong val_int(); bool check_vcol_func_processor(uchar *int_arg) { @@ -1523,6 +1530,12 @@ class Item_func_get_lock :public Item_int_func longlong val_int(); const char *func_name() const { return "get_lock"; } void fix_length_and_dec() { max_length=1; set_persist_maybe_null(1);} + table_map used_tables() const + { + return Item_int_func::used_tables() | RAND_TABLE_BIT; + } + bool const_item() const { return 0; } + bool is_expensive() { return 1; } bool check_vcol_func_processor(uchar *int_arg) { return trace_unsupported_by_check_vcol_func_processor(func_name()); @@ -1537,6 +1550,12 @@ public: longlong val_int(); const char *func_name() const { return "release_lock"; } void fix_length_and_dec() { max_length=1; set_persist_maybe_null(1);} + table_map used_tables() const + { + return Item_int_func::used_tables() | RAND_TABLE_BIT; + } + bool const_item() const { return 0; } + bool is_expensive() { return 1; } bool check_vcol_func_processor(uchar *int_arg) { return trace_unsupported_by_check_vcol_func_processor(func_name()); @@ -1629,6 +1648,12 @@ public: enum Item_result result_type () const { return cached_result_type; } bool fix_fields(THD *thd, Item **ref); void fix_length_and_dec(); + table_map used_tables() const + { + return Item_func::used_tables() | RAND_TABLE_BIT; + } + bool const_item() const { return 0; } + bool is_expensive() { return 1; } virtual void print(String *str, enum_query_type query_type); void print_as_stmt(String *str, enum_query_type query_type); const char *func_name() const { return "set_user_var"; } diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index e777ecf121e..c82fb3dd0f2 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2032,7 +2032,9 @@ bool Item_date_add_interval::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) { INTERVAL interval; - if (args[0]->get_date(ltime, 0) || + if (args[0]->get_date(ltime, + cached_field_type == MYSQL_TYPE_TIME ? + TIME_TIME_ONLY : 0) || get_interval_value(args[1], int_type, &interval)) return (null_value=1); @@ -2423,7 +2425,9 @@ bool Item_time_typecast::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) if (ltime->time_type != MYSQL_TIMESTAMP_TIME) ltime->year= ltime->month= ltime->day= 0; ltime->time_type= MYSQL_TIMESTAMP_TIME; - return 0; + return (fuzzy_date & TIME_TIME_ONLY) ? 0 : + (null_value= check_date_with_warn(ltime, fuzzy_date, + MYSQL_TIMESTAMP_ERROR)); } diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 2f4efab2cb8..bcc18d316c8 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1312,17 +1312,17 @@ ulong Query_cache::resize(ulong query_cache_size_arg) { BLOCK_LOCK_WR(block); Query_cache_query *query= block->query(); - if (query && query->writer()) + if (query->writer()) { /* - Drop the writer; this will cancel any attempts to store + Drop the writer; this will cancel any attempts to store the processed statement associated with this writer. */ query->writer()->first_query_block= NULL; query->writer(0); refused++; } - BLOCK_UNLOCK_WR(block); + query->unlock_n_destroy(); block= block->next; } while (block != queries_blocks); } @@ -4247,11 +4247,11 @@ my_bool Query_cache::move_by_type(uchar **border, size_t key_length; key=query_cache_query_get_key((uchar*) block, &key_length, 0); my_hash_first(&queries, (uchar*) key, key_length, &record_idx); - // Move table of used tables - memmove((char*) new_block->table(0), (char*) block->table(0), - ALIGN_SIZE(n_tables*sizeof(Query_cache_block_table))); block->query()->unlock_n_destroy(); block->destroy(); + // Move table of used tables + memmove((char*) new_block->table(0), (char*) block->table(0), + ALIGN_SIZE(n_tables*sizeof(Query_cache_block_table))); new_block->init(len); new_block->type=Query_cache_block::QUERY; new_block->used=used; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 727dfc94175..3bb62598027 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8957,10 +8957,6 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) { /* there may be a select without a cond. */ if (join->table_count > 1) cond->update_used_tables(); // Tablenr may have changed - if (join->const_tables == join->table_count && - thd->lex->current_select->master_unit() == - &thd->lex->unit) // not upper level SELECT - join->const_table_map|=RAND_TABLE_BIT; /* Extract expressions that depend on constant tables @@ -16171,6 +16167,8 @@ create_internal_tmp_table_from_heap2(THD *thd, TABLE *table, const char *save_proc_info; int write_err= 0; DBUG_ENTER("create_internal_tmp_table_from_heap2"); + if (is_duplicate) + *is_duplicate= FALSE; if (table->s->db_type() != heap_hton || error != HA_ERR_RECORD_FILE_FULL) diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 82808708889..0950cd371eb 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -83,7 +83,7 @@ int select_union::send_data(List<Item> &values) */ return -1; } - bool is_duplicate; + bool is_duplicate= FALSE; /* create_internal_tmp_table_from_heap will generate error if needed */ if (table->file->is_fatal_error(write_err, HA_CHECK_DUP) && create_internal_tmp_table_from_heap(thd, table, diff --git a/sql/sys_vars.h b/sql/sys_vars.h index d68761d91ca..260a8af8384 100644 --- a/sql/sys_vars.h +++ b/sql/sys_vars.h @@ -428,7 +428,10 @@ public: void cleanup() { if (flags & ALLOCATED) + { my_free(global_var(char*)); + global_var(char *)= NULL; + } flags&= ~ALLOCATED; } static bool do_string_check(THD *thd, set_var *var, CHARSET_INFO *charset) diff --git a/storage/innobase/mysql-test/storage_engine/parts/optimize_table.rdiff b/storage/innobase/mysql-test/storage_engine/parts/optimize_table.rdiff index 77ee7e2eb31..a35ba5167d9 100644 --- a/storage/innobase/mysql-test/storage_engine/parts/optimize_table.rdiff +++ b/storage/innobase/mysql-test/storage_engine/parts/optimize_table.rdiff @@ -1,25 +1,25 @@ ---- suite/storage_engine/parts/optimize_table.result 2012-07-12 22:16:39.343572304 +0400 -+++ suite/storage_engine/parts/optimize_table.reject 2012-07-15 20:07:01.632130348 +0400 +--- suite/storage_engine/parts/optimize_table.result 2013-07-18 22:55:38.000000000 +0400 ++++ suite/storage_engine/parts/optimize_table.reject 2013-08-05 19:45:19.000000000 +0400 @@ -9,18 +9,22 @@ INSERT INTO t1 (a,b) VALUES (3,'c'),(4,'d'); ALTER TABLE t1 OPTIMIZE PARTITION p1; Table Op Msg_type Msg_text -+test.t1 optimize note Table does not support optimize, doing recreate + analyze instead ++test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t2 (a,b) VALUES (4,'d'); ALTER TABLE t2 OPTIMIZE PARTITION p0 NO_WRITE_TO_BINLOG; Table Op Msg_type Msg_text -+test.t2 optimize note Table does not support optimize, doing recreate + analyze instead ++test.t2 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t2 optimize status OK INSERT INTO t1 (a,b) VALUES (6,'f'); ALTER TABLE t1 OPTIMIZE PARTITION ALL LOCAL; Table Op Msg_type Msg_text -+test.t1 optimize note Table does not support optimize, doing recreate + analyze instead ++test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t2 (a,b) VALUES (5,'e'); ALTER TABLE t2 OPTIMIZE PARTITION p1,p0; Table Op Msg_type Msg_text -+test.t2 optimize note Table does not support optimize, doing recreate + analyze instead ++test.t2 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t2 optimize status OK DROP TABLE t1, t2; DROP TABLE IF EXISTS t1,t2; diff --git a/storage/innobase/mysql-test/storage_engine/parts/repair_table.rdiff b/storage/innobase/mysql-test/storage_engine/parts/repair_table.rdiff index 7ddc57e0ead..35b150e82d1 100644 --- a/storage/innobase/mysql-test/storage_engine/parts/repair_table.rdiff +++ b/storage/innobase/mysql-test/storage_engine/parts/repair_table.rdiff @@ -1,26 +1,6 @@ ---- suite/storage_engine/parts/repair_table.result 2013-01-23 01:35:44.388267080 +0400 -+++ suite/storage_engine/parts/repair_table.reject 2013-01-23 01:44:40.337529283 +0400 -@@ -9,27 +9,27 @@ - INSERT INTO t2 (a,b) SELECT a, b FROM t1; - ALTER TABLE t1 REPAIR PARTITION p0; - Table Op Msg_type Msg_text --test.t1 repair status OK -+test.t1 repair note The storage engine for the table doesn't support repair - INSERT INTO t1 (a,b) VALUES (3,'c'); - ALTER TABLE t1 REPAIR PARTITION NO_WRITE_TO_BINLOG p0, p1; - Table Op Msg_type Msg_text --test.t1 repair status OK -+test.t1 repair note The storage engine for the table doesn't support repair - INSERT INTO t2 (a,b) VALUES (5,'e'),(6,'f'); - ALTER TABLE t2 REPAIR PARTITION LOCAL p1; - Table Op Msg_type Msg_text --test.t2 repair status OK -+test.t2 repair note The storage engine for the table doesn't support repair - INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h'); - ALTER TABLE t1 REPAIR PARTITION LOCAL ALL EXTENDED; - Table Op Msg_type Msg_text --test.t1 repair status OK -+test.t1 repair note The storage engine for the table doesn't support repair +--- suite/storage_engine/parts/repair_table.result 2013-07-18 22:55:38.000000000 +0400 ++++ suite/storage_engine/parts/repair_table.reject 2013-08-05 19:54:09.000000000 +0400 +@@ -25,7 +25,7 @@ INSERT INTO t1 (a,b) VALUES (10,'j'); ALTER TABLE t1 REPAIR PARTITION p1 QUICK USE_FRM; Table Op Msg_type Msg_text @@ -29,39 +9,7 @@ INSERT INTO t2 (a,b) VALUES (12,'l'); ALTER TABLE t2 REPAIR PARTITION NO_WRITE_TO_BINLOG ALL QUICK EXTENDED USE_FRM; Table Op Msg_type Msg_text --test.t2 repair status OK -+test.t2 repair note The storage engine for the table doesn't support repair - DROP TABLE t1, t2; - DROP TABLE IF EXISTS t1,t2; - CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2; -@@ -37,35 +37,35 @@ - CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2; - REPAIR TABLE t1; - Table Op Msg_type Msg_text --test.t1 repair status OK -+test.t1 repair note The storage engine for the table doesn't support repair - INSERT INTO t1 (a,b) VALUES (3,'c'); - INSERT INTO t2 (a,b) VALUES (4,'d'); - REPAIR NO_WRITE_TO_BINLOG TABLE t1, t2; - Table Op Msg_type Msg_text --test.t1 repair status OK --test.t2 repair status OK -+test.t1 repair note The storage engine for the table doesn't support repair -+test.t2 repair note The storage engine for the table doesn't support repair - INSERT INTO t2 (a,b) VALUES (5,'e'),(6,'f'); - REPAIR LOCAL TABLE t2; - Table Op Msg_type Msg_text --test.t2 repair status OK -+test.t2 repair note The storage engine for the table doesn't support repair - INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h'); - INSERT INTO t2 (a,b) VALUES (9,'i'); - REPAIR LOCAL TABLE t2, t1 EXTENDED; - Table Op Msg_type Msg_text --test.t2 repair status OK --test.t1 repair status OK -+test.t2 repair note The storage engine for the table doesn't support repair -+test.t1 repair note The storage engine for the table doesn't support repair - INSERT INTO t1 (a,b) VALUES (10,'j'); +@@ -58,8 +58,8 @@ INSERT INTO t2 (a,b) VALUES (11,'k'); REPAIR TABLE t1, t2 QUICK USE_FRM; Table Op Msg_type Msg_text @@ -72,25 +20,7 @@ INSERT INTO t1 (a,b) VALUES (12,'l'); INSERT INTO t2 (a,b) VALUES (13,'m'); REPAIR NO_WRITE_TO_BINLOG TABLE t1, t2 QUICK EXTENDED USE_FRM; - Table Op Msg_type Msg_text --test.t1 repair status OK --test.t2 repair status OK -+test.t1 repair note The storage engine for the table doesn't support repair -+test.t2 repair note The storage engine for the table doesn't support repair - FLUSH TABLE t1; - INSERT INTO t1 (a,b) VALUES (14,'n'); - ERROR HY000: Failed to read from the .par file -@@ -93,127 +93,21 @@ - CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, <CUSTOM_INDEX> (a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2; - REPAIR TABLE t1; - Table Op Msg_type Msg_text --test.t1 repair status OK -+test.t1 repair note The storage engine for the table doesn't support repair - INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h'); - REPAIR TABLE t1 EXTENDED; - Table Op Msg_type Msg_text --test.t1 repair status OK -+test.t1 repair note The storage engine for the table doesn't support repair +@@ -101,119 +101,13 @@ INSERT INTO t1 (a,b) VALUES (10,'j'); REPAIR TABLE t1 USE_FRM; Table Op Msg_type Msg_text diff --git a/storage/innobase/mysql-test/storage_engine/type_spatial_indexes.rdiff b/storage/innobase/mysql-test/storage_engine/type_spatial_indexes.rdiff index 9061900182e..04572ee03be 100644 --- a/storage/innobase/mysql-test/storage_engine/type_spatial_indexes.rdiff +++ b/storage/innobase/mysql-test/storage_engine/type_spatial_indexes.rdiff @@ -1,5 +1,5 @@ ---- suite/storage_engine/type_spatial_indexes.result 2013-01-23 01:25:45.367797786 +0400 -+++ suite/storage_engine/type_spatial_indexes.reject 2013-01-23 01:46:17.560307029 +0400 +--- suite/storage_engine/type_spatial_indexes.result 2013-08-05 18:08:49.000000000 +0400 ++++ suite/storage_engine/type_spatial_indexes.reject 2013-08-05 18:25:24.000000000 +0400 @@ -702,699 +702,15 @@ DROP DATABASE IF EXISTS gis_ogs; CREATE DATABASE gis_ogs; @@ -416,20 +416,20 @@ -first second w c o e d t i r -120 120 1 1 0 1 0 1 1 0 -120 121 0 0 1 0 0 0 1 0 --120 122 0 1 NULL 0 NULL 0 NULL 0 --120 123 0 1 NULL 0 NULL 0 NULL 0 +-120 122 NULL NULL NULL NULL NULL NULL NULL NULL +-120 123 NULL NULL NULL NULL NULL NULL NULL NULL -121 120 0 0 1 0 0 0 1 0 -121 121 1 1 0 1 0 1 1 0 --121 122 0 1 NULL 0 NULL 0 NULL 0 --121 123 0 1 NULL 0 NULL 0 NULL 0 --122 120 1 0 NULL 0 NULL 0 NULL 0 --122 121 1 0 NULL 0 NULL 0 NULL 0 --122 122 1 1 NULL 1 NULL 0 NULL 0 --122 123 1 1 NULL 1 NULL 0 NULL 0 --123 120 1 0 NULL 0 NULL 0 NULL 0 --123 121 1 0 NULL 0 NULL 0 NULL 0 --123 122 1 1 NULL 1 NULL 0 NULL 0 --123 123 1 1 NULL 1 NULL 0 NULL 0 +-121 122 NULL NULL NULL NULL NULL NULL NULL NULL +-121 123 NULL NULL NULL NULL NULL NULL NULL NULL +-122 120 NULL NULL NULL NULL NULL NULL NULL NULL +-122 121 NULL NULL NULL NULL NULL NULL NULL NULL +-122 122 NULL NULL NULL NULL NULL NULL NULL NULL +-122 123 NULL NULL NULL NULL NULL NULL NULL NULL +-123 120 NULL NULL NULL NULL NULL NULL NULL NULL +-123 121 NULL NULL NULL NULL NULL NULL NULL NULL +-123 122 NULL NULL NULL NULL NULL NULL NULL NULL +-123 123 NULL NULL NULL NULL NULL NULL NULL NULL -DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry; -USE gis_ogs; -# Lakes diff --git a/storage/maria/ma_range.c b/storage/maria/ma_range.c index bb72c10bba7..2a01359f1a1 100644 --- a/storage/maria/ma_range.c +++ b/storage/maria/ma_range.c @@ -144,6 +144,10 @@ static ha_rows _ma_record_pos(MARIA_HA *info, const uchar *key_data, (HA_KEYSEG**) 0); DBUG_EXECUTE("key", _ma_print_key(DBUG_FILE, &key);); nextflag=maria_read_vec[search_flag]; + + /* Indicate if we're doing a search on a key prefix */ + if (((((key_part_map)1) << key.keyinfo->keysegs) - 1) != keypart_map) + nextflag |= SEARCH_PART_KEY; /* my_handler.c:ha_compare_text() has a flag 'skip_end_space'. diff --git a/storage/myisammrg/mysql-test/storage_engine/type_spatial.rdiff b/storage/myisammrg/mysql-test/storage_engine/type_spatial.rdiff index dbf29fb8d00..52e9d9fdbe4 100644 --- a/storage/myisammrg/mysql-test/storage_engine/type_spatial.rdiff +++ b/storage/myisammrg/mysql-test/storage_engine/type_spatial.rdiff @@ -1,5 +1,5 @@ ---- type_spatial.result 2013-01-23 01:25:39.143876032 +0400 -+++ type_spatial.reject 2013-01-23 02:51:14.535315418 +0400 +--- suite/storage_engine/type_spatial.result 2013-08-05 17:52:53.000000000 +0400 ++++ suite/storage_engine/type_spatial.reject 2013-08-05 17:56:37.000000000 +0400 @@ -2,699 +2,15 @@ DROP DATABASE IF EXISTS gis_ogs; CREATE DATABASE gis_ogs; @@ -416,20 +416,20 @@ -first second w c o e d t i r -120 120 1 1 0 1 0 1 1 0 -120 121 0 0 1 0 0 0 1 0 --120 122 0 1 NULL 0 NULL 0 NULL 0 --120 123 0 1 NULL 0 NULL 0 NULL 0 +-120 122 NULL NULL NULL NULL NULL NULL NULL NULL +-120 123 NULL NULL NULL NULL NULL NULL NULL NULL -121 120 0 0 1 0 0 0 1 0 -121 121 1 1 0 1 0 1 1 0 --121 122 0 1 NULL 0 NULL 0 NULL 0 --121 123 0 1 NULL 0 NULL 0 NULL 0 --122 120 1 0 NULL 0 NULL 0 NULL 0 --122 121 1 0 NULL 0 NULL 0 NULL 0 --122 122 1 1 NULL 1 NULL 0 NULL 0 --122 123 1 1 NULL 1 NULL 0 NULL 0 --123 120 1 0 NULL 0 NULL 0 NULL 0 --123 121 1 0 NULL 0 NULL 0 NULL 0 --123 122 1 1 NULL 1 NULL 0 NULL 0 --123 123 1 1 NULL 1 NULL 0 NULL 0 +-121 122 NULL NULL NULL NULL NULL NULL NULL NULL +-121 123 NULL NULL NULL NULL NULL NULL NULL NULL +-122 120 NULL NULL NULL NULL NULL NULL NULL NULL +-122 121 NULL NULL NULL NULL NULL NULL NULL NULL +-122 122 NULL NULL NULL NULL NULL NULL NULL NULL +-122 123 NULL NULL NULL NULL NULL NULL NULL NULL +-123 120 NULL NULL NULL NULL NULL NULL NULL NULL +-123 121 NULL NULL NULL NULL NULL NULL NULL NULL +-123 122 NULL NULL NULL NULL NULL NULL NULL NULL +-123 123 NULL NULL NULL NULL NULL NULL NULL NULL -DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry; -USE gis_ogs; -# Lakes diff --git a/storage/myisammrg/mysql-test/storage_engine/type_spatial_indexes.rdiff b/storage/myisammrg/mysql-test/storage_engine/type_spatial_indexes.rdiff index 20d98db1ff2..ecd0025c9d9 100644 --- a/storage/myisammrg/mysql-test/storage_engine/type_spatial_indexes.rdiff +++ b/storage/myisammrg/mysql-test/storage_engine/type_spatial_indexes.rdiff @@ -1,5 +1,5 @@ ---- type_spatial_indexes.result 2013-01-23 01:25:45.367797786 +0400 -+++ type_spatial_indexes.reject 2013-01-23 02:51:15.247306467 +0400 +--- suite/storage_engine/type_spatial_indexes.result 2013-08-05 18:08:49.000000000 +0400 ++++ suite/storage_engine/type_spatial_indexes.reject 2013-08-05 18:27:47.000000000 +0400 @@ -2,1399 +2,31 @@ DROP DATABASE IF EXISTS gis_ogs; CREATE DATABASE gis_ogs; @@ -416,20 +416,20 @@ -first second w c o e d t i r -120 120 1 1 0 1 0 1 1 0 -120 121 0 0 1 0 0 0 1 0 --120 122 0 1 NULL 0 NULL 0 NULL 0 --120 123 0 1 NULL 0 NULL 0 NULL 0 +-120 122 NULL NULL NULL NULL NULL NULL NULL NULL +-120 123 NULL NULL NULL NULL NULL NULL NULL NULL -121 120 0 0 1 0 0 0 1 0 -121 121 1 1 0 1 0 1 1 0 --121 122 0 1 NULL 0 NULL 0 NULL 0 --121 123 0 1 NULL 0 NULL 0 NULL 0 --122 120 1 0 NULL 0 NULL 0 NULL 0 --122 121 1 0 NULL 0 NULL 0 NULL 0 --122 122 1 1 NULL 1 NULL 0 NULL 0 --122 123 1 1 NULL 1 NULL 0 NULL 0 --123 120 1 0 NULL 0 NULL 0 NULL 0 --123 121 1 0 NULL 0 NULL 0 NULL 0 --123 122 1 1 NULL 1 NULL 0 NULL 0 --123 123 1 1 NULL 1 NULL 0 NULL 0 +-121 122 NULL NULL NULL NULL NULL NULL NULL NULL +-121 123 NULL NULL NULL NULL NULL NULL NULL NULL +-122 120 NULL NULL NULL NULL NULL NULL NULL NULL +-122 121 NULL NULL NULL NULL NULL NULL NULL NULL +-122 122 NULL NULL NULL NULL NULL NULL NULL NULL +-122 123 NULL NULL NULL NULL NULL NULL NULL NULL +-123 120 NULL NULL NULL NULL NULL NULL NULL NULL +-123 121 NULL NULL NULL NULL NULL NULL NULL NULL +-123 122 NULL NULL NULL NULL NULL NULL NULL NULL +-123 123 NULL NULL NULL NULL NULL NULL NULL NULL -DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry; -USE gis_ogs; -# Lakes @@ -1126,20 +1126,20 @@ -first second w c o e d t i r -120 120 1 1 0 1 0 1 1 0 -120 121 0 0 1 0 0 0 1 0 --120 122 0 1 NULL 0 NULL 0 NULL 0 --120 123 0 1 NULL 0 NULL 0 NULL 0 +-120 122 NULL NULL NULL NULL NULL NULL NULL NULL +-120 123 NULL NULL NULL NULL NULL NULL NULL NULL -121 120 0 0 1 0 0 0 1 0 -121 121 1 1 0 1 0 1 1 0 --121 122 0 1 NULL 0 NULL 0 NULL 0 --121 123 0 1 NULL 0 NULL 0 NULL 0 --122 120 1 0 NULL 0 NULL 0 NULL 0 --122 121 1 0 NULL 0 NULL 0 NULL 0 --122 122 1 1 NULL 1 NULL 0 NULL 0 --122 123 1 1 NULL 1 NULL 0 NULL 0 --123 120 1 0 NULL 0 NULL 0 NULL 0 --123 121 1 0 NULL 0 NULL 0 NULL 0 --123 122 1 1 NULL 1 NULL 0 NULL 0 --123 123 1 1 NULL 1 NULL 0 NULL 0 +-121 122 NULL NULL NULL NULL NULL NULL NULL NULL +-121 123 NULL NULL NULL NULL NULL NULL NULL NULL +-122 120 NULL NULL NULL NULL NULL NULL NULL NULL +-122 121 NULL NULL NULL NULL NULL NULL NULL NULL +-122 122 NULL NULL NULL NULL NULL NULL NULL NULL +-122 123 NULL NULL NULL NULL NULL NULL NULL NULL +-123 120 NULL NULL NULL NULL NULL NULL NULL NULL +-123 121 NULL NULL NULL NULL NULL NULL NULL NULL +-123 122 NULL NULL NULL NULL NULL NULL NULL NULL +-123 123 NULL NULL NULL NULL NULL NULL NULL NULL -DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry; -USE gis_ogs; -# Lakes diff --git a/storage/xtradb/buf/buf0buf.c b/storage/xtradb/buf/buf0buf.c index b294c88497e..1084dcdf344 100644 --- a/storage/xtradb/buf/buf0buf.c +++ b/storage/xtradb/buf/buf0buf.c @@ -581,6 +581,8 @@ UNIV_INTERN ibool buf_page_is_corrupted( /*==================*/ + ibool check_lsn, /*!< in: TRUE if we need to check + and complain about the LSN */ const byte* read_buf, /*!< in: a database page */ ulint zip_size) /*!< in: size of compressed page; 0 for uncompressed pages */ @@ -600,7 +602,7 @@ buf_page_is_corrupted( } #ifndef UNIV_HOTBACKUP - if (recv_lsn_checks_on) { + if (check_lsn && recv_lsn_checks_on) { ib_uint64_t current_lsn; if (log_peek_lsn(¤t_lsn) @@ -3945,7 +3947,7 @@ buf_page_io_complete( /* From version 3.23.38 up we store the page checksum to the 4 first bytes of the page end lsn field */ - if (buf_page_is_corrupted(frame, + if (buf_page_is_corrupted(TRUE, frame, buf_page_get_zip_size(bpage))) { corrupt: fprintf(stderr, diff --git a/storage/xtradb/fil/fil0fil.c b/storage/xtradb/fil/fil0fil.c index 48f3c43cdc0..929e24d20ce 100644 --- a/storage/xtradb/fil/fil0fil.c +++ b/storage/xtradb/fil/fil0fil.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1884,10 +1884,62 @@ fil_write_flushed_lsn_to_data_files( } /*******************************************************************//** +Checks the consistency of the first data page of a data file +at database startup. +@retval NULL on success, or if innodb_force_recovery is set +@return pointer to an error message string */ +static __attribute__((warn_unused_result)) +const char* +fil_check_first_page( +/*=================*/ + const page_t* page, /*!< in: data page */ + ibool first_page) /*!< in: TRUE if this is the + first page of the tablespace */ +{ + ulint space_id; + ulint flags; + + if (srv_force_recovery >= SRV_FORCE_IGNORE_CORRUPT) { + return(NULL); + } + + space_id = mach_read_from_4(FSP_HEADER_OFFSET + FSP_SPACE_ID + page); + flags = mach_read_from_4(FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + page); + + if (first_page && !space_id && !flags) { + ulint nonzero_bytes = UNIV_PAGE_SIZE; + const byte* b = page; + + while (!*b && --nonzero_bytes) { + b++; + } + + if (!nonzero_bytes) { + return("space header page consists of zero bytes"); + } + } + + if (buf_page_is_corrupted( + FALSE, page, dict_table_flags_to_zip_size(flags))) { + return("checksum mismatch"); + } + + if (!first_page + || (page_get_space_id(page) == space_id + && page_get_page_no(page) == 0)) { + return(NULL); + } + + return("inconsistent data in space header"); +} + +/*******************************************************************//** Reads the flushed lsn, arch no, and tablespace flag fields from a data -file at database startup. */ +file at database startup. +@retval NULL on success, or if innodb_force_recovery is set +@return pointer to an error message string */ UNIV_INTERN -void +const char* fil_read_first_page( /*================*/ os_file_t data_file, /*!< in: open data file */ @@ -1909,6 +1961,7 @@ fil_read_first_page( byte* buf; page_t* page; ib_uint64_t flushed_lsn; + const char* check_msg; buf = ut_malloc(2 * UNIV_PAGE_SIZE); /* Align the memory for a possible read from a raw device */ @@ -1916,13 +1969,18 @@ fil_read_first_page( os_file_read(data_file, page, 0, 0, UNIV_PAGE_SIZE); - *flags = mach_read_from_4(page + - FSP_HEADER_OFFSET + FSP_SPACE_FLAGS); + *flags = mach_read_from_4(FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + page); flushed_lsn = mach_read_from_8(page + FIL_PAGE_FILE_FLUSH_LSN); + check_msg = fil_check_first_page(page, !one_read_already); + ut_free(buf); + if (check_msg) { + return(check_msg); + } + if (!one_read_already) { *min_flushed_lsn = flushed_lsn; *max_flushed_lsn = flushed_lsn; @@ -1930,7 +1988,7 @@ fil_read_first_page( *min_arch_log_no = arch_log_no; *max_arch_log_no = arch_log_no; #endif /* UNIV_LOG_ARCHIVE */ - return; + return(NULL); } if (*min_flushed_lsn > flushed_lsn) { @@ -1947,6 +2005,8 @@ fil_read_first_page( *max_arch_log_no = arch_log_no; } #endif /* UNIV_LOG_ARCHIVE */ + + return(NULL); } /*================ SINGLE-TABLE TABLESPACES ==========================*/ @@ -3271,6 +3331,7 @@ fil_open_single_table_tablespace( os_file_t file; char* filepath; ibool success; + const char* check_msg; byte* buf2; byte* page; ulint space_id; @@ -3331,6 +3392,8 @@ fil_open_single_table_tablespace( success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE); + check_msg = fil_check_first_page(page, TRUE); + /* We have to read the tablespace id and flags from the file. */ space_id = fsp_header_get_space_id(page); @@ -3366,7 +3429,7 @@ fil_open_single_table_tablespace( current_lsn = log_get_lsn(); /* check the header page's consistency */ - if (buf_page_is_corrupted(page, + if (buf_page_is_corrupted(TRUE, page, dict_table_flags_to_zip_size(space_flags))) { fprintf(stderr, "InnoDB: page 0 of %s seems corrupt.\n", filepath); file_is_corrupt = TRUE; @@ -3788,8 +3851,20 @@ skip_write: ut_free(buf2); - if (UNIV_UNLIKELY(space_id != id - || space_flags != (flags & ~(~0 << DICT_TF_BITS)))) { + if (check_msg) { + ut_print_timestamp(stderr); + fprintf(stderr, " InnoDB: Error: %s in file ", check_msg); + ut_print_filename(stderr, filepath); + fprintf(stderr, " (tablespace id=%lu, flags=%lu)\n" + "InnoDB: Please refer to " REFMAN + "innodb-troubleshooting-datadict.html\n", + (ulong) id, (ulong) flags); + success = FALSE; + goto func_exit; + } + + if (space_id != id + || space_flags != (flags & ~(~0 << DICT_TF_BITS))) { ut_print_timestamp(stderr); fputs(" InnoDB: Error: tablespace id and flags in file ", @@ -4280,11 +4355,21 @@ fil_load_single_table_tablespace( page = ut_align(buf2, UNIV_PAGE_SIZE); if (size >= FIL_IBD_FILE_INITIAL_SIZE * (lint)UNIV_PAGE_SIZE) { + const char* check_msg; success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE); /* We have to read the tablespace id from the file */ + check_msg = fil_check_first_page(page, TRUE); + + if (check_msg) { + fprintf(stderr, + "InnoDB: Error: %s in file %s", + check_msg, filepath); + goto func_exit; + } + space_id = fsp_header_get_space_id(page); flags = fsp_header_get_flags(page); } else { diff --git a/storage/xtradb/include/buf0buf.h b/storage/xtradb/include/buf0buf.h index f00a06c8805..233231e4cab 100644 --- a/storage/xtradb/include/buf0buf.h +++ b/storage/xtradb/include/buf0buf.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -684,9 +684,12 @@ UNIV_INTERN ibool buf_page_is_corrupted( /*==================*/ + ibool check_lsn, /*!< in: TRUE if we need to check + and complain about the LSN */ const byte* read_buf, /*!< in: a database page */ - ulint zip_size); /*!< in: size of compressed page; + ulint zip_size) /*!< in: size of compressed page; 0 for uncompressed pages */ + __attribute__((warn_unused_result)); #ifndef UNIV_HOTBACKUP /**********************************************************************//** Gets the space id, page offset, and byte offset within page of a diff --git a/storage/xtradb/include/fil0fil.h b/storage/xtradb/include/fil0fil.h index 2149d0aadca..881623b30cf 100644 --- a/storage/xtradb/include/fil0fil.h +++ b/storage/xtradb/include/fil0fil.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -328,10 +328,12 @@ fil_write_flushed_lsn_to_data_files( ulint arch_log_no); /*!< in: latest archived log file number */ /*******************************************************************//** -Reads the flushed lsn and arch no fields from a data file at database -startup. */ +Reads the flushed lsn, arch no, and tablespace flag fields from a data +file at database startup. +@retval NULL on success, or if innodb_force_recovery is set +@return pointer to an error message string */ UNIV_INTERN -void +const char* fil_read_first_page( /*================*/ os_file_t data_file, /*!< in: open data file */ @@ -347,8 +349,9 @@ fil_read_first_page( #endif /* UNIV_LOG_ARCHIVE */ ib_uint64_t* min_flushed_lsn, /*!< out: min of flushed lsn values in data files */ - ib_uint64_t* max_flushed_lsn); /*!< out: max of flushed + ib_uint64_t* max_flushed_lsn) /*!< out: max of flushed lsn values in data files */ + __attribute__((warn_unused_result)); /*******************************************************************//** Increments the count of pending operation, if space is not being deleted. @return TRUE if being deleted, and operation should be skipped */ diff --git a/storage/xtradb/os/os0file.c b/storage/xtradb/os/os0file.c index ae6ba05c9f6..5beed447c91 100644 --- a/storage/xtradb/os/os0file.c +++ b/storage/xtradb/os/os0file.c @@ -3773,6 +3773,10 @@ os_aio_free(void) ut_free(os_aio_segment_wait_events); os_aio_segment_wait_events = 0; os_aio_n_segments = 0; +#ifdef _WIN32 + completion_port = 0; + read_completion_port = 0; +#endif } #ifdef WIN_ASYNC_IO diff --git a/storage/xtradb/srv/srv0start.c b/storage/xtradb/srv/srv0start.c index 6e6c5ff4e41..93416088f17 100644 --- a/storage/xtradb/srv/srv0start.c +++ b/storage/xtradb/srv/srv0start.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2008, Google Inc. Copyright (c) 2009, Percona Inc. @@ -817,6 +817,7 @@ open_or_create_data_files( } if (ret == FALSE) { + const char* check_msg; /* We open the data file */ if (one_created) { @@ -914,13 +915,20 @@ open_or_create_data_files( return(DB_ERROR); } skip_size_check: - fil_read_first_page( + check_msg = fil_read_first_page( files[i], one_opened, &flags, #ifdef UNIV_LOG_ARCHIVE min_arch_log_no, max_arch_log_no, #endif /* UNIV_LOG_ARCHIVE */ min_flushed_lsn, max_flushed_lsn); + if (check_msg) { + fprintf(stderr, + "InnoDB: Error: %s in data file %s\n", + check_msg, name); + return(DB_ERROR); + } + if (!one_opened && UNIV_PAGE_SIZE != fsp_flags_get_page_size(flags)) { @@ -1042,6 +1050,8 @@ skip_size_check: if (ret == FALSE) { + const char* check_msg; + /* We open the data file */ files[i] = os_file_create(innodb_file_data_key, @@ -1078,13 +1088,20 @@ skip_size_check: (ulong) TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9); } - fil_read_first_page( + check_msg = fil_read_first_page( files[i], one_opened, &flags, #ifdef UNIV_LOG_ARCHIVE min_arch_log_no, max_arch_log_no, #endif /* UNIV_LOG_ARCHIVE */ min_flushed_lsn, max_flushed_lsn); + if (check_msg) { + fprintf(stderr, + "InnoDB: Error: %s in doublewrite " + "buffer file %s\n", check_msg, name); + return(DB_ERROR); + } + one_opened = TRUE; } else { /* We created the data file and now write it full of diff --git a/storage/xtradb/trx/trx0sys.c b/storage/xtradb/trx/trx0sys.c index ef00bc0a1f0..a56e55c0e19 100644 --- a/storage/xtradb/trx/trx0sys.c +++ b/storage/xtradb/trx/trx0sys.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -726,7 +726,8 @@ trx_sys_doublewrite_init_or_restore_pages( /* Check if the page is corrupt */ if (UNIV_UNLIKELY - (buf_page_is_corrupted(read_buf, zip_size))) { + (buf_page_is_corrupted( + TRUE, read_buf, zip_size))) { fprintf(stderr, "InnoDB: Warning: database page" @@ -737,7 +738,8 @@ trx_sys_doublewrite_init_or_restore_pages( " the doublewrite buffer.\n", (ulong) space_id, (ulong) page_no); - if (buf_page_is_corrupted(page, zip_size)) { + if (buf_page_is_corrupted( + TRUE, page, zip_size)) { fprintf(stderr, "InnoDB: Dump of the page:\n"); buf_page_print( |