diff options
Diffstat (limited to 'mysql-test/t/func_analyse.test')
-rw-r--r-- | mysql-test/t/func_analyse.test | 172 |
1 files changed, 110 insertions, 62 deletions
diff --git a/mysql-test/t/func_analyse.test b/mysql-test/t/func_analyse.test index 0903db1eca4..05f739bfd69 100644 --- a/mysql-test/t/func_analyse.test +++ b/mysql-test/t/func_analyse.test @@ -1,87 +1,135 @@ # -# Bug #10901 Analyze Table on new table destroys table -# This is minimal test case to get error -# The problem was that analyze table wrote the shared state to the -# file and this didn't include the inserts while locked. A check was -# needed to ensure that state information was not updated when -# executing analyze table for a locked table. The analyze table had -# to be within locks and check table had to be after unlocking since -# then it brings the wrong state from disk rather than from the -# currently correct internal state. The insert is needed since it -# changes the file state, number of records. The fix is to -# synchronise the state of the shared state and the current state -# before calling mi_state_info_write +# Test of procedure analyse # -create table t1 (a bigint); -lock tables t1 write; -insert into t1 values(0); -analyze table t1; -unlock tables; -check table t1; - +--disable_warnings +drop table if exists t1,t2; +--enable_warnings +create table t1 (i int, j int, empty_string char(10), bool char(1), d date); +insert into t1 values (1,2,"","Y","2002-03-03"), (3,4,"","N","2002-03-04"), (5,6,"","Y","2002-03-04"), (7,8,"","N","2002-03-05"); +select count(*) from t1 procedure analyse(); +select * from t1 procedure analyse(); +select * from t1 procedure analyse(2); +--error ER_WRONG_USAGE +create table t2 select * from t1 procedure analyse(); drop table t1; -create table t1 (a bigint); -insert into t1 values(0); -lock tables t1 write; -delete from t1; -analyze table t1; -unlock tables; -check table t1; +--error ER_WRONG_USAGE +EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(); + +# +# Bug#2813 - analyse does not quote string values in enums from string +# +create table t1 (v varchar(128)); +insert into t1 values ('abc'),('abc\'def\\hij\"klm\0opq'),('\''),('\"'),('\\'),('a\0'),('b\''),('c\"'),('d\\'),('\'b'),('\"c'),('\\d'),('a\0\0\0b'),('a\'\'\'\'b'),('a\"\"\"\"b'),('a\\\\\\\\b'),('\'\0\\\"'),('\'\''),('\"\"'),('\\\\'),('The\ZEnd'); +select * from t1 procedure analyse(); drop table t1; -create table t1 (a bigint); -insert into t1 values(0); -analyze table t1; -check table t1; +#decimal-related test +create table t1 (df decimal(5,1)); +insert into t1 values(1.1); +insert into t1 values(2.2); +select * from t1 procedure analyse(); drop table t1; -# Bug #14902 ANALYZE TABLE fails to recognize up-to-date tables -# minimal test case to get an error. -# The problem is happening when analysing table with FT index that -# contains stopwords only. The first execution of analyze table should -# mark index statistics as up to date so that next execution of this -# statement will end up with Table is up to date status. -create table t1 (a mediumtext, fulltext key key1(a)) charset utf8 collate utf8_general_ci engine myisam; -insert into t1 values ('hello'); - -analyze table t1; -analyze table t1; +# +# Bug#10716 - Procedure Analyse results in wrong values for optimal field type +# +create table t1 (d double); +insert into t1 values (100000); +select * from t1 procedure analyse (1,1); drop table t1; # -# procedure in PS BUG#13673 +# Bug #14138 ROLLUP and PROCEDURE ANALYSE() hang server # -CREATE TABLE t1 (a int); -prepare stmt1 from "SELECT * FROM t1 PROCEDURE ANALYSE()"; -execute stmt1; -execute stmt1; -deallocate prepare stmt1; -drop table t1; +create table t1 (product varchar(32), country_id int not null, year int, + profit int); +insert into t1 values ( 'Computer', 2,2000, 1200), + ( 'TV', 1, 1999, 150), + ( 'Calculator', 1, 1999,50), + ( 'Computer', 1, 1999,1500), + ( 'Computer', 1, 2000,1500), + ( 'TV', 1, 2000, 150), + ( 'TV', 2, 2000, 100), + ( 'TV', 2, 2000, 100), + ( 'Calculator', 1, 2000,75), + ( 'Calculator', 2, 2000,75), + ( 'TV', 1, 1999, 100), + ( 'Computer', 1, 1999,1200), + ( 'Computer', 2, 2000,1500), + ( 'Calculator', 2, 2000,75), + ( 'Phone', 3, 2003,10) + ; +create table t2 (country_id int primary key, country char(20) not null); +insert into t2 values (1, 'USA'),(2,'India'), (3,'Finland'); +select product, sum(profit),avg(profit) from t1 group by product with rollup procedure analyse(); +drop table t1,t2; # -# bug#15225 (ANALYZE temporary has no effect) +# Bug #20305 PROCEDURE ANALYSE() returns wrong M for FLOAT(M, D) and DOUBLE(M, D) # -create temporary table t1(a int, index(a)); -insert into t1 values('1'),('2'),('3'),('4'),('5'); -analyze table t1; -show index from t1; -drop table t1; ---echo End of 4.1 tests +create table t1 (f1 double(10,5), f2 char(10), f3 double(10,5)); +insert into t1 values (5.999, "5.9999", 5.99999), (9.555, "9.5555", 9.55555); +select f1 from t1 procedure analyse(1, 1); +select f2 from t1 procedure analyse(1, 1); +select f3 from t1 procedure analyse(1, 1); +drop table t1; # -# Bug #30495: optimize table t1,t2,t3 extended errors +# Bug#46184 Crash, SELECT ... FROM derived table procedure analyze # -create table t1(a int); ---error 1064 -analyze table t1 extended; ---error 1064 -optimize table t1 extended; -drop table t1; +CREATE TABLE t1(a INT,b INT,c INT,d INT,e INT,f INT,g INT,h INT,i INT,j INT,k INT); +INSERT INTO t1 VALUES (); +--error ER_WRONG_USAGE +SELECT * FROM (SELECT * FROM t1) d PROCEDURE ANALYSE(); +DROP TABLE t1; + +--echo End of 4.1 tests + +--echo # +--echo # Bug #48293: crash with procedure analyse, view with > 10 columns, +--echo # having clause... +--echo # + +CREATE TABLE t1(a INT, b INT, c INT, d INT, e INT, + f INT, g INT, h INT, i INT, j INT,k INT); +INSERT INTO t1 VALUES (),(); + +CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1; +--echo #should have a derived table +EXPLAIN SELECT * FROM v1; +--echo #should not crash +--error ER_WRONG_USAGE +SELECT * FROM v1 PROCEDURE analyse(); +--echo #should not crash +--error ER_WRONG_USAGE +SELECT * FROM t1 a, v1, t1 b PROCEDURE analyse(); +--echo #should not crash +--error ER_WRONG_USAGE +SELECT * FROM (SELECT * FROM t1 having a > 1) x PROCEDURE analyse(); +--echo #should not crash +--error ER_WRONG_USAGE +SELECT * FROM t1 a, (SELECT * FROM t1 having a > 1) x, t1 b PROCEDURE analyse(); +--echo #should not crash +--error ER_ORDER_WITH_PROC +SELECT 1 FROM t1 group by a having a > 1 order by 1 PROCEDURE analyse(); + +DROP VIEW v1; +DROP TABLE t1; + +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1),(2); + +--echo # should not crash +--error ER_WRONG_USAGE +CREATE TABLE t2 SELECT 1 FROM t1, t1 t3 GROUP BY t3.a PROCEDURE ANALYSE(); + +DROP TABLE t1; + --echo End of 5.0 tests |