2000-12-28 02:56:38 +01:00
#
# Testing of comparison functions
#
select 0=0,1>0,1>=1,1<0,1<=0,1!=0,strcmp("abc","abcd"),strcmp("b","a"),strcmp("a","a") ;
select "a"<"b","a"<="b","b">="a","b">"a","a"="A","a"<>"b";
select "a "="A", "A "="a", "a " <= "A b";
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%";
select "a" like "%%b","a" like "%%ab","ab" like "a\%", "ab" like "_", "ab" like "ab_", "abc" like "%_d", "abc" like "abc%d";
select '?' like '|%', '?' like '|%' ESCAPE '|', '%' like '|%', '%' like '|%' ESCAPE '|', '%' like '%';
select 'abc' like '%c','abcabc' like '%c', "ab" like "", "ab" like "a", "ab" like "ab";
select "Det h<> r <20> r svenska" regexp "h[[:alpha:]]+r", "aba" regexp "^(a|b)*$";
select "aba" regexp concat("^","a");
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;
select 2 between 1 and 3, "monty" between "max" and "my",2=2 and "monty" between "max" and "my" and 3=3;
select 'b' between 'a' and 'c', 'B' between 'a' and 'c';
select 2 in (3,2,5,9,5,1),"monty" in ("david","monty","allan"), 1.2 in (1.4,1.2,1.0);
select -1.49 or -1.49,0.6 or 0.6;
2002-06-30 17:57:21 +02:00
select 3 ^ 11, 1 ^ 1, 1 ^ 0, 1 ^ NULL, NULL ^ 1;
select 1 XOR 1, 1 XOR 0, 0 XOR 1, 0 XOR 0, NULL XOR 1, 1 XOR NULL, 0 XOR NULL;
2002-11-21 01:07:14 +01:00
select 10 % 7, 10 mod 7, 10 div 3;
2003-03-19 20:23:13 +01:00
select (1 << 64)-1, ((1 << 64)-1) DIV 1, ((1 << 64)-1) DIV 2;
2002-06-30 17:57:21 +02:00
2003-08-05 16:29:09 +02:00
create table t1 (a int);
insert t1 values (1);
select * from t1 where 1 xor 1;
drop table t1;
2003-08-18 23:08:08 +02:00
#
# Wrong usage of functions
#
select 5 between 0 and 10 between 0 and 1,(5 between 0 and 10) between 0 and 1;
select 1 and 2 between 2 and 10, 2 between 2 and 10 and 1;
select 1 and 0 or 2, 2 or 1 and 0;
2003-06-10 12:25:27 +02:00
#
# Coercibility
#
select _koi8r'a' = _koi8r'A';
select _koi8r'a' = _koi8r'A' COLLATE koi8r_general_ci;
select _koi8r'a' = _koi8r'A' COLLATE koi8r_bin;
select _koi8r'a' COLLATE koi8r_general_ci = _koi8r'A';
select _koi8r'a' COLLATE koi8r_bin = _koi8r'A';
2003-08-18 23:08:08 +02:00
--error 1266
2003-06-10 12:25:27 +02:00
select _koi8r'a' COLLATE koi8r_bin = _koi8r'A' COLLATE koi8r_general_ci;
2003-08-18 23:08:08 +02:00
--error 1266
2003-06-10 12:25:27 +02:00
select _koi8r'a' = _latin1'A';
select strcmp(_koi8r'a', _koi8r'A');
select strcmp(_koi8r'a', _koi8r'A' COLLATE koi8r_general_ci);
select strcmp(_koi8r'a', _koi8r'A' COLLATE koi8r_bin);
select strcmp(_koi8r'a' COLLATE koi8r_general_ci, _koi8r'A');
select strcmp(_koi8r'a' COLLATE koi8r_bin, _koi8r'A');
2003-08-18 23:08:08 +02:00
--error 1266
2003-06-10 12:25:27 +02:00
select strcmp(_koi8r'a' COLLATE koi8r_general_ci, _koi8r'A' COLLATE koi8r_bin);
2003-08-18 23:08:08 +02:00
--error 1266
2003-06-10 12:25:27 +02:00
select strcmp(_koi8r'a', _latin1'A');
select _koi8r'a' LIKE _koi8r'A';
select _koi8r'a' LIKE _koi8r'A' COLLATE koi8r_general_ci;
select _koi8r'a' LIKE _koi8r'A' COLLATE koi8r_bin;
select _koi8r'a' COLLATE koi8r_general_ci LIKE _koi8r'A';
select _koi8r'a' COLLATE koi8r_bin LIKE _koi8r'A';
2003-08-18 23:08:08 +02:00
--error 1266
2003-06-10 12:25:27 +02:00
select _koi8r'a' COLLATE koi8r_general_ci LIKE _koi8r'A' COLLATE koi8r_bin;
2003-08-18 23:08:08 +02:00
--error 1266
2003-06-10 12:25:27 +02:00
select _koi8r'a' LIKE _latin1'A';