From 2aa3234e54a21fd5b1488dc3f9ec824ff8652795 Mon Sep 17 00:00:00 2001 From: Nedeljko Stefanovic Date: Wed, 30 Jul 2025 19:30:51 +0000 Subject: [PATCH] Tests added --- .../basic/r/mcol4240-enum_set_json.result | 178 +++++++++++++++ .../basic/t/mcol4240-enum_set_json.test | 204 ++++++++++++++++++ 2 files changed, 382 insertions(+) create mode 100644 mysql-test/columnstore/basic/r/mcol4240-enum_set_json.result create mode 100644 mysql-test/columnstore/basic/t/mcol4240-enum_set_json.test diff --git a/mysql-test/columnstore/basic/r/mcol4240-enum_set_json.result b/mysql-test/columnstore/basic/r/mcol4240-enum_set_json.result new file mode 100644 index 000000000..fda7c54b2 --- /dev/null +++ b/mysql-test/columnstore/basic/r/mcol4240-enum_set_json.result @@ -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; diff --git a/mysql-test/columnstore/basic/t/mcol4240-enum_set_json.test b/mysql-test/columnstore/basic/t/mcol4240-enum_set_json.test new file mode 100644 index 000000000..a4e54facd --- /dev/null +++ b/mysql-test/columnstore/basic/t/mcol4240-enum_set_json.test @@ -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;