~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/func_test.test

  • Committer: Monty Taylor
  • Date: 2008-09-15 17:24:04 UTC
  • Revision ID: monty@inaugust.com-20080915172404-ygh6hiyu0q7qpa9x
Removed strndup calls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
--disable_warnings
2
 
drop table if exists t1,t2;
3
 
--enable_warnings
4
 
#
5
 
# Testing of comparison functions
6
 
#
7
 
select 0=0,1>0,1>=1,1<0,1<=0,1!=0,strcmp("abc","abcd"),strcmp("b","a"),strcmp("a","a") ;
8
 
select "a"<"b","a"<="b","b">="a","b">"a","a"="A","a"<>"b";
9
 
select "a "="A", "A "="a", "a  " <= "A b"; 
10
 
select "abc" like "a%", "abc" not like "%d%", "a%" like "a\%","abc%" like "a%\%","abcd" like "a%b_%d", "a" like "%%a","abcde" like "a%_e","abc" like "abc%";
11
 
select "a" like "%%b","a" like "%%ab","ab" like "a\%", "ab" like "_", "ab" like "ab_", "abc" like "%_d", "abc" like "abc%d";
12
 
select '?' like '|%', '?' like '|%' ESCAPE '|', '%' like '|%', '%' like '|%' ESCAPE '|', '%' like '%';
13
 
select 'abc' like '%c','abcabc' like '%c',  "ab" like "", "ab" like "a", "ab" like "ab";
14
 
select "Det h�r �r svenska" regexp "h[[:alpha:]]+r", "aba" regexp "^(a|b)*$";
15
 
select "aba" regexp concat("^","a");
16
 
select !0,NOT 0=1,!(0=0),1 AND 1,1 && 0,0 OR 1,1 || NULL, 1=1 or 1=1 and 1=0;
17
 
select 2 between 1 and 3, "monty" between "max" and "my",2=2 and "monty" between "max" and "my" and 3=3;
18
 
select 'b' between 'a' and 'c', 'B' between 'a' and 'c';
19
 
select 2 in (3,2,5,9,5,1),"monty" in ("david","monty","allan"), 1.2 in (1.4,1.2,1.0);
20
 
select -1.49 or -1.49,0.6 or 0.6;
21
 
select 3 ^ 11, 1 ^ 1, 1 ^ 0, 1 ^ NULL, NULL ^ 1;
22
 
explain extended select 3 ^ 11, 1 ^ 1, 1 ^ 0, 1 ^ NULL, NULL ^ 1;
23
 
select 1 XOR 1, 1 XOR 0, 0 XOR 1, 0 XOR 0, NULL XOR 1, 1 XOR NULL, 0 XOR NULL;
24
 
select 1 like 2 xor 2 like 1;
25
 
select 10 % 7, 10 mod 7, 10 div 3;
26
 
explain extended select 10 % 7, 10 mod 7, 10 div 3;
27
 
select (1 << 64)-1, ((1 << 64)-1) DIV 1, ((1 << 64)-1) DIV 2;
28
 
explain extended select (1 << 64)-1, ((1 << 64)-1) DIV 1, ((1 << 64)-1) DIV 2;
29
 
 
30
 
create table t1 (a int);
31
 
insert t1 values (1);
32
 
select * from t1 where 1 xor 1;
33
 
explain extended select * from t1 where 1 xor 1;
34
 
select - a from t1;
35
 
explain extended select - a from t1;
36
 
drop table t1;
37
 
 
38
 
#
39
 
# Wrong usage of functions
40
 
#
41
 
 
42
 
select 5 between 0 and 10 between 0 and 1,(5 between 0 and 10) between 0 and 1;
43
 
select 1 and 2 between 2 and 10, 2 between 2 and 10 and 1;
44
 
select 1 and 0 or 2, 2 or 1 and 0;
45
 
 
46
 
#
47
 
# Coercibility
48
 
#
49
 
select _koi8r'a' = _koi8r'A';
50
 
select _koi8r'a' = _koi8r'A' COLLATE koi8r_general_ci;
51
 
explain extended select _koi8r'a' = _koi8r'A' COLLATE koi8r_general_ci;
52
 
select _koi8r'a' = _koi8r'A' COLLATE koi8r_bin;
53
 
select _koi8r'a' COLLATE koi8r_general_ci = _koi8r'A';
54
 
select _koi8r'a' COLLATE koi8r_bin = _koi8r'A';
55
 
--error 1267
56
 
select _koi8r'a' COLLATE koi8r_bin = _koi8r'A' COLLATE koi8r_general_ci;
57
 
--error 1267
58
 
select _koi8r'a' = _latin1'A';
59
 
 
60
 
select strcmp(_koi8r'a', _koi8r'A');
61
 
select strcmp(_koi8r'a', _koi8r'A' COLLATE koi8r_general_ci);
62
 
select strcmp(_koi8r'a', _koi8r'A' COLLATE koi8r_bin);
63
 
select strcmp(_koi8r'a' COLLATE koi8r_general_ci, _koi8r'A');
64
 
select strcmp(_koi8r'a' COLLATE koi8r_bin, _koi8r'A');
65
 
--error 1267
66
 
select strcmp(_koi8r'a' COLLATE koi8r_general_ci, _koi8r'A' COLLATE koi8r_bin);
67
 
--error 1267
68
 
select strcmp(_koi8r'a', _latin1'A');
69
 
 
70
 
select _koi8r'a' LIKE _koi8r'A';
71
 
select _koi8r'a' LIKE _koi8r'A' COLLATE koi8r_general_ci;
72
 
select _koi8r'a' LIKE _koi8r'A' COLLATE koi8r_bin;
73
 
select _koi8r'a' COLLATE koi8r_general_ci LIKE _koi8r'A';
74
 
select _koi8r'a' COLLATE koi8r_bin LIKE _koi8r'A';
75
 
--error 1267
76
 
select _koi8r'a' COLLATE koi8r_general_ci LIKE _koi8r'A' COLLATE koi8r_bin;
77
 
--error 1267
78
 
select _koi8r'a' LIKE _latin1'A';
79
 
 
80
 
#
81
 
# Test for LEAST() BUG in LEFT JOIN
82
 
#
83
 
CREATE TABLE t1 (   faq_group_id int(11) NOT NULL default '0',   faq_id int(11) NOT NULL default '0',   title varchar(240) default NULL,   keywords text,   description longblob,   solution longblob,   status int(4) NOT NULL default '0',   access_id int(6) default NULL,   lang_id int(6) NOT NULL default '0',   created datetime NOT NULL default '0000-00-00 00:00:00',   updated datetime default NULL,   last_access datetime default NULL,   last_notify datetime default NULL,   solved_count int(11) NOT NULL default '0',   static_solved int(11) default NULL,   solved_1 int(11) default NULL,   solved_2 int(11) default NULL,   solved_3 int(11) default NULL,   solved_4 int(11) default NULL,   solved_5 int(11) default NULL,   expires datetime default NULL,   notes text,   assigned_to int(6) default NULL,   assigned_group int(6) default NULL,   last_edited_by int(6) default NULL,   orig_ref_no varchar(15) binary default NULL,   c$fundstate int(6) default NULL,   c$contributor int(6) default NULL,   UNIQUE KEY t1$faq_id (faq_id),   KEY t1$group_id$faq_id (faq_group_id,faq_id),   KEY t1$c$fundstate (c$fundstate) ) ENGINE=MyISAM;
84
 
INSERT INTO t1 VALUES (82,82,'How to use the DynaVox Usage Counts Feature','usages count, number, corner, white, box, button','<as-html>\r\n<table width=\"100%\" border=\"0\">\r\n  <tr>\r\n    <td width=\"3%\">�</td>\r\n    <td width=\"97%\">\r\n       <h3><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#000000\">How \r\n        To</font><!-- #BeginEditable \"CS_troubleshoot_question\" --><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#000099\"><font color=\"#000000\">: \r\n        Display or Hide the Usage Counts to find out how many times each button is being selected. </font></font><!-- #EndEditable --></h3>\r\n    </td>\r\n  </tr>\r\n</table>','<as-html>\r\n <table width=\"100%\" border=\"0\">\r\n  <tr>\r\n    <td width=\"3%\">�</td>\r\n    \r\n<td width=\"97%\"><!-- #BeginEditable \"CS_troubleshoot_answer\" --> \r\n      \r\n<p><font color=\"#000000\" face=\"Verdana, Arial, Helvetica, sans-serif\">1. Select \r\n  the <i>On/Setup</i> button to access the DynaVox Setup Menu.<br>\r\n  2. Select <b>Button Features.</b><br>\r\n  3. Below the <b>OK</b> button is the <b>Usage Counts</b> button.<br>\r\n  a. If it says \"Hidden\" then the Usage Counts will not be displayed.<br>\r\n  b. If it says \"Displayed\" then the Usage Counts will be shown.<br>\r\n        c. Select the <b>Usage Counts</b> Option Ring once and it will toggle \r\n        to the alternative option.<br>\r\n  4. Once the correct setting has been chosen, select <b>OK</b> to leave the <i>Button \r\n  Features</i> menu.<br>\r\n  5. Select <b>OK</b> out of the <i>Setup</i> menu and return to the communication \r\n  page.</font></p>\r\n      <p><font color=\"#000000\" face=\"Verdana, Arial, Helvetica, sans-serif\">For \r\n        further information on <i>Usage Counts,</i> see the <i>Button Features \r\n        Menu Entry</i> in the DynaVox/DynaMyte Reference Manual.</font></p>\r\n<!-- #EndEditable --></td>\r\n  </tr>\r\n</table>',4,1,1,'2001-11-16 16:43:34','2002-11-25 12:09:43','2003-07-24 01:04:48',NULL,11,NULL,0,0,0,0,0,NULL,NULL,NULL,NULL,11,NULL,NULL,NULL);
85
 
CREATE TABLE t2 (  access_id int(6) NOT NULL default '0',   name varchar(20) binary default NULL,   rank int(6) NOT NULL default '0',   KEY t2$access_id (access_id) ) ENGINE=MyISAM;
86
 
INSERT INTO t2 VALUES (1,'Everyone',2),(2,'Help',3),(3,'Customer Support',1);
87
 
SELECT f_acc.rank, a1.rank, a2.rank  FROM t1 LEFT JOIN t1 f1 ON  (f1.access_id=1 AND f1.faq_group_id = t1.faq_group_id) LEFT JOIN t2 a1 ON (a1.access_id =  f1.access_id) LEFT JOIN t1 f2 ON (f2.access_id=3 AND  f2.faq_group_id = t1.faq_group_id) LEFT  JOIN t2 a2 ON (a2.access_id = f2.access_id), t2 f_acc WHERE LEAST(a1.rank,a2.rank) =  f_acc.rank;
88
 
DROP TABLE t1,t2;
89
 
 
90
 
#
91
 
# Test for GREATEST() and LEAST() bug, which segfaulted 4.1.1 server
92
 
#
93
 
CREATE TABLE t1 (d varchar(6), k int);
94
 
INSERT INTO t1 VALUES (NULL, 2);
95
 
SELECT GREATEST(d,d) FROM t1 WHERE k=2;
96
 
DROP TABLE t1;
97
 
 
98
 
#
99
 
# Bug #6138: mod and doubles
100
 
#
101
 
 
102
 
select 1197.90 mod 50;
103
 
select 5.1 mod 3, 5.1 mod -3, -5.1 mod 3, -5.1 mod -3;
104
 
 
105
 
#
106
 
# Test for mod and signed integers
107
 
#
108
 
 
109
 
select 5 mod 3, 5 mod -3, -5 mod 3, -5 mod -3;
110
 
 
111
 
#
112
 
# Bug#23411: The "%" (MOD) operator is not documented; MOD-ing zero returns strange result
113
 
# Manual: "Division by zero produces a NULL result"
114
 
#
115
 
select (12%0) <=> null      as '1';
116
 
select (12%0) is null       as '1';
117
 
select 12%0                 as 'NULL';
118
 
select 12%2                 as '0';
119
 
select 12%NULL              as 'NULL';
120
 
select 12 % null            as 'NULL';
121
 
select null % 12            as 'NULL';
122
 
select null % 0             as 'NULL';
123
 
select 0 % null             as 'NULL';
124
 
select null % null          as 'NULL';
125
 
 
126
 
select (12 mod 0) <=> null  as '1';
127
 
select (12 mod 0) is null   as '1';
128
 
select 12 mod 0             as 'NULL';
129
 
select 12 mod 2             as '0';
130
 
select 12 mod null          as 'NULL';
131
 
select null mod 12          as 'NULL';
132
 
select null mod 0           as 'NULL';
133
 
select 0 mod null           as 'NULL';
134
 
select null mod null        as 'NULL';
135
 
 
136
 
select mod(12.0, 0)         as 'NULL';
137
 
select mod(12, 0.0)         as 'NULL';
138
 
select mod(12, NULL)        as 'NULL';
139
 
select mod(12.0, NULL)      as 'NULL';
140
 
select mod(NULL, 2)         as 'NULL';
141
 
select mod(NULL, 2.0)       as 'NULL';
142
 
 
143
 
 
144
 
#
145
 
# Bug#6726: NOT BETWEEN parse failure
146
 
#
147
 
create table t1 (a int, b int);
148
 
insert into t1 values (1,2), (2,3), (3,4), (4,5);
149
 
select * from t1 where a not between 1 and 2;
150
 
select * from t1 where a not between 1 and 2 and b not between 3 and 4;
151
 
drop table t1;
152
 
 
153
 
#
154
 
# Test for bug #12791: one of the arguments of LEAST/GREATEST is NULL
155
 
#
156
 
 
157
 
SELECT GREATEST(1,NULL) FROM DUAL;
158
 
SELECT LEAST('xxx','aaa',NULL,'yyy') FROM DUAL;
159
 
SELECT LEAST(1.1,1.2,NULL,1.0) FROM DUAL;
160
 
SELECT GREATEST(1.5E+2,1.3E+2,NULL) FROM DUAL;
161
 
 
162
 
# End of 4.1 tests