1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-34189 Unexpected error on WHERE inet6col

normalize_cond() translated `WHERE col` into `WHERE col<>0`

But the opetator "not equal to 0" does not necessarily exists
for all data types.

For example, the query:

  SELECT * FROM t1 WHERE inet6col;

was translated to:

  SELECT * FROM t1 WHERE inet6col<>0;

which further failed with this error:

  ERROR : Illegal parameter data types inet6 and bigint for operation '<>'

This patch changes the translation from `col<>0` to `col IS TRUE`.
So now
  SELECT * FROM t1 WHERE inet6col;
gets translated to:
  SELECT * FROM t1 WHERE inet6col IS TRUE;

Details:
1. Implementing methods:
   - Field_longstr::val_bool()
   - Field_string::val_bool()
   - Item::val_int_from_val_str()
   If the input contains bad data,
   these methods raise a better error message:
     Truncated incorrect BOOLEAN value
   Before the change, the error was:
     Truncated incorrect DOUBLE value

2. Fixing normalize_cond() to generate Item_func_istrue/Item_func_isfalse
   instances instead of Item_func_ne/Item_func_eq

3. Making Item_func_truth sargable, so it uses the range optimizer.
   Implementing the following methods:
   - get_mm_tree(), get_mm_leaf(), add_key_fields() in Item_func_truth.
   - get_func_mm_tree(), for all Item_func_truth descendants.

4. Implementing the method negated_item() for all Item_func_truth
   descendants, so the negated item has a chance to be sargable:
   For example,
     WHERE NOT col IS NOT FALSE    -- this notation is not sargable
   is now translated to:
     WHERE col IS FALSE            -- this notation is sargable
This commit is contained in:
Alexander Barkov
2024-12-29 12:50:04 +04:00
parent d1ba623677
commit 5a8e6230d7
47 changed files with 1670 additions and 257 deletions

View File

@@ -1911,9 +1911,9 @@ a b
foo 0.0.0.0
bar 1.0.0.1
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'foo'
Warning 1292 Truncated incorrect BOOLEAN value: 'foo'
Warning 1292 Incorrect inet4 value: 'foo'
Warning 1292 Truncated incorrect DOUBLE value: 'bar'
Warning 1292 Truncated incorrect BOOLEAN value: 'bar'
Warning 1292 Incorrect inet4 value: 'bar'
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (a VARCHAR(8) NOT NULL);
@@ -2029,3 +2029,256 @@ DROP TABLE t1;
#
# End of 10.10 tests
#
# Start of 11.8 tests
#
# MDEV-34189 Unexpected error on `WHERE inet6col`
#
CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY, a INET4, KEY(a));
INSERT INTO t1 VALUES (-1,NULL);
INSERT INTO t1 SELECT seq,CONCAT('0.0.0.',seq) FROM seq_0_to_31;
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE a;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL a NULL NULL NULL 33 96.97 Using where
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is true
SELECT id, a FROM t1 WHERE a;
id a
1 0.0.0.1
2 0.0.0.2
3 0.0.0.3
4 0.0.0.4
5 0.0.0.5
6 0.0.0.6
7 0.0.0.7
8 0.0.0.8
9 0.0.0.9
10 0.0.0.10
11 0.0.0.11
12 0.0.0.12
13 0.0.0.13
14 0.0.0.14
15 0.0.0.15
16 0.0.0.16
17 0.0.0.17
18 0.0.0.18
19 0.0.0.19
20 0.0.0.20
21 0.0.0.21
22 0.0.0.22
23 0.0.0.23
24 0.0.0.24
25 0.0.0.25
26 0.0.0.26
27 0.0.0.27
28 0.0.0.28
29 0.0.0.29
30 0.0.0.30
31 0.0.0.31
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE NOT a;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range a a 5 NULL 1 100.00 Using index condition
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is false
SELECT id, a FROM t1 WHERE NOT a;
id a
0 0.0.0.0
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE a IS TRUE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL a NULL NULL NULL 33 96.97 Using where
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is true
SELECT id, a FROM t1 WHERE a IS TRUE;
id a
1 0.0.0.1
2 0.0.0.2
3 0.0.0.3
4 0.0.0.4
5 0.0.0.5
6 0.0.0.6
7 0.0.0.7
8 0.0.0.8
9 0.0.0.9
10 0.0.0.10
11 0.0.0.11
12 0.0.0.12
13 0.0.0.13
14 0.0.0.14
15 0.0.0.15
16 0.0.0.16
17 0.0.0.17
18 0.0.0.18
19 0.0.0.19
20 0.0.0.20
21 0.0.0.21
22 0.0.0.22
23 0.0.0.23
24 0.0.0.24
25 0.0.0.25
26 0.0.0.26
27 0.0.0.27
28 0.0.0.28
29 0.0.0.29
30 0.0.0.30
31 0.0.0.31
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE NOT a IS TRUE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range a a 5 NULL 2 100.00 Using index condition
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is not true
SELECT id, a FROM t1 WHERE NOT a IS TRUE;
id a
-1 NULL
0 0.0.0.0
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE a IS NOT TRUE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range a a 5 NULL 2 100.00 Using index condition
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is not true
SELECT id, a FROM t1 WHERE a IS NOT TRUE;
id a
-1 NULL
0 0.0.0.0
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE NOT a IS NOT TRUE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL a NULL NULL NULL 33 96.97 Using where
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is true
SELECT id, a FROM t1 WHERE NOT a IS NOT TRUE;
id a
1 0.0.0.1
2 0.0.0.2
3 0.0.0.3
4 0.0.0.4
5 0.0.0.5
6 0.0.0.6
7 0.0.0.7
8 0.0.0.8
9 0.0.0.9
10 0.0.0.10
11 0.0.0.11
12 0.0.0.12
13 0.0.0.13
14 0.0.0.14
15 0.0.0.15
16 0.0.0.16
17 0.0.0.17
18 0.0.0.18
19 0.0.0.19
20 0.0.0.20
21 0.0.0.21
22 0.0.0.22
23 0.0.0.23
24 0.0.0.24
25 0.0.0.25
26 0.0.0.26
27 0.0.0.27
28 0.0.0.28
29 0.0.0.29
30 0.0.0.30
31 0.0.0.31
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE a IS FALSE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range a a 5 NULL 1 100.00 Using index condition
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is false
SELECT id, a FROM t1 WHERE a IS FALSE;
id a
0 0.0.0.0
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE NOT a IS FALSE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL a NULL NULL NULL 33 96.97 Using where
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is not false
SELECT id, a FROM t1 WHERE NOT a IS FALSE;
id a
-1 NULL
1 0.0.0.1
2 0.0.0.2
3 0.0.0.3
4 0.0.0.4
5 0.0.0.5
6 0.0.0.6
7 0.0.0.7
8 0.0.0.8
9 0.0.0.9
10 0.0.0.10
11 0.0.0.11
12 0.0.0.12
13 0.0.0.13
14 0.0.0.14
15 0.0.0.15
16 0.0.0.16
17 0.0.0.17
18 0.0.0.18
19 0.0.0.19
20 0.0.0.20
21 0.0.0.21
22 0.0.0.22
23 0.0.0.23
24 0.0.0.24
25 0.0.0.25
26 0.0.0.26
27 0.0.0.27
28 0.0.0.28
29 0.0.0.29
30 0.0.0.30
31 0.0.0.31
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE a IS NOT FALSE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL a NULL NULL NULL 33 96.97 Using where
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is not false
SELECT id, a FROM t1 WHERE a IS NOT FALSE;
id a
-1 NULL
1 0.0.0.1
2 0.0.0.2
3 0.0.0.3
4 0.0.0.4
5 0.0.0.5
6 0.0.0.6
7 0.0.0.7
8 0.0.0.8
9 0.0.0.9
10 0.0.0.10
11 0.0.0.11
12 0.0.0.12
13 0.0.0.13
14 0.0.0.14
15 0.0.0.15
16 0.0.0.16
17 0.0.0.17
18 0.0.0.18
19 0.0.0.19
20 0.0.0.20
21 0.0.0.21
22 0.0.0.22
23 0.0.0.23
24 0.0.0.24
25 0.0.0.25
26 0.0.0.26
27 0.0.0.27
28 0.0.0.28
29 0.0.0.29
30 0.0.0.30
31 0.0.0.31
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE NOT a IS NOT FALSE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range a a 5 NULL 1 100.00 Using index condition
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is false
SELECT id, a FROM t1 WHERE NOT a IS NOT FALSE;
id a
0 0.0.0.0
DROP TABLE t1;
# End of 11.8 tests

View File

@@ -1,3 +1,5 @@
--source include/have_sequence.inc
--echo #
--echo # Start of 10.10 tests
--echo #
@@ -1479,3 +1481,17 @@ DROP TABLE t1;
--echo #
--echo # End of 10.10 tests
--echo #
--echo # Start of 11.8 tests
--echo #
--echo # MDEV-34189 Unexpected error on `WHERE inet6col`
--echo #
CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY, a INET4, KEY(a));
INSERT INTO t1 VALUES (-1,NULL);
INSERT INTO t1 SELECT seq,CONCAT('0.0.0.',seq) FROM seq_0_to_31;
--source include/boolean_factor.inc
DROP TABLE t1;
--echo # End of 11.8 tests

View File

@@ -868,7 +868,12 @@ DROP TABLE t1;
CREATE TABLE t1 (a INET6);
INSERT INTO t1 VALUES ('::'),('::1'),('::2');
SELECT * FROM t1 WHERE a;
ERROR HY000: Illegal parameter data types inet6 and bigint for operation '<>'
a
::1
::2
SELECT * FROM t1 WHERE NOT a;
a
::
DROP TABLE t1;
#
# GROUP BY
@@ -2091,9 +2096,9 @@ a b
foo ::
bar 1::1
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'foo'
Warning 1292 Truncated incorrect BOOLEAN value: 'foo'
Warning 1292 Incorrect inet6 value: 'foo'
Warning 1292 Truncated incorrect DOUBLE value: 'bar'
Warning 1292 Truncated incorrect BOOLEAN value: 'bar'
Warning 1292 Incorrect inet6 value: 'bar'
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (a VARCHAR(8) NOT NULL);
@@ -2419,3 +2424,256 @@ f::f
DROP TABLE t1;
SET max_sort_length=DEFAULT;
# End of 10.8 tests
# Start of 11.8 tests
#
# MDEV-34189 Unexpected error on `WHERE inet6col`
#
CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY, a INET6, KEY(a));
INSERT INTO t1 VALUES (-1,NULL);
INSERT INTO t1 SELECT seq,CONCAT('::',seq) FROM seq_0_to_31;
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE a;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL a NULL NULL NULL 33 96.97 Using where
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is true
SELECT id, a FROM t1 WHERE a;
id a
1 ::1
2 ::2
3 ::3
4 ::4
5 ::5
6 ::6
7 ::7
8 ::8
9 ::9
10 ::10
11 ::11
12 ::12
13 ::13
14 ::14
15 ::15
16 ::16
17 ::17
18 ::18
19 ::19
20 ::20
21 ::21
22 ::22
23 ::23
24 ::24
25 ::25
26 ::26
27 ::27
28 ::28
29 ::29
30 ::30
31 ::31
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE NOT a;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range a a 17 NULL 1 100.00 Using index condition
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is false
SELECT id, a FROM t1 WHERE NOT a;
id a
0 ::
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE a IS TRUE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL a NULL NULL NULL 33 96.97 Using where
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is true
SELECT id, a FROM t1 WHERE a IS TRUE;
id a
1 ::1
2 ::2
3 ::3
4 ::4
5 ::5
6 ::6
7 ::7
8 ::8
9 ::9
10 ::10
11 ::11
12 ::12
13 ::13
14 ::14
15 ::15
16 ::16
17 ::17
18 ::18
19 ::19
20 ::20
21 ::21
22 ::22
23 ::23
24 ::24
25 ::25
26 ::26
27 ::27
28 ::28
29 ::29
30 ::30
31 ::31
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE NOT a IS TRUE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range a a 17 NULL 2 100.00 Using index condition
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is not true
SELECT id, a FROM t1 WHERE NOT a IS TRUE;
id a
-1 NULL
0 ::
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE a IS NOT TRUE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range a a 17 NULL 2 100.00 Using index condition
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is not true
SELECT id, a FROM t1 WHERE a IS NOT TRUE;
id a
-1 NULL
0 ::
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE NOT a IS NOT TRUE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL a NULL NULL NULL 33 96.97 Using where
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is true
SELECT id, a FROM t1 WHERE NOT a IS NOT TRUE;
id a
1 ::1
2 ::2
3 ::3
4 ::4
5 ::5
6 ::6
7 ::7
8 ::8
9 ::9
10 ::10
11 ::11
12 ::12
13 ::13
14 ::14
15 ::15
16 ::16
17 ::17
18 ::18
19 ::19
20 ::20
21 ::21
22 ::22
23 ::23
24 ::24
25 ::25
26 ::26
27 ::27
28 ::28
29 ::29
30 ::30
31 ::31
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE a IS FALSE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range a a 17 NULL 1 100.00 Using index condition
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is false
SELECT id, a FROM t1 WHERE a IS FALSE;
id a
0 ::
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE NOT a IS FALSE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL a NULL NULL NULL 33 96.97 Using where
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is not false
SELECT id, a FROM t1 WHERE NOT a IS FALSE;
id a
-1 NULL
1 ::1
2 ::2
3 ::3
4 ::4
5 ::5
6 ::6
7 ::7
8 ::8
9 ::9
10 ::10
11 ::11
12 ::12
13 ::13
14 ::14
15 ::15
16 ::16
17 ::17
18 ::18
19 ::19
20 ::20
21 ::21
22 ::22
23 ::23
24 ::24
25 ::25
26 ::26
27 ::27
28 ::28
29 ::29
30 ::30
31 ::31
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE a IS NOT FALSE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL a NULL NULL NULL 33 96.97 Using where
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is not false
SELECT id, a FROM t1 WHERE a IS NOT FALSE;
id a
-1 NULL
1 ::1
2 ::2
3 ::3
4 ::4
5 ::5
6 ::6
7 ::7
8 ::8
9 ::9
10 ::10
11 ::11
12 ::12
13 ::13
14 ::14
15 ::15
16 ::16
17 ::17
18 ::18
19 ::19
20 ::20
21 ::21
22 ::22
23 ::23
24 ::24
25 ::25
26 ::26
27 ::27
28 ::28
29 ::29
30 ::30
31 ::31
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE NOT a IS NOT FALSE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range a a 17 NULL 1 100.00 Using index condition
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is false
SELECT id, a FROM t1 WHERE NOT a IS NOT FALSE;
id a
0 ::
DROP TABLE t1;
# End of 11.8 tests

View File

@@ -1,3 +1,5 @@
--source include/have_sequence.inc
--echo #
--echo # Basic CREATE functionality, defaults, metadata
--echo #
@@ -488,14 +490,10 @@ INSERT INTO t1 VALUES ('::'),('::1');
SELECT a, a IS TRUE, a IS FALSE FROM t1 ORDER BY a;
DROP TABLE t1;
#
# TODO: Error looks like a bug. This should return rows where a<>'::'.
# The same problem is repeatable with GEOMETRY.
#
CREATE TABLE t1 (a INET6);
INSERT INTO t1 VALUES ('::'),('::1'),('::2');
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
SELECT * FROM t1 WHERE a;
SELECT * FROM t1 WHERE NOT a;
DROP TABLE t1;
@@ -1741,3 +1739,17 @@ DROP TABLE t1;
SET max_sort_length=DEFAULT;
--echo # End of 10.8 tests
--echo # Start of 11.8 tests
--echo #
--echo # MDEV-34189 Unexpected error on `WHERE inet6col`
--echo #
CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY, a INET6, KEY(a));
INSERT INTO t1 VALUES (-1,NULL);
INSERT INTO t1 SELECT seq,CONCAT('::',seq) FROM seq_0_to_31;
--source include/boolean_factor.inc
DROP TABLE t1;
--echo # End of 11.8 tests

View File

@@ -1983,8 +1983,13 @@ INSERT INTO t1 VALUES
('00000000-0000-0000-0000-000000000000'),
('00000000-0000-0000-0000-000000000001'),
('00000000-0000-0000-0000-000000000002');
SELECT * FROM t1 WHERE a;
ERROR HY000: Illegal parameter data types uuid and bigint for operation '<>'
SELECT * FROM t1 WHERE a ORDER BY a;
a
00000000-0000-0000-0000-000000000001
00000000-0000-0000-0000-000000000002
SELECT * FROM t1 WHERE NOT a;
a
00000000-0000-0000-0000-000000000000
DROP TABLE t1;
#
# GROUP BY
@@ -3214,3 +3219,258 @@ Warnings:
Warning 1292 Incorrect uuid value: ''
Warning 1292 Incorrect uuid value: ''
DROP TABLE t1;
# End of 10.6 tests
# Start of 11.8 tests
#
# MDEV-34189 Unexpected error on `WHERE inet6col`
#
CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY, a UUID, KEY(a));
INSERT INTO t1 VALUES (-1,NULL);
INSERT INTO t1 VALUES (0,'00000000-0000-0000-0000-000000000000');
INSERT INTO t1 SELECT seq,concat('ba2f21be-d306-11ef-ab9e-', lpad(seq,12,'0')) FROM seq_1_to_31;
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE a;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL a NULL NULL NULL 33 96.97 Using where
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is true
SELECT id, a FROM t1 WHERE a;
id a
1 ba2f21be-d306-11ef-ab9e-000000000001
2 ba2f21be-d306-11ef-ab9e-000000000002
3 ba2f21be-d306-11ef-ab9e-000000000003
4 ba2f21be-d306-11ef-ab9e-000000000004
5 ba2f21be-d306-11ef-ab9e-000000000005
6 ba2f21be-d306-11ef-ab9e-000000000006
7 ba2f21be-d306-11ef-ab9e-000000000007
8 ba2f21be-d306-11ef-ab9e-000000000008
9 ba2f21be-d306-11ef-ab9e-000000000009
10 ba2f21be-d306-11ef-ab9e-000000000010
11 ba2f21be-d306-11ef-ab9e-000000000011
12 ba2f21be-d306-11ef-ab9e-000000000012
13 ba2f21be-d306-11ef-ab9e-000000000013
14 ba2f21be-d306-11ef-ab9e-000000000014
15 ba2f21be-d306-11ef-ab9e-000000000015
16 ba2f21be-d306-11ef-ab9e-000000000016
17 ba2f21be-d306-11ef-ab9e-000000000017
18 ba2f21be-d306-11ef-ab9e-000000000018
19 ba2f21be-d306-11ef-ab9e-000000000019
20 ba2f21be-d306-11ef-ab9e-000000000020
21 ba2f21be-d306-11ef-ab9e-000000000021
22 ba2f21be-d306-11ef-ab9e-000000000022
23 ba2f21be-d306-11ef-ab9e-000000000023
24 ba2f21be-d306-11ef-ab9e-000000000024
25 ba2f21be-d306-11ef-ab9e-000000000025
26 ba2f21be-d306-11ef-ab9e-000000000026
27 ba2f21be-d306-11ef-ab9e-000000000027
28 ba2f21be-d306-11ef-ab9e-000000000028
29 ba2f21be-d306-11ef-ab9e-000000000029
30 ba2f21be-d306-11ef-ab9e-000000000030
31 ba2f21be-d306-11ef-ab9e-000000000031
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE NOT a;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range a a 17 NULL 1 100.00 Using index condition
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is false
SELECT id, a FROM t1 WHERE NOT a;
id a
0 00000000-0000-0000-0000-000000000000
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE a IS TRUE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL a NULL NULL NULL 33 96.97 Using where
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is true
SELECT id, a FROM t1 WHERE a IS TRUE;
id a
1 ba2f21be-d306-11ef-ab9e-000000000001
2 ba2f21be-d306-11ef-ab9e-000000000002
3 ba2f21be-d306-11ef-ab9e-000000000003
4 ba2f21be-d306-11ef-ab9e-000000000004
5 ba2f21be-d306-11ef-ab9e-000000000005
6 ba2f21be-d306-11ef-ab9e-000000000006
7 ba2f21be-d306-11ef-ab9e-000000000007
8 ba2f21be-d306-11ef-ab9e-000000000008
9 ba2f21be-d306-11ef-ab9e-000000000009
10 ba2f21be-d306-11ef-ab9e-000000000010
11 ba2f21be-d306-11ef-ab9e-000000000011
12 ba2f21be-d306-11ef-ab9e-000000000012
13 ba2f21be-d306-11ef-ab9e-000000000013
14 ba2f21be-d306-11ef-ab9e-000000000014
15 ba2f21be-d306-11ef-ab9e-000000000015
16 ba2f21be-d306-11ef-ab9e-000000000016
17 ba2f21be-d306-11ef-ab9e-000000000017
18 ba2f21be-d306-11ef-ab9e-000000000018
19 ba2f21be-d306-11ef-ab9e-000000000019
20 ba2f21be-d306-11ef-ab9e-000000000020
21 ba2f21be-d306-11ef-ab9e-000000000021
22 ba2f21be-d306-11ef-ab9e-000000000022
23 ba2f21be-d306-11ef-ab9e-000000000023
24 ba2f21be-d306-11ef-ab9e-000000000024
25 ba2f21be-d306-11ef-ab9e-000000000025
26 ba2f21be-d306-11ef-ab9e-000000000026
27 ba2f21be-d306-11ef-ab9e-000000000027
28 ba2f21be-d306-11ef-ab9e-000000000028
29 ba2f21be-d306-11ef-ab9e-000000000029
30 ba2f21be-d306-11ef-ab9e-000000000030
31 ba2f21be-d306-11ef-ab9e-000000000031
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE NOT a IS TRUE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range a a 17 NULL 2 100.00 Using index condition
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is not true
SELECT id, a FROM t1 WHERE NOT a IS TRUE;
id a
-1 NULL
0 00000000-0000-0000-0000-000000000000
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE a IS NOT TRUE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range a a 17 NULL 2 100.00 Using index condition
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is not true
SELECT id, a FROM t1 WHERE a IS NOT TRUE;
id a
-1 NULL
0 00000000-0000-0000-0000-000000000000
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE NOT a IS NOT TRUE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL a NULL NULL NULL 33 96.97 Using where
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is true
SELECT id, a FROM t1 WHERE NOT a IS NOT TRUE;
id a
1 ba2f21be-d306-11ef-ab9e-000000000001
2 ba2f21be-d306-11ef-ab9e-000000000002
3 ba2f21be-d306-11ef-ab9e-000000000003
4 ba2f21be-d306-11ef-ab9e-000000000004
5 ba2f21be-d306-11ef-ab9e-000000000005
6 ba2f21be-d306-11ef-ab9e-000000000006
7 ba2f21be-d306-11ef-ab9e-000000000007
8 ba2f21be-d306-11ef-ab9e-000000000008
9 ba2f21be-d306-11ef-ab9e-000000000009
10 ba2f21be-d306-11ef-ab9e-000000000010
11 ba2f21be-d306-11ef-ab9e-000000000011
12 ba2f21be-d306-11ef-ab9e-000000000012
13 ba2f21be-d306-11ef-ab9e-000000000013
14 ba2f21be-d306-11ef-ab9e-000000000014
15 ba2f21be-d306-11ef-ab9e-000000000015
16 ba2f21be-d306-11ef-ab9e-000000000016
17 ba2f21be-d306-11ef-ab9e-000000000017
18 ba2f21be-d306-11ef-ab9e-000000000018
19 ba2f21be-d306-11ef-ab9e-000000000019
20 ba2f21be-d306-11ef-ab9e-000000000020
21 ba2f21be-d306-11ef-ab9e-000000000021
22 ba2f21be-d306-11ef-ab9e-000000000022
23 ba2f21be-d306-11ef-ab9e-000000000023
24 ba2f21be-d306-11ef-ab9e-000000000024
25 ba2f21be-d306-11ef-ab9e-000000000025
26 ba2f21be-d306-11ef-ab9e-000000000026
27 ba2f21be-d306-11ef-ab9e-000000000027
28 ba2f21be-d306-11ef-ab9e-000000000028
29 ba2f21be-d306-11ef-ab9e-000000000029
30 ba2f21be-d306-11ef-ab9e-000000000030
31 ba2f21be-d306-11ef-ab9e-000000000031
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE a IS FALSE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range a a 17 NULL 1 100.00 Using index condition
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is false
SELECT id, a FROM t1 WHERE a IS FALSE;
id a
0 00000000-0000-0000-0000-000000000000
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE NOT a IS FALSE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL a NULL NULL NULL 33 96.97 Using where
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is not false
SELECT id, a FROM t1 WHERE NOT a IS FALSE;
id a
-1 NULL
1 ba2f21be-d306-11ef-ab9e-000000000001
2 ba2f21be-d306-11ef-ab9e-000000000002
3 ba2f21be-d306-11ef-ab9e-000000000003
4 ba2f21be-d306-11ef-ab9e-000000000004
5 ba2f21be-d306-11ef-ab9e-000000000005
6 ba2f21be-d306-11ef-ab9e-000000000006
7 ba2f21be-d306-11ef-ab9e-000000000007
8 ba2f21be-d306-11ef-ab9e-000000000008
9 ba2f21be-d306-11ef-ab9e-000000000009
10 ba2f21be-d306-11ef-ab9e-000000000010
11 ba2f21be-d306-11ef-ab9e-000000000011
12 ba2f21be-d306-11ef-ab9e-000000000012
13 ba2f21be-d306-11ef-ab9e-000000000013
14 ba2f21be-d306-11ef-ab9e-000000000014
15 ba2f21be-d306-11ef-ab9e-000000000015
16 ba2f21be-d306-11ef-ab9e-000000000016
17 ba2f21be-d306-11ef-ab9e-000000000017
18 ba2f21be-d306-11ef-ab9e-000000000018
19 ba2f21be-d306-11ef-ab9e-000000000019
20 ba2f21be-d306-11ef-ab9e-000000000020
21 ba2f21be-d306-11ef-ab9e-000000000021
22 ba2f21be-d306-11ef-ab9e-000000000022
23 ba2f21be-d306-11ef-ab9e-000000000023
24 ba2f21be-d306-11ef-ab9e-000000000024
25 ba2f21be-d306-11ef-ab9e-000000000025
26 ba2f21be-d306-11ef-ab9e-000000000026
27 ba2f21be-d306-11ef-ab9e-000000000027
28 ba2f21be-d306-11ef-ab9e-000000000028
29 ba2f21be-d306-11ef-ab9e-000000000029
30 ba2f21be-d306-11ef-ab9e-000000000030
31 ba2f21be-d306-11ef-ab9e-000000000031
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE a IS NOT FALSE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL a NULL NULL NULL 33 96.97 Using where
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is not false
SELECT id, a FROM t1 WHERE a IS NOT FALSE;
id a
-1 NULL
1 ba2f21be-d306-11ef-ab9e-000000000001
2 ba2f21be-d306-11ef-ab9e-000000000002
3 ba2f21be-d306-11ef-ab9e-000000000003
4 ba2f21be-d306-11ef-ab9e-000000000004
5 ba2f21be-d306-11ef-ab9e-000000000005
6 ba2f21be-d306-11ef-ab9e-000000000006
7 ba2f21be-d306-11ef-ab9e-000000000007
8 ba2f21be-d306-11ef-ab9e-000000000008
9 ba2f21be-d306-11ef-ab9e-000000000009
10 ba2f21be-d306-11ef-ab9e-000000000010
11 ba2f21be-d306-11ef-ab9e-000000000011
12 ba2f21be-d306-11ef-ab9e-000000000012
13 ba2f21be-d306-11ef-ab9e-000000000013
14 ba2f21be-d306-11ef-ab9e-000000000014
15 ba2f21be-d306-11ef-ab9e-000000000015
16 ba2f21be-d306-11ef-ab9e-000000000016
17 ba2f21be-d306-11ef-ab9e-000000000017
18 ba2f21be-d306-11ef-ab9e-000000000018
19 ba2f21be-d306-11ef-ab9e-000000000019
20 ba2f21be-d306-11ef-ab9e-000000000020
21 ba2f21be-d306-11ef-ab9e-000000000021
22 ba2f21be-d306-11ef-ab9e-000000000022
23 ba2f21be-d306-11ef-ab9e-000000000023
24 ba2f21be-d306-11ef-ab9e-000000000024
25 ba2f21be-d306-11ef-ab9e-000000000025
26 ba2f21be-d306-11ef-ab9e-000000000026
27 ba2f21be-d306-11ef-ab9e-000000000027
28 ba2f21be-d306-11ef-ab9e-000000000028
29 ba2f21be-d306-11ef-ab9e-000000000029
30 ba2f21be-d306-11ef-ab9e-000000000030
31 ba2f21be-d306-11ef-ab9e-000000000031
EXPLAIN EXTENDED
SELECT id, a FROM t1 WHERE NOT a IS NOT FALSE;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range a a 17 NULL 1 100.00 Using index condition
Warnings:
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` is false
SELECT id, a FROM t1 WHERE NOT a IS NOT FALSE;
id a
0 00000000-0000-0000-0000-000000000000
DROP TABLE t1;
# End of 11.8 tests

View File

@@ -1,3 +1,5 @@
--source include/have_sequence.inc
--echo #
--echo # MDEV-4958 Adding datatype UUID
--echo #
@@ -585,17 +587,13 @@ INSERT INTO t1 VALUES
SELECT a, a IS TRUE, a IS FALSE FROM t1 ORDER BY a;
DROP TABLE t1;
#
# TODO: Error looks like a bug. This should return rows where a<>'00000000-0000-0000-0000-000000000000'.
# The same problem is repeatable with GEOMETRY.
#
CREATE TABLE t1 (a UUID);
INSERT INTO t1 VALUES
('00000000-0000-0000-0000-000000000000'),
('00000000-0000-0000-0000-000000000001'),
('00000000-0000-0000-0000-000000000002');
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
SELECT * FROM t1 WHERE a;
SELECT * FROM t1 WHERE a ORDER BY a;
SELECT * FROM t1 WHERE NOT a;
DROP TABLE t1;
@@ -1697,3 +1695,20 @@ INSERT INTO t1 VALUES ('00000000-0000-0000-0000-000000000000');
SELECT * FROM t1 WHERE a IN ('','00000000-0000-0000-0000-000000000001');
SELECT * FROM t1 WHERE a='';
DROP TABLE t1;
--echo # End of 10.6 tests
--echo # Start of 11.8 tests
--echo #
--echo # MDEV-34189 Unexpected error on `WHERE inet6col`
--echo #
CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY, a UUID, KEY(a));
INSERT INTO t1 VALUES (-1,NULL);
INSERT INTO t1 VALUES (0,'00000000-0000-0000-0000-000000000000');
INSERT INTO t1 SELECT seq,concat('ba2f21be-d306-11ef-ab9e-', lpad(seq,12,'0')) FROM seq_1_to_31;
--source include/boolean_factor.inc
DROP TABLE t1;
--echo # End of 11.8 tests