ClickHouse/tests/queries/0_stateless/01721_constraints_constant_expressions.sql

41 lines
1.3 KiB
MySQL
Raw Normal View History

2021-02-19 20:00:33 +00:00
DROP TABLE IF EXISTS constraint_constant_number_expression;
CREATE TABLE constraint_constant_number_expression
(
id UInt64,
CONSTRAINT `c0` CHECK 1,
CONSTRAINT `c1` CHECK 1 < 2,
CONSTRAINT `c2` CHECK isNull(cast(NULL, 'Nullable(UInt8)'))
) ENGINE = TinyLog();
INSERT INTO constraint_constant_number_expression VALUES (1);
SELECT * FROM constraint_constant_number_expression;
DROP TABLE constraint_constant_number_expression;
DROP TABLE IF EXISTS constraint_constant_number_expression_non_uint8;
CREATE TABLE constraint_constant_number_expression_non_uint8
(
id UInt64,
CONSTRAINT `c0` CHECK toUInt64(1)
) ENGINE = TinyLog();
2021-02-25 08:35:31 +00:00
INSERT INTO constraint_constant_number_expression_non_uint8 VALUES (2); -- {serverError 1}
2021-02-19 20:00:33 +00:00
SELECT * FROM constraint_constant_number_expression_non_uint8;
DROP TABLE constraint_constant_number_expression_non_uint8;
2021-02-25 08:35:31 +00:00
DROP TABLE IF EXISTS constraint_constant_nullable_expression_that_contains_null;
CREATE TABLE constraint_constant_nullable_expression_that_contains_null
(
id UInt64,
CONSTRAINT `c0` CHECK nullIf(1 % 2, 1)
) ENGINE = TinyLog();
INSERT INTO constraint_constant_nullable_expression_that_contains_null VALUES (3); -- {serverError 469}
SELECT * FROM constraint_constant_nullable_expression_that_contains_null;
DROP TABLE constraint_constant_nullable_expression_that_contains_null;