mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-11 18:14:03 +00:00
Merge pull request #34357 from kssenii/fix-clickhouse-local-use-db
Fix USE database for clickhouse-local
This commit is contained in:
commit
4b1e1314b2
@ -74,6 +74,8 @@ void LocalConnection::sendQuery(
|
||||
query_context->setProgressCallback([this] (const Progress & value) { return this->updateProgress(value); });
|
||||
query_context->setFileProgressCallback([this](const FileProgress & value) { this->updateProgress(Progress(value)); });
|
||||
}
|
||||
if (!current_database.empty())
|
||||
query_context->setCurrentDatabase(current_database);
|
||||
|
||||
CurrentThread::QueryScope query_scope_holder(query_context);
|
||||
|
||||
@ -427,9 +429,9 @@ void LocalConnection::getServerVersion(
|
||||
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Not implemented");
|
||||
}
|
||||
|
||||
void LocalConnection::setDefaultDatabase(const String &)
|
||||
void LocalConnection::setDefaultDatabase(const String & database)
|
||||
{
|
||||
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Not implemented");
|
||||
current_database = database;
|
||||
}
|
||||
|
||||
UInt64 LocalConnection::getServerRevision(const ConnectionTimeouts &)
|
||||
|
@ -142,5 +142,7 @@ private:
|
||||
|
||||
/// Last "server" packet.
|
||||
std::optional<UInt64> next_packet_type;
|
||||
|
||||
String current_database;
|
||||
};
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
SHOW TABLES;
|
||||
CREATE DATABASE test1;
|
||||
CREATE TABLE test1.table1 (a Int32) ENGINE=Memory;
|
||||
USE test1;
|
||||
SHOW TABLES;
|
||||
table1
|
||||
CREATE DATABASE test2;
|
||||
USE test2;
|
||||
SHOW TABLES;
|
||||
USE test1;
|
||||
SHOW TABLES;
|
||||
table1
|
19
tests/queries/0_stateless/02206_clickhouse_local_use_database.sh
Executable file
19
tests/queries/0_stateless/02206_clickhouse_local_use_database.sh
Executable file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
|
||||
$CLICKHOUSE_LOCAL --echo --multiline --multiquery -q """
|
||||
SHOW TABLES;
|
||||
CREATE DATABASE test1;
|
||||
CREATE TABLE test1.table1 (a Int32) ENGINE=Memory;
|
||||
USE test1;
|
||||
SHOW TABLES;
|
||||
CREATE DATABASE test2;
|
||||
USE test2;
|
||||
SHOW TABLES;
|
||||
USE test1;
|
||||
SHOW TABLES;
|
||||
"""
|
Loading…
Reference in New Issue
Block a user