1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-04-28 06:45:06 +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

47 lines
1.2 KiB
Plaintext

#
# Test NULLIF, IFNULL, ISNULL functions
# Author: Bharath, bharath.bokka@mariadb.com
#
-- source ../include/have_columnstore.inc
--disable_warnings
DROP DATABASE IF EXISTS mcs171_db;
--enable_warnings
CREATE DATABASE mcs171_db;
USE mcs171_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);
--replace_regex /( COLLATE=latin1_swedish_ci)//
SHOW CREATE TABLE t1;
SELECT IFNULL(NULL, 'abc');
SELECT IFNULL(NULL, 123);
SELECT IFNULL('abc', 123);
SELECT ISNULL(NULL);
SELECT ISNULL(1);
SELECT ISNULL('a');
SELECT NULLIF(1, 1);
SELECT NULLIF('abc', 'a');
--disable_warnings
SELECT NULLIF(1, 'abcd');
--enable_warnings
SELECT a, ISNULL(a) FROM t1;
SELECT b, ISNULL(b) FROM t1;
SELECT c, ISNULL(c) FROM t1;
SELECT d, ISNULL(d) FROM t1;
SELECT a, IFNULL(a, 'Null Char') FROM t1;
SELECT b, IFNULL(b, 'Null Integer') FROM t1;
SELECT c, IFNULL(d, 'Null Decimal') FROM t1;
SELECT a, NULLIF(a, 'c') FROM t1;
SELECT b, NULLIF(b, 15) FROM t1;
SELECT c, NULLIF(c, '2015-5-15') FROM t1;
# Clean UP
DROP DATABASE mcs171_db;