Skip to content

Commit

Permalink
Merge pull request #1602 from EvgeniyPatlan/release-5.7.17-12
Browse files Browse the repository at this point in the history
lp1676401 : mysqldump using deprecated variable
  • Loading branch information
EvgeniyPatlan authored Apr 3, 2017
2 parents 1e87281 + 5a66ee3 commit fd33d43
Show file tree
Hide file tree
Showing 14 changed files with 943 additions and 624 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MYSQL_VERSION_MAJOR=5
MYSQL_VERSION_MINOR=7
MYSQL_VERSION_PATCH=17
MYSQL_VERSION_EXTRA=-12
MYSQL_VERSION_EXTRA=-13
68 changes: 48 additions & 20 deletions client/mysqldump.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,22 +787,34 @@ static void write_header(FILE *sql_file, char *db_name)
"/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;\n",
path?"":"NO_AUTO_VALUE_ON_ZERO",compatible_mode_normal_str[0]==0?"":",",
compatible_mode_normal_str);

// This is specifically to allow MyRocks to bulk load a dump faster
// We have no interest in anything earlier than 5.7 and 17 being the
// current release. 5.7.8 and after can only use P_S for session_variables
// and never I_S. So we first check that P_S is present and the
// session_variables table exists. If no, we simply skip the optimization
// assuming that MyRocks isn't present either. If it is, ohh well, bulk
// loader will not be invoked.
fprintf(sql_file,
"/*!50112 SELECT COUNT(*) INTO @is_rocksdb_supported FROM"
" INFORMATION_SCHEMA.SESSION_VARIABLES WHERE"
" VARIABLE_NAME='rocksdb_bulk_load' */;\n"
"/*!50112 SET @save_old_rocksdb_bulk_load ="
" IF (@is_rocksdb_supported,"
" 'SET @old_rocksdb_bulk_load = @@rocksdb_bulk_load',"
" 'SET @dummy_old_rocksdb_bulk_load = 0') */;\n"
"/*!50112 PREPARE s FROM @save_old_rocksdb_bulk_load */;\n"
"/*!50112 EXECUTE s */;\n"
"/*!50112 SET @enable_bulk_load = IF (@is_rocksdb_supported,"
" 'SET SESSION rocksdb_bulk_load = 1',"
" 'SET @dummy_rocksdb_bulk_load = 0') */;\n"
"/*!50112 PREPARE s FROM @enable_bulk_load */;\n"
"/*!50112 EXECUTE s */;\n"
"/*!50112 DEALLOCATE PREPARE s */;\n");
"/*!50717 SET @rocksdb_bulk_load_var_name='rocksdb_bulk_load' */;\n"
"/*!50717 SELECT COUNT(*) INTO @rocksdb_has_p_s_session_variables"
" FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA ="
" 'performance_schema' AND TABLE_NAME = 'session_variables'"
" */;\n"
"/*!50717 SET @rocksdb_get_is_supported = IF"
" (@rocksdb_has_p_s_session_variables, 'SELECT COUNT(*) INTO"
" @rocksdb_is_supported FROM performance_schema.session_variables"
" WHERE VARIABLE_NAME=?', 'SELECT 0') */;\n"
"/*!50717 PREPARE s FROM @rocksdb_get_is_supported */;\n"
"/*!50717 EXECUTE s USING @rocksdb_bulk_load_var_name */;\n"
"/*!50717 DEALLOCATE PREPARE s */;\n"
"/*!50717 SET @rocksdb_enable_bulk_load = IF"
" (@rocksdb_is_supported, 'SET SESSION rocksdb_bulk_load = 1',"
" 'SET @rocksdb_dummy_bulk_load = 0') */;\n"
"/*!50717 PREPARE s FROM @rocksdb_enable_bulk_load */;\n"
"/*!50717 EXECUTE s */;\n"
"/*!50717 DEALLOCATE PREPARE s */;\n");


check_io(sql_file);
}
Expand Down Expand Up @@ -6883,19 +6895,35 @@ static my_bool has_session_variables_like(MYSQL *mysql_con, const char *var_name
MYSQL_RES *res;
MYSQL_ROW row;
char *val= 0;
char buf[32], query[256];
my_bool has_var= FALSE;
char buf[32], query[256];
my_bool has_var= FALSE;
my_bool has_table= FALSE;

my_snprintf(query, sizeof(query), "SELECT COUNT(*) FROM"
" INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME LIKE"
" %s", quote_for_like(var_name, buf));
" INFORMATION_SCHEMA.TABLES WHERE table_schema ="
" 'performance_schema' AND table_name = 'session_variables'");
if (mysql_query_with_error_report(mysql_con, &res, query))
return FALSE;

row = mysql_fetch_row(res);
val = row ? (char*)row[0] : NULL;
has_var = val && strcmp(val, "0") != 0;
has_table = val && strcmp(val, "0") != 0;
mysql_free_result(res);

if (has_table)
{
my_snprintf(query, sizeof(query), "SELECT COUNT(*) FROM"
" performance_schema.session_variables WHERE VARIABLE_NAME LIKE"
" %s", quote_for_like(var_name, buf));
if (mysql_query_with_error_report(mysql_con, &res, query))
return FALSE;

row = mysql_fetch_row(res);
val = row ? (char*)row[0] : NULL;
has_var = val && strcmp(val, "0") != 0;
mysql_free_result(res);
}

return has_var;
}

Expand Down
9 changes: 6 additions & 3 deletions mysql-test/r/backup_locks_mysqldump.result
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ root@localhost on using Socket
/*!40103 SET TIME_ZONE='+00:00' */
FLUSH TABLES
FLUSH TABLES WITH READ LOCK
SELECT COUNT(*) FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME LIKE 'rocksdb\_skip\_fill\_cache'
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'performance_schema' AND table_name = 'session_variables'
SELECT COUNT(*) FROM performance_schema.session_variables WHERE VARIABLE_NAME LIKE 'rocksdb\_skip\_fill\_cache'
SHOW VARIABLES LIKE 'gtid\_mode'
SELECT LOGFILE_GROUP_NAME, FILE_NAME, TOTAL_EXTENTS, INITIAL_SIZE, ENGINE, EXTRA FROM INFORMATION_SCHEMA.FILES WHERE FILE_TYPE = 'UNDO LOG' AND FILE_NAME IS NOT NULL AND LOGFILE_GROUP_NAME IS NOT NULL AND LOGFILE_GROUP_NAME IN (SELECT DISTINCT LOGFILE_GROUP_NAME FROM INFORMATION_SCHEMA.FILES WHERE FILE_TYPE = 'DATAFILE' AND TABLESPACE_NAME IN (SELECT DISTINCT TABLESPACE_NAME FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA IN ('test'))) GROUP BY LOGFILE_GROUP_NAME, FILE_NAME, ENGINE, TOTAL_EXTENTS, INITIAL_SIZE ORDER BY LOGFILE_GROUP_NAME
SELECT DISTINCT TABLESPACE_NAME, FILE_NAME, LOGFILE_GROUP_NAME, EXTENT_SIZE, INITIAL_SIZE, ENGINE FROM INFORMATION_SCHEMA.FILES WHERE FILE_TYPE = 'DATAFILE' AND TABLESPACE_NAME IN (SELECT DISTINCT TABLESPACE_NAME FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA IN ('test')) ORDER BY TABLESPACE_NAME, LOGFILE_GROUP_NAME
Expand Down Expand Up @@ -62,7 +63,8 @@ root@localhost on using Socket
/*!40103 SET TIME_ZONE='+00:00' */
SHOW VARIABLES LIKE 'have_backup_locks'
LOCK TABLES FOR BACKUP
SELECT COUNT(*) FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME LIKE 'rocksdb\_skip\_fill\_cache'
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'performance_schema' AND table_name = 'session_variables'
SELECT COUNT(*) FROM performance_schema.session_variables WHERE VARIABLE_NAME LIKE 'rocksdb\_skip\_fill\_cache'
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ
START TRANSACTION /*!40100 WITH CONSISTENT SNAPSHOT */
SHOW VARIABLES LIKE 'gtid\_mode'
Expand Down Expand Up @@ -112,7 +114,8 @@ root@localhost on using Socket
SHOW VARIABLES LIKE 'have_backup_locks'
SHOW STATUS LIKE 'binlog_snapshot_%'
LOCK TABLES FOR BACKUP
SELECT COUNT(*) FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME LIKE 'rocksdb\_skip\_fill\_cache'
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'performance_schema' AND table_name = 'session_variables'
SELECT COUNT(*) FROM performance_schema.session_variables WHERE VARIABLE_NAME LIKE 'rocksdb\_skip\_fill\_cache'
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ
START TRANSACTION /*!40100 WITH CONSISTENT SNAPSHOT */
SHOW VARIABLES LIKE 'gtid\_mode'
Expand Down
36 changes: 20 additions & 16 deletions mysql-test/r/mysqldump-max.result
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,16 @@ id name
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
/*!50112 SELECT COUNT(*) INTO @is_rocksdb_supported FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='rocksdb_bulk_load' */;
/*!50112 SET @save_old_rocksdb_bulk_load = IF (@is_rocksdb_supported, 'SET @old_rocksdb_bulk_load = @@rocksdb_bulk_load', 'SET @dummy_old_rocksdb_bulk_load = 0') */;
/*!50112 PREPARE s FROM @save_old_rocksdb_bulk_load */;
/*!50112 EXECUTE s */;
/*!50112 SET @enable_bulk_load = IF (@is_rocksdb_supported, 'SET SESSION rocksdb_bulk_load = 1', 'SET @dummy_rocksdb_bulk_load = 0') */;
/*!50112 PREPARE s FROM @enable_bulk_load */;
/*!50112 EXECUTE s */;
/*!50112 DEALLOCATE PREPARE s */;
/*!50717 SET @rocksdb_bulk_load_var_name='rocksdb_bulk_load' */;
/*!50717 SELECT COUNT(*) INTO @rocksdb_has_p_s_session_variables FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'performance_schema' AND TABLE_NAME = 'session_variables' */;
/*!50717 SET @rocksdb_get_is_supported = IF (@rocksdb_has_p_s_session_variables, 'SELECT COUNT(*) INTO @rocksdb_is_supported FROM performance_schema.session_variables WHERE VARIABLE_NAME=?', 'SELECT 0') */;
/*!50717 PREPARE s FROM @rocksdb_get_is_supported */;
/*!50717 EXECUTE s USING @rocksdb_bulk_load_var_name */;
/*!50717 DEALLOCATE PREPARE s */;
/*!50717 SET @rocksdb_enable_bulk_load = IF (@rocksdb_is_supported, 'SET SESSION rocksdb_bulk_load = 1', 'SET @rocksdb_dummy_bulk_load = 0') */;
/*!50717 PREPARE s FROM @rocksdb_enable_bulk_load */;
/*!50717 EXECUTE s */;
/*!50717 DEALLOCATE PREPARE s */;

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */;

Expand Down Expand Up @@ -209,14 +211,16 @@ UNLOCK TABLES;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
/*!50112 SELECT COUNT(*) INTO @is_rocksdb_supported FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='rocksdb_bulk_load' */;
/*!50112 SET @save_old_rocksdb_bulk_load = IF (@is_rocksdb_supported, 'SET @old_rocksdb_bulk_load = @@rocksdb_bulk_load', 'SET @dummy_old_rocksdb_bulk_load = 0') */;
/*!50112 PREPARE s FROM @save_old_rocksdb_bulk_load */;
/*!50112 EXECUTE s */;
/*!50112 SET @enable_bulk_load = IF (@is_rocksdb_supported, 'SET SESSION rocksdb_bulk_load = 1', 'SET @dummy_rocksdb_bulk_load = 0') */;
/*!50112 PREPARE s FROM @enable_bulk_load */;
/*!50112 EXECUTE s */;
/*!50112 DEALLOCATE PREPARE s */;
/*!50717 SET @rocksdb_bulk_load_var_name='rocksdb_bulk_load' */;
/*!50717 SELECT COUNT(*) INTO @rocksdb_has_p_s_session_variables FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'performance_schema' AND TABLE_NAME = 'session_variables' */;
/*!50717 SET @rocksdb_get_is_supported = IF (@rocksdb_has_p_s_session_variables, 'SELECT COUNT(*) INTO @rocksdb_is_supported FROM performance_schema.session_variables WHERE VARIABLE_NAME=?', 'SELECT 0') */;
/*!50717 PREPARE s FROM @rocksdb_get_is_supported */;
/*!50717 EXECUTE s USING @rocksdb_bulk_load_var_name */;
/*!50717 DEALLOCATE PREPARE s */;
/*!50717 SET @rocksdb_enable_bulk_load = IF (@rocksdb_is_supported, 'SET SESSION rocksdb_bulk_load = 1', 'SET @rocksdb_dummy_bulk_load = 0') */;
/*!50717 PREPARE s FROM @rocksdb_enable_bulk_load */;
/*!50717 EXECUTE s */;
/*!50717 DEALLOCATE PREPARE s */;

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */;

Expand Down
Loading

0 comments on commit fd33d43

Please sign in to comment.