1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-04-21 19:45:56 +03:00
mariadb-columnstore-engine/mysql-test/columnstore/basic/t/mcol271-empty-string-is-not-null.test
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

65 lines
1.6 KiB
Plaintext

# tests updates that sets invalid range when we set value at max boundary that is less than max.
--disable_warnings
DROP DATABASE IF EXISTS test_empty_strings;
CREATE DATABASE test_empty_strings;
USE test_empty_strings;
--enable_warnings
CREATE TABLE t(s text) ENGINE=COLUMNSTORE;
INSERT INTO t(s) VALUES (''), (NULL);
SELECT COUNT(*) FROM t WHERE s IS NULL;
SELECT COUNT(*) FROM t WHERE s IS NOT NULL;
SELECT * FROM t;
DROP TABLE t;
CREATE TABLE t(s text) ENGINE=COLUMNSTORE;
# this will test different code path in writeengine.
INSERT INTO t(s) VALUES ('');
INSERT INTO t(s) VALUES (NULL);
SELECT * FROM t;
SELECT COUNT(*) FROM t WHERE s IS NULL;
DROP TABLE t;
CREATE TABLE t(s text) ENGINE=COLUMNSTORE;
# handling of some obsucure pseudo-null magic value.
INSERT INTO t(s) VALUES ('_CpNuLl_'),(''), (NULL);
SELECT * FROM t;
SELECT COUNT(*) FROM t WHERE s IS NULL;
DROP TABLE t;
# There is a problem with comparison
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 <= '');
SELECT 2, COUNT(*) FROM t WHERE (c6 <= 'b');
SELECT 0, COUNT(*) FROM t WHERE (c6 <= '');
SELECT 0, COUNT(*) FROM t WHERE (c6 <= ' ');
SELECT 2, COUNT(*) FROM t WHERE (c6 <= 'b' OR c6 <= ' ');
SELECT 0, COUNT(*) FROM t WHERE (c6 < '');
SELECT 0, COUNT(*) FROM t WHERE (c6 < ' ');
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;
SELECT RTRIM_ORACLE(a) FROM t;
DROP DATABASE test_empty_strings;