Skip to content

Commit 987df96

Browse files
authored
Merge pull request duckdb#98 from Vercantez/main
use mutex to protect mysql_real_query
2 parents f2a1501 + ba2c6b6 commit 987df96

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/include/mysql_connection.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#pragma once
1010

1111
#include "duckdb/common/shared_ptr.hpp"
12+
#include "duckdb/common/mutex.hpp"
1213
#include "mysql_utils.hpp"
1314
#include "mysql_result.hpp"
1415

@@ -77,6 +78,7 @@ class MySQLConnection {
7778
private:
7879
MYSQL_RES *MySQLExecute(const string &query);
7980

81+
mutex query_lock;
8082
shared_ptr<OwnedMySQLConnection> connection;
8183
string dsn;
8284
};

src/mysql_connection.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ MYSQL_RES *MySQLConnection::MySQLExecute(const string &query) {
3939
Printer::Print(query + "\n");
4040
}
4141
auto con = GetConn();
42+
lock_guard<mutex> l(query_lock);
4243
int res = mysql_real_query(con, query.c_str(), query.size());
4344
if (res != 0) {
4445
throw IOException("Failed to run query \"%s\": %s\n", query.c_str(), mysql_error(con));

0 commit comments

Comments
 (0)