Skip to content

Commit 9045f89

Browse files
jkedgarfacebook-github-bot
authored andcommitted
Support local files in the sync client
Summary: The async client doesn't support local files (used for LOAD DATA LOCAL INFILE) as the response from the server is telling the client to start sending the file and the code has never been written to handle this correctly in a background thread. However, the sync client can support it. Add the code to query the client for whether it can be supported when initializing the connection. Reviewed By: abal147 Differential Revision: D33781238 fbshipit-source-id: da8c2ee3f635682a82ef4fa5144ccbbd69ed0302
1 parent 97cf867 commit 9045f89

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

squangle/mysql_client/AsyncMysqlClient.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ class AsyncMysqlClient : public MysqlClientBase {
189189
return ret;
190190
}
191191

192+
bool supportsLocalFiles() override {
193+
// The async client does not yet support local files for LOAD DATA
194+
return false;
195+
}
196+
192197
protected:
193198
AsyncMysqlClient(
194199
std::unique_ptr<db::SquangleLoggerBase> db_logger,

squangle/mysql_client/Connection.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ void Connection::initMysqlOnly() {
4343
CHECK_THROW(mysql_connection_ == nullptr, db::InvalidConnectionException);
4444
mysql_connection_ = std::make_unique<MysqlConnectionHolder>(
4545
mysql_client_, mysql_init(nullptr), conn_key_);
46-
mysql_connection_->mysql()->options.client_flag &= ~CLIENT_LOCAL_FILES;
46+
if (!mysql_client_->supportsLocalFiles()) {
47+
mysql_connection_->mysql()->options.client_flag &= ~CLIENT_LOCAL_FILES;
48+
}
4749
// Turn off SSL by default for tests that rely on this.
4850
enum mysql_ssl_mode ssl_mode = SSL_MODE_DISABLED;
4951
mysql_options(mysql_connection_->mysql(), MYSQL_OPT_SSL_MODE, &ssl_mode);

squangle/mysql_client/MysqlClientBase.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ class MysqlClientBase {
120120
return 0.0;
121121
}
122122

123+
virtual bool supportsLocalFiles() = 0;
124+
123125
protected:
124126
friend class Connection;
125127
friend class Operation;

squangle/mysql_client/SyncMysqlClient.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ class SyncMysqlClient : public MysqlClientBase {
5858

5959
void drain(bool /*unused*/) {}
6060

61+
bool supportsLocalFiles() override {
62+
return true;
63+
}
64+
6165
protected:
6266
// Private methods, primarily used by Operations and its subclasses.
6367
friend class AsyncConnectionPool;

0 commit comments

Comments
 (0)