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
|
#
# Basic ALTER TABLE statements.
#
# USAGE of table options in ALTER statements
# is covered in tbl_standard_opts and tbl_opt*.tests.
#
# Index operations are covered in index* tests.
#
# ALTER ONLINE syntax is covered in alter_online_table.test
# ALTER OFFLINE is not covered as it is not supported, as of 5.5.23
#
# ALTER TABLE ... DISCARD|IMPORT TABLESPACE is covered in alter_tablespace.test
#
--source have_engine.inc
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
--enable_warnings
--let $create_definition = a $int_col, c $char_col
--source create_table.inc
INSERT INTO t1 (a,c) VALUES (1,'a'),(5,'z');
# Column operations
--let $alter_definition = ADD COLUMN b $int_col
--source alter_table.inc
if ($mysql_errname)
{
--source unexpected_result.inc
}
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = ALTER COLUMN a SET DEFAULT '0'
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = ALTER a DROP DEFAULT
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = CHANGE COLUMN b b1 $char_col FIRST
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = CHANGE b1 b $int_col AFTER c
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = CHANGE b b $char_col
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = MODIFY COLUMN b $int_col
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = MODIFY COLUMN b $char_col FIRST
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = MODIFY COLUMN b $int_col AFTER a
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = DROP COLUMN b
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
# Rename table
--let $rename_to = t2
--source alter_table.inc
--let $error_codes = ER_NO_SUCH_TABLE
SHOW CREATE TABLE t1;
--source check_errors.inc
if ($mysql_errname != 'ER_NO_SUCH_TABLE')
{
--let $functionality = ALTER TABLE
--source unexpected_result.inc
DROP TABLE t1;
}
if ($mysql_errname == ER_NO_SUCH_TABLE)
{
--source mask_engine.inc
SHOW CREATE TABLE t2;
DROP TABLE t2;
}
# ORDER BY
--let $create_definition = a $int_col, b $int_col
--source create_table.inc
INSERT INTO t1 (a,b) VALUES (1,5),(2,2),(4,3);
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = ORDER BY b ASC, a DESC
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
# Character set, collate
--let $table_options = CHARACTER SET latin1 COLLATE latin1_general_cs
--let $create_definition = a $int_col, b $char_col, c $char_col
--source create_table.inc
INSERT INTO t1 (a,b,c) VALUES (5,'z','t');
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = CONVERT TO CHARACTER SET utf8
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
--let $alter_definition = DEFAULT CHARACTER SET = latin1 COLLATE latin1_general_ci
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
# A 'null' ALTER operation
--let $alter_definition = FORCE
--source alter_table.inc
--source mask_engine.inc
SHOW CREATE TABLE t1;
# Cleanup
DROP TABLE t1;
--source cleanup_engine.inc
|