1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-05-02 19:24:47 +03:00
Sergey Zefirov b53c231ca6 MCOL-271 empty strings should not be NULLs (#2794)
This patch improves handling of NULLs in textual fields in ColumnStore.
Previously empty strings were considered NULLs and it could be a problem
if data scheme allows for empty strings. It was also one of major
reasons of behavior difference between ColumnStore and other engines in
MariaDB family.

Also, this patch fixes some other bugs and incorrect behavior, for
example, incorrect comparison for "column <= ''" which evaluates to
constant True for all purposes before this patch.
2023-03-30 21:18:29 +03:00

54 lines
1.8 KiB
Plaintext

DROP DATABASE IF EXISTS mcs174_db;
CREATE DATABASE mcs174_db;
USE mcs174_db;
SET default_storage_engine=Columnstore;
CREATE TABLE t1 (a CHAR(1), b INT, c DATETIME, d DOUBLE);
INSERT INTO t1 VALUES (NULL, NULL, '0-0-0', NULL),('a', 12, '1212-12-12', 1.19691E+100),('b', 13, '1313-3-13 13:13:13', 2.1961E+18),('c', 14, '1414-4-14', 0.16191),('d', 15, '2015-5-15 15:15:15', 1.971917);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` char(1) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
`c` datetime DEFAULT NULL,
`d` double DEFAULT NULL
) ENGINE=Columnstore DEFAULT CHARSET=latin1
SELECT b, c, (CASE WHEN a = 'b' THEN b ELSE c END) FROM t1;
b c (CASE WHEN a = 'b' THEN b ELSE c END)
NULL 0000-00-00 00:00:00 0000-00-00 00:00:00
12 1212-12-12 00:00:00 1212-12-12 00:00:00
13 1313-03-13 13:13:13 13
14 1414-04-14 00:00:00 1414-04-14 00:00:00
15 2015-05-15 15:15:15 2015-05-15 15:15:15
SELECT b, a, (CASE WHEN b > 13 THEN b ELSE a END) FROM t1;
b a (CASE WHEN b > 13 THEN b ELSE a END)
NULL NULL NULL
12 a a
13 b b
14 c 14
15 d 15
SELECT c, a, (CASE WHEN d > 1 THEN a ELSE c END) FROM t1;
c a (CASE WHEN d > 1 THEN a ELSE c END)
0000-00-00 00:00:00 NULL 0000-00-00 00:00:00
1212-12-12 00:00:00 a a
1313-03-13 13:13:13 b b
1414-04-14 00:00:00 c 1414-04-14 00:00:00
2015-05-15 15:15:15 d d
SELECT a, c, (CASE WHEN c IS NULL THEN a ELSE c END) FROM t1;
a c (CASE WHEN c IS NULL THEN a ELSE c END)
NULL 0000-00-00 00:00:00 0000-00-00 00:00:00
a 1212-12-12 00:00:00 1212-12-12 00:00:00
b 1313-03-13 13:13:13 1313-03-13 13:13:13
c 1414-04-14 00:00:00 1414-04-14 00:00:00
d 2015-05-15 15:15:15 2015-05-15 15:15:15
SELECT (CASE WHEN a = 'a' THEN 0 ELSE 1 END) FROM t1;
(CASE WHEN a = 'a' THEN 0 ELSE 1 END)
1
0
1
1
1
SELECT (CASE WHEN 10 > 5 THEN 'True' ELSE 'False' END);
(CASE WHEN 10 > 5 THEN 'True' ELSE 'False' END)
True
DROP DATABASE mcs174_db;