~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/t/analyse.test

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Test of procedure analyse
 
3
#
 
4
 
 
5
--disable_warnings
 
6
drop table if exists t1,t2;
 
7
--enable_warnings
 
8
create table t1 (i int, j int, empty_string char(10), bool char(1), d date);
 
9
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");
 
10
select count(*) from t1 procedure analyse();
 
11
select * from t1 procedure analyse();
 
12
select * from t1 procedure analyse(2);
 
13
--error ER_WRONG_USAGE
 
14
create table t2 select * from t1 procedure analyse();
 
15
drop table t1;
 
16
 
 
17
--error ER_WRONG_USAGE
 
18
EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE();
 
19
 
 
20
#
 
21
# Bug#2813 - analyse does not quote string values in enums from string
 
22
#
 
23
 
 
24
create table t1 (v varchar(128));
 
25
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');
 
26
select * from t1 procedure analyse();
 
27
drop table t1;
 
28
 
 
29
#decimal-related test
 
30
 
 
31
create table t1 (df decimal(5,1));
 
32
insert into t1 values(1.1);
 
33
insert into t1 values(2.2);
 
34
select * from t1 procedure analyse();
 
35
drop table t1;
 
36
 
 
37
#
 
38
# Bug#10716 - Procedure Analyse results in wrong values for optimal field type
 
39
#
 
40
 
 
41
create table t1 (d double);
 
42
insert into t1 values (100000);
 
43
select * from t1 procedure analyse (1,1);
 
44
drop table t1;
 
45
 
 
46
#
 
47
# Bug #14138 ROLLUP and PROCEDURE ANALYSE() hang server
 
48
#
 
49
create table t1 (product varchar(32), country_id int not null, year int,
 
50
                 profit int);
 
51
insert into t1  values ( 'Computer', 2,2000, 1200),
 
52
    ( 'TV', 1, 1999, 150),
 
53
    ( 'Calculator', 1, 1999,50),
 
54
    ( 'Computer', 1, 1999,1500),
 
55
    ( 'Computer', 1, 2000,1500),
 
56
    ( 'TV', 1, 2000, 150),
 
57
    ( 'TV', 2, 2000, 100),
 
58
    ( 'TV', 2, 2000, 100),
 
59
    ( 'Calculator', 1, 2000,75),
 
60
    ( 'Calculator', 2, 2000,75),
 
61
    ( 'TV', 1, 1999, 100),
 
62
    ( 'Computer', 1, 1999,1200),
 
63
    ( 'Computer', 2, 2000,1500),
 
64
    ( 'Calculator', 2, 2000,75),
 
65
    ( 'Phone', 3, 2003,10)
 
66
    ;
 
67
create table t2 (country_id int primary key, country char(20) not null); 
 
68
insert into t2 values (1, 'USA'),(2,'India'), (3,'Finland');
 
69
select product, sum(profit),avg(profit) from t1 group by product with rollup procedure analyse();
 
70
drop table t1,t2;
 
71
 
 
72
#
 
73
# Bug #20305 PROCEDURE ANALYSE() returns wrong M for FLOAT(M, D) and DOUBLE(M, D)
 
74
#
 
75
 
 
76
create table t1 (f1 double(10,5), f2 char(10), f3 double(10,5));
 
77
insert into t1 values (5.999, "5.9999", 5.99999), (9.555, "9.5555", 9.55555);
 
78
select f1 from t1 procedure analyse(1, 1);
 
79
select f2 from t1 procedure analyse(1, 1);
 
80
select f3 from t1 procedure analyse(1, 1);
 
81
drop table t1;
 
82
 
 
83
#
 
84
# Bug#46184 Crash, SELECT ... FROM derived table procedure analyze
 
85
#
 
86
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);
 
87
INSERT INTO t1 VALUES ();
 
88
--error ER_WRONG_USAGE
 
89
SELECT * FROM (SELECT * FROM t1) d PROCEDURE ANALYSE();
 
90
DROP TABLE t1;
 
91
 
 
92
--echo End of 4.1 tests
 
93
 
 
94
--echo #
 
95
--echo # Bug #48293: crash with procedure analyse, view with > 10 columns, 
 
96
--echo #  having clause...
 
97
--echo #
 
98
 
 
99
CREATE TABLE t1(a INT, b INT, c INT, d INT, e INT,
 
100
                f INT, g INT, h INT, i INT, j INT,k INT);
 
101
INSERT INTO t1 VALUES (),();
 
102
 
 
103
CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
 
104
--echo #should have a derived table
 
105
EXPLAIN SELECT * FROM v1;
 
106
--echo #should not crash
 
107
--error ER_WRONG_USAGE
 
108
SELECT * FROM v1 PROCEDURE analyse();
 
109
--echo #should not crash
 
110
--error ER_WRONG_USAGE
 
111
SELECT * FROM t1 a, v1, t1 b PROCEDURE analyse();
 
112
--echo #should not crash
 
113
--error ER_WRONG_USAGE
 
114
SELECT * FROM (SELECT * FROM t1 having a > 1) x PROCEDURE analyse();
 
115
--echo #should not crash
 
116
--error ER_WRONG_USAGE
 
117
SELECT * FROM t1 a, (SELECT * FROM t1 having a > 1) x, t1 b PROCEDURE analyse();
 
118
--echo #should not crash
 
119
--error ER_ORDER_WITH_PROC
 
120
SELECT 1 FROM t1 group by a having a > 1 order by 1 PROCEDURE analyse();
 
121
 
 
122
DROP VIEW v1;
 
123
DROP TABLE t1;
 
124
 
 
125
CREATE TABLE t1(a INT);
 
126
INSERT INTO t1 VALUES (1),(2);
 
127
 
 
128
--echo # should not crash
 
129
--error ER_WRONG_USAGE
 
130
CREATE TABLE t2 SELECT 1 FROM t1, t1 t3 GROUP BY t3.a PROCEDURE ANALYSE();
 
131
 
 
132
DROP TABLE t1;
 
133
 
 
134
 
 
135
--echo End of 5.0 tests