~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to tests/r/pbxt/null.result

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-10-02 14:17:48 UTC
  • mfrom: (1.1.1 upstream)
  • mto: (2.1.17 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20101002141748-m6vbfbfjhrw1153e
Tags: 2010.09.1802-1
* New upstream release.
* Removed pid-file argument hack.
* Updated GPL-2 address to be new address.
* Directly copy in drizzledump.1 since debian doesn't have sphinx 1.0 yet.
* Link to jquery from libjs-jquery. Add it as a depend.
* Add drizzled.8 symlink to the install files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
drop table if exists t1, t2;
 
2
select null,\N,isnull(null),isnull(1/0),isnull(1/0 = null),ifnull(null,1),ifnull(null,"TRUE"),ifnull("TRUE","ERROR"),1/0 is null,1 is not null;
 
3
NULL    NULL    isnull(null)    isnull(1/0)     isnull(1/0 = null)      ifnull(null,1)  ifnull(null,"TRUE")     ifnull("TRUE","ERROR")  1/0 is null     1 is not null
 
4
NULL    NULL    1       1       1       1       TRUE    TRUE    1       1
 
5
Warnings:
 
6
Error   1365    Division by 0
 
7
Error   1365    Division by 0
 
8
Error   1365    Division by 0
 
9
explain extended select null,\N,isnull(null),isnull(1/0),isnull(1/0 = null),ifnull(null,1),ifnull(null,"TRUE"),ifnull("TRUE","ERROR"),1/0 is null,1 is not null;
 
10
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
11
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
12
Warnings:
 
13
Error   1365    Division by 0
 
14
Error   1365    Division by 0
 
15
Error   1365    Division by 0
 
16
Note    1003    select NULL AS `NULL`,NULL AS `NULL`,isnull(NULL) AS `isnull(null)`,isnull((1 / 0)) AS `isnull(1/0)`,isnull(((1 / 0) = NULL)) AS `isnull(1/0 = null)`,ifnull(NULL,1) AS `ifnull(null,1)`,ifnull(NULL,'TRUE') AS `ifnull(null,"TRUE")`,ifnull('TRUE','ERROR') AS `ifnull("TRUE","ERROR")`,isnull((1 / 0)) AS `1/0 is null`,(1 is not null) AS `1 is not null`
 
17
select CONCAT(1, NULL),1+NULL,1-NULL;
 
18
CONCAT(1, NULL) 1+NULL  1-NULL
 
19
NULL    NULL    NULL
 
20
select NULL=NULL,NULL<>NULL,IFNULL(NULL,1.1)+0,CONCAT(IFNULL(NULL,1), 0);
 
21
NULL=NULL       NULL<>NULL      IFNULL(NULL,1.1)+0      CONCAT(IFNULL(NULL,1), 0)
 
22
NULL    NULL    1.1     10
 
23
select strcmp("a",NULL),(1<NULL)+0.0,null like "a%","a%" like null;
 
24
strcmp("a",NULL)        (1<NULL)+0.0    null like "a%"  "a%" like null
 
25
NULL    NULL    NULL    NULL
 
26
select concat("a",NULL),replace(NULL,"a","b"),replace("string","i",NULL),replace("string",NULL,"i"),insert("abc",1,1,NULL),left(NULL,1);
 
27
concat("a",NULL)        replace(NULL,"a","b")   replace("string","i",NULL)      replace("string",NULL,"i")      insert("abc",1,1,NULL)  left(NULL,1)
 
28
NULL    NULL    NULL    NULL    NULL    NULL
 
29
select repeat("a",0),repeat("ab",5+5),repeat("ab",-1),reverse(NULL);
 
30
repeat("a",0)   repeat("ab",5+5)        repeat("ab",-1) reverse(NULL)
 
31
        abababababababababab            NULL
 
32
select field(NULL,"a","b","c");
 
33
field(NULL,"a","b","c")
 
34
0
 
35
select 2 between null and 1,2 between 3 AND NULL,NULL between 1 and 2,2 between NULL and 3, 2 between 1 AND null;
 
36
2 between null and 1    2 between 3 AND NULL    NULL between 1 and 2    2 between NULL and 3    2 between 1 AND null
 
37
0       0       NULL    NULL    NULL
 
38
explain extended select 2 between null and 1,2 between 3 AND NULL,NULL between 1 and 2,2 between NULL and 3, 2 between 1 AND null;
 
39
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
40
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
41
Warnings:
 
42
Note    1003    select (2 between NULL and 1) AS `2 between null and 1`,(2 between 3 and NULL) AS `2 between 3 AND NULL`,(NULL between 1 and 2) AS `NULL between 1 and 2`,(2 between NULL and 3) AS `2 between NULL and 3`,(2 between 1 and NULL) AS `2 between 1 AND null`
 
43
SELECT NULL AND NULL, 1 AND NULL, NULL AND 1, NULL OR NULL, 0 OR NULL, NULL OR 0;
 
44
NULL AND NULL   1 AND NULL      NULL AND 1      NULL OR NULL    0 OR NULL       NULL OR 0
 
45
NULL    NULL    NULL    NULL    NULL    NULL
 
46
SELECT (NULL OR NULL) IS NULL;
 
47
(NULL OR NULL) IS NULL
 
48
1
 
49
select NULL AND 0, 0 and NULL;
 
50
NULL AND 0      0 and NULL
 
51
0       0
 
52
create table t1 (x int);
 
53
insert into t1 values (null);
 
54
select * from t1 where x != 0;
 
55
x
 
56
drop table t1;
 
57
CREATE TABLE t1 (
 
58
indexed_field int default NULL,
 
59
KEY indexed_field (indexed_field)
 
60
);
 
61
INSERT INTO t1 VALUES (NULL),(NULL);
 
62
SELECT * FROM t1 WHERE indexed_field=NULL;
 
63
indexed_field
 
64
SELECT * FROM t1 WHERE indexed_field IS NULL;
 
65
indexed_field
 
66
NULL
 
67
NULL
 
68
SELECT * FROM t1 WHERE indexed_field<=>NULL;
 
69
indexed_field
 
70
NULL
 
71
NULL
 
72
DROP TABLE t1;
 
73
create table t1 (a int, b int);
 
74
insert into t1 values(20,null);
 
75
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
 
76
t2.b=t3.a;
 
77
b       ifnull(t2.b,"this is null")
 
78
NULL    this is null
 
79
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
 
80
t2.b=t3.a order by 1;
 
81
b       ifnull(t2.b,"this is null")
 
82
NULL    this is null
 
83
insert into t1 values(10,null);
 
84
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
 
85
t2.b=t3.a order by 1;
 
86
b       ifnull(t2.b,"this is null")
 
87
NULL    this is null
 
88
NULL    this is null
 
89
drop table t1;
 
90
CREATE TABLE t1 (a varchar(16) NOT NULL default '', b int NOT NULL default 0, c datetime NOT NULL default '2009-02-10 00:00:00', d int NOT NULL default 0);
 
91
INSERT INTO t1 (a) values (null);
 
92
ERROR 23000: Column 'a' cannot be null
 
93
INSERT INTO t1 (a) values (1/null);
 
94
ERROR 23000: Column 'a' cannot be null
 
95
INSERT INTO t1 (a) values (null),(null);
 
96
ERROR 23000: Column 'a' cannot be null
 
97
INSERT INTO t1 (b) values (null);
 
98
ERROR 23000: Column 'b' cannot be null
 
99
INSERT INTO t1 (b) values (1/null);
 
100
ERROR 23000: Column 'b' cannot be null
 
101
INSERT INTO t1 (b) values (null),(null);
 
102
ERROR 23000: Column 'b' cannot be null
 
103
INSERT INTO t1 (c) values (null);
 
104
ERROR 23000: Column 'c' cannot be null
 
105
INSERT INTO t1 (c) values (1/null);
 
106
ERROR 23000: Column 'c' cannot be null
 
107
INSERT INTO t1 (c) values (null),(null);
 
108
ERROR 23000: Column 'c' cannot be null
 
109
INSERT INTO t1 (d) values (null);
 
110
ERROR 23000: Column 'd' cannot be null
 
111
INSERT INTO t1 (d) values (1/null);
 
112
ERROR 23000: Column 'd' cannot be null
 
113
INSERT INTO t1 (d) values (null),(null);
 
114
ERROR 23000: Column 'd' cannot be null
 
115
UPDATE t1 SET d= NULL;
 
116
INSERT INTO t1 VALUES ();
 
117
UPDATE t1 SET a=1/NULL;
 
118
ERROR 23000: Column 'a' cannot be null
 
119
UPDATE t1 SET a=NULL;
 
120
ERROR 23000: Column 'a' cannot be null
 
121
UPDATE t1 SET b=NULL;
 
122
ERROR 23000: Column 'b' cannot be null
 
123
UPDATE t1 SET c=NULL;
 
124
ERROR 23000: Column 'c' cannot be null
 
125
UPDATE t1 SET d=NULL;
 
126
ERROR 23000: Column 'd' cannot be null
 
127
truncate table t1;
 
128
LOAD DATA INFILE '../std_data_ln/null_test.txt' INTO TABLE t1 FIELDS ENCLOSED BY '"';
 
129
ERROR 22004: Column set to default value; NULL supplied to NOT NULL column 'a' at row 1
 
130
drop table t1;
 
131
create table t1 (a int not null, b int not null, index idx(a));
 
132
insert into t1 values
 
133
(1,1), (2,2), (3,3), (4,4), (5,5), (6,6),
 
134
(7,7), (8,8), (9,9), (10,10), (11,11), (12,12);
 
135
explain select * from t1 where a between 2 and 3;
 
136
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
137
1       SIMPLE  t1      ALL     idx     NULL    NULL    NULL    12      Using where
 
138
explain select * from t1 where a between 2 and 3 or b is null;
 
139
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
140
1       SIMPLE  t1      ALL     idx     NULL    NULL    NULL    12      Using where
 
141
drop table t1;
 
142
create table t1 select
 
143
null as c00,
 
144
if(1, null, 'string') as c01,
 
145
if(0, null, 'string') as c02,
 
146
ifnull(null, 'string') as c03,
 
147
ifnull('string', null) as c04,
 
148
case when 0 then null else 'string' end as c05,
 
149
case when 1 then null else 'string' end as c06,
 
150
coalesce(null, 'string') as c07,
 
151
coalesce('string', null) as c08,
 
152
least('string',null) as c09,
 
153
least(null, 'string') as c10,
 
154
greatest('string',null) as c11,
 
155
greatest(null, 'string') as c12,
 
156
nullif('string', null) as c13,
 
157
nullif(null, 'string') as c14,
 
158
trim('string' from null) as c15,
 
159
trim(null from 'string') as c16,
 
160
substring_index('string', null, 1) as c17,
 
161
substring_index(null, 'string', 1) as c18,
 
162
elt(1, null, 'string') as c19,
 
163
elt(1, 'string', null) as c20,
 
164
concat('string', null) as c21,
 
165
concat(null, 'string') as c22,
 
166
concat_ws('sep', 'string', null) as c23,
 
167
concat_ws('sep', null, 'string') as c24,
 
168
concat_ws(null, 'string', 'string') as c25,
 
169
make_set(3, 'string', null) as c26,
 
170
make_set(3, null, 'string') as c27,
 
171
export_set(3, null, 'off', 'sep') as c29,
 
172
export_set(3, 'on', null, 'sep') as c30,
 
173
export_set(3, 'on', 'off', null) as c31,
 
174
replace(null, 'from', 'to') as c32,
 
175
replace('str', null, 'to') as c33,
 
176
replace('str', 'from', null) as c34,
 
177
insert('str', 1, 2, null) as c35,
 
178
insert(null, 1, 2, 'str') as c36,
 
179
lpad('str', 10, null) as c37,
 
180
rpad(null, 10, 'str') as c38;
 
181
show create table t1;
 
182
Table   Create Table
 
183
t1      CREATE TABLE `t1` (
 
184
  `c00` VARBINARY(0) DEFAULT NULL,
 
185
  `c01` VARCHAR(6) COLLATE utf8_general_ci DEFAULT NULL,
 
186
  `c02` VARCHAR(6) COLLATE utf8_general_ci DEFAULT NULL,
 
187
  `c03` VARCHAR(6) COLLATE utf8_general_ci NOT NULL,
 
188
  `c04` VARCHAR(6) COLLATE utf8_general_ci DEFAULT NULL,
 
189
  `c05` VARCHAR(6) COLLATE utf8_general_ci DEFAULT NULL,
 
190
  `c06` VARCHAR(6) COLLATE utf8_general_ci DEFAULT NULL,
 
191
  `c07` VARCHAR(6) COLLATE utf8_general_ci DEFAULT NULL,
 
192
  `c08` VARCHAR(6) COLLATE utf8_general_ci DEFAULT NULL,
 
193
  `c09` VARCHAR(6) COLLATE utf8_general_ci DEFAULT NULL,
 
194
  `c10` VARCHAR(6) COLLATE utf8_general_ci DEFAULT NULL,
 
195
  `c11` VARCHAR(6) COLLATE utf8_general_ci DEFAULT NULL,
 
196
  `c12` VARCHAR(6) COLLATE utf8_general_ci DEFAULT NULL,
 
197
  `c13` VARCHAR(6) COLLATE utf8_general_ci DEFAULT NULL,
 
198
  `c14` VARCHAR(0) COLLATE utf8_general_ci DEFAULT NULL,
 
199
  `c15` VARCHAR(0) COLLATE utf8_general_ci DEFAULT NULL,
 
200
  `c16` VARCHAR(6) COLLATE utf8_general_ci DEFAULT NULL,
 
201
  `c17` VARCHAR(6) COLLATE utf8_general_ci DEFAULT NULL,
 
202
  `c18` VARCHAR(0) COLLATE utf8_general_ci DEFAULT NULL,
 
203
  `c19` VARCHAR(6) COLLATE utf8_general_ci DEFAULT NULL,
 
204
  `c20` VARCHAR(6) COLLATE utf8_general_ci DEFAULT NULL,
 
205
  `c21` VARCHAR(6) COLLATE utf8_general_ci DEFAULT NULL,
 
206
  `c22` VARCHAR(6) COLLATE utf8_general_ci DEFAULT NULL,
 
207
  `c23` VARCHAR(9) COLLATE utf8_general_ci DEFAULT NULL,
 
208
  `c24` VARCHAR(9) COLLATE utf8_general_ci DEFAULT NULL,
 
209
  `c25` VARCHAR(12) COLLATE utf8_general_ci DEFAULT NULL,
 
210
  `c26` VARCHAR(7) COLLATE utf8_general_ci DEFAULT NULL,
 
211
  `c27` VARCHAR(7) COLLATE utf8_general_ci DEFAULT NULL,
 
212
  `c29` VARCHAR(381) COLLATE utf8_general_ci DEFAULT NULL,
 
213
  `c30` VARCHAR(317) COLLATE utf8_general_ci DEFAULT NULL,
 
214
  `c31` VARCHAR(192) COLLATE utf8_general_ci DEFAULT NULL,
 
215
  `c32` VARCHAR(0) COLLATE utf8_general_ci DEFAULT NULL,
 
216
  `c33` VARCHAR(3) COLLATE utf8_general_ci DEFAULT NULL,
 
217
  `c34` VARCHAR(3) COLLATE utf8_general_ci DEFAULT NULL,
 
218
  `c35` VARCHAR(3) COLLATE utf8_general_ci DEFAULT NULL,
 
219
  `c36` VARCHAR(3) COLLATE utf8_general_ci DEFAULT NULL,
 
220
  `c37` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
 
221
  `c38` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL
 
222
) ENGINE=DEFAULT COLLATE = utf8_general_ci
 
223
drop table t1;
 
224
select 
 
225
case 'str' when 'STR' then 'str' when null then 'null' end as c01,
 
226
case 'str' when null then 'null' when 'STR' then 'str' end as c02,
 
227
field(null, 'str1', 'str2') as c03,
 
228
field('str1','STR1', null) as c04,
 
229
field('str1', null, 'STR1') as c05,
 
230
'string' in ('STRING', null) as c08,
 
231
'string' in (null, 'STRING') as c09;
 
232
c01     c02     c03     c04     c05     c08     c09
 
233
str     str     0       1       2       1       1
 
234
# End of 4.1 tests
 
235
#
 
236
# Bug #31471: decimal_bin_size: Assertion `scale >= 0 &&
 
237
#             precision > 0 && scale <= precision'
 
238
#
 
239
CREATE TABLE t1 (a DECIMAL (1, 0) , b DECIMAL (1, 0) );
 
240
INSERT INTO t1 (a, b) VALUES (0, 0);
 
241
CREATE TABLE t2 SELECT IFNULL(a, b) FROM t1;
 
242
DESCRIBE t2;
 
243
Field   Type    Null    Default Default_is_NULL On_Update
 
244
IFNULL(a, b)    DECIMAL YES             YES     
 
245
DROP TABLE t2;
 
246
CREATE TABLE t2 SELECT IFNULL(a, NULL) FROM t1;
 
247
DESCRIBE t2;
 
248
Field   Type    Null    Default Default_is_NULL On_Update
 
249
IFNULL(a, NULL) DECIMAL YES             YES     
 
250
DROP TABLE t2;
 
251
CREATE TABLE t2 SELECT IFNULL(NULL, b) FROM t1;
 
252
DESCRIBE t2;
 
253
Field   Type    Null    Default Default_is_NULL On_Update
 
254
IFNULL(NULL, b) DECIMAL YES             YES     
 
255
DROP TABLE t1, t2;
 
256
# End of 5.0 tests