1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-08 14:22:09 +03:00

Tests added

This commit is contained in:
Nedeljko Stefanovic
2025-07-30 19:30:51 +00:00
parent d9259647e4
commit 2aa3234e54
2 changed files with 382 additions and 0 deletions

View File

@@ -0,0 +1,178 @@
# MCOL-4240 enum, set and json Test Cases
DROP DATABASE IF EXISTS mcol4240_enum_set_json_db;
SET SQL_MODE='ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
create database mcol4240_enum_set_json_db;
use mcol4240_enum_set_json_db;
CREATE TABLE t (
status ENUM('active', 'inactive', 'deleted') NOT NULL,
options SET('a', 'b', 'c', 'd') NOT NULL,
info JSON NOT NULL
) ENGINE=columnstore;
SELECT * FROM t;
status options info
INSERT INTO t (status, options)
VALUES ('active', 'a,b');
ERROR 23000: CONSTRAINT `t.info` failed for `mcol4240_enum_set_json_db`.`t`
INSERT INTO t (status, info)
VALUES ('active', '{ "comment": "This is example", "number": 42 }');
Warnings:
Warning 1364 Field 'options' doesn't have a default value
SELECT * FROM t;
status options info
active { "comment": "This is example", "number": 42 }
DELETE FROM t WHERE status = 'active';
SELECT * FROM t;
status options info
INSERT INTO t (options, info)
VALUES ('a,b', '{ "comment": "This is example", "number": 42 }');
INSERT INTO t (status, options, info)
VALUES ('active', 'a,b','{ "comment": "This is example", "number": 42 }');
INSERT INTO t (status, options, info)
VALUES ('inactive', '','{ "comment": "This is example", "number": 43 }');
SELECT * FROM t;
status options info
active a,b { "comment": "This is example", "number": 42 }
active a,b { "comment": "This is example", "number": 42 }
inactive { "comment": "This is example", "number": 43 }
DELETE FROM t WHERE status = 'active';
SELECT * FROM t;
status options info
inactive { "comment": "This is example", "number": 43 }
UPDATE t SET status = 'active' WHERE status = 'inactive';
SELECT * FROM t;
status options info
active { "comment": "This is example", "number": 43 }
UPDATE t SET options = 'a' WHERE options = 'b';
SELECT * FROM t;
status options info
active { "comment": "This is example", "number": 43 }
UPDATE t SET options = 'a' WHERE options = 'a,b';
SELECT * FROM t;
status options info
active { "comment": "This is example", "number": 43 }
INSERT INTO t (status, options, info)
VALUES ('inactive', '','{ "comment": "This is example", "number": 43 ');
ERROR 23000: CONSTRAINT `t.info` failed for `mcol4240_enum_set_json_db`.`t`
DELETE FROM t WHERE status = 'deleted';
SELECT * FROM t;
status options info
active { "comment": "This is example", "number": 43 }
INSERT INTO t (status, options, info)
VALUES ('inactive', 'b','{ "comment": "This is example", "number": 42 }');
SELECT * FROM t;
status options info
active { "comment": "This is example", "number": 43 }
inactive b { "comment": "This is example", "number": 42 }
DELETE FROM t WHERE options = 'b';
SELECT * FROM t;
status options info
active { "comment": "This is example", "number": 43 }
TRUNCATE TABLE t;
SELECT * FROM t;
status options info
DROP TABLE t;
CREATE TABLE t (
status ENUM('active', 'inactive', 'deleted') NOT NULL DEFAULT NULL,
dummy int
) ENGINE=columnstore;
ERROR 42000: Invalid default value for 'status'
CREATE TABLE t (
options SET('a', 'b', 'c', 'd') NOT NULL DEFAULT NULL,
dummy int
) ENGINE=columnstore;
ERROR 42000: Invalid default value for 'options'
CREATE TABLE t (
info JSON NOT NULL DEFAULT NULL,
dummy int
) ENGINE=columnstore;
ERROR 42000: Invalid default value for 'info'
CREATE TABLE t (
info JSON,
dummy int NOT NULL DEFAULT NULL
) ENGINE=columnstore;
ERROR 42000: Invalid default value for 'dummy'
CREATE TABLE t (
status ENUM('active', 'inactive', 'deleted') NOT NULL,
options SET('a', 'b', 'c', 'd') NOT NULL,
info JSON NOT NULL
) ENGINE=columnstore;
INSERT INTO t (status, options)
VALUES ('active', 'a,b');
ERROR 23000: CONSTRAINT `t.info` failed for `mcol4240_enum_set_json_db`.`t`
SELECT * FROM t;
status options info
INSERT INTO t (status, info)
VALUES ('active', '{ "comment": "This is example", "number": 42 }');
Warnings:
Warning 1364 Field 'options' doesn't have a default value
SELECT * FROM t;
status options info
active { "comment": "This is example", "number": 42 }
INSERT INTO t (options, info)
VALUES ('a,b', '{ "comment": "This is example", "number": 42 }');
SELECT * FROM t;
status options info
active { "comment": "This is example", "number": 42 }
active a,b { "comment": "This is example", "number": 42 }
DROP TABLE t;
CREATE TABLE t (
status ENUM('active', 'inactive', 'deleted') DEFAULT NULL,
options SET('a', 'b', 'c', 'd') DEFAULT NULL,
info JSON DEFAULT NULL
) ENGINE=columnstore;
INSERT INTO t (status, options)
VALUES ('active', 'a,b');
SELECT * FROM t;
status options info
active a,b NULL
TRUNCATE TABLE t;
SELECT * FROM t;
status options info
INSERT INTO t (status, info)
VALUES ('active', '{ "comment": "This is example", "number": 42 }');
SELECT * FROM t;
status options info
active NULL { "comment": "This is example", "number": 42 }
TRUNCATE TABLE t;
SELECT * FROM t;
status options info
INSERT INTO t (options, info)
VALUES ('a,b', '{ "comment": "This is example", "number": 42 }');
SELECT * FROM t;
status options info
NULL a,b { "comment": "This is example", "number": 42 }
TRUNCATE TABLE t;
SELECT * FROM t;
status options info
DROP TABLE t;
CREATE TABLE t (
status ENUM('active', 'inactive', 'deleted') DEFAULT 'active',
options SET('a', 'b', 'c', 'd') DEFAULT 'a,b',
info JSON DEFAULT '{}'
) ENGINE=columnstore;
INSERT INTO t (status, options)
VALUES ('active', 'a,b');
SELECT * FROM t;
status options info
active a,b {}
TRUNCATE TABLE t;
SELECT * FROM t;
status options info
INSERT INTO t (status, info)
VALUES ('active', '{ "comment": "This is example", "number": 42 }');
SELECT * FROM t;
status options info
active a,b { "comment": "This is example", "number": 42 }
TRUNCATE TABLE t;
SELECT * FROM t;
status options info
INSERT INTO t (options, info)
VALUES ('a,b', '{ "comment": "This is example", "number": 42 }');
SELECT * FROM t;
status options info
active a,b { "comment": "This is example", "number": 42 }
TRUNCATE TABLE t;
SELECT * FROM t;
status options info
DROP TABLE t;
DROP DATABASE mcol4240_enum_set_json_db;

View File

@@ -0,0 +1,204 @@
-- source ../include/have_columnstore.inc
--echo # MCOL-4240 enum, set and json Test Cases
--disable_warnings
DROP DATABASE IF EXISTS mcol4240_enum_set_json_db;
--enable_warnings
SET SQL_MODE='ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
create database mcol4240_enum_set_json_db;
use mcol4240_enum_set_json_db;
CREATE TABLE t (
status ENUM('active', 'inactive', 'deleted') NOT NULL,
options SET('a', 'b', 'c', 'd') NOT NULL,
info JSON NOT NULL
) ENGINE=columnstore;
SELECT * FROM t;
--error ER_CONSTRAINT_FAILED
INSERT INTO t (status, options)
VALUES ('active', 'a,b');
INSERT INTO t (status, info)
VALUES ('active', '{ "comment": "This is example", "number": 42 }');
SELECT * FROM t;
DELETE FROM t WHERE status = 'active';
SELECT * FROM t;
INSERT INTO t (options, info)
VALUES ('a,b', '{ "comment": "This is example", "number": 42 }');
INSERT INTO t (status, options, info)
VALUES ('active', 'a,b','{ "comment": "This is example", "number": 42 }');
INSERT INTO t (status, options, info)
VALUES ('inactive', '','{ "comment": "This is example", "number": 43 }');
SELECT * FROM t;
DELETE FROM t WHERE status = 'active';
SELECT * FROM t;
UPDATE t SET status = 'active' WHERE status = 'inactive';
SELECT * FROM t;
UPDATE t SET options = 'a' WHERE options = 'b';
SELECT * FROM t;
UPDATE t SET options = 'a' WHERE options = 'a,b';
SELECT * FROM t;
--error ER_CONSTRAINT_FAILED (4025): CONSTRAINT `t.info` failed for `mcol4240_enum_set_json_db`.`t`
INSERT INTO t (status, options, info)
VALUES ('inactive', '','{ "comment": "This is example", "number": 43 ');
DELETE FROM t WHERE status = 'deleted';
SELECT * FROM t;
INSERT INTO t (status, options, info)
VALUES ('inactive', 'b','{ "comment": "This is example", "number": 42 }');
SELECT * FROM t;
DELETE FROM t WHERE options = 'b';
SELECT * FROM t;
TRUNCATE TABLE t;
SELECT * FROM t;
DROP TABLE t;
--error ER_INVALID_DEFAULT (1067): Invalid default value for 'status'
CREATE TABLE t (
status ENUM('active', 'inactive', 'deleted') NOT NULL DEFAULT NULL,
dummy int
) ENGINE=columnstore;
--error ER_INVALID_DEFAULT (1067): Invalid default value for 'options'
CREATE TABLE t (
options SET('a', 'b', 'c', 'd') NOT NULL DEFAULT NULL,
dummy int
) ENGINE=columnstore;
--error ER_INVALID_DEFAULT (1067): Invalid default value for 'info'
CREATE TABLE t (
info JSON NOT NULL DEFAULT NULL,
dummy int
) ENGINE=columnstore;
--error ER_INVALID_DEFAULT (1067): Invalid default value for 'dummy'
CREATE TABLE t (
info JSON,
dummy int NOT NULL DEFAULT NULL
) ENGINE=columnstore;
CREATE TABLE t (
status ENUM('active', 'inactive', 'deleted') NOT NULL,
options SET('a', 'b', 'c', 'd') NOT NULL,
info JSON NOT NULL
) ENGINE=columnstore;
--error ER_CONSTRAINT_FAILED (4025): CONSTRAINT `t.info` failed for `mcol4240_enum_set_json_db`.`t`
INSERT INTO t (status, options)
VALUES ('active', 'a,b');
SELECT * FROM t;
INSERT INTO t (status, info)
VALUES ('active', '{ "comment": "This is example", "number": 42 }');
SELECT * FROM t;
INSERT INTO t (options, info)
VALUES ('a,b', '{ "comment": "This is example", "number": 42 }');
SELECT * FROM t;
DROP TABLE t;
CREATE TABLE t (
status ENUM('active', 'inactive', 'deleted') DEFAULT NULL,
options SET('a', 'b', 'c', 'd') DEFAULT NULL,
info JSON DEFAULT NULL
) ENGINE=columnstore;
INSERT INTO t (status, options)
VALUES ('active', 'a,b');
SELECT * FROM t;
TRUNCATE TABLE t;
SELECT * FROM t;
INSERT INTO t (status, info)
VALUES ('active', '{ "comment": "This is example", "number": 42 }');
SELECT * FROM t;
TRUNCATE TABLE t;
SELECT * FROM t;
INSERT INTO t (options, info)
VALUES ('a,b', '{ "comment": "This is example", "number": 42 }');
SELECT * FROM t;
TRUNCATE TABLE t;
SELECT * FROM t;
DROP TABLE t;
CREATE TABLE t (
status ENUM('active', 'inactive', 'deleted') DEFAULT 'active',
options SET('a', 'b', 'c', 'd') DEFAULT 'a,b',
info JSON DEFAULT '{}'
) ENGINE=columnstore;
INSERT INTO t (status, options)
VALUES ('active', 'a,b');
SELECT * FROM t;
TRUNCATE TABLE t;
SELECT * FROM t;
INSERT INTO t (status, info)
VALUES ('active', '{ "comment": "This is example", "number": 42 }');
SELECT * FROM t;
TRUNCATE TABLE t;
SELECT * FROM t;
INSERT INTO t (options, info)
VALUES ('a,b', '{ "comment": "This is example", "number": 42 }');
SELECT * FROM t;
TRUNCATE TABLE t;
SELECT * FROM t;
DROP TABLE t;
# Clean UP
DROP DATABASE mcol4240_enum_set_json_db;