diff options
47 files changed, 992 insertions, 483 deletions
diff --git a/cmake/build_configurations/mysql_release.cmake b/cmake/build_configurations/mysql_release.cmake index a19470e6df1..e4e854d1d20 100644 --- a/cmake/build_configurations/mysql_release.cmake +++ b/cmake/build_configurations/mysql_release.cmake @@ -1,5 +1,5 @@ # Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2011, 2021, MariaDB Corporation. +# Copyright (c) 2011, 2022, MariaDB Corporation. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -105,12 +105,12 @@ ELSEIF(RPM) SET(SEMODULE_PACKAGE /usr/bin/semodule_package CACHE FILEPATH "") SET(WITH_JEMALLOC "yes" CACHE STRING "") SET(PLUGIN_AUTH_SOCKET YES CACHE STRING "") - IF(RPM MATCHES "fedora|centos|rhel") + IF(RPM MATCHES "fedora|centos|rhel|rocky|alma") SET(WITH_INNODB_BZIP2 OFF CACHE STRING "") SET(WITH_INNODB_LZO OFF CACHE STRING "") SET(WITH_ROCKSDB_BZip2 OFF CACHE STRING "") ENDIF() - IF(RPM MATCHES "opensuse|sles|centos|rhel") + IF(RPM MATCHES "opensuse|sles|centos|rhel|rocky|alma") SET(WITH_INNODB_LZ4 OFF CACHE STRING "") SET(WITH_ROCKSDB_LZ4 OFF CACHE STRING "") SET(GRN_WITH_LZ4 no CACHE STRING "") diff --git a/extra/mariabackup/changed_page_bitmap.cc b/extra/mariabackup/changed_page_bitmap.cc index ac67bb9b924..793d7378b0f 100644 --- a/extra/mariabackup/changed_page_bitmap.cc +++ b/extra/mariabackup/changed_page_bitmap.cc @@ -455,7 +455,7 @@ log_online_open_bitmap_file_read_only( bitmap_file->size = os_file_get_size(bitmap_file->file); bitmap_file->offset = 0; -#ifdef UNIV_LINUX +#ifdef __linux__ posix_fadvise(bitmap_file->file, 0, 0, POSIX_FADV_SEQUENTIAL); posix_fadvise(bitmap_file->file, 0, 0, POSIX_FADV_NOREUSE); #endif diff --git a/include/my_global.h b/include/my_global.h index a4c694fd196..b60fa59dfaa 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -1088,7 +1088,7 @@ static inline char *dlerror(void) { static char win_errormsg[2048]; FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, - 0, GetLastError(), 0, win_errormsg, 2048, NULL); + 0, GetLastError(), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), win_errormsg, 2048, NULL); return win_errormsg; } #define HAVE_DLOPEN 1 diff --git a/mysql-test/main/binary_to_hex.result b/mysql-test/main/binary_to_hex.result index 6ea17e4ec93..0438f89332b 100644 --- a/mysql-test/main/binary_to_hex.result +++ b/mysql-test/main/binary_to_hex.result @@ -21,7 +21,7 @@ t1 CREATE TABLE `t1` ( `c7` binary(1) DEFAULT NULL, `c8` varbinary(10) DEFAULT NULL, `c9` geometry DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=binary COLLATE=binary +) ENGINE=MyISAM DEFAULT CHARSET=binary INSERT INTO t1 VALUES ('tinyblob-text readable', 'blob-text readable', 'mediumblob-text readable', 'longblob-text readable', 'text readable', b'1', 'c', 'variable', diff --git a/mysql-test/main/ctype_binary.result b/mysql-test/main/ctype_binary.result index 1c0a2c433e1..02aa08272c1 100644 --- a/mysql-test/main/ctype_binary.result +++ b/mysql-test/main/ctype_binary.result @@ -3180,7 +3180,7 @@ CREATE TABLE t1(a ENUM(0x6100,0x6200,0x6300) CHARACTER SET 'Binary'); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` enum('a\0','b\0','c\0') CHARACTER SET binary COLLATE binary DEFAULT NULL + `a` enum('a\0','b\0','c\0') CHARACTER SET binary DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT INTO t1 VALUES (1),(2),(3); SELECT HEX(a) FROM t1 ORDER BY a; @@ -3281,7 +3281,7 @@ CREATE TABLE t1(c ENUM(0x0061) CHARACTER SET 'Binary', d JSON); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `c` enum('\0a') CHARACTER SET binary COLLATE binary DEFAULT NULL, + `c` enum('\0a') CHARACTER SET binary DEFAULT NULL, `d` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`d`)) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT INTO t1 (c) VALUES (1); @@ -3296,7 +3296,7 @@ d INT DEFAULT NULL CHECK (d>0) SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `c` enum('\0a') CHARACTER SET binary COLLATE binary DEFAULT NULL, + `c` enum('\0a') CHARACTER SET binary DEFAULT NULL, `d` int(11) DEFAULT NULL CHECK (`d` > 0) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT INTO t1 VALUES (1,1); @@ -3308,7 +3308,7 @@ CREATE TABLE t1(c ENUM(0x0061) CHARACTER SET 'Binary' CHECK (c>0)); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `c` enum('\0a') CHARACTER SET binary COLLATE binary DEFAULT NULL CHECK (`c` > 0) + `c` enum('\0a') CHARACTER SET binary DEFAULT NULL CHECK (`c` > 0) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT INTO t1 VALUES (1); SELECT HEX(c) FROM t1; @@ -3318,3 +3318,47 @@ DROP TABLE t1; # # End of 10.2 tests # +# +# Start of 10.3 tests +# +# +# MDEV-29561 SHOW CREATE TABLE produces syntactically incorrect structure +# +CREATE TABLE t1 (a ENUM('x') CHARACTER SET BINARY); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('x') CHARACTER SET binary DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +DROP TABLE t1; +CREATE TABLE `t1` ( + `a` enum('x') CHARACTER SET binary DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +DROP TABLE t1; +CREATE TABLE t1 (a INT ) CHARSET=binary; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=binary +DROP TABLE t1; +CREATE DATABASE db1 CHARACTER SET BINARY; +SHOW CREATE DATABASE db1; +Database Create Database +db1 CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET binary */ +DROP DATABASE db1; +CREATE FUNCTION f1() RETURNS ENUM('a') CHARACTER SET binary RETURN NULL; +SHOW CREATE FUNCTION f1; +Function sql_mode Create Function character_set_client collation_connection Database Collation +f1 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS enum('a') CHARSET binary +RETURN NULL latin1 latin1_swedish_ci latin1_swedish_ci +DROP FUNCTION f1; +CREATE FUNCTION f1(a ENUM('a') CHARACTER SET binary) RETURNS INT RETURN NULL; +SHOW CREATE FUNCTION f1; +Function sql_mode Create Function character_set_client collation_connection Database Collation +f1 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f1`(a ENUM('a') CHARACTER SET binary) RETURNS int(11) +RETURN NULL latin1 latin1_swedish_ci latin1_swedish_ci +DROP FUNCTION f1; +# +# End of 10.3 tests +# diff --git a/mysql-test/main/ctype_binary.test b/mysql-test/main/ctype_binary.test index b871a41309b..27870a9fc54 100644 --- a/mysql-test/main/ctype_binary.test +++ b/mysql-test/main/ctype_binary.test @@ -169,12 +169,42 @@ INSERT INTO t1 VALUES (1); SELECT HEX(c) FROM t1; DROP TABLE t1; +--echo # +--echo # End of 10.2 tests +--echo # + + +--echo # +--echo # Start of 10.3 tests +--echo # + +--echo # +--echo # MDEV-29561 SHOW CREATE TABLE produces syntactically incorrect structure +--echo # +CREATE TABLE t1 (a ENUM('x') CHARACTER SET BINARY); +SHOW CREATE TABLE t1; +let $def= query_get_value(show create table t1,'Create Table',1); +DROP TABLE t1; +eval $def; +DROP TABLE t1; +CREATE TABLE t1 (a INT ) CHARSET=binary; +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE DATABASE db1 CHARACTER SET BINARY; +SHOW CREATE DATABASE db1; +DROP DATABASE db1; +CREATE FUNCTION f1() RETURNS ENUM('a') CHARACTER SET binary RETURN NULL; +SHOW CREATE FUNCTION f1; +DROP FUNCTION f1; +CREATE FUNCTION f1(a ENUM('a') CHARACTER SET binary) RETURNS INT RETURN NULL; +SHOW CREATE FUNCTION f1; +DROP FUNCTION f1; --echo # ---echo # End of 10.2 tests +--echo # End of 10.3 tests --echo # diff --git a/mysql-test/main/ctype_utf16_uca.result b/mysql-test/main/ctype_utf16_uca.result index c930fb9bd94..5886cf483ba 100644 --- a/mysql-test/main/ctype_utf16_uca.result +++ b/mysql-test/main/ctype_utf16_uca.result @@ -7907,7 +7907,7 @@ CREATE TABLE t1(c ENUM('aaaaaaaa') CHARACTER SET 'Binary',d JSON); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `c` enum('\0a\0a\0a\0a\0a\0a\0a\0a') CHARACTER SET binary COLLATE binary DEFAULT NULL, + `c` enum('\0a\0a\0a\0a\0a\0a\0a\0a') CHARACTER SET binary DEFAULT NULL, `d` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`d`)) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT INTO t1 (c) VALUES (1); @@ -7919,7 +7919,7 @@ CREATE OR REPLACE TABLE t1(c ENUM('aaaaaaaaa') CHARACTER SET 'Binary',d JSON); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `c` enum('\0a\0a\0a\0a\0a\0a\0a\0a\0a') CHARACTER SET binary COLLATE binary DEFAULT NULL, + `c` enum('\0a\0a\0a\0a\0a\0a\0a\0a\0a') CHARACTER SET binary DEFAULT NULL, `d` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`d`)) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT INTO t1 (c) VALUES (1); @@ -7931,7 +7931,7 @@ CREATE OR REPLACE TABLE t1(c ENUM('aaaaaaaaaa') CHARACTER SET 'Binary',d JSON); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `c` enum('\0a\0a\0a\0a\0a\0a\0a\0a\0a\0a') CHARACTER SET binary COLLATE binary DEFAULT NULL, + `c` enum('\0a\0a\0a\0a\0a\0a\0a\0a\0a\0a') CHARACTER SET binary DEFAULT NULL, `d` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`d`)) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT INTO t1 (c) VALUES (1); diff --git a/mysql-test/main/ctype_utf32.result b/mysql-test/main/ctype_utf32.result index d45f996bcb2..a0f760cbdc0 100644 --- a/mysql-test/main/ctype_utf32.result +++ b/mysql-test/main/ctype_utf32.result @@ -2878,7 +2878,7 @@ CREATE TABLE t1(c1 ENUM('a','b','ac') CHARACTER SET 'Binary',c2 JSON,c3 INT); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `c1` enum('\0\0\0a','\0\0\0b','\0\0\0a\0\0\0c') CHARACTER SET binary COLLATE binary DEFAULT NULL, + `c1` enum('\0\0\0a','\0\0\0b','\0\0\0a\0\0\0c') CHARACTER SET binary DEFAULT NULL, `c2` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`c2`)), `c3` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci diff --git a/mysql-test/main/ctype_utf32_uca.result b/mysql-test/main/ctype_utf32_uca.result index e18446ac7a2..b26736f89cb 100644 --- a/mysql-test/main/ctype_utf32_uca.result +++ b/mysql-test/main/ctype_utf32_uca.result @@ -7969,7 +7969,7 @@ CREATE TABLE t1(c1 SET('a') COLLATE 'Binary',c2 JSON); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `c1` set('\0\0\0a') CHARACTER SET binary COLLATE binary DEFAULT NULL, + `c1` set('\0\0\0a') CHARACTER SET binary DEFAULT NULL, `c2` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`c2`)) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_rsu_wsrep_desync.result b/mysql-test/suite/galera/r/galera_rsu_wsrep_desync.result index 310611a0e49..54af2e68aa1 100644 --- a/mysql-test/suite/galera/r/galera_rsu_wsrep_desync.result +++ b/mysql-test/suite/galera/r/galera_rsu_wsrep_desync.result @@ -17,7 +17,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` int(11) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1 +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci SHOW VARIABLES LIKE 'wsrep_desync'; Variable_name Value wsrep_desync OFF @@ -44,7 +44,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` int(11) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1 +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci SET wsrep_OSU_method=TOI; DROP TABLE t1; SET DEBUG_SYNC= 'RESET'; diff --git a/mysql-test/suite/galera/r/galera_sync_wait_show.result b/mysql-test/suite/galera/r/galera_sync_wait_show.result index 793da3246ff..8f6f936806a 100644 --- a/mysql-test/suite/galera/r/galera_sync_wait_show.result +++ b/mysql-test/suite/galera/r/galera_sync_wait_show.result @@ -7,7 +7,7 @@ CREATE DATABASE db1; connection node_2; SHOW CREATE DATABASE db1; Database Create Database -db1 CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET latin1 */ +db1 CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci */ DROP DATABASE db1; connection node_1; CREATE PROCEDURE p1 () SELECT 1 FROM DUAL; diff --git a/mysql-test/suite/galera/r/galera_toi_ddl_error.result b/mysql-test/suite/galera/r/galera_toi_ddl_error.result index 386dc28bed3..9aec137d010 100644 --- a/mysql-test/suite/galera/r/galera_toi_ddl_error.result +++ b/mysql-test/suite/galera/r/galera_toi_ddl_error.result @@ -12,13 +12,13 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1 +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci connection node_1; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1 +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci DROP TABLE t1; DROP TABLE ten; CALL mtr.add_suppression("Ignoring error 'Duplicate entry '111110' for key 'PRIMARY'' on query."); diff --git a/mysql-test/suite/galera/r/lp1376747-4.result b/mysql-test/suite/galera/r/lp1376747-4.result index 9c021c3eac3..16141f0268d 100644 --- a/mysql-test/suite/galera/r/lp1376747-4.result +++ b/mysql-test/suite/galera/r/lp1376747-4.result @@ -16,7 +16,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `id` int(11) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci SET debug_sync='flush_tables_with_read_lock_after_acquire_locks SIGNAL parked2 WAIT_FOR go2'; FLUSH TABLES t1 WITH READ LOCK;; connection node_2; @@ -28,7 +28,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `id` int(11) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci connection node_2a; set debug_sync= 'RESET'; UNLOCK TABLES; @@ -39,7 +39,7 @@ t1 CREATE TABLE `t1` ( `id` int(11) NOT NULL, `f2` int(11) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci SELECT * from t1; id f2 1 NULL diff --git a/mysql-test/suite/innodb/r/innodb-system-table-view.result b/mysql-test/suite/innodb/r/innodb-system-table-view.result index 65dc0a8e274..85f0563437b 100644 --- a/mysql-test/suite/innodb/r/innodb-system-table-view.result +++ b/mysql-test/suite/innodb/r/innodb-system-table-view.result @@ -181,3 +181,10 @@ test/parent 1 2 DROP TABLE child; DROP TABLE parent; SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency; +# +# MDEV-29479 I_S.INNODB_SYS_TABLESPACES doesn't have +# temporary tablespace information +# +SELECT SPACE FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES WHERE name like 'innodb_temporary'; +SPACE +4294967294 diff --git a/mysql-test/suite/innodb/t/innodb-system-table-view.test b/mysql-test/suite/innodb/t/innodb-system-table-view.test index 4f5111eafbc..ea620b398e5 100644 --- a/mysql-test/suite/innodb/t/innodb-system-table-view.test +++ b/mysql-test/suite/innodb/t/innodb-system-table-view.test @@ -141,3 +141,9 @@ DROP TABLE child; DROP TABLE parent; SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency; + +--echo # +--echo # MDEV-29479 I_S.INNODB_SYS_TABLESPACES doesn't have +--echo # temporary tablespace information +--echo # +SELECT SPACE FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES WHERE name like 'innodb_temporary'; diff --git a/mysql-test/suite/roles/recursive_dbug.result b/mysql-test/suite/roles/recursive_dbug.result index 417602c5c60..6a86df655e7 100644 --- a/mysql-test/suite/roles/recursive_dbug.result +++ b/mysql-test/suite/roles/recursive_dbug.result @@ -56,7 +56,7 @@ connection default; grant select on *.* to role1; show status like 'debug%'; Variable_name Value -Debug_role_merges_global 19 +Debug_role_merges_global 20 Debug_role_merges_db 0 Debug_role_merges_table 0 Debug_role_merges_column 0 @@ -106,7 +106,7 @@ connection default; revoke select on *.* from role1; show status like 'debug%'; Variable_name Value -Debug_role_merges_global 27 +Debug_role_merges_global 29 Debug_role_merges_db 0 Debug_role_merges_table 0 Debug_role_merges_column 0 @@ -124,8 +124,8 @@ connection default; grant select on mysql.* to role1; show status like 'debug%'; Variable_name Value -Debug_role_merges_global 27 -Debug_role_merges_db 8 +Debug_role_merges_global 29 +Debug_role_merges_db 9 Debug_role_merges_table 0 Debug_role_merges_column 0 Debug_role_merges_routine 0 @@ -164,8 +164,8 @@ connection default; revoke select on mysql.* from role1; show status like 'debug%'; Variable_name Value -Debug_role_merges_global 27 -Debug_role_merges_db 16 +Debug_role_merges_global 29 +Debug_role_merges_db 17 Debug_role_merges_table 0 Debug_role_merges_column 0 Debug_role_merges_routine 0 @@ -177,9 +177,9 @@ connection default; grant select on mysql.roles_mapping to role1; show status like 'debug%'; Variable_name Value -Debug_role_merges_global 27 -Debug_role_merges_db 16 -Debug_role_merges_table 8 +Debug_role_merges_global 29 +Debug_role_merges_db 17 +Debug_role_merges_table 9 Debug_role_merges_column 0 Debug_role_merges_routine 0 connection foo; @@ -217,9 +217,9 @@ connection default; revoke select on mysql.roles_mapping from role1; show status like 'debug%'; Variable_name Value -Debug_role_merges_global 27 -Debug_role_merges_db 16 -Debug_role_merges_table 16 +Debug_role_merges_global 29 +Debug_role_merges_db 17 +Debug_role_merges_table 17 Debug_role_merges_column 0 Debug_role_merges_routine 0 connection foo; @@ -230,10 +230,10 @@ connection default; grant select(User) on mysql.roles_mapping to role1; show status like 'debug%'; Variable_name Value -Debug_role_merges_global 27 -Debug_role_merges_db 16 -Debug_role_merges_table 24 -Debug_role_merges_column 8 +Debug_role_merges_global 29 +Debug_role_merges_db 17 +Debug_role_merges_table 26 +Debug_role_merges_column 9 Debug_role_merges_routine 0 connection foo; select count(*) from mysql.roles_mapping; @@ -272,10 +272,10 @@ connection default; grant select(Host) on mysql.roles_mapping to role3; show status like 'debug%'; Variable_name Value -Debug_role_merges_global 27 -Debug_role_merges_db 16 -Debug_role_merges_table 30 -Debug_role_merges_column 14 +Debug_role_merges_global 29 +Debug_role_merges_db 17 +Debug_role_merges_table 33 +Debug_role_merges_column 16 Debug_role_merges_routine 0 connection foo; select count(concat(User,Host,Role)) from mysql.roles_mapping; @@ -312,10 +312,10 @@ connection default; revoke select(User) on mysql.roles_mapping from role1; show status like 'debug%'; Variable_name Value -Debug_role_merges_global 27 -Debug_role_merges_db 16 -Debug_role_merges_table 38 -Debug_role_merges_column 22 +Debug_role_merges_global 29 +Debug_role_merges_db 17 +Debug_role_merges_table 41 +Debug_role_merges_column 24 Debug_role_merges_routine 0 connection foo; select count(concat(User,Host)) from mysql.roles_mapping; @@ -327,10 +327,10 @@ connection default; revoke select(Host) on mysql.roles_mapping from role3; show status like 'debug%'; Variable_name Value -Debug_role_merges_global 27 -Debug_role_merges_db 16 -Debug_role_merges_table 44 -Debug_role_merges_column 28 +Debug_role_merges_global 29 +Debug_role_merges_db 17 +Debug_role_merges_table 47 +Debug_role_merges_column 30 Debug_role_merges_routine 0 connection foo; select count(concat(Host)) from mysql.roles_mapping; @@ -342,11 +342,11 @@ create function fn1() returns char(10) return "fn1"; grant execute on procedure test.pr1 to role1; show status like 'debug%'; Variable_name Value -Debug_role_merges_global 27 -Debug_role_merges_db 16 -Debug_role_merges_table 44 -Debug_role_merges_column 28 -Debug_role_merges_routine 8 +Debug_role_merges_global 29 +Debug_role_merges_db 17 +Debug_role_merges_table 47 +Debug_role_merges_column 30 +Debug_role_merges_routine 9 connection foo; call pr1(); ERROR 42000: execute command denied to user 'foo'@'localhost' for routine 'test.pr1' @@ -360,11 +360,11 @@ connection default; grant execute on function test.fn1 to role5; show status like 'debug%'; Variable_name Value -Debug_role_merges_global 27 -Debug_role_merges_db 16 -Debug_role_merges_table 44 -Debug_role_merges_column 28 -Debug_role_merges_routine 13 +Debug_role_merges_global 29 +Debug_role_merges_db 17 +Debug_role_merges_table 47 +Debug_role_merges_column 30 +Debug_role_merges_routine 15 connection foo; select fn1(); fn1() @@ -373,11 +373,11 @@ connection default; revoke execute on procedure test.pr1 from role1; show status like 'debug%'; Variable_name Value -Debug_role_merges_global 27 -Debug_role_merges_db 16 -Debug_role_merges_table 44 -Debug_role_merges_column 28 -Debug_role_merges_routine 21 +Debug_role_merges_global 29 +Debug_role_merges_db 17 +Debug_role_merges_table 47 +Debug_role_merges_column 30 +Debug_role_merges_routine 23 connection foo; call pr1(); ERROR 42000: execute command denied to user 'foo'@'localhost' for routine 'test.pr1' @@ -388,11 +388,11 @@ connection default; revoke execute on function test.fn1 from role5; show status like 'debug%'; Variable_name Value -Debug_role_merges_global 27 -Debug_role_merges_db 16 -Debug_role_merges_table 44 -Debug_role_merges_column 28 -Debug_role_merges_routine 26 +Debug_role_merges_global 29 +Debug_role_merges_db 17 +Debug_role_merges_table 47 +Debug_role_merges_column 30 +Debug_role_merges_routine 28 connection foo; select fn1(); ERROR 42000: execute command denied to user 'foo'@'localhost' for routine 'test.fn1' @@ -403,67 +403,67 @@ drop function fn1; grant select on mysql.roles_mapping to role3; show status like 'debug%'; Variable_name Value -Debug_role_merges_global 27 -Debug_role_merges_db 16 -Debug_role_merges_table 50 -Debug_role_merges_column 28 -Debug_role_merges_routine 26 +Debug_role_merges_global 29 +Debug_role_merges_db 17 +Debug_role_merges_table 54 +Debug_role_merges_column 30 +Debug_role_merges_routine 28 grant select on mysql.roles_mapping to role1; show status like 'debug%'; Variable_name Value -Debug_role_merges_global 27 -Debug_role_merges_db 16 -Debug_role_merges_table 53 -Debug_role_merges_column 28 -Debug_role_merges_routine 26 +Debug_role_merges_global 29 +Debug_role_merges_db 17 +Debug_role_merges_table 58 +Debug_role_merges_column 30 +Debug_role_merges_routine 28 revoke select on mysql.roles_mapping from role3; show status like 'debug%'; Variable_name Value -Debug_role_merges_global 27 -Debug_role_merges_db 16 -Debug_role_merges_table 54 -Debug_role_merges_column 28 -Debug_role_merges_routine 26 +Debug_role_merges_global 29 +Debug_role_merges_db 17 +Debug_role_merges_table 59 +Debug_role_merges_column 30 +Debug_role_merges_routine 28 revoke select on mysql.roles_mapping from role1; show status like 'debug%'; Variable_name Value -Debug_role_merges_global 27 -Debug_role_merges_db 16 -Debug_role_merges_table 62 -Debug_role_merges_column 28 -Debug_role_merges_routine 26 +Debug_role_merges_global 29 +Debug_role_merges_db 17 +Debug_role_merges_table 67 +Debug_role_merges_column 30 +Debug_role_merges_routine 28 grant select on mysql.* to role1; show status like 'debug%'; Variable_name Value -Debug_role_merges_global 27 -Debug_role_merges_db 24 -Debug_role_merges_table 62 -Debug_role_merges_column 28 -Debug_role_merges_routine 26 +Debug_role_merges_global 29 +Debug_role_merges_db 26 +Debug_role_merges_table 67 +Debug_role_merges_column 30 +Debug_role_merges_routine 28 grant select on test.* to role1; show status like 'debug%'; Variable_name Value -Debug_role_merges_global 27 -Debug_role_merges_db 32 -Debug_role_merges_table 62 -Debug_role_merges_column 28 -Debug_role_merges_routine 26 +Debug_role_merges_global 29 +Debug_role_merges_db 35 +Debug_role_merges_table 67 +Debug_role_merges_column 30 +Debug_role_merges_routine 28 revoke select on mysql.* from role1; show status like 'debug%'; Variable_name Value -Debug_role_merges_global 27 -Debug_role_merges_db 40 -Debug_role_merges_table 62 -Debug_role_merges_column 28 -Debug_role_merges_routine 26 +Debug_role_merges_global 29 +Debug_role_merges_db 43 +Debug_role_merges_table 67 +Debug_role_merges_column 30 +Debug_role_merges_routine 28 revoke select on test.* from role1; show status like 'debug%'; Variable_name Value -Debug_role_merges_global 27 -Debug_role_merges_db 48 -Debug_role_merges_table 62 -Debug_role_merges_column 28 -Debug_role_merges_routine 26 +Debug_role_merges_global 29 +Debug_role_merges_db 51 +Debug_role_merges_table 67 +Debug_role_merges_column 30 +Debug_role_merges_routine 28 connection default; drop user foo@localhost; drop role role1; diff --git a/mysql-test/suite/roles/role_grant_propagate-29458.result b/mysql-test/suite/roles/role_grant_propagate-29458.result new file mode 100644 index 00000000000..28aa053f38a --- /dev/null +++ b/mysql-test/suite/roles/role_grant_propagate-29458.result @@ -0,0 +1,136 @@ +create user foo; +create database some_db; +create table some_db.t1 (a int, b int, secret int); +CREATE PROCEDURE some_db.p1 (OUT param1 INT) +BEGIN +SELECT COUNT(*) INTO param1 FROM some_db.t1; +END; +// +CREATE FUNCTION some_db.f1 (param1 INT) RETURNS INT +BEGIN +DECLARE c INT; +SET c = 100; +RETURN param1 + c; +END; +// +# +# These roles will form a two level hierarchy. +# The "select" role will have the select privilege, while +# the active role will inherit the select role. +# +# The active role will be granted a different privilege but on the same +# level (global, database, table, proc respectively) *after* the 'select' +# role has been granted its select privilege. +# +create role r_select_global; +create role r_active_global; +create role r_select_database; +create role r_active_database; +create role r_select_table; +create role r_active_table; +create role r_select_column; +create role r_active_column; +create role r_execute_proc; +create role r_active_proc; +create role r_execute_func; +create role r_active_func; +grant r_select_global to r_active_global; +grant r_select_database to r_active_database; +grant r_select_table to r_active_table; +grant r_select_column to r_active_column; +grant r_execute_proc to r_active_proc; +grant r_execute_func to r_active_func; +# +# These 3 roles form a chain, where only the upper level has select +# privileges and the middle level will receive a grant for the same level +# privilege, but different kind (for example select on upper and insert +# on middle). +# +# The lower level should inherit both rights. +# +create role upper_level; +create role middle_level; +create role lower_level; +grant upper_level to middle_level; +grant middle_level to lower_level; +grant r_active_global to foo; +grant r_active_database to foo; +grant r_active_table to foo; +grant r_active_column to foo; +grant r_active_proc to foo; +grant r_active_func to foo; +grant lower_level to foo; +grant select on *.* to r_select_global; +grant select on some_db.* to r_select_database; +grant select on some_db.t1 to r_select_table; +grant select(a) on some_db.t1 to r_select_column; +grant select on *.* to upper_level; +grant execute on procedure some_db.p1 to r_execute_proc; +grant execute on function some_db.f1 to r_execute_func; +# +# Granting a privilege different than select on the corresponding level. +# This tests that the base role correctly inherits its granted roles +# privileges. +# +grant insert on *.* to r_active_global; +grant insert on some_db.* to r_active_database; +grant insert on some_db.t1 to r_active_table; +grant insert(a) on some_db.t1 to r_active_column; +grant insert on *.* to middle_level; +grant alter routine on procedure some_db.p1 to r_active_proc; +grant alter routine on function some_db.f1 to r_active_func; +connect con1, localhost, foo,,; +select * from some_db.t1; +ERROR 42000: SELECT command denied to user 'foo'@'localhost' for table 't1' +# +# Before MDEV-29458 fix, all these commands would return +# ER_TABLEACCESS_DENIED_ERROR +# +set role r_active_global; +select * from some_db.t1; +a b secret +set role r_active_database; +select * from some_db.t1; +a b secret +set role r_active_table; +select * from some_db.t1; +a b secret +set role r_active_column; +select a from some_db.t1; +a +set role lower_level; +select * from some_db.t1; +a b secret +set role r_active_proc; +set @var=100; +call some_db.p1(@var); +set role r_active_func; +select some_db.f1(10); +some_db.f1(10) +110 +disconnect con1; +# +# Cleanup. +# +connection default; +drop database some_db; +drop role r_select_global, r_select_database, r_select_table, r_select_column; +drop role r_active_global, r_active_database, r_active_table, r_active_column; +drop role r_execute_proc, r_execute_func; +drop role r_active_proc, r_active_func; +drop role upper_level, middle_level, lower_level; +drop user foo; +# +# Test that dropping of roles clears the intermediate generated +# (such as an `acl_dbs` element with 0 init_access, but with access != 0) +# datastructures. +# +create role test_role1; +create role test_role2; +grant test_role2 to test_role1; +grant select on mysql.* to test_role2; +grant select on mysql.user to test_role2; +grant select(user) on mysql.user to test_role2; +drop role test_role1, test_role2; +create role test_role1; +drop role test_role1; diff --git a/mysql-test/suite/roles/role_grant_propagate-29458.test b/mysql-test/suite/roles/role_grant_propagate-29458.test new file mode 100644 index 00000000000..1b0906dce25 --- /dev/null +++ b/mysql-test/suite/roles/role_grant_propagate-29458.test @@ -0,0 +1,163 @@ +--source include/not_embedded.inc + +create user foo; +create database some_db; +create table some_db.t1 (a int, b int, secret int); + +delimiter //; +CREATE PROCEDURE some_db.p1 (OUT param1 INT) + BEGIN + SELECT COUNT(*) INTO param1 FROM some_db.t1; + END; +// +delimiter ;// + +delimiter //; +CREATE FUNCTION some_db.f1 (param1 INT) RETURNS INT + BEGIN + DECLARE c INT; + SET c = 100; + RETURN param1 + c; + END; +// +delimiter ;// + +--echo # +--echo # These roles will form a two level hierarchy. +--echo # The "select" role will have the select privilege, while +--echo # the active role will inherit the select role. +--echo # +--echo # The active role will be granted a different privilege but on the same +--echo # level (global, database, table, proc respectively) *after* the 'select' +--echo # role has been granted its select privilege. +--echo # + +create role r_select_global; +create role r_active_global; + +create role r_select_database; +create role r_active_database; + +create role r_select_table; +create role r_active_table; + +create role r_select_column; +create role r_active_column; + +create role r_execute_proc; +create role r_active_proc; + +create role r_execute_func; +create role r_active_func; + +grant r_select_global to r_active_global; +grant r_select_database to r_active_database; +grant r_select_table to r_active_table; +grant r_select_column to r_active_column; +grant r_execute_proc to r_active_proc; +grant r_execute_func to r_active_func; + +--echo # +--echo # These 3 roles form a chain, where only the upper level has select +--echo # privileges and the middle level will receive a grant for the same level +--echo # privilege, but different kind (for example select on upper and insert +--echo # on middle). +--echo # +--echo # The lower level should inherit both rights. +--echo # +create role upper_level; +create role middle_level; +create role lower_level; + +grant upper_level to middle_level; +grant middle_level to lower_level; + +grant r_active_global to foo; +grant r_active_database to foo; +grant r_active_table to foo; +grant r_active_column to foo; +grant r_active_proc to foo; +grant r_active_func to foo; +grant lower_level to foo; + +grant select on *.* to r_select_global; +grant select on some_db.* to r_select_database; +grant select on some_db.t1 to r_select_table; +grant select(a) on some_db.t1 to r_select_column; +grant select on *.* to upper_level; + +grant execute on procedure some_db.p1 to r_execute_proc; +grant execute on function some_db.f1 to r_execute_func; + + +--echo # +--echo # Granting a privilege different than select on the corresponding level. +--echo # This tests that the base role correctly inherits its granted roles +--echo # privileges. +--echo # +grant insert on *.* to r_active_global; +grant insert on some_db.* to r_active_database; +grant insert on some_db.t1 to r_active_table; +grant insert(a) on some_db.t1 to r_active_column; +grant insert on *.* to middle_level; + +grant alter routine on procedure some_db.p1 to r_active_proc; +grant alter routine on function some_db.f1 to r_active_func; + +--connect (con1, localhost, foo,,) +--error ER_TABLEACCESS_DENIED_ERROR +select * from some_db.t1; + +--echo # +--echo # Before MDEV-29458 fix, all these commands would return +--echo # ER_TABLEACCESS_DENIED_ERROR +--echo # +set role r_active_global; +select * from some_db.t1; +set role r_active_database; +select * from some_db.t1; +set role r_active_table; +select * from some_db.t1; +set role r_active_column; +select a from some_db.t1; +set role lower_level; +select * from some_db.t1; + +set role r_active_proc; +set @var=100; +call some_db.p1(@var); + +set role r_active_func; +select some_db.f1(10); + +disconnect con1; + +--echo # +--echo # Cleanup. +--echo # +connection default; + +drop database some_db; +drop role r_select_global, r_select_database, r_select_table, r_select_column; +drop role r_active_global, r_active_database, r_active_table, r_active_column; +drop role r_execute_proc, r_execute_func; +drop role r_active_proc, r_active_func; +drop role upper_level, middle_level, lower_level; +drop user foo; + +--echo # +--echo # Test that dropping of roles clears the intermediate generated +--echo # (such as an `acl_dbs` element with 0 init_access, but with access != 0) +--echo # datastructures. +--echo # +create role test_role1; +create role test_role2; + +grant test_role2 to test_role1; +grant select on mysql.* to test_role2; +grant select on mysql.user to test_role2; +grant select(user) on mysql.user to test_role2; +drop role test_role1, test_role2; + +create role test_role1; +drop role test_role1; diff --git a/mysql-test/suite/roles/roles_tables_priv-29465.result b/mysql-test/suite/roles/roles_tables_priv-29465.result new file mode 100644 index 00000000000..1e0721956b4 --- /dev/null +++ b/mysql-test/suite/roles/roles_tables_priv-29465.result @@ -0,0 +1,38 @@ +create user foo; +create database some_db; +create table some_db.t1 (a int, b int, secret int); +create role r_select_column; +create role r_active_column; +grant r_select_column to r_active_column; +grant r_active_column to foo; +grant select(a) on some_db.t1 to r_select_column; +select * from mysql.tables_priv order by user; +Host Db User Table_name Grantor Timestamp Table_priv Column_priv +localhost mysql mariadb.sys global_priv root@localhost 0000-00-00 00:00:00 Select,Delete + some_db r_select_column t1 root@localhost 0000-00-00 00:00:00 Select +grant insert(a) on some_db.t1 to r_active_column; +select * from mysql.tables_priv order by user; +Host Db User Table_name Grantor Timestamp Table_priv Column_priv +localhost mysql mariadb.sys global_priv root@localhost 0000-00-00 00:00:00 Select,Delete + some_db r_active_column t1 root@localhost 0000-00-00 00:00:00 Insert + some_db r_select_column t1 root@localhost 0000-00-00 00:00:00 Select +connect con1, localhost, foo,,; +insert into some_db.t1(a) values (1); +ERROR 42000: INSERT command denied to user 'foo'@'localhost' for table 't1' +set role r_active_column; +insert into some_db.t1(a) values (1); +disconnect con1; +connection default; +revoke insert(a) on some_db.t1 from r_active_column; +connect con1, localhost, foo,,; +insert into some_db.t1(a) values (1); +ERROR 42000: INSERT command denied to user 'foo'@'localhost' for table 't1' +set role r_active_column; +insert into some_db.t1(a) values (1); +ERROR 42000: INSERT command denied to user 'foo'@'localhost' for table 't1' +disconnect con1; +connection default; +drop role r_select_column; +drop role r_active_column; +drop user foo; +drop database some_db; diff --git a/mysql-test/suite/roles/roles_tables_priv-29465.test b/mysql-test/suite/roles/roles_tables_priv-29465.test new file mode 100644 index 00000000000..550b05a408a --- /dev/null +++ b/mysql-test/suite/roles/roles_tables_priv-29465.test @@ -0,0 +1,40 @@ +--source include/not_embedded.inc + +create user foo; +create database some_db; +create table some_db.t1 (a int, b int, secret int); + +create role r_select_column; +create role r_active_column; +grant r_select_column to r_active_column; +grant r_active_column to foo; + +grant select(a) on some_db.t1 to r_select_column; +select * from mysql.tables_priv order by user; +grant insert(a) on some_db.t1 to r_active_column; +select * from mysql.tables_priv order by user; + +--connect (con1, localhost, foo,,) +--error ER_TABLEACCESS_DENIED_ERROR +insert into some_db.t1(a) values (1); +set role r_active_column; +insert into some_db.t1(a) values (1); +disconnect con1; + +connection default; +revoke insert(a) on some_db.t1 from r_active_column; + +--connect (con1, localhost, foo,,) +--error ER_TABLEACCESS_DENIED_ERROR +insert into some_db.t1(a) values (1); +set role r_active_column; +--error ER_TABLEACCESS_DENIED_ERROR +insert into some_db.t1(a) values (1); +disconnect con1; + +connection default; + +drop role r_select_column; +drop role r_active_column; +drop user foo; +drop database some_db; diff --git a/sql/sp.cc b/sql/sp.cc index 43292f7ab49..af9c7901c5a 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -1053,8 +1053,11 @@ sp_returns_type(THD *thd, String &result, const sp_head *sp) { result.append(STRING_WITH_LEN(" CHARSET ")); result.append(field->charset()->csname); - result.append(STRING_WITH_LEN(" COLLATE ")); - result.append(field->charset()->name); + if (Charset(field->charset()).can_have_collate_clause()) + { + result.append(STRING_WITH_LEN(" COLLATE ")); + result.append(field->charset()->name); + } } delete field; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 826b2d9ea22..3eb89b58289 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -5243,7 +5243,7 @@ GRANT_NAME::GRANT_NAME(const char *h, const char *d,const char *u, GRANT_TABLE::GRANT_TABLE(const char *h, const char *d,const char *u, const char *t, ulong p, ulong c) - :GRANT_NAME(h,d,u,t,p, FALSE), cols(c) + :GRANT_NAME(h,d,u,t,p, FALSE), cols(c), init_cols(c) { init_hash(); } @@ -6037,6 +6037,7 @@ static int count_subgraph_nodes(ACL_ROLE *role, ACL_ROLE *grantee, void *context } static int merge_role_privileges(ACL_ROLE *, ACL_ROLE *, void *); +static bool merge_one_role_privileges(ACL_ROLE *grantee, PRIVS_TO_MERGE what); /** rebuild privileges of all affected roles @@ -6056,6 +6057,11 @@ static void propagate_role_grants(ACL_ROLE *role, PRIVS_TO_MERGE data= { what, db, name }; /* + Before updating grants to roles that inherit from this role, ensure that + the effective grants on this role are up-to-date from *its* granted roles. + */ + merge_one_role_privileges(role, data); + /* Changing privileges of a role causes all other roles that had this role granted to them to have their rights invalidated. @@ -6502,7 +6508,6 @@ static int table_name_sort(GRANT_TABLE * const *tbl1, GRANT_TABLE * const *tbl2) */ static int update_role_columns(GRANT_TABLE *merged, GRANT_TABLE **cur, GRANT_TABLE **last) - { ulong rights __attribute__((unused))= 0; int changed= 0; @@ -6851,11 +6856,12 @@ static int merge_role_privileges(ACL_ROLE *role __attribute__((unused)), return !changed; // don't recurse into the subgraph if privs didn't change } -static bool merge_one_role_privileges(ACL_ROLE *grantee) +static +bool merge_one_role_privileges(ACL_ROLE *grantee, + PRIVS_TO_MERGE what) { - PRIVS_TO_MERGE data= { PRIVS_TO_MERGE::ALL, 0, 0 }; grantee->counter= 1; - return merge_role_privileges(0, grantee, &data); + return merge_role_privileges(0, grantee, &what); } /***************************************************************** @@ -7045,15 +7051,15 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, /* Find/create cached table grant */ grant_table= table_hash_search(Str->host.str, NullS, db_name, - Str->user.str, table_name, 1); + Str->user.str, table_name, 1); if (!grant_table) { if (revoke_grant) { - my_error(ER_NONEXISTING_TABLE_GRANT, MYF(0), + my_error(ER_NONEXISTING_TABLE_GRANT, MYF(0), Str->user.str, Str->host.str, table_list->table_name.str); - result= TRUE; - continue; + result= TRUE; + continue; } grant_table= new (&grant_memroot) GRANT_TABLE(Str->host.str, db_name, Str->user.str, table_name, @@ -7062,8 +7068,8 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, if (!grant_table || column_priv_insert(grant_table)) { - result= TRUE; /* purecov: deadcode */ - continue; /* purecov: deadcode */ + result= TRUE; /* purecov: deadcode */ + continue; /* purecov: deadcode */ } } @@ -7077,11 +7083,15 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, /* Fix old grants */ while ((column = column_iter++)) { - grant_column = column_hash_search(grant_table, - column->column.ptr(), - column->column.length()); - if (grant_column) - grant_column->rights&= ~(column->rights | rights); + grant_column = column_hash_search(grant_table, + column->column.ptr(), + column->column.length()); + if (grant_column) + { + grant_column->init_rights&= ~(column->rights | rights); + // If this is a role, rights will need to be reconstructed. + grant_column->rights= grant_column->init_rights; + } } /* scan trough all columns to get new column grant */ column_priv= 0; @@ -7089,13 +7099,14 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, { grant_column= (GRANT_COLUMN*) my_hash_element(&grant_table->hash_columns, idx); - grant_column->rights&= ~rights; // Fix other columns - column_priv|= grant_column->rights; + grant_column->init_rights&= ~rights; // Fix other columns + grant_column->rights= grant_column->init_rights; + column_priv|= grant_column->init_rights; } } else { - column_priv|= grant_table->cols; + column_priv|= grant_table->init_cols; } @@ -7223,23 +7234,24 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, table_name= table_list->table_name.str; grant_name= routine_hash_search(Str->host.str, NullS, db_name, Str->user.str, table_name, sph, 1); - if (!grant_name || !grant_name->init_privs) + if (revoke_grant && (!grant_name || !grant_name->init_privs)) { - if (revoke_grant) - { - my_error(ER_NONEXISTING_PROC_GRANT, MYF(0), - Str->user.str, Str->host.str, table_name); - result= TRUE; - continue; - } + my_error(ER_NONEXISTING_PROC_GRANT, MYF(0), + Str->user.str, Str->host.str, table_name); + result= TRUE; + continue; + } + if (!grant_name) + { + DBUG_ASSERT(!revoke_grant); grant_name= new GRANT_NAME(Str->host.str, db_name, - Str->user.str, table_name, - rights, TRUE); + Str->user.str, table_name, + rights, TRUE); if (!grant_name || - my_hash_insert(sph->get_priv_hash(), (uchar*) grant_name)) + my_hash_insert(sph->get_priv_hash(), (uchar*) grant_name)) { result= TRUE; - continue; + continue; } } @@ -7576,7 +7588,7 @@ bool mysql_grant_role(THD *thd, List <LEX_USER> &list, bool revoke) Only need to propagate grants when granting/revoking a role to/from a role */ - if (role_as_user && merge_one_role_privileges(role_as_user) == 0) + if (role_as_user) propagate_role_grants(role_as_user, PRIVS_TO_MERGE::ALL); } @@ -10179,9 +10191,6 @@ static int handle_grant_struct(enum enum_acl_lists struct_no, bool drop, size_t old_key_length= acl_role->user.length; if (drop) { - /* all grants must be revoked from this role by now. propagate this */ - propagate_role_grants(acl_role, PRIVS_TO_MERGE::ALL); - // delete the role from cross-reference arrays for (uint i=0; i < acl_role->role_grants.elements; i++) { @@ -10197,6 +10206,12 @@ static int handle_grant_struct(enum enum_acl_lists struct_no, bool drop, remove_ptr_from_dynarray(&grantee->role_grants, acl_role); } + /* Remove all of the role_grants from this role. */ + delete_dynamic(&acl_role->role_grants); + + /* all grants must be revoked from this role by now. propagate this */ + propagate_role_grants(acl_role, PRIVS_TO_MERGE::ALL); + my_hash_delete(&acl_roles, (uchar*) acl_role); DBUG_RETURN(1); } diff --git a/sql/sql_audit.cc b/sql/sql_audit.cc index ed175ae4865..14e876ef749 100644 --- a/sql/sql_audit.cc +++ b/sql/sql_audit.cc @@ -113,8 +113,6 @@ void mysql_audit_acquire_plugins(THD *thd, ulong *event_class_mask) { DBUG_ENTER("mysql_audit_acquire_plugins"); DBUG_ASSERT(thd); - DBUG_ASSERT(!check_audit_mask(mysql_global_audit_mask, event_class_mask)); - if (check_audit_mask(thd->audit_class_mask, event_class_mask)) { plugin_foreach(thd, acquire_plugins, MYSQL_AUDIT_PLUGIN, event_class_mask); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 83745e9aa9c..85889b614c8 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1553,8 +1553,11 @@ bool mysqld_show_create_db(THD *thd, LEX_CSTRING *dbname, buffer.append(STRING_WITH_LEN(" /*!40100")); buffer.append(STRING_WITH_LEN(" DEFAULT CHARACTER SET ")); buffer.append(create.default_table_charset->csname); - buffer.append(STRING_WITH_LEN(" COLLATE ")); - buffer.append(create.default_table_charset->name); + if (Charset(create.default_table_charset).can_have_collate_clause()) + { + buffer.append(STRING_WITH_LEN(" COLLATE ")); + buffer.append(create.default_table_charset->name); + } buffer.append(STRING_WITH_LEN(" */")); } protocol->store(buffer.ptr(), buffer.length(), buffer.charset()); @@ -2001,8 +2004,11 @@ static void add_table_options(THD *thd, TABLE *table, { packet->append(STRING_WITH_LEN(" DEFAULT CHARSET=")); packet->append(share->table_charset->csname); - packet->append(STRING_WITH_LEN(" COLLATE=")); - packet->append(table->s->table_charset->name); + if (Charset(table->s->table_charset).can_have_collate_clause()) + { + packet->append(STRING_WITH_LEN(" COLLATE=")); + packet->append(table->s->table_charset->name); + } } } @@ -2259,10 +2265,13 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet, { if (field->charset() != share->table_charset) { - packet->append(STRING_WITH_LEN(" CHARACTER SET ")); - packet->append(field->charset()->csname); - packet->append(STRING_WITH_LEN(" COLLATE ")); - packet->append(field->charset()->name); + packet->append(STRING_WITH_LEN(" CHARACTER SET ")); + packet->append(field->charset()->csname); + if (Charset(field->charset()).can_have_collate_clause()) + { + packet->append(STRING_WITH_LEN(" COLLATE ")); + packet->append(field->charset()->name); + } } } @@ -3611,6 +3620,7 @@ union Any_pointer { @param variable [in] Details of the variable. @param value_type [in] Variable type. @param show_type [in] Variable show type. + @param status_var [in] Status variable pointer @param charset [out] Character set of the value. @param buff [in,out] Buffer to store the value. (Needs to have enough memory diff --git a/sql/sql_string.h b/sql/sql_string.h index 0098ad15cb6..ff29e98bfd9 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -180,6 +180,10 @@ public: LEX_CSTRING collation_specific_name() const; bool encoding_allows_reinterpret_as(CHARSET_INFO *cs) const; bool eq_collation_specific_names(CHARSET_INFO *cs) const; + bool can_have_collate_clause() const + { + return m_charset != &my_charset_bin; + } }; diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index b29264536f9..56f3bd92bc4 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -5099,7 +5099,6 @@ Sys_var_rpl_filter::global_value_ptr(THD *thd, } rpl_filter= mi->rpl_filter; - tmp.length(0); mysql_mutex_lock(&LOCK_active_mi); switch (opt_id) { diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc index 1a13dc71652..41bce530aeb 100644 --- a/storage/connect/connect.cc +++ b/storage/connect/connect.cc @@ -553,7 +553,8 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort) if (!tdbp) return rc; // Nothing to do else if (tdbp->GetUse() != USE_OPEN) { - if (tdbp->GetAmType() == TYPE_AM_XML) + if (tdbp->GetAmType() == TYPE_AM_XML || + tdbp->GetAmType() == TYPE_AM_JSN) tdbp->CloseDB(g); // Opened by GetMaxSize return rc; diff --git a/storage/connect/mysql-test/connect/r/bson.result b/storage/connect/mysql-test/connect/r/bson.result index fd15e020aac..985c55f5db7 100644 --- a/storage/connect/mysql-test/connect/r/bson.result +++ b/storage/connect/mysql-test/connect/r/bson.result @@ -515,3 +515,27 @@ Beth 4 Food 17.00 Beth 4 Beer 15.00 Janet 4 Car 17.00 DROP TABLE t1, t2, t3, t4; +# +# MDEV-29426 memory leak on "SHOW INDEX" +# +CREATE TABLE t1 +( +ISBN CHAR(15) NOT NULL, +Language CHAR(2) JPATH='$.LANG', +Subject CHAR(32) JPATH='$.SUBJECT', +AuthorFN CHAR(128) JPATH='$.AUTHOR[*].FIRSTNAME', +AuthorLN CHAR(128) JPATH='$.AUTHOR[*].LASTNAME', +Title CHAR(32) JPATH='$.TITLE', +Translation CHAR(32) JPATH='$.TRANSLATED.PREFIX', +TranslatorFN CHAR(80) JPATH='$.TRANSLATED.TRANSLATOR.FIRSTNAME', +TranslatorLN CHAR(80) JPATH='$.TRANSLATED.TRANSLATOR.LASTNAME', +Publisher CHAR(20) JPATH='$.PUBLISHER.NAME', +Location CHAR(16) JPATH='$.PUBLISHER.PLACE', +Year int(4) JPATH='$.DATEPUB', +INDEX IX(ISBN) +) +ENGINE=CONNECT TABLE_TYPE=BSON FILE_NAME='bib0.json' LRECL=320 OPTION_LIST='Pretty=0'; +SHOW INDEX FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +t1 1 IX 1 ISBN A NULL NULL NULL XINDEX +DROP TABLE t1; diff --git a/storage/connect/mysql-test/connect/r/json.result b/storage/connect/mysql-test/connect/r/json.result index dc527acd4a3..a8749dd7420 100644 --- a/storage/connect/mysql-test/connect/r/json.result +++ b/storage/connect/mysql-test/connect/r/json.result @@ -515,3 +515,27 @@ Beth 4 Food 17.00 Beth 4 Beer 15.00 Janet 4 Car 17.00 DROP TABLE t1, t2, t3, t4; +# +# MDEV-29426 memory leak on "SHOW INDEX" +# +CREATE TABLE t1 +( +ISBN CHAR(15) NOT NULL, +Language CHAR(2) JPATH='$.LANG', +Subject CHAR(32) JPATH='$.SUBJECT', +AuthorFN CHAR(128) JPATH='$.AUTHOR[*].FIRSTNAME', +AuthorLN CHAR(128) JPATH='$.AUTHOR[*].LASTNAME', +Title CHAR(32) JPATH='$.TITLE', +Translation CHAR(32) JPATH='$.TRANSLATED.PREFIX', +TranslatorFN CHAR(80) JPATH='$.TRANSLATED.TRANSLATOR.FIRSTNAME', +TranslatorLN CHAR(80) JPATH='$.TRANSLATED.TRANSLATOR.LASTNAME', +Publisher CHAR(20) JPATH='$.PUBLISHER.NAME', +Location CHAR(16) JPATH='$.PUBLISHER.PLACE', +Year int(4) JPATH='$.DATEPUB', +INDEX IX(ISBN) +) +ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='bib0.json' LRECL=320 OPTION_LIST='Pretty=0'; +SHOW INDEX FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +t1 1 IX 1 ISBN A NULL NULL NULL XINDEX +DROP TABLE t1; diff --git a/storage/connect/mysql-test/connect/t/bson.test b/storage/connect/mysql-test/connect/t/bson.test index ab38cab73fc..173435d79d1 100644 --- a/storage/connect/mysql-test/connect/t/bson.test +++ b/storage/connect/mysql-test/connect/t/bson.test @@ -282,6 +282,29 @@ SELECT * FROM t1; SELECT * FROM t1 WHERE WEEK = 4; DROP TABLE t1, t2, t3, t4; +--echo # +--echo # MDEV-29426 memory leak on "SHOW INDEX" +--echo # +CREATE TABLE t1 +( + ISBN CHAR(15) NOT NULL, + Language CHAR(2) JPATH='$.LANG', + Subject CHAR(32) JPATH='$.SUBJECT', + AuthorFN CHAR(128) JPATH='$.AUTHOR[*].FIRSTNAME', + AuthorLN CHAR(128) JPATH='$.AUTHOR[*].LASTNAME', + Title CHAR(32) JPATH='$.TITLE', + Translation CHAR(32) JPATH='$.TRANSLATED.PREFIX', + TranslatorFN CHAR(80) JPATH='$.TRANSLATED.TRANSLATOR.FIRSTNAME', + TranslatorLN CHAR(80) JPATH='$.TRANSLATED.TRANSLATOR.LASTNAME', + Publisher CHAR(20) JPATH='$.PUBLISHER.NAME', + Location CHAR(16) JPATH='$.PUBLISHER.PLACE', + Year int(4) JPATH='$.DATEPUB', + INDEX IX(ISBN) +) +ENGINE=CONNECT TABLE_TYPE=BSON FILE_NAME='bib0.json' LRECL=320 OPTION_LIST='Pretty=0'; +SHOW INDEX FROM t1; +DROP TABLE t1; + # # Clean up # diff --git a/storage/connect/mysql-test/connect/t/json.test b/storage/connect/mysql-test/connect/t/json.test index 8b42ef9cfab..80306fc5480 100644 --- a/storage/connect/mysql-test/connect/t/json.test +++ b/storage/connect/mysql-test/connect/t/json.test @@ -282,6 +282,30 @@ SELECT * FROM t1; SELECT * FROM t1 WHERE WEEK = 4; DROP TABLE t1, t2, t3, t4; + +--echo # +--echo # MDEV-29426 memory leak on "SHOW INDEX" +--echo # +CREATE TABLE t1 +( + ISBN CHAR(15) NOT NULL, + Language CHAR(2) JPATH='$.LANG', + Subject CHAR(32) JPATH='$.SUBJECT', + AuthorFN CHAR(128) JPATH='$.AUTHOR[*].FIRSTNAME', + AuthorLN CHAR(128) JPATH='$.AUTHOR[*].LASTNAME', + Title CHAR(32) JPATH='$.TITLE', + Translation CHAR(32) JPATH='$.TRANSLATED.PREFIX', + TranslatorFN CHAR(80) JPATH='$.TRANSLATED.TRANSLATOR.FIRSTNAME', + TranslatorLN CHAR(80) JPATH='$.TRANSLATED.TRANSLATOR.LASTNAME', + Publisher CHAR(20) JPATH='$.PUBLISHER.NAME', + Location CHAR(16) JPATH='$.PUBLISHER.PLACE', + Year int(4) JPATH='$.DATEPUB', + INDEX IX(ISBN) +) +ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='bib0.json' LRECL=320 OPTION_LIST='Pretty=0'; +SHOW INDEX FROM t1; +DROP TABLE t1; + # # Clean up # diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 8a4fc0e79d9..ab7d00e71a8 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2014, 2021, MariaDB Corporation. +# Copyright (c) 2014, 2022, MariaDB Corporation. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,9 +16,182 @@ # This is the CMakeLists for InnoDB +INCLUDE(CheckFunctionExists) +INCLUDE(CheckCSourceCompiles) +INCLUDE(CheckCSourceRuns) +INCLUDE(lz4.cmake) +INCLUDE(lzo.cmake) +INCLUDE(lzma.cmake) +INCLUDE(bzip2.cmake) +INCLUDE(snappy.cmake) +INCLUDE(numa) +INCLUDE(TestBigEndian) +MYSQL_CHECK_LZ4() +MYSQL_CHECK_LZO() +MYSQL_CHECK_LZMA() +MYSQL_CHECK_BZIP2() +MYSQL_CHECK_SNAPPY() +MYSQL_CHECK_NUMA() -INCLUDE(innodb.cmake) +INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/compile_flags.cmake) + +IF(CMAKE_CROSSCOMPILING) + # Use CHECK_C_SOURCE_COMPILES instead of CHECK_C_SOURCE_RUNS when + # cross-compiling. Not as precise, but usually good enough. + # This only make sense for atomic tests in this file, this trick doesn't + # work in a general case. + MACRO(CHECK_C_SOURCE SOURCE VAR) + CHECK_C_SOURCE_COMPILES("${SOURCE}" "${VAR}") + ENDMACRO() +ELSE() + MACRO(CHECK_C_SOURCE SOURCE VAR) + CHECK_C_SOURCE_RUNS("${SOURCE}" "${VAR}") + ENDMACRO() +ENDIF() + +# OS tests +IF(UNIX) + IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") + + ADD_DEFINITIONS("-D_GNU_SOURCE=1") + + CHECK_INCLUDE_FILES (libaio.h HAVE_LIBAIO_H) + CHECK_LIBRARY_EXISTS(aio io_queue_init "" HAVE_LIBAIO) + + IF(HAVE_LIBAIO_H AND HAVE_LIBAIO) + ADD_DEFINITIONS(-DLINUX_NATIVE_AIO=1) + LINK_LIBRARIES(aio) + ENDIF() + IF(HAVE_LIBNUMA) + LINK_LIBRARIES(numa) + ENDIF() + ENDIF() +ENDIF() + +SET(MUTEXTYPE "event" CACHE STRING "Mutex type: event, sys or futex") + +IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU") +# After: WL#5825 Using C++ Standard Library with MySQL code +# we no longer use -fno-exceptions +# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions") + +# Add -Wconversion if compiling with GCC +## As of Mar 15 2011 this flag causes 3573+ warnings. If you are reading this +## please fix them and enable the following code: +#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wconversion") + + IF (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "i386" AND + CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6) + INCLUDE(CheckCXXCompilerFlag) + CHECK_CXX_COMPILER_FLAG("-fno-builtin-memcmp" HAVE_NO_BUILTIN_MEMCMP) + IF (HAVE_NO_BUILTIN_MEMCMP) + # Work around http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052 + SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/rem/rem0cmp.cc + PROPERTIES COMPILE_FLAGS -fno-builtin-memcmp) + ENDIF() + ENDIF() +ENDIF() + +# Enable InnoDB's UNIV_DEBUG in debug builds +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DUNIV_DEBUG") + +OPTION(WITH_INNODB_AHI "Include innodb_adaptive_hash_index" ON) +OPTION(WITH_INNODB_ROOT_GUESS "Cache index root block descriptors" ON) +IF(WITH_INNODB_AHI) + ADD_DEFINITIONS(-DBTR_CUR_HASH_ADAPT -DBTR_CUR_ADAPT) + IF(NOT WITH_INNODB_ROOT_GUESS) + MESSAGE(WARNING "WITH_INNODB_AHI implies WITH_INNODB_ROOT_GUESS") + SET(WITH_INNODB_ROOT_GUESS ON) + ENDIF() +ELSEIF(WITH_INNODB_ROOT_GUESS) + ADD_DEFINITIONS(-DBTR_CUR_ADAPT) +ENDIF() +ADD_FEATURE_INFO(INNODB_AHI WITH_INNODB_AHI "InnoDB Adaptive Hash Index") +ADD_FEATURE_INFO(INNODB_ROOT_GUESS WITH_INNODB_ROOT_GUESS + "Cache index root block descriptors in InnoDB") + +OPTION(WITH_INNODB_EXTRA_DEBUG "Enable extra InnoDB debug checks" OFF) +IF(WITH_INNODB_EXTRA_DEBUG) + ADD_DEFINITIONS(-DUNIV_ZIP_DEBUG) +ENDIF() +ADD_FEATURE_INFO(INNODB_EXTRA_DEBUG WITH_INNODB_EXTRA_DEBUG "Extra InnoDB debug checks") + + +CHECK_FUNCTION_EXISTS(sched_getcpu HAVE_SCHED_GETCPU) +IF(HAVE_SCHED_GETCPU) + ADD_DEFINITIONS(-DHAVE_SCHED_GETCPU=1) +ENDIF() + +CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP) +IF(HAVE_NANOSLEEP) + ADD_DEFINITIONS(-DHAVE_NANOSLEEP=1) +ENDIF() + +IF(HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE) + ADD_DEFINITIONS(-DHAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE=1) +ENDIF() + +IF(NOT MSVC) + # Work around MDEV-18417, MDEV-18656, MDEV-18417 + IF(WITH_ASAN AND CMAKE_COMPILER_IS_GNUCC AND + CMAKE_C_COMPILER_VERSION VERSION_LESS "6.0.0") + SET_SOURCE_FILES_PROPERTIES(trx/trx0rec.cc PROPERTIES COMPILE_FLAGS -O1) + ENDIF() +ENDIF(NOT MSVC) + +CHECK_FUNCTION_EXISTS(vasprintf HAVE_VASPRINTF) + +SET(MUTEXTYPE "event" CACHE STRING "Mutex type: event, sys or futex") + +IF(MUTEXTYPE MATCHES "event") + ADD_DEFINITIONS(-DMUTEX_EVENT) +ELSEIF(MUTEXTYPE MATCHES "futex" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") + ADD_DEFINITIONS(-DMUTEX_FUTEX) +ELSE() + ADD_DEFINITIONS(-DMUTEX_SYS) +ENDIF() + + +# Include directories under innobase +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/storage/innobase/include + ${CMAKE_SOURCE_DIR}/storage/innobase/handler) + +# Sun Studio bug with -xO2 +IF(CMAKE_CXX_COMPILER_ID MATCHES "SunPro" + AND CMAKE_CXX_FLAGS_RELEASE MATCHES "O2" + AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + # Sun Studio 12 crashes with -xO2 flag, but not with higher optimization + # -xO3 + SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/rem/rem0rec.cc + PROPERTIES COMPILE_FLAGS -xO3) +ENDIF() + +# Avoid generating Hardware Capabilities due to crc32 instructions +IF(CMAKE_SYSTEM_NAME MATCHES "SunOS" AND CMAKE_SYSTEM_PROCESSOR MATCHES "i386") + MY_CHECK_CXX_COMPILER_FLAG("-Wa,-nH") + IF(have_CXX__Wa__nH) + ADD_COMPILE_FLAGS( + ut/ut0crc32.cc + COMPILE_FLAGS "-Wa,-nH" + ) + ENDIF() +ENDIF() + +IF(MSVC) + # Avoid "unreferenced label" warning in generated file + GET_FILENAME_COMPONENT(_SRC_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) + SET_SOURCE_FILES_PROPERTIES(${_SRC_DIR}/pars/pars0grm.c + PROPERTIES COMPILE_FLAGS "/wd4102") + SET_SOURCE_FILES_PROPERTIES(${_SRC_DIR}/pars/lexyy.c + PROPERTIES COMPILE_FLAGS "/wd4003") +ENDIF() + +# Include directories under innobase +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/storage/innobase/include + ${CMAKE_SOURCE_DIR}/storage/innobase/handler + ${CMAKE_SOURCE_DIR}/libbinlogevents/include) SET(INNOBASE_SOURCES btr/btr0btr.cc diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index f688cf4f719..72a9764bf3f 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -68,7 +68,7 @@ Created 11/5/1995 Heikki Tuuri #include <sstream> #include "log.h" -#ifdef UNIV_LINUX +#ifdef __linux__ #include <stdlib.h> #endif diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index eee8ff0af4a..8f9486276f1 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -47,14 +47,14 @@ Created 11/11/1995 Heikki Tuuri #include "srv0mon.h" #include "ut0stage.h" #include "fil0pagecompress.h" -#ifdef UNIV_LINUX +#ifdef __linux__ /* include defs for CPU time priority settings */ #include <unistd.h> #include <sys/syscall.h> #include <sys/time.h> #include <sys/resource.h> static const int buf_flush_page_cleaner_priority = -20; -#endif /* UNIV_LINUX */ +#endif /* __linux__ */ /** Sleep time in microseconds for loop waiting for the oldest modification lsn */ @@ -2848,7 +2848,7 @@ pc_wait_finished( return(all_succeeded); } -#ifdef UNIV_LINUX +#ifdef __linux__ /** Set priority for page_cleaner threads. @param[in] priority priority intended to set @@ -2863,7 +2863,7 @@ buf_flush_page_cleaner_set_priority( return(getpriority(PRIO_PROCESS, (pid_t)syscall(SYS_gettid)) == priority); } -#endif /* UNIV_LINUX */ +#endif /* __linux__ */ #ifdef UNIV_DEBUG /** Loop used to disable page cleaner threads. */ @@ -2990,7 +2990,7 @@ DECLARE_THREAD(buf_flush_page_cleaner_coordinator)(void*) ib::info() << "page_cleaner thread running, id " << os_thread_pf(os_thread_get_curr_id()); #endif /* UNIV_DEBUG_THREAD_CREATION */ -#ifdef UNIV_LINUX +#ifdef __linux__ /* linux might be able to set different setting for each thread. worth to try to set high priority for page cleaner threads */ if (buf_flush_page_cleaner_set_priority( @@ -3005,7 +3005,7 @@ DECLARE_THREAD(buf_flush_page_cleaner_coordinator)(void*) } /* Signal that setpriority() has been attempted. */ os_event_set(recv_sys.flush_end); -#endif /* UNIV_LINUX */ +#endif /* __linux__ */ do { /* treat flushing requests during recovery. */ @@ -3406,7 +3406,7 @@ DECLARE_THREAD(buf_flush_page_cleaner_worker)( os_event_set(page_cleaner.is_started); mutex_exit(&page_cleaner.mutex); -#ifdef UNIV_LINUX +#ifdef __linux__ /* linux might be able to set different setting for each thread worth to try to set high priority for page cleaner threads */ if (buf_flush_page_cleaner_set_priority( @@ -3415,7 +3415,7 @@ DECLARE_THREAD(buf_flush_page_cleaner_worker)( ib::info() << "page_cleaner worker priority: " << buf_flush_page_cleaner_priority; } -#endif /* UNIV_LINUX */ +#endif /* __linux__ */ while (true) { os_event_wait(page_cleaner.is_requested); diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 7a6a3656abb..53387657ebc 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -50,7 +50,7 @@ Created 10/25/1995 Heikki Tuuri #include "sync0sync.h" #include "buf0flu.h" #include "os0api.h" -#ifdef UNIV_LINUX +#ifdef __linux__ # include <sys/types.h> # include <sys/sysmacros.h> # include <dirent.h> @@ -1574,7 +1574,7 @@ void fil_system_t::create(ulint hash_size) spaces = hash_create(hash_size); fil_space_crypt_init(); -#ifdef UNIV_LINUX +#ifdef __linux__ ssd.clear(); char fn[sizeof(dirent::d_name) + sizeof "/sys/block/" "/queue/rotational"]; @@ -1656,10 +1656,10 @@ void fil_system_t::close() ut_ad(!spaces); -#ifdef UNIV_LINUX +#ifdef __linux__ ssd.clear(); ssd.shrink_to_fit(); -#endif /* UNIV_LINUX */ +#endif /* __linux__ */ } /*******************************************************************//** diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc index c0951ab7e01..bc9d24cd00f 100644 --- a/storage/innobase/handler/i_s.cc +++ b/storage/innobase/handler/i_s.cc @@ -6821,6 +6821,11 @@ i_s_sys_tablespaces_fill_table( mutex_exit(&dict_sys.mutex); mem_heap_free(heap); + i_s_dict_fill_sys_tablespaces( + thd, fil_system.temp_space->id, + fil_system.temp_space->name, + fil_system.temp_space->flags, tables->table); + DBUG_RETURN(0); } /*******************************************************************//** diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index dac2443276d..57d62bf8fde 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -34,7 +34,7 @@ Created 10/25/1995 Heikki Tuuri #include "log0recv.h" #include "dict0types.h" #include "ilist.h" -#ifdef UNIV_LINUX +#ifdef __linux__ # include <set> #endif @@ -938,7 +938,7 @@ struct fil_system_t { private: bool m_initialised; -#ifdef UNIV_LINUX +#ifdef __linux__ /** available block devices that reside on non-rotational storage */ std::vector<dev_t> ssd; public: diff --git a/storage/innobase/include/ib0mutex.h b/storage/innobase/include/ib0mutex.h index ce0e911dbb4..de1d208fff4 100644 --- a/storage/innobase/include/ib0mutex.h +++ b/storage/innobase/include/ib0mutex.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2013, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2020, MariaDB Corporation. +Copyright (c) 2017, 2022, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -145,7 +145,7 @@ private: }; -#ifdef HAVE_IB_LINUX_FUTEX +#ifdef __linux__ #include <linux/futex.h> #include <sys/syscall.h> @@ -261,7 +261,7 @@ private: std::atomic<int32> m_lock_word; }; -#endif /* HAVE_IB_LINUX_FUTEX */ +#endif /* __linux__ */ template <template <typename> class Policy> struct TTASMutex { diff --git a/storage/innobase/include/os0proc.h b/storage/innobase/include/os0proc.h index d8952a56cc9..381e1e9cd21 100644 --- a/storage/innobase/include/os0proc.h +++ b/storage/innobase/include/os0proc.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2019, MariaDB Corporation. +Copyright (c) 2017, 2022, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -30,7 +30,7 @@ Created 9/30/1995 Heikki Tuuri #include "univ.i" -#ifdef UNIV_LINUX +#ifdef __linux__ #include <sys/ipc.h> #include <sys/shm.h> #endif diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index ddb27c107ff..b60ecaa9f1b 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -505,7 +505,7 @@ contains the sum of the following flag and the locally stored len. */ #endif /* CHECK FOR GCC VER_GT_2 */ /* Some macros to improve branch prediction and reduce cache misses */ -#if defined(COMPILER_HINTS) && defined(__GNUC__) +#ifdef __GNUC__ /* Tell the compiler that 'expr' probably evaluates to 'constant'. */ # define UNIV_EXPECT(expr,constant) __builtin_expect(expr, constant) /* Tell the compiler that a pointer is likely to be NULL */ @@ -525,16 +525,11 @@ it is read or written. */ # define UNIV_EXPECT(expr,value) (expr) # define UNIV_LIKELY_NULL(expr) (expr) -# if defined(COMPILER_HINTS) //# define UNIV_PREFETCH_R(addr) sun_prefetch_read_many((void*) addr) -# define UNIV_PREFETCH_R(addr) ((void) 0) -# define UNIV_PREFETCH_RW(addr) sun_prefetch_write_many(addr) -# else -# define UNIV_PREFETCH_R(addr) ((void) 0) -# define UNIV_PREFETCH_RW(addr) ((void) 0) -# endif /* COMPILER_HINTS */ - -# elif defined __WIN__ && defined COMPILER_HINTS +# define UNIV_PREFETCH_R(addr) ((void) 0) +# define UNIV_PREFETCH_RW(addr) sun_prefetch_write_many(addr) + +# elif defined __WIN__ # include <xmmintrin.h> # define UNIV_EXPECT(expr,value) (expr) # define UNIV_LIKELY_NULL(expr) (expr) diff --git a/storage/innobase/include/ut0mutex.h b/storage/innobase/include/ut0mutex.h index e1b6d129b9d..abdd5729d43 100644 --- a/storage/innobase/include/ut0mutex.h +++ b/storage/innobase/include/ut0mutex.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2012, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2020, MariaDB Corporation. +Copyright (c) 2017, 2022, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -38,10 +38,10 @@ Created 2012-03-24 Sunny Bains. @param[in] T The resulting typedef alias */ #define UT_MUTEX_TYPE(M, P, T) typedef PolicyMutex<M<P> > T; -# ifdef HAVE_IB_LINUX_FUTEX +# ifdef __linux__ UT_MUTEX_TYPE(TTASFutexMutex, GenericPolicy, FutexMutex); UT_MUTEX_TYPE(TTASFutexMutex, BlockMutexPolicy, BlockFutexMutex); -# endif /* HAVE_IB_LINUX_FUTEX */ +# endif /* __linux__ */ UT_MUTEX_TYPE(TTASMutex, GenericPolicy, SpinMutex); UT_MUTEX_TYPE(TTASMutex, BlockMutexPolicy, BlockSpinMutex); diff --git a/storage/innobase/innodb.cmake b/storage/innobase/innodb.cmake deleted file mode 100644 index dede8e8d3cd..00000000000 --- a/storage/innobase/innodb.cmake +++ /dev/null @@ -1,248 +0,0 @@ -# Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2017, 2022, MariaDB Corporation. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -# This is the CMakeLists for InnoDB - -INCLUDE(CheckFunctionExists) -INCLUDE(CheckCSourceCompiles) -INCLUDE(CheckCSourceRuns) -INCLUDE(lz4.cmake) -INCLUDE(lzo.cmake) -INCLUDE(lzma.cmake) -INCLUDE(bzip2.cmake) -INCLUDE(snappy.cmake) -INCLUDE(numa) -INCLUDE(TestBigEndian) - -MYSQL_CHECK_LZ4() -MYSQL_CHECK_LZO() -MYSQL_CHECK_LZMA() -MYSQL_CHECK_BZIP2() -MYSQL_CHECK_SNAPPY() -MYSQL_CHECK_NUMA() - -INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/compile_flags.cmake) - -IF(CMAKE_CROSSCOMPILING) - # Use CHECK_C_SOURCE_COMPILES instead of CHECK_C_SOURCE_RUNS when - # cross-compiling. Not as precise, but usually good enough. - # This only make sense for atomic tests in this file, this trick doesn't - # work in a general case. - MACRO(CHECK_C_SOURCE SOURCE VAR) - CHECK_C_SOURCE_COMPILES("${SOURCE}" "${VAR}") - ENDMACRO() -ELSE() - MACRO(CHECK_C_SOURCE SOURCE VAR) - CHECK_C_SOURCE_RUNS("${SOURCE}" "${VAR}") - ENDMACRO() -ENDIF() - -# OS tests -IF(UNIX) - IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") - - ADD_DEFINITIONS("-DUNIV_LINUX -D_GNU_SOURCE=1") - - CHECK_INCLUDE_FILES (libaio.h HAVE_LIBAIO_H) - CHECK_LIBRARY_EXISTS(aio io_queue_init "" HAVE_LIBAIO) - - IF(HAVE_LIBAIO_H AND HAVE_LIBAIO) - ADD_DEFINITIONS(-DLINUX_NATIVE_AIO=1) - LINK_LIBRARIES(aio) - ENDIF() - IF(HAVE_LIBNUMA) - LINK_LIBRARIES(numa) - ENDIF() - ELSEIF(CMAKE_SYSTEM_NAME MATCHES "HP*") - ADD_DEFINITIONS("-DUNIV_HPUX") - ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "AIX") - ADD_DEFINITIONS("-DUNIV_AIX") - ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS") - ADD_DEFINITIONS("-DUNIV_SOLARIS") - ENDIF() -ENDIF() - -OPTION(INNODB_COMPILER_HINTS "Compile InnoDB with compiler hints" ON) -MARK_AS_ADVANCED(INNODB_COMPILER_HINTS) - -IF(INNODB_COMPILER_HINTS) - ADD_DEFINITIONS("-DCOMPILER_HINTS") -ENDIF() -ADD_FEATURE_INFO(INNODB_COMPILER_HINTS INNODB_COMPILER_HINTS "InnoDB compiled with compiler hints") - -SET(MUTEXTYPE "event" CACHE STRING "Mutex type: event, sys or futex") - -IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU") -# After: WL#5825 Using C++ Standard Library with MySQL code -# we no longer use -fno-exceptions -# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions") - -# Add -Wconversion if compiling with GCC -## As of Mar 15 2011 this flag causes 3573+ warnings. If you are reading this -## please fix them and enable the following code: -#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wconversion") - - IF (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64" OR - CMAKE_SYSTEM_PROCESSOR MATCHES "i386" AND - CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6) - INCLUDE(CheckCXXCompilerFlag) - CHECK_CXX_COMPILER_FLAG("-fno-builtin-memcmp" HAVE_NO_BUILTIN_MEMCMP) - IF (HAVE_NO_BUILTIN_MEMCMP) - # Work around http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052 - SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/rem/rem0cmp.cc - PROPERTIES COMPILE_FLAGS -fno-builtin-memcmp) - ENDIF() - ENDIF() -ENDIF() - -# Enable InnoDB's UNIV_DEBUG in debug builds -SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DUNIV_DEBUG") - -OPTION(WITH_INNODB_AHI "Include innodb_adaptive_hash_index" ON) -OPTION(WITH_INNODB_ROOT_GUESS "Cache index root block descriptors" ON) -IF(WITH_INNODB_AHI) - ADD_DEFINITIONS(-DBTR_CUR_HASH_ADAPT -DBTR_CUR_ADAPT) - IF(NOT WITH_INNODB_ROOT_GUESS) - MESSAGE(WARNING "WITH_INNODB_AHI implies WITH_INNODB_ROOT_GUESS") - SET(WITH_INNODB_ROOT_GUESS ON) - ENDIF() -ELSEIF(WITH_INNODB_ROOT_GUESS) - ADD_DEFINITIONS(-DBTR_CUR_ADAPT) -ENDIF() -ADD_FEATURE_INFO(INNODB_AHI WITH_INNODB_AHI "InnoDB Adaptive Hash Index") -ADD_FEATURE_INFO(INNODB_ROOT_GUESS WITH_INNODB_ROOT_GUESS - "Cache index root block descriptors in InnoDB") - -OPTION(WITH_INNODB_EXTRA_DEBUG "Enable extra InnoDB debug checks" OFF) -IF(WITH_INNODB_EXTRA_DEBUG) - ADD_DEFINITIONS(-DUNIV_ZIP_DEBUG) -ENDIF() -ADD_FEATURE_INFO(INNODB_EXTRA_DEBUG WITH_INNODB_EXTRA_DEBUG "Extra InnoDB debug checks") - - -CHECK_FUNCTION_EXISTS(sched_getcpu HAVE_SCHED_GETCPU) -IF(HAVE_SCHED_GETCPU) - ADD_DEFINITIONS(-DHAVE_SCHED_GETCPU=1) -ENDIF() - -CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP) -IF(HAVE_NANOSLEEP) - ADD_DEFINITIONS(-DHAVE_NANOSLEEP=1) -ENDIF() - -IF(HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE) - ADD_DEFINITIONS(-DHAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE=1) -ENDIF() - -IF(NOT MSVC) - # Work around MDEV-18417, MDEV-18656, MDEV-18417 - IF(WITH_ASAN AND CMAKE_COMPILER_IS_GNUCC AND - CMAKE_C_COMPILER_VERSION VERSION_LESS "6.0.0") - SET_SOURCE_FILES_PROPERTIES(trx/trx0rec.cc PROPERTIES COMPILE_FLAGS -O1) - ENDIF() - -# Only use futexes on Linux if GCC atomics are available -IF(NOT MSVC AND NOT CMAKE_CROSSCOMPILING) - CHECK_C_SOURCE_RUNS( - " - #include <stdio.h> - #include <unistd.h> - #include <errno.h> - #include <assert.h> - #include <linux/futex.h> - #include <unistd.h> - #include <sys/syscall.h> - - int futex_wait(int* futex, int v) { - return(syscall(SYS_futex, futex, FUTEX_WAIT_PRIVATE, v, NULL, NULL, 0)); - } - - int futex_signal(int* futex) { - return(syscall(SYS_futex, futex, FUTEX_WAKE, 1, NULL, NULL, 0)); - } - - int main() { - int ret; - int m = 1; - - /* It is setup to fail and return EWOULDBLOCK. */ - ret = futex_wait(&m, 0); - assert(ret == -1 && errno == EWOULDBLOCK); - /* Shouldn't wake up any threads. */ - assert(futex_signal(&m) == 0); - - return(0); - }" - HAVE_IB_LINUX_FUTEX) -ENDIF() - -IF(HAVE_IB_LINUX_FUTEX) - ADD_DEFINITIONS(-DHAVE_IB_LINUX_FUTEX=1) -ENDIF() - -ENDIF(NOT MSVC) - -CHECK_FUNCTION_EXISTS(vasprintf HAVE_VASPRINTF) - -SET(MUTEXTYPE "event" CACHE STRING "Mutex type: event, sys or futex") - -IF(MUTEXTYPE MATCHES "event") - ADD_DEFINITIONS(-DMUTEX_EVENT) -ELSEIF(MUTEXTYPE MATCHES "futex" AND DEFINED HAVE_IB_LINUX_FUTEX) - ADD_DEFINITIONS(-DMUTEX_FUTEX) -ELSE() - ADD_DEFINITIONS(-DMUTEX_SYS) -ENDIF() - - -# Include directories under innobase -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/storage/innobase/include - ${CMAKE_SOURCE_DIR}/storage/innobase/handler) - -# Sun Studio bug with -xO2 -IF(CMAKE_CXX_COMPILER_ID MATCHES "SunPro" - AND CMAKE_CXX_FLAGS_RELEASE MATCHES "O2" - AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug") - # Sun Studio 12 crashes with -xO2 flag, but not with higher optimization - # -xO3 - SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/rem/rem0rec.cc - PROPERTIES COMPILE_FLAGS -xO3) -ENDIF() - -# Avoid generating Hardware Capabilities due to crc32 instructions -IF(CMAKE_SYSTEM_NAME MATCHES "SunOS" AND CMAKE_SYSTEM_PROCESSOR MATCHES "i386") - MY_CHECK_CXX_COMPILER_FLAG("-Wa,-nH") - IF(have_CXX__Wa__nH) - ADD_COMPILE_FLAGS( - ut/ut0crc32.cc - COMPILE_FLAGS "-Wa,-nH" - ) - ENDIF() -ENDIF() - -IF(MSVC) - # Avoid "unreferenced label" warning in generated file - GET_FILENAME_COMPONENT(_SRC_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) - SET_SOURCE_FILES_PROPERTIES(${_SRC_DIR}/pars/pars0grm.c - PROPERTIES COMPILE_FLAGS "/wd4102") - SET_SOURCE_FILES_PROPERTIES(${_SRC_DIR}/pars/lexyy.c - PROPERTIES COMPILE_FLAGS "/wd4003") -ENDIF() - -# Include directories under innobase -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/storage/innobase/include - ${CMAKE_SOURCE_DIR}/storage/innobase/handler - ${CMAKE_SOURCE_DIR}/libbinlogevents/include ) diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index d31a7d29380..b40e41cbab9 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -37,7 +37,7 @@ Created 10/21/1995 Heikki Tuuri #include "os0file.h" #include "sql_const.h" -#ifdef UNIV_LINUX +#ifdef __linux__ # include <sys/types.h> # include <sys/stat.h> #endif @@ -63,7 +63,7 @@ Created 10/21/1995 Heikki Tuuri # include <linux/falloc.h> #endif /* HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE */ -#if defined(UNIV_LINUX) && defined(HAVE_SYS_IOCTL_H) +#if defined(__linux__) && defined(HAVE_SYS_IOCTL_H) # include <sys/ioctl.h> # ifndef DFS_IOCTL_ATOMIC_WRITE_SET # define DFS_IOCTL_ATOMIC_WRITE_SET _IOW(0x95, 2, uint) @@ -1516,7 +1516,7 @@ os_file_punch_hole_posix( return(DB_IO_ERROR); -#elif defined(UNIV_SOLARIS) +#elif defined __sun__ // Use F_FREESP @@ -4533,10 +4533,11 @@ os_file_io( @param[in] type IO context @param[in] file handle to an open file @param[out] buf buffer from which to write -@param[in] n number of bytes to read, starting from offset -@param[in] offset file offset from the start where to read +@param[in] n number of bytes to write, starting from offset +@param[in] offset file offset from the start where to write @param[out] err DB_SUCCESS or error code -@return number of bytes written, -1 if error */ +@return number of bytes written +@retval -1 on error */ static MY_ATTRIBUTE((warn_unused_result)) ssize_t os_file_pwrite( @@ -4815,7 +4816,7 @@ os_file_set_nocache( const char* operation_name MY_ATTRIBUTE((unused))) { /* some versions of Solaris may not have DIRECTIO_ON */ -#if defined(UNIV_SOLARIS) && defined(DIRECTIO_ON) +#if defined(__sun__) && defined(DIRECTIO_ON) if (directio(fd, DIRECTIO_ON) == -1) { int errno_save = errno; @@ -4832,7 +4833,7 @@ os_file_set_nocache( if (errno_save == EINVAL) { if (!warning_message_printed) { warning_message_printed = true; -# ifdef UNIV_LINUX +# ifdef __linux__ ib::warn() << "Failed to set O_DIRECT on file" << file_name << "; " << operation_name @@ -4841,12 +4842,12 @@ os_file_set_nocache( "known to result in 'Invalid argument' " "on Linux on tmpfs, " "see MySQL Bug#26662."; -# else /* UNIV_LINUX */ +# else /* __linux__ */ goto short_warning; -# endif /* UNIV_LINUX */ +# endif /* __linux__ */ } } else { -# ifndef UNIV_LINUX +# ifndef __linux__ short_warning: # endif ib::warn() @@ -4856,7 +4857,7 @@ short_warning: << ", continuing anyway."; } } -#endif /* defined(UNIV_SOLARIS) && defined(DIRECTIO_ON) */ +#endif /* defined(__sun__) && defined(DIRECTIO_ON) */ } #endif /* _WIN32 */ @@ -7465,7 +7466,7 @@ void fil_node_t::find_metadata(os_file_t file block_size = statbuf->st_blksize; } on_ssd = space->atomic_write_supported -# ifdef UNIV_LINUX +# ifdef __linux__ || (statbuf && fil_system.is_ssd(statbuf->st_dev)) # endif ; @@ -7576,7 +7577,7 @@ invalid: if (first) { ut_ad(space->id != TRX_SYS_SPACE); -#ifdef UNIV_LINUX +#ifdef __linux__ find_metadata(handle, &statbuf); #else find_metadata(); diff --git a/storage/innobase/os/os0proc.cc b/storage/innobase/os/os0proc.cc index d22b6ffe887..d6d64a47b91 100644 --- a/storage/innobase/os/os0proc.cc +++ b/storage/innobase/os/os0proc.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2019, 2020, MariaDB Corporation. +Copyright (c) 2019, 2022, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -180,11 +180,11 @@ os_mem_free_large( #elif !defined OS_MAP_ANON ut_free(ptr); #else -# if defined(UNIV_SOLARIS) +# if defined(__sun__) if (munmap(static_cast<caddr_t>(ptr), size)) { # else if (munmap(ptr, size)) { -# endif /* UNIV_SOLARIS */ +# endif /* __sun__ */ ib::error() << "munmap(" << ptr << ", " << size << ") failed;" " errno " << errno; } else { diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 894722964ae..7661994394c 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -3363,12 +3363,12 @@ row_merge_sort( is used. MDEV-9356: innodb.innodb_bug53290 fails (crashes) on sol10-64 in buildbot. */ -#ifndef UNIV_SOLARIS +#ifndef __sun__ /* Progress report only for "normal" indexes. */ if (!(dup->index->type & DICT_FTS)) { thd_progress_init(trx->mysql_thd, 1); } -#endif /* UNIV_SOLARIS */ +#endif /* __sun__ */ if (global_system_variables.log_warnings > 2) { sql_print_information("InnoDB: Online DDL : merge-sorting" @@ -3381,11 +3381,11 @@ row_merge_sort( /* Report progress of merge sort to MySQL for show processlist progress field */ /* Progress report only for "normal" indexes. */ -#ifndef UNIV_SOLARIS +#ifndef __sun__ if (!(dup->index->type & DICT_FTS)) { thd_progress_report(trx->mysql_thd, file->offset - num_runs, file->offset); } -#endif /* UNIV_SOLARIS */ +#endif /* __sun__ */ error = row_merge(trx, dup, file, block, tmpfd, &num_runs, run_offset, stage, @@ -3410,11 +3410,11 @@ row_merge_sort( ut_free(run_offset); /* Progress report only for "normal" indexes. */ -#ifndef UNIV_SOLARIS +#ifndef __sun__ if (!(dup->index->type & DICT_FTS)) { thd_progress_end(trx->mysql_thd); } -#endif /* UNIV_SOLARIS */ +#endif /* __sun__ */ DBUG_RETURN(error); } diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 00864234380..30e2d7c6fbb 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -604,12 +604,12 @@ srv_undo_tablespace_create( } else if (ret == FALSE) { if (os_file_get_last_error(false) != OS_FILE_ALREADY_EXISTS -#ifdef UNIV_AIX +#ifdef _AIX /* AIX 5.1 after security patch ML7 may have errno set to 0 here, which causes our function to return 100; work around that AIX problem */ && os_file_get_last_error(false) != 100 -#endif /* UNIV_AIX */ +#endif ) { ib::error() << "Can't create UNDO tablespace " << name; @@ -1569,10 +1569,10 @@ dberr_t srv_start(bool create_new_db) buf_flush_set_page_cleaner_thread_cnt(srv_n_page_cleaners); } -#ifdef UNIV_LINUX +#ifdef __linux__ /* Wait for the setpriority() call to finish. */ os_event_wait(recv_sys.flush_end); -#endif /* UNIV_LINUX */ +#endif /* __linux__ */ srv_start_state_set(SRV_START_STATE_IO); } diff --git a/storage/myisam/mi_test3.c b/storage/myisam/mi_test3.c index 30cf95c47a4..74684edd5bc 100644 --- a/storage/myisam/mi_test3.c +++ b/storage/myisam/mi_test3.c @@ -401,7 +401,7 @@ int test_write(MI_INFO *file,int id,int lock_type) int test_update(MI_INFO *file,int id,int lock_type) { - uint i,lock,found,next,prev,update; + uint i,lock,update; uint32 tmp; char find[4]; struct record new_record; @@ -424,24 +424,20 @@ int test_update(MI_INFO *file,int id,int lock_type) bzero((char*) &new_record,sizeof(new_record)); strmov((char*) new_record.text,"Updated"); - found=next=prev=update=0; + update=0; for (i=0 ; i < 100 ; i++) { tmp=rnd(100000); int4store(find,tmp); - if (!mi_rkey(file,record.id,1,(uchar*) find, HA_WHOLE_KEY, - HA_READ_KEY_EXACT)) - found++; - else + if (mi_rkey(file,record.id,1,(uchar*) find, HA_WHOLE_KEY, + HA_READ_KEY_EXACT)) { if (my_errno != HA_ERR_KEY_NOT_FOUND) { fprintf(stderr,"%2d: Got error %d from read in update\n",id,my_errno); return 1; } - else if (!mi_rnext(file,record.id,1)) - next++; - else + else if (mi_rnext(file,record.id,1)) { if (my_errno != HA_ERR_END_OF_FILE) { @@ -449,9 +445,7 @@ int test_update(MI_INFO *file,int id,int lock_type) id,my_errno); return 1; } - else if (!mi_rprev(file,record.id,1)) - prev++; - else + else if (mi_rprev(file,record.id,1)) { if (my_errno != HA_ERR_END_OF_FILE) { |