mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-04-18 21:44:02 +03:00
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.
78 lines
1.5 KiB
Plaintext
78 lines
1.5 KiB
Plaintext
DROP DATABASE IF EXISTS test_empty_strings;
|
|
CREATE DATABASE test_empty_strings;
|
|
USE test_empty_strings;
|
|
CREATE TABLE t(s text) ENGINE=COLUMNSTORE;
|
|
INSERT INTO t(s) VALUES (''), (NULL);
|
|
SELECT COUNT(*) FROM t WHERE s IS NULL;
|
|
COUNT(*)
|
|
1
|
|
SELECT COUNT(*) FROM t WHERE s IS NOT NULL;
|
|
COUNT(*)
|
|
1
|
|
SELECT * FROM t;
|
|
s
|
|
|
|
NULL
|
|
DROP TABLE t;
|
|
CREATE TABLE t(s text) ENGINE=COLUMNSTORE;
|
|
INSERT INTO t(s) VALUES ('');
|
|
INSERT INTO t(s) VALUES (NULL);
|
|
SELECT * FROM t;
|
|
s
|
|
|
|
NULL
|
|
SELECT COUNT(*) FROM t WHERE s IS NULL;
|
|
COUNT(*)
|
|
1
|
|
DROP TABLE t;
|
|
CREATE TABLE t(s text) ENGINE=COLUMNSTORE;
|
|
INSERT INTO t(s) VALUES ('_CpNuLl_'),(''), (NULL);
|
|
SELECT * FROM t;
|
|
s
|
|
_CpNuLl_
|
|
|
|
NULL
|
|
SELECT COUNT(*) FROM t WHERE s IS NULL;
|
|
COUNT(*)
|
|
1
|
|
DROP TABLE t;
|
|
CREATE TABLE t(c6 CHAR(6)) ENGINE=COLUMNSTORE;
|
|
INSERT INTO t(c6) VALUES ('a'), ('b'), ('c');
|
|
SELECT 2, COUNT(*) FROM t WHERE (c6 <= 'b' OR c6 <= '');
|
|
2 COUNT(*)
|
|
2 2
|
|
SELECT 2, COUNT(*) FROM t WHERE (c6 <= 'b');
|
|
2 COUNT(*)
|
|
2 2
|
|
SELECT 0, COUNT(*) FROM t WHERE (c6 <= '');
|
|
0 COUNT(*)
|
|
0 0
|
|
SELECT 0, COUNT(*) FROM t WHERE (c6 <= ' ');
|
|
0 COUNT(*)
|
|
0 0
|
|
SELECT 2, COUNT(*) FROM t WHERE (c6 <= 'b' OR c6 <= ' ');
|
|
2 COUNT(*)
|
|
2 2
|
|
SELECT 0, COUNT(*) FROM t WHERE (c6 < '');
|
|
0 COUNT(*)
|
|
0 0
|
|
SELECT 0, COUNT(*) FROM t WHERE (c6 < ' ');
|
|
0 COUNT(*)
|
|
0 0
|
|
DROP TABLE IF EXISTS t;
|
|
CREATE TABLE t(a CHAR(10)) ENGINE=COLUMNSTORE;
|
|
INSERT INTO t(a) VALUES (''), (NULL), (' '), (' a ');
|
|
SELECT LTRIM_ORACLE(a) FROM t;
|
|
LTRIM_ORACLE(a)
|
|
NULL
|
|
NULL
|
|
NULL
|
|
a
|
|
SELECT RTRIM_ORACLE(a) FROM t;
|
|
RTRIM_ORACLE(a)
|
|
NULL
|
|
NULL
|
|
NULL
|
|
a
|
|
DROP DATABASE test_empty_strings;
|