1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-01 06:46:55 +03:00

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.
This commit is contained in:
Sergey Zefirov
2023-03-30 17:26:45 +01:00
committed by Roman Nozdrin
parent 0ea592da80
commit b53c231ca6
417 changed files with 12459 additions and 3520 deletions

View File

@ -9,33 +9,33 @@ t1_text TEXT,
t1_char CHAR(1),
t1_datetime DATETIME
)ENGINE=Columnstore;
INSERT INTO t1 VALUES(NULL, NULL, '', '', '0000-00-00');
INSERT INTO t1 VALUES(NULL, NULL, NULL, NULL, '0000-00-00');
INSERT INTO t1 VALUES(123456, 111.11, repeat('a',10), 'a', '1111-11-11 11:11:11');
INSERT INTO t1 VALUES(NULL, 222.22, '', 'b', '2222-12-22 22:22:22');
SELECT *, COALESCE(t1_int, 'No Value') FROM t1 ORDER BY t1_int;
t1_int t1_decimal t1_text t1_char t1_datetime COALESCE(t1_int, 'No Value')
NULL NULL NULL NULL 0000-00-00 00:00:00 No Value
NULL 222.22 NULL b 2222-12-22 22:22:22 No Value
NULL 222.22 b 2222-12-22 22:22:22 No Value
123456 111.11 aaaaaaaaaa a 1111-11-11 11:11:11 123456
SELECT *, COALESCE(t1_decimal, 'No Value') FROM t1 ORDER BY t1_int;
t1_int t1_decimal t1_text t1_char t1_datetime COALESCE(t1_decimal, 'No Value')
NULL NULL NULL NULL 0000-00-00 00:00:00 No Value
NULL 222.22 NULL b 2222-12-22 22:22:22 222.22
NULL 222.22 b 2222-12-22 22:22:22 222.22
123456 111.11 aaaaaaaaaa a 1111-11-11 11:11:11 111.11
SELECT *, COALESCE(t1_text, 'No Value') FROM t1 ORDER BY t1_int;
t1_int t1_decimal t1_text t1_char t1_datetime COALESCE(t1_text, 'No Value')
NULL NULL NULL NULL 0000-00-00 00:00:00 No Value
NULL 222.22 NULL b 2222-12-22 22:22:22 No Value
NULL 222.22 b 2222-12-22 22:22:22
123456 111.11 aaaaaaaaaa a 1111-11-11 11:11:11 aaaaaaaaaa
SELECT *, COALESCE(t1_datetime, 'No Value') FROM t1 ORDER BY t1_int;
t1_int t1_decimal t1_text t1_char t1_datetime COALESCE(t1_datetime, 'No Value')
NULL NULL NULL NULL 0000-00-00 00:00:00 0000-00-00 00:00:00
NULL 222.22 NULL b 2222-12-22 22:22:22 2222-12-22 22:22:22
NULL 222.22 b 2222-12-22 22:22:22 2222-12-22 22:22:22
123456 111.11 aaaaaaaaaa a 1111-11-11 11:11:11 1111-11-11 11:11:11
SELECT t1_int, t1_decimal, COALESCE(t1_text, LEFT(t1_char,10)) FROM t1 ORDER BY t1_int;
t1_int t1_decimal COALESCE(t1_text, LEFT(t1_char,10))
NULL NULL NULL
NULL 222.22 b
NULL 222.22
123456 111.11 aaaaaaaaaa
SELECT t1_int, LEAST(t1_int, t1_decimal) FROM t1 ORDER BY 1;
t1_int LEAST(t1_int, t1_decimal)
@ -77,14 +77,13 @@ NULL 0 6.256546477863076e17
SELECT * FROM t1 WHERE ISNULL(t1_int) ORDER BY t1_decimal;
t1_int t1_decimal t1_text t1_char t1_datetime
NULL NULL NULL NULL 0000-00-00 00:00:00
NULL 222.22 NULL b 2222-12-22 22:22:22
NULL 222.22 b 2222-12-22 22:22:22
SELECT * FROM t1 WHERE ISNULL(t1_decimal) ORDER BY t1_decimal;
t1_int t1_decimal t1_text t1_char t1_datetime
NULL NULL NULL NULL 0000-00-00 00:00:00
SELECT * FROM t1 WHERE ISNULL(t1_text) ORDER BY t1_decimal;
t1_int t1_decimal t1_text t1_char t1_datetime
NULL NULL NULL NULL 0000-00-00 00:00:00
NULL 222.22 NULL b 2222-12-22 22:22:22
SELECT * FROM t1 WHERE ISNULL(t1_datetime) ORDER BY t1_decimal;
t1_int t1_decimal t1_text t1_char t1_datetime
DROP DATABASE mcs91_db;