Skip to content

Commit 41a64ac

Browse files
committed
Add options for Timeout and multi statement
1 parent e973d09 commit 41a64ac

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

docs/intro/config-file.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ The InterceptDB Config file
1717
database: production
1818
port: 3306 #optional
1919
opt_compress: false #set the MYSQL_OPT_COMPRESS option
20+
#opt_read_timeout: 5 #set the MYSQL_OPT_READ_TIMEOUT option
21+
#opt_write_timeout: 5 #set the MYSQL_OPT_WRITE_TIMEOUT option
22+
#opt_multi_statement: false #set the MARIADB_OPT_MULTI_STATEMENTS and MARIADB_OPT_MULTI_RESULTS option. I think this is broken, you can try it if you want though.
2023
2124
statements:
2225
insertStuff: INSERT INTO table (a,b,c) VALUES (?,?,?)

src/config.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,16 @@ void Config::reloadConfig() {
7474
acc->set_connect_option(MYSQL_OPT_RECONNECT, true);
7575
if (value["opt_compress"].as<bool>(false))
7676
acc->set_connect_option(MYSQL_OPT_COMPRESS, true);
77-
//acc->set_connect_option(MARIADB_OPT_MULTI_STATEMENTS, true);
78-
//acc->set_connect_option(MARIADB_OPT_MULTI_RESULTS, true);
77+
if (value["opt_read_timeout"].IsDefined())
78+
acc->set_connect_option(MYSQL_OPT_READ_TIMEOUT, value["opt_read_timeout"].as<int>());
79+
if (value["opt_write_timeout"].IsDefined())
80+
acc->set_connect_option(MYSQL_OPT_WRITE_TIMEOUT, value["opt_write_timeout"].as<int>());
81+
82+
if (value["opt_multi_statement"].as<bool>(false)) {
83+
acc->set_connect_option(MARIADB_OPT_MULTI_STATEMENTS, true);
84+
acc->set_connect_option(MARIADB_OPT_MULTI_RESULTS, true);
85+
}
86+
7987
//acc->set_auto_commit(false);
8088

8189
accounts[accountName] = acc;

0 commit comments

Comments
 (0)