Skip to content

Commit

Permalink
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/ClickHouse_Server.h
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ class ClickHouse_Session {
public:
SQLite3DB *sessdb;
bool transfer_started;
bool schema_initialized;
uint8_t sid;
ClickHouse_Session();
bool init();
17 changes: 17 additions & 0 deletions lib/ClickHouse_Server.cpp
Original file line number Diff line number Diff line change
@@ -1036,6 +1036,22 @@ void ClickHouse_Server_session_handler(MySQL_Session *sess, void *_pa, PtrSize_t
try {
clickhouse_thread___mysql_sess = sess;
if (clickhouse_sess->connected == true) {
if (clickhouse_sess->schema_initialized == false) {
if (sess && sess->client_myds) {
MySQL_Data_Stream *ds = sess->client_myds;
if (ds->myconn && ds->myconn->userinfo && ds->myconn->userinfo->schemaname) {
char *sn = ds->myconn->userinfo->schemaname;
char *use_query = NULL;
use_query = (char *)malloc(strlen(sn)+8);
sprintf(use_query,"USE %s", sn);
clickhouse::Query myq(use_query);
clickhouse_sess->client->Execute(myq);
free(use_query);
}
}
clickhouse_sess->schema_initialized = true;
}

if (expected_resultset) {
clickhouse_sess->client->Select(query, [](const Block& block) { ClickHouse_to_MySQL(block); } );

@@ -1105,6 +1121,7 @@ ClickHouse_Session::ClickHouse_Session() {
sessdb = new SQLite3DB();
sessdb->open((char *)"file:mem_sqlitedb_clickhouse?mode=memory&cache=shared", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX);
transfer_started = false;
schema_initialized = false;
}

bool ClickHouse_Session::init() {

0 comments on commit 1e524bb

Please sign in to comment.