Skip to content

Commit 4d4826d

Browse files
committed
Merge branch 'mysql-5.7' into mysql-5.7-cluster-7.6
Change-Id: I446a38597730c6af2d91ea0891be4ad65c099ab3
2 parents 4c61d4e + 3d680eb commit 4d4826d

21 files changed

+254
-43
lines changed

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2006, 2023, Oracle and/or its affiliates.
1+
# Copyright (c) 2006, 2025, Oracle and/or its affiliates.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0,
@@ -712,6 +712,13 @@ IF(CMAKE_COMPILER_IS_GNUCXX AND NOT GXX_VERSION VERSION_LESS 9)
712712
STRING_APPEND(CMAKE_CXX_FLAGS " -Wno-class-memaccess")
713713
ENDIF()
714714

715+
# Modern gcc versions will reject e.g. Bitmap<64>()
716+
# saying it is illegal in C++20
717+
MY_CHECK_CXX_COMPILER_WARNING("-Wtemplate-id-cdtor" HAS_WARN_FLAG)
718+
IF(HAS_WARN_FLAG)
719+
STRING_APPEND(CMAKE_CXX_FLAGS " ${HAS_WARN_FLAG}")
720+
ENDIF()
721+
715722
IF(NOT WITHOUT_SERVER)
716723
SET (MYSQLD_STATIC_PLUGIN_LIBS "" CACHE INTERNAL "")
717724
SET (MYSQLD_STATIC_EMBEDDED_PLUGIN_LIBS "" CACHE INTERNAL "")

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
MYSQL_VERSION_MAJOR=5
22
MYSQL_VERSION_MINOR=7
3-
MYSQL_VERSION_PATCH=49
3+
MYSQL_VERSION_PATCH=50
44
MYSQL_VERSION_EXTRA=-ndb-7.6.34

client/mysqldump.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
2+
Copyright (c) 2000, 2025, Oracle and/or its affiliates.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License, version 2.0,
@@ -2356,7 +2356,7 @@ static void fprintf_string(char *row, ulong row_len, char quote,
23562356
pbuffer = (char *)my_malloc(PSI_NOT_INSTRUMENTED, curr_row_size, MYF(0));
23572357

23582358
// Put the sanitized row in the buffer.
2359-
mysql_real_escape_string_quote(mysql, pbuffer, row, row_len, '\'');
2359+
mysql_real_escape_string_quote(mysql, pbuffer, row, row_len, quote);
23602360

23612361
// Opening quote
23622362
fputc(quote, md_result_file);
@@ -4658,7 +4658,7 @@ static int dump_tablespaces(char* ts_where)
46584658
mysql_free_result(tableres);
46594659
mysql_query_with_error_report(
46604660
mysql, &tableres,
4661-
"SELECT 'TN; /*' AS TABLESPACE_NAME, 'FN' AS FILE_NAME, 'LGN' AS "
4661+
"SELECT 'T`N; /*' AS TABLESPACE_NAME, 'FN' AS FILE_NAME, 'LGN' AS "
46624662
"LOGFILE_GROUP_NAME, 77 AS EXTENT_SIZE, 88 AS INITIAL_SIZE, "
46634663
"'*/\nsystem touch foo;\n' AS ENGINE");
46644664
});
@@ -6269,6 +6269,8 @@ static my_bool get_view_structure(char *table, char* db)
62696269
char *result_table, *opt_quoted_table;
62706270
char table_buff[NAME_LEN*2+3];
62716271
char table_buff2[NAME_LEN*2+3];
6272+
char table_string_buff[NAME_LEN * 2 + 3];
6273+
char db_string_buff[NAME_LEN * 2 + 3];
62726274
char query[QUERY_LENGTH];
62736275
FILE *sql_file= md_result_file;
62746276
my_bool freemem= FALSE;
@@ -6282,6 +6284,15 @@ static my_bool get_view_structure(char *table, char* db)
62826284

62836285
result_table= quote_name(table, table_buff, 1);
62846286
opt_quoted_table= quote_name(table, table_buff2, 0);
6287+
if (((ulong)-1 == mysql_real_escape_string_quote(mysql, table_string_buff,
6288+
table, strlen(table),
6289+
'\'')) ||
6290+
((ulong)-1 == mysql_real_escape_string_quote(mysql, db_string_buff, db,
6291+
strlen(db), '\''))) {
6292+
DB_error(mysql,
6293+
"when trying to quote table and db names when dumping views.");
6294+
DBUG_RETURN(1);
6295+
}
62856296

62866297
if (switch_character_set_results(mysql, "binary"))
62876298
DBUG_RETURN(1);
@@ -6329,7 +6340,8 @@ static my_bool get_view_structure(char *table, char* db)
63296340
"SELECT CHECK_OPTION, DEFINER, SECURITY_TYPE, "
63306341
" CHARACTER_SET_CLIENT, COLLATION_CONNECTION "
63316342
"FROM information_schema.views "
6332-
"WHERE table_name=\"%s\" AND table_schema=\"%s\"", table, db);
6343+
"WHERE table_name=\"%s\" AND table_schema=\"%s\"",
6344+
table_string_buff, db_string_buff);
63336345

63346346
if (mysql_query(mysql, query))
63356347
{

include/sql_string.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef SQL_STRING_INCLUDED
22
#define SQL_STRING_INCLUDED
33

4-
/* Copyright (c) 2000, 2023, Oracle and/or its affiliates.
4+
/* Copyright (c) 2000, 2025, Oracle and/or its affiliates.
55
66
This program is free software; you can redistribute it and/or modify
77
it under the terms of the GNU General Public License, version 2.0,
@@ -79,6 +79,8 @@ class Simple_cstring
7979
{
8080
set(arg.str, arg.length);
8181
}
82+
Simple_cstring(const LEX_CSTRING arg) { set(arg.str, arg.length); }
83+
8284
void reset()
8385
{
8486
set(NULL, 0);

mysql-test/lsan.supp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, 2023, Oracle and/or its affiliates.
1+
# Copyright (c) 2018, 2025, Oracle and/or its affiliates.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0,
@@ -25,3 +25,9 @@
2525
leak:Perl_safesyscalloc
2626
leak:Perl_safesysmalloc
2727
leak:Perl_safesysrealloc
28+
leak:Perl_savesharedpv
29+
leak:Perl_Slab_Alloc
30+
leak:Perl_newUNOP_AUX
31+
leak:Perl_newSTATEOP
32+
leak:Perl_pmruntime
33+
leak:/lib64/libperl.so.*

mysql-test/r/mysqldump-tablespace-escape.result

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,78 @@
22
# Bug#36816986 - MySQL Shell command injection
33
#
44
CREATE DATABASE bug36816986;
5+
USE bug36816986;
56
-- Run mysqldump with tablespace_injection_test.
67
The test injected string must be found:
78
Pattern found.
9+
The ` must be escaped:
10+
Pattern found.
811
DROP DATABASE bug36816986;
12+
13+
#######################################
14+
15+
#
16+
# Bug#37607195 - fprintf_string not using the actual quote parameter
17+
#
18+
CREATE DATABASE bug37607195;
19+
USE bug37607195;
20+
Create a bunch of tables with numerous ` ' " \n etc.
21+
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';
22+
CREATE TABLE "custo`mers" (
23+
"customer'_id" INT AUTO_INCREMENT PRIMARY KEY,
24+
"fir`st_`na`me" VARCHAR(50) NOT NULL,
25+
"last_'name" VARCHAR(50) NOT NULL,
26+
"em`ail" VARCHAR(100) UNIQUE NOT NULL,
27+
`pho"\ne` VARCHAR(15),
28+
"created'_'at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
29+
"updated'_'at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
30+
);
31+
CREATE TABLE "prod'ucts" (
32+
"product`_`id" INT AUTO_INCREMENT PRIMARY KEY,
33+
"product'_`name" VARCHAR(100) NOT NULL,
34+
"descri`p`t`i`o`n" TEXT,
35+
"pr'i'ce" DECIMAL(10, 2) NOT NULL CHECK ("pr'i'ce" >= 0),
36+
`stock"_"qua\ntity` INT DEFAULT 0,
37+
`created'_'at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
38+
`updated"_'at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
39+
INDEX ("product'_`name")
40+
);
41+
CREATE TABLE "orders" (
42+
"order_id" INT AUTO_INCREMENT PRIMARY KEY,
43+
"customer_id" INT NOT NULL,
44+
"order_date" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
45+
"status" ENUM('Pending', 'Completed', 'Cancelled') NOT NULL,
46+
"total\n" DECIMAL(10, 2) NOT NULL CHECK ("total\n" >= 0),
47+
FOREIGN KEY (customer_id) REFERENCES "custo`mers"("customer'_id") ON DELETE CASCADE,
48+
INDEX (order_date)
49+
);
50+
CREATE TABLE `'order'_'items'` (
51+
`order'_'item_id` INT AUTO_INCREMENT PRIMARY KEY,
52+
`'order'_'id'` INT NOT NULL,
53+
`product'_'id` INT NOT NULL,
54+
`qua\ntity` INT NOT NULL CHECK (`qua\ntity` > 0),
55+
`p'rice` DECIMAL(10,2) NOT NULL CHECK (`p'rice` >= 0),
56+
FOREIGN KEY (`'order'_'id'`) REFERENCES "orders"(order_id) ON DELETE CASCADE,
57+
FOREIGN KEY (`product'_'id`) REFERENCES "prod'ucts"("product`_`id") ON DELETE CASCADE,
58+
UNIQUE KEY (`'order'_'id'`, `product'_'id`)
59+
);
60+
# Table 1: `'order'_'items'`
61+
# `qua\ntity` must be escaped
62+
Pattern found.
63+
# Table 2: "custo`mers"
64+
# "custo`mers" must be escaped
65+
Pattern found.
66+
# `pho"\ne` must be escaped
67+
Pattern found.
68+
# Table 3: "orders"
69+
# `total\n` must be escaped
70+
Pattern found.
71+
# FOREIGN KEY (`customer_id`) REFERENCES must be escaped
72+
Pattern found.
73+
# Table 4: `prod'ucts`
74+
# "descri`p`t`i`o`n" TEXT must be escaped
75+
Pattern found.
76+
# `stock"_"qua\ntity` must be escaped
77+
Pattern found.
78+
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';
79+
DROP DATABASE bug37607195;

mysql-test/t/mysqldump-tablespace-escape.test

Lines changed: 107 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ let $grep_file= $MYSQLTEST_VARDIR/tmp/bug36816986.sql;
88
let $grep_output=boolean;
99

1010
CREATE 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;
1617
let $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
2125
DROP 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;

sql-common/sql_string.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2023, Oracle and/or its affiliates.
1+
/* Copyright (c) 2000, 2025, Oracle and/or its affiliates.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -1305,8 +1305,7 @@ size_t bin_to_hex_str(char *to, size_t to_len, char *from, size_t from_len)
13051305
prefix for a character, i.e. the byte length
13061306
of that invalid character is undefined.
13071307
1308-
@retval true if the whole input byte sequence is a valid character string.
1309-
The length_error output parameter is undefined.
1308+
@retval true if the input is invalid.
13101309
13111310
@return
13121311
if the whole input byte sequence is a valid character string

sql/item.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef ITEM_INCLUDED
22
#define ITEM_INCLUDED
33

4-
/* Copyright (c) 2000, 2023, Oracle and/or its affiliates.
4+
/* Copyright (c) 2000, 2025, Oracle and/or its affiliates.
55
66
This program is free software; you can redistribute it and/or modify
77
it under the terms of the GNU General Public License, version 2.0,
@@ -255,6 +255,7 @@ class Name_string: public Simple_cstring
255255
Name_string(const char *str, size_t length):
256256
Simple_cstring(str, length) {}
257257
Name_string(const LEX_STRING str): Simple_cstring(str) {}
258+
Name_string(const LEX_CSTRING str) : Simple_cstring(str) {}
258259
Name_string(const char *str, size_t length, bool is_null_terminated):
259260
Simple_cstring()
260261
{

sql/item_func.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2023, Oracle and/or its affiliates.
1+
/* Copyright (c) 2000, 2025, Oracle and/or its affiliates.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -4912,7 +4912,7 @@ longlong Item_master_pos_wait::val_int()
49124912
return 0;
49134913
}
49144914

4915-
mi= channel_map.get_mi(channel_str->ptr());
4915+
mi = channel_map.get_mi(channel_str->c_ptr_safe());
49164916

49174917
}
49184918
else

sql/parse_tree_items.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2013, 2023, Oracle and/or its affiliates.
1+
/* Copyright (c) 2013, 2025, Oracle and/or its affiliates.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -190,7 +190,7 @@ bool PTI_expr_with_alias::itemize(Parse_context *pc, Item **res)
190190
if (alias.str)
191191
{
192192
if (pc->thd->lex->sql_command == SQLCOM_CREATE_VIEW &&
193-
check_column_name(alias.str))
193+
check_column_name(alias))
194194
{
195195
my_error(ER_WRONG_COLUMN_NAME, MYF(0), alias.str);
196196
return true;

sql/sql_class.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2023, Oracle and/or its affiliates.
1+
/* Copyright (c) 2000, 2025, Oracle and/or its affiliates.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -5507,7 +5507,7 @@ class user_var_entry
55075507
*/
55085508
static user_var_entry *create(THD *thd, const Name_string &name, const CHARSET_INFO *cs)
55095509
{
5510-
if (check_column_name(name.ptr()))
5510+
if (check_column_name(name))
55115511
{
55125512
my_error(ER_ILLEGAL_USER_VAR, MYF(0), name.ptr());
55135513
return NULL;

0 commit comments

Comments
 (0)