1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-12-03 08:20:57 +03:00
Files
mariadb-columnstore-engine/mysql-test/columnstore/basic/r/mcs74_check_constraint.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

84 lines
3.0 KiB
Plaintext

DROP DATABASE IF EXISTS mcs74_db;
CREATE DATABASE mcs74_db;
USE mcs74_db;
CREATE TABLE t1(t1_int INT, t1_char CHAR(5), CHECK (t1_int > 0))ENGINE=Columnstore;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t1_int` int(11) DEFAULT NULL,
`t1_char` char(5) DEFAULT NULL,
CONSTRAINT `CONSTRAINT_1` CHECK (`t1_int` > 0)
) ENGINE=Columnstore DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES(NULL, NULL);
INSERT INTO t1 VALUES(1, 'a');
INSERT INTO t1 VALUES(0, 'b');
ERROR 23000: CONSTRAINT `CONSTRAINT_1` failed for `mcs74_db`.`t1`
INSERT INTO t1 VALUES(-1, 'c');
ERROR 23000: CONSTRAINT `CONSTRAINT_1` failed for `mcs74_db`.`t1`
SELECT * FROM t1;
t1_int t1_char
NULL NULL
1 a
CREATE TABLE t2(t1_char CHAR(10), CONSTRAINT c1 CHECK(t1_char = ''))ENGINE=Columnstore;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`t1_char` char(10) DEFAULT NULL,
CONSTRAINT `c1` CHECK (`t1_char` = '')
) ENGINE=Columnstore DEFAULT CHARSET=latin1
INSERT INTO t2 VALUES();
INSERT INTO t2 VALUES('');
INSERT INTO t2 VALUES('aaaa');
ERROR 23000: CONSTRAINT `c1` failed for `mcs74_db`.`t2`
SELECT * FROM t2;
t1_char
NULL
CREATE TABLE t3(
t3_decimal DECIMAL(5,2),
t3_blob BLOB,
t3_datetime DATETIME,
CONSTRAINT t3_check_date CHECK(t3_datetime >= '1212-12-12 12:12:12'),
CONSTRAINT t3_check_decimal CHECK(t3_decimal < 888.88),
CONSTRAINT t3_check_blob CHECK(t3_blob = 'aaaa')
)ENGINE=Columnstore;
SHOW CREATE TABLE t3;
Table Create Table
t3 CREATE TABLE `t3` (
`t3_decimal` decimal(5,2) DEFAULT NULL,
`t3_blob` blob DEFAULT NULL,
`t3_datetime` datetime DEFAULT NULL,
CONSTRAINT `t3_check_date` CHECK (`t3_datetime` >= '1212-12-12 12:12:12'),
CONSTRAINT `t3_check_decimal` CHECK (`t3_decimal` < 888.88),
CONSTRAINT `t3_check_blob` CHECK (`t3_blob` = 'aaaa')
) ENGINE=Columnstore DEFAULT CHARSET=latin1
INSERT INTO t3(t3_decimal) VALUES(NULL);
INSERT INTO t3(t3_decimal) VALUES(888.87);
INSERT INTO t3(t3_decimal) VALUES(888.88);
ERROR 23000: CONSTRAINT `t3_check_decimal` failed for `mcs74_db`.`t3`
INSERT INTO t3(t3_decimal) VALUES(888.89);
ERROR 23000: CONSTRAINT `t3_check_decimal` failed for `mcs74_db`.`t3`
INSERT INTO t3(t3_blob) VALUES('');
ERROR 23000: CONSTRAINT `t3_check_blob` failed for `mcs74_db`.`t3`
INSERT INTO t3(t3_blob) VALUES('aaaa');
INSERT INTO t3(t3_blob) VALUES('aaaaa');
ERROR 23000: CONSTRAINT `t3_check_blob` failed for `mcs74_db`.`t3`
INSERT INTO t3(t3_blob) VALUES('aaa');
ERROR 23000: CONSTRAINT `t3_check_blob` failed for `mcs74_db`.`t3`
INSERT INTO t3(t3_datetime) VALUES(NULL);
INSERT INTO t3(t3_datetime) VALUES('0:0:0');
ERROR 23000: CONSTRAINT `t3_check_date` failed for `mcs74_db`.`t3`
INSERT INTO t3(t3_datetime) VALUES('1212-12-12 12:12:12');
INSERT INTO t3(t3_datetime) VALUES('1212-12-12 12:12:13');
INSERT INTO t3(t3_datetime) VALUES('1212-12-12 12:12:11');
ERROR 23000: CONSTRAINT `t3_check_date` failed for `mcs74_db`.`t3`
SELECT * FROM t3;
t3_decimal t3_blob t3_datetime
NULL NULL NULL
888.87 NULL NULL
NULL aaaa NULL
NULL NULL NULL
NULL NULL 1212-12-12 12:12:12
NULL NULL 1212-12-12 12:12:13
DROP DATABASE mcs74_db;