diff --git a/mysql-test/include/dd_schema_assert_and_fill_table_names.inc b/mysql-test/include/dd_schema_assert_and_fill_table_names.inc
index 7993c9aa1584..cd75236da514 100644
--- a/mysql-test/include/dd_schema_assert_and_fill_table_names.inc
+++ b/mysql-test/include/dd_schema_assert_and_fill_table_names.inc
@@ -9,11 +9,11 @@ SET debug = '+d,skip_dd_table_access_check';
--echo ########################################################################
--echo # The number of hidden DD/DDSE tables must be as expected.
--echo ########################################################################
-let $number_of_hidden_dd_tables = 31;
+let $number_of_hidden_dd_tables = 32;
let $assert_cond = "[SELECT COUNT(*) from mysql.tables
WHERE schema_id = 1 AND hidden = \'System\']"
= $number_of_hidden_dd_tables;
---let $assert_text = There are 31 hidden DD/DDSE tables.
+--let $assert_text = There are 32 hidden DD/DDSE tables.
--source include/assert.inc
# Fill two help tables with the names of the DDSE and DD tables.
@@ -46,6 +46,7 @@ eval INSERT INTO $dd_table_names (name) VALUES
('catalogs'),
('character_sets'),
('collations'),
+ ('check_constraints'),
('column_statistics'),
('column_type_elements'),
('columns'),
@@ -78,7 +79,7 @@ eval INSERT INTO $dd_table_names (name) VALUES
let $assert_cond = "[SELECT (SELECT COUNT(*) FROM $dd_table_names) +
(SELECT COUNT(*) FROM $ddse_table_names)]"
= $number_of_hidden_dd_tables + 2;
---let $assert_text = There are 33 DD/DDSE tables in total.
+--let $assert_text = There are 34 DD/DDSE tables in total.
--source include/assert.inc
--echo ########################################################################
diff --git a/mysql-test/r/check_constraints.result b/mysql-test/r/check_constraints.result
new file mode 100644
index 000000000000..9cbefeabd020
--- /dev/null
+++ b/mysql-test/r/check_constraints.result
@@ -0,0 +1,2613 @@
+#------------------------------------------------------------------------
+# Test cases to verify column check constraint syntax.
+#------------------------------------------------------------------------
+CREATE TABLE t1(f1 int CHECK);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
+CREATE TABLE t1(f1 int CHECK());
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 1
+CREATE TABLE t1(f1 int CONSTRAINT CHECK());
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 1
+CREATE TABLE t1(f1 int t1_ck CHECK());
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't1_ck CHECK())' at line 1
+CREATE TABLE t1(f1 int CONSTRAINT t1_ck CHECK());
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 1
+CREATE TABLE t1(f1 int CONSTRAINT t1_ck CHECK( f1 < 10) NOT);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
+CREATE TABLE t1(f1 int CHECK(f1));
+ERROR HY000: An expression of non-boolean type specified to a check constraint 't1_chk_1'.
+CREATE TABLE t1(f1 int CHECK(f1 + 10));
+ERROR HY000: An expression of non-boolean type specified to a check constraint 't1_chk_1'.
+CREATE TABLE t1(f1 int CHECK(f2 < 10));
+ERROR HY000: Column check constraint 't1_chk_1' references other column.
+CREATE TABLE t1 (f1 int CHECK(f1 < 10),
+f2 int CONSTRAINT t1_f2_ck CHECK (f2 < 10));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` < 10)),
+ CONSTRAINT `t1_f2_ck` CHECK ((`f2` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t1;
+CREATE TABLE t1(f1 int CHECK(f1 < 10), f2 int CHECK);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
+CREATE TABLE t1(f1 int CHECK(f1 < 10), f2 int CHECK());
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 1
+CREATE TABLE t1(f1 int CHECK(f1 < 10), f2 int CONSTRAINT CHECK());
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 1
+CREATE TABLE t1(f1 int CHECK(f1 < 10), f2 int t1_f2_ck CHECK(f2 < 10));
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't1_f2_ck CHECK(f2 < 10))' at line 1
+CREATE TABLE t1(f1 int CHECK(f1 < 10), f2 int CONSTRAINT t1_f2_ck CHECK(f2 < 10) NOT);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
+CREATE TABLE t1(f1 int CHECK(f1 < 10), f2 int CHECK(f2 < 10) NOT);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
+CREATE TABLE t1(f1 int CHECK(f1 < 10), f2 int CHECK(f2));
+ERROR HY000: An expression of non-boolean type specified to a check constraint 't1_chk_2'.
+CREATE TABLE t1(f1 int CHECK(f1 < 10), f2 int CHECK(f2 + 10));
+ERROR HY000: An expression of non-boolean type specified to a check constraint 't1_chk_2'.
+CREATE TABLE t1(f1 int CHECK(f1 < 10), f2 int CHECK(f3 < 10));
+ERROR HY000: Column check constraint 't1_chk_2' references other column.
+CREATE TABLE t1 (f1 int CHECK(f1 < 10), f2 int CHECK(f2 < 10),
+f3 int CONSTRAINT t1_f3_ck CHECK (f3 < 10));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ `f3` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` < 10)),
+ CONSTRAINT `t1_chk_2` CHECK ((`f2` < 10)),
+ CONSTRAINT `t1_f3_ck` CHECK ((`f3` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t1;
+#------------------------------------------------------------------------
+# Test cases to verify table check constraint syntax.
+#------------------------------------------------------------------------
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK();
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK());
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 1
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK(f1));
+ERROR HY000: An expression of non-boolean type specified to a check constraint 't1_ck'.
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK(f1 + 10));
+ERROR HY000: An expression of non-boolean type specified to a check constraint 't1_ck'.
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK(f2 < 10));
+ERROR HY000: Check constraint 't1_ck' refers to non-existing column 'f2'.
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK(f1 < 10));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_ck` CHECK ((`f1` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t1;
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK(f1<10), CONSTRAINT t2_ck CHECK);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK(f1<10), CONSTRAINT t2_ck CHECK();
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK(f1<10), CONSTRAINT t2_ck CHECK(f2 > 0) NOT);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK(f1<10), CONSTRAINT t2_ck CHECK(f1));
+ERROR HY000: An expression of non-boolean type specified to a check constraint 't2_ck'.
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK(f1<10), CONSTRAINT t2_ck CHECK(f1 + 10));
+ERROR HY000: An expression of non-boolean type specified to a check constraint 't2_ck'.
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK(f1<10), CONSTRAINT t2_ck CHECK(f2 > 1));
+ERROR HY000: Check constraint 't2_ck' refers to non-existing column 'f2'.
+CREATE TABLE t1(f1 int, CHECK(f1<10), CONSTRAINT t2_ck CHECK(f1 > 1));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` < 10)),
+ CONSTRAINT `t2_ck` CHECK ((`f1` > 1))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint name with special charecters.
+#-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, c2 INT, CONSTRAINT `ck_1$` CHECK (c2 < 10));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL,
+ CONSTRAINT `ck_1$` CHECK ((`c2` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint name with white spaces.
+#-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, c2 INT, CONSTRAINT ` ck_2$ ` CHECK (c2 < 10));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL,
+ CONSTRAINT ` ck_2$ ` CHECK ((`c2` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+ALTER TABLE t1 DROP CHECK ck_2$;
+ERROR HY000: Check constraint 'ck_2$' is not found in the table.
+ALTER TABLE t1 DROP CHECK ` ck_2$ `;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+ALTER TABLE t1 ADD COLUMN c3 INTEGER , ADD CONSTRAINT ` c 3 ` CHECK ( c3 > 10 );
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL,
+ `c3` int(11) DEFAULT NULL,
+ CONSTRAINT ` c 3 ` CHECK ((`c3` > 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint name with reserved words.
+#-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, c2 INT, CONSTRAINT FLOAT CHECK (c2 < 10));
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FLOAT CHECK (c2 < 10))' at line 1
+CREATE TABLE t1(c1 INT, c2 INT, CONSTRAINT `FLOAT` CHECK (c2 < 10));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL,
+ CONSTRAINT `FLOAT` CHECK ((`c2` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint with long name.
+#-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, c2 INT,
+CONSTRAINT ckkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+CHECK (c2 < 10));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL,
+ CONSTRAINT `ckkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk` CHECK ((`c2` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+CREATE TABLE t2(c1 INT, c2 INT,
+CONSTRAINT ckkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk1
+CHECK (c2 < 10));
+ERROR 42000: Identifier name 'ckkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk1' is too long
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint with too long generated name.
+#-----------------------------------------------------------------------
+CREATE TABLE t1 (f1 INT CHECK (f1 < 10));
+RENAME TABLE t1 TO t123456789012345678901234567890123456789012345678901234567890;
+ERROR 42000: Identifier name 't123456789012345678901234567890123456789012345678901234567890_chk_1' is too long
+DROP TABLE t1;
+CREATE TABLE t123456789012345678901234567890123456789012345678901234567890(f1 INT CHECK(f1 < 10));
+ERROR 42000: Identifier name 't123456789012345678901234567890123456789012345678901234567890_chk_1' is too long
+CREATE TABLE t123456789012345678901234567890123456789012345678901234567890(f1 INT);
+ALTER TABLE t123456789012345678901234567890123456789012345678901234567890 ADD CONSTRAINT CHECK (f1 < 10);
+ERROR 42000: Identifier name 't123456789012345678901234567890123456789012345678901234567890_chk_1' is too long
+DROP TABLE t123456789012345678901234567890123456789012345678901234567890;
+#-----------------------------------------------------------------------
+# Test case to verify duplicate check constraint name under same
+# database. Check constraints with same name are not allowed under
+# same database.
+#-----------------------------------------------------------------------
+CREATE TABLE t(c1 INT CONSTRAINT t2_chk_1 CHECK (c1 > 10));
+CREATE TABLE t1(c1 INT CHECK (c1 > 10), CONSTRAINT ck CHECK(c1 > 10));
+CREATE TABLE t2(c1 INT, CONSTRAINT ck CHECK(c1 > 10));
+ERROR HY000: Duplicate check constraint name 'ck'.
+ALTER TABLE t1 ADD CONSTRAINT ck CHECK(c1 > 10);
+ERROR HY000: Duplicate check constraint name 'ck'.
+ALTER TABLE t1 RENAME TO t2;
+ERROR HY000: Duplicate check constraint name 't2_chk_1'.
+ALTER TABLE t1 ADD c2 INT, RENAME TO t2;
+ERROR HY000: Duplicate check constraint name 't2_chk_1'.
+DROP TABLE t;
+CREATE DATABASE db1;
+CREATE TABLE db1.t(c1 INT CONSTRAINT t2_chk_1 CHECK (c1 > 10));
+ALTER TABLE t1 ADD c2 INT, RENAME TO db1.t2;
+ERROR HY000: Duplicate check constraint name 't2_chk_1'.
+ALTER TABLE t1 RENAME TO db1.t2;
+ERROR HY000: Duplicate check constraint name 't2_chk_1'.
+DROP DATABASE db1;
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Check constraint names are case insenitive and accent sensitive. Test
+# case to verify the same.
+#-----------------------------------------------------------------------
+CREATE TABLE t1 (f1 INT,
+CONSTRAINT cafe CHECK (f1 < 10),
+CONSTRAINT CAFE CHECK (f1 < 10));
+ERROR HY000: Duplicate check constraint name 'CAFE'.
+create table t1 (f1 int,
+CONSTRAINT cafe CHECK (f1 < 10),
+CONSTRAINT café CHECK (f1 < 10));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ CONSTRAINT `cafe` CHECK ((`f1` < 10)),
+ CONSTRAINT `café` CHECK ((`f1` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t1;
+#------------------------------------------------------------------------
+# Test cases to verify forward reference of columns in the constraint.
+#------------------------------------------------------------------------
+CREATE TABLE t1(CHECK((f1 + f3) > 10), f1 int CHECK (f1 < 10), f2 int);
+ERROR HY000: Check constraint 't1_chk_1' refers to non-existing column 'f3'.
+CREATE TABLE t1(CHECK((f1 + f2) > 10), f1 int CHECK (f1 < 10), f2 int);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK (((`f1` + `f2`) > 10)),
+ CONSTRAINT `t1_chk_2` CHECK ((`f1` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME CHECK_CLAUSE
+def test t1_chk_1 ((`f1` + `f2`) > 10)
+def test t1_chk_2 (`f1` < 10)
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify creation of multiple check constraint on table.
+#-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, c2 INT, c3 INT, c4 INT);
+ALTER TABLE t1 ADD CONSTRAINT ck11 CHECK(c1 > 1),
+ADD CONSTRAINT ck12 CHECK(c1 < 1),
+ADD CONSTRAINT ck21 CHECK(c2 > 1),
+ADD CONSTRAINT ck22 CHECK(c2 < 1),
+ADD CONSTRAINT ck31 CHECK(c3 > 1),
+ADD CONSTRAINT ck32 CHECK(c3 < 1),
+ADD CONSTRAINT ck41 CHECK(c4 > 1),
+ADD CONSTRAINT ck42 CHECK(c4 < 1);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL,
+ `c3` int(11) DEFAULT NULL,
+ `c4` int(11) DEFAULT NULL,
+ CONSTRAINT `ck11` CHECK ((`c1` > 1)),
+ CONSTRAINT `ck12` CHECK ((`c1` < 1)),
+ CONSTRAINT `ck21` CHECK ((`c2` > 1)),
+ CONSTRAINT `ck22` CHECK ((`c2` < 1)),
+ CONSTRAINT `ck31` CHECK ((`c3` > 1)),
+ CONSTRAINT `ck32` CHECK ((`c3` < 1)),
+ CONSTRAINT `ck41` CHECK ((`c4` > 1)),
+ CONSTRAINT `ck42` CHECK ((`c4` < 1))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify check constraints with generated columns
+#-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT,
+c2 INT,
+c3 INT GENERATED ALWAYS AS (c1 + c2),
+CONSTRAINT ck CHECK (c3 > 10)
+);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL,
+ `c3` int(11) GENERATED ALWAYS AS ((`c1` + `c2`)) VIRTUAL,
+ CONSTRAINT `ck` CHECK ((`c3` > 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+INSERT INTO t1(c1,c2) VALUES(1,1);
+ERROR HY000: Check constraint 'ck' is violated.
+INSERT INTO t1(c1,c2) VALUES(10,10);
+DROP TABLE t1;
+#------------------------------------------------------------------------
+# Test case to verify check constraints with DEFAULT column value.
+#------------------------------------------------------------------------
+CREATE TABLE t1(c1 INT DEFAULT 100 CHECK(c1 > 10));
+INSERT INTO t1() VALUES(1);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO t1() VALUES();
+DROP TABLE t1;
+CREATE TABLE t1(c1 int DEFAULT 1, CONSTRAINT CHECK(c1 IS NOT NULL));
+INSERT INTO t1() VALUES();
+INSERT INTO t1() VALUES(NULL);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint behaviour with ascii charset
+#-----------------------------------------------------------------------
+CREATE TABLE t1(c1 VARCHAR(1) CHARSET ASCII CHECK(c1 = 'a'),
+c2 VARCHAR(1) CHARSET ASCII DEFAULT('b'));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` varchar(1) CHARACTER SET ascii COLLATE ascii_general_ci DEFAULT NULL,
+ `c2` varchar(1) CHARACTER SET ascii COLLATE ascii_general_ci DEFAULT (_utf8mb4'b'),
+ CONSTRAINT `t1_chk_1` CHECK ((`c1` = _utf8mb4'a'))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+INSERT INTO t1(c1) VALUES('b');
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO t1(c1) VALUES('a');
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint with an expression evaluated to
+# FALSE always.
+#-----------------------------------------------------------------------
+CREATE TABLE t1 (CHECK (1 < 1), f1 int);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((1 < 1))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+INSERT INTO t1 VALUES(1);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO t1 VALUES(10);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO t1 VALUES();
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+DROP TABLE t1;
+#------------------------------------------------------------------------
+# Test case to verify INFORMATION_SCHEMA.CHECK_CONSTRAINTS and
+# INFORMATION_SCHEMA.TABLE_CONSTRAINTS result set.
+#------------------------------------------------------------------------
+CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT CHECK (f2 < 10),
+CONSTRAINT t2_cc1 CHECK (f1 + SQRT(f2) > 6174));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) NOT NULL,
+ `f2` int(11) DEFAULT NULL,
+ PRIMARY KEY (`f1`),
+ CONSTRAINT `t1_chk_1` CHECK ((`f2` < 10)),
+ CONSTRAINT `t2_cc1` CHECK (((`f1` + sqrt(`f2`)) > 6174))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME CHECK_CLAUSE
+def test t1_chk_1 (`f2` < 10)
+def test t2_cc1 ((`f1` + sqrt(`f2`)) > 6174)
+SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE TABLE_NAME='t1';
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
+def test PRIMARY test t1 PRIMARY KEY YES
+def test t1_chk_1 test t1 CHECK YES
+def test t2_cc1 test t1 CHECK YES
+DROP TABLE t1;
+#------------------------------------------------------------------------
+# Test cases to verify check constraints in temporary table.
+#------------------------------------------------------------------------
+CREATE TEMPORARY TABLE tmp_t1(CHECK((f1 + f2) > 10), f1 int CHECK (f1 < 12),
+f2 int);
+SHOW CREATE TABLE tmp_t1;
+Table Create Table
+tmp_t1 CREATE TEMPORARY TABLE `tmp_t1` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `tmp_t1_chk_1` CHECK (((`f1` + `f2`) > 10)),
+ CONSTRAINT `tmp_t1_chk_2` CHECK ((`f1` < 12))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME CHECK_CLAUSE
+DROP TABLE tmp_t1;
+#------------------------------------------------------------------------
+# Test cases to verify check constraints with CREATE TABLE LIKE
+#------------------------------------------------------------------------
+CREATE TABLE t1(f1 INT CHECK (f1 < 10), f2 INT, CHECK (f2 < 10),
+CONSTRAINT min CHECK (f1 + f2 > 10),
+CONSTRAINT max CHECK (f1 + f2 < 929));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `max` CHECK (((`f1` + `f2`) < 929)),
+ CONSTRAINT `min` CHECK (((`f1` + `f2`) > 10)),
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` < 10)),
+ CONSTRAINT `t1_chk_2` CHECK ((`f2` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+CREATE TABLE t2 LIKE t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `t2_chk_1` CHECK (((`f1` + `f2`) < 929)),
+ CONSTRAINT `t2_chk_2` CHECK (((`f1` + `f2`) > 10)),
+ CONSTRAINT `t2_chk_3` CHECK ((`f1` < 10)),
+ CONSTRAINT `t2_chk_4` CHECK ((`f2` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+CREATE TEMPORARY TABLE tmp_t2 LIKE t2;
+SHOW CREATE TABLE tmp_t2;
+Table Create Table
+tmp_t2 CREATE TEMPORARY TABLE `tmp_t2` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `tmp_t2_chk_1` CHECK (((`f1` + `f2`) < 929)),
+ CONSTRAINT `tmp_t2_chk_2` CHECK (((`f1` + `f2`) > 10)),
+ CONSTRAINT `tmp_t2_chk_3` CHECK ((`f1` < 10)),
+ CONSTRAINT `tmp_t2_chk_4` CHECK ((`f2` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+CREATE TABLE t3 LIKE tmp_t2;
+SHOW CREATE TABLE t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `t3_chk_1` CHECK (((`f1` + `f2`) < 929)),
+ CONSTRAINT `t3_chk_2` CHECK (((`f1` + `f2`) > 10)),
+ CONSTRAINT `t3_chk_3` CHECK ((`f1` < 10)),
+ CONSTRAINT `t3_chk_4` CHECK ((`f2` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t1, t2, t3, tmp_t2;
+#------------------------------------------------------------------------
+# Test cases to verify effect of check constraint in DML operations.
+#------------------------------------------------------------------------
+CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT CHECK (f2 < 10));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) NOT NULL,
+ `f2` int(11) DEFAULT NULL,
+ PRIMARY KEY (`f1`),
+ CONSTRAINT `t1_chk_1` CHECK ((`f2` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+CREATE TABLE t2(f1 INT, f2 INT);
+INSERT INTO t2 VALUES(101, 1);
+INSERT INTO t2 VALUES(102, NULL);
+INSERT INTO t2 VALUES(103, 1000);
+# INSERT operations.
+INSERT INTO t1 VALUES(1, 1);
+INSERT INTO t1 VALUES(2, NULL);
+INSERT INTO t1 VALUES(3, 1000);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT IGNORE INTO t1 VALUES (3, 1000);
+Warnings:
+Warning 3820 Check constraint 't1_chk_1' is violated.
+SELECT * FROM t1;
+f1 f2
+1 1
+2 NULL
+INSERT INTO t1 SELECT * FROM t2;
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+SELECT * FROM t1;
+f1 f2
+1 1
+2 NULL
+INSERT IGNORE INTO t1 SELECT * FROM t2;
+Warnings:
+Warning 3820 Check constraint 't1_chk_1' is violated.
+SELECT * FROM t1;
+f1 f2
+1 1
+2 NULL
+101 1
+102 NULL
+# REPLACE operations.
+REPLACE INTO t1 VALUES(4, 1);
+REPLACE INTO t1 VALUES(5, NULL);
+REPLACE INTO t1 VALUES(6, 100);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+REPLACE INTO t1 VALUES(2, 10);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+REPLACE INTO t1 VALUES(2, 2);
+SELECT * FROM t1;
+f1 f2
+1 1
+2 2
+4 1
+5 NULL
+101 1
+102 NULL
+# UPDATE operations.
+UPDATE t1 SET f2 = 2;
+SELECT * FROM t1;
+f1 f2
+1 2
+2 2
+4 2
+5 2
+101 2
+102 2
+UPDATE t1 SET f2 = NULL;
+UPDATE t1 SET f2 = 1000;
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+UPDATE IGNORE t1 SET f2 = 1000;
+Warnings:
+Warning 3820 Check constraint 't1_chk_1' is violated.
+Warning 3820 Check constraint 't1_chk_1' is violated.
+Warning 3820 Check constraint 't1_chk_1' is violated.
+Warning 3820 Check constraint 't1_chk_1' is violated.
+Warning 3820 Check constraint 't1_chk_1' is violated.
+Warning 3820 Check constraint 't1_chk_1' is violated.
+SELECT * FROM t1;
+f1 f2
+1 NULL
+2 NULL
+4 NULL
+5 NULL
+101 NULL
+102 NULL
+DROP TABLE t1, t2;
+# LOAD DATA operations.
+CREATE TABLE t2(f1 INT,f2 INT);
+INSERT INTO t2 VALUES(1,1);
+INSERT INTO t2 VALUES(2,NULL);
+CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT CHECK (f2 < 10));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) NOT NULL,
+ `f2` int(11) DEFAULT NULL,
+ PRIMARY KEY (`f1`),
+ CONSTRAINT `t1_chk_1` CHECK ((`f2` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+SELECT * FROM t2;
+f1 f2
+1 1
+2 NULL
+SELECT * FROM t2 INTO OUTFILE 'tmp1.txt';
+LOAD DATA INFILE 'tmp1.txt' INTO TABLE t1;
+SELECT * FROM t1;
+f1 f2
+1 1
+2 NULL
+DELETE FROM t1;
+INSERT INTO t2 VALUES(3,20);
+SELECT * FROM t2;
+f1 f2
+1 1
+2 NULL
+3 20
+SELECT * FROM t2 INTO OUTFILE 'tmp2.txt';
+LOAD DATA INFILE 'tmp2.txt' INTO TABLE t1;
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+SELECT * FROM t1;
+f1 f2
+LOAD DATA INFILE 'tmp2.txt' IGNORE INTO TABLE t1;
+Warnings:
+Warning 3820 Check constraint 't1_chk_1' is violated.
+SELECT * FROM t1;
+f1 f2
+1 1
+2 NULL
+DROP TABLE t1,t2;
+CREATE TABLE t1 (a INT CHECK(a < 3), b CHAR(10)) CHARSET latin1;
+LOAD DATA INFILE '../../std_data/loaddata3.dat' IGNORE INTO TABLE t1
+FIELDS TERMINATED BY '' ENCLOSED BY '' IGNORE 1 LINES;
+Warnings:
+Warning 1366 Incorrect integer value: 'error ' for column 'a' at row 3
+Warning 1262 Row 3 was truncated; it contained more data than there were input columns
+Warning 3820 Check constraint 't1_chk_1' is violated.
+Warning 1261 Row 4 doesn't contain data for all columns
+Warning 1261 Row 4 doesn't contain data for all columns
+Warning 1366 Incorrect integer value: 'wrong end ' for column 'a' at row 5
+Warning 1262 Row 5 was truncated; it contained more data than there were input columns
+DROP TABLE t1;
+# LOAD XML operations.
+CREATE TABLE t2(f1 INT,f2 INT);
+INSERT INTO t2 VALUES(1,1);
+INSERT INTO t2 VALUES(2,NULL);
+CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT CHECK (f2 < 10));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) NOT NULL,
+ `f2` int(11) DEFAULT NULL,
+ PRIMARY KEY (`f1`),
+ CONSTRAINT `t1_chk_1` CHECK ((`f2` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+SELECT * FROM t2;
+f1 f2
+1 1
+2 NULL
+LOAD XML INFILE "MYSQLTEST_VARDIR/tmp/tmp1.xml" INTO TABLE t1;;
+SELECT * FROM t1;
+f1 f2
+1 1
+2 NULL
+DELETE FROM t1;
+INSERT INTO t2 VALUES(3,20);
+SELECT * FROM t2;
+f1 f2
+1 1
+2 NULL
+3 20
+LOAD XML INFILE "MYSQLTEST_VARDIR/tmp/tmp2.xml" INTO TABLE t1;;
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+SELECT * FROM t1;
+f1 f2
+LOAD XML INFILE "MYSQLTEST_VARDIR/tmp/tmp2.xml" IGNORE INTO TABLE t1;;
+Warnings:
+Warning 3820 Check constraint 't1_chk_1' is violated.
+SELECT * FROM t1;
+f1 f2
+1 1
+2 NULL
+DROP TABLE t1,t2;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint with INSERT ON DUPLICATE
+#-----------------------------------------------------------------------
+CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT CHECK (f2 < 10));
+INSERT INTO t1 VALUES (1, 1);
+INSERT INTO t1 VALUES (1, 2) ON DUPLICATE KEY UPDATE f2 = 4;
+SELECT * FROM t1;
+f1 f2
+1 4
+INSERT IGNORE INTO t1 VALUES (1, 1) ON DUPLICATE KEY UPDATE f2 = 20;
+Warnings:
+Warning 3820 Check constraint 't1_chk_1' is violated.
+INSERT INTO t1 VALUES (1, 1) ON DUPLICATE KEY UPDATE f2 = 20;
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify check constraints with multi-table update.
+#-----------------------------------------------------------------------
+CREATE TABLE t1(f1 INT, f2 INT CHECK(f2 < 20));
+INSERT INTO t1 VALUES (4, 4);
+CREATE TABLE t2(f1 INT, f2 INT);
+INSERT INTO t2 VALUES (4, 24);
+UPDATE t1,t2 SET t1.f2 = t1.f2 + 20 WHERE t1.f1 = t2.f1;
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+UPDATE IGNORE t1,t2 SET t1.f2 = t1.f2 + 20 WHERE t1.f1 = t2.f1;
+Warnings:
+Warning 3820 Check constraint 't1_chk_1' is violated.
+DROP TABLE t1, t2;
+CREATE TABLE t1 (
+`f1` int(10) unsigned NOT NULL auto_increment,
+`f2` int(11) NOT NULL default '0',
+PRIMARY KEY (`f1`)
+);
+INSERT INTO t1 VALUES (4433,5424);
+CREATE TABLE t2 (
+`f3` int(10) unsigned NOT NULL default '0',
+`f4` int(10) unsigned NOT NULL default '0' CHECK (f4 <= 500),
+PRIMARY KEY (`f3`,`f4`)
+);
+INSERT INTO t2 VALUES (495,500);
+INSERT INTO t2 VALUES (496,500);
+UPDATE t2,t1 set t2.f4 = t2.f4 + 1;
+ERROR HY000: Check constraint 't2_chk_1' is violated.
+UPDATE IGNORE t2,t1 set t2.f4 = t2.f4 + 1;
+Warnings:
+Warning 3820 Check constraint 't2_chk_1' is violated.
+Warning 3820 Check constraint 't2_chk_1' is violated.
+DROP TABLE t1, t2;
+#------------------------------------------------------------------------
+# Test cases to verify generated check constraint name updates due to
+# RENAME TABLE operation.
+#------------------------------------------------------------------------
+CREATE TABLE t1 (f1 INT CHECK(f1 < 10));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+RENAME TABLE t1 TO t2;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `f1` int(11) DEFAULT NULL,
+ CONSTRAINT `t2_chk_1` CHECK ((`f1` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+CREATE TABLE t1(f1 INT CHECK (f1>10), f11 INT CHECK (f11 < 1000));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ `f11` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` > 10)),
+ CONSTRAINT `t1_chk_2` CHECK ((`f11` < 1000))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+RENAME TABLE t1 TO t3, t2 TO t1, t3 TO t2;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `f1` int(11) DEFAULT NULL,
+ `f11` int(11) DEFAULT NULL,
+ CONSTRAINT `t2_chk_1` CHECK ((`f1` > 10)),
+ CONSTRAINT `t2_chk_2` CHECK ((`f11` < 1000))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t1, t2;
+#------------------------------------------------------------------------
+# Test case to verify check constraints removal on DROP table operation.
+#------------------------------------------------------------------------
+CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT CHECK (f2 < 10));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) NOT NULL,
+ `f2` int(11) DEFAULT NULL,
+ PRIMARY KEY (`f1`),
+ CONSTRAINT `t1_chk_1` CHECK ((`f2` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME CHECK_CLAUSE
+def test t1_chk_1 (`f2` < 10)
+SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE TABLE_NAME='t1';
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
+def test PRIMARY test t1 PRIMARY KEY YES
+def test t1_chk_1 test t1 CHECK YES
+DROP TABLE t1;
+#------------------------------------------------------------------------
+# Test case to verify check constraints creation with ALTER TABLE ADD
+# CONSTRAINT operation.
+#------------------------------------------------------------------------
+CREATE TABLE t1 (f1 INT CHECK (f1 < 10));
+CREATE TEMPORARY TABLE t3(f1 INT CHECK (f1 < 10));
+ALTER TABLE t1 ADD CONSTRAINT CHECK (f1 > 1), ADD CONSTRAINT `t1_p_ck` CHECK (f1 > 1);
+ALTER TABLE t3 ADD CONSTRAINT CHECK (f1 > 1), ADD CONSTRAINT `t3_p_ck` CHECK (f1 > 1);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` < 10)),
+ CONSTRAINT `t1_chk_2` CHECK ((`f1` > 1)),
+ CONSTRAINT `t1_p_ck` CHECK ((`f1` > 1))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+SHOW CREATE TABLE t3;
+Table Create Table
+t3 CREATE TEMPORARY TABLE `t3` (
+ `f1` int(11) DEFAULT NULL,
+ CONSTRAINT `t3_chk_1` CHECK ((`f1` < 10)),
+ CONSTRAINT `t3_chk_2` CHECK ((`f1` > 1)),
+ CONSTRAINT `t3_p_ck` CHECK ((`f1` > 1))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+# Test case to verify check constraint creation with ALTER TABLE ADD
+# constraint and generated name updates with RENAME TO
in
+# ALTER operation.
+ALTER TABLE t1 ADD f2 INT CHECK (f2 < 10), RENAME TO t6, ALGORITHM=COPY;
+SHOW CREATE TABLE t6;
+Table Create Table
+t6 CREATE TABLE `t6` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_p_ck` CHECK ((`f1` > 1)),
+ CONSTRAINT `t6_chk_1` CHECK ((`f1` < 10)),
+ CONSTRAINT `t6_chk_2` CHECK ((`f1` > 1)),
+ CONSTRAINT `t6_chk_3` CHECK ((`f2` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+ALTER TABLE t3 ADD f2 INT CHECK (f2 < 10), RENAME TO t7, ALGORITHM=COPY;
+SHOW CREATE TABLE t7;
+Table Create Table
+t7 CREATE TEMPORARY TABLE `t7` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `t7_chk_1` CHECK ((`f1` < 10)),
+ CONSTRAINT `t7_chk_2` CHECK ((`f1` > 1)),
+ CONSTRAINT `t3_p_ck` CHECK ((`f1` > 1)),
+ CONSTRAINT `t7_chk_3` CHECK ((`f2` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+ALTER TABLE t6 RENAME TO t1;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` < 10)),
+ CONSTRAINT `t1_chk_2` CHECK ((`f1` > 1)),
+ CONSTRAINT `t1_chk_3` CHECK ((`f2` < 10)),
+ CONSTRAINT `t1_p_ck` CHECK ((`f1` > 1))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+ALTER TABLE t7 RENAME TO t3;
+SHOW CREATE TABLE t3;
+Table Create Table
+t3 CREATE TEMPORARY TABLE `t3` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `t3_chk_1` CHECK ((`f1` < 10)),
+ CONSTRAINT `t3_chk_2` CHECK ((`f1` > 1)),
+ CONSTRAINT `t3_p_ck` CHECK ((`f1` > 1)),
+ CONSTRAINT `t3_chk_3` CHECK ((`f2` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+# Test case to verify add check constraint with INPLACE alter algorithm.
+ALTER TABLE t1 ADD f2 INT CHECK (f2 < 10), ALGORITHM=INPLACE;
+ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
+ALTER TABLE t3 ADD f2 INT CHECK (f2 < 10), ALGORITHM=INPLACE;
+ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
+ALTER TABLE t1 ADD f3 INT CHECK (f3 < 10) NOT ENFORCED, ALGORITHM=INPLACE;
+ALTER TABLE t1 ADD CONSTRAINT CHECK (f2 < 10) NOT ENFORCED, ALGORITHM=INPLACE;
+ALTER TABLE t1 RENAME COLUMN f1 TO f10;
+ERROR 42S22: Unknown column 'f1' in 'check constraint t1_chk_1 expression'
+#------------------------------------------------------------------------
+# Test case to verify check constraints creation with ALTER TABLE DROP
+# CONSTRAINT operation.
+#------------------------------------------------------------------------
+SHOW CREATE TABLE t3;
+Table Create Table
+t3 CREATE TEMPORARY TABLE `t3` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `t3_chk_1` CHECK ((`f1` < 10)),
+ CONSTRAINT `t3_chk_2` CHECK ((`f1` > 1)),
+ CONSTRAINT `t3_p_ck` CHECK ((`f1` > 1)),
+ CONSTRAINT `t3_chk_3` CHECK ((`f2` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+ALTER TABLE t3 DROP CHECK t3_chk_3;
+SHOW CREATE TABLE t3;
+Table Create Table
+t3 CREATE TEMPORARY TABLE `t3` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `t3_chk_1` CHECK ((`f1` < 10)),
+ CONSTRAINT `t3_chk_2` CHECK ((`f1` > 1)),
+ CONSTRAINT `t3_p_ck` CHECK ((`f1` > 1))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+ALTER TABLE t3 DROP CHECK t3_p_ck, ADD CONSTRAINT t3_p_ck CHECK (f1 > 38);
+SHOW CREATE TABLE t3;
+Table Create Table
+t3 CREATE TEMPORARY TABLE `t3` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `t3_chk_1` CHECK ((`f1` < 10)),
+ CONSTRAINT `t3_chk_2` CHECK ((`f1` > 1)),
+ CONSTRAINT `t3_p_ck` CHECK ((`f1` > 38))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+#------------------------------------------------------------------------
+# Test case to verify check constraints alter operations.
+#------------------------------------------------------------------------
+INSERT INTO t1 VALUES (5, 5, 5);
+ALTER TABLE t1 ALTER CHECK t1_chk_1 NOT ENFORCED, ALGORITHM=INPLACE;
+INSERT INTO t1 VALUES (8, 8, 8);
+ALTER TABLE t1 ALTER CHECK t1_chk_1 ENFORCED, ALGORITHM=INPLACE;
+ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
+ALTER TABLE t1 ALTER CHECK t1_chk_1 ENFORCED, ALGORITHM=COPY;
+ALTER TABLE t1 ALTER CHECK t1_chk_1 ENFORCED, ALGORITHM=INPLACE;
+INSERT INTO t1 VALUES (12, 5, 5);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+ALTER TABLE t1 ALTER CHECK t1_chk_1 NOT ENFORCED, ALGORITHM=INPLACE;
+INSERT INTO t1 VALUES (12, 5, 5);
+ALTER TABLE t1 ALTER CHECK t1_chk_1 ENFORCED, ALGORITHM=COPY;
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+DROP TABLE t1, t3;
+#-----------------------------------------------------------------------
+# Test case to add check constraint with copy,instant,inplace algorithm
+#-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT);
+ALTER TABLE t1 ADD CONSTRAINT CHECK (C1 > 10), ALGORITHM=COPY;
+ALTER TABLE t1 ADD CONSTRAINT CHECK (C1 > 10), ALGORITHM=INPLACE;
+ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
+ALTER TABLE t1 ADD CONSTRAINT CHECK (C1 > 10), ALGORITHM=INSTANT;
+ERROR 0A000: ALGORITHM=INSTANT is not supported for this operation. Try ALGORITHM=COPY.
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`C1` > 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify drop check constraint with inplace algorithm.
+#-----------------------------------------------------------------------
+CREATE TABLE t1 (f1 INT CHECK (f1 < 10));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+ALTER TABLE t1 DROP CHECK t1_chk_1, ALGORITHM=INPLACE;
+ALTER TABLE t1 ADD CONSTRAINT t1_chk_1 CHECK (f1 < 10), DROP CHECK t1_chk_1, ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to alter table to add/drop column with the check constraint.
+#-----------------------------------------------------------------------
+CREATE TABLE t1 (c1 INT, CONSTRAINT ck1 CHECK (c1 > 10));
+ALTER TABLE t1 ADD COLUMN c2 INT,
+ADD CONSTRAINT ck2 CHECK (c2 > 10);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL,
+ CONSTRAINT `ck1` CHECK ((`c1` > 10)),
+ CONSTRAINT `ck2` CHECK ((`c2` > 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+INSERT INTO t1 VALUES(20,10);
+ERROR HY000: Check constraint 'ck2' is violated.
+ALTER TABLE t1 DROP CHECK ck2, DROP COLUMN c2;
+ALTER TABLE t1 ADD COLUMN c3 INT,
+ADD CONSTRAINT ck3 CHECK (c3 < 10);
+ALTER TABLE t1 DROP CHECK ck3, DROP COLUMN c3,
+ADD COLUMN c4 INT, ADD CONSTRAINT ck4 CHECK( c4 > 10);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) DEFAULT NULL,
+ `c4` int(11) DEFAULT NULL,
+ CONSTRAINT `ck1` CHECK ((`c1` > 10)),
+ CONSTRAINT `ck4` CHECK ((`c4` > 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify
+# - Creation of check constraint with NOT ENFORCED state.
+# - Listing state of the check constraints with SHOW and
+# INFORMATION_SCHEMA.CHECK_CONSTRAINTS table.
+# - State updates with ALTER TABLE statement to ALTER
+# check constraints.
+#-----------------------------------------------------------------------
+CREATE TABLE t1(f1 INT,
+f2 INT CHECK (f2 < 10),
+f3 INT CHECK (f3 < 10) NOT ENFORCED,
+CONSTRAINT ck CHECK (f1 > 10),
+CONSTRAINT CHECK (f1 > 10) NOT ENFORCED);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ `f3` int(11) DEFAULT NULL,
+ CONSTRAINT `ck` CHECK ((`f1` > 10)),
+ CONSTRAINT `t1_chk_1` CHECK ((`f2` < 10)),
+ CONSTRAINT `t1_chk_2` CHECK ((`f3` < 10)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t1_chk_3` CHECK ((`f1` > 10)) /*!80015 NOT ENFORCED */
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME CHECK_CLAUSE
+def test t1_chk_1 (`f2` < 10)
+def test t1_chk_2 (`f3` < 10)
+def test ck (`f1` > 10)
+def test t1_chk_3 (`f1` > 10)
+# REVOKE check constraint ck.
+ALTER TABLE t1 ALTER CHECK ck NOT ENFORCED;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ `f3` int(11) DEFAULT NULL,
+ CONSTRAINT `ck` CHECK ((`f1` > 10)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t1_chk_1` CHECK ((`f2` < 10)),
+ CONSTRAINT `t1_chk_2` CHECK ((`f3` < 10)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t1_chk_3` CHECK ((`f1` > 10)) /*!80015 NOT ENFORCED */
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME CHECK_CLAUSE
+def test ck (`f1` > 10)
+def test t1_chk_1 (`f2` < 10)
+def test t1_chk_2 (`f3` < 10)
+def test t1_chk_3 (`f1` > 10)
+# ENFORCE check constraint ck.
+ALTER TABLE t1 ALTER CHECK ck ENFORCED;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ `f3` int(11) DEFAULT NULL,
+ CONSTRAINT `ck` CHECK ((`f1` > 10)),
+ CONSTRAINT `t1_chk_1` CHECK ((`f2` < 10)),
+ CONSTRAINT `t1_chk_2` CHECK ((`f3` < 10)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t1_chk_3` CHECK ((`f1` > 10)) /*!80015 NOT ENFORCED */
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME CHECK_CLAUSE
+def test ck (`f1` > 10)
+def test t1_chk_1 (`f2` < 10)
+def test t1_chk_2 (`f3` < 10)
+def test t1_chk_3 (`f1` > 10)
+# Add new constraint in NOT ENFORCED state.
+ALTER TABLE t1 ADD CONSTRAINT ck1 CHECK(f1<10) NOT ENFORCED;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ `f3` int(11) DEFAULT NULL,
+ CONSTRAINT `ck` CHECK ((`f1` > 10)),
+ CONSTRAINT `ck1` CHECK ((`f1` < 10)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t1_chk_1` CHECK ((`f2` < 10)),
+ CONSTRAINT `t1_chk_2` CHECK ((`f3` < 10)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t1_chk_3` CHECK ((`f1` > 10)) /*!80015 NOT ENFORCED */
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME CHECK_CLAUSE
+def test ck (`f1` > 10)
+def test t1_chk_1 (`f2` < 10)
+def test t1_chk_2 (`f3` < 10)
+def test t1_chk_3 (`f1` > 10)
+def test ck1 (`f1` < 10)
+# ENFORCE check constraint ck1
+ALTER TABLE t1 ALTER CHECK ck1 ENFORCED;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ `f3` int(11) DEFAULT NULL,
+ CONSTRAINT `ck` CHECK ((`f1` > 10)),
+ CONSTRAINT `ck1` CHECK ((`f1` < 10)),
+ CONSTRAINT `t1_chk_1` CHECK ((`f2` < 10)),
+ CONSTRAINT `t1_chk_2` CHECK ((`f3` < 10)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t1_chk_3` CHECK ((`f1` > 10)) /*!80015 NOT ENFORCED */
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME CHECK_CLAUSE
+def test ck (`f1` > 10)
+def test ck1 (`f1` < 10)
+def test t1_chk_1 (`f2` < 10)
+def test t1_chk_2 (`f3` < 10)
+def test t1_chk_3 (`f1` > 10)
+# ENFORCE check constraint t1_chk_2
+ALTER TABLE t1 ALTER CHECK t1_chk_2 ENFORCED;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ `f3` int(11) DEFAULT NULL,
+ CONSTRAINT `ck` CHECK ((`f1` > 10)),
+ CONSTRAINT `ck1` CHECK ((`f1` < 10)),
+ CONSTRAINT `t1_chk_1` CHECK ((`f2` < 10)),
+ CONSTRAINT `t1_chk_2` CHECK ((`f3` < 10)),
+ CONSTRAINT `t1_chk_3` CHECK ((`f1` > 10)) /*!80015 NOT ENFORCED */
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME CHECK_CLAUSE
+def test ck (`f1` > 10)
+def test ck1 (`f1` < 10)
+def test t1_chk_1 (`f2` < 10)
+def test t1_chk_2 (`f3` < 10)
+def test t1_chk_3 (`f1` > 10)
+# ADD column check constraint in NOT ENFORCED state.
+ALTER TABLE t1 ADD f4 INT CONSTRAINT t1_f4_chk CHECK (f4 < 10) NOT ENFORCED;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ `f3` int(11) DEFAULT NULL,
+ `f4` int(11) DEFAULT NULL,
+ CONSTRAINT `ck` CHECK ((`f1` > 10)),
+ CONSTRAINT `ck1` CHECK ((`f1` < 10)),
+ CONSTRAINT `t1_chk_1` CHECK ((`f2` < 10)),
+ CONSTRAINT `t1_chk_2` CHECK ((`f3` < 10)),
+ CONSTRAINT `t1_chk_3` CHECK ((`f1` > 10)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t1_f4_chk` CHECK ((`f4` < 10)) /*!80015 NOT ENFORCED */
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME CHECK_CLAUSE
+def test ck (`f1` > 10)
+def test ck1 (`f1` < 10)
+def test t1_chk_1 (`f2` < 10)
+def test t1_chk_2 (`f3` < 10)
+def test t1_chk_3 (`f1` > 10)
+def test t1_f4_chk (`f4` < 10)
+# ENFORCE check constraint t1_f4_chk
+ALTER TABLE t1 ALTER CHECK t1_f4_chk ENFORCED;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ `f3` int(11) DEFAULT NULL,
+ `f4` int(11) DEFAULT NULL,
+ CONSTRAINT `ck` CHECK ((`f1` > 10)),
+ CONSTRAINT `ck1` CHECK ((`f1` < 10)),
+ CONSTRAINT `t1_chk_1` CHECK ((`f2` < 10)),
+ CONSTRAINT `t1_chk_2` CHECK ((`f3` < 10)),
+ CONSTRAINT `t1_chk_3` CHECK ((`f1` > 10)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t1_f4_chk` CHECK ((`f4` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME CHECK_CLAUSE
+def test ck (`f1` > 10)
+def test ck1 (`f1` < 10)
+def test t1_chk_1 (`f2` < 10)
+def test t1_chk_2 (`f3` < 10)
+def test t1_chk_3 (`f1` > 10)
+def test t1_f4_chk (`f4` < 10)
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify alter statement with drop and alter constraint
+# on non-existing check constraint.
+#-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, c2 INT, c3 INT, c4 INT);
+ALTER TABLE t1 DROP CHECK ck13;
+ERROR HY000: Check constraint 'ck13' is not found in the table.
+ALTER TABLE t1 ALTER CHECK ck13 ENFORCED;
+ERROR HY000: Check constraint 'ck13' is not found in the table.
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify alter statement with multiple add, drop, enforce,
+# revoke check constraints.
+#-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, c2 INT, c3 INT, c4 INT);
+ALTER TABLE t1 ADD CONSTRAINT ck11 CHECK(c1 > 1),
+ADD CONSTRAINT ck12 CHECK(c1 < 1),
+ADD CONSTRAINT ck21 CHECK(c2 > 1),
+ADD CONSTRAINT ck22 CHECK(c2 < 1),
+ADD CONSTRAINT ck31 CHECK(c3 > 1),
+ADD CONSTRAINT ck32 CHECK(c3 < 1),
+ADD CONSTRAINT ck41 CHECK(c4 > 1),
+ADD CONSTRAINT ck42 CHECK(c4 < 1);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL,
+ `c3` int(11) DEFAULT NULL,
+ `c4` int(11) DEFAULT NULL,
+ CONSTRAINT `ck11` CHECK ((`c1` > 1)),
+ CONSTRAINT `ck12` CHECK ((`c1` < 1)),
+ CONSTRAINT `ck21` CHECK ((`c2` > 1)),
+ CONSTRAINT `ck22` CHECK ((`c2` < 1)),
+ CONSTRAINT `ck31` CHECK ((`c3` > 1)),
+ CONSTRAINT `ck32` CHECK ((`c3` < 1)),
+ CONSTRAINT `ck41` CHECK ((`c4` > 1)),
+ CONSTRAINT `ck42` CHECK ((`c4` < 1))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+ALTER TABLE t1
+DROP CHECK ck11, ADD CONSTRAINT ck11 CHECK (c1 > 10),
+DROP CHECK ck12, ADD CONSTRAINT ck12 CHECK (c1 < 10),
+DROP CHECK ck21, ADD CONSTRAINT ck21 CHECK (c1 > 10),
+DROP CHECK ck22, ADD CONSTRAINT ck22 CHECK (c1 < 10),
+DROP CHECK ck31, ADD CONSTRAINT ck31 CHECK (c1 > 10),
+DROP CHECK ck32, ADD CONSTRAINT ck32 CHECK (c1 < 10),
+DROP CHECK ck41, ADD CONSTRAINT ck41 CHECK (c1 > 10),
+DROP CHECK ck42, ADD CONSTRAINT ck42 CHECK (c1 < 10),
+ALTER CHECK ck11 NOT ENFORCED,
+ALTER CHECK ck12 NOT ENFORCED,
+ALTER CHECK ck21 NOT ENFORCED,
+ALTER CHECK ck22 NOT ENFORCED,
+ALTER CHECK ck11 ENFORCED;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL,
+ `c3` int(11) DEFAULT NULL,
+ `c4` int(11) DEFAULT NULL,
+ CONSTRAINT `ck11` CHECK ((`c1` > 10)),
+ CONSTRAINT `ck12` CHECK ((`c1` < 10)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `ck21` CHECK ((`c1` > 10)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `ck22` CHECK ((`c1` < 10)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `ck31` CHECK ((`c1` > 10)),
+ CONSTRAINT `ck32` CHECK ((`c1` < 10)),
+ CONSTRAINT `ck41` CHECK ((`c1` > 10)),
+ CONSTRAINT `ck42` CHECK ((`c1` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify auto-drop of check constraint on column drop.
+#-----------------------------------------------------------------------
+CREATE TABLE t1 (f1 INT check (f1 < 10), f2 INT);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+# Drops check constraint t1_chk_1 too.
+ALTER TABLE t1 DROP COLUMN f1;
+ALTER TABLE t1 ADD COLUMN f1 INT check(f1 < 10),
+ADD CONSTRAINT check(f1 + f2 < 10),
+ADD CONSTRAINT check(f2 < 10);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f2` int(11) DEFAULT NULL,
+ `f1` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` < 10)),
+ CONSTRAINT `t1_chk_2` CHECK (((`f1` + `f2`) < 10)),
+ CONSTRAINT `t1_chk_3` CHECK ((`f2` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+ALTER TABLE t1 DROP COLUMN f1;
+ERROR 42S22: Unknown column 'f1' in 'check constraint t1_chk_2 expression'
+ALTER TABLE t1 RENAME COLUMN f1 to f3;
+ERROR 42S22: Unknown column 'f1' in 'check constraint t1_chk_1 expression'
+# Drops column f1 and constraints t1_chk_1, t1_chk_2.
+ALTER TABLE t1 DROP CHECK t1_chk_2, DROP COLUMN f1;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_3` CHECK ((`f2` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint with MODIFY COLUMN syntax.
+#-----------------------------------------------------------------------
+CREATE TABLE t1(c1 CHAR(1), CHECK (c1 > 'A'));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` char(1) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`c1` > _utf8mb4'A'))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+INSERT INTO t1 VALUES('A');
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO t1 VALUES('B');
+DELETE FROM t1;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` char(1) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`c1` > _utf8mb4'A'))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+ALTER TABLE t1 MODIFY COLUMN c1 FLOAT(10.3), DROP CHECK t1_chk_1, ADD CONSTRAINT CHECK(C1 > 10.1) ENFORCED;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` float DEFAULT NULL,
+ CONSTRAINT `t1_chk_2` CHECK ((`C1` > 10.1))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t1;
+CREATE TABLE t1 (f1 INT CHECK (f1 = default(f1)));
+INSERT INTO t1 VALUES (10);
+ALTER TABLE t1 MODIFY COLUMN f1 INT DEFAULT 20, algorithm=inplace;
+ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
+ALTER TABLE t1 ALTER f1 SET DEFAULT 20, algorithm=inplace;
+ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
+ALTER TABLE t1 MODIFY COLUMN f1 INT DEFAULT 20, algorithm=copy;
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint with CHANGE COLUMN syntax.
+#-----------------------------------------------------------------------
+CREATE TABLE t1(c1 CHAR(1), CHECK (c1 > 'A'));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` char(1) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`c1` > _utf8mb4'A'))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+ALTER TABLE t1 CHANGE c1 c1 FLOAT, ALGORITHM=INPLACE;
+ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
+ALTER TABLE t1 DROP CHECK t1_chk_1, CHANGE c1 c2 VARCHAR(20), ADD CONSTRAINT CHECK(c2 > 'B');
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c2` varchar(20) DEFAULT NULL,
+ CONSTRAINT `t1_chk_2` CHECK ((`c2` > _utf8mb4'B'))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t1;
+CREATE TABLE t (a INT, b INT, CHECK(a != b));
+INSERT INTO t VALUES (2000000000, 2000000001);
+ALTER TABLE t CHANGE a a FLOAT, CHANGE b b FLOAT;
+ERROR HY000: Check constraint 't_chk_1' is violated.
+ALTER TABLE t ADD CONSTRAINT CHECK(a > b);
+ERROR HY000: Check constraint 't_chk_2' is violated.
+DROP TABLE t;
+#------------------------------------------------------------------------
+# Test case to verify check constraints with IN operator.
+#------------------------------------------------------------------------
+CREATE TABLE t1(f1 int CHECK (f1 IN (10, 20, 30)), f2 int, CHECK(f2 IN (100, 120, 450)));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` in (10,20,30))),
+ CONSTRAINT `t1_chk_2` CHECK ((`f2` in (100,120,450)))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+INSERT INTO t1 VALUES(10, 100);
+INSERT INTO t1 VALUES(15, 100);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO t1 VALUES(10, 105);
+ERROR HY000: Check constraint 't1_chk_2' is violated.
+DROP TABLE t1;
+#------------------------------------------------------------------------
+# Test case to verify check constraints with BETWEEN operator.
+#------------------------------------------------------------------------
+CREATE TABLE t1(f1 int CHECK(f1 BETWEEN 10 AND 30),
+f2 int, CHECK(f2 BETWEEN 100 AND 450));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` between 10 and 30)),
+ CONSTRAINT `t1_chk_2` CHECK ((`f2` between 100 and 450))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+INSERT INTO t1 VALUES(20, 200);
+INSERT INTO t1 VALUES(2, 200);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO t1 VALUES(20, 2000);
+ERROR HY000: Check constraint 't1_chk_2' is violated.
+DROP TABLE t1;
+#------------------------------------------------------------------------
+# Test case to verify check constraints with IS NOT NULL.
+#------------------------------------------------------------------------
+CREATE TABLE t1 (f1 int CHECK(f1 IS NOT NULL));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` is not null))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+INSERT INTO t1 VALUES(10);
+INSERT INTO t1 VALUES(NULL);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+DROP TABLE t1;
+#------------------------------------------------------------------------
+# Test case to verify check constraints with IS NULL.
+#------------------------------------------------------------------------
+CREATE TABLE t1 (f1 int CHECK(f1 IS NULL));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK (isnull(`f1`))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+INSERT INTO t1 VALUES(NULL);
+INSERT INTO t1 VALUES(10);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint with CASE Statement
+#-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, c2 INT);
+ALTER TABLE t1 ADD CONSTRAINT CHECK( (CASE WHEN c1 > 10 THEN c2 = 20 END) = 1);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK (((case when (`c1` > 10) then (`c2` = 20) end) = 1))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+INSERT INTO t1 VALUES(1,1);
+INSERT INTO t1 VALUES(15,1);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO t1 VALUES(15,20);
+SELECT * FROM t1;
+c1 c2
+1 1
+15 20
+DROP TABLE t1;
+#------------------------------------------------------------------------
+# Test case to verify check constraints restrictions.
+#------------------------------------------------------------------------
+# Check constraint using column with AUTO_INCREMENT attribute.
+CREATE TABLE t1 (f1 int primary key auto_increment, f2 int, CHECK (f1 != f2));
+ERROR HY000: Check constraint 't1_chk_1' cannot refer to an auto-increment column.
+CREATE TABLE t1 (f1 int primary key auto_increment CHECK (f1 < 10), f2 int, CHECK (f1 != f2));
+ERROR HY000: Check constraint 't1_chk_1' cannot refer to an auto-increment column.
+# Check constraint using non-deterministic builtin functions.
+# NOW()
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + NOW() > '2011-11-21'));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: now.
+# CURRENT_TIMESTAMP()
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + CURRENT_TIMESTAMP() > '2011-11-21 01:02:03'));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: now.
+# CURRENT_TIMESTAMP
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + CURRENT_TIMESTAMP > '2011-11-21 01:02:03'));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: now.
+# CURDATE()
+CREATE TABLE t1 (f1 DATETIME CHECK (f1 + CURDATE() > '2011-11-21'));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: curdate.
+# CURTIME()
+CREATE TABLE t1 (f1 DATETIME CHECK (f1 + CURTIME() > '23:11:21'));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: curtime.
+# CURTIME
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + CURRENT_TIME > '01:02:03'));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: curtime.
+# CURRENT_DATE()
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + CURRENT_DATE() > '2011-11-21'));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: curdate.
+# CURRENT_DATE
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + CURRENT_DATE > '2011-11-21'));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: curdate.
+# CURRENT_TIME()
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + CURRENT_TIME() > '01:02:03'));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: curtime.
+# CURRENT_TIME
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + CURRENT_TIME > '01:02:03'));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: curtime.
+# LOCALTIME()
+CREATE TABLE t1 (f1 DATETIME CHECK (f1 + LOCALTIME() > '23:11:21'));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: now.
+# LOCALTIME
+CREATE TABLE t1 (f1 DATETIME CHECK (f1 + LOCALTIME > '23:11:21'));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: now.
+# LOCALTIMESTAMP()
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + LOCALTIMESTAMP() > '2011-11-21 01:02:03'));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: now.
+# LOCALTIMESTAMP
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + LOCALTIMESTAMP > '2011-11-21 01:02:03'));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: now.
+# UNIX_TIMESTAMP()
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + UNIX_TIMESTAMP() > '2011-11-21 01:02:03'));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: unix_timestamp.
+# UNIX_DATE()
+CREATE TABLE t1 (f1 DATETIME CHECK (f1 + UTC_DATE() > '2011-11-21'));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: utc_date.
+# UNIX_TIMESTAMP()
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + UTC_TIMESTAMP() > '2011-11-21 01:02:03'));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: utc_timestamp.
+# UNIX_TIME()
+CREATE TABLE t1 (f1 DATETIME CHECK (f1 + UTC_TIME() > '23:11:21'));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: utc_time.
+# CONNECTION_ID
+CREATE TABLE t1 (f1 INT CHECK (f1 + CONNECTION_ID() < 929));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: connection_id.
+# CURRENT_USER()
+CREATE TABLE t1 (a VARCHAR(32) CHECK (CURRENT_USER() != a));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: current_user.
+# CURRENT_USER
+CREATE TABLE t1 (a VARCHAR(32) CHECK (CURRENT_USER != a));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: current_user.
+# SESSION_USER()
+CREATE TABLE t1 (a VARCHAR(32) CHECK (SESSION_USER() != a));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: user.
+# VERSION()
+CREATE TABLE t1 (a VARCHAR(32) CHECK (VERSION() != a));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: version().
+# FOUND_ROWS
+CREATE TABLE t1 (a VARCHAR(1024), b INT CHECK (b + FOUND_ROWS() > 2000));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: found_rows.
+# LAST_INSERT_ID
+CREATE TABLE t1 (a INT CHECK ((a + LAST_INSERT_ID()) < 929));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: last_insert_id.
+# SYSTEM_USER
+CREATE TABLE t1 (a VARCHAR(32) CHECK (SYSTEM_USER() != a));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: user.
+# USER
+CREATE TABLE t1 (a VARCHAR(32) CHECK (USER() != a));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: user.
+# RAND()
+CREATE TABLE t1 (f1 FLOAT CHECK (f1 + RAND() < 929.929));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: rand.
+# ROW_COUNT()
+CREATE TABLE t1 (a INT CHECK (a + ROW_COUNT() > 1000));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: row_count.
+# GET_LOCK()
+CREATE TABLE t1 (a VARCHAR(1024), b VARCHAR(1024) CHECK (GET_LOCK(b,10) != 0));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: get_lock.
+# IS_FREE_LOCK()
+CREATE TABLE t1 (a VARCHAR(1024), b VARCHAR(1024) CHECK (IS_FREE_LOCK(b) != 0));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: is_free_lock.
+# IS_USED_LOCK()
+CREATE TABLE t1 (a VARCHAR(1024), b VARCHAR(1024) CHECK (IS_USED_LOCK(b) != 0));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: is_used_lock.
+# RELEASE_LOCK()
+CREATE TABLE t1 (a VARCHAR(1024), b VARCHAR(1024) CHECK (RELEASE_LOCK(b) != 0));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: release_lock.
+# RELEASE_ALL_LOCK()
+CREATE TABLE t1 (a VARCHAR(1024), b VARCHAR(1024), CHECK (RELEASE_ALL_LOCKS() != 0));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: release_all_locks.
+# LOAD_FILE
+CREATE TABLE t1 (f1 VARCHAR(1024), f2 VARCHAR(1024) CHECK (LOAD_FILE(f2) != NULL));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: load_file.
+# UUID()
+CREATE TABLE t1 (id CHAR(40) CHECK(UUID() != id));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: uuid.
+# UUID_SHORT
+CREATE TABLE t1 (id INT CHECK(UUID_SHORT() != id));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: uuid_short.
+# SLEEP
+CREATE TABLE t1 (id INT CHECK(SLEEP(id) != 0));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: sleep.
+# Stored function
+CREATE FUNCTION func() RETURNS INT DETERMINISTIC return 1;
+CREATE TABLE t1 (id INT CHECK(id = func()));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: `func`.
+DROP FUNCTION func;
+# Stored procedure
+CREATE PROCEDURE proc() SELECT 1;
+CREATE TABLE t1 (id INT CHECK(id = proc()));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function: `proc`.
+DROP PROCEDURE proc;
+# User variable
+SET @v = 10;
+CREATE TABLE t1 (id INT CHECK (id != @v));
+ERROR HY000: An expression of a check constraint 't1_chk_1' cannot refer to a user or system variables.
+# System variables.
+CREATE TABLE t1 (id INT CHECK (id != @@global.max_execution_time));
+ERROR HY000: An expression of a check constraint 't1_chk_1' cannot refer to a user or system variables.
+CREATE TABLE t1 (id INt CHECK (id != @@session.max_execution_time));
+ERROR HY000: An expression of a check constraint 't1_chk_1' cannot refer to a user or system variables.
+# Subquery
+CREATE TABLE t1 (id INT CHECK (id != (SELECT 1)));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function.
+# Parameter
+PREPARE stmt FROM 'CREATE TABLE t1 (id INT CHECK(id != ?))';
+EXECUTE stmt using @v;
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function.
+DEALLOCATE PREPARE stmt;
+#------------------------------------------------------------------------
+# Test case to verify check constraints with numeric data types.
+#------------------------------------------------------------------------
+CREATE TABLE t1 (
+c1 BIT(7) CHECK(c1 < B'1111100'),
+c2 BOOLEAN CHECK(c2 > 0),
+c3 TINYINT CHECK(c3 > 10),
+c4 SMALLINT CHECK(c4 > 10),
+c5 MEDIUMINT CHECK(c5 > 10),
+c6 INT CHECK(c6 > 10),
+c7 BIGINT CHECK(c7 > 10),
+c8 DECIMAL(6,2) CHECK(c8 > 10.1),
+c9 FLOAT(6,2) CHECK(c9 > 10.1),
+c10 DOUBLE(6,2) CHECK(c10 > 10.1));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` bit(7) DEFAULT NULL,
+ `c2` tinyint(1) DEFAULT NULL,
+ `c3` tinyint(4) DEFAULT NULL,
+ `c4` smallint(6) DEFAULT NULL,
+ `c5` mediumint(9) DEFAULT NULL,
+ `c6` int(11) DEFAULT NULL,
+ `c7` bigint(20) DEFAULT NULL,
+ `c8` decimal(6,2) DEFAULT NULL,
+ `c9` float(6,2) DEFAULT NULL,
+ `c10` double(6,2) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`c1` < 0x7c)),
+ CONSTRAINT `t1_chk_10` CHECK ((`c10` > 10.1)),
+ CONSTRAINT `t1_chk_2` CHECK ((`c2` > 0)),
+ CONSTRAINT `t1_chk_3` CHECK ((`c3` > 10)),
+ CONSTRAINT `t1_chk_4` CHECK ((`c4` > 10)),
+ CONSTRAINT `t1_chk_5` CHECK ((`c5` > 10)),
+ CONSTRAINT `t1_chk_6` CHECK ((`c6` > 10)),
+ CONSTRAINT `t1_chk_7` CHECK ((`c7` > 10)),
+ CONSTRAINT `t1_chk_8` CHECK ((`c8` > 10.1)),
+ CONSTRAINT `t1_chk_9` CHECK ((`c9` > 10.1))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+INSERT INTO t1(c1) VALUES(B'1111110');
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO t1(c2) VALUES(0);
+ERROR HY000: Check constraint 't1_chk_2' is violated.
+INSERT INTO t1(c3) VALUES(1);
+ERROR HY000: Check constraint 't1_chk_3' is violated.
+INSERT INTO t1(c4) VALUES(1);
+ERROR HY000: Check constraint 't1_chk_4' is violated.
+INSERT INTO t1(c5) VALUES(1);
+ERROR HY000: Check constraint 't1_chk_5' is violated.
+INSERT INTO t1(c6) VALUES(1);
+ERROR HY000: Check constraint 't1_chk_6' is violated.
+INSERT INTO t1(c7) VALUES(1);
+ERROR HY000: Check constraint 't1_chk_7' is violated.
+INSERT INTO t1(c8) VALUES(10.0);
+ERROR HY000: Check constraint 't1_chk_8' is violated.
+INSERT INTO t1(c9) VALUES(10.0);
+ERROR HY000: Check constraint 't1_chk_9' is violated.
+INSERT INTO t1(c10) VALUES(10.0);
+ERROR HY000: Check constraint 't1_chk_10' is violated.
+INSERT INTO t1(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10)
+VALUES(B'1111000',1,11,11,11,11,11,10.2,10.2,10.2);
+DROP TABLE t1;
+#------------------------------------------------------------------------
+# Test case to verify check constraints with string data types.
+#------------------------------------------------------------------------
+CREATE TABLE t1(c1 CHAR(1) CHECK(c1 > 'a'),
+c2 VARCHAR(1) CHECK(c2 > 'a'),
+c3 BINARY(1) CHECK(c3 > 'a'),
+c4 VARBINARY(1) CHECK(c4 > 'a'),
+c5 TINYBLOB CHECK(c5 > 'a'),
+c6 TINYTEXT CHECK(c6 > 'a'),
+c7 BLOB CHECK(c7 > 'a'),
+c8 TEXT CHECK(c8 > 'a'),
+c9 MEDIUMBLOB CHECK(c9 > 'a'),
+c10 MEDIUMTEXT CHECK(c10 > 'a'),
+c11 LONGBLOB CHECK(c11 > 'a'),
+c12 LONGTEXT CHECK(c12 > 'a'));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` char(1) DEFAULT NULL,
+ `c2` varchar(1) DEFAULT NULL,
+ `c3` binary(1) DEFAULT NULL,
+ `c4` varbinary(1) DEFAULT NULL,
+ `c5` tinyblob,
+ `c6` tinytext,
+ `c7` blob,
+ `c8` text,
+ `c9` mediumblob,
+ `c10` mediumtext,
+ `c11` longblob,
+ `c12` longtext,
+ CONSTRAINT `t1_chk_1` CHECK ((`c1` > _utf8mb4'a')),
+ CONSTRAINT `t1_chk_10` CHECK ((`c10` > _utf8mb4'a')),
+ CONSTRAINT `t1_chk_11` CHECK ((`c11` > _utf8mb4'a')),
+ CONSTRAINT `t1_chk_12` CHECK ((`c12` > _utf8mb4'a')),
+ CONSTRAINT `t1_chk_2` CHECK ((`c2` > _utf8mb4'a')),
+ CONSTRAINT `t1_chk_3` CHECK ((`c3` > _utf8mb4'a')),
+ CONSTRAINT `t1_chk_4` CHECK ((`c4` > _utf8mb4'a')),
+ CONSTRAINT `t1_chk_5` CHECK ((`c5` > _utf8mb4'a')),
+ CONSTRAINT `t1_chk_6` CHECK ((`c6` > _utf8mb4'a')),
+ CONSTRAINT `t1_chk_7` CHECK ((`c7` > _utf8mb4'a')),
+ CONSTRAINT `t1_chk_8` CHECK ((`c8` > _utf8mb4'a')),
+ CONSTRAINT `t1_chk_9` CHECK ((`c9` > _utf8mb4'a'))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+INSERT INTO t1(c1) VALUES('a');
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO t1(c2) VALUES('a');
+ERROR HY000: Check constraint 't1_chk_2' is violated.
+INSERT INTO t1(c3) VALUES('a');
+ERROR HY000: Check constraint 't1_chk_3' is violated.
+INSERT INTO t1(c4) VALUES('a');
+ERROR HY000: Check constraint 't1_chk_4' is violated.
+INSERT INTO t1(c5) VALUES('a');
+ERROR HY000: Check constraint 't1_chk_5' is violated.
+INSERT INTO t1(c6) VALUES('a');
+ERROR HY000: Check constraint 't1_chk_6' is violated.
+INSERT INTO t1(c7) VALUES('a');
+ERROR HY000: Check constraint 't1_chk_7' is violated.
+INSERT INTO t1(c8) VALUES('a');
+ERROR HY000: Check constraint 't1_chk_8' is violated.
+INSERT INTO t1(c9) VALUES('a');
+ERROR HY000: Check constraint 't1_chk_9' is violated.
+INSERT INTO t1(c10) VALUES('a');
+ERROR HY000: Check constraint 't1_chk_10' is violated.
+INSERT INTO t1(c11) VALUES('a');
+ERROR HY000: Check constraint 't1_chk_11' is violated.
+INSERT INTO t1(c12) VALUES('a');
+ERROR HY000: Check constraint 't1_chk_12' is violated.
+INSERT INTO t1(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12)
+VALUES('b',"b","b","b","b","b","b","b","b","b","b","b");
+DROP TABLE t1;
+#------------------------------------------------------------------------
+# Test case to verify check constraints with date and time data types.
+#------------------------------------------------------------------------
+CREATE TABLE t1 (c1 DATE CHECK(c1 > '2007-01-01'),
+c2 DATETIME CHECK(c2 > '2007-01-01 12:00:01'),
+c3 TIMESTAMP CHECK(c3 > '2007-01-01 00:00:01.000000'),
+c4 TIME CHECK(c4 > '12:00:01.000000'),
+c5 YEAR CHECK(c5 > '2007'));
+INSERT INTO t1(c1) VALUES('2006-01-01');
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO t1(c2) VALUES('2007-01-01 11:00:01');
+ERROR HY000: Check constraint 't1_chk_2' is violated.
+INSERT INTO t1(c3) VALUES('2007-01-01 00:00:00.000000');
+ERROR HY000: Check constraint 't1_chk_3' is violated.
+INSERT INTO t1(c4) VALUES('12:00:00.000000');
+ERROR HY000: Check constraint 't1_chk_4' is violated.
+INSERT INTO t1(c5) VALUES('2006');
+ERROR HY000: Check constraint 't1_chk_5' is violated.
+INSERT INTO t1(c1,c2,c3,c4,c5)
+VALUES('2008-01-01','2007-01-01 12:00:02','2007-01-01 00:00:02.000000',
+'12:00:02.000000','2008');
+DROP TABLE t1;
+#------------------------------------------------------------------------
+# Test case to verify check constraints with JSON data type.
+#------------------------------------------------------------------------
+CREATE TABLE t1(
+id INT AUTO_INCREMENT PRIMARY KEY,
+name VARCHAR(255),
+browser JSON CHECK( browser->'$.name' = "Chrome" ));
+INSERT INTO t1(name,browser)
+VALUES('pageview','{ "name": "Safari", "os": "Mac" }');
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO t1(name,browser)
+VALUES('pageview','{ "name": "Chrome", "os": "Mac" }');
+SELECT * FROM t1;
+id name browser
+1 pageview {"os": "Mac", "name": "Chrome"}
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# check constraint with ENUM data type
+#-----------------------------------------------------------------------
+CREATE TABLE t1 (c1 ENUM ('a','b') CHECK (c1 IN ('c', 'd')) );
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` enum('a','b') DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`c1` in (_utf8mb4'c',_utf8mb4'd')))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+INSERT INTO t1 VALUES('a');
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO t1 VALUES('b');
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO t1 VALUES('c');
+ERROR 01000: Data truncated for column 'c1' at row 1
+INSERT INTO t1 VALUES('d');
+ERROR 01000: Data truncated for column 'c1' at row 1
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# check constraint with SET data type
+#-----------------------------------------------------------------------
+CREATE TABLE t1 (c1 SET ('a','b') CHECK (c1 IN ('c', 'd')) );
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` set('a','b') DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`c1` in (_utf8mb4'c',_utf8mb4'd')))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+INSERT INTO t1 VALUES('a');
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO t1 VALUES('b');
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO t1 VALUES('c');
+ERROR 01000: Data truncated for column 'c1' at row 1
+INSERT INTO t1 VALUES('d');
+ERROR 01000: Data truncated for column 'c1' at row 1
+DROP TABLE t1;
+#------------------------------------------------------------------------
+# Test case to verify check constraints with spatial data type.
+#------------------------------------------------------------------------
+CREATE TABLE t1(
+pt POINT CHECK(ST_Equals(pt, ST_GEOMFROMTEXT('POINT(10 20)')) = TRUE),
+lnstr LINESTRING CHECK(ST_Equals(lnstr, ST_GEOMFROMTEXT('LINESTRING(0 0,5 5,6 6)'))),
+mlnstr MULTILINESTRING CHECK(ST_Equals(mlnstr, ST_GEOMFROMTEXT('MULTILINESTRING((0 0,2 3,4 5),
+ (6 6,8 8,9 9,10 10))'))),
+poly POLYGON CHECK(ST_Equals(poly, ST_GEOMFROMTEXT('POLYGON((0 0,6 7,8 8,3 9,0 0),
+ (3 6,4 6,4 7,3 6))'))),
+mpoly MULTIPOLYGON CHECK(ST_Equals(mpoly, ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),
+ ((2 2,4 5,6 2,2 2)))'))));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `pt` point DEFAULT NULL,
+ `lnstr` linestring DEFAULT NULL,
+ `mlnstr` multilinestring DEFAULT NULL,
+ `poly` polygon DEFAULT NULL,
+ `mpoly` multipolygon DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((st_equals(`pt`,st_geomfromtext(_utf8mb4'POINT(10 20)')) = TRUE)),
+ CONSTRAINT `t1_chk_2` CHECK (st_equals(`lnstr`,st_geomfromtext(_utf8mb4'LINESTRING(0 0,5 5,6 6)'))),
+ CONSTRAINT `t1_chk_3` CHECK (st_equals(`mlnstr`,st_geomfromtext(_utf8mb4'MULTILINESTRING((0 0,2 3,4 5),\n (6 6,8 8,9 9,10 10))'))),
+ CONSTRAINT `t1_chk_4` CHECK (st_equals(`poly`,st_geomfromtext(_utf8mb4'POLYGON((0 0,6 7,8 8,3 9,0 0),\n (3 6,4 6,4 7,3 6))'))),
+ CONSTRAINT `t1_chk_5` CHECK (st_equals(`mpoly`,st_geomfromtext(_utf8mb4'MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),\n ((2 2,4 5,6 2,2 2)))')))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+INSERT INTO t1(pt) VALUES (ST_GEOMFROMTEXT('POINT(10 21)'));
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO t1(lnstr) VALUES (ST_GEOMFROMTEXT('LINESTRING(0 0,5 5,6 7)'));
+ERROR HY000: Check constraint 't1_chk_2' is violated.
+INSERT INTO t1(mlnstr) VALUES (ST_GEOMFROMTEXT('MULTILINESTRING((0 0,2 3,4 5),(6 6,8 8,9 9,10 11))'));
+ERROR HY000: Check constraint 't1_chk_3' is violated.
+INSERT INTO t1(poly) VALUES (ST_GEOMFROMTEXT('POLYGON((0 0,6 7,8 8,3 9,0 0),(3 6,4 6,4 8,3 6))'));
+ERROR HY000: Check constraint 't1_chk_4' is violated.
+INSERT INTO t1(mpoly) VALUES (ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((2 2,4 5,6 3,2 2)))'));
+ERROR HY000: Check constraint 't1_chk_5' is violated.
+INSERT INTO t1(pt) VALUES (ST_GEOMFROMTEXT('POINT(10 20)'));
+INSERT INTO t1(lnstr) VALUES (ST_GEOMFROMTEXT('LINESTRING(0 0,5 5,6 6)'));
+INSERT INTO t1(mlnstr) VALUES (ST_GEOMFROMTEXT('MULTILINESTRING((0 0,2 3,4 5),(6 6,8 8,9 9,10 10))'));
+INSERT INTO t1(poly) VALUES (ST_GEOMFROMTEXT('POLYGON((0 0,6 7,8 8,3 9,0 0),(3 6,4 6,4 7,3 6))'));
+INSERT INTO t1(mpoly) VALUES (ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((2 2,4 5,6 2,2 2)))'));
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint with REGEX
+#-----------------------------------------------------------------------
+CREATE TABLE student
+(
+id INT,
+stu_code VARCHAR(10),
+name VARCHAR(14),
+email VARCHAR(20),
+scholarship INT,
+country VARCHAR(20),
+CONSTRAINT ck1 CHECK (id != 0),
+CONSTRAINT ck2 CHECK (stu_code like 'j%'),
+CONSTRAINT ck3 CHECK (lower(name) != "noname"),
+CONSTRAINT ck4 CHECK (REGEXP_LIKE(email,'@')),
+CONSTRAINT ck5 CHECK (scholarship BETWEEN 5000 AND 20000),
+CONSTRAINT ck6 CHECK (country IN ('usa','uk'))
+);
+SHOW CREATE TABLE student;
+Table Create Table
+student CREATE TABLE `student` (
+ `id` int(11) DEFAULT NULL,
+ `stu_code` varchar(10) DEFAULT NULL,
+ `name` varchar(14) DEFAULT NULL,
+ `email` varchar(20) DEFAULT NULL,
+ `scholarship` int(11) DEFAULT NULL,
+ `country` varchar(20) DEFAULT NULL,
+ CONSTRAINT `ck1` CHECK ((`id` <> 0)),
+ CONSTRAINT `ck2` CHECK ((`stu_code` like _utf8mb4'j%')),
+ CONSTRAINT `ck3` CHECK ((lower(`name`) <> _utf8mb4'noname')),
+ CONSTRAINT `ck4` CHECK (regexp_like(`email`,_utf8mb4'@')),
+ CONSTRAINT `ck5` CHECK ((`scholarship` between 5000 and 20000)),
+ CONSTRAINT `ck6` CHECK ((`country` in (_utf8mb4'usa',_utf8mb4'uk')))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+INSERT INTO student VALUES(0,"j001","name1","name1@oracle.com",6000,'usa');
+ERROR HY000: Check constraint 'ck1' is violated.
+INSERT INTO student VALUES(1,"s001","name1","name1@oracle.com",6000,'usa');
+ERROR HY000: Check constraint 'ck2' is violated.
+INSERT INTO student VALUES(1,"j001","NONAME","name1@oracle.com",6000,'usa');
+ERROR HY000: Check constraint 'ck3' is violated.
+INSERT INTO student VALUES(1,"j001","name1","name1oracle.com",6000,'usa');
+ERROR HY000: Check constraint 'ck4' is violated.
+INSERT INTO student VALUES(1,"j001","name1","name1@oracle.com",4000,'usa');
+ERROR HY000: Check constraint 'ck5' is violated.
+INSERT INTO student VALUES(1,"j001","name1","name1@oracle.com",6000,'nocountry');
+ERROR HY000: Check constraint 'ck6' is violated.
+INSERT INTO student VALUES(1,"j001","name1","name1@oracle.com",6000,'usa');
+SELECT * FROM student;
+id stu_code name email scholarship country
+1 j001 name1 name1@oracle.com 6000 usa
+DROP TABLE student;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint with numeric comparator
+# operators with varchar columns.
+#-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, c2 VARCHAR(20));
+ALTER TABLE t1 ADD CONSTRAINT ck1 CHECK ( c1 > c2 );
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` varchar(20) DEFAULT NULL,
+ CONSTRAINT `ck1` CHECK ((`c1` > `c2`))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint with Comparison Functions
+# and Operators
+#-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, CHECK ( c1 IN ( SELECT COALESCE(NULL, 1, 1))));
+ERROR HY000: An expression of non-boolean type specified to a check constraint 't1_chk_1'.
+CREATE TABLE t1(c1 INT, CHECK ( c1 < ( SELECT COALESCE(NULL, 1, 1))));
+ERROR HY000: An expression of a check constraint 't1_chk_1' contains disallowed function.
+CREATE TABLE t1(c1 INT , CHECK ( c1 <=> NULL ));
+INSERT INTO t1 VALUES(1);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO t1 VALUES(NULL);
+SELECT * FROM t1;
+c1
+NULL
+ALTER TABLE t1 ADD COLUMN c2 INT, ADD CONSTRAINT CHECK( c2 > 10 );
+INSERT INTO t1(c2) VALUES(10);
+ERROR HY000: Check constraint 't1_chk_2' is violated.
+INSERT INTO t1(c2) VALUES(11);
+ALTER TABLE t1 ADD COLUMN c3 INT, ADD CONSTRAINT CHECK( c3 >= 10 );
+INSERT INTO t1(c3) VALUES(9);
+ERROR HY000: Check constraint 't1_chk_3' is violated.
+INSERT INTO t1(c3) VALUES(10);
+ALTER TABLE t1 ADD COLUMN c4 INT, ADD CONSTRAINT CHECK( c4 < 10 );
+INSERT INTO t1(c4) VALUES(10);
+ERROR HY000: Check constraint 't1_chk_4' is violated.
+INSERT INTO t1(c4) VALUES(9);
+ALTER TABLE t1 ADD COLUMN c5 INT, ADD CONSTRAINT CHECK( c5 <= 10 );
+INSERT INTO t1(c5) VALUES(11);
+ERROR HY000: Check constraint 't1_chk_5' is violated.
+INSERT INTO t1(c5) VALUES(10);
+ALTER TABLE t1 ADD COLUMN c6 INT, ADD CONSTRAINT CHECK( c6 != 10 );
+INSERT INTO t1(c6) VALUES(10);
+ERROR HY000: Check constraint 't1_chk_6' is violated.
+INSERT INTO t1(c6) VALUES(20);
+ALTER TABLE t1 ADD COLUMN c7 INT, ADD CONSTRAINT CHECK( c7 <> 10 );
+INSERT INTO t1(c7) VALUES(10);
+ERROR HY000: Check constraint 't1_chk_7' is violated.
+INSERT INTO t1(c7) VALUES(20);
+ALTER TABLE t1 ADD COLUMN c8 INT, ADD CONSTRAINT CHECK( c8 = GREATEST(1,2,3) );
+INSERT INTO t1(c8) VALUES(1);
+ERROR HY000: Check constraint 't1_chk_8' is violated.
+INSERT INTO t1(c8) VALUES(3);
+ALTER TABLE t1 ADD COLUMN c9 INT, ADD CONSTRAINT CHECK( c9 = LEAST(1,2,3) );
+INSERT INTO t1(c9) VALUES(3);
+ERROR HY000: Check constraint 't1_chk_9' is violated.
+INSERT INTO t1(c9) VALUES(1);
+ALTER TABLE t1 ADD COLUMN c10 INT, ADD CONSTRAINT CHECK( c10 NOT IN (1,2,3) );
+INSERT INTO t1(c10) VALUES(1);
+ERROR HY000: Check constraint 't1_chk_10' is violated.
+INSERT INTO t1(c10) VALUES(3);
+ERROR HY000: Check constraint 't1_chk_10' is violated.
+INSERT INTO t1(c10) VALUES(10);
+ALTER TABLE t1 ADD COLUMN c11 YEAR, ADD CONSTRAINT CHECK ( c11 > '2007-01-01' + INTERVAL +1 YEAR);
+INSERT INTO t1(c11) VALUES(2007);
+ERROR HY000: Check constraint 't1_chk_11' is violated.
+INSERT INTO t1(c11) VALUES(2008);
+ERROR HY000: Check constraint 't1_chk_11' is violated.
+INSERT INTO t1(c11) VALUES(2009);
+ALTER TABLE t1 ADD COLUMN c12 INT, ADD CONSTRAINT CHECK ( c12 NOT BETWEEN 10 AND 20);
+INSERT INTO t1(c12) VALUES(15);
+ERROR HY000: Check constraint 't1_chk_12' is violated.
+INSERT INTO t1(c12) VALUES(25);
+ALTER TABLE t1 ADD COLUMN c13 INT, ADD CONSTRAINT CHECK ( c13 NOT IN (1, 2, 3));
+INSERT INTO t1(c13) VALUES(1);
+ERROR HY000: Check constraint 't1_chk_13' is violated.
+INSERT INTO t1(c13) VALUES(15);
+ALTER TABLE t1 ADD COLUMN c14 CHAR(10), ADD CONSTRAINT CHECK ( c14 LIKE 'A%');
+INSERT INTO t1(c14) VALUES('Good');
+ERROR HY000: Check constraint 't1_chk_14' is violated.
+INSERT INTO t1(c14) VALUES('All');
+ALTER TABLE t1 ADD COLUMN c15 INT, ADD CONSTRAINT CHECK ( c15 = STRCMP('A','A'));
+INSERT INTO t1(c15) VALUES(1);
+ERROR HY000: Check constraint 't1_chk_15' is violated.
+INSERT INTO t1(c15) VALUES(0);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL,
+ `c3` int(11) DEFAULT NULL,
+ `c4` int(11) DEFAULT NULL,
+ `c5` int(11) DEFAULT NULL,
+ `c6` int(11) DEFAULT NULL,
+ `c7` int(11) DEFAULT NULL,
+ `c8` int(11) DEFAULT NULL,
+ `c9` int(11) DEFAULT NULL,
+ `c10` int(11) DEFAULT NULL,
+ `c11` year(4) DEFAULT NULL,
+ `c12` int(11) DEFAULT NULL,
+ `c13` int(11) DEFAULT NULL,
+ `c14` char(10) DEFAULT NULL,
+ `c15` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`c1` <=> NULL)),
+ CONSTRAINT `t1_chk_10` CHECK ((`c10` not in (1,2,3))),
+ CONSTRAINT `t1_chk_11` CHECK ((`c11` > 2008)),
+ CONSTRAINT `t1_chk_12` CHECK ((`c12` not between 10 and 20)),
+ CONSTRAINT `t1_chk_13` CHECK ((`c13` not in (1,2,3))),
+ CONSTRAINT `t1_chk_14` CHECK ((`c14` like _utf8mb4'A%')),
+ CONSTRAINT `t1_chk_15` CHECK ((`c15` = strcmp(_utf8mb4'A',_utf8mb4'A'))),
+ CONSTRAINT `t1_chk_2` CHECK ((`c2` > 10)),
+ CONSTRAINT `t1_chk_3` CHECK ((`c3` >= 10)),
+ CONSTRAINT `t1_chk_4` CHECK ((`c4` < 10)),
+ CONSTRAINT `t1_chk_5` CHECK ((`c5` <= 10)),
+ CONSTRAINT `t1_chk_6` CHECK ((`c6` <> 10)),
+ CONSTRAINT `t1_chk_7` CHECK ((`c7` <> 10)),
+ CONSTRAINT `t1_chk_8` CHECK ((`c8` = greatest(1,2,3))),
+ CONSTRAINT `t1_chk_9` CHECK ((`c9` = least(1,2,3)))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint with Logical Operators
+#-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, c2 INT);
+ALTER TABLE t1 ADD CONSTRAINT CHECK( (c1 > 10) AND (c2 < 20) );
+INSERT INTO t1 VALUES(1,10);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+ALTER TABLE t1 ADD CONSTRAINT CHECK( (c1 > 10) && (c2 < 20) );
+INSERT INTO t1 VALUES(15,25);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+ALTER TABLE t1 DROP CHECK `t1_chk_1`;
+ALTER TABLE t1 DROP CHECK `t1_chk_2`;
+ALTER TABLE t1 ADD CONSTRAINT CHECK( (c1 > 10) || (c2 < 20) );
+ALTER TABLE t1 ADD CONSTRAINT CHECK( (c1 > 10) OR (c2 < 20) );
+INSERT INTO t1 VALUES(15,25);
+INSERT INTO t1 VALUES(5,10);
+INSERT INTO t1 VALUES(5,25);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+ALTER TABLE t1 DROP CHECK `t1_chk_1`;
+ALTER TABLE t1 DROP CHECK `t1_chk_2`;
+DELETE FROM t1;
+ALTER TABLE t1 ADD CONSTRAINT CHECK( (c1 > 10) XOR (c2 < 20) );
+INSERT INTO t1 VALUES(15,10);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) DEFAULT NULL,
+ `c2` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK (((`c1` > 10) xor (`c2` < 20)))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint behaviour with DEFAULT, NULL
+# and with LOGICAL operators.
+#-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT DEFAULT 2 PRIMARY KEY CHECK(c1 > 1 OR c1 IS NOT NULL));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) NOT NULL DEFAULT '2',
+ PRIMARY KEY (`c1`),
+ CONSTRAINT `t1_chk_1` CHECK (((`c1` > 1) or (`c1` is not null)))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+INSERT INTO t1 VALUES(NULL);
+ERROR 23000: Column 'c1' cannot be null
+INSERT INTO t1 VALUES(1);
+SELECT * FROM t1;
+c1
+1
+DROP TABLE t1;
+CREATE TABLE t1(c1 INT DEFAULT 2 PRIMARY KEY CHECK(c1 > 1 OR c1 > 2));
+INSERT INTO t1 VALUES(1);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO t1 VALUES(2);
+SELECT * FROM t1;
+c1
+2
+DROP TABLE t1;
+CREATE TABLE t1(c1 INT DEFAULT 2 PRIMARY KEY CHECK(c1 > 1 AND c1 IS NOT NULL));
+INSERT INTO t1 VALUES(1);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint when table is moved to another DB
+#-----------------------------------------------------------------------
+CREATE DATABASE test1;
+CREATE DATABASE test2;
+USE test1;
+CREATE TABLE t1(c1 INT, c2 INT CHECK (c2 < 10));
+INSERT INTO t1 VALUES(1,1);
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME CHECK_CLAUSE
+def test1 t1_chk_1 (`c2` < 10)
+SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE TABLE_NAME='t1';
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
+def test1 t1_chk_1 test1 t1 CHECK YES
+ALTER TABLE test1.t1 rename test2.t1;
+USE test2;
+SELECT * FROM t1;
+c1 c2
+1 1
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME CHECK_CLAUSE
+def test2 t1_chk_1 (`c2` < 10)
+SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE TABLE_NAME='t1';
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
+def test2 t1_chk_1 test2 t1 CHECK YES
+DROP DATABASE test2;
+DROP DATABASE test1;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint when table is moved to another DB
+# with different name.
+#-----------------------------------------------------------------------
+CREATE DATABASE test1;
+CREATE DATABASE test2;
+USE test1;
+CREATE TABLE t1(c1 INT, c2 INT CHECK (c2 < 10));
+INSERT INTO t1 VALUES(1,1);
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME CHECK_CLAUSE
+def test1 t1_chk_1 (`c2` < 10)
+SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE TABLE_NAME='t1';
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
+def test1 t1_chk_1 test1 t1 CHECK YES
+ALTER TABLE test1.t1 rename test2.t2;
+USE test2;
+SELECT * FROM t2;
+c1 c2
+1 1
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME CHECK_CLAUSE
+def test2 t2_chk_1 (`c2` < 10)
+SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE TABLE_NAME='t2';
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
+def test2 t2_chk_1 test2 t2 CHECK YES
+DROP DATABASE test2;
+DROP DATABASE test1;
+use test;
+#-----------------------------------------------------------------------
+# Test case to verify check constraints with foreign key constraint
+#-----------------------------------------------------------------------
+CREATE TABLE parent(pid INT NOT NULL PRIMARY KEY CHECK(pid > 1));
+CREATE TABLE child(cid INT CHECK(cid > 1),
+FOREIGN KEY fk(cid) REFERENCES parent(pid));
+SHOW CREATE TABLE parent;
+Table Create Table
+parent CREATE TABLE `parent` (
+ `pid` int(11) NOT NULL,
+ PRIMARY KEY (`pid`),
+ CONSTRAINT `parent_chk_1` CHECK ((`pid` > 1))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+SHOW CREATE TABLE child;
+Table Create Table
+child CREATE TABLE `child` (
+ `cid` int(11) DEFAULT NULL,
+ KEY `fk` (`cid`),
+ CONSTRAINT `fk` FOREIGN KEY (`cid`) REFERENCES `parent` (`pid`),
+ CONSTRAINT `child_chk_1` CHECK ((`cid` > 1))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+INSERT INTO parent VALUES(2);
+INSERT INTO child VALUES(1);
+ERROR HY000: Check constraint 'child_chk_1' is violated.
+INSERT INTO child VALUES(3);
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `fk` FOREIGN KEY (`cid`) REFERENCES `parent` (`pid`))
+INSERT INTO child VALUES(2);
+SELECT * FROM parent;
+pid
+2
+SELECT * FROM child;
+cid
+2
+DROP TABLE child;
+DROP TABLE parent;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint with FK referential actions.
+#-----------------------------------------------------------------------
+CREATE TABLE parent (a INT PRIMARY KEY);
+CREATE TABLE child (
+b INT,
+c INT CHECK (c < 10),
+INDEX(b),
+FOREIGN KEY (b) REFERENCES parent(a) ON DELETE SET NULL,
+CHECK (b IS NOT NULL)
+);
+ERROR HY000: Column 'b' cannot be used in a check constraint 'child_chk_2': needed in a foreign key constraint 'child_ibfk_1' referential action.
+CREATE TABLE child (
+b INT,
+c INT CHECK (c < 10),
+INDEX(b),
+FOREIGN KEY (b) REFERENCES parent(a) ON DELETE SET NULL
+);
+ALTER TABLE child ADD CONSTRAINT CHECK (b IS NOT NULL);
+ERROR HY000: Column 'b' cannot be used in a check constraint 'child_chk_2': needed in a foreign key constraint 'child_ibfk_1' referential action.
+ALTER TABLE child DROP FOREIGN KEY child_ibfk_1;
+ALTER TABLE child ADD CONSTRAINT FOREIGN KEY (b) REFERENCES parent(a) ON DELETE SET NULL,
+ADD CONSTRAINT CHECK (b IS NOT NULL);
+ERROR HY000: Column 'b' cannot be used in a check constraint 'child_chk_2': needed in a foreign key constraint 'child_ibfk_1' referential action.
+DROP TABLE child;
+CREATE TABLE child (
+b INT,
+c INT CHECK (c < 10),
+INDEX(b),
+FOREIGN KEY (b) REFERENCES parent(a) ON UPDATE SET NULL,
+CHECK (b IS NOT NULL)
+);
+ERROR HY000: Column 'b' cannot be used in a check constraint 'child_chk_2': needed in a foreign key constraint 'child_ibfk_1' referential action.
+CREATE TABLE child (
+b INT,
+c INT CHECK (c < 10),
+INDEX(b),
+FOREIGN KEY (b) REFERENCES parent(a) ON UPDATE SET NULL
+);
+ALTER TABLE child ADD CONSTRAINT CHECK (b IS NOT NULL);
+ERROR HY000: Column 'b' cannot be used in a check constraint 'child_chk_2': needed in a foreign key constraint 'child_ibfk_1' referential action.
+ALTER TABLE child DROP FOREIGN KEY child_ibfk_1;
+ALTER TABLE child ADD CONSTRAINT FOREIGN KEY (b) REFERENCES parent(a) ON UPDATE SET NULL,
+ADD CONSTRAINT CHECK (b IS NOT NULL);
+ERROR HY000: Column 'b' cannot be used in a check constraint 'child_chk_2': needed in a foreign key constraint 'child_ibfk_1' referential action.
+DROP TABLE child;
+CREATE TABLE child (
+b INT,
+c INT CHECK (c < 10),
+INDEX(b),
+FOREIGN KEY (b) REFERENCES parent(a) ON UPDATE CASCADE,
+CHECK (b IS NOT NULL)
+);
+ERROR HY000: Column 'b' cannot be used in a check constraint 'child_chk_2': needed in a foreign key constraint 'child_ibfk_1' referential action.
+CREATE TABLE child (
+b INT,
+c INT CHECK (c < 10),
+INDEX(b),
+FOREIGN KEY (b) REFERENCES parent(a) ON UPDATE CASCADE
+);
+ALTER TABLE child ADD CONSTRAINT CHECK (b IS NOT NULL);
+ERROR HY000: Column 'b' cannot be used in a check constraint 'child_chk_2': needed in a foreign key constraint 'child_ibfk_1' referential action.
+ALTER TABLE child DROP FOREIGN KEY child_ibfk_1;
+ALTER TABLE child ADD CONSTRAINT FOREIGN KEY (b) REFERENCES parent(a) ON UPDATE CASCADE,
+ADD CONSTRAINT CHECK (b IS NOT NULL);
+ERROR HY000: Column 'b' cannot be used in a check constraint 'child_chk_2': needed in a foreign key constraint 'child_ibfk_1' referential action.
+DROP TABLE child;
+DROP TABLE parent;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint with triggers
+#-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, c2 INT CHECK (c2 < 10));
+CREATE TABLE t2(c1 INT, c2 INT);
+CREATE TRIGGER before_t2_insert
+BEFORE INSERT ON t2
+FOR EACH ROW
+BEGIN
+INSERT INTO t1 VALUES(NEW.c1,NEW.c2);
+END
+//
+INSERT INTO t2 VALUES(1,20);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+SELECT * FROM t1;
+c1 c2
+SELECT * FROM t2;
+c1 c2
+DROP TRIGGER before_t2_insert;
+CREATE TRIGGER after_t2_insert
+AFTER INSERT ON t2
+FOR EACH ROW
+BEGIN
+INSERT INTO t1 VALUES(NEW.c1,NEW.c2);
+END
+//
+INSERT INTO t2 VALUES(1,30);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+SELECT * FROM t1;
+c1 c2
+SELECT * FROM t2;
+c1 c2
+DROP TRIGGER after_t2_insert;
+INSERT INTO t2 VALUES(1,5);
+INSERT INTO t1 VALUES(1,5);
+CREATE TRIGGER before_t2_update
+BEFORE UPDATE ON t2
+FOR EACH ROW
+BEGIN
+UPDATE t1 SET c2=NEW.c2 WHERE c1=NEW.c1;
+END
+//
+UPDATE t2 SET c2=20 WHERE c1=1;
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+SELECT * FROM t1;
+c1 c2
+1 5
+SELECT * FROM t2;
+c1 c2
+1 5
+DROP TRIGGER before_t2_update;
+CREATE TRIGGER after_t2_update
+AFTER UPDATE ON t2
+FOR EACH ROW
+BEGIN
+UPDATE t1 SET c2=NEW.c2 WHERE c1=NEW.c1;
+END
+//
+UPDATE t2 SET c2=20 WHERE c1=1;
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+SELECT * FROM t1;
+c1 c2
+1 5
+SELECT * FROM t2;
+c1 c2
+1 5
+DROP TRIGGER after_t2_update;
+DROP TABLE t1,t2;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint with triggers old style.
+#-----------------------------------------------------------------------
+CREATE TABLE t1(c1 int CONSTRAINT ck1 CHECK(c1 < 5));
+CREATE PROCEDURE proc1 (IN val1 INT)
+BEGIN
+IF val1 < 10 THEN
+SIGNAL SQLSTATE '45000'
+ SET MESSAGE_TEXT = 'check constraint on c1 failed';
+END IF;
+END
+//
+CREATE TRIGGER before_t1_insert
+BEFORE INSERT ON t1
+FOR EACH ROW
+BEGIN
+CALL proc1(new.c1);
+END
+//
+INSERT INTO t1 VALUES(20);
+ERROR HY000: Check constraint 'ck1' is violated.
+INSERT INTO t1 VALUES(9);
+ERROR 45000: check constraint on c1 failed
+INSERT INTO t1 VALUES(4);
+ERROR 45000: check constraint on c1 failed
+DROP PROCEDURE proc1;
+DROP TRIGGER before_t1_insert;
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint with mysqldump
+#-----------------------------------------------------------------------
+CREATE DATABASE test1;
+USE test1;
+CREATE TABLE t1 (
+c1 BIT(7) CHECK(c1 < B'1111100') NOT ENFORCED,
+c2 BOOLEAN CHECK(c2 > 0) NOT ENFORCED,
+c3 TINYINT CHECK(c3 > 10) NOT ENFORCED,
+c4 SMALLINT CHECK(c4 > 10) NOT ENFORCED,
+c5 MEDIUMINT CHECK(c5 > 10) NOT ENFORCED,
+c6 INT CHECK(c6 > 10),
+c7 BIGINT CHECK(c7 > 10),
+c8 DECIMAL(6,2) CHECK(c8 > 10.1),
+c9 FLOAT(6,2) CHECK(c9 > 10.1),
+c10 DOUBLE(6,2) CHECK(c10 > 10.1),
+c11 CHAR(6) CHECK (c11 IS NULL));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` bit(7) DEFAULT NULL,
+ `c2` tinyint(1) DEFAULT NULL,
+ `c3` tinyint(4) DEFAULT NULL,
+ `c4` smallint(6) DEFAULT NULL,
+ `c5` mediumint(9) DEFAULT NULL,
+ `c6` int(11) DEFAULT NULL,
+ `c7` bigint(20) DEFAULT NULL,
+ `c8` decimal(6,2) DEFAULT NULL,
+ `c9` float(6,2) DEFAULT NULL,
+ `c10` double(6,2) DEFAULT NULL,
+ `c11` char(6) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`c1` < 0x7c)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t1_chk_10` CHECK ((`c10` > 10.1)),
+ CONSTRAINT `t1_chk_11` CHECK (isnull(`c11`)),
+ CONSTRAINT `t1_chk_2` CHECK ((`c2` > 0)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t1_chk_3` CHECK ((`c3` > 10)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t1_chk_4` CHECK ((`c4` > 10)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t1_chk_5` CHECK ((`c5` > 10)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t1_chk_6` CHECK ((`c6` > 10)),
+ CONSTRAINT `t1_chk_7` CHECK ((`c7` > 10)),
+ CONSTRAINT `t1_chk_8` CHECK ((`c8` > 10.1)),
+ CONSTRAINT `t1_chk_9` CHECK ((`c9` > 10.1))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP DATABASE test1;
+USE test1;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` bit(7) DEFAULT NULL,
+ `c2` tinyint(1) DEFAULT NULL,
+ `c3` tinyint(4) DEFAULT NULL,
+ `c4` smallint(6) DEFAULT NULL,
+ `c5` mediumint(9) DEFAULT NULL,
+ `c6` int(11) DEFAULT NULL,
+ `c7` bigint(20) DEFAULT NULL,
+ `c8` decimal(6,2) DEFAULT NULL,
+ `c9` float(6,2) DEFAULT NULL,
+ `c10` double(6,2) DEFAULT NULL,
+ `c11` char(6) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`c1` < 0x7c)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t1_chk_10` CHECK ((`c10` > 10.1)),
+ CONSTRAINT `t1_chk_11` CHECK (isnull(`c11`)),
+ CONSTRAINT `t1_chk_2` CHECK ((`c2` > 0)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t1_chk_3` CHECK ((`c3` > 10)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t1_chk_4` CHECK ((`c4` > 10)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t1_chk_5` CHECK ((`c5` > 10)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t1_chk_6` CHECK ((`c6` > 10)),
+ CONSTRAINT `t1_chk_7` CHECK ((`c7` > 10)),
+ CONSTRAINT `t1_chk_8` CHECK ((`c8` > 10.1)),
+ CONSTRAINT `t1_chk_9` CHECK ((`c9` > 10.1))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+INSERT INTO t1(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10)
+VALUES(B'1111111',0,5,5,5,1,1,1.2,1.2,1.2);
+ERROR HY000: Check constraint 't1_chk_10' is violated.
+INSERT INTO t1(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10)
+VALUES(B'1111111',0,5,5,5,11,11,10.2,10.2,10.2);
+SELECT * FROM t1;
+c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11
+ 0 5 5 5 11 11 10.20 10.20 10.20 NULL
+DROP TABLE t1;
+DROP DATABASE test1;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint with mysqlpump
+#-----------------------------------------------------------------------
+CREATE DATABASE test2;
+USE test2;
+CREATE TABLE t2 (
+c1 BIT(7) CHECK(c1 < B'1111100'),
+c2 BOOLEAN CHECK(c2 > 0),
+c3 TINYINT CHECK(c3 > 10),
+c4 SMALLINT CHECK(c4 > 10),
+c5 MEDIUMINT CHECK(c5 > 10),
+c6 INT CHECK(c6 > 10) NOT ENFORCED,
+c7 BIGINT CHECK(c7 > 10) NOT ENFORCED,
+c8 DECIMAL(6,2) CHECK(c8 > 10.1) NOT ENFORCED,
+c9 FLOAT(6,2) CHECK(c9 > 10.1) NOT ENFORCED,
+c10 DOUBLE(6,2) CHECK(c10 > 10.1) NOT ENFORCED);
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `c1` bit(7) DEFAULT NULL,
+ `c2` tinyint(1) DEFAULT NULL,
+ `c3` tinyint(4) DEFAULT NULL,
+ `c4` smallint(6) DEFAULT NULL,
+ `c5` mediumint(9) DEFAULT NULL,
+ `c6` int(11) DEFAULT NULL,
+ `c7` bigint(20) DEFAULT NULL,
+ `c8` decimal(6,2) DEFAULT NULL,
+ `c9` float(6,2) DEFAULT NULL,
+ `c10` double(6,2) DEFAULT NULL,
+ CONSTRAINT `t2_chk_1` CHECK ((`c1` < 0x7c)),
+ CONSTRAINT `t2_chk_10` CHECK ((`c10` > 10.1)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t2_chk_2` CHECK ((`c2` > 0)),
+ CONSTRAINT `t2_chk_3` CHECK ((`c3` > 10)),
+ CONSTRAINT `t2_chk_4` CHECK ((`c4` > 10)),
+ CONSTRAINT `t2_chk_5` CHECK ((`c5` > 10)),
+ CONSTRAINT `t2_chk_6` CHECK ((`c6` > 10)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t2_chk_7` CHECK ((`c7` > 10)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t2_chk_8` CHECK ((`c8` > 10.1)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t2_chk_9` CHECK ((`c9` > 10.1)) /*!80015 NOT ENFORCED */
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP DATABASE test2;
+USE test2;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `c1` bit(7) DEFAULT NULL,
+ `c2` tinyint(1) DEFAULT NULL,
+ `c3` tinyint(4) DEFAULT NULL,
+ `c4` smallint(6) DEFAULT NULL,
+ `c5` mediumint(9) DEFAULT NULL,
+ `c6` int(11) DEFAULT NULL,
+ `c7` bigint(20) DEFAULT NULL,
+ `c8` decimal(6,2) DEFAULT NULL,
+ `c9` float(6,2) DEFAULT NULL,
+ `c10` double(6,2) DEFAULT NULL,
+ CONSTRAINT `t2_chk_1` CHECK ((`c1` < 0x7c)),
+ CONSTRAINT `t2_chk_10` CHECK ((`c10` > 10.1)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t2_chk_2` CHECK ((`c2` > 0)),
+ CONSTRAINT `t2_chk_3` CHECK ((`c3` > 10)),
+ CONSTRAINT `t2_chk_4` CHECK ((`c4` > 10)),
+ CONSTRAINT `t2_chk_5` CHECK ((`c5` > 10)),
+ CONSTRAINT `t2_chk_6` CHECK ((`c6` > 10)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t2_chk_7` CHECK ((`c7` > 10)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t2_chk_8` CHECK ((`c8` > 10.1)) /*!80015 NOT ENFORCED */,
+ CONSTRAINT `t2_chk_9` CHECK ((`c9` > 10.1)) /*!80015 NOT ENFORCED */
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+INSERT INTO t2(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10)
+VALUES(B'1111000',0,10,10,10,5,5,9.1,9.1,9.1);
+ERROR HY000: Check constraint 't2_chk_2' is violated.
+INSERT INTO t2(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10)
+VALUES(B'1111000',1,11,11,11,5,5,9.1,9.1,9.1);
+SELECT * FROM t2;
+c1 c2 c3 c4 c5 c6 c7 c8 c9 c10
+x 1 11 11 11 5 5 9.10 9.10 9.10
+DROP TABLE t2;
+DROP DATABASE test2;
+USE test;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint with PREPARE statement
+#-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT CHECK(c1 > 10));
+PREPARE stmt1 FROM 'INSERT INTO t1 VALUES(1)';
+EXECUTE stmt1;
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+DEALLOCATE PREPARE stmt1;
+PREPARE stmt2 FROM 'INSERT INTO t1 VALUES(20)';
+EXECUTE stmt2;
+DEALLOCATE PREPARE stmt2;
+SELECT * FROM t1;
+c1
+20
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint behaviour inside transaction
+#-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT);
+CREATE TABLE t2(c1 INT CHECK(c1 > 10));
+SET AUTOCOMMIT = OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t2 VALUES(1);
+ERROR HY000: Check constraint 't2_chk_1' is violated.
+ROLLBACK;
+SELECT * FROM t1;
+c1
+SELECT * FROM t2;
+c1
+START TRANSACTION;
+ALTER TABLE t1 ADD CONSTRAINT CHECK (C1 > 10);
+COMMIT;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`C1` > 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+SET AUTOCOMMIT = ON;
+DROP TABLE t1,t2;
+#------------------------------------------------------------------------
+# Test case to verify check constraints with Partition table.
+#------------------------------------------------------------------------
+# check constraint with range partition
+CREATE TABLE t1(
+d DATE NOT NULL CHECK(YEAR(d) > '1950')
+)
+PARTITION BY RANGE( YEAR(d) ) (
+PARTITION p0 VALUES LESS THAN (1960),
+PARTITION p1 VALUES LESS THAN (1970),
+PARTITION p2 VALUES LESS THAN (1980),
+PARTITION p3 VALUES LESS THAN (1990)
+);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `d` date NOT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((year(`d`) > _utf8mb4'1950'))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+/*!50100 PARTITION BY RANGE (year(`d`))
+(PARTITION p0 VALUES LESS THAN (1960) ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN (1970) ENGINE = InnoDB,
+ PARTITION p2 VALUES LESS THAN (1980) ENGINE = InnoDB,
+ PARTITION p3 VALUES LESS THAN (1990) ENGINE = InnoDB) */
+INSERT INTO t1 VALUES('1940-01-01');
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO t1 VALUES('1960-01-01');
+SELECT * FROM t1;
+d
+1960-01-01
+DROP TABLE t1;
+# check constraint with list partition
+CREATE TABLE t1(
+id INT NOT NULL CHECK(id BETWEEN 10 AND 50),
+name VARCHAR(10)
+)
+PARTITION BY LIST(id) (
+PARTITION p0 VALUES IN (10,19),
+PARTITION p1 VALUES IN (20,29),
+PARTITION p2 VALUES IN (30,39),
+PARTITION p3 VALUES IN (40,49)
+);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id` int(11) NOT NULL,
+ `name` varchar(10) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`id` between 10 and 50))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+/*!50100 PARTITION BY LIST (`id`)
+(PARTITION p0 VALUES IN (10,19) ENGINE = InnoDB,
+ PARTITION p1 VALUES IN (20,29) ENGINE = InnoDB,
+ PARTITION p2 VALUES IN (30,39) ENGINE = InnoDB,
+ PARTITION p3 VALUES IN (40,49) ENGINE = InnoDB) */
+INSERT INTO t1 VALUES(60,'aaa');
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO t1 VALUES(30,'aaa');
+SELECT * FROM t1;
+id name
+30 aaa
+DROP TABLE t1;
+# check constraint with hash partition
+CREATE TABLE t1(id INT NOT NULL CHECK(id > 10),
+name VARCHAR(40)
+)
+PARTITION BY HASH(id)
+PARTITIONS 4;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id` int(11) NOT NULL,
+ `name` varchar(40) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`id` > 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+/*!50100 PARTITION BY HASH (`id`)
+PARTITIONS 4 */
+INSERT INTO t1 VALUES(1,'aaa');
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO t1 VALUES(60,'aaa');
+SELECT * FROM t1;
+id name
+60 aaa
+DROP TABLE t1;
+# check constraint with key partition
+CREATE TABLE t1(id INT PRIMARY KEY NOT NULL CHECK(id > 10),
+name VARCHAR(40)
+)
+PARTITION BY KEY()
+PARTITIONS 4;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id` int(11) NOT NULL,
+ `name` varchar(40) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ CONSTRAINT `t1_chk_1` CHECK ((`id` > 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+/*!50100 PARTITION BY KEY ()
+PARTITIONS 4 */
+INSERT INTO t1 VALUES(1,'aaa');
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO t1 VALUES(60,'aaa');
+SELECT * FROM t1;
+id name
+60 aaa
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify alter operations on non-transactional SE table
+# with check constraints.
+#-----------------------------------------------------------------------
+CREATE TABLE t1(f1 INT CHECK (f1 < 10)) ENGINE = myisam;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` < 10))
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+ALTER TABLE t1 ADD f2 INT, ALGORITHM=copy;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` < 10))
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+ALTER TABLE t1 ALTER f1 SET DEFAULT 10, ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT '10',
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` < 10))
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t1;
+#-----------------------------------------------------------------------
+# Test case to verify check constraint with Updatable view
+#-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, c2 INT CHECK (c2 < 10));
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO v1 VALUES(1,20);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+INSERT INTO v1 VALUES(1,5);
+SELECT * FROM t1;
+c1 c2
+1 5
+SELECT * FROM v1;
+c1 c2
+1 5
+DROP VIEW v1;
+DROP TABLE t1;
diff --git a/mysql-test/r/check_constraints_debug.result b/mysql-test/r/check_constraints_debug.result
new file mode 100644
index 000000000000..5f578cdb1c1c
--- /dev/null
+++ b/mysql-test/r/check_constraints_debug.result
@@ -0,0 +1,135 @@
+#------------------------------------------------------------------------
+# Test case to verify MDL locking on check constraints with same names
+# in the concurrent CREATE TABLE statements.
+#------------------------------------------------------------------------
+SET DEBUG_SYNC="after_acquiring_lock_on_check_constraints SIGNAL cc_locked WAIT_FOR continue";
+CREATE TABLE t1 (f1 INT CHECK (f1 < 10), f2 INT, CONSTRAINT t1_ck CHECK(f2 < 10));;
+CONNECT con1, localhost, root;
+SET DEBUG_SYNC="now WAIT_FOR cc_locked";
+CREATE TABLE t2 (f1 INT, f2 INT, CONSTRAINT t1_ck CHECK(f2 < 10));;
+CONNECT con2, localhost, root;
+# default connection acquires MDL lock on the check constraint name 'test.t1_ck'.
+# con1 waits for the MDL lock on 'test.t1_ck' at this point.
+SET DEBUG_SYNC="now SIGNAL continue";
+connection con1;
+ERROR HY000: Duplicate check constraint name 't1_ck'.
+connection default;
+#------------------------------------------------------------------------
+# Test case to verify MDL locking on check constraints names in the
+# RENAME TABLE and CREATE TABLE statements.
+#------------------------------------------------------------------------
+SET DEBUG_SYNC="after_acquiring_lock_on_check_constraints_for_rename SIGNAL cc_locked WAIT_FOR continue";
+RENAME TABLE t1 to t2;;
+connection con1;
+SET DEBUG_SYNC="now WAIT_FOR cc_locked";
+CREATE TABLE t3 (f1 INT, CONSTRAINT t1_chk_1 CHECK (f1 < 10));;
+connection con2;
+# default connection acquires lock on check constraint 'test.t1_chk_1'.
+# Concurrent create operation with same name for check constraint in con1
+# waits for the lock.
+SET DEBUG_SYNC="now SIGNAL continue";
+connection con1;
+connection default;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_ck` CHECK ((`f2` < 10)),
+ CONSTRAINT `t2_chk_1` CHECK ((`f1` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+SHOW CREATE TABLE t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `f1` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t3;
+#------------------------------------------------------------------------
+# Test case to verify MDL locking on generated check constraints names
+# in the RENAME TABLE using the target table name and CREATE TABLE
+# statements.
+#------------------------------------------------------------------------
+SET DEBUG_SYNC="after_acquiring_lock_on_check_constraints_for_rename SIGNAL cc_locked WAIT_FOR continue";
+RENAME TABLE t2 to t1;;
+connection con1;
+SET DEBUG_SYNC="now WAIT_FOR cc_locked";
+CREATE TABLE t3 (f1 INT, CONSTRAINT t1_chk_1 CHECK (f1 < 10));;
+connection con2;
+# default connection acquires lock on check constraint name('test.t1_chk_1')
+# generated using target table t1.
+# concurrent con1 waits for the MDL on test.t1_chk_1 in CREATE TABLE
+# statement.
+SET DEBUG_SYNC="now SIGNAL continue";
+connection con1;
+ERROR HY000: Duplicate check constraint name 't1_chk_1'.
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` < 10)),
+ CONSTRAINT `t1_ck` CHECK ((`f2` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+connection default;
+#------------------------------------------------------------------------
+# Test case to verify MDL locking on check constraint name in ALTER
+# TABLE statement to RENAME table and CREATE TABLE statements.
+#------------------------------------------------------------------------
+SET DEBUG_SYNC="after_acquiring_lock_on_check_constraints_for_rename SIGNAL cc_locked WAIT_FOR continue";
+ALTER TABLE t1 RENAME TO t3;;
+connection con1;
+SET DEBUG_SYNC="now WAIT_FOR cc_locked";
+CREATE TABLE t2 (f1 INT, CONSTRAINT t1_chk_1 CHECK (f1 < 10));;
+connection con2;
+# default connection acquires lock on check constraint 'test.t1_chk_1'.
+# Concurrent con1 waits for lock on test.t1_chk_1.
+SET DEBUG_SYNC="now SIGNAL continue";
+connection con1;
+connection default;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `f1` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+SHOW CREATE TABLE t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_ck` CHECK ((`f2` < 10)),
+ CONSTRAINT `t3_chk_1` CHECK ((`f1` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t2;
+#------------------------------------------------------------------------
+# Test case to verify MDL locking on generated check constraint name
+# using target table name in ALTER TABLE statement to RENAME table and
+# CREATE TABLE statements.
+#------------------------------------------------------------------------
+SET DEBUG_SYNC="after_acquiring_lock_on_check_constraints_for_rename SIGNAL cc_locked WAIT_FOR continue";
+ALTER TABLE t3 RENAME TO t1;;
+connection con1;
+SET DEBUG_SYNC="now WAIT_FOR cc_locked";
+CREATE TABLE t2 (f1 INT, CONSTRAINT t1_chk_1 CHECK (f1 < 10));;
+connection con2;
+# default connection acquires lock on the generated check constraint
+# name('test.t1_chk_1') using target table name t1. con1 waits for
+# the lock on same name for check constraint.
+SET DEBUG_SYNC="now SIGNAL continue";
+connection con1;
+ERROR HY000: Duplicate check constraint name 't1_chk_1'.
+connection default;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` < 10)),
+ CONSTRAINT `t1_ck` CHECK ((`f2` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
+SET DEBUG_SYNC='RESET';
diff --git a/mysql-test/r/constraints.result b/mysql-test/r/constraints.result
index 74dc3457e9ce..ae6069b1182a 100644
--- a/mysql-test/r/constraints.result
+++ b/mysql-test/r/constraints.result
@@ -2,14 +2,17 @@ drop table if exists t1;
create table t1 (a int check (a>0));
insert into t1 values (1);
insert into t1 values (0);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
drop table t1;
create table t1 (a int, b int, check (a>b));
insert into t1 values (1,0);
insert into t1 values (0,1);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
drop table t1;
create table t1 (a int ,b int, constraint abc check (a>b));
insert into t1 values (1,0);
insert into t1 values (0,1);
+ERROR HY000: Check constraint 'abc' is violated.
drop table t1;
create table t1 (a int null);
insert into t1 values (1),(NULL);
diff --git a/mysql-test/r/dd_is_compatibility_ci.result b/mysql-test/r/dd_is_compatibility_ci.result
index fdb596ff3af9..2e2962884f00 100644
--- a/mysql-test/r/dd_is_compatibility_ci.result
+++ b/mysql-test/r/dd_is_compatibility_ci.result
@@ -154,6 +154,7 @@ WHERE table_schema LIKE 'information_schema'
SELECT * FROM v1;
table_name
CHARACTER_SETS
+CHECK_CONSTRAINTS
COLLATIONS
COLLATION_CHARACTER_SET_APPLICABILITY
COLUMNS
diff --git a/mysql-test/r/dd_is_compatibility_cs.result b/mysql-test/r/dd_is_compatibility_cs.result
index 75aadb51636f..dab6f56f9b65 100644
--- a/mysql-test/r/dd_is_compatibility_cs.result
+++ b/mysql-test/r/dd_is_compatibility_cs.result
@@ -154,6 +154,7 @@ WHERE table_schema LIKE 'information_schema'
SELECT * FROM v1;
table_name
CHARACTER_SETS
+CHECK_CONSTRAINTS
COLLATIONS
COLLATION_CHARACTER_SET_APPLICABILITY
COLUMNS
diff --git a/mysql-test/r/dd_schema_definition_after_upgrade_debug.result b/mysql-test/r/dd_schema_definition_after_upgrade_debug.result
index f1843d3a7784..c45a0a6cf7d3 100644
--- a/mysql-test/r/dd_schema_definition_after_upgrade_debug.result
+++ b/mysql-test/r/dd_schema_definition_after_upgrade_debug.result
@@ -50,8 +50,8 @@ SET debug = '+d,skip_dd_table_access_check';
########################################################################
# The number of hidden DD/DDSE tables must be as expected.
########################################################################
-include/assert.inc [There are 31 hidden DD/DDSE tables.]
-include/assert.inc [There are 33 DD/DDSE tables in total.]
+include/assert.inc [There are 32 hidden DD/DDSE tables.]
+include/assert.inc [There are 34 DD/DDSE tables in total.]
########################################################################
# No unexpected DD tables must be present.
########################################################################
@@ -190,8 +190,8 @@ SET debug = '+d,skip_dd_table_access_check';
########################################################################
# The number of hidden DD/DDSE tables must be as expected.
########################################################################
-include/assert.inc [There are 31 hidden DD/DDSE tables.]
-include/assert.inc [There are 33 DD/DDSE tables in total.]
+include/assert.inc [There are 32 hidden DD/DDSE tables.]
+include/assert.inc [There are 34 DD/DDSE tables in total.]
########################################################################
# No unexpected DD tables must be present.
########################################################################
@@ -332,8 +332,8 @@ SET debug = '+d,skip_dd_table_access_check';
########################################################################
# The number of hidden DD/DDSE tables must be as expected.
########################################################################
-include/assert.inc [There are 31 hidden DD/DDSE tables.]
-include/assert.inc [There are 33 DD/DDSE tables in total.]
+include/assert.inc [There are 32 hidden DD/DDSE tables.]
+include/assert.inc [There are 34 DD/DDSE tables in total.]
########################################################################
# No unexpected DD tables must be present.
########################################################################
@@ -474,8 +474,8 @@ SET debug = '+d,skip_dd_table_access_check';
########################################################################
# The number of hidden DD/DDSE tables must be as expected.
########################################################################
-include/assert.inc [There are 31 hidden DD/DDSE tables.]
-include/assert.inc [There are 33 DD/DDSE tables in total.]
+include/assert.inc [There are 32 hidden DD/DDSE tables.]
+include/assert.inc [There are 34 DD/DDSE tables in total.]
########################################################################
# No unexpected DD tables must be present.
########################################################################
diff --git a/mysql-test/r/dd_schema_definition_debug.result b/mysql-test/r/dd_schema_definition_debug.result
index ff63eb44968c..25aa30a17455 100644
--- a/mysql-test/r/dd_schema_definition_debug.result
+++ b/mysql-test/r/dd_schema_definition_debug.result
@@ -141,8 +141,8 @@ SET debug = '+d,skip_dd_table_access_check';
########################################################################
# The number of hidden DD/DDSE tables must be as expected.
########################################################################
-include/assert.inc [There are 31 hidden DD/DDSE tables.]
-include/assert.inc [There are 33 DD/DDSE tables in total.]
+include/assert.inc [There are 32 hidden DD/DDSE tables.]
+include/assert.inc [There are 34 DD/DDSE tables in total.]
########################################################################
# No unexpected DD tables must be present.
########################################################################
@@ -165,7 +165,7 @@ SET debug = '+d,skip_dd_table_access_check';
########################################################################
# The actual DD version stored on disk.
########################################################################
-DD_VERSION=80014
+DD_VERSION=80015
########################################################################
# List the CREATE TABLE statements for the DD tables.
# Mask the AUTO INCREMENT counter, which is not
@@ -719,5 +719,5 @@ SET debug = '-d,skip_dd_table_access_check';
SET debug = '+d,skip_dd_table_access_check';
include/assert.inc [The group concat max length is sufficient.]
CHECK_STATUS
-The schema checksum corresponds to DD version 80014.
+The schema checksum corresponds to DD version 80015.
include/assert.inc [The schema checksum corresponds to a known DD version.]
diff --git a/mysql-test/r/dd_upgrade_test.result b/mysql-test/r/dd_upgrade_test.result
index 5ec36ebf45ca..4cd8c0d41e95 100644
--- a/mysql-test/r/dd_upgrade_test.result
+++ b/mysql-test/r/dd_upgrade_test.result
@@ -864,4 +864,35 @@ t_set CREATE TABLE `t_set` (
# Remove copied files
# Restart the server with default options.
# restart
+#-----------------------------------------------------------------------
+# WL#929: CHECK Constraint
+# Test case to verify upgrade from version before check
+# constraint suppport.
+#-----------------------------------------------------------------------
+# Copy the remote tablespace & DB zip files from suite location to working location.
+# Check that the file exists in the working folder.
+# Set different paths for --datadir
+CREATE TABLE t1 (f1 INT CHECK (f1 < 10));
+# After upgrade CHECK_CONSTRAINTS table should be present and should list
+# check constraints.
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME CHECK_CLAUSE
+def test t1_chk_1 (`f1` < 10)
+# After upgrade TABLE_CONSTRAINTS should list check constraints.
+SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE TABLE_NAME='t1';
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
+def test t1_chk_1 test t1 CHECK YES
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` < 10))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+INSERT INTO t1 VALUES (100);
+ERROR HY000: Check constraint 't1_chk_1' is violated.
+DROP TABLE t1;
+# Stop the server
+# Remove copied files
+# Restart the server with default options.
+# restart
# end of test
diff --git a/mysql-test/r/dictionary_tablespace.result b/mysql-test/r/dictionary_tablespace.result
index c678d5e8d206..c6ff45286388 100644
--- a/mysql-test/r/dictionary_tablespace.result
+++ b/mysql-test/r/dictionary_tablespace.result
@@ -14,6 +14,7 @@ mysql.tablespaces ON tables1.tablespace_id = tablespaces.id
WHERE tables1.name NOT IN ('ndb_binlog_index') ORDER BY tables1.name;
catalogs mysql
character_sets mysql
+check_constraints mysql
collations mysql
column_statistics mysql
column_type_elements mysql
@@ -82,6 +83,7 @@ name NOT IN ('ndb_binlog_index')
ORDER BY name ASC;
catalogs
character_sets
+check_constraints
collations
column_statistics
column_type_elements
diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result
index f94742cbab71..0062052a8118 100644
--- a/mysql-test/r/group_min_max.result
+++ b/mysql-test/r/group_min_max.result
@@ -2527,7 +2527,7 @@ FLUSH STATUS;
CREATE TABLE t2 SELECT max(b), a FROM t1 GROUP BY a;
SHOW STATUS LIKE 'handler_read__e%';
Variable_name Value
-Handler_read_key 23
+Handler_read_key 24
Handler_read_next 2
FLUSH STATUS;
SELECT * FROM (SELECT max(b), a FROM t1 GROUP BY a) b;
diff --git a/mysql-test/r/import.result b/mysql-test/r/import.result
index de6664d543e4..5a8a277e7dfd 100644
--- a/mysql-test/r/import.result
+++ b/mysql-test/r/import.result
@@ -499,4 +499,18 @@ IMPORT TABLE FROM 't1_*.sdi';
ERROR HY000: Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting.
SET SESSION sql_require_primary_key= OFF;
# Clean SDI files in $EXPORT_DIR
+#-----------------------------------------------------------------------
+# WL#929 - Check constraint.
+# Test case to verify check constraint import from SDI.
+#-----------------------------------------------------------------------
+CREATE TABLE t1 (f1 INT CHECK (f1 < 10)) ENGINE=MyISAM;
+DROP TABLE t1;
+IMPORT TABLE FROM 'test/t1*.sdi';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) DEFAULT NULL,
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` < 10))
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+DROP TABLE t1;
# Remove 'export' folder created at the beginning of test file.
diff --git a/mysql-test/r/information_schema_ci.result b/mysql-test/r/information_schema_ci.result
index 472003af61e1..7ea7edbae15e 100644
--- a/mysql-test/r/information_schema_ci.result
+++ b/mysql-test/r/information_schema_ci.result
@@ -61,6 +61,7 @@ table_name COLLATE utf8_general_ci not like 'innodb_%';
select * from v1;
c
CHARACTER_SETS
+CHECK_CONSTRAINTS
COLLATIONS
COLLATION_CHARACTER_SET_APPLICABILITY
COLUMNS
@@ -470,11 +471,11 @@ t1 CREATE TABLE `t1` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
select * from information_schema.TABLE_CONSTRAINTS where
TABLE_SCHEMA= "test" order by constraint_name;
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
-def test constraint_1 test t1 UNIQUE
-def test key_1 test t1 UNIQUE
-def test key_2 test t1 UNIQUE
-def test PRIMARY test t1 PRIMARY KEY
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
+def test constraint_1 test t1 UNIQUE YES
+def test key_1 test t1 UNIQUE YES
+def test key_2 test t1 UNIQUE YES
+def test PRIMARY test t1 PRIMARY KEY YES
select * from information_schema.key_column_usage where
TABLE_SCHEMA= "test" order by constraint_name;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
@@ -599,7 +600,7 @@ show index from vo;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
select * from information_schema.TABLE_CONSTRAINTS where
TABLE_NAME= "vo";
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
select * from information_schema.key_column_usage where
TABLE_NAME= "vo";
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
@@ -610,7 +611,7 @@ where table_schema='information_schema'
order by table_name collate utf8_general_ci limit 2;
TABLE_NAME TABLE_TYPE ENGINE
CHARACTER_SETS SYSTEM VIEW NULL
-COLLATIONS SYSTEM VIEW NULL
+CHECK_CONSTRAINTS SYSTEM VIEW NULL
show tables from information_schema like "T%";
Tables_in_information_schema (T%)
TABLES
@@ -761,6 +762,7 @@ select table_schema, table_name, column_name from information_schema.columns
where table_schema not in ('performance_schema', 'sys', 'mysql')
and data_type = 'longtext' order by table_name, column_name;
TABLE_SCHEMA TABLE_NAME COLUMN_NAME
+information_schema CHECK_CONSTRAINTS CHECK_CLAUSE
information_schema COLUMNS DATA_TYPE
information_schema COLUMNS GENERATION_EXPRESSION
information_schema EVENTS EVENT_DEFINITION
@@ -846,7 +848,7 @@ table_schema IN ('mysql', 'information_schema', 'test', 'mysqltest')
AND table_name not like 'ndb%' AND table_name COLLATE utf8_general_ci not like 'innodb_%'
GROUP BY TABLE_SCHEMA;
TABLE_SCHEMA count(*)
-information_schema 35
+information_schema 36
mysql 31
create table t1 (i int, j int);
create trigger trg1 before insert on t1 for each row
@@ -1288,6 +1290,7 @@ and t.table_name not like 'INNODB_%'
group by t.table_name order by num1, t.table_name COLLATE utf8_general_ci;
TABLE_NAME group_concat(t.table_schema, '.', t.table_name) num1
CHARACTER_SETS information_schema.CHARACTER_SETS 1
+CHECK_CONSTRAINTS information_schema.CHECK_CONSTRAINTS 1
COLLATIONS information_schema.COLLATIONS 1
COLUMNS information_schema.COLUMNS 1
COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
@@ -1508,9 +1511,9 @@ TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE
select * from information_schema.tables where table_name = NULL;
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE AUTO_INCREMENT CREATE_TIME UPDATE_TIME CHECK_TIME TABLE_COLLATION CHECKSUM CREATE_OPTIONS TABLE_COMMENT
select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_SCHEMA` = NULL;
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_NAME` = NULL;
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_SCHEMA` = NULL;
TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_TABLE` = NULL;
@@ -2420,6 +2423,7 @@ AND t.table_name NOT LIKE 'ndb%'
c1.column_name COLLATE utf8_general_ci;
TABLE_NAME COLUMN_NAME
CHARACTER_SETS CHARACTER_SET_NAME
+CHECK_CONSTRAINTS CONSTRAINT_SCHEMA
COLLATIONS COLLATION_NAME
COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
COLUMNS TABLE_SCHEMA
@@ -2474,6 +2478,7 @@ AND t.table_name NOT LIKE 'ndb%'
c1.column_name COLLATE utf8_general_ci;
TABLE_NAME COLUMN_NAME
CHARACTER_SETS CHARACTER_SET_NAME
+CHECK_CONSTRAINTS CONSTRAINT_SCHEMA
COLLATIONS COLLATION_NAME
COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
COLUMNS TABLE_SCHEMA
diff --git a/mysql-test/r/information_schema_cs.result b/mysql-test/r/information_schema_cs.result
index 241835b7379f..cab63a3fb4f2 100644
--- a/mysql-test/r/information_schema_cs.result
+++ b/mysql-test/r/information_schema_cs.result
@@ -61,6 +61,7 @@ table_name COLLATE utf8_general_ci not like 'innodb_%';
select * from v1;
c
CHARACTER_SETS
+CHECK_CONSTRAINTS
COLLATIONS
COLLATION_CHARACTER_SET_APPLICABILITY
COLUMNS
@@ -470,11 +471,11 @@ t1 CREATE TABLE `t1` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
select * from information_schema.TABLE_CONSTRAINTS where
TABLE_SCHEMA= "test" order by constraint_name;
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
-def test constraint_1 test t1 UNIQUE
-def test key_1 test t1 UNIQUE
-def test key_2 test t1 UNIQUE
-def test PRIMARY test t1 PRIMARY KEY
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
+def test constraint_1 test t1 UNIQUE YES
+def test key_1 test t1 UNIQUE YES
+def test key_2 test t1 UNIQUE YES
+def test PRIMARY test t1 PRIMARY KEY YES
select * from information_schema.key_column_usage where
TABLE_SCHEMA= "test" order by constraint_name;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
@@ -599,7 +600,7 @@ show index from vo;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
select * from information_schema.TABLE_CONSTRAINTS where
TABLE_NAME= "vo";
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
select * from information_schema.key_column_usage where
TABLE_NAME= "vo";
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
@@ -610,7 +611,7 @@ where table_schema='information_schema'
order by table_name collate utf8_general_ci limit 2;
TABLE_NAME TABLE_TYPE ENGINE
CHARACTER_SETS SYSTEM VIEW NULL
-COLLATIONS SYSTEM VIEW NULL
+CHECK_CONSTRAINTS SYSTEM VIEW NULL
show tables from information_schema like "T%";
Tables_in_information_schema (T%)
TABLES
@@ -761,6 +762,7 @@ select table_schema, table_name, column_name from information_schema.columns
where table_schema not in ('performance_schema', 'sys', 'mysql')
and data_type = 'longtext' order by table_name, column_name;
TABLE_SCHEMA TABLE_NAME COLUMN_NAME
+information_schema CHECK_CONSTRAINTS CHECK_CLAUSE
information_schema COLUMNS DATA_TYPE
information_schema COLUMNS GENERATION_EXPRESSION
information_schema EVENTS EVENT_DEFINITION
@@ -846,7 +848,7 @@ table_schema IN ('mysql', 'information_schema', 'test', 'mysqltest')
AND table_name not like 'ndb%' AND table_name COLLATE utf8_general_ci not like 'innodb_%'
GROUP BY TABLE_SCHEMA;
TABLE_SCHEMA count(*)
-information_schema 35
+information_schema 36
mysql 31
create table t1 (i int, j int);
create trigger trg1 before insert on t1 for each row
@@ -1288,6 +1290,7 @@ and t.table_name not like 'INNODB_%'
group by t.table_name order by num1, t.table_name COLLATE utf8_general_ci;
TABLE_NAME group_concat(t.table_schema, '.', t.table_name) num1
CHARACTER_SETS information_schema.CHARACTER_SETS 1
+CHECK_CONSTRAINTS information_schema.CHECK_CONSTRAINTS 1
COLLATIONS information_schema.COLLATIONS 1
COLUMNS information_schema.COLUMNS 1
COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
@@ -1508,9 +1511,9 @@ TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE
select * from information_schema.tables where table_name = NULL;
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE AUTO_INCREMENT CREATE_TIME UPDATE_TIME CHECK_TIME TABLE_COLLATION CHECKSUM CREATE_OPTIONS TABLE_COMMENT
select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_SCHEMA` = NULL;
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_NAME` = NULL;
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_SCHEMA` = NULL;
TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_TABLE` = NULL;
@@ -2420,6 +2423,7 @@ AND t.table_name NOT LIKE 'ndb%'
c1.column_name COLLATE utf8_general_ci;
TABLE_NAME COLUMN_NAME
CHARACTER_SETS CHARACTER_SET_NAME
+CHECK_CONSTRAINTS CONSTRAINT_SCHEMA
COLLATIONS COLLATION_NAME
COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
COLUMNS TABLE_SCHEMA
@@ -2474,6 +2478,7 @@ AND t.table_name NOT LIKE 'ndb%'
c1.column_name COLLATE utf8_general_ci;
TABLE_NAME COLUMN_NAME
CHARACTER_SETS CHARACTER_SET_NAME
+CHECK_CONSTRAINTS CONSTRAINT_SCHEMA
COLLATIONS COLLATION_NAME
COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
COLUMNS TABLE_SCHEMA
diff --git a/mysql-test/r/information_schema_db.result b/mysql-test/r/information_schema_db.result
index 2088bd57ea55..8110a33f203d 100644
--- a/mysql-test/r/information_schema_db.result
+++ b/mysql-test/r/information_schema_db.result
@@ -7,6 +7,7 @@ use INFORMATION_SCHEMA;
show tables where Tables_in_information_schema NOT LIKE 'INNODB%' and Tables_in_information_schema NOT LIKE 'ndb%';
Tables_in_information_schema
CHARACTER_SETS
+CHECK_CONSTRAINTS
COLLATIONS
COLLATION_CHARACTER_SET_APPLICABILITY
COLUMNS
diff --git a/mysql-test/r/information_schema_inno.result b/mysql-test/r/information_schema_inno.result
index 2301f6435271..cd4dd5bfd9d7 100644
--- a/mysql-test/r/information_schema_inno.result
+++ b/mysql-test/r/information_schema_inno.result
@@ -7,13 +7,13 @@ CREATE TABLE t3 (id INT PRIMARY KEY, t2_id INT, INDEX par_ind (t2_id),
FOREIGN KEY (id, t2_id) REFERENCES t2(t1_id, id) ON DELETE CASCADE) ENGINE=INNODB;
select * from information_schema.TABLE_CONSTRAINTS where
TABLE_SCHEMA= "test" order by TABLE_SCHEMA, TABLE_NAME, CONSTRAINT_NAME;
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
-def test PRIMARY test t1 PRIMARY KEY
-def test PRIMARY test t2 PRIMARY KEY
-def test t2_ibfk_1 test t2 FOREIGN KEY
-def test t2_ibfk_2 test t2 FOREIGN KEY
-def test PRIMARY test t3 PRIMARY KEY
-def test t3_ibfk_1 test t3 FOREIGN KEY
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
+def test PRIMARY test t1 PRIMARY KEY YES
+def test PRIMARY test t2 PRIMARY KEY YES
+def test t2_ibfk_1 test t2 FOREIGN KEY YES
+def test t2_ibfk_2 test t2 FOREIGN KEY YES
+def test PRIMARY test t3 PRIMARY KEY YES
+def test t3_ibfk_1 test t3 FOREIGN KEY YES
select * from information_schema.KEY_COLUMN_USAGE where
TABLE_SCHEMA= "test" order by TABLE_SCHEMA, TABLE_NAME, CONSTRAINT_NAME, COLUMN_NAME;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
diff --git a/mysql-test/r/information_schema_keywords.result b/mysql-test/r/information_schema_keywords.result
index 6372616f9073..85831b7cc045 100644
--- a/mysql-test/r/information_schema_keywords.result
+++ b/mysql-test/r/information_schema_keywords.result
@@ -156,6 +156,7 @@ ENCLOSED 1
ENCRYPTION 0
END 0
ENDS 0
+ENFORCED 0
ENGINE 0
ENGINES 0
ENUM 0
diff --git a/mysql-test/r/mysqlshow_ci.result b/mysql-test/r/mysqlshow_ci.result
index 0f04465635a6..c85882812400 100644
--- a/mysql-test/r/mysqlshow_ci.result
+++ b/mysql-test/r/mysqlshow_ci.result
@@ -80,6 +80,7 @@ Database: information_schema
| Tables |
+---------------------------------------+
| CHARACTER_SETS |
+| CHECK_CONSTRAINTS |
| COLLATION_CHARACTER_SET_APPLICABILITY |
| COLLATIONS |
| COLUMN_PRIVILEGES |
@@ -151,6 +152,7 @@ Database: INFORMATION_SCHEMA
| Tables |
+---------------------------------------+
| CHARACTER_SETS |
+| CHECK_CONSTRAINTS |
| COLLATION_CHARACTER_SET_APPLICABILITY |
| COLLATIONS |
| COLUMN_PRIVILEGES |
diff --git a/mysql-test/r/mysqlshow_cs.result b/mysql-test/r/mysqlshow_cs.result
index 2b825a151511..1c470c184236 100644
--- a/mysql-test/r/mysqlshow_cs.result
+++ b/mysql-test/r/mysqlshow_cs.result
@@ -80,6 +80,7 @@ Database: information_schema
| Tables |
+---------------------------------------+
| CHARACTER_SETS |
+| CHECK_CONSTRAINTS |
| COLLATIONS |
| COLLATION_CHARACTER_SET_APPLICABILITY |
| COLUMNS |
@@ -151,6 +152,7 @@ Database: INFORMATION_SCHEMA
| Tables |
+---------------------------------------+
| CHARACTER_SETS |
+| CHECK_CONSTRAINTS |
| COLLATIONS |
| COLLATION_CHARACTER_SET_APPLICABILITY |
| COLUMNS |
diff --git a/mysql-test/r/partition_locking.result b/mysql-test/r/partition_locking.result
index 18a216ffb168..2f2f15483009 100644
--- a/mysql-test/r/partition_locking.result
+++ b/mysql-test/r/partition_locking.result
@@ -2748,7 +2748,7 @@ FLUSH STATUS;
CREATE VIEW v1_25 AS SELECT a, b FROM t1 PARTITION (p2, p5);
VARIABLE_NAME VARIABLE_VALUE
Handler_commit 7
-Handler_external_lock 68
+Handler_external_lock 72
Handler_prepare 4
Handler_read_key 3
Handler_write 4
@@ -2757,7 +2757,7 @@ FLUSH STATUS;
CREATE VIEW v1_25_check AS SELECT a, b FROM t1 PARTITION (p2, p5) t1_alias WITH CHECK OPTION;
VARIABLE_NAME VARIABLE_VALUE
Handler_commit 7
-Handler_external_lock 68
+Handler_external_lock 72
Handler_prepare 4
Handler_read_key 3
Handler_write 4
@@ -2766,7 +2766,7 @@ FLUSH STATUS;
CREATE VIEW v1_9 AS SELECT a, b FROM t1 WHERE a = 9;
VARIABLE_NAME VARIABLE_VALUE
Handler_commit 7
-Handler_external_lock 68
+Handler_external_lock 72
Handler_prepare 4
Handler_read_key 3
Handler_write 4
@@ -2775,7 +2775,7 @@ FLUSH STATUS;
CREATE VIEW v1_9_check AS SELECT a, b FROM t1 WHERE a = 9 WITH CHECK OPTION;
VARIABLE_NAME VARIABLE_VALUE
Handler_commit 7
-Handler_external_lock 68
+Handler_external_lock 72
Handler_prepare 4
Handler_read_key 3
Handler_write 4
@@ -2784,7 +2784,7 @@ FLUSH STATUS;
CREATE VIEW v1_all AS SELECT a, b FROM t1;
VARIABLE_NAME VARIABLE_VALUE
Handler_commit 7
-Handler_external_lock 68
+Handler_external_lock 72
Handler_prepare 4
Handler_read_key 3
Handler_write 4
@@ -2975,7 +2975,7 @@ FLUSH STATUS;
CREATE TABLE t3 SELECT a, b FROM t1 WHERE a IN (0, 1, 13, 113, 26);
VARIABLE_NAME VARIABLE_VALUE
Handler_commit 12
-Handler_external_lock 150
+Handler_external_lock 160
Handler_prepare 4
Handler_read_first 3
Handler_read_key 24
@@ -2993,7 +2993,7 @@ FLUSH STATUS;
CREATE TABLE t3 SELECT a, b FROM t1 WHERE b LIKE 'First%';
VARIABLE_NAME VARIABLE_VALUE
Handler_commit 12
-Handler_external_lock 150
+Handler_external_lock 160
Handler_prepare 4
Handler_read_key 34
Handler_read_next 5
@@ -4645,7 +4645,7 @@ FLUSH STATUS;
ALTER TABLE t2 EXCHANGE PARTITION p1 WITH TABLE t1;
VARIABLE_NAME VARIABLE_VALUE
Handler_commit 20
-Handler_external_lock 128
+Handler_external_lock 132
Handler_prepare 4
Handler_read_first 1
Handler_read_key 66
@@ -4862,7 +4862,7 @@ FLUSH STATUS;
CREATE TABLE t2 SELECT * FROM t1 PARTITION (p1, p2);
VARIABLE_NAME VARIABLE_VALUE
Handler_commit 11
-Handler_external_lock 148
+Handler_external_lock 158
Handler_prepare 4
Handler_read_first 2
Handler_read_key 20
@@ -4880,7 +4880,7 @@ FLUSH STATUS;
CREATE TABLE t2 SELECT * FROM t1 WHERE a IN (1, 3, 9);
VARIABLE_NAME VARIABLE_VALUE
Handler_commit 11
-Handler_external_lock 148
+Handler_external_lock 158
Handler_prepare 4
Handler_read_first 2
Handler_read_key 20
diff --git a/mysql-test/r/partition_locking_ps_protocol.result b/mysql-test/r/partition_locking_ps_protocol.result
index a5ea3513aa01..22d256f0edb2 100644
--- a/mysql-test/r/partition_locking_ps_protocol.result
+++ b/mysql-test/r/partition_locking_ps_protocol.result
@@ -16,7 +16,7 @@ FLUSH STATUS;
CREATE TABLE t2 SELECT a, b FROM t1 WHERE a in (0, 1, 13, 113);
VARIABLE_NAME VARIABLE_VALUE
Handler_commit 13
-Handler_external_lock 179
+Handler_external_lock 191
Handler_prepare 4
Handler_read_first 3
Handler_read_key 25
@@ -33,7 +33,7 @@ FLUSH STATUS;
CREATE TABLE t2 SELECT a, b FROM t1 WHERE b LIKE 'First%';
VARIABLE_NAME VARIABLE_VALUE
Handler_commit 13
-Handler_external_lock 179
+Handler_external_lock 191
Handler_prepare 4
Handler_read_key 35
Handler_read_next 5
@@ -54,7 +54,7 @@ FLUSH STATUS;
CREATE TABLE t2 SELECT * FROM t1 PARTITION (p1, p2);
VARIABLE_NAME VARIABLE_VALUE
Handler_commit 12
-Handler_external_lock 177
+Handler_external_lock 189
Handler_prepare 4
Handler_read_first 2
Handler_read_key 21
@@ -72,7 +72,7 @@ FLUSH STATUS;
CREATE TABLE t2 SELECT * FROM t1 WHERE a IN (1, 3, 9);
VARIABLE_NAME VARIABLE_VALUE
Handler_commit 12
-Handler_external_lock 177
+Handler_external_lock 189
Handler_prepare 4
Handler_read_first 2
Handler_read_key 21
diff --git a/mysql-test/r/show_check_ci.result b/mysql-test/r/show_check_ci.result
index 5758f2ab00d8..c14c10f77a28 100644
--- a/mysql-test/r/show_check_ci.result
+++ b/mysql-test/r/show_check_ci.result
@@ -272,6 +272,7 @@ create table t1(n int);
insert into t1 values (1);
show open tables;
Database Table In_use Name_locked
+mysql check_constraints 0 0
mysql column_statistics 0 0
mysql column_type_elements 0 0
mysql columns 0 0
@@ -1738,8 +1739,8 @@ TABLE_SCHEMA TABLE_NAME INDEX_NAME COLUMN_NAME
test t1 c2d c2
test t1 PRIMARY c1
SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE table_name='t1';
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
-def test PRIMARY test t1 PRIMARY KEY
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
+def test PRIMARY test t1 PRIMARY KEY YES
SELECT constraint_schema, constraint_name, table_name, column_name FROM
INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE table_name='t1';
constraint_schema constraint_name table_name column_name
diff --git a/mysql-test/r/show_check_cs.result b/mysql-test/r/show_check_cs.result
index 2ed7f347d102..dc3e91e1e102 100644
--- a/mysql-test/r/show_check_cs.result
+++ b/mysql-test/r/show_check_cs.result
@@ -272,6 +272,7 @@ create table t1(n int);
insert into t1 values (1);
show open tables;
Database Table In_use Name_locked
+mysql check_constraints 0 0
mysql column_statistics 0 0
mysql column_type_elements 0 0
mysql columns 0 0
@@ -1736,8 +1737,8 @@ TABLE_SCHEMA TABLE_NAME INDEX_NAME COLUMN_NAME
test t1 c2d c2
test t1 PRIMARY c1
SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE table_name='t1';
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
-def test PRIMARY test t1 PRIMARY KEY
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
+def test PRIMARY test t1 PRIMARY KEY YES
SELECT constraint_schema, constraint_name, table_name, column_name FROM
INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE table_name='t1';
constraint_schema constraint_name table_name column_name
diff --git a/mysql-test/r/slow_log_extra.result b/mysql-test/r/slow_log_extra.result
index 4ad3af17da29..c9624096f43f 100644
--- a/mysql-test/r/slow_log_extra.result
+++ b/mysql-test/r/slow_log_extra.result
@@ -69,11 +69,11 @@ DROP TABLE mslow;
# We strip off time related fields (non-deterministic) and
# verify the rest are correct.
#
-Rows_sent: 0 Rows_examined: 0 Thread_id: 0 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 11 Read_first: 0 Read_last: 0 Read_key: 4 Read_next: 0 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 0 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0
-Rows_sent: 0 Rows_examined: 0 Thread_id: 0 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 11 Read_first: 0 Read_last: 0 Read_key: 4 Read_next: 0 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 0 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0
+Rows_sent: 0 Rows_examined: 0 Thread_id: 0 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 11 Read_first: 0 Read_last: 0 Read_key: 5 Read_next: 0 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 0 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0
+Rows_sent: 0 Rows_examined: 0 Thread_id: 0 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 11 Read_first: 0 Read_last: 0 Read_key: 5 Read_next: 0 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 0 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0
Rows_sent: 0 Rows_examined: 0 Thread_id: 0 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 11 Read_first: 0 Read_last: 0 Read_key: 17 Read_next: 0 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 0 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0
-Rows_sent: 0 Rows_examined: 0 Thread_id: 0 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 50 Read_first: 0 Read_last: 0 Read_key: 10 Read_next: 9 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 0 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0
-Rows_sent: 0 Rows_examined: 0 Thread_id: 0 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 11 Read_first: 0 Read_last: 0 Read_key: 11 Read_next: 1 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 0 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0
+Rows_sent: 0 Rows_examined: 0 Thread_id: 0 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 50 Read_first: 0 Read_last: 0 Read_key: 11 Read_next: 9 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 0 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0
+Rows_sent: 0 Rows_examined: 0 Thread_id: 0 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 11 Read_first: 0 Read_last: 0 Read_key: 12 Read_next: 1 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 0 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0
Rows_sent: 0 Rows_examined: 0 Thread_id: 0 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 50 Read_first: 0 Read_last: 0 Read_key: 1 Read_next: 0 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 0 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0
Rows_sent: 8 Rows_examined: 8 Thread_id: 0 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 106 Read_first: 1 Read_last: 0 Read_key: 1 Read_next: 0 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 9 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0
Rows_sent: 8 Rows_examined: 8 Thread_id: 0 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 106 Read_first: 1 Read_last: 0 Read_key: 1 Read_next: 0 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 9 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0
diff --git a/mysql-test/r/status.result b/mysql-test/r/status.result
index 73b3191feb4b..8d691460838e 100644
--- a/mysql-test/r/status.result
+++ b/mysql-test/r/status.result
@@ -263,7 +263,7 @@ i
show status like 'table_open_cache_%';
Variable_name Value
Table_open_cache_hits 1
-Table_open_cache_misses 15
+Table_open_cache_misses 16
Table_open_cache_overflows 0
# The second statement accessing the same table should
# result in table cache hit.
@@ -272,23 +272,23 @@ i
show status like 'table_open_cache_%';
Variable_name Value
Table_open_cache_hits 2
-Table_open_cache_misses 15
+Table_open_cache_misses 16
Table_open_cache_overflows 0
# Again table cache miss if accessing different table.
select * from t2;
j
show status like 'table_open_cache_%';
Variable_name Value
-Table_open_cache_hits 17
-Table_open_cache_misses 16
+Table_open_cache_hits 18
+Table_open_cache_misses 17
Table_open_cache_overflows 0
# And cache hit then accessing it second time.
select * from t2;
j
show status like 'table_open_cache_%';
Variable_name Value
-Table_open_cache_hits 18
-Table_open_cache_misses 16
+Table_open_cache_hits 19
+Table_open_cache_misses 17
Table_open_cache_overflows 0
# The below statement should result in 2 cache hits and
# 4 cache misses since it needs 6 table instances in total.
@@ -296,8 +296,8 @@ select * from t1 as a, t2 as b, t1 as c, t2 as d, t1 as e, t2 as f;
i j i j i j
show status like 'table_open_cache_%';
Variable_name Value
-Table_open_cache_hits 20
-Table_open_cache_misses 20
+Table_open_cache_hits 21
+Table_open_cache_misses 21
Table_open_cache_overflows 0
# Reduce size of table cache to check that status
# variable tracking cache overflows works.
@@ -310,18 +310,18 @@ select * from t1;
i
show status like 'table_open_cache_%';
Variable_name Value
-Table_open_cache_hits 21
-Table_open_cache_misses 20
-Table_open_cache_overflows 18
+Table_open_cache_hits 22
+Table_open_cache_misses 21
+Table_open_cache_overflows 19
# This statement should result in 4 cache hits, 2 cache misses/
# overflows.
select * from t1 as a, t2 as b, t1 as c, t2 as d, t1 as e, t2 as f;
i j i j i j
show status like 'table_open_cache_%';
Variable_name Value
-Table_open_cache_hits 24
-Table_open_cache_misses 23
-Table_open_cache_overflows 21
+Table_open_cache_hits 25
+Table_open_cache_misses 24
+Table_open_cache_overflows 22
# Finally, the below statement should result in 1 cache miss
# and 1 overflow since it accesses table which is not yet in
# cache and table cache is full.
@@ -329,9 +329,9 @@ select * from t3;
k
show status like 'table_open_cache_%';
Variable_name Value
-Table_open_cache_hits 24
-Table_open_cache_misses 39
-Table_open_cache_overflows 37
+Table_open_cache_hits 25
+Table_open_cache_misses 41
+Table_open_cache_overflows 39
# Cleanup
set @@global.table_open_cache= @old_table_open_cache;
drop tables t1, t2, t3;
diff --git a/mysql-test/r/temptable.result b/mysql-test/r/temptable.result
index 745344f7a4da..22986744e4db 100644
--- a/mysql-test/r/temptable.result
+++ b/mysql-test/r/temptable.result
@@ -4,41 +4,41 @@ USE temptable_test;
SELECT * FROM information_schema.table_constraints
WHERE table_schema = 'mysql' AND table_name != 'ndb_binlog_index'
ORDER BY table_schema,table_name,constraint_name COLLATE utf8_general_ci;
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
-def mysql PRIMARY mysql columns_priv PRIMARY KEY
-def mysql PRIMARY mysql component PRIMARY KEY
-def mysql PRIMARY mysql db PRIMARY KEY
-def mysql PRIMARY mysql default_roles PRIMARY KEY
-def mysql PRIMARY mysql engine_cost PRIMARY KEY
-def mysql PRIMARY mysql func PRIMARY KEY
-def mysql PRIMARY mysql global_grants PRIMARY KEY
-def mysql PRIMARY mysql gtid_executed PRIMARY KEY
-def mysql PRIMARY mysql help_category PRIMARY KEY
-def mysql PRIMARY mysql help_keyword PRIMARY KEY
-def mysql PRIMARY mysql help_relation PRIMARY KEY
-def mysql PRIMARY mysql help_topic PRIMARY KEY
-def mysql PRIMARY mysql innodb_index_stats PRIMARY KEY
-def mysql PRIMARY mysql innodb_table_stats PRIMARY KEY
-def mysql PRIMARY mysql password_history PRIMARY KEY
-def mysql PRIMARY mysql plugin PRIMARY KEY
-def mysql PRIMARY mysql procs_priv PRIMARY KEY
-def mysql PRIMARY mysql proxies_priv PRIMARY KEY
-def mysql PRIMARY mysql role_edges PRIMARY KEY
-def mysql PRIMARY mysql server_cost PRIMARY KEY
-def mysql PRIMARY mysql servers PRIMARY KEY
-def mysql PRIMARY mysql slave_master_info PRIMARY KEY
-def mysql PRIMARY mysql slave_relay_log_info PRIMARY KEY
-def mysql PRIMARY mysql slave_worker_info PRIMARY KEY
-def mysql PRIMARY mysql tables_priv PRIMARY KEY
-def mysql PRIMARY mysql time_zone PRIMARY KEY
-def mysql PRIMARY mysql time_zone_leap_second PRIMARY KEY
-def mysql PRIMARY mysql time_zone_name PRIMARY KEY
-def mysql PRIMARY mysql time_zone_transition PRIMARY KEY
-def mysql PRIMARY mysql time_zone_transition_type PRIMARY KEY
-def mysql PRIMARY mysql user PRIMARY KEY
-def mysql name mysql help_category UNIQUE
-def mysql name mysql help_keyword UNIQUE
-def mysql name mysql help_topic UNIQUE
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
+def mysql PRIMARY mysql columns_priv PRIMARY KEY YES
+def mysql PRIMARY mysql component PRIMARY KEY YES
+def mysql PRIMARY mysql db PRIMARY KEY YES
+def mysql PRIMARY mysql default_roles PRIMARY KEY YES
+def mysql PRIMARY mysql engine_cost PRIMARY KEY YES
+def mysql PRIMARY mysql func PRIMARY KEY YES
+def mysql PRIMARY mysql global_grants PRIMARY KEY YES
+def mysql PRIMARY mysql gtid_executed PRIMARY KEY YES
+def mysql PRIMARY mysql help_category PRIMARY KEY YES
+def mysql PRIMARY mysql help_keyword PRIMARY KEY YES
+def mysql PRIMARY mysql help_relation PRIMARY KEY YES
+def mysql PRIMARY mysql help_topic PRIMARY KEY YES
+def mysql PRIMARY mysql innodb_index_stats PRIMARY KEY YES
+def mysql PRIMARY mysql innodb_table_stats PRIMARY KEY YES
+def mysql PRIMARY mysql password_history PRIMARY KEY YES
+def mysql PRIMARY mysql plugin PRIMARY KEY YES
+def mysql PRIMARY mysql procs_priv PRIMARY KEY YES
+def mysql PRIMARY mysql proxies_priv PRIMARY KEY YES
+def mysql PRIMARY mysql role_edges PRIMARY KEY YES
+def mysql PRIMARY mysql server_cost PRIMARY KEY YES
+def mysql PRIMARY mysql servers PRIMARY KEY YES
+def mysql PRIMARY mysql slave_master_info PRIMARY KEY YES
+def mysql PRIMARY mysql slave_relay_log_info PRIMARY KEY YES
+def mysql PRIMARY mysql slave_worker_info PRIMARY KEY YES
+def mysql PRIMARY mysql tables_priv PRIMARY KEY YES
+def mysql PRIMARY mysql time_zone PRIMARY KEY YES
+def mysql PRIMARY mysql time_zone_leap_second PRIMARY KEY YES
+def mysql PRIMARY mysql time_zone_name PRIMARY KEY YES
+def mysql PRIMARY mysql time_zone_transition PRIMARY KEY YES
+def mysql PRIMARY mysql time_zone_transition_type PRIMARY KEY YES
+def mysql PRIMARY mysql user PRIMARY KEY YES
+def mysql name mysql help_category UNIQUE YES
+def mysql name mysql help_keyword UNIQUE YES
+def mysql name mysql help_topic UNIQUE YES
# Test 02
SET optimizer_switch = "derived_merge=off";
CREATE TABLE t1 (
diff --git a/mysql-test/std_data/dd/sdi/innodb_index_debug/t1.json b/mysql-test/std_data/dd/sdi/innodb_index_debug/t1.json
index c4f4687b1dc9..6cacfdd644ba 100644
--- a/mysql-test/std_data/dd/sdi/innodb_index_debug/t1.json
+++ b/mysql-test/std_data/dd/sdi/innodb_index_debug/t1.json
@@ -263,6 +263,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255
}
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/ibdata1.json b/mysql-test/std_data/dd/sdi/innodb_sdi/ibdata1.json
index f061c9e6aac4..67685831d4af 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/ibdata1.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/ibdata1.json
@@ -505,6 +505,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255,
"tablespace_ref": "innodb_system"
@@ -691,6 +692,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255,
"tablespace_ref": "innodb_system"
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/mysql.json b/mysql-test/std_data/dd/sdi/innodb_sdi/mysql.json
index 71fce98a1193..cd68efd1bac4 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/mysql.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/mysql.json
@@ -221,6 +221,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -491,6 +492,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -887,6 +889,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -1367,6 +1370,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -1918,6 +1922,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -2301,6 +2306,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -2773,6 +2779,560 @@
]
}
],
+ "check_constraints": [],
+ "partitions": [],
+ "collation_id": X,
+ "tablespace_ref": "mysql"
+ }
+}
+}
+,
+{
+ "type": 1,
+ "id": X,
+ "object":
+ {
+ "mysqld_version_id": X,
+ "dd_version": X,
+ "sdi_version": 1,
+ "dd_object_type": "Table",
+ "dd_object": {
+ "name": "check_constraints",
+ "mysql_version_id": X,
+ "created": NNN,
+ "last_altered": NNN,
+ "hidden": 2,
+ "options": "avg_row_length=0;explicit_tablespace=1;key_block_size=0;keys_disabled=0;pack_record=1;row_type=2;stats_auto_recalc=0;stats_persistent=0;stats_sample_pages=0;",
+ "columns": [
+ {
+ "name": "id",
+ "type": 9,
+ "is_nullable": false,
+ "is_zerofill": false,
+ "is_unsigned": true,
+ "is_auto_increment": true,
+ "is_virtual": false,
+ "hidden": 1,
+ "ordinal_position": 1,
+ "char_length": 20,
+ "numeric_precision": 20,
+ "numeric_scale": 0,
+ "numeric_scale_null": false,
+ "datetime_precision": 0,
+ "datetime_precision_null": 1,
+ "has_no_default": false,
+ "default_value_null": false,
+ "srs_id_null": true,
+ "srs_id": 0,
+ "default_value": "",
+ "default_value_utf8_null": true,
+ "default_value_utf8": "",
+ "default_option": "",
+ "update_option": "",
+ "comment": "",
+ "generation_expression": "",
+ "generation_expression_utf8": "",
+ "options": "interval_count=0;",
+ "se_private_data": "table_id=X",
+ "column_key": 2,
+ "column_type_utf8": "bigint(20) unsigned",
+ "elements": [],
+ "collation_id": X,
+ "is_explicit_collation": false
+ },
+ {
+ "name": "schema_id",
+ "type": 9,
+ "is_nullable": false,
+ "is_zerofill": false,
+ "is_unsigned": true,
+ "is_auto_increment": false,
+ "is_virtual": false,
+ "hidden": 1,
+ "ordinal_position": 2,
+ "char_length": 20,
+ "numeric_precision": 20,
+ "numeric_scale": 0,
+ "numeric_scale_null": false,
+ "datetime_precision": 0,
+ "datetime_precision_null": 1,
+ "has_no_default": true,
+ "default_value_null": false,
+ "srs_id_null": true,
+ "srs_id": 0,
+ "default_value": "",
+ "default_value_utf8_null": true,
+ "default_value_utf8": "",
+ "default_option": "",
+ "update_option": "",
+ "comment": "",
+ "generation_expression": "",
+ "generation_expression_utf8": "",
+ "options": "interval_count=0;",
+ "se_private_data": "table_id=X",
+ "column_key": 4,
+ "column_type_utf8": "bigint(20) unsigned",
+ "elements": [],
+ "collation_id": X,
+ "is_explicit_collation": false
+ },
+ {
+ "name": "table_id",
+ "type": 9,
+ "is_nullable": false,
+ "is_zerofill": false,
+ "is_unsigned": true,
+ "is_auto_increment": false,
+ "is_virtual": false,
+ "hidden": 1,
+ "ordinal_position": 3,
+ "char_length": 20,
+ "numeric_precision": 20,
+ "numeric_scale": 0,
+ "numeric_scale_null": false,
+ "datetime_precision": 0,
+ "datetime_precision_null": 1,
+ "has_no_default": true,
+ "default_value_null": false,
+ "srs_id_null": true,
+ "srs_id": 0,
+ "default_value": "",
+ "default_value_utf8_null": true,
+ "default_value_utf8": "",
+ "default_option": "",
+ "update_option": "",
+ "comment": "",
+ "generation_expression": "",
+ "generation_expression_utf8": "",
+ "options": "interval_count=0;",
+ "se_private_data": "table_id=X",
+ "column_key": 4,
+ "column_type_utf8": "bigint(20) unsigned",
+ "elements": [],
+ "collation_id": X,
+ "is_explicit_collation": false
+ },
+ {
+ "name": "name",
+ "type": 16,
+ "is_nullable": false,
+ "is_zerofill": false,
+ "is_unsigned": false,
+ "is_auto_increment": false,
+ "is_virtual": false,
+ "hidden": 1,
+ "ordinal_position": 4,
+ "char_length": 192,
+ "numeric_precision": 0,
+ "numeric_scale": 0,
+ "numeric_scale_null": true,
+ "datetime_precision": 0,
+ "datetime_precision_null": 1,
+ "has_no_default": true,
+ "default_value_null": false,
+ "srs_id_null": true,
+ "srs_id": 0,
+ "default_value": "",
+ "default_value_utf8_null": true,
+ "default_value_utf8": "",
+ "default_option": "",
+ "update_option": "",
+ "comment": "",
+ "generation_expression": "",
+ "generation_expression_utf8": "",
+ "options": "interval_count=0;",
+ "se_private_data": "table_id=X",
+ "column_key": 1,
+ "column_type_utf8": "varchar(64)",
+ "elements": [],
+ "collation_id": X,
+ "is_explicit_collation": true
+ },
+ {
+ "name": "enforced",
+ "type": 22,
+ "is_nullable": false,
+ "is_zerofill": false,
+ "is_unsigned": false,
+ "is_auto_increment": false,
+ "is_virtual": false,
+ "hidden": 1,
+ "ordinal_position": 5,
+ "char_length": 9,
+ "numeric_precision": 0,
+ "numeric_scale": 0,
+ "numeric_scale_null": true,
+ "datetime_precision": 0,
+ "datetime_precision_null": 1,
+ "has_no_default": true,
+ "default_value_null": false,
+ "srs_id_null": true,
+ "srs_id": 0,
+ "default_value": "",
+ "default_value_utf8_null": true,
+ "default_value_utf8": "",
+ "default_option": "",
+ "update_option": "",
+ "comment": "",
+ "generation_expression": "",
+ "generation_expression_utf8": "",
+ "options": "interval_count=2;",
+ "se_private_data": "table_id=X",
+ "column_key": 1,
+ "column_type_utf8": "enum('NO','YES')",
+ "elements": [
+ {
+ "name": "Tk8=", "decoded-name": "NO",
+ "index": 1
+ },
+ {
+ "name": "WUVT", "decoded-name": "YES",
+ "index": 2
+ }
+ ],
+ "collation_id": X,
+ "is_explicit_collation": false
+ },
+ {
+ "name": "check_clause",
+ "type": 26,
+ "is_nullable": false,
+ "is_zerofill": false,
+ "is_unsigned": false,
+ "is_auto_increment": false,
+ "is_virtual": false,
+ "hidden": 1,
+ "ordinal_position": 6,
+ "char_length": 4294967295,
+ "numeric_precision": 0,
+ "numeric_scale": 0,
+ "numeric_scale_null": true,
+ "datetime_precision": 0,
+ "datetime_precision_null": 1,
+ "has_no_default": true,
+ "default_value_null": false,
+ "srs_id_null": true,
+ "srs_id": 0,
+ "default_value": "",
+ "default_value_utf8_null": true,
+ "default_value_utf8": "",
+ "default_option": "",
+ "update_option": "",
+ "comment": "",
+ "generation_expression": "",
+ "generation_expression_utf8": "",
+ "options": "interval_count=0;",
+ "se_private_data": "table_id=X",
+ "column_key": 1,
+ "column_type_utf8": "longblob",
+ "elements": [],
+ "collation_id": X,
+ "is_explicit_collation": true
+ },
+ {
+ "name": "check_clause_utf8",
+ "type": 26,
+ "is_nullable": false,
+ "is_zerofill": false,
+ "is_unsigned": false,
+ "is_auto_increment": false,
+ "is_virtual": false,
+ "hidden": 1,
+ "ordinal_position": 7,
+ "char_length": 4294967295,
+ "numeric_precision": 0,
+ "numeric_scale": 0,
+ "numeric_scale_null": true,
+ "datetime_precision": 0,
+ "datetime_precision_null": 1,
+ "has_no_default": true,
+ "default_value_null": false,
+ "srs_id_null": true,
+ "srs_id": 0,
+ "default_value": "",
+ "default_value_utf8_null": true,
+ "default_value_utf8": "",
+ "default_option": "",
+ "update_option": "",
+ "comment": "",
+ "generation_expression": "",
+ "generation_expression_utf8": "",
+ "options": "interval_count=0;",
+ "se_private_data": "table_id=X",
+ "column_key": 1,
+ "column_type_utf8": "longtext",
+ "elements": [],
+ "collation_id": X,
+ "is_explicit_collation": false
+ },
+ {
+ "name": "DB_TRX_ID",
+ "type": 10,
+ "is_nullable": false,
+ "is_zerofill": false,
+ "is_unsigned": false,
+ "is_auto_increment": false,
+ "is_virtual": false,
+ "hidden": 2,
+ "ordinal_position": 8,
+ "char_length": 6,
+ "numeric_precision": 0,
+ "numeric_scale": 0,
+ "numeric_scale_null": true,
+ "datetime_precision": 0,
+ "datetime_precision_null": 1,
+ "has_no_default": false,
+ "default_value_null": true,
+ "srs_id_null": true,
+ "srs_id": 0,
+ "default_value": "",
+ "default_value_utf8_null": true,
+ "default_value_utf8": "",
+ "default_option": "",
+ "update_option": "",
+ "comment": "",
+ "generation_expression": "",
+ "generation_expression_utf8": "",
+ "options": "",
+ "se_private_data": "table_id=X",
+ "column_key": 1,
+ "column_type_utf8": "",
+ "elements": [],
+ "collation_id": X,
+ "is_explicit_collation": false
+ },
+ {
+ "name": "DB_ROLL_PTR",
+ "type": 9,
+ "is_nullable": false,
+ "is_zerofill": false,
+ "is_unsigned": false,
+ "is_auto_increment": false,
+ "is_virtual": false,
+ "hidden": 2,
+ "ordinal_position": 9,
+ "char_length": 7,
+ "numeric_precision": 0,
+ "numeric_scale": 0,
+ "numeric_scale_null": true,
+ "datetime_precision": 0,
+ "datetime_precision_null": 1,
+ "has_no_default": false,
+ "default_value_null": true,
+ "srs_id_null": true,
+ "srs_id": 0,
+ "default_value": "",
+ "default_value_utf8_null": true,
+ "default_value_utf8": "",
+ "default_option": "",
+ "update_option": "",
+ "comment": "",
+ "generation_expression": "",
+ "generation_expression_utf8": "",
+ "options": "",
+ "se_private_data": "table_id=X",
+ "column_key": 1,
+ "column_type_utf8": "",
+ "elements": [],
+ "collation_id": X,
+ "is_explicit_collation": false
+ }
+ ],
+ "schema_ref": "mysql",
+ "se_private_id":NNN,
+ "engine": "InnoDB",
+ "last_checked_for_upgrade_version_id": X,
+ "comment": "",
+ "se_private_data": "autoinc=0;version=0;",
+ "row_format": 2,
+ "partition_type": 0,
+ "partition_expression": "",
+ "partition_expression_utf8": "",
+ "default_partitioning": 0,
+ "subpartition_type": 0,
+ "subpartition_expression": "",
+ "subpartition_expression_utf8": "",
+ "default_subpartitioning": 0,
+ "indexes": [
+ {
+ "name": "PRIMARY",
+ "hidden": false,
+ "is_generated": false,
+ "ordinal_position": 1,
+ "comment": "",
+ "options": "flags=0;",
+ "se_private_data": "id=A;root=B;space_id=C;table_id=D;trx_id=E",
+ "type": 1,
+ "algorithm": 2,
+ "is_algorithm_explicit": false,
+ "is_visible": true,
+ "engine": "InnoDB",
+ "elements": [
+ {
+ "ordinal_position": 1,
+ "length": 8,
+ "order": 2,
+ "column_opx": 0
+ },
+ {
+ "ordinal_position": 2,
+ "length": 4294967295,
+ "order": 2,
+ "column_opx": 7
+ },
+ {
+ "ordinal_position": 3,
+ "length": 4294967295,
+ "order": 2,
+ "column_opx": 8
+ },
+ {
+ "ordinal_position": 4,
+ "length": 4294967295,
+ "order": 2,
+ "column_opx": 1
+ },
+ {
+ "ordinal_position": 5,
+ "length": 4294967295,
+ "order": 2,
+ "column_opx": 2
+ },
+ {
+ "ordinal_position": 6,
+ "length": 4294967295,
+ "order": 2,
+ "column_opx": 3
+ },
+ {
+ "ordinal_position": 7,
+ "length": 4294967295,
+ "order": 2,
+ "column_opx": 4
+ },
+ {
+ "ordinal_position": 8,
+ "length": 4294967295,
+ "order": 2,
+ "column_opx": 5
+ },
+ {
+ "ordinal_position": 9,
+ "length": 4294967295,
+ "order": 2,
+ "column_opx": 6
+ }
+ ],
+ "tablespace_ref": "mysql"
+ },
+ {
+ "name": "schema_id",
+ "hidden": false,
+ "is_generated": false,
+ "ordinal_position": 2,
+ "comment": "",
+ "options": "flags=0;",
+ "se_private_data": "id=A;root=B;space_id=C;table_id=D;trx_id=E",
+ "type": 2,
+ "algorithm": 2,
+ "is_algorithm_explicit": false,
+ "is_visible": true,
+ "engine": "InnoDB",
+ "elements": [
+ {
+ "ordinal_position": 1,
+ "length": 8,
+ "order": 2,
+ "column_opx": 1
+ },
+ {
+ "ordinal_position": 2,
+ "length": 192,
+ "order": 2,
+ "column_opx": 3
+ },
+ {
+ "ordinal_position": 3,
+ "length": 4294967295,
+ "order": 2,
+ "column_opx": 0
+ }
+ ],
+ "tablespace_ref": "mysql"
+ },
+ {
+ "name": "table_id",
+ "hidden": false,
+ "is_generated": false,
+ "ordinal_position": 3,
+ "comment": "",
+ "options": "flags=0;",
+ "se_private_data": "id=A;root=B;space_id=C;table_id=D;trx_id=E",
+ "type": 2,
+ "algorithm": 2,
+ "is_algorithm_explicit": false,
+ "is_visible": true,
+ "engine": "InnoDB",
+ "elements": [
+ {
+ "ordinal_position": 1,
+ "length": 8,
+ "order": 2,
+ "column_opx": 2
+ },
+ {
+ "ordinal_position": 2,
+ "length": 192,
+ "order": 2,
+ "column_opx": 3
+ },
+ {
+ "ordinal_position": 3,
+ "length": 4294967295,
+ "order": 2,
+ "column_opx": 0
+ }
+ ],
+ "tablespace_ref": "mysql"
+ }
+ ],
+ "foreign_keys": [
+ {
+ "name": "check_constraints_ibfk_1",
+ "match_option": 1,
+ "update_rule": 1,
+ "delete_rule": 1,
+ "unique_constraint_name": "",
+ "referenced_table_catalog_name": "def",
+ "referenced_table_schema_name": "mysql",
+ "referenced_table_name": "schemata",
+ "elements": [
+ {
+ "column_opx": 1,
+ "ordinal_position": 1,
+ "referenced_column_name": "id"
+ }
+ ]
+ },
+ {
+ "name": "check_constraints_ibfk_2",
+ "match_option": 1,
+ "update_rule": 1,
+ "delete_rule": 1,
+ "unique_constraint_name": "",
+ "referenced_table_catalog_name": "def",
+ "referenced_table_schema_name": "mysql",
+ "referenced_table_name": "tables",
+ "elements": [
+ {
+ "column_opx": 2,
+ "ordinal_position": 1,
+ "referenced_column_name": "id"
+ }
+ ]
+ }
+ ],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -3296,6 +3856,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -3876,6 +4437,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -4164,6 +4726,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -5903,6 +6466,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -7482,6 +8046,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -7905,6 +8470,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -8737,6 +9303,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -9257,6 +9824,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -9727,6 +10295,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -10123,6 +10692,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -11038,6 +11608,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -11326,6 +11897,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -12337,6 +12909,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -12813,6 +13386,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -14715,6 +15289,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -15252,6 +15827,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -15910,6 +16486,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -16282,6 +16859,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -17180,6 +17758,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -17870,6 +18449,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -20017,6 +20597,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -20382,6 +20963,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -20807,6 +21389,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -22075,6 +22658,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -22446,6 +23030,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -22817,6 +23402,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -24091,6 +24677,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -26700,6 +27287,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -27012,6 +27600,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -27375,6 +27964,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -27696,6 +28286,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -28008,6 +28599,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -28329,6 +28921,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -28557,6 +29150,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -29079,6 +29673,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -29676,6 +30271,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -30131,6 +30727,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -30556,6 +31153,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -30897,6 +31495,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -31125,6 +31724,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -31382,6 +31982,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -31610,6 +32211,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -31847,6 +32449,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -32117,6 +32720,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -32471,6 +33075,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -32699,6 +33304,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -33254,6 +33860,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -33524,6 +34131,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -34046,6 +34654,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -35324,6 +35933,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -36014,6 +36624,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -36284,6 +36895,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -36632,6 +37244,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -37064,6 +37677,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -37549,6 +38163,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/t1.json b/mysql-test/std_data/dd/sdi/innodb_sdi/t1.json
index 6cc5ef4e5daf..19e5b3428ca5 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/t1.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/t1.json
@@ -221,6 +221,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255
}
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/t10.json b/mysql-test/std_data/dd/sdi/innodb_sdi/t10.json
index 922c491a8b75..913013a6f5f0 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/t10.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/t10.json
@@ -389,6 +389,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255
}
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/t10_altered.json b/mysql-test/std_data/dd/sdi/innodb_sdi/t10_altered.json
index 029b4a22e7c2..8a55f34feb5a 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/t10_altered.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/t10_altered.json
@@ -389,6 +389,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255
}
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/t11.json b/mysql-test/std_data/dd/sdi/innodb_sdi/t11.json
index ed7bdeab94ef..128f88bfbb31 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/t11.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/t11.json
@@ -710,6 +710,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255
}
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/t11_altered.json b/mysql-test/std_data/dd/sdi/innodb_sdi/t11_altered.json
index 71694f16bc29..a557580b6a1f 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/t11_altered.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/t11_altered.json
@@ -645,6 +645,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255
}
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/t12#p#p0.json b/mysql-test/std_data/dd/sdi/innodb_sdi/t12#p#p0.json
index 76dd307c98fa..7a7212eda993 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/t12#p#p0.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/t12#p#p0.json
@@ -298,6 +298,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [
{
"name": "p0",
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/t13.json b/mysql-test/std_data/dd/sdi/innodb_sdi/t13.json
index 032966418817..d93f405aaa2d 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/t13.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/t13.json
@@ -392,6 +392,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255
}
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/t14.json b/mysql-test/std_data/dd/sdi/innodb_sdi/t14.json
index 8efdf41e1b81..a6dc638740df 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/t14.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/t14.json
@@ -315,6 +315,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255
}
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/t15.json b/mysql-test/std_data/dd/sdi/innodb_sdi/t15.json
index 6e9718592529..d12bf5e40349 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/t15.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/t15.json
@@ -292,6 +292,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255
}
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/t18.json b/mysql-test/std_data/dd/sdi/innodb_sdi/t18.json
index 1641024dbf7f..34916902e742 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/t18.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/t18.json
@@ -263,6 +263,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255
}
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/t1_altered.json b/mysql-test/std_data/dd/sdi/innodb_sdi/t1_altered.json
index 5fa90f7802cb..c87de1db1d27 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/t1_altered.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/t1_altered.json
@@ -263,6 +263,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255
}
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/t2.json b/mysql-test/std_data/dd/sdi/innodb_sdi/t2.json
index 34c3927b3662..3068b2e074a7 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/t2.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/t2.json
@@ -221,6 +221,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255
}
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/t2_altered.json b/mysql-test/std_data/dd/sdi/innodb_sdi/t2_altered.json
index ec9a8410c06b..da72232d7155 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/t2_altered.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/t2_altered.json
@@ -250,6 +250,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255
}
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/t3.json b/mysql-test/std_data/dd/sdi/innodb_sdi/t3.json
index a4347f4b9bd2..483db36fb933 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/t3.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/t3.json
@@ -369,6 +369,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255
}
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/t3_altered.json b/mysql-test/std_data/dd/sdi/innodb_sdi/t3_altered.json
index 7cb9acf0155b..037eb5361119 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/t3_altered.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/t3_altered.json
@@ -334,6 +334,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255
}
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/t4.json b/mysql-test/std_data/dd/sdi/innodb_sdi/t4.json
index 7f69c1e05506..e001ed71eb27 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/t4.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/t4.json
@@ -305,6 +305,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255
}
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/t4_altered.json b/mysql-test/std_data/dd/sdi/innodb_sdi/t4_altered.json
index e2ebcda235d0..3c805348479e 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/t4_altered.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/t4_altered.json
@@ -263,6 +263,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255
}
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/t5.json b/mysql-test/std_data/dd/sdi/innodb_sdi/t5.json
index 28401b59201b..c7900d126e81 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/t5.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/t5.json
@@ -347,6 +347,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255
}
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/t6.json b/mysql-test/std_data/dd/sdi/innodb_sdi/t6.json
index 7115a4101e4a..cf3508b22a8c 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/t6.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/t6.json
@@ -950,6 +950,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 8
}
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/t7.json b/mysql-test/std_data/dd/sdi/innodb_sdi/t7.json
index 55d860a3ec00..8606056c931d 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/t7.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/t7.json
@@ -305,6 +305,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255
}
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/ts1.json b/mysql-test/std_data/dd/sdi/innodb_sdi/ts1.json
index c25b9753f0be..8945e9cd7682 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/ts1.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/ts1.json
@@ -179,6 +179,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255,
"tablespace_ref": "ts1"
@@ -519,6 +520,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255,
"tablespace_ref": "ts1"
diff --git a/mysql-test/std_data/dd/sdi/innodb_sdi/ts1_altered.json b/mysql-test/std_data/dd/sdi/innodb_sdi/ts1_altered.json
index c25b9753f0be..8945e9cd7682 100644
--- a/mysql-test/std_data/dd/sdi/innodb_sdi/ts1_altered.json
+++ b/mysql-test/std_data/dd/sdi/innodb_sdi/ts1_altered.json
@@ -179,6 +179,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255,
"tablespace_ref": "ts1"
@@ -519,6 +520,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255,
"tablespace_ref": "ts1"
diff --git a/mysql-test/std_data/dd/sdi/upgrade/actor.json b/mysql-test/std_data/dd/sdi/upgrade/actor.json
index 77d5815b2b7a..9cad5b9a006b 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/actor.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/actor.json
@@ -334,6 +334,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 33
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/address.json b/mysql-test/std_data/dd/sdi/upgrade/address.json
index 642c4fa32969..a1a45a3ddb95 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/address.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/address.json
@@ -591,6 +591,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": 33
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/category.json b/mysql-test/std_data/dd/sdi/upgrade/category.json
index 0c5e6016eabd..852900c46e89 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/category.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/category.json
@@ -263,6 +263,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 33
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/city.json b/mysql-test/std_data/dd/sdi/upgrade/city.json
index 90378be858d8..3c91e8d17007 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/city.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/city.json
@@ -352,6 +352,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": 33
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/country.json b/mysql-test/std_data/dd/sdi/upgrade/country.json
index bc947a7faec5..f061e9e6955b 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/country.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/country.json
@@ -263,6 +263,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 33
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/customer.json b/mysql-test/std_data/dd/sdi/upgrade/customer.json
index 6aa1f3723506..799d55ed0a68 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/customer.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/customer.json
@@ -637,6 +637,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": 33
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/film.json b/mysql-test/std_data/dd/sdi/upgrade/film.json
index bce83bee0739..bff5277a04ec 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/film.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/film.json
@@ -843,6 +843,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": 33
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/film_actor.json b/mysql-test/std_data/dd/sdi/upgrade/film_actor.json
index 0d4a2680c81d..b1fa2ac41694 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/film_actor.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/film_actor.json
@@ -327,6 +327,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": 33
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/film_category.json b/mysql-test/std_data/dd/sdi/upgrade/film_category.json
index f9ca52257a24..33c89b580cf8 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/film_category.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/film_category.json
@@ -327,6 +327,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": 33
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/film_text.json b/mysql-test/std_data/dd/sdi/upgrade/film_text.json
index b488dc022e9a..64fa73ebae66 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/film_text.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/film_text.json
@@ -363,6 +363,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 33
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/geom.json b/mysql-test/std_data/dd/sdi/upgrade/geom.json
index 25f8637a0339..ed9a7455c240 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/geom.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/geom.json
@@ -376,6 +376,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 8
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/inventory.json b/mysql-test/std_data/dd/sdi/upgrade/inventory.json
index ae296c1a8e39..62455c6fe0f2 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/inventory.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/inventory.json
@@ -404,6 +404,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": 33
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/jemp.json b/mysql-test/std_data/dd/sdi/upgrade/jemp.json
index dc5cf4fde224..1a9e536abb5f 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/jemp.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/jemp.json
@@ -286,6 +286,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 8
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/language.json b/mysql-test/std_data/dd/sdi/upgrade/language.json
index 73ada505b044..a00029d02d26 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/language.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/language.json
@@ -263,6 +263,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 33
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/mysql.json b/mysql-test/std_data/dd/sdi/upgrade/mysql.json
index 6e73437ca1d7..662dcba2ff3d 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/mysql.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/mysql.json
@@ -221,6 +221,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -491,6 +492,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -887,6 +889,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -1367,6 +1370,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -1918,6 +1922,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -2301,6 +2306,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -2773,6 +2779,560 @@
]
}
],
+ "check_constraints": [],
+ "partitions": [],
+ "collation_id": X,
+ "tablespace_ref": "mysql"
+ }
+}
+}
+,
+{
+ "type": 1,
+ "id": X,
+ "object":
+ {
+ "mysqld_version_id": X,
+ "dd_version": X,
+ "sdi_version": 1,
+ "dd_object_type": "Table",
+ "dd_object": {
+ "name": "check_constraints",
+ "mysql_version_id": X,
+ "created": NNN,
+ "last_altered": NNN,
+ "hidden": 2,
+ "options": "avg_row_length=0;explicit_tablespace=1;key_block_size=0;keys_disabled=0;pack_record=1;row_type=2;stats_auto_recalc=0;stats_persistent=0;stats_sample_pages=0;",
+ "columns": [
+ {
+ "name": "id",
+ "type": 9,
+ "is_nullable": false,
+ "is_zerofill": false,
+ "is_unsigned": true,
+ "is_auto_increment": true,
+ "is_virtual": false,
+ "hidden": 1,
+ "ordinal_position": 1,
+ "char_length": 20,
+ "numeric_precision": 20,
+ "numeric_scale": 0,
+ "numeric_scale_null": false,
+ "datetime_precision": 0,
+ "datetime_precision_null": 1,
+ "has_no_default": false,
+ "default_value_null": false,
+ "srs_id_null": true,
+ "srs_id": 0,
+ "default_value": "",
+ "default_value_utf8_null": true,
+ "default_value_utf8": "",
+ "default_option": "",
+ "update_option": "",
+ "comment": "",
+ "generation_expression": "",
+ "generation_expression_utf8": "",
+ "options": "interval_count=0;",
+ "se_private_data": "table_id=X",
+ "column_key": 2,
+ "column_type_utf8": "bigint(20) unsigned",
+ "elements": [],
+ "collation_id": X,
+ "is_explicit_collation": false
+ },
+ {
+ "name": "schema_id",
+ "type": 9,
+ "is_nullable": false,
+ "is_zerofill": false,
+ "is_unsigned": true,
+ "is_auto_increment": false,
+ "is_virtual": false,
+ "hidden": 1,
+ "ordinal_position": 2,
+ "char_length": 20,
+ "numeric_precision": 20,
+ "numeric_scale": 0,
+ "numeric_scale_null": false,
+ "datetime_precision": 0,
+ "datetime_precision_null": 1,
+ "has_no_default": true,
+ "default_value_null": false,
+ "srs_id_null": true,
+ "srs_id": 0,
+ "default_value": "",
+ "default_value_utf8_null": true,
+ "default_value_utf8": "",
+ "default_option": "",
+ "update_option": "",
+ "comment": "",
+ "generation_expression": "",
+ "generation_expression_utf8": "",
+ "options": "interval_count=0;",
+ "se_private_data": "table_id=X",
+ "column_key": 4,
+ "column_type_utf8": "bigint(20) unsigned",
+ "elements": [],
+ "collation_id": X,
+ "is_explicit_collation": false
+ },
+ {
+ "name": "table_id",
+ "type": 9,
+ "is_nullable": false,
+ "is_zerofill": false,
+ "is_unsigned": true,
+ "is_auto_increment": false,
+ "is_virtual": false,
+ "hidden": 1,
+ "ordinal_position": 3,
+ "char_length": 20,
+ "numeric_precision": 20,
+ "numeric_scale": 0,
+ "numeric_scale_null": false,
+ "datetime_precision": 0,
+ "datetime_precision_null": 1,
+ "has_no_default": true,
+ "default_value_null": false,
+ "srs_id_null": true,
+ "srs_id": 0,
+ "default_value": "",
+ "default_value_utf8_null": true,
+ "default_value_utf8": "",
+ "default_option": "",
+ "update_option": "",
+ "comment": "",
+ "generation_expression": "",
+ "generation_expression_utf8": "",
+ "options": "interval_count=0;",
+ "se_private_data": "table_id=X",
+ "column_key": 4,
+ "column_type_utf8": "bigint(20) unsigned",
+ "elements": [],
+ "collation_id": X,
+ "is_explicit_collation": false
+ },
+ {
+ "name": "name",
+ "type": 16,
+ "is_nullable": false,
+ "is_zerofill": false,
+ "is_unsigned": false,
+ "is_auto_increment": false,
+ "is_virtual": false,
+ "hidden": 1,
+ "ordinal_position": 4,
+ "char_length": 192,
+ "numeric_precision": 0,
+ "numeric_scale": 0,
+ "numeric_scale_null": true,
+ "datetime_precision": 0,
+ "datetime_precision_null": 1,
+ "has_no_default": true,
+ "default_value_null": false,
+ "srs_id_null": true,
+ "srs_id": 0,
+ "default_value": "",
+ "default_value_utf8_null": true,
+ "default_value_utf8": "",
+ "default_option": "",
+ "update_option": "",
+ "comment": "",
+ "generation_expression": "",
+ "generation_expression_utf8": "",
+ "options": "interval_count=0;",
+ "se_private_data": "table_id=X",
+ "column_key": 1,
+ "column_type_utf8": "varchar(64)",
+ "elements": [],
+ "collation_id": X,
+ "is_explicit_collation": true
+ },
+ {
+ "name": "enforced",
+ "type": 22,
+ "is_nullable": false,
+ "is_zerofill": false,
+ "is_unsigned": false,
+ "is_auto_increment": false,
+ "is_virtual": false,
+ "hidden": 1,
+ "ordinal_position": 5,
+ "char_length": 9,
+ "numeric_precision": 0,
+ "numeric_scale": 0,
+ "numeric_scale_null": true,
+ "datetime_precision": 0,
+ "datetime_precision_null": 1,
+ "has_no_default": true,
+ "default_value_null": false,
+ "srs_id_null": true,
+ "srs_id": 0,
+ "default_value": "",
+ "default_value_utf8_null": true,
+ "default_value_utf8": "",
+ "default_option": "",
+ "update_option": "",
+ "comment": "",
+ "generation_expression": "",
+ "generation_expression_utf8": "",
+ "options": "interval_count=2;",
+ "se_private_data": "table_id=X",
+ "column_key": 1,
+ "column_type_utf8": "enum('NO','YES')",
+ "elements": [
+ {
+ "name": "Tk8=", "decoded-name": "NO",
+ "index": 1
+ },
+ {
+ "name": "WUVT", "decoded-name": "YES",
+ "index": 2
+ }
+ ],
+ "collation_id": X,
+ "is_explicit_collation": false
+ },
+ {
+ "name": "check_clause",
+ "type": 26,
+ "is_nullable": false,
+ "is_zerofill": false,
+ "is_unsigned": false,
+ "is_auto_increment": false,
+ "is_virtual": false,
+ "hidden": 1,
+ "ordinal_position": 6,
+ "char_length": 4294967295,
+ "numeric_precision": 0,
+ "numeric_scale": 0,
+ "numeric_scale_null": true,
+ "datetime_precision": 0,
+ "datetime_precision_null": 1,
+ "has_no_default": true,
+ "default_value_null": false,
+ "srs_id_null": true,
+ "srs_id": 0,
+ "default_value": "",
+ "default_value_utf8_null": true,
+ "default_value_utf8": "",
+ "default_option": "",
+ "update_option": "",
+ "comment": "",
+ "generation_expression": "",
+ "generation_expression_utf8": "",
+ "options": "interval_count=0;",
+ "se_private_data": "table_id=X",
+ "column_key": 1,
+ "column_type_utf8": "longblob",
+ "elements": [],
+ "collation_id": X,
+ "is_explicit_collation": true
+ },
+ {
+ "name": "check_clause_utf8",
+ "type": 26,
+ "is_nullable": false,
+ "is_zerofill": false,
+ "is_unsigned": false,
+ "is_auto_increment": false,
+ "is_virtual": false,
+ "hidden": 1,
+ "ordinal_position": 7,
+ "char_length": 4294967295,
+ "numeric_precision": 0,
+ "numeric_scale": 0,
+ "numeric_scale_null": true,
+ "datetime_precision": 0,
+ "datetime_precision_null": 1,
+ "has_no_default": true,
+ "default_value_null": false,
+ "srs_id_null": true,
+ "srs_id": 0,
+ "default_value": "",
+ "default_value_utf8_null": true,
+ "default_value_utf8": "",
+ "default_option": "",
+ "update_option": "",
+ "comment": "",
+ "generation_expression": "",
+ "generation_expression_utf8": "",
+ "options": "interval_count=0;",
+ "se_private_data": "table_id=X",
+ "column_key": 1,
+ "column_type_utf8": "longtext",
+ "elements": [],
+ "collation_id": X,
+ "is_explicit_collation": false
+ },
+ {
+ "name": "DB_TRX_ID",
+ "type": 10,
+ "is_nullable": false,
+ "is_zerofill": false,
+ "is_unsigned": false,
+ "is_auto_increment": false,
+ "is_virtual": false,
+ "hidden": 2,
+ "ordinal_position": 8,
+ "char_length": 6,
+ "numeric_precision": 0,
+ "numeric_scale": 0,
+ "numeric_scale_null": true,
+ "datetime_precision": 0,
+ "datetime_precision_null": 1,
+ "has_no_default": false,
+ "default_value_null": true,
+ "srs_id_null": true,
+ "srs_id": 0,
+ "default_value": "",
+ "default_value_utf8_null": true,
+ "default_value_utf8": "",
+ "default_option": "",
+ "update_option": "",
+ "comment": "",
+ "generation_expression": "",
+ "generation_expression_utf8": "",
+ "options": "",
+ "se_private_data": "table_id=X",
+ "column_key": 1,
+ "column_type_utf8": "",
+ "elements": [],
+ "collation_id": X,
+ "is_explicit_collation": false
+ },
+ {
+ "name": "DB_ROLL_PTR",
+ "type": 9,
+ "is_nullable": false,
+ "is_zerofill": false,
+ "is_unsigned": false,
+ "is_auto_increment": false,
+ "is_virtual": false,
+ "hidden": 2,
+ "ordinal_position": 9,
+ "char_length": 7,
+ "numeric_precision": 0,
+ "numeric_scale": 0,
+ "numeric_scale_null": true,
+ "datetime_precision": 0,
+ "datetime_precision_null": 1,
+ "has_no_default": false,
+ "default_value_null": true,
+ "srs_id_null": true,
+ "srs_id": 0,
+ "default_value": "",
+ "default_value_utf8_null": true,
+ "default_value_utf8": "",
+ "default_option": "",
+ "update_option": "",
+ "comment": "",
+ "generation_expression": "",
+ "generation_expression_utf8": "",
+ "options": "",
+ "se_private_data": "table_id=X",
+ "column_key": 1,
+ "column_type_utf8": "",
+ "elements": [],
+ "collation_id": X,
+ "is_explicit_collation": false
+ }
+ ],
+ "schema_ref": "mysql",
+ "se_private_id":NNN,
+ "engine": "InnoDB",
+ "last_checked_for_upgrade_version_id": X,
+ "comment": "",
+ "se_private_data": "autoinc=0;version=0;",
+ "row_format": 2,
+ "partition_type": 0,
+ "partition_expression": "",
+ "partition_expression_utf8": "",
+ "default_partitioning": 0,
+ "subpartition_type": 0,
+ "subpartition_expression": "",
+ "subpartition_expression_utf8": "",
+ "default_subpartitioning": 0,
+ "indexes": [
+ {
+ "name": "PRIMARY",
+ "hidden": false,
+ "is_generated": false,
+ "ordinal_position": 1,
+ "comment": "",
+ "options": "flags=0;",
+ "se_private_data": "id=A;root=B;space_id=C;table_id=D;trx_id=E",
+ "type": 1,
+ "algorithm": 2,
+ "is_algorithm_explicit": false,
+ "is_visible": true,
+ "engine": "InnoDB",
+ "elements": [
+ {
+ "ordinal_position": 1,
+ "length": 8,
+ "order": 2,
+ "column_opx": 0
+ },
+ {
+ "ordinal_position": 2,
+ "length": 4294967295,
+ "order": 2,
+ "column_opx": 7
+ },
+ {
+ "ordinal_position": 3,
+ "length": 4294967295,
+ "order": 2,
+ "column_opx": 8
+ },
+ {
+ "ordinal_position": 4,
+ "length": 4294967295,
+ "order": 2,
+ "column_opx": 1
+ },
+ {
+ "ordinal_position": 5,
+ "length": 4294967295,
+ "order": 2,
+ "column_opx": 2
+ },
+ {
+ "ordinal_position": 6,
+ "length": 4294967295,
+ "order": 2,
+ "column_opx": 3
+ },
+ {
+ "ordinal_position": 7,
+ "length": 4294967295,
+ "order": 2,
+ "column_opx": 4
+ },
+ {
+ "ordinal_position": 8,
+ "length": 4294967295,
+ "order": 2,
+ "column_opx": 5
+ },
+ {
+ "ordinal_position": 9,
+ "length": 4294967295,
+ "order": 2,
+ "column_opx": 6
+ }
+ ],
+ "tablespace_ref": "mysql"
+ },
+ {
+ "name": "schema_id",
+ "hidden": false,
+ "is_generated": false,
+ "ordinal_position": 2,
+ "comment": "",
+ "options": "flags=0;",
+ "se_private_data": "id=A;root=B;space_id=C;table_id=D;trx_id=E",
+ "type": 2,
+ "algorithm": 2,
+ "is_algorithm_explicit": false,
+ "is_visible": true,
+ "engine": "InnoDB",
+ "elements": [
+ {
+ "ordinal_position": 1,
+ "length": 8,
+ "order": 2,
+ "column_opx": 1
+ },
+ {
+ "ordinal_position": 2,
+ "length": 192,
+ "order": 2,
+ "column_opx": 3
+ },
+ {
+ "ordinal_position": 3,
+ "length": 4294967295,
+ "order": 2,
+ "column_opx": 0
+ }
+ ],
+ "tablespace_ref": "mysql"
+ },
+ {
+ "name": "table_id",
+ "hidden": false,
+ "is_generated": false,
+ "ordinal_position": 3,
+ "comment": "",
+ "options": "flags=0;",
+ "se_private_data": "id=A;root=B;space_id=C;table_id=D;trx_id=E",
+ "type": 2,
+ "algorithm": 2,
+ "is_algorithm_explicit": false,
+ "is_visible": true,
+ "engine": "InnoDB",
+ "elements": [
+ {
+ "ordinal_position": 1,
+ "length": 8,
+ "order": 2,
+ "column_opx": 2
+ },
+ {
+ "ordinal_position": 2,
+ "length": 192,
+ "order": 2,
+ "column_opx": 3
+ },
+ {
+ "ordinal_position": 3,
+ "length": 4294967295,
+ "order": 2,
+ "column_opx": 0
+ }
+ ],
+ "tablespace_ref": "mysql"
+ }
+ ],
+ "foreign_keys": [
+ {
+ "name": "check_constraints_ibfk_1",
+ "match_option": 1,
+ "update_rule": 1,
+ "delete_rule": 1,
+ "unique_constraint_name": "",
+ "referenced_table_catalog_name": "def",
+ "referenced_table_schema_name": "mysql",
+ "referenced_table_name": "schemata",
+ "elements": [
+ {
+ "column_opx": 1,
+ "ordinal_position": 1,
+ "referenced_column_name": "id"
+ }
+ ]
+ },
+ {
+ "name": "check_constraints_ibfk_2",
+ "match_option": 1,
+ "update_rule": 1,
+ "delete_rule": 1,
+ "unique_constraint_name": "",
+ "referenced_table_catalog_name": "def",
+ "referenced_table_schema_name": "mysql",
+ "referenced_table_name": "tables",
+ "elements": [
+ {
+ "column_opx": 2,
+ "ordinal_position": 1,
+ "referenced_column_name": "id"
+ }
+ ]
+ }
+ ],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -3296,6 +3856,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -3876,6 +4437,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -4164,6 +4726,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -5903,6 +6466,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -7482,6 +8046,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -7905,6 +8470,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -8737,6 +9303,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -9257,6 +9824,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -9727,6 +10295,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -10123,6 +10692,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -11038,6 +11608,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -11326,6 +11897,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -12337,6 +12909,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -12813,6 +13386,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -14715,6 +15289,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -15252,6 +15827,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -15910,6 +16486,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -16282,6 +16859,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -17180,6 +17758,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -17870,6 +18449,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -20017,6 +20597,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -20382,6 +20963,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -20807,6 +21389,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -22075,6 +22658,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -22446,6 +23030,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -22817,6 +23402,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -23129,6 +23715,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -23492,6 +24079,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -23813,6 +24401,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -24125,6 +24714,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -24395,6 +24985,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -25669,6 +26260,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -28278,6 +28870,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -28875,6 +29468,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -29330,6 +29924,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -29885,6 +30480,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -30370,6 +30966,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -31018,6 +31615,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -31339,6 +31937,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -31567,6 +32166,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -32089,6 +32689,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -32514,6 +33115,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -32855,6 +33457,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -33083,6 +33686,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -33340,6 +33944,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -33568,6 +34173,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -33805,6 +34411,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -34075,6 +34682,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -34429,6 +35037,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -34657,6 +35266,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -35179,6 +35789,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -36457,6 +37068,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -37147,6 +37759,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -37417,6 +38030,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -37765,6 +38379,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
@@ -38197,6 +38812,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": X,
"tablespace_ref": "mysql"
diff --git a/mysql-test/std_data/dd/sdi/upgrade/opening_lines.json b/mysql-test/std_data/dd/sdi/upgrade/opening_lines.json
index 0e09a044fd03..dab7f36b1792 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/opening_lines.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/opening_lines.json
@@ -399,6 +399,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 8
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/payment.json b/mysql-test/std_data/dd/sdi/upgrade/payment.json
index 536f07e2bb95..128282a7b908 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/payment.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/payment.json
@@ -570,6 +570,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": 33
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/rental.json b/mysql-test/std_data/dd/sdi/upgrade/rental.json
index efa98d6b2deb..018fdc496b92 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/rental.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/rental.json
@@ -611,6 +611,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": 33
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/staff.json b/mysql-test/std_data/dd/sdi/upgrade/staff.json
index 97abfd80419f..b8aa51a92321 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/staff.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/staff.json
@@ -692,6 +692,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": 33
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/store.json b/mysql-test/std_data/dd/sdi/upgrade/store.json
index c715c141f079..db30e7ded969 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/store.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/store.json
@@ -398,6 +398,7 @@
]
}
],
+ "check_constraints": [],
"partitions": [],
"collation_id": 33
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/t_blob.json b/mysql-test/std_data/dd/sdi/upgrade/t_blob.json
index a3b783371694..e886b885758d 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/t_blob.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/t_blob.json
@@ -311,6 +311,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 8
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/t_blob_myisam.json b/mysql-test/std_data/dd/sdi/upgrade/t_blob_myisam.json
index a89b4bb41058..fcca18e126bf 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/t_blob_myisam.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/t_blob_myisam.json
@@ -311,6 +311,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 8
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/t_compressed.json b/mysql-test/std_data/dd/sdi/upgrade/t_compressed.json
index 331249ff380a..aa9540da398a 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/t_compressed.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/t_compressed.json
@@ -221,6 +221,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 8
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/t_compressed2.json b/mysql-test/std_data/dd/sdi/upgrade/t_compressed2.json
index afa184a78763..4c07700599be 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/t_compressed2.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/t_compressed2.json
@@ -221,6 +221,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 8
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/t_compressed3.json b/mysql-test/std_data/dd/sdi/upgrade/t_compressed3.json
index 9b1ffb109c37..832b564fd151 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/t_compressed3.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/t_compressed3.json
@@ -221,6 +221,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 8
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/t_dynamic.json b/mysql-test/std_data/dd/sdi/upgrade/t_dynamic.json
index 1b74f6bacd56..0832de390a8c 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/t_dynamic.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/t_dynamic.json
@@ -221,6 +221,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 8
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/t_gen_stored.json b/mysql-test/std_data/dd/sdi/upgrade/t_gen_stored.json
index e0513ee60e1c..4d5a2746bd16 100755
--- a/mysql-test/std_data/dd/sdi/upgrade/t_gen_stored.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/t_gen_stored.json
@@ -263,6 +263,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 8
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/t_json.json b/mysql-test/std_data/dd/sdi/upgrade/t_json.json
index 1b9dc627a954..21a0653d12ef 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/t_json.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/t_json.json
@@ -221,6 +221,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 8
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade/test_tablespace_2.json b/mysql-test/std_data/dd/sdi/upgrade/test_tablespace_2.json
index c344e03286f2..b05f8f915bfe 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/test_tablespace_2.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/test_tablespace_2.json
@@ -263,6 +263,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 8,
"tablespace_ref": "tbsp1"
@@ -533,6 +534,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 8,
"tablespace_ref": "tbsp1"
diff --git a/mysql-test/std_data/dd/sdi/upgrade/test_tablespace_3.json b/mysql-test/std_data/dd/sdi/upgrade/test_tablespace_3.json
index 7bc577bb2c3a..d440b580ab27 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/test_tablespace_3.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/test_tablespace_3.json
@@ -221,6 +221,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 8,
"tablespace_ref": "tbsp2"
diff --git a/mysql-test/std_data/dd/sdi/upgrade/vt2.json b/mysql-test/std_data/dd/sdi/upgrade/vt2.json
index 685ae82d29c7..46bd5f0ceae3 100644
--- a/mysql-test/std_data/dd/sdi/upgrade/vt2.json
+++ b/mysql-test/std_data/dd/sdi/upgrade/vt2.json
@@ -250,6 +250,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 8
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade_partition/sys_config.json b/mysql-test/std_data/dd/sdi/upgrade_partition/sys_config.json
index 463418e8b3ef..c53ed917bfd6 100755
--- a/mysql-test/std_data/dd/sdi/upgrade_partition/sys_config.json
+++ b/mysql-test/std_data/dd/sdi/upgrade_partition/sys_config.json
@@ -305,6 +305,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 33
}
diff --git a/mysql-test/std_data/dd/sdi/upgrade_partition/t1#p#p0.json b/mysql-test/std_data/dd/sdi/upgrade_partition/t1#p#p0.json
index fa4c021db206..23d697a84007 100755
--- a/mysql-test/std_data/dd/sdi/upgrade_partition/t1#p#p0.json
+++ b/mysql-test/std_data/dd/sdi/upgrade_partition/t1#p#p0.json
@@ -262,6 +262,7 @@
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [
{
"name": "p0",
diff --git a/mysql-test/std_data/upgrade/data_80014.zip b/mysql-test/std_data/upgrade/data_80014.zip
new file mode 100644
index 000000000000..167f0b4eb050
Binary files /dev/null and b/mysql-test/std_data/upgrade/data_80014.zip differ
diff --git a/mysql-test/suite/funcs_1/r/is_columns_is_ci.result b/mysql-test/suite/funcs_1/r/is_columns_is_ci.result
index fa417c6b0844..f1bdb22d2e85 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_is_ci.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_is_ci.result
@@ -10,6 +10,10 @@ def information_schema CHARACTER_SETS CHARACTER_SET_NAME 1 NULL NO varchar 64 19
def information_schema CHARACTER_SETS DEFAULT_COLLATE_NAME 2 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NULL
def information_schema CHARACTER_SETS DESCRIPTION 3 NULL NO varchar 2048 6144 NULL NULL NULL utf8 utf8_general_ci varchar(2048) select NULL
def information_schema CHARACTER_SETS MAXLEN 4 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned select NULL
+def information_schema CHECK_CONSTRAINTS CONSTRAINT_CATALOG 1 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) select NULL
+def information_schema CHECK_CONSTRAINTS CONSTRAINT_SCHEMA 2 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) select NULL
+def information_schema CHECK_CONSTRAINTS CONSTRAINT_NAME 3 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) select NULL
+def information_schema CHECK_CONSTRAINTS CHECK_CLAUSE 4 NULL NO longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_bin longtext select NULL
def information_schema COLLATIONS COLLATION_NAME 1 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NULL
def information_schema COLLATIONS CHARACTER_SET_NAME 2 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NULL
def information_schema COLLATIONS ID 3 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select NULL
@@ -326,6 +330,7 @@ def information_schema TABLE_CONSTRAINTS CONSTRAINT_NAME 3 NULL NO varchar 64 19
def information_schema TABLE_CONSTRAINTS TABLE_SCHEMA 4 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) select NULL
def information_schema TABLE_CONSTRAINTS TABLE_NAME 5 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) select NULL
def information_schema TABLE_CONSTRAINTS CONSTRAINT_TYPE 6 NO varchar 11 33 NULL NULL NULL utf8 utf8_bin varchar(11) select NULL
+def information_schema TABLE_CONSTRAINTS ENFORCED 7 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3) select NULL
def information_schema TABLE_PRIVILEGES GRANTEE 1 NO varchar 27 81 NULL NULL NULL utf8 utf8_general_ci varchar(81) select NULL
def information_schema TABLE_PRIVILEGES TABLE_CATALOG 2 NO varchar 170 512 NULL NULL NULL utf8 utf8_general_ci varchar(512) select NULL
def information_schema TABLE_PRIVILEGES TABLE_SCHEMA 3 NO varchar 21 64 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NULL
@@ -462,6 +467,10 @@ COL_CML TABLE_SCHEMA TABLE_NAME COLUMN_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH C
3.0000 information_schema CHARACTER_SETS DEFAULT_COLLATE_NAME varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema CHARACTER_SETS DESCRIPTION varchar 2048 6144 utf8 utf8_general_ci varchar(2048)
NULL information_schema CHARACTER_SETS MAXLEN int NULL NULL NULL NULL int(10) unsigned
+3.0000 information_schema CHECK_CONSTRAINTS CONSTRAINT_CATALOG varchar 64 192 utf8 utf8_bin varchar(64)
+3.0000 information_schema CHECK_CONSTRAINTS CONSTRAINT_SCHEMA varchar 64 192 utf8 utf8_bin varchar(64)
+3.0000 information_schema CHECK_CONSTRAINTS CONSTRAINT_NAME varchar 64 192 utf8 utf8_bin varchar(64)
+1.0000 information_schema CHECK_CONSTRAINTS CHECK_CLAUSE longtext 4294967295 4294967295 utf8 utf8_bin longtext
3.0000 information_schema COLLATIONS COLLATION_NAME varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema COLLATIONS CHARACTER_SET_NAME varchar 64 192 utf8 utf8_general_ci varchar(64)
NULL information_schema COLLATIONS ID bigint NULL NULL NULL NULL bigint(20) unsigned
@@ -778,6 +787,7 @@ NULL information_schema TABLESPACES NODEGROUP_ID bigint NULL NULL NULL NULL bigi
3.0000 information_schema TABLE_CONSTRAINTS TABLE_SCHEMA varchar 64 192 utf8 utf8_bin varchar(64)
3.0000 information_schema TABLE_CONSTRAINTS TABLE_NAME varchar 64 192 utf8 utf8_bin varchar(64)
3.0000 information_schema TABLE_CONSTRAINTS CONSTRAINT_TYPE varchar 11 33 utf8 utf8_bin varchar(11)
+3.0000 information_schema TABLE_CONSTRAINTS ENFORCED varchar 3 9 utf8 utf8_general_ci varchar(3)
3.0000 information_schema TABLE_PRIVILEGES GRANTEE varchar 27 81 utf8 utf8_general_ci varchar(81)
3.0118 information_schema TABLE_PRIVILEGES TABLE_CATALOG varchar 170 512 utf8 utf8_general_ci varchar(512)
3.0476 information_schema TABLE_PRIVILEGES TABLE_SCHEMA varchar 21 64 utf8 utf8_general_ci varchar(64)
diff --git a/mysql-test/suite/funcs_1/r/is_columns_is_cs.result b/mysql-test/suite/funcs_1/r/is_columns_is_cs.result
index 5ed3f804bfcd..4ee9575c6ace 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_is_cs.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_is_cs.result
@@ -10,6 +10,10 @@ def information_schema CHARACTER_SETS CHARACTER_SET_NAME 1 NULL NO varchar 64 19
def information_schema CHARACTER_SETS DEFAULT_COLLATE_NAME 2 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NULL
def information_schema CHARACTER_SETS DESCRIPTION 3 NULL NO varchar 2048 6144 NULL NULL NULL utf8 utf8_general_ci varchar(2048) select NULL
def information_schema CHARACTER_SETS MAXLEN 4 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned select NULL
+def information_schema CHECK_CONSTRAINTS CONSTRAINT_CATALOG 1 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) select NULL
+def information_schema CHECK_CONSTRAINTS CONSTRAINT_SCHEMA 2 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) select NULL
+def information_schema CHECK_CONSTRAINTS CONSTRAINT_NAME 3 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) select NULL
+def information_schema CHECK_CONSTRAINTS CHECK_CLAUSE 4 NULL NO longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_bin longtext select NULL
def information_schema COLLATIONS COLLATION_NAME 1 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NULL
def information_schema COLLATIONS CHARACTER_SET_NAME 2 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NULL
def information_schema COLLATIONS ID 3 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select NULL
@@ -326,6 +330,7 @@ def information_schema TABLE_CONSTRAINTS CONSTRAINT_NAME 3 NULL NO varchar 64 19
def information_schema TABLE_CONSTRAINTS TABLE_SCHEMA 4 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) select NULL
def information_schema TABLE_CONSTRAINTS TABLE_NAME 5 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) select NULL
def information_schema TABLE_CONSTRAINTS CONSTRAINT_TYPE 6 NO varchar 11 33 NULL NULL NULL utf8 utf8_bin varchar(11) select NULL
+def information_schema TABLE_CONSTRAINTS ENFORCED 7 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3) select NULL
def information_schema TABLE_PRIVILEGES GRANTEE 1 NO varchar 27 81 NULL NULL NULL utf8 utf8_general_ci varchar(81) select NULL
def information_schema TABLE_PRIVILEGES TABLE_CATALOG 2 NO varchar 170 512 NULL NULL NULL utf8 utf8_general_ci varchar(512) select NULL
def information_schema TABLE_PRIVILEGES TABLE_SCHEMA 3 NO varchar 21 64 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NULL
@@ -462,6 +467,10 @@ COL_CML TABLE_SCHEMA TABLE_NAME COLUMN_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH C
3.0000 information_schema CHARACTER_SETS DEFAULT_COLLATE_NAME varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema CHARACTER_SETS DESCRIPTION varchar 2048 6144 utf8 utf8_general_ci varchar(2048)
NULL information_schema CHARACTER_SETS MAXLEN int NULL NULL NULL NULL int(10) unsigned
+3.0000 information_schema CHECK_CONSTRAINTS CONSTRAINT_CATALOG varchar 64 192 utf8 utf8_bin varchar(64)
+3.0000 information_schema CHECK_CONSTRAINTS CONSTRAINT_SCHEMA varchar 64 192 utf8 utf8_bin varchar(64)
+3.0000 information_schema CHECK_CONSTRAINTS CONSTRAINT_NAME varchar 64 192 utf8 utf8_bin varchar(64)
+1.0000 information_schema CHECK_CONSTRAINTS CHECK_CLAUSE longtext 4294967295 4294967295 utf8 utf8_bin longtext
3.0000 information_schema COLLATIONS COLLATION_NAME varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema COLLATIONS CHARACTER_SET_NAME varchar 64 192 utf8 utf8_general_ci varchar(64)
NULL information_schema COLLATIONS ID bigint NULL NULL NULL NULL bigint(20) unsigned
@@ -778,6 +787,7 @@ NULL information_schema TABLESPACES NODEGROUP_ID bigint NULL NULL NULL NULL bigi
3.0000 information_schema TABLE_CONSTRAINTS TABLE_SCHEMA varchar 64 192 utf8 utf8_bin varchar(64)
3.0000 information_schema TABLE_CONSTRAINTS TABLE_NAME varchar 64 192 utf8 utf8_bin varchar(64)
3.0000 information_schema TABLE_CONSTRAINTS CONSTRAINT_TYPE varchar 11 33 utf8 utf8_bin varchar(11)
+3.0000 information_schema TABLE_CONSTRAINTS ENFORCED varchar 3 9 utf8 utf8_general_ci varchar(3)
3.0000 information_schema TABLE_PRIVILEGES GRANTEE varchar 27 81 utf8 utf8_general_ci varchar(81)
3.0118 information_schema TABLE_PRIVILEGES TABLE_CATALOG varchar 170 512 utf8 utf8_general_ci varchar(512)
3.0476 information_schema TABLE_PRIVILEGES TABLE_SCHEMA varchar 21 64 utf8 utf8_general_ci varchar(64)
diff --git a/mysql-test/suite/funcs_1/r/is_table_constraints.result b/mysql-test/suite/funcs_1/r/is_table_constraints.result
index a333771bd5d4..b51450b0eb32 100644
--- a/mysql-test/suite/funcs_1/r/is_table_constraints.result
+++ b/mysql-test/suite/funcs_1/r/is_table_constraints.result
@@ -34,9 +34,10 @@ CONSTRAINT_NAME varchar(64) NO NULL
TABLE_SCHEMA varchar(64) NO NULL
TABLE_NAME varchar(64) NO NULL
CONSTRAINT_TYPE varchar(11) NO
+ENFORCED varchar(3) NO
SHOW CREATE TABLE information_schema.TABLE_CONSTRAINTS;
View Create View character_set_client collation_connection
-TABLE_CONSTRAINTS CREATE ALGORITHM=UNDEFINED DEFINER=`mysql.infoschema`@`localhost` SQL SECURITY DEFINER VIEW `information_schema`.`TABLE_CONSTRAINTS` AS (select `cat`.`name` AS `CONSTRAINT_CATALOG`,`sch`.`name` AS `CONSTRAINT_SCHEMA`,`idx`.`name` AS `CONSTRAINT_NAME`,`sch`.`name` AS `TABLE_SCHEMA`,`tbl`.`name` AS `TABLE_NAME`,if((`idx`.`type` = 'PRIMARY'),'PRIMARY KEY',`idx`.`type`) AS `CONSTRAINT_TYPE` from (((`mysql`.`indexes` `idx` join `mysql`.`tables` `tbl` on((`idx`.`table_id` = `tbl`.`id`))) join `mysql`.`schemata` `sch` on((`tbl`.`schema_id` = `sch`.`id`))) join `mysql`.`catalogs` `cat` on(((`cat`.`id` = `sch`.`catalog_id`) and (`idx`.`type` in ('PRIMARY','UNIQUE'))))) where (can_access_table(`sch`.`name`,`tbl`.`name`) and is_visible_dd_object(`tbl`.`hidden`,`idx`.`hidden`))) union (select `cat`.`name` AS `CONSTRAINT_CATALOG`,`sch`.`name` AS `CONSTRAINT_SCHEMA`,(`fk`.`name` collate utf8_tolower_ci) AS `CONSTRAINT_NAME`,`sch`.`name` AS `TABLE_SCHEMA`,`tbl`.`name` AS `TABLE_NAME`,'FOREIGN KEY' AS `CONSTRAINT_TYPE` from (((`mysql`.`foreign_keys` `fk` join `mysql`.`tables` `tbl` on((`fk`.`table_id` = `tbl`.`id`))) join `mysql`.`schemata` `sch` on((`tbl`.`schema_id` = `sch`.`id`))) join `mysql`.`catalogs` `cat` on((`cat`.`id` = `sch`.`catalog_id`))) where (can_access_table(`sch`.`name`,`tbl`.`name`) and is_visible_dd_object(`tbl`.`hidden`))) utf8 utf8_general_ci
+TABLE_CONSTRAINTS CREATE ALGORITHM=UNDEFINED DEFINER=`mysql.infoschema`@`localhost` SQL SECURITY DEFINER VIEW `information_schema`.`TABLE_CONSTRAINTS` AS (select `cat`.`name` AS `CONSTRAINT_CATALOG`,`sch`.`name` AS `CONSTRAINT_SCHEMA`,`idx`.`name` AS `CONSTRAINT_NAME`,`sch`.`name` AS `TABLE_SCHEMA`,`tbl`.`name` AS `TABLE_NAME`,if((`idx`.`type` = 'PRIMARY'),'PRIMARY KEY',`idx`.`type`) AS `CONSTRAINT_TYPE`,'YES' AS `ENFORCED` from (((`mysql`.`indexes` `idx` join `mysql`.`tables` `tbl` on((`idx`.`table_id` = `tbl`.`id`))) join `mysql`.`schemata` `sch` on((`tbl`.`schema_id` = `sch`.`id`))) join `mysql`.`catalogs` `cat` on(((`cat`.`id` = `sch`.`catalog_id`) and (`idx`.`type` in ('PRIMARY','UNIQUE'))))) where (can_access_table(`sch`.`name`,`tbl`.`name`) and is_visible_dd_object(`tbl`.`hidden`,`idx`.`hidden`))) union (select `cat`.`name` AS `CONSTRAINT_CATALOG`,`sch`.`name` AS `CONSTRAINT_SCHEMA`,(`fk`.`name` collate utf8_tolower_ci) AS `CONSTRAINT_NAME`,`sch`.`name` AS `TABLE_SCHEMA`,`tbl`.`name` AS `TABLE_NAME`,'FOREIGN KEY' AS `CONSTRAINT_TYPE`,'YES' AS `ENFORCED` from (((`mysql`.`foreign_keys` `fk` join `mysql`.`tables` `tbl` on((`fk`.`table_id` = `tbl`.`id`))) join `mysql`.`schemata` `sch` on((`tbl`.`schema_id` = `sch`.`id`))) join `mysql`.`catalogs` `cat` on((`cat`.`id` = `sch`.`catalog_id`))) where (can_access_table(`sch`.`name`,`tbl`.`name`) and is_visible_dd_object(`tbl`.`hidden`))) union (select `cat`.`name` AS `CONSTRAINT_CATALOG`,`sch`.`name` AS `CONSTRAINT_SCHEMA`,`cc`.`name` AS `CONSTRAINT_NAME`,`sch`.`name` AS `TABLE_SCHEMA`,`tbl`.`name` AS `TABLE_NAME`,'CHECK' AS `CONSTRAINT_TYPE`,`cc`.`enforced` AS `ENFORCED` from (((`mysql`.`check_constraints` `cc` join `mysql`.`tables` `tbl` on((`cc`.`table_id` = `tbl`.`id`))) join `mysql`.`schemata` `sch` on((`tbl`.`schema_id` = `sch`.`id`))) join `mysql`.`catalogs` `cat` on((`cat`.`id` = `sch`.`catalog_id`))) where (can_access_table(`sch`.`name`,`tbl`.`name`) and is_visible_dd_object(`tbl`.`hidden`))) utf8 utf8_general_ci
SHOW COLUMNS FROM information_schema.TABLE_CONSTRAINTS;
Field Type Null Key Default Extra
CONSTRAINT_CATALOG varchar(64) NO NULL
@@ -45,6 +46,7 @@ CONSTRAINT_NAME varchar(64) NO NULL
TABLE_SCHEMA varchar(64) NO NULL
TABLE_NAME varchar(64) NO NULL
CONSTRAINT_TYPE varchar(11) NO
+ENFORCED varchar(3) NO
SELECT constraint_catalog, constraint_schema, constraint_name,
table_schema, table_name
FROM information_schema.table_constraints
@@ -201,11 +203,11 @@ GRANT SELECT (`f5`) ON `db_datadict`.`t1` TO `testuser1`@`localhost`
SELECT * FROM information_schema.table_constraints
WHERE table_schema = 'db_datadict'
ORDER BY table_schema,table_name, constraint_name;
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
-def db_datadict my_idx1 db_datadict t1 UNIQUE
-def db_datadict my_idx2 db_datadict t1 UNIQUE
-def db_datadict PRIMARY db_datadict t1 PRIMARY KEY
-def db_datadict PRIMARY db_datadict t2 PRIMARY KEY
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
+def db_datadict my_idx1 db_datadict t1 UNIQUE YES
+def db_datadict my_idx2 db_datadict t1 UNIQUE YES
+def db_datadict PRIMARY db_datadict t1 PRIMARY KEY YES
+def db_datadict PRIMARY db_datadict t2 PRIMARY KEY YES
SHOW INDEXES FROM db_datadict.t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
t1 0 PRIMARY 1 f1 ### ### ### ### ### ### ### YES NULL
@@ -225,10 +227,10 @@ GRANT SELECT (`f5`) ON `db_datadict`.`t1` TO `testuser1`@`localhost`
SELECT * FROM information_schema.table_constraints
WHERE table_schema = 'db_datadict'
ORDER BY table_schema,table_name, constraint_name;
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
-def db_datadict my_idx1 db_datadict t1 UNIQUE
-def db_datadict my_idx2 db_datadict t1 UNIQUE
-def db_datadict PRIMARY db_datadict t1 PRIMARY KEY
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
+def db_datadict my_idx1 db_datadict t1 UNIQUE YES
+def db_datadict my_idx2 db_datadict t1 UNIQUE YES
+def db_datadict PRIMARY db_datadict t1 PRIMARY KEY YES
SHOW INDEXES FROM db_datadict.t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
t1 0 PRIMARY 1 f1 ### ### ### ### ### ### ### YES NULL
diff --git a/mysql-test/suite/funcs_1/r/is_table_constraints_ci.result b/mysql-test/suite/funcs_1/r/is_table_constraints_ci.result
index 9f87e5972626..37352579fe6f 100644
--- a/mysql-test/suite/funcs_1/r/is_table_constraints_ci.result
+++ b/mysql-test/suite/funcs_1/r/is_table_constraints_ci.result
@@ -34,9 +34,10 @@ CONSTRAINT_NAME varchar(64) NO NULL
TABLE_SCHEMA varchar(64) YES NULL
TABLE_NAME varchar(64) YES NULL
CONSTRAINT_TYPE varchar(11) NO
+ENFORCED varchar(3) NO
SHOW CREATE TABLE information_schema.TABLE_CONSTRAINTS;
View Create View character_set_client collation_connection
-TABLE_CONSTRAINTS CREATE ALGORITHM=UNDEFINED DEFINER=`mysql.infoschema`@`localhost` SQL SECURITY DEFINER VIEW `information_schema`.`TABLE_CONSTRAINTS` AS (select (`cat`.`name` collate utf8_tolower_ci) AS `CONSTRAINT_CATALOG`,(`sch`.`name` collate utf8_tolower_ci) AS `CONSTRAINT_SCHEMA`,`idx`.`name` AS `CONSTRAINT_NAME`,(`sch`.`name` collate utf8_tolower_ci) AS `TABLE_SCHEMA`,(`tbl`.`name` collate utf8_tolower_ci) AS `TABLE_NAME`,if((`idx`.`type` = 'PRIMARY'),'PRIMARY KEY',`idx`.`type`) AS `CONSTRAINT_TYPE` from (((`mysql`.`indexes` `idx` join `mysql`.`tables` `tbl` on((`idx`.`table_id` = `tbl`.`id`))) join `mysql`.`schemata` `sch` on((`tbl`.`schema_id` = `sch`.`id`))) join `mysql`.`catalogs` `cat` on(((`cat`.`id` = `sch`.`catalog_id`) and (`idx`.`type` in ('PRIMARY','UNIQUE'))))) where (can_access_table(`sch`.`name`,`tbl`.`name`) and is_visible_dd_object(`tbl`.`hidden`,`idx`.`hidden`))) union (select (`cat`.`name` collate utf8_tolower_ci) AS `CONSTRAINT_CATALOG`,(`sch`.`name` collate utf8_tolower_ci) AS `CONSTRAINT_SCHEMA`,(`fk`.`name` collate utf8_tolower_ci) AS `CONSTRAINT_NAME`,(`sch`.`name` collate utf8_tolower_ci) AS `TABLE_SCHEMA`,(`tbl`.`name` collate utf8_tolower_ci) AS `TABLE_NAME`,'FOREIGN KEY' AS `CONSTRAINT_TYPE` from (((`mysql`.`foreign_keys` `fk` join `mysql`.`tables` `tbl` on((`fk`.`table_id` = `tbl`.`id`))) join `mysql`.`schemata` `sch` on((`tbl`.`schema_id` = `sch`.`id`))) join `mysql`.`catalogs` `cat` on((`cat`.`id` = `sch`.`catalog_id`))) where (can_access_table(`sch`.`name`,`tbl`.`name`) and is_visible_dd_object(`tbl`.`hidden`))) utf8 utf8_general_ci
+TABLE_CONSTRAINTS CREATE ALGORITHM=UNDEFINED DEFINER=`mysql.infoschema`@`localhost` SQL SECURITY DEFINER VIEW `information_schema`.`TABLE_CONSTRAINTS` AS (select (`cat`.`name` collate utf8_tolower_ci) AS `CONSTRAINT_CATALOG`,(`sch`.`name` collate utf8_tolower_ci) AS `CONSTRAINT_SCHEMA`,`idx`.`name` AS `CONSTRAINT_NAME`,(`sch`.`name` collate utf8_tolower_ci) AS `TABLE_SCHEMA`,(`tbl`.`name` collate utf8_tolower_ci) AS `TABLE_NAME`,if((`idx`.`type` = 'PRIMARY'),'PRIMARY KEY',`idx`.`type`) AS `CONSTRAINT_TYPE`,'YES' AS `ENFORCED` from (((`mysql`.`indexes` `idx` join `mysql`.`tables` `tbl` on((`idx`.`table_id` = `tbl`.`id`))) join `mysql`.`schemata` `sch` on((`tbl`.`schema_id` = `sch`.`id`))) join `mysql`.`catalogs` `cat` on(((`cat`.`id` = `sch`.`catalog_id`) and (`idx`.`type` in ('PRIMARY','UNIQUE'))))) where (can_access_table(`sch`.`name`,`tbl`.`name`) and is_visible_dd_object(`tbl`.`hidden`,`idx`.`hidden`))) union (select (`cat`.`name` collate utf8_tolower_ci) AS `CONSTRAINT_CATALOG`,(`sch`.`name` collate utf8_tolower_ci) AS `CONSTRAINT_SCHEMA`,(`fk`.`name` collate utf8_tolower_ci) AS `CONSTRAINT_NAME`,(`sch`.`name` collate utf8_tolower_ci) AS `TABLE_SCHEMA`,(`tbl`.`name` collate utf8_tolower_ci) AS `TABLE_NAME`,'FOREIGN KEY' AS `CONSTRAINT_TYPE`,'YES' AS `ENFORCED` from (((`mysql`.`foreign_keys` `fk` join `mysql`.`tables` `tbl` on((`fk`.`table_id` = `tbl`.`id`))) join `mysql`.`schemata` `sch` on((`tbl`.`schema_id` = `sch`.`id`))) join `mysql`.`catalogs` `cat` on((`cat`.`id` = `sch`.`catalog_id`))) where (can_access_table(`sch`.`name`,`tbl`.`name`) and is_visible_dd_object(`tbl`.`hidden`))) union (select (`cat`.`name` collate utf8_tolower_ci) AS `CONSTRAINT_CATALOG`,(`sch`.`name` collate utf8_tolower_ci) AS `CONSTRAINT_SCHEMA`,`cc`.`name` AS `CONSTRAINT_NAME`,(`sch`.`name` collate utf8_tolower_ci) AS `TABLE_SCHEMA`,(`tbl`.`name` collate utf8_tolower_ci) AS `TABLE_NAME`,'CHECK' AS `CONSTRAINT_TYPE`,`cc`.`enforced` AS `ENFORCED` from (((`mysql`.`check_constraints` `cc` join `mysql`.`tables` `tbl` on((`cc`.`table_id` = `tbl`.`id`))) join `mysql`.`schemata` `sch` on((`tbl`.`schema_id` = `sch`.`id`))) join `mysql`.`catalogs` `cat` on((`cat`.`id` = `sch`.`catalog_id`))) where (can_access_table(`sch`.`name`,`tbl`.`name`) and is_visible_dd_object(`tbl`.`hidden`))) utf8 utf8_general_ci
SHOW COLUMNS FROM information_schema.TABLE_CONSTRAINTS;
Field Type Null Key Default Extra
CONSTRAINT_CATALOG varchar(64) YES NULL
@@ -45,6 +46,7 @@ CONSTRAINT_NAME varchar(64) NO NULL
TABLE_SCHEMA varchar(64) YES NULL
TABLE_NAME varchar(64) YES NULL
CONSTRAINT_TYPE varchar(11) NO
+ENFORCED varchar(3) NO
SELECT constraint_catalog, constraint_schema, constraint_name,
table_schema, table_name
FROM information_schema.table_constraints
@@ -201,11 +203,11 @@ GRANT SELECT (`f5`) ON `db_datadict`.`t1` TO `testuser1`@`localhost`
SELECT * FROM information_schema.table_constraints
WHERE table_schema = 'db_datadict'
ORDER BY table_schema,table_name, constraint_name;
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
-def db_datadict my_idx1 db_datadict t1 UNIQUE
-def db_datadict my_idx2 db_datadict t1 UNIQUE
-def db_datadict PRIMARY db_datadict t1 PRIMARY KEY
-def db_datadict PRIMARY db_datadict t2 PRIMARY KEY
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
+def db_datadict my_idx1 db_datadict t1 UNIQUE YES
+def db_datadict my_idx2 db_datadict t1 UNIQUE YES
+def db_datadict PRIMARY db_datadict t1 PRIMARY KEY YES
+def db_datadict PRIMARY db_datadict t2 PRIMARY KEY YES
SHOW INDEXES FROM db_datadict.t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
t1 0 PRIMARY 1 f1 ### ### ### ### ### ### ### YES NULL
@@ -225,10 +227,10 @@ GRANT SELECT (`f5`) ON `db_datadict`.`t1` TO `testuser1`@`localhost`
SELECT * FROM information_schema.table_constraints
WHERE table_schema = 'db_datadict'
ORDER BY table_schema,table_name, constraint_name;
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
-def db_datadict my_idx1 db_datadict t1 UNIQUE
-def db_datadict my_idx2 db_datadict t1 UNIQUE
-def db_datadict PRIMARY db_datadict t1 PRIMARY KEY
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
+def db_datadict my_idx1 db_datadict t1 UNIQUE YES
+def db_datadict my_idx2 db_datadict t1 UNIQUE YES
+def db_datadict PRIMARY db_datadict t1 PRIMARY KEY YES
SHOW INDEXES FROM db_datadict.t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
t1 0 PRIMARY 1 f1 ### ### ### ### ### ### ### YES NULL
diff --git a/mysql-test/suite/funcs_1/r/is_table_constraints_is.result b/mysql-test/suite/funcs_1/r/is_table_constraints_is.result
index 202170b81eb1..1d7994afe650 100644
--- a/mysql-test/suite/funcs_1/r/is_table_constraints_is.result
+++ b/mysql-test/suite/funcs_1/r/is_table_constraints_is.result
@@ -6,12 +6,12 @@ GRANT SELECT ON db_datadict.* TO testuser1@localhost;
SELECT * FROM information_schema.table_constraints
WHERE table_schema = 'information_schema' AND table_name != 'ndb_binlog_index'
ORDER BY table_schema,table_name,constraint_name COLLATE utf8_general_ci;
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
# Establish connection testuser1 (user=testuser1)
SELECT * FROM information_schema.table_constraints
WHERE table_schema = 'information_schema' AND table_name != 'ndb_binlog_index'
ORDER BY table_schema,table_name,constraint_name COLLATE utf8_general_ci;
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
# Switch to connection default and close connection testuser1
DROP USER testuser1@localhost;
DROP DATABASE db_datadict;
diff --git a/mysql-test/suite/funcs_1/r/is_table_constraints_mysql.result b/mysql-test/suite/funcs_1/r/is_table_constraints_mysql.result
index 4dda5be2116b..6d67d23c8aa2 100644
--- a/mysql-test/suite/funcs_1/r/is_table_constraints_mysql.result
+++ b/mysql-test/suite/funcs_1/r/is_table_constraints_mysql.result
@@ -6,46 +6,46 @@ GRANT SELECT ON db_datadict.* TO testuser1@localhost;
SELECT * FROM information_schema.table_constraints
WHERE table_schema = 'mysql' AND table_name != 'ndb_binlog_index'
ORDER BY table_schema,table_name,constraint_name COLLATE utf8_general_ci;
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
-def mysql PRIMARY mysql columns_priv PRIMARY KEY
-def mysql PRIMARY mysql component PRIMARY KEY
-def mysql PRIMARY mysql db PRIMARY KEY
-def mysql PRIMARY mysql default_roles PRIMARY KEY
-def mysql PRIMARY mysql engine_cost PRIMARY KEY
-def mysql PRIMARY mysql func PRIMARY KEY
-def mysql PRIMARY mysql global_grants PRIMARY KEY
-def mysql PRIMARY mysql gtid_executed PRIMARY KEY
-def mysql name mysql help_category UNIQUE
-def mysql PRIMARY mysql help_category PRIMARY KEY
-def mysql name mysql help_keyword UNIQUE
-def mysql PRIMARY mysql help_keyword PRIMARY KEY
-def mysql PRIMARY mysql help_relation PRIMARY KEY
-def mysql name mysql help_topic UNIQUE
-def mysql PRIMARY mysql help_topic PRIMARY KEY
-def mysql PRIMARY mysql innodb_index_stats PRIMARY KEY
-def mysql PRIMARY mysql innodb_table_stats PRIMARY KEY
-def mysql PRIMARY mysql password_history PRIMARY KEY
-def mysql PRIMARY mysql plugin PRIMARY KEY
-def mysql PRIMARY mysql procs_priv PRIMARY KEY
-def mysql PRIMARY mysql proxies_priv PRIMARY KEY
-def mysql PRIMARY mysql role_edges PRIMARY KEY
-def mysql PRIMARY mysql server_cost PRIMARY KEY
-def mysql PRIMARY mysql servers PRIMARY KEY
-def mysql PRIMARY mysql slave_master_info PRIMARY KEY
-def mysql PRIMARY mysql slave_relay_log_info PRIMARY KEY
-def mysql PRIMARY mysql slave_worker_info PRIMARY KEY
-def mysql PRIMARY mysql tables_priv PRIMARY KEY
-def mysql PRIMARY mysql time_zone PRIMARY KEY
-def mysql PRIMARY mysql time_zone_leap_second PRIMARY KEY
-def mysql PRIMARY mysql time_zone_name PRIMARY KEY
-def mysql PRIMARY mysql time_zone_transition PRIMARY KEY
-def mysql PRIMARY mysql time_zone_transition_type PRIMARY KEY
-def mysql PRIMARY mysql user PRIMARY KEY
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
+def mysql PRIMARY mysql columns_priv PRIMARY KEY YES
+def mysql PRIMARY mysql component PRIMARY KEY YES
+def mysql PRIMARY mysql db PRIMARY KEY YES
+def mysql PRIMARY mysql default_roles PRIMARY KEY YES
+def mysql PRIMARY mysql engine_cost PRIMARY KEY YES
+def mysql PRIMARY mysql func PRIMARY KEY YES
+def mysql PRIMARY mysql global_grants PRIMARY KEY YES
+def mysql PRIMARY mysql gtid_executed PRIMARY KEY YES
+def mysql name mysql help_category UNIQUE YES
+def mysql PRIMARY mysql help_category PRIMARY KEY YES
+def mysql name mysql help_keyword UNIQUE YES
+def mysql PRIMARY mysql help_keyword PRIMARY KEY YES
+def mysql PRIMARY mysql help_relation PRIMARY KEY YES
+def mysql name mysql help_topic UNIQUE YES
+def mysql PRIMARY mysql help_topic PRIMARY KEY YES
+def mysql PRIMARY mysql innodb_index_stats PRIMARY KEY YES
+def mysql PRIMARY mysql innodb_table_stats PRIMARY KEY YES
+def mysql PRIMARY mysql password_history PRIMARY KEY YES
+def mysql PRIMARY mysql plugin PRIMARY KEY YES
+def mysql PRIMARY mysql procs_priv PRIMARY KEY YES
+def mysql PRIMARY mysql proxies_priv PRIMARY KEY YES
+def mysql PRIMARY mysql role_edges PRIMARY KEY YES
+def mysql PRIMARY mysql server_cost PRIMARY KEY YES
+def mysql PRIMARY mysql servers PRIMARY KEY YES
+def mysql PRIMARY mysql slave_master_info PRIMARY KEY YES
+def mysql PRIMARY mysql slave_relay_log_info PRIMARY KEY YES
+def mysql PRIMARY mysql slave_worker_info PRIMARY KEY YES
+def mysql PRIMARY mysql tables_priv PRIMARY KEY YES
+def mysql PRIMARY mysql time_zone PRIMARY KEY YES
+def mysql PRIMARY mysql time_zone_leap_second PRIMARY KEY YES
+def mysql PRIMARY mysql time_zone_name PRIMARY KEY YES
+def mysql PRIMARY mysql time_zone_transition PRIMARY KEY YES
+def mysql PRIMARY mysql time_zone_transition_type PRIMARY KEY YES
+def mysql PRIMARY mysql user PRIMARY KEY YES
# Establish connection testuser1 (user=testuser1)
SELECT * FROM information_schema.table_constraints
WHERE table_schema = 'mysql' AND table_name != 'ndb_binlog_index'
ORDER BY table_schema,table_name,constraint_name COLLATE utf8_general_ci;
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
# Switch to connection default and close connection testuser1
DROP USER testuser1@localhost;
DROP DATABASE db_datadict;
diff --git a/mysql-test/suite/funcs_1/r/is_tables_is.result b/mysql-test/suite/funcs_1/r/is_tables_is.result
index dcacee98a432..e1084cc2aa25 100644
--- a/mysql-test/suite/funcs_1/r/is_tables_is.result
+++ b/mysql-test/suite/funcs_1/r/is_tables_is.result
@@ -40,6 +40,29 @@ user_comment
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA information_schema
+TABLE_NAME CHECK_CONSTRAINTS
+TABLE_TYPE SYSTEM VIEW
+ENGINE NULL
+VERSION 10
+ROW_FORMAT NULL
+TABLE_ROWS #TBLR#
+AVG_ROW_LENGTH #ARL#
+DATA_LENGTH #DL#
+MAX_DATA_LENGTH #MDL#
+INDEX_LENGTH #IL#
+DATA_FREE #DF#
+AUTO_INCREMENT #AI#
+CREATE_TIME #CRT#
+UPDATE_TIME #UT#
+CHECK_TIME #CT#
+TABLE_COLLATION NULL
+CHECKSUM NULL
+CREATE_OPTIONS #CO#
+TABLE_COMMENT #TC#
+user_comment
+Separator -----------------------------------------------------
+TABLE_CATALOG def
+TABLE_SCHEMA information_schema
TABLE_NAME COLLATIONS
TABLE_TYPE SYSTEM VIEW
ENGINE NULL
@@ -841,6 +864,29 @@ user_comment
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA information_schema
+TABLE_NAME CHECK_CONSTRAINTS
+TABLE_TYPE SYSTEM VIEW
+ENGINE NULL
+VERSION 10
+ROW_FORMAT NULL
+TABLE_ROWS #TBLR#
+AVG_ROW_LENGTH #ARL#
+DATA_LENGTH #DL#
+MAX_DATA_LENGTH #MDL#
+INDEX_LENGTH #IL#
+DATA_FREE #DF#
+AUTO_INCREMENT #AI#
+CREATE_TIME #CRT#
+UPDATE_TIME #UT#
+CHECK_TIME #CT#
+TABLE_COLLATION NULL
+CHECKSUM NULL
+CREATE_OPTIONS #CO#
+TABLE_COMMENT #TC#
+user_comment
+Separator -----------------------------------------------------
+TABLE_CATALOG def
+TABLE_SCHEMA information_schema
TABLE_NAME COLLATIONS
TABLE_TYPE SYSTEM VIEW
ENGINE NULL
diff --git a/mysql-test/suite/innodb/r/import_5_7.result b/mysql-test/suite/innodb/r/import_5_7.result
index 9c77c865a50f..1fca75a011a8 100644
--- a/mysql-test/suite/innodb/r/import_5_7.result
+++ b/mysql-test/suite/innodb/r/import_5_7.result
@@ -316,6 +316,7 @@ a b c d
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 8
}
diff --git a/mysql-test/suite/innodb/r/sdi_delete_marked.result b/mysql-test/suite/innodb/r/sdi_delete_marked.result
index 58078d2e99ca..b45aa58ae4f3 100644
--- a/mysql-test/suite/innodb/r/sdi_delete_marked.result
+++ b/mysql-test/suite/innodb/r/sdi_delete_marked.result
@@ -405,6 +405,7 @@ SET GLOBAL DEBUG= '+d, skip_purge_check_shutdown';
}
],
"foreign_keys": [],
+ "check_constraints": [],
"partitions": [],
"collation_id": 255
}
diff --git a/mysql-test/suite/innodb_gis/r/create_spatial_index.result b/mysql-test/suite/innodb_gis/r/create_spatial_index.result
index 03a75cbd647d..4dfa9f3c23ca 100644
--- a/mysql-test/suite/innodb_gis/r/create_spatial_index.result
+++ b/mysql-test/suite/innodb_gis/r/create_spatial_index.result
@@ -1625,13 +1625,17 @@ CHECK TABLE tab;
Table Op Msg_type Msg_text
test.tab check status OK
DROP TABLE tab;
-CREATE TABLE tab(c1 POINT NOT NULL SRID 0,CONSTRAINT tab_const check(c1 > 0) ) ENGINE=InnoDB;
+CREATE TABLE tab(c1 POINT NOT NULL SRID 0,
+CONSTRAINT tab_const
+CHECK(ST_Equals(c1, ST_GeomFromText("POINT(0 0)") = FALSE))
+) ENGINE=InnoDB;
CREATE SPATIAL INDEX idx1 ON tab(c1) ;
SHOW CREATE TABLE tab;
Table Create Table
tab CREATE TABLE `tab` (
`c1` point NOT NULL /*!80003 SRID 0 */,
- SPATIAL KEY `idx1` (`c1`)
+ SPATIAL KEY `idx1` (`c1`),
+ CONSTRAINT `tab_const` CHECK (st_equals(`c1`,(st_geomfromtext(_utf8mb4'POINT(0 0)') = FALSE)))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
ANALYZE TABLE tab;
Table Op Msg_type Msg_text
diff --git a/mysql-test/suite/innodb_gis/t/create_spatial_index.test b/mysql-test/suite/innodb_gis/t/create_spatial_index.test
index e321027dbbb5..ff4ab9adeb29 100644
--- a/mysql-test/suite/innodb_gis/t/create_spatial_index.test
+++ b/mysql-test/suite/innodb_gis/t/create_spatial_index.test
@@ -1121,7 +1121,10 @@ DROP TABLE tab;
# End of Testcase compress table with Auto_increment
# Test check constraint on spatial column
-CREATE TABLE tab(c1 POINT NOT NULL SRID 0,CONSTRAINT tab_const check(c1 > 0) ) ENGINE=InnoDB;
+CREATE TABLE tab(c1 POINT NOT NULL SRID 0,
+ CONSTRAINT tab_const
+ CHECK(ST_Equals(c1, ST_GeomFromText("POINT(0 0)") = FALSE))
+ ) ENGINE=InnoDB;
CREATE SPATIAL INDEX idx1 ON tab(c1) ;
diff --git a/mysql-test/suite/ndbcluster/information_schema_fk.result b/mysql-test/suite/ndbcluster/information_schema_fk.result
index f829f88ea407..728002a5409a 100644
--- a/mysql-test/suite/ndbcluster/information_schema_fk.result
+++ b/mysql-test/suite/ndbcluster/information_schema_fk.result
@@ -32,14 +32,14 @@ foreign key emp_fk1 (manager) references emp (id)
select * from information_schema.table_constraints
where table_schema = 'test'
order by table_name, constraint_type, constraint_name;
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
-def test PRIMARY test customer PRIMARY KEY
-def test emp_fk1 test emp FOREIGN KEY
-def test PRIMARY test emp PRIMARY KEY
-def test PRIMARY test product PRIMARY KEY
-def test fk1 test product_order FOREIGN KEY
-def test fk2 test product_order FOREIGN KEY
-def test PRIMARY test product_order PRIMARY KEY
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
+def test PRIMARY test customer PRIMARY KEY YES
+def test emp_fk1 test emp FOREIGN KEY YES
+def test PRIMARY test emp PRIMARY KEY YES
+def test PRIMARY test product PRIMARY KEY YES
+def test fk1 test product_order FOREIGN KEY YES
+def test fk2 test product_order FOREIGN KEY YES
+def test PRIMARY test product_order PRIMARY KEY YES
select CONCAT_WS('.', TABLE_NAME, COLUMN_NAME) as COL,
ORDINAL_POSITION,
POSITION_IN_UNIQUE_CONSTRAINT,
@@ -93,15 +93,15 @@ select *
from information_schema.table_constraints
where table_schema like 'mydb%'
order by table_name, constraint_type, constraint_name;
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
-def mydb1 fk_b1a1 mydb1 t1 FOREIGN KEY
-def mydb1 fk_b1b2 mydb1 t1 FOREIGN KEY
-def mydb1 PRIMARY mydb1 t1 PRIMARY KEY
-def mydb1 xb1 mydb1 t1 UNIQUE
-def mydb2 fk_b2a2 mydb2 t2 FOREIGN KEY
-def mydb2 fk_b2b1 mydb2 t2 FOREIGN KEY
-def mydb2 PRIMARY mydb2 t2 PRIMARY KEY
-def mydb2 xb2 mydb2 t2 UNIQUE
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE ENFORCED
+def mydb1 fk_b1a1 mydb1 t1 FOREIGN KEY YES
+def mydb1 fk_b1b2 mydb1 t1 FOREIGN KEY YES
+def mydb1 PRIMARY mydb1 t1 PRIMARY KEY YES
+def mydb1 xb1 mydb1 t1 UNIQUE YES
+def mydb2 fk_b2a2 mydb2 t2 FOREIGN KEY YES
+def mydb2 fk_b2b1 mydb2 t2 FOREIGN KEY YES
+def mydb2 PRIMARY mydb2 t2 PRIMARY KEY YES
+def mydb2 xb2 mydb2 t2 UNIQUE YES
select *
from information_schema.key_column_usage
where table_schema like 'mydb%'
diff --git a/mysql-test/suite/rpl/r/rpl_check_constraints.result b/mysql-test/suite/rpl/r/rpl_check_constraints.result
new file mode 100644
index 000000000000..75f5282a5d9f
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_check_constraints.result
@@ -0,0 +1,55 @@
+include/master-slave.inc
+Warnings:
+Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
+Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
+[connection master]
+CALL mtr.add_suppression("Check constraint 't1_chk_2' is violated.");
+CALL mtr.add_suppression("The slave coordinator and worker threads are stopped, possibly leaving data in inconsistent state");
+CREATE TABLE t1 (f1 int primary key, CHECK(f1 < 100));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) NOT NULL,
+ PRIMARY KEY (`f1`),
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` < 100))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+INSERT INTO t1 (f1) VALUES(20);
+include/sync_slave_sql_with_master.inc
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) NOT NULL,
+ PRIMARY KEY (`f1`),
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` < 100))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+ALTER TABLE t1 ADD CONSTRAINT CHECK(f1 < 50);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) NOT NULL,
+ PRIMARY KEY (`f1`),
+ CONSTRAINT `t1_chk_1` CHECK ((`f1` < 100)),
+ CONSTRAINT `t1_chk_2` CHECK ((`f1` < 50))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+[connection master]
+update t1 set f1 = 80;
+[connection slave]
+# t1_chk_2 check constraint validation for update fails at slave.
+include/wait_for_slave_sql_error.inc [errno=3820]
+SELECT * from t1;
+f1
+20
+[connection master]
+insert into t1 values(90);
+[connection slave]
+# t1_chk_2 check constraint validation for insert fails at slave.
+include/wait_for_slave_sql_error.inc [errno=3820]
+SELECT * from t1;
+f1
+20
+[connection master]
+DROP TABLE t1;
+[connection slave]
+DROP TABLE t1;
+include/rpl_reset.inc
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_check_constraints.test b/mysql-test/suite/rpl/t/rpl_check_constraints.test
new file mode 100644
index 000000000000..8363ad021f83
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_check_constraints.test
@@ -0,0 +1,45 @@
+################################################################################
+# WL929 - CHECK CONSTRAINTS. #
+################################################################################
+
+--source include/master-slave.inc
+
+CALL mtr.add_suppression("Check constraint 't1_chk_2' is violated.");
+CALL mtr.add_suppression("The slave coordinator and worker threads are stopped, possibly leaving data in inconsistent state");
+
+CREATE TABLE t1 (f1 int primary key, CHECK(f1 < 100));
+SHOW CREATE TABLE t1;
+INSERT INTO t1 (f1) VALUES(20);
+
+--source include/sync_slave_sql_with_master.inc
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 ADD CONSTRAINT CHECK(f1 < 50);
+SHOW CREATE TABLE t1;
+
+--source include/rpl_connection_master.inc
+update t1 set f1 = 80;
+
+--source include/rpl_connection_slave.inc
+--echo # t1_chk_2 check constraint validation for update fails at slave.
+--let $slave_sql_errno= convert_error(ER_CHECK_CONSTRAINT_VIOLATED)
+--source include/wait_for_slave_sql_error.inc
+SELECT * from t1;
+
+--source include/rpl_connection_master.inc
+insert into t1 values(90);
+
+--source include/rpl_connection_slave.inc
+--echo # t1_chk_2 check constraint validation for insert fails at slave.
+--let $slave_sql_errno= convert_error(ER_CHECK_CONSTRAINT_VIOLATED)
+--source include/wait_for_slave_sql_error.inc
+SELECT * from t1;
+
+--source include/rpl_connection_master.inc
+DROP TABLE t1;
+
+--source include/rpl_connection_slave.inc
+DROP TABLE t1;
+
+--let $rpl_only_running_threads= 1
+--source include/rpl_reset.inc
+--source include/rpl_end.inc
diff --git a/mysql-test/t/check_constraints.test b/mysql-test/t/check_constraints.test
new file mode 100644
index 000000000000..12fad47b0b77
--- /dev/null
+++ b/mysql-test/t/check_constraints.test
@@ -0,0 +1,1917 @@
+################################################################################
+# WL929 - CHECK CONSTRAINTS. #
+# Test file has cases to verify check constraint feature, common #
+# restrictions and mysql specific restriction on check constraints. #
+################################################################################
+
+--echo #------------------------------------------------------------------------
+--echo # Test cases to verify column check constraint syntax.
+--echo #------------------------------------------------------------------------
+--error ER_PARSE_ERROR
+CREATE TABLE t1(f1 int CHECK);
+
+--error ER_PARSE_ERROR
+CREATE TABLE t1(f1 int CHECK());
+
+--error ER_PARSE_ERROR
+CREATE TABLE t1(f1 int CONSTRAINT CHECK());
+
+--error ER_PARSE_ERROR
+CREATE TABLE t1(f1 int t1_ck CHECK());
+
+--error ER_PARSE_ERROR
+CREATE TABLE t1(f1 int CONSTRAINT t1_ck CHECK());
+
+--error ER_PARSE_ERROR
+CREATE TABLE t1(f1 int CONSTRAINT t1_ck CHECK( f1 < 10) NOT);
+
+--error ER_NON_BOOLEAN_EXPR_FOR_CHECK_CONSTRAINT
+CREATE TABLE t1(f1 int CHECK(f1));
+
+--error ER_NON_BOOLEAN_EXPR_FOR_CHECK_CONSTRAINT
+CREATE TABLE t1(f1 int CHECK(f1 + 10));
+
+--error ER_COLUMN_CHECK_CONSTRAINT_REFERENCES_OTHER_COLUMN
+CREATE TABLE t1(f1 int CHECK(f2 < 10));
+
+CREATE TABLE t1 (f1 int CHECK(f1 < 10),
+ f2 int CONSTRAINT t1_f2_ck CHECK (f2 < 10));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+--error ER_PARSE_ERROR
+CREATE TABLE t1(f1 int CHECK(f1 < 10), f2 int CHECK);
+
+--error ER_PARSE_ERROR
+CREATE TABLE t1(f1 int CHECK(f1 < 10), f2 int CHECK());
+
+--error ER_PARSE_ERROR
+CREATE TABLE t1(f1 int CHECK(f1 < 10), f2 int CONSTRAINT CHECK());
+
+--error ER_PARSE_ERROR
+CREATE TABLE t1(f1 int CHECK(f1 < 10), f2 int t1_f2_ck CHECK(f2 < 10));
+
+--error ER_PARSE_ERROR
+CREATE TABLE t1(f1 int CHECK(f1 < 10), f2 int CONSTRAINT t1_f2_ck CHECK(f2 < 10) NOT);
+
+--error ER_PARSE_ERROR
+CREATE TABLE t1(f1 int CHECK(f1 < 10), f2 int CHECK(f2 < 10) NOT);
+
+--error ER_NON_BOOLEAN_EXPR_FOR_CHECK_CONSTRAINT
+CREATE TABLE t1(f1 int CHECK(f1 < 10), f2 int CHECK(f2));
+
+--error ER_NON_BOOLEAN_EXPR_FOR_CHECK_CONSTRAINT
+CREATE TABLE t1(f1 int CHECK(f1 < 10), f2 int CHECK(f2 + 10));
+
+--error ER_COLUMN_CHECK_CONSTRAINT_REFERENCES_OTHER_COLUMN
+CREATE TABLE t1(f1 int CHECK(f1 < 10), f2 int CHECK(f3 < 10));
+
+CREATE TABLE t1 (f1 int CHECK(f1 < 10), f2 int CHECK(f2 < 10),
+ f3 int CONSTRAINT t1_f3_ck CHECK (f3 < 10));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test cases to verify table check constraint syntax.
+--echo #------------------------------------------------------------------------
+--error ER_PARSE_ERROR
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK);
+
+--error ER_PARSE_ERROR
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK();
+
+--error ER_PARSE_ERROR
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK());
+
+--error ER_NON_BOOLEAN_EXPR_FOR_CHECK_CONSTRAINT
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK(f1));
+
+--error ER_NON_BOOLEAN_EXPR_FOR_CHECK_CONSTRAINT
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK(f1 + 10));
+
+--error ER_CHECK_CONSTRAINT_REFERS_UNKNOWN_COLUMN
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK(f2 < 10));
+
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK(f1 < 10));
+
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+--error ER_PARSE_ERROR
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK(f1<10), CONSTRAINT t2_ck CHECK);
+
+--error ER_PARSE_ERROR
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK(f1<10), CONSTRAINT t2_ck CHECK();
+
+--error ER_PARSE_ERROR
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK(f1<10), CONSTRAINT t2_ck CHECK(f2 > 0) NOT);
+
+--error ER_NON_BOOLEAN_EXPR_FOR_CHECK_CONSTRAINT
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK(f1<10), CONSTRAINT t2_ck CHECK(f1));
+
+--error ER_NON_BOOLEAN_EXPR_FOR_CHECK_CONSTRAINT
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK(f1<10), CONSTRAINT t2_ck CHECK(f1 + 10));
+
+--error ER_CHECK_CONSTRAINT_REFERS_UNKNOWN_COLUMN
+CREATE TABLE t1(f1 int, CONSTRAINT t1_ck CHECK(f1<10), CONSTRAINT t2_ck CHECK(f2 > 1));
+
+# Check constraint with specified and generated name.
+CREATE TABLE t1(f1 int, CHECK(f1<10), CONSTRAINT t2_ck CHECK(f1 > 1));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint name with special charecters.
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, c2 INT, CONSTRAINT `ck_1$` CHECK (c2 < 10));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint name with white spaces.
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, c2 INT, CONSTRAINT ` ck_2$ ` CHECK (c2 < 10));
+SHOW CREATE TABLE t1;
+--error ER_CHECK_CONSTRAINT_NOT_FOUND
+ALTER TABLE t1 DROP CHECK ck_2$;
+ALTER TABLE t1 DROP CHECK ` ck_2$ `;
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 ADD COLUMN c3 INTEGER , ADD CONSTRAINT ` c 3 ` CHECK ( c3 > 10 );
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint name with reserved words.
+--echo #-----------------------------------------------------------------------
+--error ER_PARSE_ERROR
+CREATE TABLE t1(c1 INT, c2 INT, CONSTRAINT FLOAT CHECK (c2 < 10));
+CREATE TABLE t1(c1 INT, c2 INT, CONSTRAINT `FLOAT` CHECK (c2 < 10));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint with long name.
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, c2 INT,
+ CONSTRAINT ckkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+ CHECK (c2 < 10));
+SHOW CREATE TABLE t1;
+--error ER_TOO_LONG_IDENT
+CREATE TABLE t2(c1 INT, c2 INT,
+ CONSTRAINT ckkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk1
+ CHECK (c2 < 10));
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint with too long generated name.
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1 (f1 INT CHECK (f1 < 10));
+--error ER_TOO_LONG_IDENT
+RENAME TABLE t1 TO t123456789012345678901234567890123456789012345678901234567890;
+DROP TABLE t1;
+
+--error ER_TOO_LONG_IDENT
+CREATE TABLE t123456789012345678901234567890123456789012345678901234567890(f1 INT CHECK(f1 < 10));
+
+CREATE TABLE t123456789012345678901234567890123456789012345678901234567890(f1 INT);
+--error ER_TOO_LONG_IDENT
+ALTER TABLE t123456789012345678901234567890123456789012345678901234567890 ADD CONSTRAINT CHECK (f1 < 10);
+DROP TABLE t123456789012345678901234567890123456789012345678901234567890;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify duplicate check constraint name under same
+--echo # database. Check constraints with same name are not allowed under
+--echo # same database.
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t(c1 INT CONSTRAINT t2_chk_1 CHECK (c1 > 10));
+CREATE TABLE t1(c1 INT CHECK (c1 > 10), CONSTRAINT ck CHECK(c1 > 10));
+--error ER_CHECK_CONSTRAINT_DUP_NAME
+CREATE TABLE t2(c1 INT, CONSTRAINT ck CHECK(c1 > 10));
+--error ER_CHECK_CONSTRAINT_DUP_NAME
+ALTER TABLE t1 ADD CONSTRAINT ck CHECK(c1 > 10);
+--error ER_CHECK_CONSTRAINT_DUP_NAME
+ALTER TABLE t1 RENAME TO t2;
+--error ER_CHECK_CONSTRAINT_DUP_NAME
+ALTER TABLE t1 ADD c2 INT, RENAME TO t2;
+DROP TABLE t;
+
+CREATE DATABASE db1;
+CREATE TABLE db1.t(c1 INT CONSTRAINT t2_chk_1 CHECK (c1 > 10));
+--error ER_CHECK_CONSTRAINT_DUP_NAME
+ALTER TABLE t1 ADD c2 INT, RENAME TO db1.t2;
+--error ER_CHECK_CONSTRAINT_DUP_NAME
+ALTER TABLE t1 RENAME TO db1.t2;
+DROP DATABASE db1;
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Check constraint names are case insenitive and accent sensitive. Test
+--echo # case to verify the same.
+--echo #-----------------------------------------------------------------------
+--error ER_CHECK_CONSTRAINT_DUP_NAME
+CREATE TABLE t1 (f1 INT,
+ CONSTRAINT cafe CHECK (f1 < 10),
+ CONSTRAINT CAFE CHECK (f1 < 10));
+create table t1 (f1 int,
+ CONSTRAINT cafe CHECK (f1 < 10),
+ CONSTRAINT café CHECK (f1 < 10));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test cases to verify forward reference of columns in the constraint.
+--echo #------------------------------------------------------------------------
+--error ER_CHECK_CONSTRAINT_REFERS_UNKNOWN_COLUMN
+CREATE TABLE t1(CHECK((f1 + f3) > 10), f1 int CHECK (f1 < 10), f2 int);
+
+CREATE TABLE t1(CHECK((f1 + f2) > 10), f1 int CHECK (f1 < 10), f2 int);
+SHOW CREATE TABLE t1;
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify creation of multiple check constraint on table.
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, c2 INT, c3 INT, c4 INT);
+ALTER TABLE t1 ADD CONSTRAINT ck11 CHECK(c1 > 1),
+ ADD CONSTRAINT ck12 CHECK(c1 < 1),
+ ADD CONSTRAINT ck21 CHECK(c2 > 1),
+ ADD CONSTRAINT ck22 CHECK(c2 < 1),
+ ADD CONSTRAINT ck31 CHECK(c3 > 1),
+ ADD CONSTRAINT ck32 CHECK(c3 < 1),
+ ADD CONSTRAINT ck41 CHECK(c4 > 1),
+ ADD CONSTRAINT ck42 CHECK(c4 < 1);
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraints with generated columns
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT,
+ c2 INT,
+ c3 INT GENERATED ALWAYS AS (c1 + c2),
+ CONSTRAINT ck CHECK (c3 > 10)
+);
+SHOW CREATE TABLE t1;
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c1,c2) VALUES(1,1);
+INSERT INTO t1(c1,c2) VALUES(10,10);
+DROP TABLE t1;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test case to verify check constraints with DEFAULT column value.
+--echo #------------------------------------------------------------------------
+CREATE TABLE t1(c1 INT DEFAULT 100 CHECK(c1 > 10));
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1() VALUES(1);
+INSERT INTO t1() VALUES();
+DROP TABLE t1;
+CREATE TABLE t1(c1 int DEFAULT 1, CONSTRAINT CHECK(c1 IS NOT NULL));
+INSERT INTO t1() VALUES();
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1() VALUES(NULL);
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint behaviour with ascii charset
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(c1 VARCHAR(1) CHARSET ASCII CHECK(c1 = 'a'),
+ c2 VARCHAR(1) CHARSET ASCII DEFAULT('b'));
+SHOW CREATE TABLE t1;
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c1) VALUES('b');
+INSERT INTO t1(c1) VALUES('a');
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint with an expression evaluated to
+--echo # FALSE always.
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1 (CHECK (1 < 1), f1 int);
+SHOW CREATE TABLE t1;
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES(1);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES(10);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES();
+DROP TABLE t1;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test case to verify INFORMATION_SCHEMA.CHECK_CONSTRAINTS and
+--echo # INFORMATION_SCHEMA.TABLE_CONSTRAINTS result set.
+--echo #------------------------------------------------------------------------
+CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT CHECK (f2 < 10),
+ CONSTRAINT t2_cc1 CHECK (f1 + SQRT(f2) > 6174));
+SHOW CREATE TABLE t1;
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE TABLE_NAME='t1';
+DROP TABLE t1;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test cases to verify check constraints in temporary table.
+--echo #------------------------------------------------------------------------
+CREATE TEMPORARY TABLE tmp_t1(CHECK((f1 + f2) > 10), f1 int CHECK (f1 < 12),
+ f2 int);
+SHOW CREATE TABLE tmp_t1;
+# Temporary table check constraints are not listed in CHECK_CONSTRAINTS.
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+DROP TABLE tmp_t1;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test cases to verify check constraints with CREATE TABLE LIKE
+--echo #------------------------------------------------------------------------
+CREATE TABLE t1(f1 INT CHECK (f1 < 10), f2 INT, CHECK (f2 < 10),
+ CONSTRAINT min CHECK (f1 + f2 > 10),
+ CONSTRAINT max CHECK (f1 + f2 < 929));
+SHOW CREATE TABLE t1;
+CREATE TABLE t2 LIKE t1;
+# t2 will have check constraints with all generated names.
+SHOW CREATE TABLE t2;
+
+CREATE TEMPORARY TABLE tmp_t2 LIKE t2;
+SHOW CREATE TABLE tmp_t2;
+CREATE TABLE t3 LIKE tmp_t2;
+# t3 will have check constraints with all generated names.
+SHOW CREATE TABLE t3;
+DROP TABLE t1, t2, t3, tmp_t2;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test cases to verify effect of check constraint in DML operations.
+--echo #------------------------------------------------------------------------
+CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT CHECK (f2 < 10));
+SHOW CREATE TABLE t1;
+CREATE TABLE t2(f1 INT, f2 INT);
+INSERT INTO t2 VALUES(101, 1);
+INSERT INTO t2 VALUES(102, NULL);
+INSERT INTO t2 VALUES(103, 1000);
+
+--echo # INSERT operations.
+INSERT INTO t1 VALUES(1, 1);
+INSERT INTO t1 VALUES(2, NULL);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES(3, 1000);
+INSERT IGNORE INTO t1 VALUES (3, 1000);
+SELECT * FROM t1;
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 SELECT * FROM t2;
+SELECT * FROM t1;
+INSERT IGNORE INTO t1 SELECT * FROM t2;
+SELECT * FROM t1;
+
+--echo # REPLACE operations.
+REPLACE INTO t1 VALUES(4, 1);
+REPLACE INTO t1 VALUES(5, NULL);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+REPLACE INTO t1 VALUES(6, 100);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+REPLACE INTO t1 VALUES(2, 10);
+REPLACE INTO t1 VALUES(2, 2);
+SELECT * FROM t1;
+
+--echo # UPDATE operations.
+UPDATE t1 SET f2 = 2;
+SELECT * FROM t1;
+UPDATE t1 SET f2 = NULL;
+--error ER_CHECK_CONSTRAINT_VIOLATED
+UPDATE t1 SET f2 = 1000;
+UPDATE IGNORE t1 SET f2 = 1000;
+SELECT * FROM t1;
+DROP TABLE t1, t2;
+
+--echo # LOAD DATA operations.
+CREATE TABLE t2(f1 INT,f2 INT);
+INSERT INTO t2 VALUES(1,1);
+INSERT INTO t2 VALUES(2,NULL);
+CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT CHECK (f2 < 10));
+SHOW CREATE TABLE t1;
+SELECT * FROM t2;
+SELECT * FROM t2 INTO OUTFILE 'tmp1.txt';
+LOAD DATA INFILE 'tmp1.txt' INTO TABLE t1;
+SELECT * FROM t1;
+DELETE FROM t1;
+INSERT INTO t2 VALUES(3,20);
+SELECT * FROM t2;
+SELECT * FROM t2 INTO OUTFILE 'tmp2.txt';
+--error ER_CHECK_CONSTRAINT_VIOLATED
+LOAD DATA INFILE 'tmp2.txt' INTO TABLE t1;
+SELECT * FROM t1;
+LOAD DATA INFILE 'tmp2.txt' IGNORE INTO TABLE t1;
+SELECT * FROM t1;
+DROP TABLE t1,t2;
+CREATE TABLE t1 (a INT CHECK(a < 3), b CHAR(10)) CHARSET latin1;
+LOAD DATA INFILE '../../std_data/loaddata3.dat' IGNORE INTO TABLE t1
+ FIELDS TERMINATED BY '' ENCLOSED BY '' IGNORE 1 LINES;
+DROP TABLE t1;
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+remove_file $MYSQLD_DATADIR/test/tmp1.txt;
+remove_file $MYSQLD_DATADIR/test/tmp2.txt;
+
+--echo # LOAD XML operations.
+CREATE TABLE t2(f1 INT,f2 INT);
+INSERT INTO t2 VALUES(1,1);
+INSERT INTO t2 VALUES(2,NULL);
+CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT CHECK (f2 < 10));
+SHOW CREATE TABLE t1;
+SELECT * FROM t2;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--exec $MYSQL_DUMP --xml test t2 > "$MYSQLTEST_VARDIR/tmp/tmp1.xml" 2>&1
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval LOAD XML INFILE "$MYSQLTEST_VARDIR/tmp/tmp1.xml" INTO TABLE t1;
+SELECT * FROM t1;
+DELETE FROM t1;
+INSERT INTO t2 VALUES(3,20);
+SELECT * FROM t2;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--exec $MYSQL_DUMP --xml test t2 > "$MYSQLTEST_VARDIR/tmp/tmp2.xml" 2>&1
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error ER_CHECK_CONSTRAINT_VIOLATED
+--eval LOAD XML INFILE "$MYSQLTEST_VARDIR/tmp/tmp2.xml" INTO TABLE t1;
+SELECT * FROM t1;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval LOAD XML INFILE "$MYSQLTEST_VARDIR/tmp/tmp2.xml" IGNORE INTO TABLE t1;
+SELECT * FROM t1;
+DROP TABLE t1,t2;
+
+remove_file $MYSQLTEST_VARDIR/tmp/tmp1.xml;
+remove_file $MYSQLTEST_VARDIR/tmp/tmp2.xml;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint with INSERT ON DUPLICATE
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT CHECK (f2 < 10));
+INSERT INTO t1 VALUES (1, 1);
+INSERT INTO t1 VALUES (1, 2) ON DUPLICATE KEY UPDATE f2 = 4;
+SELECT * FROM t1;
+INSERT IGNORE INTO t1 VALUES (1, 1) ON DUPLICATE KEY UPDATE f2 = 20;
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES (1, 1) ON DUPLICATE KEY UPDATE f2 = 20;
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraints with multi-table update.
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(f1 INT, f2 INT CHECK(f2 < 20));
+INSERT INTO t1 VALUES (4, 4);
+CREATE TABLE t2(f1 INT, f2 INT);
+INSERT INTO t2 VALUES (4, 24);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+UPDATE t1,t2 SET t1.f2 = t1.f2 + 20 WHERE t1.f1 = t2.f1;
+UPDATE IGNORE t1,t2 SET t1.f2 = t1.f2 + 20 WHERE t1.f1 = t2.f1;
+DROP TABLE t1, t2;
+
+CREATE TABLE t1 (
+ `f1` int(10) unsigned NOT NULL auto_increment,
+ `f2` int(11) NOT NULL default '0',
+ PRIMARY KEY (`f1`)
+);
+INSERT INTO t1 VALUES (4433,5424);
+CREATE TABLE t2 (
+ `f3` int(10) unsigned NOT NULL default '0',
+ `f4` int(10) unsigned NOT NULL default '0' CHECK (f4 <= 500),
+ PRIMARY KEY (`f3`,`f4`)
+);
+INSERT INTO t2 VALUES (495,500);
+INSERT INTO t2 VALUES (496,500);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+UPDATE t2,t1 set t2.f4 = t2.f4 + 1;
+UPDATE IGNORE t2,t1 set t2.f4 = t2.f4 + 1;
+DROP TABLE t1, t2;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test cases to verify generated check constraint name updates due to
+--echo # RENAME TABLE operation.
+--echo #------------------------------------------------------------------------
+CREATE TABLE t1 (f1 INT CHECK(f1 < 10));
+SHOW CREATE TABLE t1;
+RENAME TABLE t1 TO t2;
+SHOW CREATE TABLE t2;
+
+CREATE TABLE t1(f1 INT CHECK (f1>10), f11 INT CHECK (f11 < 1000));
+SHOW CREATE TABLE t1;
+RENAME TABLE t1 TO t3, t2 TO t1, t3 TO t2;
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t1, t2;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test case to verify check constraints removal on DROP table operation.
+--echo #------------------------------------------------------------------------
+CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT CHECK (f2 < 10));
+SHOW CREATE TABLE t1;
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE TABLE_NAME='t1';
+DROP TABLE t1;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test case to verify check constraints creation with ALTER TABLE ADD
+--echo # CONSTRAINT operation.
+--echo #------------------------------------------------------------------------
+CREATE TABLE t1 (f1 INT CHECK (f1 < 10));
+CREATE TEMPORARY TABLE t3(f1 INT CHECK (f1 < 10));
+ALTER TABLE t1 ADD CONSTRAINT CHECK (f1 > 1), ADD CONSTRAINT `t1_p_ck` CHECK (f1 > 1);
+ALTER TABLE t3 ADD CONSTRAINT CHECK (f1 > 1), ADD CONSTRAINT `t3_p_ck` CHECK (f1 > 1);
+
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE t3;
+
+--echo # Test case to verify check constraint creation with ALTER TABLE ADD
+--echo # constraint and generated name updates with RENAME TO in
+--echo # ALTER operation.
+ALTER TABLE t1 ADD f2 INT CHECK (f2 < 10), RENAME TO t6, ALGORITHM=COPY;
+SHOW CREATE TABLE t6;
+ALTER TABLE t3 ADD f2 INT CHECK (f2 < 10), RENAME TO t7, ALGORITHM=COPY;
+SHOW CREATE TABLE t7;
+ALTER TABLE t6 RENAME TO t1;
+SHOW CREATE TABLE t1;
+ALTER TABLE t7 RENAME TO t3;
+SHOW CREATE TABLE t3;
+
+--echo # Test case to verify add check constraint with INPLACE alter algorithm.
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+ALTER TABLE t1 ADD f2 INT CHECK (f2 < 10), ALGORITHM=INPLACE;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+ALTER TABLE t3 ADD f2 INT CHECK (f2 < 10), ALGORITHM=INPLACE;
+ALTER TABLE t1 ADD f3 INT CHECK (f3 < 10) NOT ENFORCED, ALGORITHM=INPLACE;
+ALTER TABLE t1 ADD CONSTRAINT CHECK (f2 < 10) NOT ENFORCED, ALGORITHM=INPLACE;
+
+--ERROR ER_BAD_FIELD_ERROR
+ALTER TABLE t1 RENAME COLUMN f1 TO f10;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test case to verify check constraints creation with ALTER TABLE DROP
+--echo # CONSTRAINT operation.
+--echo #------------------------------------------------------------------------
+SHOW CREATE TABLE t3;
+ALTER TABLE t3 DROP CHECK t3_chk_3;
+SHOW CREATE TABLE t3;
+ALTER TABLE t3 DROP CHECK t3_p_ck, ADD CONSTRAINT t3_p_ck CHECK (f1 > 38);
+SHOW CREATE TABLE t3;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test case to verify check constraints alter operations.
+--echo #------------------------------------------------------------------------
+INSERT INTO t1 VALUES (5, 5, 5);
+ALTER TABLE t1 ALTER CHECK t1_chk_1 NOT ENFORCED, ALGORITHM=INPLACE;
+INSERT INTO t1 VALUES (8, 8, 8);
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+ALTER TABLE t1 ALTER CHECK t1_chk_1 ENFORCED, ALGORITHM=INPLACE;
+ALTER TABLE t1 ALTER CHECK t1_chk_1 ENFORCED, ALGORITHM=COPY;
+ALTER TABLE t1 ALTER CHECK t1_chk_1 ENFORCED, ALGORITHM=INPLACE;
+
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES (12, 5, 5);
+ALTER TABLE t1 ALTER CHECK t1_chk_1 NOT ENFORCED, ALGORITHM=INPLACE;
+INSERT INTO t1 VALUES (12, 5, 5);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+ALTER TABLE t1 ALTER CHECK t1_chk_1 ENFORCED, ALGORITHM=COPY;
+
+DROP TABLE t1, t3;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to add check constraint with copy,instant,inplace algorithm
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT);
+ALTER TABLE t1 ADD CONSTRAINT CHECK (C1 > 10), ALGORITHM=COPY;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+ALTER TABLE t1 ADD CONSTRAINT CHECK (C1 > 10), ALGORITHM=INPLACE;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+ALTER TABLE t1 ADD CONSTRAINT CHECK (C1 > 10), ALGORITHM=INSTANT;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify drop check constraint with inplace algorithm.
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1 (f1 INT CHECK (f1 < 10));
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 DROP CHECK t1_chk_1, ALGORITHM=INPLACE;
+ALTER TABLE t1 ADD CONSTRAINT t1_chk_1 CHECK (f1 < 10), DROP CHECK t1_chk_1, ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to alter table to add/drop column with the check constraint.
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1 (c1 INT, CONSTRAINT ck1 CHECK (c1 > 10));
+ALTER TABLE t1 ADD COLUMN c2 INT,
+ ADD CONSTRAINT ck2 CHECK (c2 > 10);
+SHOW CREATE TABLE t1;
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES(20,10);
+ALTER TABLE t1 DROP CHECK ck2, DROP COLUMN c2;
+ALTER TABLE t1 ADD COLUMN c3 INT,
+ ADD CONSTRAINT ck3 CHECK (c3 < 10);
+ALTER TABLE t1 DROP CHECK ck3, DROP COLUMN c3,
+ ADD COLUMN c4 INT, ADD CONSTRAINT ck4 CHECK( c4 > 10);
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify
+--echo # - Creation of check constraint with NOT ENFORCED state.
+--echo # - Listing state of the check constraints with SHOW and
+--echo # INFORMATION_SCHEMA.CHECK_CONSTRAINTS table.
+--echo # - State updates with ALTER TABLE statement to ALTER
+--echo # check constraints.
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(f1 INT,
+ f2 INT CHECK (f2 < 10),
+ f3 INT CHECK (f3 < 10) NOT ENFORCED,
+ CONSTRAINT ck CHECK (f1 > 10),
+ CONSTRAINT CHECK (f1 > 10) NOT ENFORCED);
+SHOW CREATE TABLE t1;
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+
+--echo # REVOKE check constraint ck.
+ALTER TABLE t1 ALTER CHECK ck NOT ENFORCED;
+SHOW CREATE TABLE t1;
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+
+--echo # ENFORCE check constraint ck.
+ALTER TABLE t1 ALTER CHECK ck ENFORCED;
+SHOW CREATE TABLE t1;
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+
+--echo # Add new constraint in NOT ENFORCED state.
+ALTER TABLE t1 ADD CONSTRAINT ck1 CHECK(f1<10) NOT ENFORCED;
+SHOW CREATE TABLE t1;
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+
+--echo # ENFORCE check constraint ck1
+ALTER TABLE t1 ALTER CHECK ck1 ENFORCED;
+SHOW CREATE TABLE t1;
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+
+--echo # ENFORCE check constraint t1_chk_2
+ALTER TABLE t1 ALTER CHECK t1_chk_2 ENFORCED;
+SHOW CREATE TABLE t1;
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+
+--echo # ADD column check constraint in NOT ENFORCED state.
+ALTER TABLE t1 ADD f4 INT CONSTRAINT t1_f4_chk CHECK (f4 < 10) NOT ENFORCED;
+SHOW CREATE TABLE t1;
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+
+--echo # ENFORCE check constraint t1_f4_chk
+ALTER TABLE t1 ALTER CHECK t1_f4_chk ENFORCED;
+SHOW CREATE TABLE t1;
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify alter statement with drop and alter constraint
+--echo # on non-existing check constraint.
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, c2 INT, c3 INT, c4 INT);
+--error ER_CHECK_CONSTRAINT_NOT_FOUND
+ALTER TABLE t1 DROP CHECK ck13;
+--error ER_CHECK_CONSTRAINT_NOT_FOUND
+ALTER TABLE t1 ALTER CHECK ck13 ENFORCED;
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify alter statement with multiple add, drop, enforce,
+--echo # revoke check constraints.
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, c2 INT, c3 INT, c4 INT);
+ALTER TABLE t1 ADD CONSTRAINT ck11 CHECK(c1 > 1),
+ ADD CONSTRAINT ck12 CHECK(c1 < 1),
+ ADD CONSTRAINT ck21 CHECK(c2 > 1),
+ ADD CONSTRAINT ck22 CHECK(c2 < 1),
+ ADD CONSTRAINT ck31 CHECK(c3 > 1),
+ ADD CONSTRAINT ck32 CHECK(c3 < 1),
+ ADD CONSTRAINT ck41 CHECK(c4 > 1),
+ ADD CONSTRAINT ck42 CHECK(c4 < 1);
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1
+ DROP CHECK ck11, ADD CONSTRAINT ck11 CHECK (c1 > 10),
+ DROP CHECK ck12, ADD CONSTRAINT ck12 CHECK (c1 < 10),
+ DROP CHECK ck21, ADD CONSTRAINT ck21 CHECK (c1 > 10),
+ DROP CHECK ck22, ADD CONSTRAINT ck22 CHECK (c1 < 10),
+ DROP CHECK ck31, ADD CONSTRAINT ck31 CHECK (c1 > 10),
+ DROP CHECK ck32, ADD CONSTRAINT ck32 CHECK (c1 < 10),
+ DROP CHECK ck41, ADD CONSTRAINT ck41 CHECK (c1 > 10),
+ DROP CHECK ck42, ADD CONSTRAINT ck42 CHECK (c1 < 10),
+ ALTER CHECK ck11 NOT ENFORCED,
+ ALTER CHECK ck12 NOT ENFORCED,
+ ALTER CHECK ck21 NOT ENFORCED,
+ ALTER CHECK ck22 NOT ENFORCED,
+ ALTER CHECK ck11 ENFORCED;
+
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify auto-drop of check constraint on column drop.
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1 (f1 INT check (f1 < 10), f2 INT);
+SHOW CREATE TABLE t1;
+--echo # Drops check constraint t1_chk_1 too.
+ALTER TABLE t1 DROP COLUMN f1;
+
+ALTER TABLE t1 ADD COLUMN f1 INT check(f1 < 10),
+ ADD CONSTRAINT check(f1 + f2 < 10),
+ ADD CONSTRAINT check(f2 < 10);
+SHOW CREATE TABLE t1;
+--error ER_BAD_FIELD_ERROR
+ALTER TABLE t1 DROP COLUMN f1;
+--error ER_BAD_FIELD_ERROR
+ALTER TABLE t1 RENAME COLUMN f1 to f3;
+--echo # Drops column f1 and constraints t1_chk_1, t1_chk_2.
+ALTER TABLE t1 DROP CHECK t1_chk_2, DROP COLUMN f1;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint with MODIFY COLUMN syntax.
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(c1 CHAR(1), CHECK (c1 > 'A'));
+SHOW CREATE TABLE t1;
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES('A');
+INSERT INTO t1 VALUES('B');
+DELETE FROM t1;
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 MODIFY COLUMN c1 FLOAT(10.3), DROP CHECK t1_chk_1, ADD CONSTRAINT CHECK(C1 > 10.1) ENFORCED;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (f1 INT CHECK (f1 = default(f1)));
+INSERT INTO t1 VALUES (10);
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+ALTER TABLE t1 MODIFY COLUMN f1 INT DEFAULT 20, algorithm=inplace;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+ALTER TABLE t1 ALTER f1 SET DEFAULT 20, algorithm=inplace;
+--error ER_CHECK_CONSTRAINT_VIOLATED
+ALTER TABLE t1 MODIFY COLUMN f1 INT DEFAULT 20, algorithm=copy;
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint with CHANGE COLUMN syntax.
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(c1 CHAR(1), CHECK (c1 > 'A'));
+SHOW CREATE TABLE t1;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+ALTER TABLE t1 CHANGE c1 c1 FLOAT, ALGORITHM=INPLACE;
+ALTER TABLE t1 DROP CHECK t1_chk_1, CHANGE c1 c2 VARCHAR(20), ADD CONSTRAINT CHECK(c2 > 'B');
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t (a INT, b INT, CHECK(a != b));
+INSERT INTO t VALUES (2000000000, 2000000001);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+ALTER TABLE t CHANGE a a FLOAT, CHANGE b b FLOAT;
+--error ER_CHECK_CONSTRAINT_VIOLATED
+ALTER TABLE t ADD CONSTRAINT CHECK(a > b);
+DROP TABLE t;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test case to verify check constraints with IN operator.
+--echo #------------------------------------------------------------------------
+CREATE TABLE t1(f1 int CHECK (f1 IN (10, 20, 30)), f2 int, CHECK(f2 IN (100, 120, 450)));
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES(10, 100);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES(15, 100);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES(10, 105);
+DROP TABLE t1;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test case to verify check constraints with BETWEEN operator.
+--echo #------------------------------------------------------------------------
+CREATE TABLE t1(f1 int CHECK(f1 BETWEEN 10 AND 30),
+ f2 int, CHECK(f2 BETWEEN 100 AND 450));
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES(20, 200);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES(2, 200);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES(20, 2000);
+DROP TABLE t1;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test case to verify check constraints with IS NOT NULL.
+--echo #------------------------------------------------------------------------
+CREATE TABLE t1 (f1 int CHECK(f1 IS NOT NULL));
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES(10);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES(NULL);
+DROP TABLE t1;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test case to verify check constraints with IS NULL.
+--echo #------------------------------------------------------------------------
+CREATE TABLE t1 (f1 int CHECK(f1 IS NULL));
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES(NULL);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES(10);
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint with CASE Statement
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, c2 INT);
+ALTER TABLE t1 ADD CONSTRAINT CHECK( (CASE WHEN c1 > 10 THEN c2 = 20 END) = 1);
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES(1,1);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES(15,1);
+INSERT INTO t1 VALUES(15,20);
+SELECT * FROM t1;
+DROP TABLE t1;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test case to verify check constraints restrictions.
+--echo #------------------------------------------------------------------------
+
+--echo # Check constraint using column with AUTO_INCREMENT attribute.
+--error ER_CHECK_CONSTRAINT_REFERS_AUTO_INCREMENT_COLUMN
+CREATE TABLE t1 (f1 int primary key auto_increment, f2 int, CHECK (f1 != f2));
+
+--error ER_CHECK_CONSTRAINT_REFERS_AUTO_INCREMENT_COLUMN
+CREATE TABLE t1 (f1 int primary key auto_increment CHECK (f1 < 10), f2 int, CHECK (f1 != f2));
+
+--echo # Check constraint using non-deterministic builtin functions.
+--echo # NOW()
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + NOW() > '2011-11-21'));
+
+--echo # CURRENT_TIMESTAMP()
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + CURRENT_TIMESTAMP() > '2011-11-21 01:02:03'));
+
+--echo # CURRENT_TIMESTAMP
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + CURRENT_TIMESTAMP > '2011-11-21 01:02:03'));
+
+--echo # CURDATE()
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (f1 DATETIME CHECK (f1 + CURDATE() > '2011-11-21'));
+
+--echo # CURTIME()
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (f1 DATETIME CHECK (f1 + CURTIME() > '23:11:21'));
+
+--echo # CURTIME
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + CURRENT_TIME > '01:02:03'));
+
+--echo # CURRENT_DATE()
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + CURRENT_DATE() > '2011-11-21'));
+
+--echo # CURRENT_DATE
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + CURRENT_DATE > '2011-11-21'));
+
+--echo # CURRENT_TIME()
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + CURRENT_TIME() > '01:02:03'));
+
+--echo # CURRENT_TIME
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + CURRENT_TIME > '01:02:03'));
+
+--echo # LOCALTIME()
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (f1 DATETIME CHECK (f1 + LOCALTIME() > '23:11:21'));
+
+--echo # LOCALTIME
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (f1 DATETIME CHECK (f1 + LOCALTIME > '23:11:21'));
+
+--echo # LOCALTIMESTAMP()
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + LOCALTIMESTAMP() > '2011-11-21 01:02:03'));
+
+--echo # LOCALTIMESTAMP
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + LOCALTIMESTAMP > '2011-11-21 01:02:03'));
+
+--echo # UNIX_TIMESTAMP()
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + UNIX_TIMESTAMP() > '2011-11-21 01:02:03'));
+
+--echo # UNIX_DATE()
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (f1 DATETIME CHECK (f1 + UTC_DATE() > '2011-11-21'));
+
+--echo # UNIX_TIMESTAMP()
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (f1 TIMESTAMP CHECK (f1 + UTC_TIMESTAMP() > '2011-11-21 01:02:03'));
+
+--echo # UNIX_TIME()
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (f1 DATETIME CHECK (f1 + UTC_TIME() > '23:11:21'));
+
+--echo # CONNECTION_ID
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (f1 INT CHECK (f1 + CONNECTION_ID() < 929));
+
+--echo # CURRENT_USER()
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a VARCHAR(32) CHECK (CURRENT_USER() != a));
+
+--echo # CURRENT_USER
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a VARCHAR(32) CHECK (CURRENT_USER != a));
+
+--echo # SESSION_USER()
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a VARCHAR(32) CHECK (SESSION_USER() != a));
+
+--echo # VERSION()
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a VARCHAR(32) CHECK (VERSION() != a));
+
+--echo # FOUND_ROWS
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a VARCHAR(1024), b INT CHECK (b + FOUND_ROWS() > 2000));
+
+--echo # LAST_INSERT_ID
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a INT CHECK ((a + LAST_INSERT_ID()) < 929));
+
+--echo # SYSTEM_USER
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a VARCHAR(32) CHECK (SYSTEM_USER() != a));
+
+--echo # USER
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a VARCHAR(32) CHECK (USER() != a));
+
+--echo # RAND()
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (f1 FLOAT CHECK (f1 + RAND() < 929.929));
+
+--echo # ROW_COUNT()
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a INT CHECK (a + ROW_COUNT() > 1000));
+
+--echo # GET_LOCK()
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a VARCHAR(1024), b VARCHAR(1024) CHECK (GET_LOCK(b,10) != 0));
+
+--echo # IS_FREE_LOCK()
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a VARCHAR(1024), b VARCHAR(1024) CHECK (IS_FREE_LOCK(b) != 0));
+
+--echo # IS_USED_LOCK()
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a VARCHAR(1024), b VARCHAR(1024) CHECK (IS_USED_LOCK(b) != 0));
+
+--echo # RELEASE_LOCK()
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a VARCHAR(1024), b VARCHAR(1024) CHECK (RELEASE_LOCK(b) != 0));
+
+--echo # RELEASE_ALL_LOCK()
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (a VARCHAR(1024), b VARCHAR(1024), CHECK (RELEASE_ALL_LOCKS() != 0));
+
+--echo # LOAD_FILE
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (f1 VARCHAR(1024), f2 VARCHAR(1024) CHECK (LOAD_FILE(f2) != NULL));
+
+--echo # UUID()
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (id CHAR(40) CHECK(UUID() != id));
+
+--echo # UUID_SHORT
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (id INT CHECK(UUID_SHORT() != id));
+
+--echo # SLEEP
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (id INT CHECK(SLEEP(id) != 0));
+
+--echo # Stored function
+CREATE FUNCTION func() RETURNS INT DETERMINISTIC return 1;
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (id INT CHECK(id = func()));
+DROP FUNCTION func;
+
+--echo # Stored procedure
+CREATE PROCEDURE proc() SELECT 1;
+--error ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (id INT CHECK(id = proc()));
+DROP PROCEDURE proc;
+
+--echo # User variable
+SET @v = 10;
+--error ER_CHECK_CONSTRAINT_VARIABLES
+CREATE TABLE t1 (id INT CHECK (id != @v));
+
+--echo # System variables.
+--error ER_CHECK_CONSTRAINT_VARIABLES
+CREATE TABLE t1 (id INT CHECK (id != @@global.max_execution_time));
+--error ER_CHECK_CONSTRAINT_VARIABLES
+CREATE TABLE t1 (id INt CHECK (id != @@session.max_execution_time));
+
+--echo # Subquery
+--error ER_CHECK_CONSTRAINT_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1 (id INT CHECK (id != (SELECT 1)));
+
+--echo # Parameter
+PREPARE stmt FROM 'CREATE TABLE t1 (id INT CHECK(id != ?))';
+--error ER_CHECK_CONSTRAINT_FUNCTION_IS_NOT_ALLOWED
+EXECUTE stmt using @v;
+DEALLOCATE PREPARE stmt;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test case to verify check constraints with numeric data types.
+--echo #------------------------------------------------------------------------
+CREATE TABLE t1 (
+ c1 BIT(7) CHECK(c1 < B'1111100'),
+ c2 BOOLEAN CHECK(c2 > 0),
+ c3 TINYINT CHECK(c3 > 10),
+ c4 SMALLINT CHECK(c4 > 10),
+ c5 MEDIUMINT CHECK(c5 > 10),
+ c6 INT CHECK(c6 > 10),
+ c7 BIGINT CHECK(c7 > 10),
+ c8 DECIMAL(6,2) CHECK(c8 > 10.1),
+ c9 FLOAT(6,2) CHECK(c9 > 10.1),
+ c10 DOUBLE(6,2) CHECK(c10 > 10.1));
+SHOW CREATE TABLE t1;
+
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c1) VALUES(B'1111110');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c2) VALUES(0);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c3) VALUES(1);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c4) VALUES(1);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c5) VALUES(1);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c6) VALUES(1);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c7) VALUES(1);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c8) VALUES(10.0);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c9) VALUES(10.0);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c10) VALUES(10.0);
+
+INSERT INTO t1(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10)
+ VALUES(B'1111000',1,11,11,11,11,11,10.2,10.2,10.2);
+
+DROP TABLE t1;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test case to verify check constraints with string data types.
+--echo #------------------------------------------------------------------------
+CREATE TABLE t1(c1 CHAR(1) CHECK(c1 > 'a'),
+ c2 VARCHAR(1) CHECK(c2 > 'a'),
+ c3 BINARY(1) CHECK(c3 > 'a'),
+ c4 VARBINARY(1) CHECK(c4 > 'a'),
+ c5 TINYBLOB CHECK(c5 > 'a'),
+ c6 TINYTEXT CHECK(c6 > 'a'),
+ c7 BLOB CHECK(c7 > 'a'),
+ c8 TEXT CHECK(c8 > 'a'),
+ c9 MEDIUMBLOB CHECK(c9 > 'a'),
+ c10 MEDIUMTEXT CHECK(c10 > 'a'),
+ c11 LONGBLOB CHECK(c11 > 'a'),
+ c12 LONGTEXT CHECK(c12 > 'a'));
+SHOW CREATE TABLE t1;
+
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c1) VALUES('a');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c2) VALUES('a');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c3) VALUES('a');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c4) VALUES('a');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c5) VALUES('a');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c6) VALUES('a');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c7) VALUES('a');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c8) VALUES('a');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c9) VALUES('a');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c10) VALUES('a');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c11) VALUES('a');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c12) VALUES('a');
+
+INSERT INTO t1(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12)
+ VALUES('b',"b","b","b","b","b","b","b","b","b","b","b");
+
+DROP TABLE t1;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test case to verify check constraints with date and time data types.
+--echo #------------------------------------------------------------------------
+CREATE TABLE t1 (c1 DATE CHECK(c1 > '2007-01-01'),
+ c2 DATETIME CHECK(c2 > '2007-01-01 12:00:01'),
+ c3 TIMESTAMP CHECK(c3 > '2007-01-01 00:00:01.000000'),
+ c4 TIME CHECK(c4 > '12:00:01.000000'),
+ c5 YEAR CHECK(c5 > '2007'));
+
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c1) VALUES('2006-01-01');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c2) VALUES('2007-01-01 11:00:01');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c3) VALUES('2007-01-01 00:00:00.000000');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c4) VALUES('12:00:00.000000');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c5) VALUES('2006');
+
+INSERT INTO t1(c1,c2,c3,c4,c5)
+ VALUES('2008-01-01','2007-01-01 12:00:02','2007-01-01 00:00:02.000000',
+ '12:00:02.000000','2008');
+DROP TABLE t1;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test case to verify check constraints with JSON data type.
+--echo #------------------------------------------------------------------------
+CREATE TABLE t1(
+ id INT AUTO_INCREMENT PRIMARY KEY,
+ name VARCHAR(255),
+ browser JSON CHECK( browser->'$.name' = "Chrome" ));
+
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(name,browser)
+ VALUES('pageview','{ "name": "Safari", "os": "Mac" }');
+
+INSERT INTO t1(name,browser)
+ VALUES('pageview','{ "name": "Chrome", "os": "Mac" }');
+
+SELECT * FROM t1;
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # check constraint with ENUM data type
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1 (c1 ENUM ('a','b') CHECK (c1 IN ('c', 'd')) );
+SHOW CREATE TABLE t1;
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES('a');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES('b');
+--error 1265 #WARN_DATA_TRUNCATED
+INSERT INTO t1 VALUES('c');
+--error 1265 #WARN_DATA_TRUNCATED
+INSERT INTO t1 VALUES('d');
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # check constraint with SET data type
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1 (c1 SET ('a','b') CHECK (c1 IN ('c', 'd')) );
+SHOW CREATE TABLE t1;
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES('a');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES('b');
+--error 1265 #WARN_DATA_TRUNCATED
+INSERT INTO t1 VALUES('c');
+--error 1265 #WARN_DATA_TRUNCATED
+INSERT INTO t1 VALUES('d');
+DROP TABLE t1;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test case to verify check constraints with spatial data type.
+--echo #------------------------------------------------------------------------
+CREATE TABLE t1(
+ pt POINT CHECK(ST_Equals(pt, ST_GEOMFROMTEXT('POINT(10 20)')) = TRUE),
+ lnstr LINESTRING CHECK(ST_Equals(lnstr, ST_GEOMFROMTEXT('LINESTRING(0 0,5 5,6 6)'))),
+ mlnstr MULTILINESTRING CHECK(ST_Equals(mlnstr, ST_GEOMFROMTEXT('MULTILINESTRING((0 0,2 3,4 5),
+ (6 6,8 8,9 9,10 10))'))),
+ poly POLYGON CHECK(ST_Equals(poly, ST_GEOMFROMTEXT('POLYGON((0 0,6 7,8 8,3 9,0 0),
+ (3 6,4 6,4 7,3 6))'))),
+ mpoly MULTIPOLYGON CHECK(ST_Equals(mpoly, ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),
+ ((2 2,4 5,6 2,2 2)))'))));
+SHOW CREATE TABLE t1;
+
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(pt) VALUES (ST_GEOMFROMTEXT('POINT(10 21)'));
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(lnstr) VALUES (ST_GEOMFROMTEXT('LINESTRING(0 0,5 5,6 7)'));
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(mlnstr) VALUES (ST_GEOMFROMTEXT('MULTILINESTRING((0 0,2 3,4 5),(6 6,8 8,9 9,10 11))'));
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(poly) VALUES (ST_GEOMFROMTEXT('POLYGON((0 0,6 7,8 8,3 9,0 0),(3 6,4 6,4 8,3 6))'));
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(mpoly) VALUES (ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((2 2,4 5,6 3,2 2)))'));
+
+INSERT INTO t1(pt) VALUES (ST_GEOMFROMTEXT('POINT(10 20)'));
+INSERT INTO t1(lnstr) VALUES (ST_GEOMFROMTEXT('LINESTRING(0 0,5 5,6 6)'));
+INSERT INTO t1(mlnstr) VALUES (ST_GEOMFROMTEXT('MULTILINESTRING((0 0,2 3,4 5),(6 6,8 8,9 9,10 10))'));
+INSERT INTO t1(poly) VALUES (ST_GEOMFROMTEXT('POLYGON((0 0,6 7,8 8,3 9,0 0),(3 6,4 6,4 7,3 6))'));
+INSERT INTO t1(mpoly) VALUES (ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((2 2,4 5,6 2,2 2)))'));
+
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint with REGEX
+--echo #-----------------------------------------------------------------------
+CREATE TABLE student
+(
+ id INT,
+ stu_code VARCHAR(10),
+ name VARCHAR(14),
+ email VARCHAR(20),
+ scholarship INT,
+ country VARCHAR(20),
+ CONSTRAINT ck1 CHECK (id != 0),
+ CONSTRAINT ck2 CHECK (stu_code like 'j%'),
+ CONSTRAINT ck3 CHECK (lower(name) != "noname"),
+ CONSTRAINT ck4 CHECK (REGEXP_LIKE(email,'@')),
+ CONSTRAINT ck5 CHECK (scholarship BETWEEN 5000 AND 20000),
+ CONSTRAINT ck6 CHECK (country IN ('usa','uk'))
+);
+SHOW CREATE TABLE student;
+
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO student VALUES(0,"j001","name1","name1@oracle.com",6000,'usa');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO student VALUES(1,"s001","name1","name1@oracle.com",6000,'usa');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO student VALUES(1,"j001","NONAME","name1@oracle.com",6000,'usa');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO student VALUES(1,"j001","name1","name1oracle.com",6000,'usa');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO student VALUES(1,"j001","name1","name1@oracle.com",4000,'usa');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO student VALUES(1,"j001","name1","name1@oracle.com",6000,'nocountry');
+
+INSERT INTO student VALUES(1,"j001","name1","name1@oracle.com",6000,'usa');
+SELECT * FROM student;
+DROP TABLE student;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint with numeric comparator
+--echo # operators with varchar columns.
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, c2 VARCHAR(20));
+ALTER TABLE t1 ADD CONSTRAINT ck1 CHECK ( c1 > c2 );
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint with Comparison Functions
+--echo # and Operators
+--echo #-----------------------------------------------------------------------
+--error ER_NON_BOOLEAN_EXPR_FOR_CHECK_CONSTRAINT
+CREATE TABLE t1(c1 INT, CHECK ( c1 IN ( SELECT COALESCE(NULL, 1, 1))));
+--error ER_CHECK_CONSTRAINT_FUNCTION_IS_NOT_ALLOWED
+CREATE TABLE t1(c1 INT, CHECK ( c1 < ( SELECT COALESCE(NULL, 1, 1))));
+CREATE TABLE t1(c1 INT , CHECK ( c1 <=> NULL ));
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES(1);
+INSERT INTO t1 VALUES(NULL);
+SELECT * FROM t1;
+
+ALTER TABLE t1 ADD COLUMN c2 INT, ADD CONSTRAINT CHECK( c2 > 10 );
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c2) VALUES(10);
+INSERT INTO t1(c2) VALUES(11);
+
+ALTER TABLE t1 ADD COLUMN c3 INT, ADD CONSTRAINT CHECK( c3 >= 10 );
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c3) VALUES(9);
+INSERT INTO t1(c3) VALUES(10);
+
+ALTER TABLE t1 ADD COLUMN c4 INT, ADD CONSTRAINT CHECK( c4 < 10 );
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c4) VALUES(10);
+INSERT INTO t1(c4) VALUES(9);
+
+ALTER TABLE t1 ADD COLUMN c5 INT, ADD CONSTRAINT CHECK( c5 <= 10 );
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c5) VALUES(11);
+INSERT INTO t1(c5) VALUES(10);
+
+ALTER TABLE t1 ADD COLUMN c6 INT, ADD CONSTRAINT CHECK( c6 != 10 );
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c6) VALUES(10);
+INSERT INTO t1(c6) VALUES(20);
+
+ALTER TABLE t1 ADD COLUMN c7 INT, ADD CONSTRAINT CHECK( c7 <> 10 );
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c7) VALUES(10);
+INSERT INTO t1(c7) VALUES(20);
+
+ALTER TABLE t1 ADD COLUMN c8 INT, ADD CONSTRAINT CHECK( c8 = GREATEST(1,2,3) );
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c8) VALUES(1);
+INSERT INTO t1(c8) VALUES(3);
+
+ALTER TABLE t1 ADD COLUMN c9 INT, ADD CONSTRAINT CHECK( c9 = LEAST(1,2,3) );
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c9) VALUES(3);
+INSERT INTO t1(c9) VALUES(1);
+
+ALTER TABLE t1 ADD COLUMN c10 INT, ADD CONSTRAINT CHECK( c10 NOT IN (1,2,3) );
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c10) VALUES(1);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c10) VALUES(3);
+INSERT INTO t1(c10) VALUES(10);
+
+ALTER TABLE t1 ADD COLUMN c11 YEAR, ADD CONSTRAINT CHECK ( c11 > '2007-01-01' + INTERVAL +1 YEAR);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c11) VALUES(2007);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c11) VALUES(2008);
+INSERT INTO t1(c11) VALUES(2009);
+
+ALTER TABLE t1 ADD COLUMN c12 INT, ADD CONSTRAINT CHECK ( c12 NOT BETWEEN 10 AND 20);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c12) VALUES(15);
+INSERT INTO t1(c12) VALUES(25);
+
+ALTER TABLE t1 ADD COLUMN c13 INT, ADD CONSTRAINT CHECK ( c13 NOT IN (1, 2, 3));
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c13) VALUES(1);
+INSERT INTO t1(c13) VALUES(15);
+
+ALTER TABLE t1 ADD COLUMN c14 CHAR(10), ADD CONSTRAINT CHECK ( c14 LIKE 'A%');
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c14) VALUES('Good');
+INSERT INTO t1(c14) VALUES('All');
+
+ALTER TABLE t1 ADD COLUMN c15 INT, ADD CONSTRAINT CHECK ( c15 = STRCMP('A','A'));
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c15) VALUES(1);
+INSERT INTO t1(c15) VALUES(0);
+
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint with Logical Operators
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, c2 INT);
+ALTER TABLE t1 ADD CONSTRAINT CHECK( (c1 > 10) AND (c2 < 20) );
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES(1,10);
+ALTER TABLE t1 ADD CONSTRAINT CHECK( (c1 > 10) && (c2 < 20) );
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES(15,25);
+ALTER TABLE t1 DROP CHECK `t1_chk_1`;
+ALTER TABLE t1 DROP CHECK `t1_chk_2`;
+
+ALTER TABLE t1 ADD CONSTRAINT CHECK( (c1 > 10) || (c2 < 20) );
+ALTER TABLE t1 ADD CONSTRAINT CHECK( (c1 > 10) OR (c2 < 20) );
+INSERT INTO t1 VALUES(15,25);
+INSERT INTO t1 VALUES(5,10);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES(5,25);
+ALTER TABLE t1 DROP CHECK `t1_chk_1`;
+ALTER TABLE t1 DROP CHECK `t1_chk_2`;
+DELETE FROM t1;
+
+ALTER TABLE t1 ADD CONSTRAINT CHECK( (c1 > 10) XOR (c2 < 20) );
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES(15,10);
+
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint behaviour with DEFAULT, NULL
+--echo # and with LOGICAL operators.
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT DEFAULT 2 PRIMARY KEY CHECK(c1 > 1 OR c1 IS NOT NULL));
+SHOW CREATE TABLE t1;
+--error ER_BAD_NULL_ERROR
+INSERT INTO t1 VALUES(NULL);
+INSERT INTO t1 VALUES(1);
+SELECT * FROM t1;
+DROP TABLE t1;
+CREATE TABLE t1(c1 INT DEFAULT 2 PRIMARY KEY CHECK(c1 > 1 OR c1 > 2));
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES(1);
+INSERT INTO t1 VALUES(2);
+SELECT * FROM t1;
+DROP TABLE t1;
+CREATE TABLE t1(c1 INT DEFAULT 2 PRIMARY KEY CHECK(c1 > 1 AND c1 IS NOT NULL));
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES(1);
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint when table is moved to another DB
+--echo #-----------------------------------------------------------------------
+CREATE DATABASE test1;
+CREATE DATABASE test2;
+USE test1;
+CREATE TABLE t1(c1 INT, c2 INT CHECK (c2 < 10));
+INSERT INTO t1 VALUES(1,1);
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE TABLE_NAME='t1';
+ALTER TABLE test1.t1 rename test2.t1;
+USE test2;
+SELECT * FROM t1;
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE TABLE_NAME='t1';
+DROP DATABASE test2;
+DROP DATABASE test1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint when table is moved to another DB
+--echo # with different name.
+--echo #-----------------------------------------------------------------------
+CREATE DATABASE test1;
+CREATE DATABASE test2;
+USE test1;
+CREATE TABLE t1(c1 INT, c2 INT CHECK (c2 < 10));
+INSERT INTO t1 VALUES(1,1);
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE TABLE_NAME='t1';
+ALTER TABLE test1.t1 rename test2.t2;
+USE test2;
+SELECT * FROM t2;
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE TABLE_NAME='t2';
+DROP DATABASE test2;
+DROP DATABASE test1;
+use test;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraints with foreign key constraint
+--echo #-----------------------------------------------------------------------
+CREATE TABLE parent(pid INT NOT NULL PRIMARY KEY CHECK(pid > 1));
+CREATE TABLE child(cid INT CHECK(cid > 1),
+ FOREIGN KEY fk(cid) REFERENCES parent(pid));
+SHOW CREATE TABLE parent;
+SHOW CREATE TABLE child;
+INSERT INTO parent VALUES(2);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO child VALUES(1);
+--error ER_NO_REFERENCED_ROW_2
+INSERT INTO child VALUES(3);
+INSERT INTO child VALUES(2);
+SELECT * FROM parent;
+SELECT * FROM child;
+DROP TABLE child;
+DROP TABLE parent;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint with FK referential actions.
+--echo #-----------------------------------------------------------------------
+CREATE TABLE parent (a INT PRIMARY KEY);
+# With ON DELETE SET NULL referential action.
+--error ER_CHECK_CONSTRAINT_CLAUSE_USING_FK_REFER_ACTION_COLUMN
+CREATE TABLE child (
+ b INT,
+ c INT CHECK (c < 10),
+ INDEX(b),
+ FOREIGN KEY (b) REFERENCES parent(a) ON DELETE SET NULL,
+ CHECK (b IS NOT NULL)
+ );
+CREATE TABLE child (
+ b INT,
+ c INT CHECK (c < 10),
+ INDEX(b),
+ FOREIGN KEY (b) REFERENCES parent(a) ON DELETE SET NULL
+ );
+--error ER_CHECK_CONSTRAINT_CLAUSE_USING_FK_REFER_ACTION_COLUMN
+ALTER TABLE child ADD CONSTRAINT CHECK (b IS NOT NULL);
+ALTER TABLE child DROP FOREIGN KEY child_ibfk_1;
+--error ER_CHECK_CONSTRAINT_CLAUSE_USING_FK_REFER_ACTION_COLUMN
+ALTER TABLE child ADD CONSTRAINT FOREIGN KEY (b) REFERENCES parent(a) ON DELETE SET NULL,
+ ADD CONSTRAINT CHECK (b IS NOT NULL);
+DROP TABLE child;
+
+# With ON UPDATE SET NULL referential action.
+--error ER_CHECK_CONSTRAINT_CLAUSE_USING_FK_REFER_ACTION_COLUMN
+CREATE TABLE child (
+ b INT,
+ c INT CHECK (c < 10),
+ INDEX(b),
+ FOREIGN KEY (b) REFERENCES parent(a) ON UPDATE SET NULL,
+ CHECK (b IS NOT NULL)
+ );
+CREATE TABLE child (
+ b INT,
+ c INT CHECK (c < 10),
+ INDEX(b),
+ FOREIGN KEY (b) REFERENCES parent(a) ON UPDATE SET NULL
+ );
+--error ER_CHECK_CONSTRAINT_CLAUSE_USING_FK_REFER_ACTION_COLUMN
+ALTER TABLE child ADD CONSTRAINT CHECK (b IS NOT NULL);
+ALTER TABLE child DROP FOREIGN KEY child_ibfk_1;
+--error ER_CHECK_CONSTRAINT_CLAUSE_USING_FK_REFER_ACTION_COLUMN
+ALTER TABLE child ADD CONSTRAINT FOREIGN KEY (b) REFERENCES parent(a) ON UPDATE SET NULL,
+ ADD CONSTRAINT CHECK (b IS NOT NULL);
+DROP TABLE child;
+
+# With ON UPDATE CASCADE referential action.
+--error ER_CHECK_CONSTRAINT_CLAUSE_USING_FK_REFER_ACTION_COLUMN
+CREATE TABLE child (
+ b INT,
+ c INT CHECK (c < 10),
+ INDEX(b),
+ FOREIGN KEY (b) REFERENCES parent(a) ON UPDATE CASCADE,
+ CHECK (b IS NOT NULL)
+ );
+CREATE TABLE child (
+ b INT,
+ c INT CHECK (c < 10),
+ INDEX(b),
+ FOREIGN KEY (b) REFERENCES parent(a) ON UPDATE CASCADE
+ );
+--error ER_CHECK_CONSTRAINT_CLAUSE_USING_FK_REFER_ACTION_COLUMN
+ALTER TABLE child ADD CONSTRAINT CHECK (b IS NOT NULL);
+ALTER TABLE child DROP FOREIGN KEY child_ibfk_1;
+--error ER_CHECK_CONSTRAINT_CLAUSE_USING_FK_REFER_ACTION_COLUMN
+ALTER TABLE child ADD CONSTRAINT FOREIGN KEY (b) REFERENCES parent(a) ON UPDATE CASCADE,
+ ADD CONSTRAINT CHECK (b IS NOT NULL);
+DROP TABLE child;
+DROP TABLE parent;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint with triggers
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, c2 INT CHECK (c2 < 10));
+CREATE TABLE t2(c1 INT, c2 INT);
+
+# before insert
+DELIMITER //;
+CREATE TRIGGER before_t2_insert
+ BEFORE INSERT ON t2
+ FOR EACH ROW
+ BEGIN
+ INSERT INTO t1 VALUES(NEW.c1,NEW.c2);
+ END
+//
+DELIMITER ;//
+
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t2 VALUES(1,20);
+SELECT * FROM t1;
+SELECT * FROM t2;
+DROP TRIGGER before_t2_insert;
+
+# after insert
+DELIMITER //;
+CREATE TRIGGER after_t2_insert
+ AFTER INSERT ON t2
+ FOR EACH ROW
+ BEGIN
+ INSERT INTO t1 VALUES(NEW.c1,NEW.c2);
+ END
+//
+DELIMITER ;//
+
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t2 VALUES(1,30);
+SELECT * FROM t1;
+SELECT * FROM t2;
+DROP TRIGGER after_t2_insert;
+
+# before update
+INSERT INTO t2 VALUES(1,5);
+INSERT INTO t1 VALUES(1,5);
+DELIMITER //;
+CREATE TRIGGER before_t2_update
+ BEFORE UPDATE ON t2
+ FOR EACH ROW
+ BEGIN
+ UPDATE t1 SET c2=NEW.c2 WHERE c1=NEW.c1;
+ END
+//
+DELIMITER ;//
+
+--error ER_CHECK_CONSTRAINT_VIOLATED
+UPDATE t2 SET c2=20 WHERE c1=1;
+SELECT * FROM t1;
+SELECT * FROM t2;
+DROP TRIGGER before_t2_update;
+
+# after update
+DELIMITER //;
+CREATE TRIGGER after_t2_update
+ AFTER UPDATE ON t2
+ FOR EACH ROW
+ BEGIN
+ UPDATE t1 SET c2=NEW.c2 WHERE c1=NEW.c1;
+ END
+//
+DELIMITER ;//
+
+--error ER_CHECK_CONSTRAINT_VIOLATED
+UPDATE t2 SET c2=20 WHERE c1=1;
+SELECT * FROM t1;
+SELECT * FROM t2;
+DROP TRIGGER after_t2_update;
+DROP TABLE t1,t2;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint with triggers old style.
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(c1 int CONSTRAINT ck1 CHECK(c1 < 5));
+
+DELIMITER //;
+CREATE PROCEDURE proc1 (IN val1 INT)
+BEGIN
+ IF val1 < 10 THEN
+ SIGNAL SQLSTATE '45000'
+ SET MESSAGE_TEXT = 'check constraint on c1 failed';
+ END IF;
+END
+//
+
+CREATE TRIGGER before_t1_insert
+ BEFORE INSERT ON t1
+ FOR EACH ROW
+ BEGIN
+ CALL proc1(new.c1);
+ END
+//
+
+DELIMITER ;//
+
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES(20);
+--error ER_SIGNAL_EXCEPTION
+INSERT INTO t1 VALUES(9);
+--error ER_SIGNAL_EXCEPTION
+INSERT INTO t1 VALUES(4);
+DROP PROCEDURE proc1;
+DROP TRIGGER before_t1_insert;
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint with mysqldump
+--echo #-----------------------------------------------------------------------
+CREATE DATABASE test1;
+USE test1;
+CREATE TABLE t1 (
+ c1 BIT(7) CHECK(c1 < B'1111100') NOT ENFORCED,
+ c2 BOOLEAN CHECK(c2 > 0) NOT ENFORCED,
+ c3 TINYINT CHECK(c3 > 10) NOT ENFORCED,
+ c4 SMALLINT CHECK(c4 > 10) NOT ENFORCED,
+ c5 MEDIUMINT CHECK(c5 > 10) NOT ENFORCED,
+ c6 INT CHECK(c6 > 10),
+ c7 BIGINT CHECK(c7 > 10),
+ c8 DECIMAL(6,2) CHECK(c8 > 10.1),
+ c9 FLOAT(6,2) CHECK(c9 > 10.1),
+ c10 DOUBLE(6,2) CHECK(c10 > 10.1),
+ c11 CHAR(6) CHECK (c11 IS NULL));
+SHOW CREATE TABLE t1;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--exec $MYSQL_DUMP --databases test1 > $MYSQLTEST_VARDIR/tmp/test1_db.sql 2>&1
+DROP DATABASE test1;
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/test1_db.sql
+USE test1;
+SHOW CREATE TABLE t1;
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10)
+ VALUES(B'1111111',0,5,5,5,1,1,1.2,1.2,1.2);
+INSERT INTO t1(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10)
+ VALUES(B'1111111',0,5,5,5,11,11,10.2,10.2,10.2);
+SELECT * FROM t1;
+DROP TABLE t1;
+DROP DATABASE test1;
+--remove_file $MYSQLTEST_VARDIR/tmp/test1_db.sql
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint with mysqlpump
+--echo #-----------------------------------------------------------------------
+CREATE DATABASE test2;
+USE test2;
+CREATE TABLE t2 (
+ c1 BIT(7) CHECK(c1 < B'1111100'),
+ c2 BOOLEAN CHECK(c2 > 0),
+ c3 TINYINT CHECK(c3 > 10),
+ c4 SMALLINT CHECK(c4 > 10),
+ c5 MEDIUMINT CHECK(c5 > 10),
+ c6 INT CHECK(c6 > 10) NOT ENFORCED,
+ c7 BIGINT CHECK(c7 > 10) NOT ENFORCED,
+ c8 DECIMAL(6,2) CHECK(c8 > 10.1) NOT ENFORCED,
+ c9 FLOAT(6,2) CHECK(c9 > 10.1) NOT ENFORCED,
+ c10 DOUBLE(6,2) CHECK(c10 > 10.1) NOT ENFORCED);
+SHOW CREATE TABLE t2;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--exec $MYSQL_PUMP --databases test2 > $MYSQLTEST_VARDIR/tmp/test2_db.sql
+DROP DATABASE test2;
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/test2_db.sql
+USE test2;
+SHOW CREATE TABLE t2;
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t2(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10)
+ VALUES(B'1111000',0,10,10,10,5,5,9.1,9.1,9.1);
+INSERT INTO t2(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10)
+ VALUES(B'1111000',1,11,11,11,5,5,9.1,9.1,9.1);
+SELECT * FROM t2;
+DROP TABLE t2;
+DROP DATABASE test2;
+--remove_file $MYSQLTEST_VARDIR/tmp/test2_db.sql
+USE test;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint with PREPARE statement
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT CHECK(c1 > 10));
+PREPARE stmt1 FROM 'INSERT INTO t1 VALUES(1)';
+--error ER_CHECK_CONSTRAINT_VIOLATED
+EXECUTE stmt1;
+DEALLOCATE PREPARE stmt1;
+PREPARE stmt2 FROM 'INSERT INTO t1 VALUES(20)';
+EXECUTE stmt2;
+DEALLOCATE PREPARE stmt2;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint behaviour inside transaction
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT);
+CREATE TABLE t2(c1 INT CHECK(c1 > 10));
+SET AUTOCOMMIT = OFF;
+# Transaction 1
+START TRANSACTION;
+INSERT INTO t1 VALUES(1);
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t2 VALUES(1);
+ROLLBACK;
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+# Transaction 2
+START TRANSACTION;
+ALTER TABLE t1 ADD CONSTRAINT CHECK (C1 > 10);
+COMMIT;
+SHOW CREATE TABLE t1;
+SET AUTOCOMMIT = ON;
+DROP TABLE t1,t2;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test case to verify check constraints with Partition table.
+--echo #------------------------------------------------------------------------
+--echo # check constraint with range partition
+CREATE TABLE t1(
+ d DATE NOT NULL CHECK(YEAR(d) > '1950')
+)
+PARTITION BY RANGE( YEAR(d) ) (
+PARTITION p0 VALUES LESS THAN (1960),
+PARTITION p1 VALUES LESS THAN (1970),
+PARTITION p2 VALUES LESS THAN (1980),
+PARTITION p3 VALUES LESS THAN (1990)
+);
+SHOW CREATE TABLE t1;
+
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES('1940-01-01');
+
+INSERT INTO t1 VALUES('1960-01-01');
+SELECT * FROM t1;
+DROP TABLE t1;
+
+--echo # check constraint with list partition
+CREATE TABLE t1(
+ id INT NOT NULL CHECK(id BETWEEN 10 AND 50),
+ name VARCHAR(10)
+)
+PARTITION BY LIST(id) (
+PARTITION p0 VALUES IN (10,19),
+PARTITION p1 VALUES IN (20,29),
+PARTITION p2 VALUES IN (30,39),
+PARTITION p3 VALUES IN (40,49)
+);
+SHOW CREATE TABLE t1;
+
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES(60,'aaa');
+INSERT INTO t1 VALUES(30,'aaa');
+SELECT * FROM t1;
+DROP TABLE t1;
+
+--echo # check constraint with hash partition
+CREATE TABLE t1(id INT NOT NULL CHECK(id > 10),
+ name VARCHAR(40)
+)
+PARTITION BY HASH(id)
+PARTITIONS 4;
+SHOW CREATE TABLE t1;
+
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES(1,'aaa');
+INSERT INTO t1 VALUES(60,'aaa');
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+--echo # check constraint with key partition
+CREATE TABLE t1(id INT PRIMARY KEY NOT NULL CHECK(id > 10),
+ name VARCHAR(40)
+)
+PARTITION BY KEY()
+PARTITIONS 4;
+SHOW CREATE TABLE t1;
+
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES(1,'aaa');
+INSERT INTO t1 VALUES(60,'aaa');
+SELECT * FROM t1;
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify alter operations on non-transactional SE table
+--echo # with check constraints.
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(f1 INT CHECK (f1 < 10)) ENGINE = myisam;
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 ADD f2 INT, ALGORITHM=copy;
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 ALTER f1 SET DEFAULT 10, ALGORITHM=INPLACE;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+--echo #-----------------------------------------------------------------------
+--echo # Test case to verify check constraint with Updatable view
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1(c1 INT, c2 INT CHECK (c2 < 10));
+CREATE VIEW v1 AS SELECT * FROM t1;
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO v1 VALUES(1,20);
+INSERT INTO v1 VALUES(1,5);
+SELECT * FROM t1;
+SELECT * FROM v1;
+DROP VIEW v1;
+DROP TABLE t1;
diff --git a/mysql-test/t/check_constraints_debug.test b/mysql-test/t/check_constraints_debug.test
new file mode 100644
index 000000000000..29b69791face
--- /dev/null
+++ b/mysql-test/t/check_constraints_debug.test
@@ -0,0 +1,172 @@
+--source include/have_debug.inc
+
+################################################################################
+# WL929 - CHECK CONSTRAINTS. #
+# Test cases to verify MDL on check constraints. #
+################################################################################
+
+--enable_connect_log
+
+--echo #------------------------------------------------------------------------
+--echo # Test case to verify MDL locking on check constraints with same names
+--echo # in the concurrent CREATE TABLE statements.
+--echo #------------------------------------------------------------------------
+SET DEBUG_SYNC="after_acquiring_lock_on_check_constraints SIGNAL cc_locked WAIT_FOR continue";
+--SEND CREATE TABLE t1 (f1 INT CHECK (f1 < 10), f2 INT, CONSTRAINT t1_ck CHECK(f2 < 10));
+
+CONNECT (con1, localhost, root);
+SET DEBUG_SYNC="now WAIT_FOR cc_locked";
+--send CREATE TABLE t2 (f1 INT, f2 INT, CONSTRAINT t1_ck CHECK(f2 < 10));
+
+CONNECT (con2, localhost, root);
+--echo # default connection acquires MDL lock on the check constraint name 'test.t1_ck'.
+--echo # con1 waits for the MDL lock on 'test.t1_ck' at this point.
+let $wait_condition=
+ SELECT count(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
+ WHERE state = "Waiting for check constraint metadata lock" AND
+ info = "CREATE TABLE t2 (f1 INT, f2 INT, CONSTRAINT t1_ck CHECK(f2 < 10))";
+--source include/wait_condition.inc
+SET DEBUG_SYNC="now SIGNAL continue";
+
+CONNECTION con1;
+--error ER_CHECK_CONSTRAINT_DUP_NAME
+--reap
+
+CONNECTION default;
+--reap
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test case to verify MDL locking on check constraints names in the
+--echo # RENAME TABLE and CREATE TABLE statements.
+--echo #------------------------------------------------------------------------
+SET DEBUG_SYNC="after_acquiring_lock_on_check_constraints_for_rename SIGNAL cc_locked WAIT_FOR continue";
+--SEND RENAME TABLE t1 to t2;
+
+CONNECTION con1;
+SET DEBUG_SYNC="now WAIT_FOR cc_locked";
+--send CREATE TABLE t3 (f1 INT, CONSTRAINT t1_chk_1 CHECK (f1 < 10));
+
+CONNECTION con2;
+--echo # default connection acquires lock on check constraint 'test.t1_chk_1'.
+--echo # Concurrent create operation with same name for check constraint in con1
+--echo # waits for the lock.
+let $wait_condition=
+ SELECT count(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
+ WHERE state = "Waiting for check constraint metadata lock" AND
+ info = "CREATE TABLE t3 (f1 INT, CONSTRAINT t1_chk_1 CHECK (f1 < 10))";
+--source include/wait_condition.inc
+SET DEBUG_SYNC="now SIGNAL continue";
+
+CONNECTION con1;
+--reap
+
+CONNECTION default;
+--reap
+SHOW CREATE TABLE t2;
+SHOW CREATE TABLE t3;
+DROP TABLE t3;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test case to verify MDL locking on generated check constraints names
+--echo # in the RENAME TABLE using the target table name and CREATE TABLE
+--echo # statements.
+--echo #------------------------------------------------------------------------
+SET DEBUG_SYNC="after_acquiring_lock_on_check_constraints_for_rename SIGNAL cc_locked WAIT_FOR continue";
+--SEND RENAME TABLE t2 to t1;
+
+CONNECTION con1;
+SET DEBUG_SYNC="now WAIT_FOR cc_locked";
+--send CREATE TABLE t3 (f1 INT, CONSTRAINT t1_chk_1 CHECK (f1 < 10));
+
+CONNECTION con2;
+--echo # default connection acquires lock on check constraint name('test.t1_chk_1')
+--echo # generated using target table t1.
+--echo # concurrent con1 waits for the MDL on test.t1_chk_1 in CREATE TABLE
+--echo # statement.
+let $wait_condition=
+ SELECT count(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
+ WHERE state = "Waiting for check constraint metadata lock" AND
+ info = "CREATE TABLE t3 (f1 INT, CONSTRAINT t1_chk_1 CHECK (f1 < 10))";
+--source include/wait_condition.inc
+SET DEBUG_SYNC="now SIGNAL continue";
+
+CONNECTION con1;
+--error ER_CHECK_CONSTRAINT_DUP_NAME
+--reap
+SHOW CREATE TABLE t1;
+
+CONNECTION default;
+--reap
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test case to verify MDL locking on check constraint name in ALTER
+--echo # TABLE statement to RENAME table and CREATE TABLE statements.
+--echo #------------------------------------------------------------------------
+SET DEBUG_SYNC="after_acquiring_lock_on_check_constraints_for_rename SIGNAL cc_locked WAIT_FOR continue";
+--SEND ALTER TABLE t1 RENAME TO t3;
+
+CONNECTION con1;
+SET DEBUG_SYNC="now WAIT_FOR cc_locked";
+--send CREATE TABLE t2 (f1 INT, CONSTRAINT t1_chk_1 CHECK (f1 < 10));
+
+CONNECTION con2;
+--echo # default connection acquires lock on check constraint 'test.t1_chk_1'.
+--echo # Concurrent con1 waits for lock on test.t1_chk_1.
+let $wait_condition=
+ SELECT count(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
+ WHERE state = "Waiting for check constraint metadata lock" AND
+ info = "CREATE TABLE t2 (f1 INT, CONSTRAINT t1_chk_1 CHECK (f1 < 10))";
+--source include/wait_condition.inc
+SET DEBUG_SYNC="now SIGNAL continue";
+
+CONNECTION con1;
+--reap
+
+CONNECTION default;
+--reap
+SHOW CREATE TABLE t2;
+SHOW CREATE TABLE t3;
+DROP TABLE t2;
+
+
+--echo #------------------------------------------------------------------------
+--echo # Test case to verify MDL locking on generated check constraint name
+--echo # using target table name in ALTER TABLE statement to RENAME table and
+--echo # CREATE TABLE statements.
+--echo #------------------------------------------------------------------------
+SET DEBUG_SYNC="after_acquiring_lock_on_check_constraints_for_rename SIGNAL cc_locked WAIT_FOR continue";
+--SEND ALTER TABLE t3 RENAME TO t1;
+
+CONNECTION con1;
+SET DEBUG_SYNC="now WAIT_FOR cc_locked";
+--send CREATE TABLE t2 (f1 INT, CONSTRAINT t1_chk_1 CHECK (f1 < 10));
+
+CONNECTION con2;
+--echo # default connection acquires lock on the generated check constraint
+--echo # name('test.t1_chk_1') using target table name t1. con1 waits for
+--echo # the lock on same name for check constraint.
+let $wait_condition=
+ SELECT count(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
+ WHERE state = "Waiting for check constraint metadata lock" AND
+ info = "CREATE TABLE t2 (f1 INT, CONSTRAINT t1_chk_1 CHECK (f1 < 10))";
+--source include/wait_condition.inc
+SET DEBUG_SYNC="now SIGNAL continue";
+
+CONNECTION con1;
+--error ER_CHECK_CONSTRAINT_DUP_NAME
+--reap
+
+CONNECTION default;
+--reap
+SHOW CREATE TABLE t1;
+
+#Cleanup
+CONNECTION default;
+DISCONNECT con1;
+DISCONNECT con2;
+DROP TABLE t1;
+SET DEBUG_SYNC='RESET';
+--disable_connect_log
diff --git a/mysql-test/t/constraints.test b/mysql-test/t/constraints.test
index 731e2f3a9bc0..45bcafa80c3e 100644
--- a/mysql-test/t/constraints.test
+++ b/mysql-test/t/constraints.test
@@ -11,14 +11,17 @@ drop table if exists t1;
create table t1 (a int check (a>0));
insert into t1 values (1);
+--error ER_CHECK_CONSTRAINT_VIOLATED
insert into t1 values (0);
drop table t1;
create table t1 (a int, b int, check (a>b));
insert into t1 values (1,0);
+--error ER_CHECK_CONSTRAINT_VIOLATED
insert into t1 values (0,1);
drop table t1;
create table t1 (a int ,b int, constraint abc check (a>b));
insert into t1 values (1,0);
+--error ER_CHECK_CONSTRAINT_VIOLATED
insert into t1 values (0,1);
drop table t1;
create table t1 (a int null);
diff --git a/mysql-test/t/dd_schema_definition_debug.test b/mysql-test/t/dd_schema_definition_debug.test
index ac915d0a8f2f..ddc8ee914028 100644
--- a/mysql-test/t/dd_schema_definition_debug.test
+++ b/mysql-test/t/dd_schema_definition_debug.test
@@ -330,6 +330,12 @@ INSERT INTO dd_published_schema
INSERT INTO dd_published_schema
VALUES ('80014', 1,
'cc5651651505fe0a4ebccb74d82e6fcd9555a4bd29478e21637c95da98f4537c');
+INSERT INTO dd_published_schema
+ VALUES('80015', 0,
+ 'd744ea5852332319804c577901ca4fb0c0b823cc4d583bab9630659cbb11951e');
+INSERT INTO dd_published_schema
+ VALUES('80015', 1,
+ '403cb6e600b964c120e0a7eb92fefa15bd02f4cee745182191275df2c1cb30d7');
SELECT IFNULL(CONCAT('The schema checksum corresponds to DD version ',
version, '.'),
diff --git a/mysql-test/t/dd_upgrade_test.test b/mysql-test/t/dd_upgrade_test.test
index 51998a73b33e..ec9e7da9f83b 100644
--- a/mysql-test/t/dd_upgrade_test.test
+++ b/mysql-test/t/dd_upgrade_test.test
@@ -767,4 +767,56 @@ call mtr.add_suppression("You need to use --log-bin to make --binlog-format work
--echo # Restart the server with default options.
--source include/start_mysqld.inc
+--echo #-----------------------------------------------------------------------
+--echo # WL#929: CHECK Constraint
+--echo # Test case to verify upgrade from version before check
+--echo # constraint suppport.
+--echo #-----------------------------------------------------------------------
+
+let $MYSQLD_LOG= $MYSQLTEST_VARDIR/log/save_dd_upgrade_4.log;
+
+--echo # Copy the remote tablespace & DB zip files from suite location to working location.
+--copy_file $MYSQLTEST_VARDIR/std_data/upgrade/data_80014.zip $MYSQL_TMP_DIR/data_80014.zip
+
+--echo # Check that the file exists in the working folder.
+--file_exists $MYSQL_TMP_DIR/data_80014.zip
+--exec unzip -qo $MYSQL_TMP_DIR/data_80014.zip -d $MYSQL_TMP_DIR/data_80014
+
+--echo # Set different paths for --datadir
+let $MYSQLD_DATADIR3 = $MYSQL_TMP_DIR/data_80014/
+
+--echo # Check that the file exits after unzip
+--file_exists $MYSQL_TMP_DIR/data_80014
+
+--echo # Stop DB server which was created by MTR default
+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--shutdown_server
+--source include/wait_until_disconnected.inc
+
+--echo # Start the DB server
+--exec echo "restart: --datadir=$MYSQLD_DATADIR3 --log-error=$MYSQLD_LOG" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--enable_reconnect
+--let $wait_counter= 3000
+--source include/wait_until_connected_again.inc
+
+USE test;
+CREATE TABLE t1 (f1 INT CHECK (f1 < 10));
+--echo # After upgrade CHECK_CONSTRAINTS table should be present and should list
+--echo # check constraints.
+SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS;
+--echo # After upgrade TABLE_CONSTRAINTS should list check constraints.
+SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE TABLE_NAME='t1';
+SHOW CREATE TABLE t1;
+--error ER_CHECK_CONSTRAINT_VIOLATED
+INSERT INTO t1 VALUES (100);
+DROP TABLE t1;
+
+--echo # Stop the server
+--source include/shutdown_mysqld.inc
+--echo # Remove copied files
+--remove_file $MYSQL_TMP_DIR/data_80014.zip
+--force-rmdir $MYSQL_TMP_DIR/data_80014
+--echo # Restart the server with default options.
+--source include/start_mysqld.inc
+
--echo # end of test
diff --git a/mysql-test/t/import.test b/mysql-test/t/import.test
index 6a73da0e62c6..e86a24926204 100644
--- a/mysql-test/t/import.test
+++ b/mysql-test/t/import.test
@@ -647,6 +647,20 @@ SET SESSION sql_require_primary_key= OFF;
--echo # Clean SDI files in \$EXPORT_DIR
--remove_files_wildcard $EXPORT_DIR t*
+--echo #-----------------------------------------------------------------------
+--echo # WL#929 - Check constraint.
+--echo # Test case to verify check constraint import from SDI.
+--echo #-----------------------------------------------------------------------
+CREATE TABLE t1 (f1 INT CHECK (f1 < 10)) ENGINE=MyISAM;
+let $MYSQLD_DATADIR=`SELECT @@datadir`;
+--copy_files_wildcard $MYSQLD_DATADIR/test/ $MYSQL_TMP_DIR/ t*
+DROP TABLE t1;
+--copy_files_wildcard $MYSQL_TMP_DIR/ $MYSQLD_DATADIR/test/ t*
+IMPORT TABLE FROM 'test/t1*.sdi';
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+--remove_files_wildcard $MYSQL_TMP_DIR/ t*
+
--echo # Remove 'export' folder created at the beginning of test file.
--force-rmdir $EXPORT_DIR
diff --git a/scripts/fill_help_tables.sql b/scripts/fill_help_tables.sql
index 36ae2f935070..76707135d4d4 100644
--- a/scripts/fill_help_tables.sql
+++ b/scripts/fill_help_tables.sql
@@ -1,4 +1,4 @@
--- Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+-- Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License, version 2.0,
@@ -118,7 +118,7 @@ INSERT INTO help_topic (help_topic_id,help_category_id,name,description,example,
INSERT INTO help_topic (help_topic_id,help_category_id,name,description,example,url) VALUES (29,9,'ALTER PROCEDURE','Syntax:\nALTER PROCEDURE proc_name [characteristic ...]\n\ncharacteristic:\n COMMENT \'string\'\n | LANGUAGE SQL\n | { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }\n | SQL SECURITY { DEFINER | INVOKER }\n\nThis statement can be used to change the characteristics of a stored\nprocedure. More than one change may be specified in an ALTER PROCEDURE\nstatement. However, you cannot change the parameters or body of a\nstored procedure using this statement; to make such changes, you must\ndrop and re-create the procedure using DROP PROCEDURE and CREATE\nPROCEDURE.\n\nYou must have the ALTER ROUTINE privilege for the procedure. By\ndefault, that privilege is granted automatically to the procedure\ncreator. This behavior can be changed by disabling the\nautomatic_sp_privileges system variable. See\nhttp://dev.mysql.com/doc/refman/8.0/en/stored-routines-privileges.html.\n\nURL: http://dev.mysql.com/doc/refman/8.0/en/alter-procedure.html\n\n','','http://dev.mysql.com/doc/refman/8.0/en/alter-procedure.html');
INSERT INTO help_topic (help_topic_id,help_category_id,name,description,example,url) VALUES (30,1,'ALTER RESOURCE GROUP','Syntax:\nALTER RESOURCE GROUP group_name\n [VCPU [=] vcpu_spec [, vcpu_spec] ...]\n [THREAD_PRIORITY [=] N]\n [ENABLE|DISABLE [FORCE]]\n\nvcpu_spec: {N | M - N}\n\nALTER RESOURCE GROUP is used for resource group management (see\nhttp://dev.mysql.com/doc/refman/8.0/en/resource-groups.html). This\nstatement alters modifiable attributes of an existing resource group.\nIt requires the RESOURCE_GROUP_ADMIN privilege.\n\ngroup_name identifies which resource group to alter. If the group does\nnot exist, an error occurs.\n\nThe attributes for CPU affinity, priority, and whether the group is\nenabled can be modified with ALTER RESOURCE GROUP. These attributes are\nspecified the same way as described for CREATE RESOURCE GROUP (see\n[HELP CREATE RESOURCE GROUP]). Only the attributes specified are\naltered. Unspecified attributes retain their current values.\n\nThe FORCE modifier is used with DISABLE. It determines statement\nbehavior if the resource group has any threads assigned to it:\n\no If FORCE is not given, existing threads in the group continue to run\n until they terminate, but new threads cannot be assigned to the\n group.\n\no If FORCE is given, existing threads in the group are moved to their\n respective default group (system threads to SYS_default, user threads\n to USR_default).\n\nThe name and type attributes are set at group creation time and cannot\nbe modified thereafter with ALTER RESOURCE GROUP.\n\nURL: http://dev.mysql.com/doc/refman/8.0/en/alter-resource-group.html\n\n','','http://dev.mysql.com/doc/refman/8.0/en/alter-resource-group.html');
INSERT INTO help_topic (help_topic_id,help_category_id,name,description,example,url) VALUES (31,9,'ALTER SERVER','Syntax:\nALTER SERVER server_name\n OPTIONS (option [, option] ...)\n\nAlters the server information for server_name, adjusting any of the\noptions permitted in the CREATE SERVER statement. The corresponding\nfields in the mysql.servers table are updated accordingly. This\nstatement requires the SUPER privilege.\n\nURL: http://dev.mysql.com/doc/refman/8.0/en/alter-server.html\n\n','ALTER SERVER s OPTIONS (USER \'sally\');\n','http://dev.mysql.com/doc/refman/8.0/en/alter-server.html');
-INSERT INTO help_topic (help_topic_id,help_category_id,name,description,example,url) VALUES (32,9,'ALTER TABLE','Syntax:\nALTER TABLE tbl_name\n [alter_specification [, alter_specification] ...]\n [partition_options]\n\nalter_specification:\n table_options\n | ADD [COLUMN] col_name column_definition\n [FIRST | AFTER col_name]\n | ADD [COLUMN] (col_name column_definition,...)\n | ADD {INDEX|KEY} [index_name]\n [index_type] (key_part,...) [index_option] ...\n | ADD [CONSTRAINT [symbol]] PRIMARY KEY\n [index_type] (key_part,...) [index_option] ...\n | ADD [CONSTRAINT [symbol]]\n UNIQUE [INDEX|KEY] [index_name]\n [index_type] (key_part,...) [index_option] ...\n | ADD FULLTEXT [INDEX|KEY] [index_name]\n (key_part,...) [index_option] ...\n | ADD SPATIAL [INDEX|KEY] [index_name]\n (key_part,...) [index_option] ...\n | ADD [CONSTRAINT [symbol]]\n FOREIGN KEY [index_name] (col_name,...)\n reference_definition\n | ALGORITHM [=] {DEFAULT|INSTANT|INPLACE|COPY}\n | ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT}\n | ALTER INDEX index_name {VISIBLE | INVISIBLE}\n | CHANGE [COLUMN] old_col_name new_col_name column_definition\n [FIRST|AFTER col_name]\n | [DEFAULT] CHARACTER SET [=] charset_name [COLLATE [=] collation_name]\n | CONVERT TO CHARACTER SET charset_name [COLLATE collation_name]\n | {DISABLE|ENABLE} KEYS\n | {DISCARD|IMPORT} TABLESPACE\n | DROP [COLUMN] col_name\n | DROP {INDEX|KEY} index_name\n | DROP PRIMARY KEY\n | DROP FOREIGN KEY fk_symbol\n | FORCE\n | LOCK [=] {DEFAULT|NONE|SHARED|EXCLUSIVE}\n | MODIFY [COLUMN] col_name column_definition\n [FIRST | AFTER col_name]\n | ORDER BY col_name [, col_name] ...\n | RENAME COLUMN old_col_name TO new_col_name\n | RENAME {INDEX|KEY} old_index_name TO new_index_name\n | RENAME [TO|AS] new_tbl_name\n | {WITHOUT|WITH} VALIDATION\n | ADD PARTITION (partition_definition)\n | DROP PARTITION partition_names\n | DISCARD PARTITION {partition_names | ALL} TABLESPACE\n | IMPORT PARTITION {partition_names | ALL} TABLESPACE\n | TRUNCATE PARTITION {partition_names | ALL}\n | COALESCE PARTITION number\n | REORGANIZE PARTITION partition_names INTO (partition_definitions)\n | EXCHANGE PARTITION partition_name WITH TABLE tbl_name [{WITH|WITHOUT} VALIDATION]\n | ANALYZE PARTITION {partition_names | ALL}\n | CHECK PARTITION {partition_names | ALL}\n | OPTIMIZE PARTITION {partition_names | ALL}\n | REBUILD PARTITION {partition_names | ALL}\n | REPAIR PARTITION {partition_names | ALL}\n | REMOVE PARTITIONING\n | UPGRADE PARTITIONING\n\nkey_part: {col_name [(length)] | (expr)} [ASC | DESC]\n\nindex_type:\n USING {BTREE | HASH}\n\nindex_option:\n KEY_BLOCK_SIZE [=] value\n | index_type\n | WITH PARSER parser_name\n | COMMENT \'string\'\n | {VISIBLE | INVISIBLE}\n\ntable_options:\n table_option [[,] table_option] ...\n\ntable_option:\n AUTO_INCREMENT [=] value\n | AVG_ROW_LENGTH [=] value\n | [DEFAULT] CHARACTER SET [=] charset_name\n | CHECKSUM [=] {0 | 1}\n | [DEFAULT] COLLATE [=] collation_name\n | COMMENT [=] \'string\'\n | COMPRESSION [=] {\'ZLIB\'|\'LZ4\'|\'NONE\'}\n | CONNECTION [=] \'connect_string\'\n | {DATA|INDEX} DIRECTORY [=] \'absolute path to directory\'\n | DELAY_KEY_WRITE [=] {0 | 1}\n | ENCRYPTION [=] {\'Y\' | \'N\'}\n | ENGINE [=] engine_name\n | INSERT_METHOD [=] { NO | FIRST | LAST }\n | KEY_BLOCK_SIZE [=] value\n | MAX_ROWS [=] value\n | MIN_ROWS [=] value\n | PACK_KEYS [=] {0 | 1 | DEFAULT}\n | PASSWORD [=] \'string\'\n | ROW_FORMAT [=] {DEFAULT|DYNAMIC|FIXED|COMPRESSED|REDUNDANT|COMPACT}\n | STATS_AUTO_RECALC [=] {DEFAULT|0|1}\n | STATS_PERSISTENT [=] {DEFAULT|0|1}\n | STATS_SAMPLE_PAGES [=] value\n | TABLESPACE tablespace_name\n | UNION [=] (tbl_name[,tbl_name]...)\n\npartition_options:\n (see CREATE TABLE options)\n\nALTER TABLE changes the structure of a table. For example, you can add\nor delete columns, create or destroy indexes, change the type of\nexisting columns, or rename columns or the table itself. You can also\nchange characteristics such as the storage engine used for the table or\nthe table comment.\n\no To use ALTER TABLE, you need ALTER, CREATE, and INSERT privileges for\n the table. Renaming a table requires ALTER and DROP on the old table,\n ALTER, CREATE, and INSERT on the new table.\n\no Following the table name, specify the alterations to be made. If none\n are given, ALTER TABLE does nothing.\n\no The syntax for many of the permissible alterations is similar to\n clauses of the CREATE TABLE statement. column_definition clauses use\n the same syntax for ADD and CHANGE as for CREATE TABLE. For more\n information, see [HELP CREATE TABLE].\n\no The word COLUMN is optional and can be omitted, except for RENAME\n COLUMN (to distinguish a column-renaming operation from the RENAME\n table-renaming operation).\n\no Multiple ADD, ALTER, DROP, and CHANGE clauses are permitted in a\n single ALTER TABLE statement, separated by commas. This is a MySQL\n extension to standard SQL, which permits only one of each clause per\n ALTER TABLE statement. For example, to drop multiple columns in a\n single statement, do this:\n\nALTER TABLE t2 DROP COLUMN c, DROP COLUMN d;\n\no If a storage engine does not support an attempted ALTER TABLE\n operation, a warning may result. Such warnings can be displayed with\n SHOW WARNINGS. See [HELP SHOW WARNINGS]. For information on\n troubleshooting ALTER TABLE, see\n http://dev.mysql.com/doc/refman/8.0/en/alter-table-problems.html.\n\no For information about generated columns, see\n http://dev.mysql.com/doc/refman/8.0/en/alter-table-generated-columns.\n html.\n\no For usage examples, see\n http://dev.mysql.com/doc/refman/8.0/en/alter-table-examples.html.\n\no With the mysql_info() C API function, you can find out how many rows\n were copied by ALTER TABLE. See\n http://dev.mysql.com/doc/refman/8.0/en/mysql-info.html.\n\nURL: http://dev.mysql.com/doc/refman/8.0/en/alter-table.html\n\n','','http://dev.mysql.com/doc/refman/8.0/en/alter-table.html');
+INSERT INTO help_topic (help_topic_id,help_category_id,name,description,example,url) VALUES (32,9,'ALTER TABLE','Syntax:\nALTER TABLE tbl_name\n [alter_specification [, alter_specification] ...]\n [partition_options]\n\nalter_specification:\n table_options\n | ADD [COLUMN] col_name column_definition\n [FIRST | AFTER col_name]\n | ADD [COLUMN] (col_name column_definition,...)\n | ADD {INDEX|KEY} [index_name]\n [index_type] (key_part,...) [index_option] ...\n | ADD [CONSTRAINT [symbol]] PRIMARY KEY\n [index_type] (key_part,...) [index_option] ...\n | ADD [CONSTRAINT [symbol]]\n UNIQUE [INDEX|KEY] [index_name]\n [index_type] (key_part,...) [index_option] ...\n | ADD FULLTEXT [INDEX|KEY] [index_name]\n (key_part,...) [index_option] ...\n | ADD SPATIAL [INDEX|KEY] [index_name]\n (key_part,...) [index_option] ...\n | ADD [CONSTRAINT [symbol]]\n FOREIGN KEY [index_name] (col_name,...)\n reference_definition\n | ALGORITHM [=] {DEFAULT|INSTANT|INPLACE|COPY}\n | ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT}\n | ALTER INDEX index_name {VISIBLE | INVISIBLE}\n | ALTER CHECK symbol [NOT] ENFORCED\n | CHANGE [COLUMN] old_col_name new_col_name column_definition\n [FIRST|AFTER col_name]\n | [DEFAULT] CHARACTER SET [=] charset_name [COLLATE [=] collation_name]\n | CONVERT TO CHARACTER SET charset_name [COLLATE collation_name]\n | {DISABLE|ENABLE} KEYS\n | {DISCARD|IMPORT} TABLESPACE\n | DROP [COLUMN] col_name\n | DROP {INDEX|KEY} index_name\n | DROP PRIMARY KEY\n | DROP FOREIGN KEY fk_symbol\n | DROP CHECK symbol\n | FORCE\n | LOCK [=] {DEFAULT|NONE|SHARED|EXCLUSIVE}\n | MODIFY [COLUMN] col_name column_definition\n [FIRST | AFTER col_name]\n | ORDER BY col_name [, col_name] ...\n | RENAME COLUMN old_col_name TO new_col_name\n | RENAME {INDEX|KEY} old_index_name TO new_index_name\n | RENAME [TO|AS] new_tbl_name\n | {WITHOUT|WITH} VALIDATION\n | ADD PARTITION (partition_definition)\n | DROP PARTITION partition_names\n | DISCARD PARTITION {partition_names | ALL} TABLESPACE\n | IMPORT PARTITION {partition_names | ALL} TABLESPACE\n | TRUNCATE PARTITION {partition_names | ALL}\n | COALESCE PARTITION number\n | REORGANIZE PARTITION partition_names INTO (partition_definitions)\n | EXCHANGE PARTITION partition_name WITH TABLE tbl_name [{WITH|WITHOUT} VALIDATION]\n | ANALYZE PARTITION {partition_names | ALL}\n | CHECK PARTITION {partition_names | ALL}\n | OPTIMIZE PARTITION {partition_names | ALL}\n | REBUILD PARTITION {partition_names | ALL}\n | REPAIR PARTITION {partition_names | ALL}\n | REMOVE PARTITIONING\n | UPGRADE PARTITIONING\n\nkey_part: {col_name [(length)] | (expr)} [ASC | DESC]\n\nindex_type:\n USING {BTREE | HASH}\n\nindex_option:\n KEY_BLOCK_SIZE [=] value\n | index_type\n | WITH PARSER parser_name\n | COMMENT \'string\'\n | {VISIBLE | INVISIBLE}\n\ntable_options:\n table_option [[,] table_option] ...\n\ntable_option:\n AUTO_INCREMENT [=] value\n | AVG_ROW_LENGTH [=] value\n | [DEFAULT] CHARACTER SET [=] charset_name\n | CHECKSUM [=] {0 | 1}\n | [DEFAULT] COLLATE [=] collation_name\n | COMMENT [=] \'string\'\n | COMPRESSION [=] {\'ZLIB\'|\'LZ4\'|\'NONE\'}\n | CONNECTION [=] \'connect_string\'\n | {DATA|INDEX} DIRECTORY [=] \'absolute path to directory\'\n | DELAY_KEY_WRITE [=] {0 | 1}\n | ENCRYPTION [=] {\'Y\' | \'N\'}\n | ENGINE [=] engine_name\n | INSERT_METHOD [=] { NO | FIRST | LAST }\n | KEY_BLOCK_SIZE [=] value\n | MAX_ROWS [=] value\n | MIN_ROWS [=] value\n | PACK_KEYS [=] {0 | 1 | DEFAULT}\n | PASSWORD [=] \'string\'\n | ROW_FORMAT [=] {DEFAULT|DYNAMIC|FIXED|COMPRESSED|REDUNDANT|COMPACT}\n | STATS_AUTO_RECALC [=] {DEFAULT|0|1}\n | STATS_PERSISTENT [=] {DEFAULT|0|1}\n | STATS_SAMPLE_PAGES [=] value\n | TABLESPACE tablespace_name\n | UNION [=] (tbl_name[,tbl_name]...)\n\npartition_options:\n (see CREATE TABLE options)\n\nALTER TABLE changes the structure of a table. For example, you can add\nor delete columns, create or destroy indexes, change the type of\nexisting columns, or rename columns or the table itself. You can also\nchange characteristics such as the storage engine used for the table or\nthe table comment.\n\no To use ALTER TABLE, you need ALTER, CREATE, and INSERT privileges for\n the table. Renaming a table requires ALTER and DROP on the old table,\n ALTER, CREATE, and INSERT on the new table.\n\no Following the table name, specify the alterations to be made. If none\n are given, ALTER TABLE does nothing.\n\no The syntax for many of the permissible alterations is similar to\n clauses of the CREATE TABLE statement. column_definition clauses use\n the same syntax for ADD and CHANGE as for CREATE TABLE. For more\n information, see [HELP CREATE TABLE].\n\no The word COLUMN is optional and can be omitted, except for RENAME\n COLUMN (to distinguish a column-renaming operation from the RENAME\n table-renaming operation).\n\no Multiple ADD, ALTER, DROP, and CHANGE clauses are permitted in a\n single ALTER TABLE statement, separated by commas. This is a MySQL\n extension to standard SQL, which permits only one of each clause per\n ALTER TABLE statement. For example, to drop multiple columns in a\n single statement, do this:\n\nALTER TABLE t2 DROP COLUMN c, DROP COLUMN d;\n\no If a storage engine does not support an attempted ALTER TABLE\n operation, a warning may result. Such warnings can be displayed with\n SHOW WARNINGS. See [HELP SHOW WARNINGS]. For information on\n troubleshooting ALTER TABLE, see\n http://dev.mysql.com/doc/refman/8.0/en/alter-table-problems.html.\n\no For information about generated columns, see\n http://dev.mysql.com/doc/refman/8.0/en/alter-table-generated-columns.\n html.\n\no For usage examples, see\n http://dev.mysql.com/doc/refman/8.0/en/alter-table-examples.html.\n\no With the mysql_info() C API function, you can find out how many rows\n were copied by ALTER TABLE. See\n http://dev.mysql.com/doc/refman/8.0/en/mysql-info.html.\n\nURL: http://dev.mysql.com/doc/refman/8.0/en/alter-table.html\n\n','','http://dev.mysql.com/doc/refman/8.0/en/alter-table.html');
INSERT INTO help_topic (help_topic_id,help_category_id,name,description,example,url) VALUES (33,9,'ALTER TABLESPACE','Syntax:\nALTER TABLESPACE tablespace_name\n [RENAME TO tablespace_name] \n [ENCRYPTION [=] {\'Y\' | \'N\'}]\n [ENGINE [=] engine_name]\n\nThis statement can be used to rename an InnoDB general tablespace.\n\nThe CREATE TABLESPACE privilege is required to rename a general\ntablespace.\n\nThe ENGINE clause, which specifies the storage engine used by the\ntablespace, is deprecated and will be removed in a future release. The\ntablespace storage engine is known by the data dictionary, making the\nENGINE clause obsolete. If the storage engine is specified, it must\nmatch the tablespace storage engine defined in the data dictionary.\n\nRENAME TO operations are implicitly performed in autocommit mode,\nregardless of the autocommit setting.\n\nA RENAME TO operation cannot be performed while LOCK TABLES or FLUSH\nTABLES WITH READ LOCK is in effect for tables that reside in the\ntablespace.\n\nExclusive metadata locks are taken on tables that reside in a general\ntablespace while the tablespace is renamed, which prevents concurrent\nDDL. Concurrent DML is supported.\n\nThe ENCRYPTION option is used to enable or disable page-level data\nencryption for an InnoDB general tablespace. Option values are not\ncase-sensitive. The Encryption support for general tablespaces was\nintroduced in MySQL 8.0.13. A keyring plugin must be installed and\nconfigured to encrypt a tablespace using the ENCRYPTION option.\n\nWhen a general tablespace is encrypted, all tables residing in the\ntablespace are encrypted. Likewise, a table created in an encrypted\ngeneral tablespace is encrypted.\n\nThe INPLACE algorithm is used when altering the ENCRYPTION attribute of\na general tablespace. The INPLACE algorithm permits concurrent DML on\ntables that reside in the general tablespace. Concurrent DDL is\nblocked.\n\nFor more information, see\nhttp://dev.mysql.com/doc/refman/8.0/en/innodb-tablespace-encryption.htm\nl.\n\nURL: http://dev.mysql.com/doc/refman/8.0/en/alter-tablespace.html\n\n','','http://dev.mysql.com/doc/refman/8.0/en/alter-tablespace.html');
INSERT INTO help_topic (help_topic_id,help_category_id,name,description,example,url) VALUES (34,1,'ALTER USER','Syntax:\nALTER USER [IF EXISTS]\n user [auth_option] [, user [auth_option]] ...\n [REQUIRE {NONE | tls_option [[AND] tls_option] ...}]\n [WITH resource_option [resource_option] ...]\n [password_option | lock_option] ...\n\nALTER USER [IF EXISTS]\n USER() IDENTIFIED BY \'auth_string\' [REPLACE \'current_auth_string\']\n\nALTER USER [IF EXISTS]\n user DEFAULT ROLE\n {NONE | ALL | role [, role ] ...}\n\nuser:\n (see )\n\nauth_option: {\n IDENTIFIED BY \'auth_string\' [REPLACE \'current_auth_string\']\n | IDENTIFIED WITH auth_plugin\n | IDENTIFIED WITH auth_plugin BY \'auth_string\' [REPLACE \'current_auth_string\']\n | IDENTIFIED WITH auth_plugin AS \'hash_string\'\n}\n\ntls_option: {\n SSL\n | X509\n | CIPHER \'cipher\'\n | ISSUER \'issuer\'\n | SUBJECT \'subject\'\n}\n\nresource_option: {\n MAX_QUERIES_PER_HOUR count\n | MAX_UPDATES_PER_HOUR count\n | MAX_CONNECTIONS_PER_HOUR count\n | MAX_USER_CONNECTIONS count\n}\n\npassword_option: {\n PASSWORD EXPIRE [DEFAULT | NEVER | INTERVAL N DAY]\n | PASSWORD HISTORY {DEFAULT | N}\n | PASSWORD REUSE INTERVAL {DEFAULT | N DAY}\n | PASSWORD REQUIRE CURRENT [DEFAULT | OPTIONAL]\n}\n\nlock_option: {\n ACCOUNT LOCK\n | ACCOUNT UNLOCK\n}\n\nThe ALTER USER statement modifies MySQL accounts. It enables\nauthentication, role, SSL/TLS, resource-limit, and password-management\nproperties to be modified for existing accounts, and enables account\nlocking and unlocking.\n\nIn most cases, ALTER USER requires the global CREATE USER privilege, or\nthe UPDATE privilege for the mysql system database. The exceptions are:\n\no Any client who connects to the server using a nonanonymous account\n can change the password for that account. (In particular, you can\n change your own password.) To see which account the server\n authenticated you as, invoke the CURRENT_USER() function:\n\nSELECT CURRENT_USER();\n\no For DEFAULT ROLE syntax, ALTER USER requires these privileges:\n\n o Setting the default roles for another user requires the global\n CREATE USER privilege, or the UPDATE privilege for the\n mysql.default_roles system table.\n\n o Setting the default roles for yourself requires no special\n privileges, as long as the roles you want as the default have been\n granted to you.\n\nWhen the read_only system variable is enabled, ALTER USER additionally\nrequires the CONNECTION_ADMIN or SUPER privilege.\n\nBy default, an error occurs if you try to modify a user that does not\nexist. If the IF EXISTS clause is given, the statement produces a\nwarning for each named user that does not exist, rather than an error.\n\nURL: http://dev.mysql.com/doc/refman/8.0/en/alter-user.html\n\n','','http://dev.mysql.com/doc/refman/8.0/en/alter-user.html');
INSERT INTO help_topic (help_topic_id,help_category_id,name,description,example,url) VALUES (35,9,'ALTER VIEW','Syntax:\nALTER\n [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]\n [DEFINER = { user | CURRENT_USER }]\n [SQL SECURITY { DEFINER | INVOKER }]\n VIEW view_name [(column_list)]\n AS select_statement\n [WITH [CASCADED | LOCAL] CHECK OPTION]\n\nThis statement changes the definition of a view, which must exist. The\nsyntax is similar to that for CREATE VIEW see [HELP CREATE VIEW]). This\nstatement requires the CREATE VIEW and DROP privileges for the view,\nand some privilege for each column referred to in the SELECT statement.\nALTER VIEW is permitted only to the definer or users with the\nSET_USER_ID or SUPER privilege.\n\nURL: http://dev.mysql.com/doc/refman/8.0/en/alter-view.html\n\n','','http://dev.mysql.com/doc/refman/8.0/en/alter-view.html');
@@ -204,7 +204,7 @@ INSERT INTO help_topic (help_topic_id,help_category_id,name,description,example,
INSERT INTO help_topic (help_topic_id,help_category_id,name,description,example,url) VALUES (115,1,'CREATE ROLE','Syntax:\nCREATE ROLE [IF NOT EXISTS] role [, role ] ...\n\nCREATE ROLE creates one or more roles, which are named collections of\nprivileges. To use this statement, you must have the global CREATE ROLE\nor CREATE USER privilege. When the read_only system variable is\nenabled, CREATE ROLE additionally requires the CONNECTION_ADMIN or\nSUPER privilege.\n\nA role when created is locked, has no password, and is assigned the\ndefault authentication plugin.\n\nCREATE ROLE either succeeds for all named roles or rolls back and has\nno effect if any error occurs. By default, an error occurs if you try\nto create a role that already exists. If the IF NOT EXISTS clause is\ngiven, the statement produces a warning for each named role that\nalready exists, rather than an error.\n\nThe statement is written to the binary log if it succeeds, but not if\nit fails; in that case, rollback occurs and no changes are made. A\nstatement written to the binary log includes all named roles. If the IF\nNOT EXISTS clause is given, this includes even roles that already exist\nand were not created.\n\nEach role name uses the format described in\nhttp://dev.mysql.com/doc/refman/8.0/en/role-names.html. For example:\n\nCREATE ROLE \'administrator\', \'developer\';\nCREATE ROLE \'webapp\'@\'localhost\';\n\nThe host name part of the role name, if omitted, defaults to \'%\'.\n\nFor role usage examples, see\nhttp://dev.mysql.com/doc/refman/8.0/en/roles.html.\n\nURL: http://dev.mysql.com/doc/refman/8.0/en/create-role.html\n\n','','http://dev.mysql.com/doc/refman/8.0/en/create-role.html');
INSERT INTO help_topic (help_topic_id,help_category_id,name,description,example,url) VALUES (116,9,'CREATE SERVER','Syntax:\nCREATE SERVER server_name\n FOREIGN DATA WRAPPER wrapper_name\n OPTIONS (option [, option] ...)\n\noption:\n { HOST character-literal\n | DATABASE character-literal\n | USER character-literal\n | PASSWORD character-literal\n | SOCKET character-literal\n | OWNER character-literal\n | PORT numeric-literal }\n\nThis statement creates the definition of a server for use with the\nFEDERATED storage engine. The CREATE SERVER statement creates a new row\nin the servers table in the mysql database. This statement requires the\nSUPER privilege.\n\nThe server_name should be a unique reference to the server. Server\ndefinitions are global within the scope of the server, it is not\npossible to qualify the server definition to a specific database.\nserver_name has a maximum length of 64 characters (names longer than 64\ncharacters are silently truncated), and is case insensitive. You may\nspecify the name as a quoted string.\n\nThe wrapper_name is an identifier and may be quoted with single\nquotation marks.\n\nFor each option you must specify either a character literal or numeric\nliteral. Character literals are UTF-8, support a maximum length of 64\ncharacters and default to a blank (empty) string. String literals are\nsilently truncated to 64 characters. Numeric literals must be a number\nbetween 0 and 9999, default value is 0.\n\n*Note*:\n\nThe OWNER option is currently not applied, and has no effect on the\nownership or operation of the server connection that is created.\n\nThe CREATE SERVER statement creates an entry in the mysql.servers table\nthat can later be used with the CREATE TABLE statement when creating a\nFEDERATED table. The options that you specify will be used to populate\nthe columns in the mysql.servers table. The table columns are\nServer_name, Host, Db, Username, Password, Port and Socket.\n\nURL: http://dev.mysql.com/doc/refman/8.0/en/create-server.html\n\n','CREATE SERVER s\nFOREIGN DATA WRAPPER mysql\nOPTIONS (USER \'Remote\', HOST \'198.51.100.106\', DATABASE \'test\');\n','http://dev.mysql.com/doc/refman/8.0/en/create-server.html');
INSERT INTO help_topic (help_topic_id,help_category_id,name,description,example,url) VALUES (117,9,'CREATE SPATIAL REFERENCE SYSTEM','Syntax:\nCREATE OR REPLACE SPATIAL REFERENCE SYSTEM\n srid srs_attribute ...\n\nCREATE SPATIAL REFERENCE SYSTEM\n [IF NOT EXISTS]\n srid srs_attribute ...\n\nsrs_attribute: {\n NAME \'srs_name\'\n | DEFINITION \'definition\'\n | ORGANIZATION \'org_name\' IDENTIFIED BY org_id\n | DESCRIPTION \'description\'\n}\n\nsrid, org_id: 32-bit unsigned integer\n\nThis statement creates a spatial reference system (SRS) definition and\nstores it in the data dictionary. The definition can be inspected using\nthe INFORMATION_SCHEMA ST_SPATIAL_REFERENCE_SYSTEMS table. This\nstatement requires the SUPER privilege.\n\nIf neither OR REPLACE nor IF NOT EXISTS is specified, an error occurs\nif an SRS definition with the SRID value already exists.\n\nWith CREATE OR REPLACE syntax, any existing SRS definition with the\nsame SRID value is replaced, unless the SRID value is used by some\ncolumn in an existing table. In that case, an error occurs. For\nexample:\n\nmysql> CREATE OR REPLACE SPATIAL REFERENCE SYSTEM 4326 ...;\nERROR 3716 (SR005): Can\'t modify SRID 4326. There is at\nleast one column depending on it.\n\nTo identify which column or columns use the SRID, use this query:\n\nSELECT * FROM INFORMATION_SCHEMA.ST_GEOMETRY_COLUMNS WHERE SRS_ID=4326;\n\nWith CREATE ... IF NOT EXISTS syntax, any existing SRS definition with\nthe same SRID value causes the new definition to be ignored and a\nwarning occurs.\n\nURL: http://dev.mysql.com/doc/refman/8.0/en/create-spatial-reference-system.html\n\n','CREATE SPATIAL REFERENCE SYSTEM 4120\nNAME \'Greek\'\nORGANIZATION \'EPSG\' IDENTIFIED BY 4120\nDEFINITION\n \'GEOGCS["Greek",DATUM["Greek",SPHEROID["Bessel 1841",\n 6377397.155,299.1528128,AUTHORITY["EPSG","7004"]],\n AUTHORITY["EPSG","6120"]],PRIMEM["Greenwich",0,\n AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943278,\n AUTHORITY["EPSG","9122"]],AXIS["Lat",NORTH],AXIS["Lon",EAST],\n AUTHORITY["EPSG","4120"]]\';\n','http://dev.mysql.com/doc/refman/8.0/en/create-spatial-reference-system.html');
-INSERT INTO help_topic (help_topic_id,help_category_id,name,description,example,url) VALUES (118,9,'CREATE TABLE','Syntax:\nCREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name\n (create_definition,...)\n [table_options]\n [partition_options]\n\nCREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name\n [(create_definition,...)]\n [table_options]\n [partition_options]\n [IGNORE | REPLACE]\n [AS] query_expression\n\nCREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name\n { LIKE old_tbl_name | (LIKE old_tbl_name) }\n\ncreate_definition:\n col_name column_definition\n | [CONSTRAINT [symbol]] PRIMARY KEY [index_type] (key_part,...)\n [index_option] ...\n | {INDEX|KEY} [index_name] [index_type] (key_part,...)\n [index_option] ...\n | [CONSTRAINT [symbol]] UNIQUE [INDEX|KEY]\n [index_name] [index_type] (key_part,...)\n [index_option] ...\n | {FULLTEXT|SPATIAL} [INDEX|KEY] [index_name] (key_part,...)\n [index_option] ...\n | [CONSTRAINT [symbol]] FOREIGN KEY\n [index_name] (col_name,...) reference_definition\n | CHECK (expr)\n\ncolumn_definition:\n data_type [NOT NULL | NULL] [DEFAULT {literal | (expr)} ]\n [AUTO_INCREMENT] [UNIQUE [KEY]] [[PRIMARY] KEY]\n [COMMENT \'string\']\n [COLUMN_FORMAT {FIXED|DYNAMIC|DEFAULT}]\n [reference_definition]\n | data_type [GENERATED ALWAYS] AS (expression)\n [VIRTUAL | STORED] [NOT NULL | NULL]\n [UNIQUE [KEY]] [[PRIMARY] KEY]\n [COMMENT \'string\']\n\ndata_type:\n (see http://dev.mysql.com/doc/refman/8.0/en/data-types.html)\n\nkey_part: {col_name [(length)] | (expr)} [ASC | DESC]\n\nindex_type:\n USING {BTREE | HASH}\n\nindex_option:\n KEY_BLOCK_SIZE [=] value\n | index_type\n | WITH PARSER parser_name\n | COMMENT \'string\'\n | {VISIBLE | INVISIBLE}\n\nreference_definition:\n REFERENCES tbl_name (key_part,...)\n [MATCH FULL | MATCH PARTIAL | MATCH SIMPLE]\n [ON DELETE reference_option]\n [ON UPDATE reference_option]\n\nreference_option:\n RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT\n\ntable_options:\n table_option [[,] table_option] ...\n\ntable_option:\n AUTO_INCREMENT [=] value\n | AVG_ROW_LENGTH [=] value\n | [DEFAULT] CHARACTER SET [=] charset_name\n | CHECKSUM [=] {0 | 1}\n | [DEFAULT] COLLATE [=] collation_name\n | COMMENT [=] \'string\'\n | COMPRESSION [=] {\'ZLIB\'|\'LZ4\'|\'NONE\'}\n | CONNECTION [=] \'connect_string\'\n | {DATA|INDEX} DIRECTORY [=] \'absolute path to directory\'\n | DELAY_KEY_WRITE [=] {0 | 1}\n | ENCRYPTION [=] {\'Y\' | \'N\'}\n | ENGINE [=] engine_name\n | INSERT_METHOD [=] { NO | FIRST | LAST }\n | KEY_BLOCK_SIZE [=] value\n | MAX_ROWS [=] value\n | MIN_ROWS [=] value\n | PACK_KEYS [=] {0 | 1 | DEFAULT}\n | PASSWORD [=] \'string\'\n | ROW_FORMAT [=] {DEFAULT|DYNAMIC|FIXED|COMPRESSED|REDUNDANT|COMPACT}\n | STATS_AUTO_RECALC [=] {DEFAULT|0|1}\n | STATS_PERSISTENT [=] {DEFAULT|0|1}\n | STATS_SAMPLE_PAGES [=] value\n | TABLESPACE tablespace_name\n | UNION [=] (tbl_name[,tbl_name]...)\n\npartition_options:\n PARTITION BY\n { [LINEAR] HASH(expr)\n | [LINEAR] KEY [ALGORITHM={1|2}] (column_list)\n | RANGE{(expr) | COLUMNS(column_list)}\n | LIST{(expr) | COLUMNS(column_list)} }\n [PARTITIONS num]\n [SUBPARTITION BY\n { [LINEAR] HASH(expr)\n | [LINEAR] KEY [ALGORITHM={1|2}] (column_list) }\n [SUBPARTITIONS num]\n ]\n [(partition_definition [, partition_definition] ...)]\n\npartition_definition:\n PARTITION partition_name\n [VALUES\n {LESS THAN {(expr | value_list) | MAXVALUE}\n |\n IN (value_list)}]\n [[STORAGE] ENGINE [=] engine_name]\n [COMMENT [=] \'string\' ]\n [DATA DIRECTORY [=] \'data_dir\']\n [INDEX DIRECTORY [=] \'index_dir\']\n [MAX_ROWS [=] max_number_of_rows]\n [MIN_ROWS [=] min_number_of_rows]\n [TABLESPACE [=] tablespace_name]\n [(subpartition_definition [, subpartition_definition] ...)]\n\nsubpartition_definition:\n SUBPARTITION logical_name\n [[STORAGE] ENGINE [=] engine_name]\n [COMMENT [=] \'string\' ]\n [DATA DIRECTORY [=] \'data_dir\']\n [INDEX DIRECTORY [=] \'index_dir\']\n [MAX_ROWS [=] max_number_of_rows]\n [MIN_ROWS [=] min_number_of_rows]\n [TABLESPACE [=] tablespace_name]\n\nquery_expression:\n SELECT ... (Some valid select or union statement)\n\nCREATE TABLE creates a table with the given name. You must have the\nCREATE privilege for the table.\n\nBy default, tables are created in the default database, using the\nInnoDB storage engine. An error occurs if the table exists, if there is\nno default database, or if the database does not exist.\n\nFor information about the physical representation of a table, see\nhttp://dev.mysql.com/doc/refman/8.0/en/create-table-files.html.\n\nURL: http://dev.mysql.com/doc/refman/8.0/en/create-table.html\n\n','','http://dev.mysql.com/doc/refman/8.0/en/create-table.html');
+INSERT INTO help_topic (help_topic_id,help_category_id,name,description,example,url) VALUES (118,9,'CREATE TABLE','Syntax:\nCREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name\n (create_definition,...)\n [table_options]\n [partition_options]\n\nCREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name\n [(create_definition,...)]\n [table_options]\n [partition_options]\n [IGNORE | REPLACE]\n [AS] query_expression\n\nCREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name\n { LIKE old_tbl_name | (LIKE old_tbl_name) }\n\ncreate_definition:\n col_name column_definition\n | [CONSTRAINT [symbol]] PRIMARY KEY [index_type] (key_part,...)\n [index_option] ...\n | {INDEX|KEY} [index_name] [index_type] (key_part,...)\n [index_option] ...\n | [CONSTRAINT [symbol]] UNIQUE [INDEX|KEY]\n [index_name] [index_type] (key_part,...)\n [index_option] ...\n | {FULLTEXT|SPATIAL} [INDEX|KEY] [index_name] (key_part,...)\n [index_option] ...\n | [CONSTRAINT [symbol]] FOREIGN KEY\n [index_name] (col_name,...) reference_definition\n | check_constraint_definition\n\ncolumn_definition:\n data_type [NOT NULL | NULL] [DEFAULT {literal | (expr)} ]\n [AUTO_INCREMENT] [UNIQUE [KEY]] [[PRIMARY] KEY]\n [COMMENT \'string\']\n [COLUMN_FORMAT {FIXED|DYNAMIC|DEFAULT}]\n [reference_definition]\n [check_constraint_definition]\n | data_type [GENERATED ALWAYS] AS (expression)\n [VIRTUAL | STORED] [NOT NULL | NULL]\n [UNIQUE [KEY]] [[PRIMARY] KEY]\n [COMMENT \'string\']\n [check_constraint_definition]\n\n\ndata_type:\n (see http://dev.mysql.com/doc/refman/8.0/en/data-types.html)\n\nkey_part: {col_name [(length)] | (expr)} [ASC | DESC]\n\nindex_type:\n USING {BTREE | HASH}\n\nindex_option:\n KEY_BLOCK_SIZE [=] value\n | index_type\n | WITH PARSER parser_name\n | COMMENT \'string\'\n | {VISIBLE | INVISIBLE}\n\nreference_definition:\n REFERENCES tbl_name (key_part,...)\n [MATCH FULL | MATCH PARTIAL | MATCH SIMPLE]\n [ON DELETE reference_option]\n [ON UPDATE reference_option]\n\nreference_option:\n RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT\n\ncheck_constraint_definition:\n [CONSTRAINT [symbol]] CHECK (expr) [[NOT] ENFORCED]\n\ntable_options:\n table_option [[,] table_option] ...\n\ntable_option:\n AUTO_INCREMENT [=] value\n | AVG_ROW_LENGTH [=] value\n | [DEFAULT] CHARACTER SET [=] charset_name\n | CHECKSUM [=] {0 | 1}\n | [DEFAULT] COLLATE [=] collation_name\n | COMMENT [=] \'string\'\n | COMPRESSION [=] {\'ZLIB\'|\'LZ4\'|\'NONE\'}\n | CONNECTION [=] \'connect_string\'\n | {DATA|INDEX} DIRECTORY [=] \'absolute path to directory\'\n | DELAY_KEY_WRITE [=] {0 | 1}\n | ENCRYPTION [=] {\'Y\' | \'N\'}\n | ENGINE [=] engine_name\n | INSERT_METHOD [=] { NO | FIRST | LAST }\n | KEY_BLOCK_SIZE [=] value\n | MAX_ROWS [=] value\n | MIN_ROWS [=] value\n | PACK_KEYS [=] {0 | 1 | DEFAULT}\n | PASSWORD [=] \'string\'\n | ROW_FORMAT [=] {DEFAULT|DYNAMIC|FIXED|COMPRESSED|REDUNDANT|COMPACT}\n | STATS_AUTO_RECALC [=] {DEFAULT|0|1}\n | STATS_PERSISTENT [=] {DEFAULT|0|1}\n | STATS_SAMPLE_PAGES [=] value\n | TABLESPACE tablespace_name\n | UNION [=] (tbl_name[,tbl_name]...)\n\npartition_options:\n PARTITION BY\n { [LINEAR] HASH(expr)\n | [LINEAR] KEY [ALGORITHM={1|2}] (column_list)\n | RANGE{(expr) | COLUMNS(column_list)}\n | LIST{(expr) | COLUMNS(column_list)} }\n [PARTITIONS num]\n [SUBPARTITION BY\n { [LINEAR] HASH(expr)\n | [LINEAR] KEY [ALGORITHM={1|2}] (column_list) }\n [SUBPARTITIONS num]\n ]\n [(partition_definition [, partition_definition] ...)]\n\npartition_definition:\n PARTITION partition_name\n [VALUES\n {LESS THAN {(expr | value_list) | MAXVALUE}\n |\n IN (value_list)}]\n [[STORAGE] ENGINE [=] engine_name]\n [COMMENT [=] \'string\' ]\n [DATA DIRECTORY [=] \'data_dir\']\n [INDEX DIRECTORY [=] \'index_dir\']\n [MAX_ROWS [=] max_number_of_rows]\n [MIN_ROWS [=] min_number_of_rows]\n [TABLESPACE [=] tablespace_name]\n [(subpartition_definition [, subpartition_definition] ...)]\n\nsubpartition_definition:\n SUBPARTITION logical_name\n [[STORAGE] ENGINE [=] engine_name]\n [COMMENT [=] \'string\' ]\n [DATA DIRECTORY [=] \'data_dir\']\n [INDEX DIRECTORY [=] \'index_dir\']\n [MAX_ROWS [=] max_number_of_rows]\n [MIN_ROWS [=] min_number_of_rows]\n [TABLESPACE [=] tablespace_name]\n\nquery_expression:\n SELECT ... (Some valid select or union statement)\n\nCREATE TABLE creates a table with the given name. You must have the\nCREATE privilege for the table.\n\nBy default, tables are created in the default database, using the\nInnoDB storage engine. An error occurs if the table exists, if there is\nno default database, or if the database does not exist.\n\nFor information about the physical representation of a table, see\nhttp://dev.mysql.com/doc/refman/8.0/en/create-table-files.html.\n\nURL: http://dev.mysql.com/doc/refman/8.0/en/create-table.html\n\n','','http://dev.mysql.com/doc/refman/8.0/en/create-table.html');
INSERT INTO help_topic (help_topic_id,help_category_id,name,description,example,url) VALUES (119,9,'CREATE TABLESPACE','Syntax:\nCREATE TABLESPACE tablespace_name\n ADD DATAFILE \'file_name\'\n [FILE_BLOCK_SIZE = value]\n [ENCRYPTION [=] {\'Y\' | \'N\'}]\n [ENGINE [=] engine_name]\n\nThis statement is used to create an InnoDB tablespace. An InnoDB\ntablespace created using CREATE TABLESPACE is referred to as general\ntablespace.\n\nA general tablespace is a shared tablespace, similar to the system\ntablespace. It can hold multiple tables, and supports all table row\nformats. General tablespaces can also be created in a location relative\nto or independent of the MySQL data directory.\n\nAfter creating an InnoDB general tablespace, you can use CREATE TABLE\ntbl_name ... TABLESPACE [=] tablespace_name or ALTER TABLE tbl_name\nTABLESPACE [=] tablespace_name to add tables to the tablespace.\n\nFor more information, see\nhttp://dev.mysql.com/doc/refman/8.0/en/general-tablespaces.html.\n\n*Note*:\n\nCREATE TABLESPACE is supported with InnoDB. In earlier releases, CREATE\nTABLESPACE only supported NDB\n(http://dev.mysql.com/doc/refman/5.7/en/mysql-cluster.html), which is\nthe MySQL NDB Cluster storage engine.\n\nOptions\n\no ADD DATAFILE: Defines the name of the tablespace data file. A data\n file must be specified with the CREATE TABLESPACE statement, and the\n data file name must have a .ibd extension. An InnoDB general\n tablespace only supports a single data file.\n\n To place the data file in a location outside of the MySQL data\n directory (DATADIR), include an absolute directory path or a path\n relative to the MySQL data directory. If you do not specify a path,\n the general tablespace is created in the MySQL data directory.\n\n To avoid conflicts with implicitly created file-per-table\n tablespaces, creating a general tablespace in a subdirectory under\n the MySQL data directory is not supported. Also, when creating a\n general tablespace outside of the MySQL data directory, the directory\n must exist and must be known to InnoDB prior to creating the\n tablespace. To make an unknown directory known to InnoDB, add the\n directory to the innodb_directories argument value.\n innodb_directories is a read-only startup option. Configuring it\n requires restarting the server.\n\n The file_name, including the path (optional), must be quoted with\n single or double quotations marks. File names (not counting the\n ".ibd" extension) and directory names must be at least one byte in\n length. Zero length file names and directory names are not supported.\n\no FILE_BLOCK_SIZE: Defines the block size for the tablespace data file.\n Values can be specified in bytes or kilobytes. For example, an 8\n kilobyte file block size can be specified as 8192 or 8K. If you do\n not specify this option, FILE_BLOCK_SIZE defaults to\n innodb_page_size. FILE_BLOCK_SIZE is required when you intend to use\n the tablespace for storing compressed InnoDB tables\n (ROW_FORMAT=COMPRESSED). In this case, you must define the tablespace\n FILE_BLOCK_SIZE when creating the tablespace.\n\n If FILE_BLOCK_SIZE is equal innodb_page_size, the tablespace can\n contain only tables having an uncompressed row format (COMPACT,\n REDUNDANT, and DYNAMIC row formats). Tables with a COMPRESSED row\n format have a different physical page size than uncompressed tables.\n Therefore, compressed tables cannot coexist in the same tablespace as\n uncompressed tables.\n\n For a general tablespace to contain compressed tables,\n FILE_BLOCK_SIZE must be specified, and the FILE_BLOCK_SIZE value must\n be a valid compressed page size in relation to the innodb_page_size\n value. Also, the physical page size of the compressed table\n (KEY_BLOCK_SIZE) must be equal to FILE_BLOCK_SIZE/1024. For example,\n if innodb_page_size=16K, and FILE_BLOCK_SIZE=8K, the KEY_BLOCK_SIZE\n of the table must be 8. For more information, see\n http://dev.mysql.com/doc/refman/8.0/en/general-tablespaces.html.\n\no The ENCRYPTION option is used to enable or disable page-level data\n encryption for an InnoDB general tablespace. Option values are not\n case-sensitive. Encryption support for general tablespaces was\n introduced in MySQL 8.0.13. A keyring plugin must be installed and\n configured to use the ENCRYPTION option.\n\n When a general tablespace is encrypted, all tables residing in the\n tablespace are encrypted. Likewise, a table created in an encrypted\n general tablespace is encrypted.\n\n For more information, see\n http://dev.mysql.com/doc/refman/8.0/en/innodb-tablespace-encryption.h\n tml\n\no ENGINE: Defines the storage engine which uses the tablespace, where\n engine_name is the name of the storage engine. Currently, only the\n InnoDB storage engine is supported. ENGINE = InnoDB must be defined\n as part of the CREATE TABLESPACE statement or InnoDB must be defined\n as the default storage engine (default_storage_engine=InnoDB).\n\nNotes\n\no tablespace_name is a case-sensitive identifier for the tablespace. It\n may be quoted or unquoted. The forward slash character ("/") is not\n permitted. Names beginning with innodb_ are either not permitted or\n are reserved for special use.\n\no Creation of temporary general tablespaces is not supported.\n\no General tablespaces do not support temporary tables.\n\no General tablespaces support the addition of tables of any row format\n using CREATE TABLE ... TABLESPACE. innodb_file_per_table does not\n need to be enabled.\n\no innodb_strict_mode is not applicable to general tablespaces.\n Tablespace management rules are strictly enforced independently of\n innodb_strict_mode. If CREATE TABLESPACE parameters are incorrect or\n incompatible, the operation fails regardless of the\n innodb_strict_mode setting. When a table is added to a general\n tablespace using CREATE TABLE ... TABLESPACE or ALTER TABLE ...\n TABLESPACE, innodb_strict_mode is ignored but the statement is\n evaluated as if innodb_strict_mode is enabled.\n\no Use DROP TABLESPACE to remove a general tablespace. All tables must\n be dropped from a general tablespace using DROP TABLE prior to\n dropping the tablespace.\n\no All parts of a table added to a general tablespace reside in the\n general tablespace, including indexes and BLOB pages.\n\no Similar to the system tablespace, truncating or dropping tables\n stored in a general tablespace creates free space internally in the\n general tablespace .ibd data file which can only be used for new\n InnoDB data. Space is not released back to the operating system as it\n is for file-per-table tablespaces.\n\no A general tablespace is not associated with any database or schema.\n\no ALTER TABLE ... DISCARD TABLESPACE and ALTER TABLE ...IMPORT\n TABLESPACE are not supported for tables that belong to a general\n tablespace.\n\no The server uses tablespace-level metadata locking for DDL that\n references general tablespaces. By comparison, the server uses\n table-level metadata locking for DDL that references file-per-table\n tablespaces.\n\no A generated or existing tablespace cannot be changed to a general\n tablespace.\n\no There is no conflict between general tablespace names and\n file-per-table tablespace names. The "/" character, which is present\n in file-per-table tablespace names, is not permitted in general\n tablespace names.\n\no mysqldump and mysqlpump do not dump InnoDB CREATE TABLESPACE\n statements.\n\nExamples\n\nThis example demonstrates creating a general tablespace and adding\nthree uncompressed tables of different row formats.\n\nmysql> CREATE TABLESPACE `ts1` ADD DATAFILE \'ts1.ibd\' Engine=InnoDB;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> CREATE TABLE t1 (c1 INT PRIMARY KEY) TABLESPACE ts1 ROW_FORMAT=REDUNDANT;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> CREATE TABLE t2 (c1 INT PRIMARY KEY) TABLESPACE ts1 ROW_FORMAT=COMPACT;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> CREATE TABLE t3 (c1 INT PRIMARY KEY) TABLESPACE ts1 ROW_FORMAT=DYNAMIC;\nQuery OK, 0 rows affected (0.00 sec)\n\nThis example demonstrates creating a general tablespace and adding a\ncompressed table. The example assumes a default innodb_page_size of\n16K. The FILE_BLOCK_SIZE of 8192 requires that the compressed table\nhave a KEY_BLOCK_SIZE of 8.\n\nmysql> CREATE TABLESPACE `ts2` ADD DATAFILE \'ts2.ibd\' FILE_BLOCK_SIZE = 8192 Engine=InnoDB;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> CREATE TABLE t4 (c1 INT PRIMARY KEY) TABLESPACE ts2 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;\nQuery OK, 0 rows affected (0.00 sec)\n\nURL: http://dev.mysql.com/doc/refman/8.0/en/create-tablespace.html\n\n','','http://dev.mysql.com/doc/refman/8.0/en/create-tablespace.html');
INSERT INTO help_topic (help_topic_id,help_category_id,name,description,example,url) VALUES (120,9,'CREATE TRIGGER','Syntax:\nCREATE\n [DEFINER = { user | CURRENT_USER }]\n TRIGGER trigger_name\n trigger_time trigger_event\n ON tbl_name FOR EACH ROW\n [trigger_order]\n trigger_body\n\ntrigger_time: { BEFORE | AFTER }\n\ntrigger_event: { INSERT | UPDATE | DELETE }\n\ntrigger_order: { FOLLOWS | PRECEDES } other_trigger_name\n\nThis statement creates a new trigger. A trigger is a named database\nobject that is associated with a table, and that activates when a\nparticular event occurs for the table. The trigger becomes associated\nwith the table named tbl_name, which must refer to a permanent table.\nYou cannot associate a trigger with a TEMPORARY table or a view.\n\nTrigger names exist in the schema namespace, meaning that all triggers\nmust have unique names within a schema. Triggers in different schemas\ncan have the same name.\n\nThis section describes CREATE TRIGGER syntax. For additional\ndiscussion, see\nhttp://dev.mysql.com/doc/refman/8.0/en/trigger-syntax.html.\n\nCREATE TRIGGER requires the TRIGGER privilege for the table associated\nwith the trigger. The statement might also require the SET_USER_ID or\nSUPER privilege, depending on the DEFINER value, as described later in\nthis section. If binary logging is enabled, CREATE TRIGGER might\nrequire the SUPER privilege, as described in\nhttp://dev.mysql.com/doc/refman/8.0/en/stored-programs-logging.html.\n\nThe DEFINER clause determines the security context to be used when\nchecking access privileges at trigger activation time, as described\nlater in this section.\n\ntrigger_time is the trigger action time. It can be BEFORE or AFTER to\nindicate that the trigger activates before or after each row to be\nmodified.\n\nBasic column value checks occur prior to trigger activation, so you\ncannot use BEFORE triggers to convert values inappropriate for the\ncolumn type to valid values.\n\ntrigger_event indicates the kind of operation that activates the\ntrigger. These trigger_event values are permitted:\n\no INSERT: The trigger activates whenever a new row is inserted into the\n table; for example, through INSERT, LOAD DATA, and REPLACE\n statements.\n\no UPDATE: The trigger activates whenever a row is modified; for\n example, through UPDATE statements.\n\no DELETE: The trigger activates whenever a row is deleted from the\n table; for example, through DELETE and REPLACE statements. DROP TABLE\n and TRUNCATE TABLE statements on the table do not activate this\n trigger, because they do not use DELETE. Dropping a partition does\n not activate DELETE triggers, either.\n\nURL: http://dev.mysql.com/doc/refman/8.0/en/create-trigger.html\n\n','','http://dev.mysql.com/doc/refman/8.0/en/create-trigger.html');
INSERT INTO help_topic (help_topic_id,help_category_id,name,description,example,url) VALUES (121,1,'CREATE USER','Syntax:\nCREATE USER [IF NOT EXISTS]\n user [auth_option] [, user [auth_option]] ...\n DEFAULT ROLE role [, role ] ...\n [REQUIRE {NONE | tls_option [[AND] tls_option] ...}]\n [WITH resource_option [resource_option] ...]\n [password_option | lock_option] ...\n\nuser:\n (see )\n\nauth_option: {\n IDENTIFIED BY \'auth_string\'\n | IDENTIFIED WITH auth_plugin\n | IDENTIFIED WITH auth_plugin BY \'auth_string\'\n | IDENTIFIED WITH auth_plugin AS \'hash_string\'\n}\n\ntls_option: {\n SSL\n | X509\n | CIPHER \'cipher\'\n | ISSUER \'issuer\'\n | SUBJECT \'subject\'\n}\n\nresource_option: {\n MAX_QUERIES_PER_HOUR count\n | MAX_UPDATES_PER_HOUR count\n | MAX_CONNECTIONS_PER_HOUR count\n | MAX_USER_CONNECTIONS count\n}\n\npassword_option: {\n PASSWORD EXPIRE [DEFAULT | NEVER | INTERVAL N DAY]\n | PASSWORD HISTORY {DEFAULT | N}\n | PASSWORD REUSE INTERVAL {DEFAULT | N DAY}\n | PASSWORD REQUIRE CURRENT [DEFAULT | OPTIONAL]\n}\n\nlock_option: {\n ACCOUNT LOCK\n | ACCOUNT UNLOCK\n}\n\nThe CREATE USER statement creates new MySQL accounts. It enables\nauthentication, role, SSL/TLS, resource-limit, and password-management\nproperties to be established for new accounts, and controls whether\naccounts are initially locked or unlocked.\n\nTo use CREATE USER, you must have the global CREATE USER privilege, or\nthe INSERT privilege for the mysql system database. When the read_only\nsystem variable is enabled, CREATE USER additionally requires the\nCONNECTION_ADMIN or SUPER privilege.\n\nCREATE USER either succeeds for all named users or rolls back and has\nno effect if any error occurs. By default, an error occurs if you try\nto create a user that already exists. If the IF NOT EXISTS clause is\ngiven, the statement produces a warning for each named user that\nalready exists, rather than an error.\n\nURL: http://dev.mysql.com/doc/refman/8.0/en/create-user.html\n\n','','http://dev.mysql.com/doc/refman/8.0/en/create-user.html');
diff --git a/share/errmsg-utf8.txt b/share/errmsg-utf8.txt
index b4ee156a73eb..c8a0c31cda36 100644
--- a/share/errmsg-utf8.txt
+++ b/share/errmsg-utf8.txt
@@ -8772,6 +8772,42 @@ ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_CLEANUP_AUX_KEY
ER_CLIENT_WARN_PARTIAL_REVOKE_MYSQLBINLOG_INCOMPATIBILITY
eng "mysqlbinlog tool may not be able to process GRANT/REVOKE correctly if --partial_revokes is set to ON. This may have implications on point in time recovery using mysqlbinlog."
+ER_NON_BOOLEAN_EXPR_FOR_CHECK_CONSTRAINT
+ eng "An expression of non-boolean type specified to a check constraint '%-.192s'."
+
+ER_COLUMN_CHECK_CONSTRAINT_REFERENCES_OTHER_COLUMN
+ eng "Column check constraint '%-.192s' references other column."
+
+ER_CHECK_CONSTRAINT_NAMED_FUNCTION_IS_NOT_ALLOWED
+ eng "An expression of a check constraint '%-.192s' contains disallowed function: %s."
+
+ER_CHECK_CONSTRAINT_FUNCTION_IS_NOT_ALLOWED
+ eng "An expression of a check constraint '%-.192s' contains disallowed function."
+
+ER_CHECK_CONSTRAINT_VARIABLES
+ eng "An expression of a check constraint '%-.192s' cannot refer to a user or system variables."
+
+ER_CHECK_CONSTRAINT_ROW_VALUE
+ eng "Check constraint '%-.192s' cannot refer to a row value."
+
+ER_CHECK_CONSTRAINT_REFERS_AUTO_INCREMENT_COLUMN
+ eng "Check constraint '%-.192s' cannot refer to an auto-increment column."
+
+ER_CHECK_CONSTRAINT_VIOLATED
+ eng "Check constraint '%-.192s' is violated."
+
+ER_CHECK_CONSTRAINT_REFERS_UNKNOWN_COLUMN
+ eng "Check constraint '%-.192s' refers to non-existing column '%-.192s'."
+
+ER_CHECK_CONSTRAINT_NOT_FOUND
+ eng "Check constraint '%-.192s' is not found in the table."
+
+ER_CHECK_CONSTRAINT_DUP_NAME
+ eng "Duplicate check constraint name '%-.192s'."
+
+ER_CHECK_CONSTRAINT_CLAUSE_USING_FK_REFER_ACTION_COLUMN
+ eng "Column '%-.192s' cannot be used in a check constraint '%-.192s': needed in a foreign key constraint '%-.192s' referential action."
+
#
# End of 8.0 error messages.
#
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index 184602edd5db..f05d3d836022 100644
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0,
@@ -120,6 +120,7 @@ SET(DD_SOURCES
dd/impl/raw/raw_table.cc
dd/impl/system_views/character_sets.cc
+ dd/impl/system_views/check_constraints.cc
dd/impl/system_views/collations.cc
dd/impl/system_views/collation_charset_applicability.cc
dd/impl/system_views/columns.cc
@@ -151,6 +152,7 @@ SET(DD_SOURCES
dd/impl/system_views/views.cc
dd/impl/tables/character_sets.cc
+ dd/impl/tables/check_constraints.cc
dd/impl/tables/collations.cc
dd/impl/tables/columns.cc
dd/impl/tables/column_statistics.cc
@@ -183,6 +185,7 @@ SET(DD_SOURCES
dd/impl/types/table_stat_impl.cc
dd/impl/types/abstract_table_impl.cc
dd/impl/types/charset_impl.cc
+ dd/impl/types/check_constraint_impl.cc
dd/impl/types/collation_impl.cc
dd/impl/types/column_impl.cc
dd/impl/types/column_statistics_impl.cc
@@ -440,6 +443,7 @@ SET(SQL_SHARED_SOURCES
sql_bootstrap.cc
sql_initialize.cc
sql_call.cc
+ sql_check_constraint.cc
sql_class.cc
sql_component.cc
sql_const_folding.cc
diff --git a/sql/create_field.cc b/sql/create_field.cc
index f43fcfbb99d3..fb9daa3b8b03 100644
--- a/sql/create_field.cc
+++ b/sql/create_field.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -279,11 +279,11 @@ bool Create_field::init(
*/
sql_type = fld_type = gcol_info->get_real_type();
if (pre_validate_value_generator_expr(gcol_info->expr_item, field_name,
- true))
+ VGS_GENERATED_COLUMN))
DBUG_RETURN(true);
} else {
if (pre_validate_value_generator_expr(m_default_val_expr->expr_item,
- field_name, false))
+ field_name, VGS_DEFAULT_EXPRESSION))
DBUG_RETURN(true);
}
}
diff --git a/sql/dd/cache/dictionary_client.h b/sql/dd/cache/dictionary_client.h
index 9a84acfeb990..d757c8d1c827 100644
--- a/sql/dd/cache/dictionary_client.h
+++ b/sql/dd/cache/dictionary_client.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -835,6 +835,23 @@ class Dictionary_client {
bool *exists)
MY_ATTRIBUTE((warn_unused_result));
+ /**
+ Check if schema contains check constraint with specified name.
+
+ @param schema Schema containing the check constraint.
+ @param check_cons_name Name of the check constraint.
+ @param [out] exists Set to true if check constraint with
+ the name provided exists in the
+ schema, false otherwise.
+
+ @retval false No error.
+ @retval true Error.
+ */
+
+ bool check_constraint_exists(const Schema &schema,
+ const String_type &check_cons_name,
+ bool *exists);
+
/**
Fetch the names of the components in the schema. Hidden components are
ignored. E.g., Object with dd::Table::hidden() == true will be ignored.
diff --git a/sql/dd/collection.cc b/sql/dd/collection.cc
index 37ddbfa69e5f..b7d105ed5855 100644
--- a/sql/dd/collection.cc
+++ b/sql/dd/collection.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -31,6 +31,7 @@
#include "sql/dd/impl/raw/raw_record_set.h" // dd::Raw_record_set
#include "sql/dd/impl/raw/raw_table.h" // dd::Raw_table
#include "sql/dd/impl/types/abstract_table_impl.h" // IWYU pragma: keep
+#include "sql/dd/impl/types/check_constraint_impl.h" // IWYU pragma: keep
#include "sql/dd/impl/types/column_impl.h" // IWYU pragma: keep
#include "sql/dd/impl/types/column_type_element_impl.h" // IWYU pragma: keep
#include "sql/dd/impl/types/foreign_key_element_impl.h" // IWYU pragma: keep
@@ -299,6 +300,8 @@ template dd::Partition_index *
template Tablespace_file *
&Collection::Collection_iterator::operator*();
template Trigger *&Collection::Collection_iterator::operator*();
+template Check_constraint *
+ &Collection::Collection_iterator::operator*();
template const Column *
&Collection::Collection_const_iterator::operator*();
@@ -330,6 +333,8 @@ template const View_table *
&Collection::Collection_const_iterator::operator*();
template const Trigger *
&Collection::Collection_const_iterator::operator*();
+template const Check_constraint *
+ &Collection::Collection_const_iterator::operator*();
template bool Collection::restore_items(
Abstract_table_impl *, Open_dictionary_tables_ctx *, Raw_table *,
@@ -390,6 +395,9 @@ template bool
Collection::restore_items(
Table_impl *, Open_dictionary_tables_ctx *, Raw_table *, Object_key *,
Trigger_order_comparator);
+template bool Collection::restore_items(
+ Table_impl *, Open_dictionary_tables_ctx *, Raw_table *, Object_key *,
+ Check_constraint_order_comparator);
template bool Collection::store_items(Open_dictionary_tables_ctx *);
template bool Collection::store_items(
@@ -418,6 +426,8 @@ template bool Collection::store_items(
template bool Collection::store_items(
Open_dictionary_tables_ctx *);
template bool Collection::store_items(Open_dictionary_tables_ctx *);
+template bool Collection::store_items(
+ Open_dictionary_tables_ctx *);
template bool Collection::drop_items(Open_dictionary_tables_ctx *,
Raw_table *, Object_key *) const;
@@ -453,6 +463,8 @@ template bool Collection::drop_items(Open_dictionary_tables_ctx *,
template bool Collection::drop_items(Open_dictionary_tables_ctx *,
Raw_table *,
Object_key *) const;
+template bool Collection::drop_items(
+ Open_dictionary_tables_ctx *, Raw_table *, Object_key *) const;
template void Collection::clear_all_items();
template void Collection::clear_all_items();
@@ -469,6 +481,7 @@ template void Collection::clear_all_items();
template void Collection::clear_all_items();
template void Collection::clear_all_items();
template void Collection::clear_all_items();
+template void Collection::clear_all_items();
template void Collection::clear_removed_items();
template void Collection::clear_removed_items();
@@ -484,6 +497,7 @@ template void Collection::clear_removed_items();
template void Collection::clear_removed_items();
template void Collection::clear_removed_items();
template void Collection::clear_removed_items();
+template void Collection::clear_removed_items();
template void Collection::remove(Column_impl *);
template void Collection::remove(
@@ -503,6 +517,7 @@ template void Collection::remove(Tablespace_file_impl *);
template void Collection::remove(View_routine_impl *);
template void Collection::remove(View_table_impl *);
template void Collection::remove(Trigger_impl *);
+template void Collection::remove(Check_constraint_impl *);
template Collection::iterator Collection::find(
const Column_impl *);
@@ -534,6 +549,8 @@ template Collection::iterator Collection::find(
const View_table_impl *);
template Collection::iterator Collection::find(
const Trigger_impl *);
+template Collection::iterator
+Collection::find(const Check_constraint_impl *);
template const Collection::abstract_type *Collection::at(
size_t n) const;
@@ -582,6 +599,8 @@ template void Collection::deep_copy(
Collection const &, View_impl *);
template void Collection::deep_copy(
Collection const &, Table_impl *);
+template void Collection::deep_copy(
+ Collection const &, Table_impl *);
/**
@endcond
diff --git a/sql/dd/dd_table.cc b/sql/dd/dd_table.cc
index 302c59f69f55..07fbd5c055fa 100644
--- a/sql/dd/dd_table.cc
+++ b/sql/dd/dd_table.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -56,6 +56,7 @@
#include "sql/dd/properties.h" // dd::Properties
#include "sql/dd/string_type.h"
#include "sql/dd/types/abstract_table.h"
+#include "sql/dd/types/check_constraint.h" // dd::Check_constraint
#include "sql/dd/types/column.h" // dd::Column
#include "sql/dd/types/column_type_element.h" // dd::Column_type_element
#include "sql/dd/types/foreign_key.h" // dd::Foreign_key
@@ -79,12 +80,14 @@
#include "sql/key_spec.h"
#include "sql/log.h"
#include "sql/mdl.h"
+#include "sql/mem_root_array.h"
#include "sql/my_decimal.h"
#include "sql/mysqld.h" // lower_case_table_names
#include "sql/partition_element.h"
-#include "sql/partition_info.h" // partition_info
-#include "sql/psi_memory_key.h" // key_memory_frm
-#include "sql/sql_class.h" // THD
+#include "sql/partition_info.h" // partition_info
+#include "sql/psi_memory_key.h" // key_memory_frm
+#include "sql/sql_check_constraint.h" // Sql_check_constraint_spec_list
+#include "sql/sql_class.h" // THD
#include "sql/sql_const.h"
#include "sql/sql_lex.h"
#include "sql/sql_list.h"
@@ -1744,6 +1747,46 @@ static bool fill_dd_partition_from_create_info(
return false;
}
+/**
+ Fill in check constraints metadata to the Table object from the list of
+ check constraint specifications.
+
+ @param[in] thd Thread handle.
+ @param[in,out] tab_obj Table object where to store the info.
+ @param[in] check_cons_spec Check constraints specification list.
+
+ @return false on success, else true.
+*/
+bool fill_dd_check_constraints(
+ THD *thd, dd::Table *tab_obj,
+ const Sql_check_constraint_spec_list *check_cons_spec) {
+ if (check_cons_spec == nullptr) return false;
+
+ for (auto &cc_spec : *check_cons_spec) {
+ Check_constraint *cc = tab_obj->add_check_constraint();
+
+ // Constraint name.
+ cc->set_name(cc_spec->name.str);
+
+ // Constraint clause.
+ char buffer[256];
+ String expr(buffer, sizeof(buffer), &my_charset_bin);
+ cc_spec->print_expr(thd, expr);
+ cc->set_check_clause(String_type(expr.c_ptr_safe()));
+
+ // Prepare UTF8 expressions for INFORMATION_SCHEMA tables.
+ String expr_for_IS;
+ convert_and_print(&expr, &expr_for_IS, system_charset_info);
+ cc->set_check_clause_utf8(
+ String_type(expr_for_IS.ptr(), expr_for_IS.length()));
+
+ // State. (enforced / not enforced)
+ cc->set_constraint_state(cc_spec->is_enforced);
+ }
+
+ return false;
+}
+
/**
Convert old row type value to corresponding value in new row format enum
used by DD framework.
@@ -1890,7 +1933,8 @@ static bool fill_dd_table_from_create_info(
const dd::String_type &schema_name, const HA_CREATE_INFO *create_info,
const List &create_fields, const KEY *keyinfo, uint keys,
Alter_info::enum_enable_or_disable keys_onoff,
- const FOREIGN_KEY *fk_keyinfo, uint fk_keys, handler *file) {
+ const FOREIGN_KEY *fk_keyinfo, uint fk_keys,
+ const Sql_check_constraint_spec_list *check_cons_spec, handler *file) {
// Table name must be set with the correct case depending on l_c_t_n
tab_obj->set_name(table_case_name(create_info, table_name.c_str()));
@@ -2089,6 +2133,9 @@ static bool fill_dd_table_from_create_info(
fill_dd_indexes_from_keyinfo(thd, tab_obj, keys, keyinfo, create_fields,
file);
+ // Add check constraints.
+ if (fill_dd_check_constraints(thd, tab_obj, check_cons_spec)) return true;
+
// Only add foreign key definitions for engines that support it.
if (ha_check_storage_engine_flag(create_info->db_type,
HTON_SUPPORTS_FOREIGN_KEYS)) {
@@ -2202,7 +2249,8 @@ static std::unique_ptr create_dd_system_table(
THD *thd, const dd::Schema &system_schema,
const dd::String_type &table_name, HA_CREATE_INFO *create_info,
const List &create_fields, const KEY *keyinfo, uint keys,
- const FOREIGN_KEY *fk_keyinfo, uint fk_keys, handler *file,
+ const FOREIGN_KEY *fk_keyinfo, uint fk_keys,
+ const Sql_check_constraint_spec_list *check_cons_spec, handler *file,
const dd::Object_table &dd_table) {
// Create dd::Table object.
std::unique_ptr tab_obj(system_schema.create_table(thd));
@@ -2215,7 +2263,7 @@ static std::unique_ptr create_dd_system_table(
if (fill_dd_table_from_create_info(
thd, tab_obj.get(), table_name, system_schema.name(), create_info,
create_fields, keyinfo, keys, Alter_info::ENABLE, fk_keyinfo, fk_keys,
- file))
+ check_cons_spec, file))
return nullptr;
/*
@@ -2255,7 +2303,8 @@ std::unique_ptr create_dd_user_table(
HA_CREATE_INFO *create_info, const List &create_fields,
const KEY *keyinfo, uint keys,
Alter_info::enum_enable_or_disable keys_onoff,
- const FOREIGN_KEY *fk_keyinfo, uint fk_keys, handler *file) {
+ const FOREIGN_KEY *fk_keyinfo, uint fk_keys,
+ const Sql_check_constraint_spec_list *check_cons_spec, handler *file) {
// Verify that this is not a dd table.
DBUG_ASSERT(
!dd::get_dictionary()->is_dd_table_name(sch_obj.name(), table_name));
@@ -2270,9 +2319,10 @@ std::unique_ptr create_dd_user_table(
if (is_server_ps_table_name(sch_obj.name(), table_name))
performance_schema::set_PS_version_for_table(&tab_obj->options());
- if (fill_dd_table_from_create_info(
- thd, tab_obj.get(), table_name, sch_obj.name(), create_info,
- create_fields, keyinfo, keys, keys_onoff, fk_keyinfo, fk_keys, file))
+ if (fill_dd_table_from_create_info(thd, tab_obj.get(), table_name,
+ sch_obj.name(), create_info, create_fields,
+ keyinfo, keys, keys_onoff, fk_keyinfo,
+ fk_keys, check_cons_spec, file))
return nullptr;
return tab_obj;
@@ -2283,24 +2333,27 @@ std::unique_ptr create_table(
HA_CREATE_INFO *create_info, const List &create_fields,
const KEY *keyinfo, uint keys,
Alter_info::enum_enable_or_disable keys_onoff,
- const FOREIGN_KEY *fk_keyinfo, uint fk_keys, handler *file) {
+ const FOREIGN_KEY *fk_keyinfo, uint fk_keys,
+ const Sql_check_constraint_spec_list *check_cons_spec, handler *file) {
dd::Dictionary *dict = dd::get_dictionary();
const dd::Object_table *dd_table =
dict->get_dd_table(sch_obj.name(), table_name);
- return dd_table ? create_dd_system_table(
- thd, sch_obj, table_name, create_info, create_fields,
- keyinfo, keys, fk_keyinfo, fk_keys, file, *dd_table)
- : create_dd_user_table(thd, sch_obj, table_name, create_info,
- create_fields, keyinfo, keys,
- keys_onoff, fk_keyinfo, fk_keys, file);
+ return dd_table
+ ? create_dd_system_table(thd, sch_obj, table_name, create_info,
+ create_fields, keyinfo, keys, fk_keyinfo,
+ fk_keys, check_cons_spec, file, *dd_table)
+ : create_dd_user_table(thd, sch_obj, table_name, create_info,
+ create_fields, keyinfo, keys, keys_onoff,
+ fk_keyinfo, fk_keys, check_cons_spec, file);
}
std::unique_ptr create_tmp_table(
THD *thd, const dd::Schema &sch_obj, const dd::String_type &table_name,
HA_CREATE_INFO *create_info, const List &create_fields,
const KEY *keyinfo, uint keys,
- Alter_info::enum_enable_or_disable keys_onoff, handler *file) {
+ Alter_info::enum_enable_or_disable keys_onoff,
+ const Sql_check_constraint_spec_list *check_cons_spec, handler *file) {
// Create dd::Table object.
std::unique_ptr tab_obj(sch_obj.create_table(thd));
@@ -2308,7 +2361,8 @@ std::unique_ptr create_tmp_table(
if (fill_dd_table_from_create_info(thd, tab_obj.get(), table_name,
sch_obj.name(), create_info, create_fields,
- keyinfo, keys, keys_onoff, NULL, 0, file))
+ keyinfo, keys, keys_onoff, NULL, 0,
+ check_cons_spec, file))
return nullptr;
return tab_obj;
@@ -2648,4 +2702,39 @@ bool has_primary_key(const Table &t) {
return ix->type() == Index::IT_PRIMARY && !ix->is_hidden();
});
}
+
+bool is_generated_check_constraint_name(const char *table_name,
+ size_t table_name_length,
+ const char *cc_name,
+ size_t cc_name_length) {
+ // We assume that the name is generated if it starts with _chk_
+ return ((cc_name_length >
+ table_name_length + sizeof(dd::CHECK_CONSTRAINT_NAME_SUBSTR) - 1) &&
+ (memcmp(cc_name, table_name, table_name_length) == 0) &&
+ (memcmp(cc_name + table_name_length, dd::CHECK_CONSTRAINT_NAME_SUBSTR,
+ sizeof(dd::CHECK_CONSTRAINT_NAME_SUBSTR) - 1) == 0));
+}
+
+bool rename_check_constraints(const char *old_table_name, dd::Table *new_tab) {
+ size_t old_table_name_length = strlen(old_table_name);
+ for (auto &cc : *new_tab->check_constraints()) {
+ if (is_generated_check_constraint_name(
+ old_table_name, old_table_name_length, cc->name().c_str(),
+ cc->name().length())) {
+ // Generate new name.
+ dd::String_type new_name(new_tab->name());
+ new_name.append(cc->name().substr(old_table_name_length));
+ if (check_string_char_length(to_lex_cstring(new_name.c_str()), "",
+ NAME_CHAR_LEN, system_charset_info, true)) {
+ my_error(ER_TOO_LONG_IDENT, MYF(0), new_name.c_str());
+ return true;
+ }
+ // Set new name.
+ cc->set_name(new_name);
+ }
+ }
+
+ return false;
+}
+
} // namespace dd
diff --git a/sql/dd/dd_table.h b/sql/dd/dd_table.h
index cba03ca01912..5f0ee83c8420 100644
--- a/sql/dd/dd_table.h
+++ b/sql/dd/dd_table.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -44,6 +44,10 @@ class Schema;
} // namespace dd
struct TABLE;
+class Sql_check_constraint_spec;
+using Sql_check_constraint_spec_list =
+ Mem_root_array;
+
struct HA_CREATE_INFO;
template
class List;
@@ -59,23 +63,26 @@ class Dictionary_client;
static const char FIELD_NAME_SEPARATOR_CHAR = ';';
static const char FOREIGN_KEY_NAME_SUBSTR[] = "_ibfk_";
+static const char CHECK_CONSTRAINT_NAME_SUBSTR[] = "_chk_";
/**
Prepares a dd::Table object from mysql_prepare_create_table() output
and return it to the caller. This function creates a user table, as
opposed to create_table() which can handle system tables as well.
- @param thd Thread handle
- @param sch_obj Schema.
- @param table_name Table name.
- @param create_info HA_CREATE_INFO describing the table to be created.
- @param create_fields List of fields for the table.
- @param keyinfo Array with descriptions of keys for the table.
- @param keys Number of keys.
- @param keys_onoff keys ON or OFF
- @param fk_keyinfo Array with descriptions of foreign keys for the table.
- @param fk_keys Number of foreign keys.
- @param file handler instance for the table.
+ @param thd Thread handle
+ @param sch_obj Schema.
+ @param table_name Table name.
+ @param create_info HA_CREATE_INFO describing the table to be created.
+ @param create_fields List of fields for the table.
+ @param keyinfo Array with descriptions of keys for the table.
+ @param keys Number of keys.
+ @param keys_onoff keys ON or OFF
+ @param fk_keyinfo Array with descriptions of foreign keys for the
+ table.
+ @param fk_keys Number of foreign keys.
+ @param check_cons_spec Specification of check constraints for the table.
+ @param file handler instance for the table.
@returns Constructed dd::Table object, or nullptr in case of an error.
*/
@@ -84,7 +91,8 @@ std::unique_ptr create_dd_user_table(
HA_CREATE_INFO *create_info, const List &create_fields,
const KEY *keyinfo, uint keys,
Alter_info::enum_enable_or_disable keys_onoff,
- const FOREIGN_KEY *fk_keyinfo, uint fk_keys, handler *file);
+ const FOREIGN_KEY *fk_keyinfo, uint fk_keys,
+ const Sql_check_constraint_spec_list *check_cons_spec, handler *file);
/**
Prepares a dd::Table object from mysql_prepare_create_table() output
@@ -101,6 +109,7 @@ std::unique_ptr create_dd_user_table(
@param fk_keyinfo Array with descriptions of foreign keys for the
table.
@param fk_keys Number of foreign keys.
+ @param check_cons_spec Specification of check constraints for the table.
@param file handler instance for the table.
@returns Constructed dd::Table object, or nullptr in case of an error.
@@ -110,22 +119,24 @@ std::unique_ptr create_table(
HA_CREATE_INFO *create_info, const List &create_fields,
const KEY *keyinfo, uint keys,
Alter_info::enum_enable_or_disable keys_onoff,
- const FOREIGN_KEY *fk_keyinfo, uint fk_keys, handler *file);
+ const FOREIGN_KEY *fk_keyinfo, uint fk_keys,
+ const Sql_check_constraint_spec_list *check_cons_spec, handler *file);
/**
Prepares a dd::Table object for a temporary table from
mysql_prepare_create_table() output. Doesn't update DD tables,
instead returns dd::Table object to caller.
- @param thd Thread handle.
- @param sch_obj Schema.
- @param table_name Table name.
- @param create_info HA_CREATE_INFO describing the table to be created.
- @param create_fields List of fields for the table.
- @param keyinfo Array with descriptions of keys for the table.
- @param keys Number of keys.
- @param keys_onoff Enable or disable keys.
- @param file handler instance for the table.
+ @param thd Thread handle.
+ @param sch_obj Schema.
+ @param table_name Table name.
+ @param create_info HA_CREATE_INFO describing the table to be created.
+ @param create_fields List of fields for the table.
+ @param keyinfo Array with descriptions of keys for the table.
+ @param keys Number of keys.
+ @param keys_onoff Enable or disable keys.
+ @param check_cons_spec Specification of check constraints for the table.
+ @param file handler instance for the table.
@returns Constructed dd::Table object, or nullptr in case of an error.
*/
@@ -133,7 +144,8 @@ std::unique_ptr create_tmp_table(
THD *thd, const dd::Schema &sch_obj, const dd::String_type &table_name,
HA_CREATE_INFO *create_info, const List &create_fields,
const KEY *keyinfo, uint keys,
- Alter_info::enum_enable_or_disable keys_onoff, handler *file);
+ Alter_info::enum_enable_or_disable keys_onoff,
+ const Sql_check_constraint_spec_list *check_cons_spec, handler *file);
//////////////////////////////////////////////////////////////////////////
// Function common to 'table' and 'view' objects
@@ -404,5 +416,31 @@ Encrypt_result is_tablespace_encrypted(THD *thd, const dd::Table &t);
*/
bool has_primary_key(const Table &t);
+/**
+ Check if name of check constraint is generated one.
+
+ @param table_name Table name.
+ @param table_name_length Table name length.
+ @param cc_name Check constraint name.
+ @param cc_name_length Check constraint name length.
+
+ @retval true If check constraint name is generated one.
+ @retval false Otherwise.
+*/
+bool is_generated_check_constraint_name(const char *table_name,
+ size_t table_name_length,
+ const char *cc_name,
+ size_t cc_name_length);
+
+/**
+ Rename generated check constraint names to match the new name of the table.
+
+ @param old_table_name Table name before rename.
+ @param new_tab New version of the table with new name set.
+
+ @returns true if error, false otherwise.
+*/
+bool rename_check_constraints(const char *old_table_name, dd::Table *new_tab);
+
} // namespace dd
#endif // DD_TABLE_INCLUDED
diff --git a/sql/dd/dd_version.h b/sql/dd/dd_version.h
index 688df9a37b4b..c02c25a396a8 100644
--- a/sql/dd/dd_version.h
+++ b/sql/dd/dd_version.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -137,18 +137,25 @@
- Bug#24741307: add last_checked_for_upgrade column to msyql.tables table
- 80014: Current
+ 80014: Published in 8.0.14
----------------------------------------------------------------------------
Changes from version 80013:
- Bug#28492272: Synchronize sql_mode in server with that in DD.
- 80015: Next DD version number after the previous is public.
+ 80015: Current
----------------------------------------------------------------------------
Changes from version 80014:
- - No changes, this version number is not active yet.
+ - WL#929 - CHECK CONSTRAINTS
+ New DD table check_constraints is introduced for the check
+ constraints metadata.
+
+
+ 80016: Next DD version number after the previous is public.
+ ----------------------------------------------------------------------------
+ Changes from version 80015:
If a new DD version is published in a MRU, that version may or may not
@@ -160,9 +167,9 @@
*/
namespace dd {
-static const uint DD_VERSION = 80014;
+static const uint DD_VERSION = 80015;
-static const uint DD_VERSION_MINOR_DOWNGRADE_THRESHOLD = 80014;
+static const uint DD_VERSION_MINOR_DOWNGRADE_THRESHOLD = 80015;
} // namespace dd
diff --git a/sql/dd/impl/bootstrap_ctx.h b/sql/dd/impl/bootstrap_ctx.h
index c877d6ad22d3..d6b41bbf9348 100644
--- a/sql/dd/impl/bootstrap_ctx.h
+++ b/sql/dd/impl/bootstrap_ctx.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -55,6 +55,7 @@ static constexpr uint DD_VERSION_80011 = 80011;
static constexpr uint DD_VERSION_80012 = 80012;
static constexpr uint DD_VERSION_80013 = 80013;
static constexpr uint DD_VERSION_80014 = 80014;
+static constexpr uint DD_VERSION_80015 = 80015;
/*
Set of supported DD version labels. A supported DD version is a version
@@ -65,7 +66,8 @@ static constexpr uint DD_VERSION_80014 = 80014;
stored in the 'dd_properties' table by the server from which we downgrade.
*/
static std::set supported_dd_versions = {
- DD_VERSION_80011, DD_VERSION_80012, DD_VERSION_80013, DD_VERSION_80014};
+ DD_VERSION_80011, DD_VERSION_80012, DD_VERSION_80013, DD_VERSION_80014,
+ DD_VERSION_80015};
// Individual server version labels that we can refer to.
static constexpr uint SERVER_VERSION_80011 = 80011;
diff --git a/sql/dd/impl/bootstrapper.cc b/sql/dd/impl/bootstrapper.cc
index 74e68671dca7..e9ca97bc5423 100644
--- a/sql/dd/impl/bootstrapper.cc
+++ b/sql/dd/impl/bootstrapper.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -1103,8 +1103,14 @@ bool sync_meta_data(THD *thd) {
it != System_tables::instance()->end() &&
persisted_it != persisted_dd_tables.end();
++it, ++persisted_it) {
+ /*
+ If we are in the process of upgrading, there may not be an entry
+ in the persisted_dd_tables for new tables that have been added after
+ the version we are upgrading from.
+ */
+ if ((*persisted_it) == nullptr) continue;
+
if ((*it)->property() == System_tables::Types::CORE) {
- DBUG_ASSERT((*it)->entity()->name() == (*persisted_it)->name());
dd::cache::Storage_adapter::instance()->core_store(
thd, static_cast((*persisted_it).get()));
}
diff --git a/sql/dd/impl/cache/dictionary_client.cc b/sql/dd/impl/cache/dictionary_client.cc
index 2b6bed150935..202b46bbcfbb 100644
--- a/sql/dd/impl/cache/dictionary_client.cc
+++ b/sql/dd/impl/cache/dictionary_client.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -48,6 +48,7 @@
#include "sql/dd/impl/raw/raw_table.h" // Raw_table
#include "sql/dd/impl/sdi.h" // dd::sdi::drop_after_update
#include "sql/dd/impl/tables/character_sets.h" // create_name_key()
+#include "sql/dd/impl/tables/check_constraints.h" // check_constraint_exists
#include "sql/dd/impl/tables/collations.h" // create_name_key()
#include "sql/dd/impl/tables/column_statistics.h" // create_name_key()
#include "sql/dd/impl/tables/events.h" // create_name_key()
@@ -1868,6 +1869,31 @@ bool Dictionary_client::check_foreign_key_exists(
return false;
}
+bool Dictionary_client::check_constraint_exists(
+ const Schema &schema, const String_type &check_cons_name, bool *exists) {
+#ifndef DBUG_OFF
+ char schema_name_buf[NAME_LEN + 1];
+ char check_cons_name_buff[NAME_LEN + 1];
+ my_stpcpy(check_cons_name_buff, check_cons_name.c_str());
+ my_casedn_str(system_charset_info, check_cons_name_buff);
+
+ DBUG_ASSERT(m_thd->mdl_context.owns_equal_or_stronger_lock(
+ MDL_key::CHECK_CONSTRAINT,
+ dd::Object_table_definition_impl::fs_name_case(schema.name(),
+ schema_name_buf),
+ check_cons_name_buff, MDL_EXCLUSIVE));
+#endif
+
+ // Get info directly from the tables.
+ if (tables::Check_constraints::check_constraint_exists(
+ m_thd, schema.id(), check_cons_name, exists)) {
+ DBUG_ASSERT(m_thd->is_error() || m_thd->killed);
+ return true;
+ }
+
+ return false;
+}
+
template
bool fetch_raw_record(THD *thd,
std::function const &processor) {
diff --git a/sql/dd/impl/system_registry.cc b/sql/dd/impl/system_registry.cc
index 51be063b0365..16ee9aa635bf 100644
--- a/sql/dd/impl/system_registry.cc
+++ b/sql/dd/impl/system_registry.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -22,7 +22,8 @@
#include "sql/dd/impl/system_registry.h"
-#include "sql/dd/impl/system_views/character_sets.h" // Character_sets
+#include "sql/dd/impl/system_views/character_sets.h" // Character_sets
+#include "sql/dd/impl/system_views/check_constraints.h" // Check_constraints
#include "sql/dd/impl/system_views/collation_charset_applicability.h" // Collati...
#include "sql/dd/impl/system_views/collations.h" // Collations
#include "sql/dd/impl/system_views/column_statistics.h" // Column_statistics
@@ -55,6 +56,7 @@
#include "sql/dd/impl/tables/catalogs.h" // Catalog
#include "sql/dd/impl/tables/character_sets.h" // Character_sets
+#include "sql/dd/impl/tables/check_constraints.h" // Check_constraints
#include "sql/dd/impl/tables/collations.h" // Collations
#include "sql/dd/impl/tables/column_statistics.h" // Column_statistics
#include "sql/dd/impl/tables/column_type_elements.h" // Column_type_elements
@@ -154,6 +156,7 @@ void System_tables::add_remaining_dd_tables() {
register_table(core);
register_table(core);
+ register_table(core);
register_table(core);
register_table(core);
register_table(core);
@@ -233,6 +236,7 @@ void System_views::init() {
dd::System_views::Types is = dd::System_views::Types::INFORMATION_SCHEMA;
register_view(is);
+ register_view(is);
register_view(is);
register_view(is);
register_view(is);
diff --git a/sql/dd/impl/system_views/check_constraints.cc b/sql/dd/impl/system_views/check_constraints.cc
new file mode 100644
index 000000000000..0076ad7b273f
--- /dev/null
+++ b/sql/dd/impl/system_views/check_constraints.cc
@@ -0,0 +1,54 @@
+/* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License, version 2.0,
+ as published by the Free Software Foundation.
+
+ This program is also distributed with certain software (including
+ but not limited to OpenSSL) that is licensed under separate terms,
+ as designated in a particular file or component or in included license
+ documentation. The authors of MySQL hereby grant you an additional
+ permission to link the program and your derivative works with the
+ separately licensed software that they have included with MySQL.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License, version 2.0, for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+
+#include "sql/dd/impl/system_views/check_constraints.h"
+
+namespace dd {
+namespace system_views {
+
+const Check_constraints &Check_constraints::instance() {
+ static Check_constraints *s_instance = new Check_constraints();
+ return *s_instance;
+}
+
+Check_constraints::Check_constraints() {
+ m_target_def.set_view_name(view_name());
+
+ m_target_def.add_field(FIELD_CONSTRAINT_CATALOG, "CONSTRAINT_CATALOG",
+ "cat.name" + m_target_def.fs_name_collation());
+ m_target_def.add_field(FIELD_CONSTRAINT_SCHEMA, "CONSTRAINT_SCHEMA",
+ "sch.name" + m_target_def.fs_name_collation());
+ m_target_def.add_field(FIELD_CONSTRAINT_NAME, "CONSTRAINT_NAME", "cc.name");
+ m_target_def.add_field(FIELD_CHECK_CLAUSE, "CHECK_CLAUSE",
+ "cc.check_clause_utf8");
+
+ m_target_def.add_from("mysql.check_constraints cc");
+ m_target_def.add_from("JOIN mysql.tables tbl ON cc.table_id=tbl.id");
+ m_target_def.add_from("JOIN mysql.schemata sch ON tbl.schema_id=sch.id");
+ m_target_def.add_from("JOIN mysql.catalogs cat ON cat.id=sch.catalog_id");
+
+ m_target_def.add_where("CAN_ACCESS_TABLE(sch.name, tbl.name)");
+ m_target_def.add_where("AND IS_VISIBLE_DD_OBJECT(tbl.hidden)");
+}
+
+} // namespace system_views
+} // namespace dd
diff --git a/sql/dd/impl/system_views/check_constraints.h b/sql/dd/impl/system_views/check_constraints.h
new file mode 100644
index 000000000000..fab6a3f479f9
--- /dev/null
+++ b/sql/dd/impl/system_views/check_constraints.h
@@ -0,0 +1,65 @@
+/* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License, version 2.0,
+ as published by the Free Software Foundation.
+
+ This program is also distributed with certain software (including
+ but not limited to OpenSSL) that is licensed under separate terms,
+ as designated in a particular file or component or in included license
+ documentation. The authors of MySQL hereby grant you an additional
+ permission to link the program and your derivative works with the
+ separately licensed software that they have included with MySQL.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License, version 2.0, for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+
+#ifndef DD_SYSTEM_VIEWS__CHECK_CONSTRAINTS_INCLUDED
+#define DD_SYSTEM_VIEWS__CHECK_CONSTRAINTS_INCLUDED
+
+#include "sql/dd/impl/system_views/system_view_definition_impl.h"
+#include "sql/dd/impl/system_views/system_view_impl.h"
+#include "sql/dd/string_type.h"
+
+namespace dd {
+namespace system_views {
+
+/*
+ The class representing INFORMATION_SCHEMA.CHECK_CONSTRAINTS system view
+ definition.
+*/
+
+class Check_constraints
+ : public System_view_impl {
+ public:
+ enum enum_fields {
+ FIELD_CONSTRAINT_CATALOG,
+ FIELD_CONSTRAINT_SCHEMA,
+ FIELD_CONSTRAINT_NAME,
+ FIELD_CHECK_CLAUSE
+ };
+
+ Check_constraints();
+
+ static const Check_constraints &instance();
+
+ static const String_type &view_name() {
+ static String_type s_view_name("CHECK_CONSTRAINTS");
+ return s_view_name;
+ }
+
+ virtual const String_type &name() const {
+ return Check_constraints::view_name();
+ }
+};
+
+} // namespace system_views
+} // namespace dd
+
+#endif // DD_SYSTEM_VIEWS__CHECK_CONSTRAINTS_INCLUDED
diff --git a/sql/dd/impl/system_views/key_column_usage.cc b/sql/dd/impl/system_views/key_column_usage.cc
index 46a64a813474..f4cc86af238e 100644
--- a/sql/dd/impl/system_views/key_column_usage.cc
+++ b/sql/dd/impl/system_views/key_column_usage.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -37,93 +37,91 @@ const Key_column_usage &Key_column_usage::instance() {
Key_column_usage::Key_column_usage() {
m_target_def.set_view_name(view_name());
- System_view_select_definition_impl *first_select, *second_select;
- first_select = m_target_def.get_first_select();
- second_select = m_target_def.get_second_select();
-
// First SELECT for UNION
-
- first_select->add_field(FIELD_CONSTRAINT_CATALOG, "CONSTRAINT_CATALOG",
- "cat.name" + m_target_def.fs_name_collation());
- first_select->add_field(FIELD_CONSTRAINT_SCHEMA, "CONSTRAINT_SCHEMA",
- "sch.name" + m_target_def.fs_name_collation());
- first_select->add_field(FIELD_CONSTRAINT_NAME, "CONSTRAINT_NAME", "idx.name");
- first_select->add_field(FIELD_TABLE_CATALOG, "TABLE_CATALOG",
- "cat.name" + m_target_def.fs_name_collation());
- first_select->add_field(FIELD_TABLE_SCHEMA, "TABLE_SCHEMA",
- "sch.name" + m_target_def.fs_name_collation());
- first_select->add_field(FIELD_TABLE_NAME, "TABLE_NAME",
- "tbl.name" + m_target_def.fs_name_collation());
- first_select->add_field(FIELD_COLUMN_NAME, "COLUMN_NAME",
- "col.name COLLATE utf8_tolower_ci");
- first_select->add_field(FIELD_ORDINAL_POSITION, "ORDINAL_POSITION",
- "icu.ordinal_position");
- first_select->add_field(FIELD_POSITION_IN_UNIQUE_CONSTRAINT,
- "POSITION_IN_UNIQUE_CONSTRAINT", "NULL");
- first_select->add_field(FIELD_REFERENCED_TABLE_SCHEMA,
- "REFERENCED_TABLE_SCHEMA", "NULL");
- first_select->add_field(FIELD_REFERENCED_TABLE_NAME, "REFERENCED_TABLE_NAME",
- "NULL");
- first_select->add_field(FIELD_REFERENCED_COLUMN_NAME,
- "REFERENCED_COLUMN_NAME", "NULL");
-
- first_select->add_from("mysql.indexes idx");
- first_select->add_from("JOIN mysql.tables tbl ON idx.table_id=tbl.id");
- first_select->add_from("JOIN mysql.schemata sch ON tbl.schema_id=sch.id");
- first_select->add_from("JOIN mysql.catalogs cat ON cat.id=sch.catalog_id");
- first_select->add_from(
+ System_view_select_definition_impl &first_select = m_target_def.get_select();
+
+ first_select.add_field(FIELD_CONSTRAINT_CATALOG, "CONSTRAINT_CATALOG",
+ "cat.name" + m_target_def.fs_name_collation());
+ first_select.add_field(FIELD_CONSTRAINT_SCHEMA, "CONSTRAINT_SCHEMA",
+ "sch.name" + m_target_def.fs_name_collation());
+ first_select.add_field(FIELD_CONSTRAINT_NAME, "CONSTRAINT_NAME", "idx.name");
+ first_select.add_field(FIELD_TABLE_CATALOG, "TABLE_CATALOG",
+ "cat.name" + m_target_def.fs_name_collation());
+ first_select.add_field(FIELD_TABLE_SCHEMA, "TABLE_SCHEMA",
+ "sch.name" + m_target_def.fs_name_collation());
+ first_select.add_field(FIELD_TABLE_NAME, "TABLE_NAME",
+ "tbl.name" + m_target_def.fs_name_collation());
+ first_select.add_field(FIELD_COLUMN_NAME, "COLUMN_NAME",
+ "col.name COLLATE utf8_tolower_ci");
+ first_select.add_field(FIELD_ORDINAL_POSITION, "ORDINAL_POSITION",
+ "icu.ordinal_position");
+ first_select.add_field(FIELD_POSITION_IN_UNIQUE_CONSTRAINT,
+ "POSITION_IN_UNIQUE_CONSTRAINT", "NULL");
+ first_select.add_field(FIELD_REFERENCED_TABLE_SCHEMA,
+ "REFERENCED_TABLE_SCHEMA", "NULL");
+ first_select.add_field(FIELD_REFERENCED_TABLE_NAME, "REFERENCED_TABLE_NAME",
+ "NULL");
+ first_select.add_field(FIELD_REFERENCED_COLUMN_NAME, "REFERENCED_COLUMN_NAME",
+ "NULL");
+
+ first_select.add_from("mysql.indexes idx");
+ first_select.add_from("JOIN mysql.tables tbl ON idx.table_id=tbl.id");
+ first_select.add_from("JOIN mysql.schemata sch ON tbl.schema_id=sch.id");
+ first_select.add_from("JOIN mysql.catalogs cat ON cat.id=sch.catalog_id");
+ first_select.add_from(
"JOIN mysql.index_column_usage icu"
" ON icu.index_id=idx.id");
- first_select->add_from(
+ first_select.add_from(
"JOIN mysql.columns col ON icu.column_id=col.id"
" AND idx.type IN ('PRIMARY', 'UNIQUE')");
- first_select->add_where("CAN_ACCESS_COLUMN(sch.name, tbl.name, col.name)");
- first_select->add_where(
+ first_select.add_where("CAN_ACCESS_COLUMN(sch.name, tbl.name, col.name)");
+ first_select.add_where(
"AND IS_VISIBLE_DD_OBJECT(tbl.hidden, "
"col.hidden <> 'Visible' OR idx.hidden OR icu.hidden)");
// Second SELECT for UNION
+ System_view_select_definition_impl &second_select = m_target_def.get_select();
- second_select->add_field(FIELD_CONSTRAINT_CATALOG, "CONSTRAINT_CATALOG",
- "cat.name" + m_target_def.fs_name_collation());
- second_select->add_field(FIELD_CONSTRAINT_SCHEMA, "CONSTRAINT_SCHEMA",
- "sch.name" + m_target_def.fs_name_collation());
- second_select->add_field(FIELD_CONSTRAINT_NAME, "CONSTRAINT_NAME",
- "fk.name COLLATE utf8_tolower_ci");
- second_select->add_field(FIELD_TABLE_CATALOG, "TABLE_CATALOG",
- "cat.name" + m_target_def.fs_name_collation());
- second_select->add_field(FIELD_TABLE_SCHEMA, "TABLE_SCHEMA",
- "sch.name" + m_target_def.fs_name_collation());
- second_select->add_field(FIELD_TABLE_NAME, "TABLE_NAME",
- "tbl.name" + m_target_def.fs_name_collation());
- second_select->add_field(FIELD_COLUMN_NAME, "COLUMN_NAME",
- "col.name COLLATE utf8_tolower_ci");
- second_select->add_field(FIELD_ORDINAL_POSITION, "ORDINAL_POSITION",
- "fkcu.ordinal_position");
- second_select->add_field(FIELD_POSITION_IN_UNIQUE_CONSTRAINT,
- "POSITION_IN_UNIQUE_CONSTRAINT",
- "fkcu.ordinal_position");
- second_select->add_field(FIELD_REFERENCED_TABLE_SCHEMA,
- "REFERENCED_TABLE_SCHEMA",
- "fk.referenced_table_schema");
- second_select->add_field(FIELD_REFERENCED_TABLE_NAME, "REFERENCED_TABLE_NAME",
- "fk.referenced_table_name");
- second_select->add_field(FIELD_REFERENCED_COLUMN_NAME,
- "REFERENCED_COLUMN_NAME",
- "fkcu.referenced_column_name");
-
- second_select->add_from("mysql.foreign_keys fk");
- second_select->add_from("JOIN mysql.tables tbl ON fk.table_id=tbl.id");
- second_select->add_from(
+ second_select.add_field(FIELD_CONSTRAINT_CATALOG, "CONSTRAINT_CATALOG",
+ "cat.name" + m_target_def.fs_name_collation());
+ second_select.add_field(FIELD_CONSTRAINT_SCHEMA, "CONSTRAINT_SCHEMA",
+ "sch.name" + m_target_def.fs_name_collation());
+ second_select.add_field(FIELD_CONSTRAINT_NAME, "CONSTRAINT_NAME",
+ "fk.name COLLATE utf8_tolower_ci");
+ second_select.add_field(FIELD_TABLE_CATALOG, "TABLE_CATALOG",
+ "cat.name" + m_target_def.fs_name_collation());
+ second_select.add_field(FIELD_TABLE_SCHEMA, "TABLE_SCHEMA",
+ "sch.name" + m_target_def.fs_name_collation());
+ second_select.add_field(FIELD_TABLE_NAME, "TABLE_NAME",
+ "tbl.name" + m_target_def.fs_name_collation());
+ second_select.add_field(FIELD_COLUMN_NAME, "COLUMN_NAME",
+ "col.name COLLATE utf8_tolower_ci");
+ second_select.add_field(FIELD_ORDINAL_POSITION, "ORDINAL_POSITION",
+ "fkcu.ordinal_position");
+ second_select.add_field(FIELD_POSITION_IN_UNIQUE_CONSTRAINT,
+ "POSITION_IN_UNIQUE_CONSTRAINT",
+ "fkcu.ordinal_position");
+ second_select.add_field(FIELD_REFERENCED_TABLE_SCHEMA,
+ "REFERENCED_TABLE_SCHEMA",
+ "fk.referenced_table_schema");
+ second_select.add_field(FIELD_REFERENCED_TABLE_NAME, "REFERENCED_TABLE_NAME",
+ "fk.referenced_table_name");
+ second_select.add_field(FIELD_REFERENCED_COLUMN_NAME,
+ "REFERENCED_COLUMN_NAME",
+ "fkcu.referenced_column_name");
+
+ second_select.add_from("mysql.foreign_keys fk");
+ second_select.add_from("JOIN mysql.tables tbl ON fk.table_id=tbl.id");
+ second_select.add_from(
"JOIN mysql.foreign_key_column_usage fkcu"
" ON fkcu.foreign_key_id=fk.id");
- second_select->add_from("JOIN mysql.schemata sch ON fk.schema_id=sch.id");
- second_select->add_from("JOIN mysql.catalogs cat ON cat.id=sch.catalog_id");
- second_select->add_from("JOIN mysql.columns col ON fkcu.column_id=col.id");
+ second_select.add_from("JOIN mysql.schemata sch ON fk.schema_id=sch.id");
+ second_select.add_from("JOIN mysql.catalogs cat ON cat.id=sch.catalog_id");
+ second_select.add_from("JOIN mysql.columns col ON fkcu.column_id=col.id");
- second_select->add_where("CAN_ACCESS_COLUMN(sch.name, tbl.name, col.name)");
- second_select->add_where(
+ second_select.add_where("CAN_ACCESS_COLUMN(sch.name, tbl.name, col.name)");
+ second_select.add_where(
"AND IS_VISIBLE_DD_OBJECT(tbl.hidden, col.hidden <> 'Visible')");
}
diff --git a/sql/dd/impl/system_views/system_view_definition_impl.h b/sql/dd/impl/system_views/system_view_definition_impl.h
index 65e489613861..f931736f8b71 100644
--- a/sql/dd/impl/system_views/system_view_definition_impl.h
+++ b/sql/dd/impl/system_views/system_view_definition_impl.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -24,6 +24,7 @@
#define DD_SYSTEM_VIEWS__SYSTEM_VIEW_DEFINITION_IMPL_INCLUDED
#include