connection node_2;
connection node_1;
#
# MDEV-28263: mariadb-tzinfo-to-sql improve wsrep and binlog cases
#

# On node_1
connection node_1;
CREATE TABLE time_zone LIKE mysql.time_zone;
CREATE TABLE time_zone_name LIKE mysql.time_zone_name;
CREATE TABLE time_zone_transition LIKE mysql.time_zone_transition;
CREATE TABLE time_zone_transition_type LIKE mysql.time_zone_transition_type;
CREATE TABLE time_zone_leap_second LIKE mysql.time_zone_leap_second;
ALTER TABLE time_zone_name ENGINE=MyISAM;
ALTER TABLE time_zone_transition_type ENGINE=MyISAM;
SET @save_wsrep_mode=@@WSREP_MODE;
#
# Run on zoneinfo directory --skip-write-binlog
#

# Apply on node_1

Warnings:
Warning	4200	The setting 'alter_algorithm' is ignored. It only exists for compatibility with old installations and will be removed in a future release
Warnings:
Warning	4200	The setting 'alter_algorithm' is ignored. It only exists for compatibility with old installations and will be removed in a future release
'binlog stationary as expected'
SELECT @wsrep_is_on,  @wsrep_cannot_replicate_tz, @save_wsrep_on, @save_sql_log_bin, @@WSREP_ON, @@SQL_LOG_BIN;
@wsrep_is_on	@wsrep_cannot_replicate_tz	@save_wsrep_on	@save_sql_log_bin	@@WSREP_ON	@@SQL_LOG_BIN
1	0	1	1	1	1
SELECT g.VARIABLE_NAME, g.VARIABLE_VALUE - b.VARIABLE_VALUE AS diff
FROM information_schema.global_status g
JOIN baseline b USING (VARIABLE_NAME)
ORDER BY g.VARIABLE_NAME;
VARIABLE_NAME	diff
COM_ALTER_TABLE	2
COM_BEGIN	0
COM_INSERT	6
COM_LOCK_TABLES	1
COM_TRUNCATE	4
SELECT COUNT(*) FROM time_zone;
COUNT(*)
2
SELECT COUNT(*) FROM time_zone_name;
COUNT(*)
2
SELECT COUNT(*) FROM time_zone_transition;
COUNT(*)
0
SELECT COUNT(*) FROM time_zone_transition_type;
COUNT(*)
2
SELECT COUNT(*) FROM time_zone_leap_second;
COUNT(*)
0

# On node_2 (not replicated)

connection node_2;
SELECT COUNT(*) FROM time_zone;
COUNT(*)
0
SELECT COUNT(*) FROM time_zone_name;
COUNT(*)
0
SELECT COUNT(*) FROM time_zone_transition;
COUNT(*)
0
SELECT COUNT(*) FROM time_zone_transition_type;
COUNT(*)
0
SELECT COUNT(*) FROM time_zone_leap_second;
COUNT(*)
0

# Apply on node_1

connection node_1;
SET GLOBAL WSREP_MODE='REPLICATE_ARIA,REPLICATE_MYISAM';
Warnings:
Warning	4200	The setting 'alter_algorithm' is ignored. It only exists for compatibility with old installations and will be removed in a future release
Warnings:
Warning	4200	The setting 'alter_algorithm' is ignored. It only exists for compatibility with old installations and will be removed in a future release
'binlog stationary as expected'
SELECT @wsrep_is_on,  @wsrep_cannot_replicate_tz, @save_wsrep_on, @save_sql_log_bin, @@WSREP_ON, @@SQL_LOG_BIN;
@wsrep_is_on	@wsrep_cannot_replicate_tz	@save_wsrep_on	@save_sql_log_bin	@@WSREP_ON	@@SQL_LOG_BIN
1	0	1	1	1	1
SELECT g.VARIABLE_NAME, g.VARIABLE_VALUE - b.VARIABLE_VALUE AS diff
FROM information_schema.global_status g
JOIN baseline b USING (VARIABLE_NAME)
ORDER BY g.VARIABLE_NAME;
VARIABLE_NAME	diff
COM_ALTER_TABLE	2
COM_BEGIN	0
COM_INSERT	6
COM_LOCK_TABLES	1
COM_TRUNCATE	4
SELECT COUNT(*) FROM time_zone;
COUNT(*)
2
SELECT COUNT(*) FROM time_zone_name;
COUNT(*)
2
SELECT COUNT(*) FROM time_zone_transition;
COUNT(*)
0
SELECT COUNT(*) FROM time_zone_transition_type;
COUNT(*)
2
SELECT COUNT(*) FROM time_zone_leap_second;
COUNT(*)
0

# On node_2 (not replicated)

connection node_2;
SELECT COUNT(*) FROM time_zone;
COUNT(*)
0
SELECT COUNT(*) FROM time_zone_name;
COUNT(*)
0
SELECT COUNT(*) FROM time_zone_transition;
COUNT(*)
0
SELECT COUNT(*) FROM time_zone_transition_type;
COUNT(*)
0
SELECT COUNT(*) FROM time_zone_leap_second;
COUNT(*)
0
#
# Run on zoneinfo directory without --skip-write-binlog
#

# Apply on node_1

connection node_1;
Warnings:
Warning	4200	The setting 'alter_algorithm' is ignored. It only exists for compatibility with old installations and will be removed in a future release
Warnings:
Warning	4200	The setting 'alter_algorithm' is ignored. It only exists for compatibility with old installations and will be removed in a future release
'binlog advanced as expected'
SELECT @wsrep_is_on,  @wsrep_cannot_replicate_tz, @save_wsrep_on, @save_sql_log_bin, @@WSREP_ON, @@SQL_LOG_BIN;
@wsrep_is_on	@wsrep_cannot_replicate_tz	@save_wsrep_on	@save_sql_log_bin	@@WSREP_ON	@@SQL_LOG_BIN
1	0	1	1	1	1
SELECT g.VARIABLE_NAME, g.VARIABLE_VALUE - b.VARIABLE_VALUE AS diff
FROM information_schema.global_status g
JOIN baseline b USING (VARIABLE_NAME)
ORDER BY g.VARIABLE_NAME;
VARIABLE_NAME	diff
COM_ALTER_TABLE	2
COM_BEGIN	0
COM_INSERT	6
COM_LOCK_TABLES	1
COM_TRUNCATE	4
SELECT COUNT(*) FROM time_zone;
COUNT(*)
2
SELECT COUNT(*) FROM time_zone_name;
COUNT(*)
2
SELECT COUNT(*) FROM time_zone_transition;
COUNT(*)
0
SELECT COUNT(*) FROM time_zone_transition_type;
COUNT(*)
2
SELECT COUNT(*) FROM time_zone_leap_second;
COUNT(*)
0

# On node_2 (replicated via ARIA)

connection node_2;
SELECT COUNT(*) FROM time_zone;
COUNT(*)
2
SELECT COUNT(*) FROM time_zone_name;
COUNT(*)
0
SELECT COUNT(*) FROM time_zone_transition;
COUNT(*)
0
SELECT COUNT(*) FROM time_zone_transition_type;
COUNT(*)
0
SELECT COUNT(*) FROM time_zone_leap_second;
COUNT(*)
0
TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
TRUNCATE TABLE time_zone_transition_type;
TRUNCATE TABLE time_zone_leap_second;

# Apply on node_1

connection node_1;
SET GLOBAL WSREP_MODE='';
Warnings:
Warning	4200	The setting 'alter_algorithm' is ignored. It only exists for compatibility with old installations and will be removed in a future release
Warnings:
Warning	4200	The setting 'alter_algorithm' is ignored. It only exists for compatibility with old installations and will be removed in a future release
'binlog advanced as expected'
SELECT @wsrep_is_on, @wsrep_cannot_replicate_tz, @save_wsrep_on, @save_sql_log_bin, @@WSREP_ON, @@SQL_LOG_BIN;
@wsrep_is_on	@wsrep_cannot_replicate_tz	@save_wsrep_on	@save_sql_log_bin	@@WSREP_ON	@@SQL_LOG_BIN
1	1	1	1	1	1
SELECT g.VARIABLE_NAME, g.VARIABLE_VALUE - b.VARIABLE_VALUE AS diff
FROM information_schema.global_status g
JOIN baseline b USING (VARIABLE_NAME)
ORDER BY g.VARIABLE_NAME;
VARIABLE_NAME	diff
COM_ALTER_TABLE	8
COM_BEGIN	1
COM_INSERT	6
COM_LOCK_TABLES	0
COM_TRUNCATE	4
SELECT COUNT(*) FROM time_zone;
COUNT(*)
2
SELECT COUNT(*) FROM time_zone_name;
COUNT(*)
2
SELECT COUNT(*) FROM time_zone_transition;
COUNT(*)
0
SELECT COUNT(*) FROM time_zone_transition_type;
COUNT(*)
2
SELECT COUNT(*) FROM time_zone_leap_second;
COUNT(*)
0
SELECT TABLE_NAME, ENGINE FROM information_schema.TABLES
WHERE
TABLE_SCHEMA = DATABASE()
AND TABLE_NAME LIKE 'time_zone%' ORDER BY TABLE_NAME;
TABLE_NAME	ENGINE
time_zone	Aria
time_zone_leap_second	Aria
time_zone_name	MyISAM
time_zone_transition	Aria
time_zone_transition_type	MyISAM

# On node_2 (replicated via InnoDB)

connection node_2;
SELECT COUNT(*) FROM time_zone;
COUNT(*)
2
SELECT COUNT(*) FROM time_zone_name;
COUNT(*)
2
SELECT COUNT(*) FROM time_zone_transition;
COUNT(*)
0
SELECT COUNT(*) FROM time_zone_transition_type;
COUNT(*)
2
SELECT COUNT(*) FROM time_zone_leap_second;
COUNT(*)
0
connection node_1;
SET GLOBAL WSREP_MODE=@save_wsrep_mode;
DROP TABLE baseline;
DROP TABLE time_zone;
DROP TABLE time_zone_name;
DROP TABLE time_zone_transition;
DROP TABLE time_zone_transition_type;
DROP TABLE time_zone_leap_second;
#
# End of 10.6 tests
#
