1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-04-20 09:07:44 +03:00
mariadb-columnstore-engine/mysql-test/columnstore/basic/r/mcol271-empty-string-is-not-null.result
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

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;