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

« back to all changes in this revision

Viewing changes to plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/bool.test

  • 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
#
 
2
# Test of boolean operations with NULL
 
3
#
 
4
 
 
5
--disable_warnings
 
6
DROP TABLE IF EXISTS t1;
 
7
--enable_warnings
 
8
 
 
9
SELECT IF(NULL AND 1, 1, 2), IF(1 AND NULL, 1, 2);
 
10
SELECT NULL AND 1, 1 AND NULL, 0 AND NULL, NULL and 0;
 
11
 
 
12
create table t1 (a int);
 
13
insert into t1 values (0),(1),(NULL);
 
14
SELECT * FROM t1 WHERE IF(a AND 1, 0, 1);
 
15
SELECT * FROM t1 WHERE IF(1 AND a, 0, 1);
 
16
SELECT * FROM t1 where NOT(a AND 1);
 
17
SELECT * FROM t1 where NOT(1 AND a);
 
18
SELECT * FROM t1 where (a AND 1)=0;
 
19
SELECT * FROM t1 where (1 AND a)=0;
 
20
SELECT * FROM t1 where (1 AND a)=1;
 
21
SELECT * FROM t1 where (1 AND a) IS NULL;
 
22
 
 
23
# SQL boolean tests
 
24
select a, a is false, a is true, a is unknown from t1;
 
25
select a, a is not false, a is not true, a is not unknown from t1;
 
26
 
 
27
# Verify that NULL optimisation works in AND clause:
 
28
SET @a=0, @b=0;
 
29
SELECT * FROM t1 WHERE NULL AND (@a:=@a+1);
 
30
SELECT * FROM t1 WHERE NOT(a>=0 AND NULL AND (@b:=@b+1));
 
31
SELECT * FROM t1 WHERE a=2 OR (NULL AND (@a:=@a+1));
 
32
SELECT * FROM t1 WHERE NOT(a=2 OR (NULL AND (@b:=@b+1)));
 
33
DROP TABLE t1;
 
34
 
 
35
 
 
36
# Test boolean operators in select part
 
37
# NULLs are represented as N for readability
 
38
# Read nA as !A, AB as A && B, AoB as A || B
 
39
# Result table makes ANSI happy
 
40
 
 
41
create table t1 (a int, b int);
 
42
insert into t1 values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1);
 
43
 
 
44
# Below test is valid untill we have True/False implemented as 1/0
 
45
# To comply to all rules it must show that:  n(AB) = nAonB,  n(AoB) = nAnB 
 
46
 
 
47
select ifnull(A, 'N') as A, ifnull(B, 'N') as B, ifnull(not A, 'N') as nA, ifnull(not B, 'N') as nB, ifnull(A and B, 'N') as AB, ifnull(not (A and B), 'N') as `n(AB)`, ifnull((not A or not B), 'N') as nAonB, ifnull(A or B, 'N') as AoB, ifnull(not(A or B), 'N') as `n(AoB)`, ifnull(not A and not B, 'N') as nAnB from t1;
 
48
 
 
49
# This should work with any internal representation of True/False
 
50
# Result must be same as above
 
51
 
 
52
select ifnull(A=1, 'N') as A, ifnull(B=1, 'N') as B, ifnull(not (A=1), 'N') as nA, ifnull(not (B=1), 'N') as nB, ifnull((A=1) and (B=1), 'N') as AB, ifnull(not ((A=1) and (B=1)), 'N') as `n(AB)`, ifnull((not (A=1) or not (B=1)), 'N') as nAonB, ifnull((A=1) or (B=1), 'N') as AoB, ifnull(not((A=1) or (B=1)), 'N') as `n(AoB)`, ifnull(not (A=1) and not (B=1), 'N') as nAnB from t1;
 
53
 
 
54
drop table t1;
 
55
 
 
56
# End of 4.1 tests