Debian Codegraph @

mysql-test/suite/ndb/t/ndb_storage.test

raw
1 --source include/have_ndb.inc
2
3 # Terminology:
4 # Explicit disk column : A column that has 'storage disk' definition.
5 # Implicit disk column : A column that has default storage and thus inherits
6 # its storage from the table having 'storage disk' definition.
7
8 #
9 # This test tests the following cases :
10 # Moving column data between disk and memory will be performed
11 # with copy algorithm
12 # Create a table and an index on a column having explicit and implicit disk
13 # columns
14
15 # Create logfile group
16 CREATE LOGFILE GROUP lg1
17 ADD UNDOFILE 'lg1_undofile.dat'
18 INITIAL_SIZE 1M
19 UNDO_BUFFER_SIZE = 1M
20 ENGINE=ndb;
21
22 # Create tablespace using the logfile group
23 CREATE TABLESPACE ts1
24 ADD DATAFILE 'ts1_datafile.dat'
25 USE LOGFILE GROUP lg1
26 INITIAL_SIZE 10M
27 ENGINE ndb;
28
29
30 ## Move columns between memory and disk storage and
31 ## verify whether the copy algorithm is used.
32
33 CREATE TABLE t5 (a int PRIMARY KEY, t5b int, t5c int)
34 ENGINE ndb TABLESPACE ts1;
35 INSERT INTO t5 VALUES (1, 1, 1);
36
37 # Moving implicit memory columns to disk will be
38 # an automatic copy alter (no need to specify alg=copy)
39 --error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
40 ALTER TABLE t5 ALGORITHM=inplace, STORAGE disk;
41 ALTER TABLE t5 STORAGE DISK;
42
43 #Check if the disk data is on disk
44 --error ER_ALTER_FILEGROUP_FAILED
45 ALTER TABLESPACE ts1
46 DROP DATAFILE 'ts1_datafile.dat';
47 SHOW WARNINGS;
48
49 # Moving implicit disk columns back to memory will be
50 # an automatic copy alter
51 ALTER TABLE t5 STORAGE memory;
52
53 #Check if the disk data has been moved from disk
54 ALTER TABLESPACE ts1
55 DROP DATAFILE 'ts1_datafile.dat';
56 SELECT * FROM t5;
57
58 DROP TABLE t5;
59 DROP TABLESPACE ts1;
60
61 CREATE TABLESPACE ts1
62 ADD DATAFILE 'ts1_datafile.dat'
63 USE LOGFILE GROUP lg1
64 INITIAL_SIZE 10M
65 ENGINE ndb;
66
67 # Move a memory column to disk
68 CREATE TABLE t5 (a int PRIMARY KEY, t5b int, t5c int)
69 ENGINE ndb;
70 INSERT INTO t5 VALUES (1, 1, 1);
71
72 ALTER TABLE t5 CHANGE t5b t5b int STORAGE disk, TABLESPACE ts1;
73
74 #Check if the disk data has been moved to disk
75 --error ER_ALTER_FILEGROUP_FAILED
76 ALTER TABLESPACE ts1
77 DROP DATAFILE 'ts1_datafile.dat';
78 SHOW WARNINGS;
79
80 # Move an explicit disk column to memory
81 ALTER TABLE t5 CHANGE t5b t5b int STORAGE memory;
82 #Check if the disk data has been moved to disk
83 ALTER TABLESPACE ts1
84 DROP DATAFILE 'ts1_datafile.dat';
85 SELECT * FROM t5;
86
87 DROP TABLE t5;
88
89 DROP TABLESPACE ts1;
90
91 CREATE TABLESPACE ts1
92 ADD DATAFILE 'ts1_datafile.dat'
93 USE LOGFILE GROUP lg1
94 INITIAL_SIZE 10M
95 ENGINE ndb;
96
97
98 ## Creating an index on an explicit disk column
99
100 # Creating an index on an explicit disk column in 'create table',
101 # 'create index' or 'alter table add index' will fail.
102
103 # Tinyblob/text will be stored in memory irrespective of
104 # the storage type specified in the create/alter query
105 # and cannot create an index on them.
106
107 --error ER_ILLEGAL_HA_CREATE_OPTION
108 CREATE TABLE t5 (a int PRIMARY KEY, t5b tinyblob,
109 t5c tinytext, t5d int unique key STORAGE disk)
110 TABLESPACE ts1 ENGINE ndb;
111 SHOW WARNINGS;
112
113 CREATE TABLE t5 (a int PRIMARY KEY, t5b tinyblob,
114 t5c tinytext, t5d int STORAGE disk)
115 TABLESPACE ts1 ENGINE ndb;
116
117 --error ER_ILLEGAL_HA_CREATE_OPTION
118 CREATE INDEX 5d_i ON t5(t5d);
119
120 --error ER_ILLEGAL_HA_CREATE_OPTION
121 ALTER TABLE t5 ADD INDEX 5d_i (t5d);
122
123 DROP TABLE t5;
124
125 # Creating an index on an implicit disk column will pass.
126 # The implicit disk column will be silently converted
127 # to a memory column by Ndb unless the column is
128 # explicitly defined as a disk column. as tested above.
129
130 CREATE TABLE t5 (a int PRIMARY KEY, t5b tinyblob,
131 t5c tinytext, t5d int)
132 STORAGE disk TABLESPACE ts1 ENGINE ndb;
133
134 CREATE INDEX 5d_i ON t5(t5d);
135
136 DROP INDEX 5d_i on t5;
137
138 ALTER TABLE t5 ADD INDEX 5d_i(t5d);
139
140 # Clean up
141 DROP TABLE t5;
142 ALTER TABLESPACE ts1
143 DROP DATAFILE 'ts1_datafile.dat';
144 DROP TABLESPACE ts1;
145 DROP LOGFILE GROUP lg1 ENGINE=ndb;
146
147 # end test ndb_storage.