File: alter_max_rows.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (191 lines) | stat: -rw-r--r-- 4,842 bytes parent folder | download
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
181
182
183
184
185
186
187
188
189
190
191
# Create t3 with MAX_ROWS set
let $t3_table_options = MAX_ROWS=333333;
# and t2 with partition balance FOR_RP_BY_NODE
let $t2_table_options = COMMENT="NDB_TABLE=PARTITION_BALANCE=FOR_RP_BY_NODE";
--source setup.inc

#
# Test ALTER TABLE .. MAX_ROWS in combination with tables with
# or without MAX_ROWS
#


#
# Check that inplace ALTER TABLE ... MAX_ROWS on a table which does
# not already have MAX_ROWS set is not allowed.
#

if (`select LOCATE("max_rows=", CREATE_OPTIONS)
       from information_schema.tables where
         TABLE_SCHEMA='ndb_ddl_test' and TABLE_NAME = 't1'`)
{
  die t1 has MAX_ROWS set;
}

--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1
  algorithm=inplace,
  max_rows=1111111;

#
# Check that copying ALTER TABLE ... MAX_ROWS on a table which does
# not already have MAX_ROWS set is allowed.
#
ALTER TABLE t1
  algorithm=copy,
  max_rows=1111111;

if (!`select LOCATE("max_rows=", CREATE_OPTIONS)
       from information_schema.tables where
         TABLE_SCHEMA='ndb_ddl_test' and TABLE_NAME = 't1'`)
{
  die t1 does not have MAX_ROWS set;
}

#
# Check that inplace ALTER TABLE ... MAX_ROWS on a table which
# already have MAX_ROWS set is allowed.
#

if (!`select LOCATE("max_rows=", CREATE_OPTIONS)
       from information_schema.tables where
         TABLE_SCHEMA='ndb_ddl_test' and TABLE_NAME = 't3'`)
{
  die t3 does not have MAX_ROWS set;
}

ALTER TABLE t3
  algorithm=inplace,
  max_rows=4444444;

if (!`select LOCATE("max_rows=4444444", CREATE_OPTIONS)
       from information_schema.tables where
         TABLE_SCHEMA='ndb_ddl_test' and TABLE_NAME = 't3'`)
{
  die The value of MAX_ROWS for t3 did not change;
}


#
# Check that copying ALTER TABLE ... MAX_ROWS on a table which
# already have MAX_ROWS set is allowed.
#

if (!`select LOCATE("max_rows=", CREATE_OPTIONS)
       from information_schema.tables where
         TABLE_SCHEMA='ndb_ddl_test' and TABLE_NAME = 't3'`)
{
  die t3 does not have MAX_ROWS set;
}

ALTER TABLE t3
  algorithm=copy,
  max_rows=5555555;

if (!`select LOCATE("max_rows=5555555", CREATE_OPTIONS)
       from information_schema.tables where
         TABLE_SCHEMA='ndb_ddl_test' and TABLE_NAME = 't3'`)
{
  die The value of MAX_ROWS for t3 did not change;
}


#
# Check that inplace ALTER TABLE to reduce MAX_ROWS which does
# not cause reduction in number of fragments is allowed
#
ALTER TABLE t3
  algorithm=copy,
  max_rows=33333 /* Small enough to get default number of frags */;
ALTER TABLE t3
  algorithm=inplace,
  max_rows=33332 /* Small enough to still be at default number of frags */;

--echo Note! The value of MAX_ROWS in NDB is still 33333
--let $ndb_describe_db= ndb_ddl_test
--let $ndb_describe_table= t3
--source suite/ndb/include/ndb_describe_table.inc

#
# Check that inplace ALTER TABLE ... REORGANIZE PARTITION is
# not allowed when MAX_ROWS is set
#
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t3
  algorithm=inplace,
  reorganize partition;

# Check that the inplace ALTER TABLE to set MAX_ROWS to 0 is not allowed
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t3
  algorithm=inplace,
  max_rows=0;

# Check that copy ALTER TABLE to reset MAX_ROWS to 0 is allowed
ALTER TABLE t3
  algorithm=copy,
  max_rows=0;

# Check that MySQL says MAX_ROWS=0
if (`select LOCATE("MAX_ROWS=", CREATE_OPTIONS)
       from information_schema.tables where
         TABLE_SCHEMA='ndb_ddl_test' and TABLE_NAME = 't3'`)
{
  die MySQL Still reported a MAX_ROWS value for t3;
}

# Check that online ALTER TABLE .. REORGANIZE is now allowed
ALTER TABLE t3
  algorithm=inplace,
  reorganize partition;
INSERT INTO t3 VALUES(37, "MySQL Cluster", '2015-12-15');
SELECT b FROM t3 WHERE a > 10;
DELETE FROM t3 WHERE a = 37;

#
# Check that copying ALTER TABLE ... MAX_ROWS=0 yields a table
# which can be reorganized
#
ALTER TABLE t3
  algorithm=copy,
  max_rows=444444444 /* Large with many frags */;
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t3
  algorithm=inplace,
  max_rows=0 /* Not allowed since number of frags reduced */;
ALTER TABLE t3
  algorithm=copy,
  max_rows=0 /* Back to zero by using copying */;

#
# Check that inplace ALTER TABLE ... REORGANIZE PARTITION is ok
# now when the table is back to MAX_ROWS=0
#
ALTER TABLE t3
  algorithm=inplace,
  reorganize partition;
INSERT INTO t3 VALUES(37, "MySQL Cluster", '2015-12-15');
SELECT b FROM t3 WHERE a > 10;
DELETE FROM t3 WHERE a = 37;

#
# Check that inplace ALTER TABLE setting MAX_ROWS to 0
# is not allowed in table with user specified partition balance
#
ALTER TABLE t2
  algorithm=copy,
  max_rows=33333;
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t2
  algorithm=inplace,
  max_rows=0;

# Check that copy ALTER variant is allowed
ALTER TABLE t2
  algorithm=copy,
  max_rows=0;

--source verify_mysql_dd.inc

--source cleanup.inc