@@ -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,109 @@ 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+ 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';
44+
45+ CREATE TABLE "custo`mers" (
46+ "customer'_id" INT AUTO_INCREMENT PRIMARY KEY,
47+ "fir`st_`na`me" VARCHAR(50) NOT NULL,
48+ "last_'name" VARCHAR(50) NOT NULL,
49+ "em`ail" VARCHAR(100) UNIQUE NOT NULL,
50+ `pho"\ne` VARCHAR(15),
51+ "created'_'at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
52+ "updated'_'at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
53+ );
54+
55+ CREATE TABLE "prod'ucts" (
56+ "product`_`id" INT AUTO_INCREMENT PRIMARY KEY,
57+ "product'_`name" VARCHAR(100) NOT NULL,
58+ "descri`p`t`i`o`n" TEXT,
59+ "pr'i'ce" DECIMAL(10, 2) NOT NULL CHECK ("pr'i'ce" >= 0),
60+ `stock"_"qua\ntity` INT DEFAULT 0,
61+ `created'_'at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
62+ `updated"_'at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
63+ INDEX ("product'_`name")
64+ );
65+
66+ CREATE TABLE "orders" (
67+ "order_id" INT AUTO_INCREMENT PRIMARY KEY,
68+ "customer_id" INT NOT NULL,
69+ "order_date" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
70+ "status" ENUM('Pending', 'Completed', 'Cancelled') NOT NULL,
71+ "total\n" DECIMAL(10, 2) NOT NULL CHECK ("total\n" >= 0),
72+ FOREIGN KEY (customer_id) REFERENCES "custo`mers"("customer'_id") ON DELETE CASCADE,
73+ INDEX (order_date)
74+ );
75+
76+ CREATE TABLE `'order'_'items'` (
77+ `order'_'item_id` INT AUTO_INCREMENT PRIMARY KEY,
78+ `'order'_'id'` INT NOT NULL,
79+ `product'_'id` INT NOT NULL,
80+ `qua\ntity` INT NOT NULL CHECK (`qua\ntity` > 0),
81+ `p'rice` DECIMAL(10,2) NOT NULL CHECK (`p'rice` >= 0),
82+ FOREIGN KEY (`'order'_'id'`) REFERENCES "orders"(order_id) ON DELETE CASCADE,
83+ FOREIGN KEY (`product'_'id`) REFERENCES "prod'ucts"("product`_`id") ON DELETE CASCADE,
84+ UNIQUE KEY (`'order'_'id'`, `product'_'id`)
85+ );
86+
87+ --exec $MYSQL_DUMP bug37607195 --init-command="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'" --result-file=$grep_file 2>&1
88+
89+ --echo # Table 1: `'order'_'items'`
90+ --echo # `qua\ntity` must be escaped
91+ let $grep_pattern=qr| `qua\ntity` INT NOT NULL CHECK (`qua\ntity` > 0)|;
92+ --source include/grep_pattern.inc
93+
94+ --echo # Table 2: "custo`mers"
95+ --echo # "custo`mers" must be escaped
96+ let $grep_pattern=qr|CREATE TABLE `custo``mers`|;
97+ --source include/grep_pattern.inc
98+
99+ --echo # `pho"\ne` must be escaped
100+ let $grep_pattern=qr|`pho"\ne` varchar(15) DEFAULT NULL|;
101+ --source include/grep_pattern.inc
102+
103+ --echo # Table 3: "orders"
104+ --echo # `total\n` must be escaped
105+ let $grep_pattern=qr|`total\n` decimal(10,2) NOT NULL|;
106+ --source include/grep_pattern.inc
107+
108+ --echo # FOREIGN KEY (`customer_id`) REFERENCES must be escaped
109+ let $grep_pattern=qr|REFERENCES `custo``mers`|;
110+ --source include/grep_pattern.inc
111+
112+ --echo # Table 4: `prod'ucts`
113+ --echo # "descri`p`t`i`o`n" TEXT must be escaped
114+ let $grep_pattern=qr|`descri``p``t``i``o``n` text|;
115+ --source include/grep_pattern.inc
116+
117+ --echo # `stock"_"qua\ntity` must be escaped
118+ let $grep_pattern=qr|`stock"_"qua\ntity` int DEFAULT '0'|;
119+ --source include/grep_pattern.inc
120+
121+ 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';
122+
123+ # Cleanup
124+ --remove_file $grep_file
125+ DROP DATABASE bug37607195;
0 commit comments