sql: accept IS NOT DISTINCT FROM operator (fix #54)
[sqlgg.git] / test / misc.sql
blob7cd626e9489130a839e6e2bd93a1cc6a991f0309
1 SELECT strftime('%s','now');
2 CREATE TABLE test (x INT, `key` VARBINARY(200));
3 SELECT * FROM test WHERE x IS NOT NULL;
4 CREATE INDEX `key` ON test(`key`(20));
5 SELECT avg(x) FROM test;
6 SELECT count(*) FROM test;
7 SELECT x FROM test WHERE ? >= `key` ORDER BY `key` DESC LIMIT 1;
8 SELECT x FROM test WHERE `key` < ?;
10 CREATE TABLE appointments (alert_at DATETIME);
11 INSERT INTO `appointments` (
12   `alert_at`
13 ) VALUES (
14   NOW() + INTERVAL @delay SECOND
16 SELECT SUM(CASE WHEN x > 10 THEN 1 ELSE 0 END) FROM test;
17 -- delete from txn_ranges
18 -- where id in (@tr1_id, @tr2_id)
19 --   and not exists (select 1 from workareas where txn_range_id = txn_ranges.id)
21 CREATE TABLE issue14 (x integer);
22 INSERT INTO issue14 (x) VALUES (@x);
23 INSERT INTO issue14 SET x = @x;
24 INSERT INTO issue14 (x) SELECT @x;
26 INSERT INTO test VALUES (20, 'twenty') ON DUPLICATE KEY UPDATE x = x + ?;
27 INSERT INTO test VALUES (20, 'twenty') ON DUPLICATE KEY UPDATE x = VALUES(x) + ?;
28 INSERT INTO test VALUES (20, $$twenty$$);
29 INSERT INTO test VALUES (200,
30 $$twenty
31 times
32 ten$$);
34 SELECT $function$
35 BEGIN
36     RETURN ($1 ~ $q$[\t\r\n\v\\]$q$);
37 END;
38 $function$;
40 INSERT INTO `test` (`x`, `key`) VALUES
41 (1, 'one'),
42 (2, 'two'),
43 (3, 'three');
45 INSERT INTO test VALUES
46 (1, 'one'),
47 (2, 'two'),
48 (3, 'three');
50 -- @issue47
51 SELECT count(*) > 0 FROM test;
52 SELECT count(*) * avg(x) FROM test;
54 -- @issue45
55 INSERT INTO test VALUES
56 (1, @one),
57 (2, @two),
58 (3, @one);
60 INSERT INTO `appointments` ( `alert_at`) VALUES (@alert);
61 INSERT INTO `appointments` ( `alert_at`) VALUES (FROM_UNIXTIME(@alert));
63 -- @count_x
64 SELECT COUNT(x) FROM test;
66 -- @count_distinct
67 SELECT COUNT(DISTINCT x), SUM(DISTINCT x) FROM test;
69 -- @issue54_mysql
70 SELECT 0 <=> 0, 0 <=> null, null <=> 0, null <=> null;
72 -- @issue54_sqlite
73 SELECT 0 is 0, 0 is null, null is 0, null is null;
75 -- @issue54_sql
76 SELECT 42 is not distinct from null, 42 is distinct from null;