~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/bug588408.result

  • Committer: Jay Pipes
  • Date: 2009-01-30 04:01:12 UTC
  • mto: This revision was merged to the branch mainline in revision 830.
  • Revision ID: jpipes@serialcoder-20090130040112-svbn774guj98pwi4
To remain in compatibility with MySQL, added ability to interpret
decimal arguments as datetime strings for temporal functions.

Fixed YEAR(), MONTH(), DAYOFMONTH(), DAYOFYEAR(), HOUR(), MINUTE(), SECOND(), and MICROSECOND()
to accept decimal parameters and interpret them the same way as MySQL.

Fixed an issue with the TemporalFormat::matches() method which was 
incorrectly assuming all microsecond arguments were specified as 6 digits.
Added power of 10 multiplier to usecond calculation. This fixes issues with
failures in type_date and func_sapdb test cases.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
# BUG#46680 - Assertion failed in file item_subselect.cc, 
3
 
#             line 305 crashing on HAVING subquery
4
 
#
5
 
# Create tables
6
 
#
7
 
CREATE TABLE t1 (
8
 
pk INT,
9
 
v VARCHAR(1) DEFAULT NULL,
10
 
PRIMARY KEY(pk)
11
 
);
12
 
CREATE TABLE t2 LIKE t1;
13
 
CREATE TABLE t3 LIKE t1;
14
 
CREATE TABLE empty1 (a int);
15
 
INSERT INTO t1 VALUES (1,'c'),(2,NULL);
16
 
INSERT INTO t2 VALUES (3,'m'),(4,NULL);
17
 
INSERT INTO t3 VALUES (1,'n');
18
 
 
19
 
#
20
 
# 1) Test that subquery materialization is setup for query with
21
 
#    premature optimize() exit due to "Impossible WHERE"
22
 
#
23
 
SELECT MIN(t2.pk)
24
 
FROM t2 JOIN t1 ON t1.pk=t2.pk
25
 
WHERE 'j'
26
 
HAVING ('m') IN ( 
27
 
SELECT v
28
 
FROM t2);
29
 
MIN(t2.pk)
30
 
NULL
31
 
Warnings:
32
 
Warning 1292    Truncated incorrect INTEGER value: 'j'
33
 
 
34
 
EXPLAIN
35
 
SELECT MIN(t2.pk)
36
 
FROM t2 JOIN t1 ON t1.pk=t2.pk
37
 
WHERE 'j'
38
 
HAVING ('m') IN ( 
39
 
SELECT v
40
 
FROM t2);
41
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
42
 
1       PRIMARY NULL    NULL    NULL    NULL    NULL    NULL    NULL    Impossible WHERE
43
 
2       SUBQUERY        t2      ALL     NULL    NULL    NULL    NULL    2       
44
 
Warnings:
45
 
Warning 1292    Truncated incorrect INTEGER value: 'j'
46
 
 
47
 
#
48
 
# 2) Test that subquery materialization is setup for query with
49
 
#    premature optimize() exit due to "No matching min/max row"
50
 
#
51
 
SELECT MIN(t2.pk)
52
 
FROM t2 
53
 
WHERE t2.pk>10
54
 
HAVING ('m') IN ( 
55
 
SELECT v
56
 
FROM t2);
57
 
MIN(t2.pk)
58
 
NULL
59
 
 
60
 
EXPLAIN
61
 
SELECT MIN(t2.pk)
62
 
FROM t2 
63
 
WHERE t2.pk>10
64
 
HAVING ('m') IN ( 
65
 
SELECT v
66
 
FROM t2);
67
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
68
 
1       PRIMARY NULL    NULL    NULL    NULL    NULL    NULL    NULL    No matching min/max row
69
 
2       SUBQUERY        t2      ALL     NULL    NULL    NULL    NULL    2       
70
 
 
71
 
#
72
 
# 3) Test that subquery materialization is setup for query with
73
 
#    premature optimize() exit due to "Select tables optimized away"
74
 
#
75
 
# NOTE: The result of this query is actually wrong; it should be NULL
76
 
# See BUG#47762. Even so, the test case is still needed to test
77
 
# that the HAVING subquery does not crash the server
78
 
79
 
SELECT MIN(pk)
80
 
FROM t1
81
 
WHERE pk=NULL
82
 
HAVING ('m') IN ( 
83
 
SELECT v
84
 
FROM t2);
85
 
MIN(pk)
86
 
2
87
 
 
88
 
EXPLAIN
89
 
SELECT MIN(pk)
90
 
FROM t1
91
 
WHERE pk=NULL
92
 
HAVING ('m') IN ( 
93
 
SELECT v
94
 
FROM t2);
95
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
96
 
1       PRIMARY NULL    NULL    NULL    NULL    NULL    NULL    NULL    Select tables optimized away
97
 
2       SUBQUERY        t2      ALL     NULL    NULL    NULL    NULL    2       
98
 
 
99
 
#
100
 
# 4) Test that subquery materialization is setup for query with
101
 
#    premature optimize() exit due to "No matching row in const table"
102
 
#
103
 
 
104
 
SELECT MIN(a)
105
 
FROM (SELECT a FROM empty1) tt
106
 
HAVING ('m') IN ( 
107
 
SELECT v
108
 
FROM t2);
109
 
MIN(a)
110
 
NULL
111
 
 
112
 
EXPLAIN 
113
 
SELECT MIN(a)
114
 
FROM (SELECT a FROM empty1) tt
115
 
HAVING ('m') IN ( 
116
 
SELECT v
117
 
FROM t2);
118
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
119
 
1       PRIMARY <derived2>      system  NULL    NULL    NULL    NULL    0       const row not found
120
 
3       SUBQUERY        t2      ALL     NULL    NULL    NULL    NULL    2       
121
 
2       DERIVED empty1  ALL     NULL    NULL    NULL    NULL    1       
122
 
 
123
 
#
124
 
# 5) Test that subquery materialization is setup for query with
125
 
#    premature optimize() exit due to "Impossible WHERE noticed 
126
 
#    after reading const tables"
127
 
#
128
 
SELECT min(t1.pk)
129
 
FROM t1
130
 
WHERE t1.pk IN (SELECT 1 from t3 where pk>10)
131
 
HAVING ('m') IN ( 
132
 
SELECT v
133
 
FROM t2);
134
 
min(t1.pk)
135
 
NULL
136
 
 
137
 
EXPLAIN
138
 
SELECT min(t1.pk)
139
 
FROM t1
140
 
WHERE t1.pk IN (SELECT 1 from t3 where pk>10)
141
 
HAVING ('m') IN ( 
142
 
SELECT v
143
 
FROM t2);
144
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
145
 
1       PRIMARY t1      index   NULL    PRIMARY 4       NULL    2       Using where; Using index
146
 
3       SUBQUERY        t2      ALL     NULL    NULL    NULL    NULL    2       
147
 
2       SUBQUERY        t3      index   PRIMARY PRIMARY 4       NULL    1       Using where; Using index
148
 
#
149
 
# Cleanup for BUG#46680
150
 
#
151
 
DROP TABLE IF EXISTS t1,t2,t3,empty1;
152
 
End of 6.0 tests