1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

MDEV-14474 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.
This commit is contained in:
Anel Husakovic
2018-04-03 12:41:13 +00:00
committed by Vicențiu Ciorbaru
parent 7f73f5e4e5
commit d526679efd
9 changed files with 334 additions and 1 deletions

View File

@ -0,0 +1,69 @@
--source include/have_innodb.inc
--echo #
--echo # MDEV-14474: Create INFORMATION_SCHEMA.CHECK_CONSTRAINTS
--echo #
set check_constraint_checks=1;
use test;
create table t0
(
t int, check (t>32) # table constraint
) ENGINE=myisam;
--vertical_results
SELECT * from information_schema.check_constraints;
ALTER TABLE t0
ADD CONSTRAINT CHK_t0_t CHECK(t<100);
SELECT * from information_schema.check_constraints;
ALTER TABLE t0
DROP CONSTRAINT CHK_t0_t;
SELECT * from information_schema.check_constraints;
CREATE TABLE t1
( t int CHECK(t>2), # field constraint
tt int, CONSTRAINT CHK_tt CHECK(tt<100) # table constraint
) ENGINE=InnoDB;
SELECT * from information_schema.check_constraints;
ALTER TABLE t1
DROP CONSTRAINT CHK_tt;
SELECT * from information_schema.check_constraints;
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;
ALTER TABLE t1
ADD CONSTRAINT CHK_new_ CHECK(t>tt);
SELECT * from information_schema.check_constraints;
# Create table with same field and table check constraint name
create table t3
(
a int,
b int check (b>0), # field constraint named 'b'
CONSTRAINT b check (b>10) # table constraint
) ENGINE=InnoDB;
--horizontal_results
select * from information_schema.check_constraints;
drop table t0;
drop table t1;
drop table t2;
drop table t3;