Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Backport INFORMATION_SCHEMA.CHECK_CONSTRAINTS
Implement according to standard SQL specification 2008. The check_constraints table is used for fetching metadata about the constraints defined for tables in all databases. There were some result files which failed after running mtr. These files are updated with newly create record with mtr --record.
- Loading branch information
Showing
10 changed files
with
379 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| # | ||
| # MDEV-17323: Backport INFORMATION_SCHEMA.CHECK_CONSTRAINTS to 10.2 | ||
| # | ||
| CREATE user boo1; | ||
| GRANT select,create,alter,drop on foo.* to boo1; | ||
| SHOW GRANTS for boo1; | ||
| Grants for boo1@% | ||
| GRANT USAGE ON *.* TO 'boo1'@'%' | ||
| GRANT SELECT, CREATE, DROP, ALTER ON `foo`.* TO 'boo1'@'%' | ||
| CREATE user boo2; | ||
| create database foo; | ||
| CONNECT con1,localhost, boo1,, foo; | ||
| SET check_constraint_checks=1; | ||
| CREATE TABLE t0 | ||
| ( | ||
| t int, check (t>32) # table constraint | ||
| ) ENGINE=myisam; | ||
| SELECT * from information_schema.check_constraints; | ||
| CONSTRAINT_CATALOG CONSTRAINT_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE | ||
| def foo t0 CONSTRAINT_1 `t` > 32 | ||
| ALTER TABLE t0 | ||
| ADD CONSTRAINT CHK_t0_t CHECK(t<100); | ||
| SELECT * from information_schema.check_constraints; | ||
| CONSTRAINT_CATALOG CONSTRAINT_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE | ||
| def foo t0 CHK_t0_t `t` < 100 | ||
| def foo t0 CONSTRAINT_1 `t` > 32 | ||
| ALTER TABLE t0 | ||
| DROP CONSTRAINT CHK_t0_t; | ||
| SELECT * from information_schema.check_constraints; | ||
| CONSTRAINT_CATALOG CONSTRAINT_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE | ||
| def foo t0 CONSTRAINT_1 `t` > 32 | ||
| ALTER TABLE t0 | ||
| ADD CONSTRAINT CHECK(t<50); | ||
| SELECT * from information_schema.check_constraints; | ||
| CONSTRAINT_CATALOG CONSTRAINT_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE | ||
| def foo t0 CONSTRAINT_1 `t` > 32 | ||
| def foo t0 CONSTRAINT_2 `t` < 50 | ||
| CREATE TABLE t1 | ||
| ( t int CHECK(t>2), # field constraint | ||
| tt int, | ||
| CONSTRAINT CHECK (tt > 32), CONSTRAINT CHECK (tt <50),# autogenerated names table constraints | ||
| CONSTRAINT CHK_tt CHECK(tt<100) # named table constraint | ||
| ) ENGINE=InnoDB; | ||
| SELECT * from information_schema.check_constraints; | ||
| CONSTRAINT_CATALOG CONSTRAINT_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE | ||
| def foo t0 CONSTRAINT_1 `t` > 32 | ||
| def foo t0 CONSTRAINT_2 `t` < 50 | ||
| def foo t1 CHK_tt `tt` < 100 | ||
| def foo t1 CONSTRAINT_1 `tt` > 32 | ||
| def foo t1 CONSTRAINT_2 `tt` < 50 | ||
| def foo t1 t `t` > 2 | ||
| ALTER TABLE t1 | ||
| DROP CONSTRAINT CHK_tt; | ||
| SELECT * from information_schema.check_constraints; | ||
| CONSTRAINT_CATALOG CONSTRAINT_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE | ||
| def foo t0 CONSTRAINT_1 `t` > 32 | ||
| def foo t0 CONSTRAINT_2 `t` < 50 | ||
| def foo t1 CONSTRAINT_1 `tt` > 32 | ||
| def foo t1 CONSTRAINT_2 `tt` < 50 | ||
| def foo t1 t `t` > 2 | ||
| CREATE TABLE t2 | ||
| ( | ||
| name VARCHAR(30) CHECK(CHAR_LENGTH(name)>2), #field constraint | ||
| start_date DATE, | ||
| end_date DATE, | ||
| CONSTRAINT CHK_dates CHECK(start_date IS NULL) #table constraint | ||
| )ENGINE=Innodb; | ||
| SELECT * from information_schema.check_constraints; | ||
| CONSTRAINT_CATALOG CONSTRAINT_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE | ||
| def foo t0 CONSTRAINT_1 `t` > 32 | ||
| def foo t0 CONSTRAINT_2 `t` < 50 | ||
| def foo t1 CONSTRAINT_1 `tt` > 32 | ||
| def foo t1 CONSTRAINT_2 `tt` < 50 | ||
| def foo t1 t `t` > 2 | ||
| def foo t2 CHK_dates `start_date` is null | ||
| def foo t2 name char_length(`name`) > 2 | ||
| ALTER TABLE t1 | ||
| ADD CONSTRAINT CHK_new_ CHECK(t>tt); | ||
| SELECT * from information_schema.check_constraints; | ||
| CONSTRAINT_CATALOG CONSTRAINT_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE | ||
| def foo t0 CONSTRAINT_1 `t` > 32 | ||
| def foo t0 CONSTRAINT_2 `t` < 50 | ||
| def foo t1 CHK_new_ `t` > `tt` | ||
| def foo t1 CONSTRAINT_1 `tt` > 32 | ||
| def foo t1 CONSTRAINT_2 `tt` < 50 | ||
| def foo t1 t `t` > 2 | ||
| def foo t2 CHK_dates `start_date` is null | ||
| def foo t2 name char_length(`name`) > 2 | ||
| CREATE TABLE t3 | ||
| ( | ||
| a int, | ||
| b int check (b>0), # field constraint named 'b' | ||
| CONSTRAINT b check (b>10) # table constraint | ||
| ) ENGINE=InnoDB; | ||
| SELECT * from information_schema.check_constraints; | ||
| CONSTRAINT_CATALOG CONSTRAINT_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE | ||
| def foo t0 CONSTRAINT_1 `t` > 32 | ||
| def foo t0 CONSTRAINT_2 `t` < 50 | ||
| def foo t1 CHK_new_ `t` > `tt` | ||
| def foo t1 CONSTRAINT_1 `tt` > 32 | ||
| def foo t1 CONSTRAINT_2 `tt` < 50 | ||
| def foo t1 t `t` > 2 | ||
| def foo t2 CHK_dates `start_date` is null | ||
| def foo t2 name char_length(`name`) > 2 | ||
| def foo t3 b `b` > 0 | ||
| def foo t3 b `b` > 10 | ||
| disconnect con1; | ||
| CONNECT con2, localhost, boo2,, test; | ||
| SELECT * from information_schema.check_constraints; | ||
| CONSTRAINT_CATALOG CONSTRAINT_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE | ||
| disconnect con2; | ||
| CONNECT con1, localhost, boo1,,foo; | ||
| DROP TABLE t0; | ||
| DROP TABLE t1; | ||
| DROP TABLE t2; | ||
| DROP TABLE t3; | ||
| DROP DATABASE foo; | ||
| disconnect con1; | ||
| connection default; | ||
| DROP USER boo1; | ||
| DROP USER boo2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.