Debian Codegraph @

mysql-test/suite/ndb_ddl/identifiers.test

raw
1 ####################################################
2 # Tests related to DDL and object identifiers
3 ####################################################
4
5 --source connect.inc
6
7 --echo #
8 --echo # Bug#31846478 IMPROVE HANDLING OF DATABASE AND TABLE NAMES
9 --echo # - Add tests to verify handling of identifiers with special
10 --echo # characters.
11 --echo #
12
13 CREATE TABLE `t_special_ö_\\_\_/_`(
14 a INT PRIMARY KEY,
15 b VARCHAR(255),
16 c DATETIME,
17 KEY(b),
18 INDEX(a,b,c)
19 ) ENGINE=ndb;
20 --source show_name_of_special_table.inc
21
22 #
23 # Check just a few DML, these will work as long as the table can be opened
24 #
25 INSERT INTO `t_special_ö_\\_\_/_` VALUES
26 (1,'t_special_1','2020-11-01 00:05:01'),
27 (2,'t_special_2','2020-11-02 00:04:02'),
28 (3,'t_special_3','2020-11-03 00:03:03'),
29 (4,'t_special_4','2020-11-04 00:02:04'),
30 (5,'t_special_5','2020-11-05 00:01:05');
31 SELECT * FROM `t_special_ö_\\_\_/_` WHERE a = 3;
32
33 #
34 # Check several different DDL variations, these are more complicated
35 #
36 --echo # Inplace alter table
37 ALTER TABLE `t_special_ö_\\_\_/_` ALGORITHM=inplace,
38 ADD COLUMN d INT DEFAULT NULL;
39 --disable_query_log ONCE
40 SELECT CASE COUNT(COLUMN_NAME) WHEN 1 THEN 'YES' ELSE 'NO' END as Column_d_exist
41 FROM information_schema.columns
42 WHERE TABLE_NAME LIKE('t_special%') AND COLUMN_NAME = 'd';
43 --source show_name_of_special_table.inc
44
45 --echo # Copying alter table
46 ALTER TABLE `t_special_ö_\\_\_/_` ALGORITHM=copy,
47 MODIFY COLUMN c DATETIME NOT NULL;
48 --disable_query_log ONCE
49 SELECT IS_NULLABLE as Column_c_is_nullable FROM information_schema.columns
50 WHERE TABLE_NAME LIKE('t_special%') AND COLUMN_NAME = 'c';
51 --source show_name_of_special_table.inc
52
53 --echo # Copying alter table with rename
54 ALTER TABLE `t_special_ö_\\_\_/_` ALGORITHM=copy,
55 RENAME TO `t_special_å_/_\_`;
56 --source show_name_of_special_table.inc
57
58 --echo # Alter table with "simple rename" (ALTER optimized by MySQL Server)
59 ALTER TABLE `t_special_å_/_\_` RENAME TO `t_special_ä_\\_/_\_`;
60 --source show_name_of_special_table.inc
61
62 --echo # Rename table
63 RENAME TABLE `t_special_ä_\\_/_\_` TO `t_special_ö_\\_/_\_`;
64 --source show_name_of_special_table.inc
65
66 --echo # Drop the table and check no "t_special*" table is left anywhere
67 DROP TABLE `t_special_ö_\\_/_\_`;
68 --source show_name_of_special_table.inc
69
70 --echo #
71 --echo # Create database with special name
72 --echo #
73
74 CREATE DATABASE `test_\_ö`;
75
76 CREATE TABLE `test_\_ö`.t_special (
77 a int primary key
78 ) engine = NDB;
79 --source show_name_of_special_table.inc
80
81 DROP DATABASE `test_\_ö`;
82
83 --echo #
84 --echo # Create table in database with forward slash is not
85 --echo # supported (by NdbApi) since the slash is used as separator
86 --echo # in the NDB tables internal name.
87 CREATE DATABASE `d/1`;
88 --error ER_CANT_CREATE_TABLE
89 CREATE TABLE `d/1`.`t1` (a int) ENGINE=NDB;
90 # The failure should also have pushed some warnings which
91 # further explains the problem. These includes also the warnings from
92 # discover phase where the same error is triggered.
93 SHOW WARNINGS;
94 DROP DATABASE `d/1`;