Skip to content
/ server Public
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 0 additions & 43 deletions mysql-test/main/comments.result
Original file line number Diff line number Diff line change
Expand Up @@ -120,46 +120,3 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
prepare bar from "DELETE FROM table_28779 WHERE a = 7 OR 1=1/*!998765' AND b = 'bar';*";
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '/*!998765' AND b = 'bar';*' at line 1
drop table table_28779;
#
# MDEV-7381: Reversed executable comments
#
# Server version is >= 100000, so reversed comments with version
# <= current should NOT execute (server is not older than that version).
SELECT 1 /*!!50101 +1 */;
1
1
SELECT 1 /*!!100000 +1 */;
1
1
# Reversed comment with version higher than current SHOULD execute.
SELECT 1 /*!!999999 +1 */;
1 +1
2
# MariaDB-specific reversed executable comments
SELECT 1 /*M!!50101 +1 */;
1
1
SELECT 1 /*M!!999999 +1 */;
1 +1
2
# Without version number (just /*!! with no digits) should still work
# as a regular executable comment expanding the content.
SELECT 1 /*!! +1 */;
1 +1
2
SELECT 1 /*M!! +1 */;
1 +1
2
# Combined forward and reversed in the same statement (MDEV-7381 use case).
# On this server (>= 10.0.0): /*!100000 OR REPLACE */ executes,
# /*!!100000 IF NOT EXISTS */ is skipped.
# Effective statement: CREATE OR REPLACE TABLE t1 (a INT);
CREATE /*!100000 OR REPLACE */ TABLE /*!!100000 IF NOT EXISTS */ t1 (a INT);
INSERT INTO t1 VALUES (1);
# Run again. OR REPLACE should drop and recreate the table, losing the row.
CREATE /*!100000 OR REPLACE */ TABLE /*!!100000 IF NOT EXISTS */ t1 (a INT);
# Table should be empty, proving OR REPLACE was used (not IF NOT EXISTS).
SELECT COUNT(*) FROM t1;
COUNT(*)
0
DROP TABLE t1;
33 changes: 0 additions & 33 deletions mysql-test/main/comments.test
Original file line number Diff line number Diff line change
Expand Up @@ -101,36 +101,3 @@ prepare bar from "DELETE FROM table_28779 WHERE a = 7 OR 1=1/*!998765' AND b = '

drop table table_28779;


--echo #
--echo # MDEV-7381: Reversed executable comments
--echo #

--echo # Server version is >= 100000, so reversed comments with version
--echo # <= current should NOT execute (server is not older than that version).
SELECT 1 /*!!50101 +1 */;
SELECT 1 /*!!100000 +1 */;

--echo # Reversed comment with version higher than current SHOULD execute.
SELECT 1 /*!!999999 +1 */;

--echo # MariaDB-specific reversed executable comments
SELECT 1 /*M!!50101 +1 */;
SELECT 1 /*M!!999999 +1 */;

--echo # Without version number (just /*!! with no digits) should still work
--echo # as a regular executable comment expanding the content.
SELECT 1 /*!! +1 */;
SELECT 1 /*M!! +1 */;

--echo # Combined forward and reversed in the same statement (MDEV-7381 use case).
--echo # On this server (>= 10.0.0): /*!100000 OR REPLACE */ executes,
--echo # /*!!100000 IF NOT EXISTS */ is skipped.
--echo # Effective statement: CREATE OR REPLACE TABLE t1 (a INT);
CREATE /*!100000 OR REPLACE */ TABLE /*!!100000 IF NOT EXISTS */ t1 (a INT);
INSERT INTO t1 VALUES (1);
--echo # Run again. OR REPLACE should drop and recreate the table, losing the row.
CREATE /*!100000 OR REPLACE */ TABLE /*!!100000 IF NOT EXISTS */ t1 (a INT);
--echo # Table should be empty, proving OR REPLACE was used (not IF NOT EXISTS).
SELECT COUNT(*) FROM t1;
DROP TABLE t1;
12 changes: 12 additions & 0 deletions mysql-test/main/mdev_38904.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# MDEV-38904: latin7 collation corruption
#
CREATE TABLE t1 (
c1 VARCHAR(10) CHARACTER SET latin7 COLLATE latin7_general_ci,
KEY(c1)
) ENGINE=InnoDB;
INSERT INTO t1 VALUES ('a-b'), ('a b');
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
15 changes: 15 additions & 0 deletions mysql-test/main/mdev_38904.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--source include/have_innodb.inc

--echo #
--echo # MDEV-38904: latin7 collation corruption
--echo #

CREATE TABLE t1 (
c1 VARCHAR(10) CHARACTER SET latin7 COLLATE latin7_general_ci,
KEY(c1)
) ENGINE=InnoDB;

INSERT INTO t1 VALUES ('a-b'), ('a b');
CHECK TABLE t1;

DROP TABLE t1;
20 changes: 3 additions & 17 deletions mysql-test/suite/plugins/r/server_audit.result
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,6 @@ select 3;
7
7
/*M!999999 SELECT 'should not log' */;
/*!! SELECT 8 */;
8
8
/*!!999999 SELECT 9 */;
9
9
/*!!100100 SELECT 'reversed should not log' */;
/*M!!999999 SELECT 10 */;
10
10
/*M!!100100 SELECT 'reversed should not log' */;
drop table t1;
set global server_audit_events='query_dcl';
create table t1(id int);
Expand Down Expand Up @@ -306,7 +295,7 @@ set global server_audit_logging= off;
set global server_audit_incl_users='root';
set global server_audit_logging= on;
disconnect cn1;
Line count in file: 169
Line count in file: 166
drop user user1@localhost;
set global server_audit_events='';
set global server_audit_incl_users='root, plug_dest, ssl_user1';
Expand All @@ -322,7 +311,7 @@ USER() CURRENT_USER()
plug@localhost plug_dest@%
connection default;
disconnect plug_con;
Line count in file: 203
Line count in file: 200
DROP USER plug;
DROP USER plug_dest;
CREATE USER ssl_user1@localhost require SSL;
Expand All @@ -332,7 +321,7 @@ select variable_value > '' as 'have_ssl' from information_schema.session_status
have_ssl
1
disconnect conssl1;
Line count in file: 234
Line count in file: 231
connection default;
DROP USER ssl_user1@localhost;
set global server_audit_query_log_limit= 15;
Expand Down Expand Up @@ -552,9 +541,6 @@ TIME,HOSTNAME,root,localhost:PORT,ID,ID,QUERY,sa_db,'/*! SELECT 4 */',0
TIME,HOSTNAME,root,localhost:PORT,ID,ID,QUERY,sa_db,'/*M! SELECT 5 */',0
TIME,HOSTNAME,root,localhost:PORT,ID,ID,QUERY,sa_db,'/*!100100 SELECT 6 */',0
TIME,HOSTNAME,root,localhost:PORT,ID,ID,QUERY,sa_db,'/*M!100100 SELECT 7 */',0
TIME,HOSTNAME,root,localhost:PORT,ID,ID,QUERY,sa_db,'/*!! SELECT 8 */',0
TIME,HOSTNAME,root,localhost:PORT,ID,ID,QUERY,sa_db,'/*!!999999 SELECT 9 */',0
TIME,HOSTNAME,root,localhost:PORT,ID,ID,QUERY,sa_db,'/*M!!999999 SELECT 10 */',0
TIME,HOSTNAME,root,localhost:PORT,ID,ID,QUERY,sa_db,'CREATE USER u1 IDENTIFIED BY *****',0
TIME,HOSTNAME,root,localhost:PORT,ID,ID,QUERY,sa_db,'GRANT ALL ON sa_db TO u2 IDENTIFIED BY *****',0
TIME,HOSTNAME,root,localhost:PORT,ID,ID,QUERY,sa_db,'CREATE USER u3 IDENTIFIED BY *****',0
Expand Down
12 changes: 3 additions & 9 deletions mysql-test/suite/plugins/t/server_audit.test
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,6 @@ query /*!999999 SELECT 'should not log' */;
query /*M!100100 SELECT 7 */;
query /*M!999999 SELECT 'should not log' */;

query /*!! SELECT 8 */;
query /*!!999999 SELECT 9 */;
query /*!!100100 SELECT 'reversed should not log' */;
query /*M!!999999 SELECT 10 */;
query /*M!!100100 SELECT 'reversed should not log' */;

drop table t1;
set global server_audit_events='query_dcl';
create table t1(id int);
Expand Down Expand Up @@ -236,7 +230,7 @@ set global server_audit_logging= off;
set global server_audit_incl_users='root';
set global server_audit_logging= on;
disconnect cn1;
let SEARCH_COUNT= 169;
let SEARCH_COUNT= 166;
source include/wait_for_line_count_in_file.inc;

drop user user1@localhost;
Expand All @@ -257,7 +251,7 @@ connect(plug_con,localhost,plug,plug_dest,"*NO-ONE*");
select USER(),CURRENT_USER();
connection default;
disconnect plug_con;
let SEARCH_COUNT= 203;
let SEARCH_COUNT= 200;
source include/wait_for_line_count_in_file.inc;
DROP USER plug;
DROP USER plug_dest;
Expand All @@ -268,7 +262,7 @@ connect (conssl1,localhost,ssl_user1,,sa_db,,,SSL);
--let $ssl_version = query_get_value(SHOW STATUS LIKE 'Ssl_version', Value, 1)
select variable_value > '' as 'have_ssl' from information_schema.session_status where variable_name='ssl_cipher';
disconnect conssl1;
let SEARCH_COUNT= 234;
let SEARCH_COUNT= 231;
source include/wait_for_line_count_in_file.inc;
connection default;
DROP USER ssl_user1@localhost;
Expand Down
25 changes: 10 additions & 15 deletions sql/rpl_master_info_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ inline const char *master_ssl_key = "";
inline const char *master_ssl_cipher = "";
inline bool master_ssl_verify_server_cert= true;
/// `ulong` is the data type `my_getopt` expects.
inline ulong master_use_gtid= static_cast<ulong>(enum_master_use_gtid::DEFAULT);
inline auto master_use_gtid= static_cast<ulong>(enum_master_use_gtid::DEFAULT);
inline uint64_t master_retry_count= 100000;
/// }@

Expand Down Expand Up @@ -612,11 +612,9 @@ struct Master_info_file: Info_file
ignore_server_ids(ignore_server_ids),
do_domain_ids(do_domain_ids), ignore_domain_ids(ignore_domain_ids)
{
for (std::unordered_map<std::string_view,
const Mem_fn>::const_iterator it= VALUE_MAP.begin();
it != VALUE_MAP.end(); ++it)
if (it->second)
it->second(this).set_default();
for(auto &[_, mem_fn]: VALUE_MAP)
if (mem_fn)
mem_fn(this).set_default();
}

bool load_from_file() override
Expand Down Expand Up @@ -697,27 +695,24 @@ break_for:;
/* Write MariaDB `key=value` lines:
The "value" can then be written individually after generating the`key=`.
*/
for (std::unordered_map<std::string_view,
const Mem_fn>::const_iterator it= VALUE_MAP.begin();
it != VALUE_MAP.end(); ++it)
{
if (it->second)
for (auto &[key, pm]: VALUE_MAP)
if (pm)
{
Persistent &value= it->second(this);
Persistent &value= pm(this);
my_b_write(&file,
reinterpret_cast<const uchar *>(it->first.data()), it->first.size());
reinterpret_cast<const uchar *>(key.data()), key.size());
if (!value.is_default())
{
my_b_write_byte(&file, '=');
value.save_to(&file);
}
my_b_write_byte(&file, '\n');
}
}
my_b_write(&file, reinterpret_cast<const uchar *>(END_MARKER),
sizeof(END_MARKER) - /* the '\0' */ 1);
sizeof(END_MARKER) - /* the '\0' */ 1);
my_b_write_byte(&file, '\n');
}

};

#endif // C++ standard guard
Expand Down
21 changes: 2 additions & 19 deletions sql/sql_lex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2425,16 +2425,6 @@ int Lex_input_stream::lex_one_token(YYSTYPE *yylval, THD *thd)
set_echo(FALSE);
yySkipn(maria_comment_syntax ? 4 : 3);

/*
Check for reversed executable comment syntax: '/' '*' '!' '!'
A reversed comment is executed only on versions OLDER than
the specified version (i.e. when MYSQL_VERSION_ID < version).
See MDEV-7381.
*/
bool reversed_comment= (yyPeekn(0) == '!');
if (reversed_comment)
yySkipn(1);

/*
The special comment format is very strict:
'/' '*' '!', followed by an optional 'M' and exactly
Expand Down Expand Up @@ -2468,16 +2458,9 @@ int Lex_input_stream::lex_one_token(YYSTYPE *yylval, THD *thd)
MariaDB-10.0 does not understand. Ignore all versioned comments
with MySQL versions in the range 50700-999999, but
do not ignore MariaDB specific comments for the same versions.

Reversed executable comments (MDEV-7381): execute the content
only when the server version is strictly less than the specified
version. The MySQL 5.7 range exclusion does not apply to
reversed comments.
*/
if ((!reversed_comment &&
version <= MYSQL_VERSION_ID &&
(version < 50700 || version > 99999 || maria_comment_syntax)) ||
(reversed_comment && MYSQL_VERSION_ID < version))
if (version <= MYSQL_VERSION_ID &&
(version < 50700 || version > 99999 || maria_comment_syntax))
{
/* Accept 'M' 'm' 'm' 'd' 'd' */
yySkipn(length);
Expand Down
Loading