@@ -8,6 +8,7 @@ let $grep_file= $MYSQLTEST_VARDIR/tmp/bug36816986.sql;
88let $grep_output=boolean;
99
1010CREATE DATABASE bug36816986;
11+ USE bug36816986;
1112
1213--echo -- Run mysqldump with tablespace_injection_test.
1314--exec $MYSQL_DUMP --debug="d,tablespace_injection_test" --result-file=$grep_file bug36816986 --all-tablespaces 2>&1
@@ -16,6 +17,111 @@ CREATE DATABASE bug36816986;
1617let $grep_pattern=qr| ENGINE=\*/\nsystem touch foo|;
1718--source include/grep_pattern.inc
1819
19- # Cleanup
20+ --echo The ` must be escaped:
21+ let $grep_pattern=qr|CREATE TABLESPACE `T``N; /*`|;
22+ --source include/grep_pattern.inc
23+
2024--remove_file $grep_file
2125DROP DATABASE bug36816986;
26+
27+ --echo
28+ --echo #######################################
29+ --echo
30+
31+ --echo #
32+ --echo # Bug#37607195 - fprintf_string not using the actual quote parameter
33+ --echo #
34+
35+ CREATE DATABASE bug37607195;
36+ USE bug37607195;
37+
38+ let $grep_file= $MYSQLTEST_VARDIR/tmp/bug37607195.sql;
39+ let $grep_output=boolean;
40+
41+ --echo Create a bunch of tables with numerous ` ' " \n etc.
42+
43+ --disable_warnings
44+ SET @@sql_mode='ANSI_QUOTES,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
45+ --enable_warnings
46+
47+ CREATE TABLE "custo`mers" (
48+ "customer'_id" INT AUTO_INCREMENT PRIMARY KEY,
49+ "fir`st_`na`me" VARCHAR(50) NOT NULL,
50+ "last_'name" VARCHAR(50) NOT NULL,
51+ "em`ail" VARCHAR(100) UNIQUE NOT NULL,
52+ `pho"\ne` VARCHAR(15),
53+ "created'_'at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
54+ "updated'_'at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
55+ );
56+
57+ CREATE TABLE "prod'ucts" (
58+ "product`_`id" INT AUTO_INCREMENT PRIMARY KEY,
59+ "product'_`name" VARCHAR(100) NOT NULL,
60+ "descri`p`t`i`o`n" TEXT,
61+ "pr'i'ce" DECIMAL(10, 2) NOT NULL CHECK ("pr'i'ce" >= 0),
62+ `stock"_"qua\ntity` INT DEFAULT 0,
63+ `created'_'at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
64+ `updated"_'at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
65+ INDEX ("product'_`name")
66+ );
67+
68+ CREATE TABLE "orders" (
69+ "order_id" INT AUTO_INCREMENT PRIMARY KEY,
70+ "customer_id" INT NOT NULL,
71+ "order_date" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
72+ "status" ENUM('Pending', 'Completed', 'Cancelled') NOT NULL,
73+ "total\n" DECIMAL(10, 2) NOT NULL CHECK ("total\n" >= 0),
74+ FOREIGN KEY (customer_id) REFERENCES "custo`mers"("customer'_id") ON DELETE CASCADE,
75+ INDEX (order_date)
76+ );
77+
78+ CREATE TABLE `'order'_'items'` (
79+ `order'_'item_id` INT AUTO_INCREMENT PRIMARY KEY,
80+ `'order'_'id'` INT NOT NULL,
81+ `product'_'id` INT NOT NULL,
82+ `qua\ntity` INT NOT NULL CHECK (`qua\ntity` > 0),
83+ `p'rice` DECIMAL(10,2) NOT NULL CHECK (`p'rice` >= 0),
84+ FOREIGN KEY (`'order'_'id'`) REFERENCES "orders"(order_id) ON DELETE CASCADE,
85+ FOREIGN KEY (`product'_'id`) REFERENCES "prod'ucts"("product`_`id") ON DELETE CASCADE,
86+ UNIQUE KEY (`'order'_'id'`, `product'_'id`)
87+ );
88+
89+ --exec $MYSQL_DUMP bug37607195 --result-file=$grep_file 2>&1
90+
91+ --echo # Table 1: `'order'_'items'`
92+ --echo # `qua\ntity` must be escaped
93+ let $grep_pattern=qr| `qua\ntity` INT NOT NULL CHECK (`qua\ntity` > 0)|;
94+ --source include/grep_pattern.inc
95+
96+ --echo # Table 2: "custo`mers"
97+ --echo # "custo`mers" must be escaped
98+ let $grep_pattern=qr|CREATE TABLE `custo``mers`|;
99+ --source include/grep_pattern.inc
100+
101+ --echo # `pho"\ne` must be escaped
102+ let $grep_pattern=qr|`pho"\ne` varchar(15) DEFAULT NULL|;
103+ --source include/grep_pattern.inc
104+
105+ --echo # Table 3: "orders"
106+ --echo # `total\n` must be escaped
107+ let $grep_pattern=qr|`total\n` decimal(10,2) NOT NULL|;
108+ --source include/grep_pattern.inc
109+
110+ --echo # FOREIGN KEY (`customer_id`) REFERENCES must be escaped
111+ let $grep_pattern=qr|REFERENCES `custo``mers`|;
112+ --source include/grep_pattern.inc
113+
114+ --echo # Table 4: `prod'ucts`
115+ --echo # "descri`p`t`i`o`n" TEXT must be escaped
116+ let $grep_pattern=qr|`descri``p``t``i``o``n` text|;
117+ --source include/grep_pattern.inc
118+
119+ --echo # `stock"_"qua\ntity` must be escaped
120+ let $grep_pattern=qr|`stock"_"qua\ntity` int DEFAULT '0'|;
121+ --source include/grep_pattern.inc
122+
123+ SET @@sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
124+
125+ # Cleanup
126+ --remove_file $grep_file
127+ DROP DATABASE bug37607195;
0 commit comments