Debian Codegraph @

mysql-test/suite/query_rewrite_plugins/r/ddl_rewriter.result

raw
1 #
2 # Test for the DDL rewrite plugin.
3 #
4 #
5 # Create a table with a DATA DIRECTORY clause, to be dumped and
6 # restored when the plugin is installed.
7 #
8 CREATE TABLE t(i int) DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp';;
9 SHOW CREATE TABLE t;
10 Table Create Table
11 t CREATE TABLE `t` (
12 `i` int DEFAULT NULL
13 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci DATA DIRECTORY='MYSQLTEST_VARDIR/tmp/'
14 INSERT INTO t VALUES (1);
15 #
16 # Install plugin.
17 #
18 INSTALL PLUGIN ddl_rewriter SONAME 'ddl_rewriter.xxx';
19 SELECT PLUGIN_NAME, PLUGIN_TYPE, PLUGIN_VERSION, PLUGIN_TYPE_VERSION
20 FROM information_schema.plugins
21 WHERE plugin_name LIKE 'ddl_rewriter';
22 PLUGIN_NAME PLUGIN_TYPE PLUGIN_VERSION PLUGIN_TYPE_VERSION
23 ddl_rewriter AUDIT 1.0 4.1
24 #
25 # Restore dump file.
26 #
27 DROP TABLE t;
28 SHOW CREATE TABLE t;
29 Table Create Table
30 t CREATE TABLE `t` (
31 `i` int DEFAULT NULL
32 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
33 include/assert.inc [Expected table contents]
34 DROP TABLE t;
35 #
36 # False positives.
37 #
38 CREATE TABLE t(i int) /* data directory = 'x' */ ;
39 Warnings:
40 Note 1105 Query 'CREATE TABLE t(i int) /* data directory = 'x' */' rewritten to 'CREATE TABLE t(i int) /* */' by a query rewrite plugin
41 DROP TABLE t;
42 CREATE TABLE t(i int, `j encryption='n'j` int);
43 Warnings:
44 Note 1105 Query 'CREATE TABLE t(i int, `j encryption='n'j` int)' rewritten to 'CREATE TABLE t(i int, `j j` int)' by a query rewrite plugin
45 DROP TABLE t;
46 #
47 # Prefix comments make the statement not be rewritten.
48 #
49 /* */ CREATE TABLE t(i int) /* data directory = 'x' */ ;
50 DROP TABLE t;
51 /* */
52 CREATE TABLE t(i int) /* data directory = 'x' */ ;
53 DROP TABLE t;
54 #
55 # Double quotes.
56 #
57 CREATE TABLE t(i int) DATA DIRECTORY = "/tmp";
58 Warnings:
59 Note 1105 Query 'CREATE TABLE t(i int) DATA DIRECTORY = "/tmp"' rewritten to 'CREATE TABLE t(i int) ' by a query rewrite plugin
60 DROP TABLE t;
61 CREATE TABLE t(i int) ENCRYPTION = "n";
62 Warnings:
63 Note 1105 Query 'CREATE TABLE t(i int) ENCRYPTION = "n"' rewritten to 'CREATE TABLE t(i int) ' by a query rewrite plugin
64 DROP TABLE t;
65 #
66 # Multi-statement queries are separated before pre-parse,
67 # so a second non-CREATE TABLE statement will be treated
68 # separately.
69 #
70 CREATE SCHEMA s;
71 CREATE TABLE s.t(i int) DATA DIRECTORY = '/tmp';
72 Warnings:
73 Note 1105 Query 'CREATE TABLE s.t(i int) DATA DIRECTORY = '/tmp'' rewritten to 'CREATE TABLE s.t(i int) ' by a query rewrite plugin
74 DROP SCHEMA s;
75 CREATE TABLE t(i int);
76 CREATE SCHEMA s /* DATA DIRECTORY = '/tmp' */;
77 DROP SCHEMA s;
78 DROP TABLE t;
79 #
80 # Statements with prefix != 'CREATE TABLE' are not rewritten.
81 #
82 CREATE SCHEMA s /* data directory = 'x' */ ;
83 DROP SCHEMA s;
84 CREATE SCHEMA `s encryption='n' s`;
85 DROP SCHEMA `s encryption='n' s`;
86 #
87 # Case sensitivity.
88 #
89 CREATE TABLE t(i int) DATA DIRECTORY = '/tmp', ENGINE = MyISAM;
90 Warnings:
91 Note 1105 Query 'CREATE TABLE t(i int) DATA DIRECTORY = '/tmp', ENGINE = MyISAM' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM' by a query rewrite plugin
92 DROP TABLE t;
93 create table t(i int) DATA DIRECTORY = '/tmp', ENGINE = MyISAM;
94 Warnings:
95 Note 1105 Query 'create table t(i int) DATA DIRECTORY = '/tmp', ENGINE = MyISAM' rewritten to 'create table t(i int) ENGINE = MyISAM' by a query rewrite plugin
96 DROP TABLE t;
97 CREATE TABLE t(i int) data directory = '/tmp', ENGINE = MyISAM;
98 Warnings:
99 Note 1105 Query 'CREATE TABLE t(i int) data directory = '/tmp', ENGINE = MyISAM' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM' by a query rewrite plugin
100 DROP TABLE t;
101 CREATE TABLE t(i int) INDEX DIRECTORY = '/tmp', ENGINE = MyISAM;
102 Warnings:
103 Note 1105 Query 'CREATE TABLE t(i int) INDEX DIRECTORY = '/tmp', ENGINE = MyISAM' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM' by a query rewrite plugin
104 DROP TABLE t;
105 CREATE TABLE t(i int) index directory = '/tmp', ENGINE = MyISAM;
106 Warnings:
107 Note 1105 Query 'CREATE TABLE t(i int) index directory = '/tmp', ENGINE = MyISAM' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM' by a query rewrite plugin
108 DROP TABLE t;
109 CREATE TABLE t(i int) ENCRYPTION = 'N', ENGINE = MyISAM;
110 Warnings:
111 Note 1105 Query 'CREATE TABLE t(i int) ENCRYPTION = 'N', ENGINE = MyISAM' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM' by a query rewrite plugin
112 DROP TABLE t;
113 CREATE TABLE t(i int) encryption = 'n', ENGINE = MyISAM;
114 Warnings:
115 Note 1105 Query 'CREATE TABLE t(i int) encryption = 'n', ENGINE = MyISAM' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM' by a query rewrite plugin
116 DROP TABLE t;
117 CREATE TABLE t(i int) ENCRYPTION = 'Y', ENGINE = MyISAM;
118 Warnings:
119 Note 1105 Query 'CREATE TABLE t(i int) ENCRYPTION = 'Y', ENGINE = MyISAM' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM' by a query rewrite plugin
120 DROP TABLE t;
121 CREATE TABLE t(i int) ENCRYPTION = 'y', ENGINE = MyISAM;
122 Warnings:
123 Note 1105 Query 'CREATE TABLE t(i int) ENCRYPTION = 'y', ENGINE = MyISAM' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM' by a query rewrite plugin
124 DROP TABLE t;
125 #
126 # Optional preceding comma with optional surrounding whitespace.
127 #
128 CREATE TABLE t(i int) ENGINE = MyISAM ENCRYPTION = 'N';
129 Warnings:
130 Note 1105 Query 'CREATE TABLE t(i int) ENGINE = MyISAM ENCRYPTION = 'N'' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM ' by a query rewrite plugin
131 DROP TABLE t;
132 CREATE TABLE t(i int) ENGINE = MyISAM,ENCRYPTION = 'N';
133 Warnings:
134 Note 1105 Query 'CREATE TABLE t(i int) ENGINE = MyISAM,ENCRYPTION = 'N'' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM ' by a query rewrite plugin
135 DROP TABLE t;
136 CREATE TABLE t(i int) ENGINE = MyISAM, ENCRYPTION = 'N';
137 Warnings:
138 Note 1105 Query 'CREATE TABLE t(i int) ENGINE = MyISAM, ENCRYPTION = 'N'' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM ' by a query rewrite plugin
139 DROP TABLE t;
140 CREATE TABLE t(i int) ENGINE = MyISAM ,ENCRYPTION = 'N';
141 Warnings:
142 Note 1105 Query 'CREATE TABLE t(i int) ENGINE = MyISAM ,ENCRYPTION = 'N'' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM ' by a query rewrite plugin
143 DROP TABLE t;
144 CREATE TABLE t(i int) ENGINE = MyISAM , ENCRYPTION = 'N';
145 Warnings:
146 Note 1105 Query 'CREATE TABLE t(i int) ENGINE = MyISAM , ENCRYPTION = 'N'' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM ' by a query rewrite plugin
147 DROP TABLE t;
148 #
149 # Optional succeeding comma with optional surrounding whitespace.
150 #
151 CREATE TABLE t(i int) ENCRYPTION = 'N' ENGINE = MyISAM;
152 Warnings:
153 Note 1105 Query 'CREATE TABLE t(i int) ENCRYPTION = 'N' ENGINE = MyISAM' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM' by a query rewrite plugin
154 DROP TABLE t;
155 CREATE TABLE t(i int) ENCRYPTION = 'N',ENGINE = MyISAM;
156 Warnings:
157 Note 1105 Query 'CREATE TABLE t(i int) ENCRYPTION = 'N',ENGINE = MyISAM' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM' by a query rewrite plugin
158 DROP TABLE t;
159 CREATE TABLE t(i int) ENCRYPTION = 'N', ENGINE = MyISAM;
160 Warnings:
161 Note 1105 Query 'CREATE TABLE t(i int) ENCRYPTION = 'N', ENGINE = MyISAM' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM' by a query rewrite plugin
162 DROP TABLE t;
163 CREATE TABLE t(i int) ENCRYPTION = 'N' ,ENGINE = MyISAM;
164 Warnings:
165 Note 1105 Query 'CREATE TABLE t(i int) ENCRYPTION = 'N' ,ENGINE = MyISAM' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM' by a query rewrite plugin
166 DROP TABLE t;
167 CREATE TABLE t(i int) ENCRYPTION = 'N' , ENGINE = MyISAM;
168 Warnings:
169 Note 1105 Query 'CREATE TABLE t(i int) ENCRYPTION = 'N' , ENGINE = MyISAM' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM' by a query rewrite plugin
170 DROP TABLE t;
171 #
172 # Optional assignment operator with optional surrounding whitespace.
173 #
174 CREATE TABLE t(i int) ENCRYPTION 'N' ENGINE = MyISAM;
175 Warnings:
176 Note 1105 Query 'CREATE TABLE t(i int) ENCRYPTION 'N' ENGINE = MyISAM' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM' by a query rewrite plugin
177 DROP TABLE t;
178 CREATE TABLE t(i int) ENCRYPTION='N' ENGINE = MyISAM;
179 Warnings:
180 Note 1105 Query 'CREATE TABLE t(i int) ENCRYPTION='N' ENGINE = MyISAM' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM' by a query rewrite plugin
181 DROP TABLE t;
182 CREATE TABLE t(i int) ENCRYPTION= 'N' ENGINE = MyISAM;
183 Warnings:
184 Note 1105 Query 'CREATE TABLE t(i int) ENCRYPTION= 'N' ENGINE = MyISAM' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM' by a query rewrite plugin
185 DROP TABLE t;
186 CREATE TABLE t(i int) ENCRYPTION ='N' ENGINE = MyISAM;
187 Warnings:
188 Note 1105 Query 'CREATE TABLE t(i int) ENCRYPTION ='N' ENGINE = MyISAM' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM' by a query rewrite plugin
189 DROP TABLE t;
190 CREATE TABLE t(i int) ENCRYPTION = 'N' ENGINE = MyISAM;
191 Warnings:
192 Note 1105 Query 'CREATE TABLE t(i int) ENCRYPTION = 'N' ENGINE = MyISAM' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM' by a query rewrite plugin
193 DROP TABLE t;
194 #
195 # Multi line statements.
196 #
197 CREATE TABLE t(i int) ENCRYPTION ='N'
198 ,ENGINE = MyISAM
199 DATA
200 DIRECTORY = '/tmp'
201 DEFAULT CHARSET latin1
202 INDEX
203 DIRECTORY '/t
204 mp';
205 Warnings:
206 Note 1105 Query 'CREATE TABLE t(i int) ENCRYPTION ='N'
207 ,ENGINE = MyISAM
208 DATA
209 DIRECTORY = '/tmp'
210 DEFAULT CHARSET latin1
211 INDEX
212 DIRECTORY '/t
213 mp'' rewritten to 'CREATE TABLE t(i int) ENGINE = MyISAM DEFAULT CHARSET latin1 ' by a query rewrite plugin
214 DROP TABLE t;
215 #
216 # Partitioned tables.
217 #
218 CREATE TABLE t (
219 i int NOT NULL AUTO_INCREMENT,
220 mt mediumtext NOT NULL,
221 c varchar(10) NOT NULL,
222 ti tinyint(1) unsigned NOT NULL,
223 PRIMARY KEY (i, ti)
224 )
225 ENGINE = InnoDB AUTO_INCREMENT = 0
226 DEFAULT CHARSET = latin1, DATA DIRECTORY = '/tmp'
227 PARTITION BY LIST (ti) (
228 PARTITION p0 VALUES IN (0) ENGINE = InnoDB,
229 PARTITION p1 VALUES IN (1) DATA DIRECTORY = '/tmp' ,ENGINE = InnoDB
230 );
231 Warnings:
232 Note 1105 Query 'CREATE TABLE t (
233 i int NOT NULL AUTO_INCREMENT,
234 mt mediumtext NOT NULL,
235 c varchar(10) NOT NULL,
236 ti tinyint(1) unsigned NOT NULL,
237 PRIMARY KEY (i, ti)
238 )
239 ENGINE = InnoDB AUTO_INCREMENT = 0
240 DEFAULT CHARSET = latin1, DATA DIRECTORY = '/tmp'
241 PARTITION BY LIST (ti) (
242 PARTITION p0 VALUES IN (0) ENGINE = InnoDB,
243 PARTITION p1 VALUES IN (1) DATA DIRECTORY = '/tmp' ,ENGINE = InnoDB
244 )' rewritten to 'CREATE TABLE t (
245 i int NOT NULL AUTO_INCREMENT,
246 mt mediumtext NOT NULL,
247 c varchar(10) NOT NULL,
248 ti tinyint(1
249 Warning 1681 Integer display width is deprecated and will be removed in a future release.
250 SHOW CREATE TABLE t;
251 Table Create Table
252 t CREATE TABLE `t` (
253 `i` int NOT NULL AUTO_INCREMENT,
254 `mt` mediumtext NOT NULL,
255 `c` varchar(10) NOT NULL,
256 `ti` tinyint unsigned NOT NULL,
257 PRIMARY KEY (`i`,`ti`)
258 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
259 /*!50100 PARTITION BY LIST (`ti`)
260 (PARTITION p0 VALUES IN (0) ENGINE = InnoDB,
261 PARTITION p1 VALUES IN (1) ENGINE = InnoDB) */
262 DROP TABLE t;
263 #
264 # Stored programs.
265 #
266 CREATE PROCEDURE p() CREATE TABLE test.t(i int) ENCRYPTION = 'N';
267 CALL p();
268 SHOW CREATE TABLE test.t;
269 Table Create Table
270 t CREATE TABLE `t` (
271 `i` int DEFAULT NULL
272 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
273 DROP TABLE test.t;
274 DROP PROCEDURE p;
275 #
276 # Prepared statements.
277 #
278 PREPARE stmt FROM 'CREATE TABLE test.t(i int) ENCRYPTION = "N"';
279 Warnings:
280 Note 1105 Query 'CREATE TABLE test.t(i int) ENCRYPTION = "N"' rewritten to 'CREATE TABLE test.t(i int) ' by a query rewrite plugin
281 EXECUTE stmt;
282 SHOW CREATE TABLE test.t;
283 Table Create Table
284 t CREATE TABLE `t` (
285 `i` int DEFAULT NULL
286 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
287 DROP TABLE test.t;
288 DROP PREPARE stmt;
289 #
290 # Uninstall plugin and verify that queries are not rewritten anymore.
291 #
292 UNINSTALL PLUGIN ddl_rewriter;
293 Warnings:
294 Warning 1620 Plugin is busy and will be uninstalled on shutdown
295 CREATE TABLE t(i int) /* data directory = 'x' */ ;
296 DROP TABLE t;