@@ -216,7 +216,7 @@ static const char *opt_offload_count_file;
216
216
static const char *opt_secondary_engine;
217
217
static int opt_change_propagation;
218
218
219
- Secondary_engine secondary_engine;
219
+ static Secondary_engine * secondary_engine = nullptr ;
220
220
221
221
#ifdef _WIN32
222
222
static DWORD opt_safe_process_pid;
@@ -1336,6 +1336,8 @@ static void free_used_memory() {
1336
1336
// Delete the exptected errors pointer
1337
1337
delete expected_errors;
1338
1338
1339
+ delete secondary_engine;
1340
+
1339
1341
if (connections) close_connections ();
1340
1342
close_files ();
1341
1343
delete var_hash;
@@ -1380,8 +1382,9 @@ static void cleanup_and_exit(int exit_code) {
1380
1382
}
1381
1383
1382
1384
// Save the final value of secondary engine execution status.
1383
- if (secondary_engine.offload_count (&cur_con->mysql , " after" )) exit_code = 1 ;
1384
- secondary_engine.report_offload_count (opt_offload_count_file);
1385
+ if (secondary_engine->offload_count (&cur_con->mysql , " after" ))
1386
+ exit_code = 1 ;
1387
+ secondary_engine->report_offload_count (opt_offload_count_file);
1385
1388
}
1386
1389
1387
1390
free_used_memory ();
@@ -5292,7 +5295,7 @@ static void do_shutdown_server(struct st_command *command) {
5292
5295
if (opt_offload_count_file) {
5293
5296
// Save the value of secondary engine execution status
5294
5297
// before shutting down the server.
5295
- if (secondary_engine. offload_count (&cur_con->mysql , " after" ))
5298
+ if (secondary_engine-> offload_count (&cur_con->mysql , " after" ))
5296
5299
cleanup_and_exit (1 );
5297
5300
}
5298
5301
@@ -7638,11 +7641,11 @@ static void run_query_normal(struct st_connection *cn,
7638
7641
DBUG_PRINT (" enter" , (" query: '%-.60s'" , query));
7639
7642
7640
7643
if (opt_change_propagation != -1 ) {
7641
- secondary_engine. match_statement (query, expected_errors->count ());
7642
- if (secondary_engine. statement_type ()) {
7644
+ secondary_engine-> match_statement (query, expected_errors->count ());
7645
+ if (secondary_engine-> statement_type ()) {
7643
7646
std::vector<unsigned int > ignore_errors = expected_errors->errors ();
7644
7647
// Run secondary engine unload statements.
7645
- if (secondary_engine. run_unload_statements (mysql, ignore_errors))
7648
+ if (secondary_engine-> run_unload_statements (mysql, ignore_errors))
7646
7649
die (" Original query '%s'." , query);
7647
7650
}
7648
7651
}
@@ -7747,10 +7750,10 @@ static void run_query_normal(struct st_connection *cn,
7747
7750
*/
7748
7751
var_set_errno (mysql_errno (mysql));
7749
7752
7750
- if (opt_change_propagation != -1 && secondary_engine. statement_type ()) {
7753
+ if (opt_change_propagation != -1 && secondary_engine-> statement_type ()) {
7751
7754
std::vector<unsigned int > ignore_errors = expected_errors->errors ();
7752
7755
// Run secondary engine load statements.
7753
- if (secondary_engine. run_load_statements (mysql, ignore_errors))
7756
+ if (secondary_engine-> run_load_statements (mysql, ignore_errors))
7754
7757
die (" Original query '%s'." , query);
7755
7758
}
7756
7759
@@ -7784,11 +7787,11 @@ static void run_query_stmt(MYSQL *mysql, struct st_command *command,
7784
7787
DBUG_PRINT (" query" , (" '%-.60s'" , query));
7785
7788
7786
7789
if (opt_change_propagation != -1 ) {
7787
- secondary_engine. match_statement (query, expected_errors->count ());
7788
- if (secondary_engine. statement_type ()) {
7790
+ secondary_engine-> match_statement (query, expected_errors->count ());
7791
+ if (secondary_engine-> statement_type ()) {
7789
7792
std::vector<unsigned int > ignore_errors = expected_errors->errors ();
7790
7793
// Run secondary engine unload statements.
7791
- if (secondary_engine. run_unload_statements (mysql, ignore_errors))
7794
+ if (secondary_engine-> run_unload_statements (mysql, ignore_errors))
7792
7795
die (" Original query '%s'." , query);
7793
7796
}
7794
7797
}
@@ -7978,10 +7981,10 @@ static void run_query_stmt(MYSQL *mysql, struct st_command *command,
7978
7981
cur_con->stmt = NULL ;
7979
7982
}
7980
7983
7981
- if (opt_change_propagation != -1 && secondary_engine. statement_type ()) {
7984
+ if (opt_change_propagation != -1 && secondary_engine-> statement_type ()) {
7982
7985
std::vector<unsigned int > ignore_errors = expected_errors->errors ();
7983
7986
// Run secondary engine load statements.
7984
- if (secondary_engine. run_load_statements (mysql, ignore_errors))
7987
+ if (secondary_engine-> run_load_statements (mysql, ignore_errors))
7985
7988
die (" Original query '%s'." , query);
7986
7989
}
7987
7990
@@ -8906,12 +8909,12 @@ int main(int argc, char **argv) {
8906
8909
8907
8910
if (opt_change_propagation != -1 ) {
8908
8911
secondary_engine =
8909
- Secondary_engine (opt_change_propagation, opt_secondary_engine);
8912
+ new Secondary_engine (opt_change_propagation, opt_secondary_engine);
8910
8913
}
8911
8914
8912
8915
if (opt_offload_count_file) {
8913
8916
// Save the initial value of secondary engine execution status.
8914
- if (secondary_engine. offload_count (&cur_con->mysql , " before" ))
8917
+ if (secondary_engine-> offload_count (&cur_con->mysql , " before" ))
8915
8918
cleanup_and_exit (1 );
8916
8919
}
8917
8920
@@ -9284,7 +9287,7 @@ int main(int argc, char **argv) {
9284
9287
if (opt_offload_count_file) {
9285
9288
// Save the value of secondary engine execution status
9286
9289
// before shutting down the server.
9287
- if (secondary_engine. offload_count (&cur_con->mysql , " after" ))
9290
+ if (secondary_engine-> offload_count (&cur_con->mysql , " after" ))
9288
9291
cleanup_and_exit (1 );
9289
9292
}
9290
9293
0 commit comments