summaryrefslogtreecommitdiff
path: root/mysql-test/suite/funcs_1/r/is_check_constraints.result
blob: eaf90f445446eb8ec8fe6ec797fc415eb3535692 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#
# MDEV-14474: Create INFORMATION_SCHEMA.CHECK_CONSTRAINTS
#
set check_constraint_checks=1;
use test;
create table t0
(
t int, check (t>32) # table constraint
) ENGINE=myisam;
SELECT * from information_schema.check_constraints order by check_clause;
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	mysql
CONSTRAINT_NAME	Priv
TABLE_NAME	global_priv
CHECK_CLAUSE	json_valid(`Priv`)
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	test
CONSTRAINT_NAME	CONSTRAINT_1
TABLE_NAME	t0
CHECK_CLAUSE	`t` > 32
ALTER TABLE t0
ADD CONSTRAINT CHK_t0_t CHECK(t<100);
SELECT * from information_schema.check_constraints order by check_clause;
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	mysql
CONSTRAINT_NAME	Priv
TABLE_NAME	global_priv
CHECK_CLAUSE	json_valid(`Priv`)
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	test
CONSTRAINT_NAME	CHK_t0_t
TABLE_NAME	t0
CHECK_CLAUSE	`t` < 100
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	test
CONSTRAINT_NAME	CONSTRAINT_1
TABLE_NAME	t0
CHECK_CLAUSE	`t` > 32
ALTER TABLE t0
DROP CONSTRAINT CHK_t0_t;
SELECT * from information_schema.check_constraints order by check_clause;
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	mysql
CONSTRAINT_NAME	Priv
TABLE_NAME	global_priv
CHECK_CLAUSE	json_valid(`Priv`)
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	test
CONSTRAINT_NAME	CONSTRAINT_1
TABLE_NAME	t0
CHECK_CLAUSE	`t` > 32
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 order by check_clause;
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	mysql
CONSTRAINT_NAME	Priv
TABLE_NAME	global_priv
CHECK_CLAUSE	json_valid(`Priv`)
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	test
CONSTRAINT_NAME	CHK_tt
TABLE_NAME	t1
CHECK_CLAUSE	`tt` < 100
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	test
CONSTRAINT_NAME	t
TABLE_NAME	t1
CHECK_CLAUSE	`t` > 2
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	test
CONSTRAINT_NAME	CONSTRAINT_1
TABLE_NAME	t0
CHECK_CLAUSE	`t` > 32
ALTER TABLE t1
DROP CONSTRAINT CHK_tt;
SELECT * from information_schema.check_constraints order by check_clause;
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	mysql
CONSTRAINT_NAME	Priv
TABLE_NAME	global_priv
CHECK_CLAUSE	json_valid(`Priv`)
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	test
CONSTRAINT_NAME	t
TABLE_NAME	t1
CHECK_CLAUSE	`t` > 2
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	test
CONSTRAINT_NAME	CONSTRAINT_1
TABLE_NAME	t0
CHECK_CLAUSE	`t` > 32
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 order by check_clause;
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	test
CONSTRAINT_NAME	name
TABLE_NAME	t2
CHECK_CLAUSE	char_length(`name`) > 2
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	mysql
CONSTRAINT_NAME	Priv
TABLE_NAME	global_priv
CHECK_CLAUSE	json_valid(`Priv`)
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	test
CONSTRAINT_NAME	CHK_dates
TABLE_NAME	t2
CHECK_CLAUSE	`start_date` is null
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	test
CONSTRAINT_NAME	t
TABLE_NAME	t1
CHECK_CLAUSE	`t` > 2
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	test
CONSTRAINT_NAME	CONSTRAINT_1
TABLE_NAME	t0
CHECK_CLAUSE	`t` > 32
ALTER TABLE t1
ADD CONSTRAINT CHK_new_ CHECK(t>tt);
SELECT * from information_schema.check_constraints order by check_clause;
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	test
CONSTRAINT_NAME	name
TABLE_NAME	t2
CHECK_CLAUSE	char_length(`name`) > 2
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	mysql
CONSTRAINT_NAME	Priv
TABLE_NAME	global_priv
CHECK_CLAUSE	json_valid(`Priv`)
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	test
CONSTRAINT_NAME	CHK_dates
TABLE_NAME	t2
CHECK_CLAUSE	`start_date` is null
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	test
CONSTRAINT_NAME	t
TABLE_NAME	t1
CHECK_CLAUSE	`t` > 2
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	test
CONSTRAINT_NAME	CONSTRAINT_1
TABLE_NAME	t0
CHECK_CLAUSE	`t` > 32
CONSTRAINT_CATALOG	def
CONSTRAINT_SCHEMA	test
CONSTRAINT_NAME	CHK_new_
TABLE_NAME	t1
CHECK_CLAUSE	`t` > `tt`
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 order by check_clause;
CONSTRAINT_CATALOG	CONSTRAINT_SCHEMA	CONSTRAINT_NAME	TABLE_NAME	CHECK_CLAUSE
def	test	name	t2	char_length(`name`) > 2
def	mysql	Priv	global_priv	json_valid(`Priv`)
def	test	b	t3	`b` > 0
def	test	b	t3	`b` > 10
def	test	CHK_dates	t2	`start_date` is null
def	test	t	t1	`t` > 2
def	test	CONSTRAINT_1	t0	`t` > 32
def	test	CHK_new_	t1	`t` > `tt`
drop table t0;
drop table t1;
drop table t2;
drop table t3;