Skip to content

Commit 13e7793

Browse files
committed
MDEV-28263: mariadb-tzinfo-to-sql improve wsrep and binlog cases
The --skip-write-binlog message was confusing that it only had an effect if the galera was enabled. There are uses beyond galera so we apply SET SESSION SQL_LOG_BIN=0 as implied by the option without being conditional on the wsrep status. We also with --skip-write-binlog actually check the session @@WSREP_ON variable rather than the global server variable. Since 10.6, the wsrep_mode could replicate Aria and MyISAM, in which case no change to innodb and back is needed. By removing the conditions, we can use LOCK TABLES in a general case improving the load speed of Aria (MDEV-23326), regardless of the skip-write-binlog flag. The only case where we don't use LOCK TABLES is when we are replicating via Innodb, because wsrep_on=1 and wsrep_mode doesn't contain REPLICATE_ARIA{,MYISAM}. This uses an Innodb transaction instead. When replicating via InnoDB we change the table engine type back to what it was originally. By removing the \d and other syntax that requires parsing by the mariadb client, we can use the generated SQL more generally, like in the embedded server. We also save and restore the SQL_LOG_BIN and WSREP_ON session server variables so this can be included in the same session as other data without taking into changes in state. Remove wsrep.mysql_tzinfo_to_sql_symlink{,_skip} tests as they offered no additional coverage beyond main.mysql_tzinfo_to_sql_symlink (no server testing was done). Add galera.mariadb_tzinfo_to_sql to actually test the replication of tzinfo data through galera. The conditional executable comment around /*M!100602 ... START TRANSACTION .. LOCK TABLES.. */ is so that we can provide tzinfo files (MDEV-27113, MDBF-389) and in the case that a user uses it on a pre-10.6 server version it will still work. Both START TRANSACTION and LOCK TABLES are not supported in prepared statements in MariaDB versions earlier than 10.6.2. Reviewed by Brandon Nesterenko
1 parent d91c268 commit 13e7793

11 files changed

+905
-348
lines changed

mysql-test/include/not_psprotocol.inc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Disable in mtr --ps-protocol
2+
--disable_abort_on_error
3+
--disable_result_log
4+
--disable_query_log
5+
/*M!100202 execute immediate 'select 1' */;
6+
--enable_query_log
7+
--enable_result_log
8+
--enable_abort_on_error
9+
let $error = $mysql_errno;
10+
# ER_UNSUPPORTED_PS
11+
if ($error == 1295)
12+
{
13+
--skip Test is not supported in the prepared statement protocol yet
14+
}

mysql-test/main/mysql_tzinfo_to_sql_symlink.result

Lines changed: 207 additions & 179 deletions
Large diffs are not rendered by default.
Lines changed: 101 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1+
--source include/have_innodb.inc
12
--source include/have_symlink.inc
23
--source include/not_windows.inc
3-
--source include/not_embedded.inc
4+
--source include/not_psprotocol.inc
45

5-
use mysql;
6-
RENAME TABLE time_zone TO time_zone_orig,
7-
time_zone_name TO time_zone_name_orig,
8-
time_zone_transition TO time_zone_transition_orig,
9-
time_zone_transition_type TO time_zone_transition_type_orig,
10-
time_zone_leap_second TO time_zone_leap_second_orig;
11-
CREATE TABLE time_zone LIKE time_zone_orig;
12-
CREATE TABLE time_zone_name LIKE time_zone_name_orig;
13-
CREATE TABLE time_zone_transition LIKE time_zone_transition_orig;
14-
CREATE TABLE time_zone_transition_type LIKE time_zone_transition_type_orig;
15-
CREATE TABLE time_zone_leap_second LIKE time_zone_leap_second_orig;
6+
CREATE TABLE time_zone LIKE mysql.time_zone;
7+
CREATE TABLE time_zone_name LIKE mysql.time_zone_name;
8+
CREATE TABLE time_zone_transition LIKE mysql.time_zone_transition;
9+
CREATE TABLE time_zone_transition_type LIKE mysql.time_zone_transition_type;
10+
CREATE TABLE time_zone_leap_second LIKE mysql.time_zone_leap_second;
1611

1712
--echo #
1813
--echo # MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above
@@ -27,16 +22,18 @@ CREATE TABLE time_zone_leap_second LIKE time_zone_leap_second_orig;
2722
--echo # Verbose run
2823
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
2924
--exec $MYSQL_TZINFO_TO_SQL --verbose $MYSQLTEST_VARDIR/zoneinfo 2>&1
30-
SELECT COUNT(*) FROM time_zone;
31-
SELECT COUNT(*) FROM time_zone_name;
32-
SELECT COUNT(*) FROM time_zone_transition;
33-
SELECT COUNT(*) FROM time_zone_transition_type;
34-
SELECT COUNT(*) FROM time_zone_leap_second;
25+
26+
--echo #
27+
--echo # MDEV-28263: mariadb-tzinfo-to-sql improve wsrep and binlog cases
28+
--echo #
3529

3630
--echo # Run on zoneinfo directory
3731
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
3832
--exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo 2>&1
39-
--exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo 2>/dev/null | $MYSQL -S $MASTER_MYSOCK -u root mysql
33+
--exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo > $MYSQL_TMP_DIR/tz.sql
34+
--disable_query_log
35+
--source $MYSQL_TMP_DIR/tz.sql
36+
--enable_query_log
4037
SELECT COUNT(*) FROM time_zone;
4138
SELECT COUNT(*) FROM time_zone_name;
4239
SELECT COUNT(*) FROM time_zone_transition;
@@ -49,13 +46,27 @@ SELECT COUNT(*) FROM time_zone_leap_second;
4946

5047
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
5148
--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo 2>&1
52-
--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo 2>/dev/null | $MYSQL -S $MASTER_MYSOCK -u root mysql
49+
--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo 2>/dev/null > $MYSQL_TMP_DIR/tz.sql
50+
--disable_query_log
51+
CREATE TEMPORARY TABLE baseline AS
52+
SELECT VARIABLE_NAME,VARIABLE_VALUE
53+
FROM information_schema.global_status
54+
WHERE VARIABLE_NAME IN ('COM_BEGIN', 'COM_INSERT', 'COM_LOCK_TABLES', 'COM_ALTER_TABLE', 'COM_TRUNCATE');
55+
--source $MYSQL_TMP_DIR/tz.sql
56+
--enable_query_log
57+
5358
SELECT COUNT(*) FROM time_zone;
5459
SELECT COUNT(*) FROM time_zone_name;
5560
SELECT COUNT(*) FROM time_zone_transition;
5661
SELECT COUNT(*) FROM time_zone_transition_type;
5762
SELECT COUNT(*) FROM time_zone_leap_second;
5863

64+
SELECT @wsrep_is_on, @wsrep_cannot_replicate_tz, @save_wsrep_on, @save_sql_log_bin, @@SQL_LOG_BIN;
65+
SELECT g.VARIABLE_NAME, g.VARIABLE_VALUE - b.VARIABLE_VALUE AS diff
66+
FROM information_schema.global_status g
67+
JOIN baseline b USING (VARIABLE_NAME)
68+
ORDER BY g.VARIABLE_NAME;
69+
5970
# Below tests don't include TRUNCATE TABLE so clear them.
6071
TRUNCATE TABLE time_zone;
6172
TRUNCATE TABLE time_zone_name;
@@ -69,13 +80,27 @@ TRUNCATE TABLE time_zone_leap_second;
6980

7081
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
7182
--exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo/GMT XXX 2>&1
72-
--exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo/GMT XXX 2>/dev/null | $MYSQL -S $MASTER_MYSOCK -u root mysql
83+
--exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo/GMT XXX 2>/dev/null > $MYSQL_TMP_DIR/tz.sql
84+
--disable_query_log
85+
CREATE OR REPLACE TEMPORARY TABLE baseline AS
86+
SELECT VARIABLE_NAME,VARIABLE_VALUE
87+
FROM information_schema.global_status
88+
WHERE VARIABLE_NAME IN ('COM_BEGIN', 'COM_INSERT', 'COM_LOCK_TABLES', 'COM_ALTER_TABLE', 'COM_TRUNCATE');
89+
--source $MYSQL_TMP_DIR/tz.sql
90+
--enable_query_log
91+
7392
SELECT COUNT(*) FROM time_zone;
7493
SELECT COUNT(*) FROM time_zone_name;
7594
SELECT COUNT(*) FROM time_zone_transition;
7695
SELECT COUNT(*) FROM time_zone_transition_type;
7796
SELECT COUNT(*) FROM time_zone_leap_second;
7897

98+
SELECT @wsrep_is_on, @wsrep_cannot_replicate_tz, @save_wsrep_on, @save_sql_log_bin, @@SQL_LOG_BIN;
99+
SELECT g.VARIABLE_NAME, g.VARIABLE_VALUE - b.VARIABLE_VALUE AS diff
100+
FROM information_schema.global_status g
101+
JOIN baseline b USING (VARIABLE_NAME)
102+
ORDER BY g.VARIABLE_NAME;
103+
79104
TRUNCATE TABLE time_zone;
80105
TRUNCATE TABLE time_zone_name;
81106
TRUNCATE TABLE time_zone_transition;
@@ -87,13 +112,27 @@ TRUNCATE TABLE time_zone_leap_second;
87112
--echo #
88113

89114
--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo/GMT XXX 2>&1
90-
--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo/GMT 2>/dev/null | $MYSQL -S $MASTER_MYSOCK -u root mysql
115+
--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo/GMT XXX 2>/dev/null > $MYSQL_TMP_DIR/tz.sql
116+
--disable_query_log
117+
CREATE OR REPLACE TEMPORARY TABLE baseline AS
118+
SELECT VARIABLE_NAME,VARIABLE_VALUE
119+
FROM information_schema.global_status
120+
WHERE VARIABLE_NAME IN ('COM_BEGIN', 'COM_INSERT', 'COM_LOCK_TABLES', 'COM_ALTER_TABLE', 'COM_TRUNCATE');
121+
--source $MYSQL_TMP_DIR/tz.sql
122+
--enable_query_log
123+
91124
SELECT COUNT(*) FROM time_zone;
92125
SELECT COUNT(*) FROM time_zone_name;
93126
SELECT COUNT(*) FROM time_zone_transition;
94127
SELECT COUNT(*) FROM time_zone_transition_type;
95128
SELECT COUNT(*) FROM time_zone_leap_second;
96129

130+
SELECT @wsrep_is_on, @wsrep_cannot_replicate_tz, @save_wsrep_on, @save_sql_log_bin, @@SQL_LOG_BIN;
131+
SELECT g.VARIABLE_NAME, g.VARIABLE_VALUE - b.VARIABLE_VALUE AS diff
132+
FROM information_schema.global_status g
133+
JOIN baseline b USING (VARIABLE_NAME)
134+
ORDER BY g.VARIABLE_NAME;
135+
97136
TRUNCATE TABLE time_zone;
98137
TRUNCATE TABLE time_zone_name;
99138
TRUNCATE TABLE time_zone_transition;
@@ -105,13 +144,27 @@ TRUNCATE TABLE time_zone_leap_second;
105144
--echo #
106145

107146
--exec $MYSQL_TZINFO_TO_SQL --leap $MYSQLTEST_VARDIR/zoneinfo/GMT 2>&1
108-
--exec $MYSQL_TZINFO_TO_SQL --leap $MYSQLTEST_VARDIR/zoneinfo/GMT 2>/dev/null | $MYSQL -S $MASTER_MYSOCK -u root mysql
147+
--exec $MYSQL_TZINFO_TO_SQL --leap $MYSQLTEST_VARDIR/zoneinfo/GMT 2>/dev/null > $MYSQL_TMP_DIR/tz.sql
148+
--disable_query_log
149+
CREATE OR REPLACE TEMPORARY TABLE baseline AS
150+
SELECT VARIABLE_NAME,VARIABLE_VALUE
151+
FROM information_schema.global_status
152+
WHERE VARIABLE_NAME IN ('COM_BEGIN', 'COM_INSERT', 'COM_LOCK_TABLES', 'COM_ALTER_TABLE', 'COM_TRUNCATE');
153+
--source $MYSQL_TMP_DIR/tz.sql
154+
--enable_query_log
155+
109156
SELECT COUNT(*) FROM time_zone;
110157
SELECT COUNT(*) FROM time_zone_name;
111158
SELECT COUNT(*) FROM time_zone_transition;
112159
SELECT COUNT(*) FROM time_zone_transition_type;
113160
SELECT COUNT(*) FROM time_zone_leap_second;
114161

162+
SELECT @wsrep_is_on, @wsrep_cannot_replicate_tz, @save_wsrep_on, @save_sql_log_bin, @@SQL_LOG_BIN;
163+
SELECT g.VARIABLE_NAME, g.VARIABLE_VALUE - b.VARIABLE_VALUE AS diff
164+
FROM information_schema.global_status g
165+
JOIN baseline b USING (VARIABLE_NAME)
166+
ORDER BY g.VARIABLE_NAME;
167+
115168
TRUNCATE TABLE time_zone;
116169
TRUNCATE TABLE time_zone_name;
117170
TRUNCATE TABLE time_zone_transition;
@@ -123,37 +176,51 @@ TRUNCATE TABLE time_zone_leap_second;
123176
--echo #
124177

125178
--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog --leap $MYSQLTEST_VARDIR/zoneinfo/GMT 2>&1
126-
--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog --leap $MYSQLTEST_VARDIR/zoneinfo/GMT 2>/dev/null | $MYSQL -S $MASTER_MYSOCK -u root mysql
179+
--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog --leap $MYSQLTEST_VARDIR/zoneinfo/GMT > $MYSQL_TMP_DIR/tz.sql
180+
--disable_query_log
181+
CREATE OR REPLACE TEMPORARY TABLE baseline AS
182+
SELECT VARIABLE_NAME,VARIABLE_VALUE
183+
FROM information_schema.global_status
184+
WHERE VARIABLE_NAME IN ('COM_BEGIN', 'COM_INSERT', 'COM_LOCK_TABLES', 'COM_ALTER_TABLE', 'COM_TRUNCATE');
185+
--source $MYSQL_TMP_DIR/tz.sql
186+
--enable_query_log
187+
127188
SELECT COUNT(*) FROM time_zone;
128189
SELECT COUNT(*) FROM time_zone_name;
129190
SELECT COUNT(*) FROM time_zone_transition;
130191
SELECT COUNT(*) FROM time_zone_transition_type;
131192
SELECT COUNT(*) FROM time_zone_leap_second;
132193

133-
#
134-
#
135-
# Cleanup
136-
#
137-
138-
--exec rm -rf $MYSQLTEST_VARDIR/zoneinfo
194+
SELECT @wsrep_is_on, @wsrep_cannot_replicate_tz, @save_wsrep_on, @save_sql_log_bin, @@SQL_LOG_BIN;
195+
SELECT g.VARIABLE_NAME, g.VARIABLE_VALUE - b.VARIABLE_VALUE AS diff
196+
FROM information_schema.global_status g
197+
JOIN baseline b USING (VARIABLE_NAME)
198+
ORDER BY g.VARIABLE_NAME;
139199

140200
--echo #
141201
--echo # MDEV-6236 - [PATCH] mysql_tzinfo_to_sql may produce invalid SQL
142202
--echo #
203+
--exec rm -rf $MYSQLTEST_VARDIR/zoneinfo
143204
--exec mkdir $MYSQLTEST_VARDIR/zoneinfo
144205
--copy_file std_data/zoneinfo/GMT $MYSQLTEST_VARDIR/zoneinfo/Factory
145206

146207
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
147208
--exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo 2>&1
148209

210+
#
211+
#
212+
# Cleanup
213+
#
214+
215+
--remove_file $MYSQL_TMP_DIR/tz.sql
149216
--exec rm -rf $MYSQLTEST_VARDIR/zoneinfo
217+
DROP TABLE baseline;
150218
DROP TABLE time_zone;
151219
DROP TABLE time_zone_name;
152220
DROP TABLE time_zone_transition;
153221
DROP TABLE time_zone_transition_type;
154222
DROP TABLE time_zone_leap_second;
155-
RENAME TABLE time_zone_orig TO time_zone,
156-
time_zone_name_orig TO time_zone_name,
157-
time_zone_transition_orig TO time_zone_transition,
158-
time_zone_transition_type_orig TO time_zone_transition_type,
159-
time_zone_leap_second_orig TO time_zone_leap_second;
223+
224+
--echo #
225+
--echo # End of 10.6 tests
226+
--echo #

0 commit comments

Comments
 (0)