File: identifiers.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 (94 lines) | stat: -rw-r--r-- 3,010 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
####################################################
# Tests related to DDL and object identifiers
####################################################

--source connect.inc

--echo #
--echo # Bug#31846478 IMPROVE HANDLING OF DATABASE AND TABLE NAMES
--echo # - Add tests to verify handling of identifiers with special
--echo #   characters.
--echo #

CREATE TABLE `t_special_ö_\\_\_/_`(
  a INT PRIMARY KEY,
  b VARCHAR(255),
  c DATETIME,
  KEY(b),
  INDEX(a,b,c)
) ENGINE=ndb;
--source show_name_of_special_table.inc

#
# Check just a few DML, these will work as long as the table can be opened
#
INSERT INTO `t_special_ö_\\_\_/_` VALUES
  (1,'t_special_1','2020-11-01 00:05:01'),
  (2,'t_special_2','2020-11-02 00:04:02'),
  (3,'t_special_3','2020-11-03 00:03:03'),
  (4,'t_special_4','2020-11-04 00:02:04'),
  (5,'t_special_5','2020-11-05 00:01:05');
SELECT * FROM `t_special_ö_\\_\_/_` WHERE a = 3;

#
# Check several different DDL variations, these are more complicated
#
--echo # Inplace alter table
ALTER TABLE `t_special_ö_\\_\_/_` ALGORITHM=inplace,
  ADD COLUMN d INT DEFAULT NULL;
--disable_query_log ONCE
SELECT CASE COUNT(COLUMN_NAME) WHEN 1 THEN 'YES' ELSE 'NO' END as Column_d_exist
  FROM information_schema.columns
    WHERE TABLE_NAME LIKE('t_special%') AND COLUMN_NAME = 'd';
--source show_name_of_special_table.inc

--echo # Copying alter table
ALTER TABLE `t_special_ö_\\_\_/_` ALGORITHM=copy,
  MODIFY COLUMN c DATETIME NOT NULL;
--disable_query_log ONCE
SELECT IS_NULLABLE as Column_c_is_nullable FROM information_schema.columns
  WHERE TABLE_NAME LIKE('t_special%') AND COLUMN_NAME = 'c';
--source show_name_of_special_table.inc

--echo # Copying alter table with rename
ALTER TABLE `t_special_ö_\\_\_/_` ALGORITHM=copy,
  RENAME TO `t_special_å_/_\_`;
--source show_name_of_special_table.inc

--echo # Alter table with "simple rename" (ALTER optimized by MySQL Server)
ALTER TABLE `t_special_å_/_\_` RENAME TO `t_special_ä_\\_/_\_`;
--source show_name_of_special_table.inc

--echo # Rename table
RENAME TABLE `t_special_ä_\\_/_\_` TO `t_special_ö_\\_/_\_`;
--source show_name_of_special_table.inc

--echo # Drop the table and check no "t_special*" table is left anywhere
DROP TABLE `t_special_ö_\\_/_\_`;
--source show_name_of_special_table.inc

--echo #
--echo # Create database with special name
--echo #

CREATE DATABASE `test_\_ö`;

CREATE TABLE `test_\_ö`.t_special (
  a int primary key
) engine = NDB;
--source show_name_of_special_table.inc

DROP DATABASE `test_\_ö`;

--echo #
--echo # Create table in database with forward slash is not
--echo # supported (by NdbApi) since the slash is used as separator
--echo # in the NDB tables internal name.
CREATE DATABASE `d/1`;
--error ER_CANT_CREATE_TABLE
CREATE TABLE `d/1`.`t1` (a int) ENGINE=NDB;
# The failure should also have pushed some warnings which
# further explains the problem. These includes also the warnings from
# discover phase where the same error is triggered.
SHOW WARNINGS;
DROP DATABASE `d/1`;