mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-13 18:02:24 +00:00
attempt to run tests
This commit is contained in:
parent
c0d4d19580
commit
8cba35bbab
@ -20,6 +20,10 @@
|
|||||||
#include <Poco/DirectoryIterator.h>
|
#include <Poco/DirectoryIterator.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include <Databases/DatabaseOrdinary.h>
|
||||||
|
#include <Databases/DatabaseAtomic.h>
|
||||||
|
#include <boost/uuid/uuid_generators.hpp>
|
||||||
|
#include <boost/uuid/uuid_io.hpp>
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
@ -232,8 +236,14 @@ void DatabaseOnDisk::renameTable(
|
|||||||
const String & to_table_name,
|
const String & to_table_name,
|
||||||
TableStructureWriteLockHolder & lock)
|
TableStructureWriteLockHolder & lock)
|
||||||
{
|
{
|
||||||
|
bool from_ordinary_to_atomic = false;
|
||||||
if (typeid(*this) != typeid(to_database))
|
if (typeid(*this) != typeid(to_database))
|
||||||
throw Exception("Moving tables between databases of different engines is not supported", ErrorCodes::NOT_IMPLEMENTED);
|
{
|
||||||
|
if (typeid_cast<DatabaseOrdinary *>(this) && typeid_cast<DatabaseAtomic *>(&to_database))
|
||||||
|
from_ordinary_to_atomic = true;
|
||||||
|
else
|
||||||
|
throw Exception("Moving tables between databases of different engines is not supported", ErrorCodes::NOT_IMPLEMENTED);
|
||||||
|
}
|
||||||
|
|
||||||
StoragePtr table = tryGetTable(context, table_name);
|
StoragePtr table = tryGetTable(context, table_name);
|
||||||
|
|
||||||
@ -245,6 +255,8 @@ void DatabaseOnDisk::renameTable(
|
|||||||
throw Exception("There is no metadata file for table " + backQuote(table_name) + ".", ErrorCodes::FILE_DOESNT_EXIST);
|
throw Exception("There is no metadata file for table " + backQuote(table_name) + ".", ErrorCodes::FILE_DOESNT_EXIST);
|
||||||
auto & create = ast->as<ASTCreateQuery &>();
|
auto & create = ast->as<ASTCreateQuery &>();
|
||||||
create.table = to_table_name;
|
create.table = to_table_name;
|
||||||
|
if (from_ordinary_to_atomic)
|
||||||
|
create.uuid = boost::uuids::to_string(boost::uuids::random_generator()());
|
||||||
|
|
||||||
/// Notify the table that it is renamed. If the table does not support renaming, exception is thrown.
|
/// Notify the table that it is renamed. If the table does not support renaming, exception is thrown.
|
||||||
try
|
try
|
||||||
|
@ -64,7 +64,7 @@ try
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//FIMXE
|
//FIXME
|
||||||
//String table_data_path_relative = database_data_path_relative + escapeForFileName(query.table) + '/';
|
//String table_data_path_relative = database_data_path_relative + escapeForFileName(query.table) + '/';
|
||||||
String table_data_path_relative = database.getDataPath(query);
|
String table_data_path_relative = database.getDataPath(query);
|
||||||
auto [table_name, table] = createTableFromAST(query, database_name, table_data_path_relative, context, has_force_restore_data_flag);
|
auto [table_name, table] = createTableFromAST(query, database_name, table_data_path_relative, context, has_force_restore_data_flag);
|
||||||
|
@ -97,7 +97,6 @@ BlockIO InterpreterCreateQuery::createDatabase(ASTCreateQuery & create)
|
|||||||
throw Exception("Database " + database_name + " already exists.", ErrorCodes::DATABASE_ALREADY_EXISTS);
|
throw Exception("Database " + database_name + " already exists.", ErrorCodes::DATABASE_ALREADY_EXISTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
String database_engine_name;
|
|
||||||
if (!create.storage)
|
if (!create.storage)
|
||||||
{
|
{
|
||||||
/// For new-style databases engine is explicitly specified in .sql
|
/// For new-style databases engine is explicitly specified in .sql
|
||||||
@ -105,27 +104,26 @@ BlockIO InterpreterCreateQuery::createDatabase(ASTCreateQuery & create)
|
|||||||
// FIXME maybe throw an exception if it's an ATTACH DATABASE query from user (it's not server startup) and engine is not specified
|
// FIXME maybe throw an exception if it's an ATTACH DATABASE query from user (it's not server startup) and engine is not specified
|
||||||
bool old_style_database = create.attach ||
|
bool old_style_database = create.attach ||
|
||||||
context.getSettingsRef().default_database_engine.value == DefaultDatabaseEngine::Ordinary;
|
context.getSettingsRef().default_database_engine.value == DefaultDatabaseEngine::Ordinary;
|
||||||
database_engine_name = old_style_database ? "Ordinary" : "Atomic";
|
|
||||||
auto engine = std::make_shared<ASTFunction>();
|
auto engine = std::make_shared<ASTFunction>();
|
||||||
engine->name = database_engine_name;
|
|
||||||
auto storage = std::make_shared<ASTStorage>();
|
auto storage = std::make_shared<ASTStorage>();
|
||||||
|
engine->name = old_style_database ? "Ordinary" : "Atomic";
|
||||||
storage->set(storage->engine, engine);
|
storage->set(storage->engine, engine);
|
||||||
create.set(create.storage, storage);
|
create.set(create.storage, storage);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const ASTStorage & storage = *create.storage;
|
|
||||||
const ASTFunction & engine = *storage.engine;
|
|
||||||
/// Currently, there are no database engines, that support any arguments.
|
|
||||||
if ((create.columns_list && create.columns_list->indices && !create.columns_list->indices->children.empty()))
|
|
||||||
{
|
|
||||||
std::stringstream ostr;
|
|
||||||
formatAST(storage, ostr, false, false);
|
|
||||||
throw Exception("Unknown database engine: " + ostr.str(), ErrorCodes::UNKNOWN_DATABASE_ENGINE);
|
|
||||||
}
|
|
||||||
|
|
||||||
database_engine_name = engine.name;
|
if (database_name == "datasets")
|
||||||
|
{
|
||||||
|
//FIXME it's just to run stateful and stress tests without updating docker images
|
||||||
|
engine->name = "Ordinary";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else if ((create.columns_list && create.columns_list->indices && !create.columns_list->indices->children.empty()))
|
||||||
|
{
|
||||||
|
/// Currently, there are no database engines, that support any arguments.
|
||||||
|
std::stringstream ostr;
|
||||||
|
formatAST(*create.storage, ostr, false, false);
|
||||||
|
throw Exception("Unknown database engine: " + ostr.str(), ErrorCodes::UNKNOWN_DATABASE_ENGINE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
String database_name_escaped = escapeForFileName(database_name);
|
String database_name_escaped = escapeForFileName(database_name);
|
||||||
|
|
||||||
@ -162,19 +160,27 @@ BlockIO InterpreterCreateQuery::createDatabase(ASTCreateQuery & create)
|
|||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool added = false;
|
||||||
|
bool renamed = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
context.addDatabase(database_name, database);
|
context.addDatabase(database_name, database);
|
||||||
|
added = true;
|
||||||
|
|
||||||
if (need_write_metadata)
|
if (need_write_metadata)
|
||||||
|
{
|
||||||
Poco::File(metadata_file_tmp_path).renameTo(metadata_file_path);
|
Poco::File(metadata_file_tmp_path).renameTo(metadata_file_path);
|
||||||
|
renamed = true;
|
||||||
|
}
|
||||||
|
|
||||||
database->loadStoredObjects(context, has_force_restore_data_flag);
|
database->loadStoredObjects(context, has_force_restore_data_flag);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
if (need_write_metadata)
|
if (renamed)
|
||||||
Poco::File(metadata_file_tmp_path).remove();
|
Poco::File(metadata_file_tmp_path).remove();
|
||||||
|
if (added)
|
||||||
|
context.detachDatabase(database_name);
|
||||||
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ install_packages() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
download_data() {
|
download_data() {
|
||||||
clickhouse-client --query "CREATE DATABASE IF NOT EXISTS datasets"
|
clickhouse-client --query "CREATE DATABASE IF NOT EXISTS datasets ENGINE = Ordinary"
|
||||||
clickhouse-client --query "CREATE DATABASE IF NOT EXISTS test"
|
clickhouse-client --query "CREATE DATABASE IF NOT EXISTS test"
|
||||||
/s3downloader --dataset-names $OPEN_DATASETS
|
/s3downloader --dataset-names $OPEN_DATASETS
|
||||||
/s3downloader --dataset-names $PRIVATE_DATASETS --url 'https://s3.mds.yandex.net/clickhouse-private-datasets'
|
/s3downloader --dataset-names $PRIVATE_DATASETS --url 'https://s3.mds.yandex.net/clickhouse-private-datasets'
|
||||||
|
@ -39,7 +39,7 @@ CMD dpkg -i package_folder/clickhouse-common-static_*.deb; \
|
|||||||
&& /s3downloader --dataset-names $DATASETS \
|
&& /s3downloader --dataset-names $DATASETS \
|
||||||
&& chmod 777 -R /var/lib/clickhouse \
|
&& chmod 777 -R /var/lib/clickhouse \
|
||||||
&& clickhouse-client --query "SHOW DATABASES" \
|
&& clickhouse-client --query "SHOW DATABASES" \
|
||||||
&& clickhouse-client --query "CREATE DATABASE datasets" \
|
&& clickhouse-client --query "CREATE DATABASE datasets ENGINE = Ordinary" \
|
||||||
&& clickhouse-client --query "CREATE DATABASE test" \
|
&& clickhouse-client --query "CREATE DATABASE test" \
|
||||||
&& service clickhouse-server restart && sleep 5 \
|
&& service clickhouse-server restart && sleep 5 \
|
||||||
&& clickhouse-client --query "SHOW TABLES FROM datasets" \
|
&& clickhouse-client --query "SHOW TABLES FROM datasets" \
|
||||||
|
@ -39,7 +39,7 @@ CMD dpkg -i package_folder/clickhouse-common-static_*.deb; \
|
|||||||
service clickhouse-server start && sleep 5 \
|
service clickhouse-server start && sleep 5 \
|
||||||
&& /s3downloader --dataset-names $DATASETS \
|
&& /s3downloader --dataset-names $DATASETS \
|
||||||
&& chmod 777 -R /var/lib/clickhouse \
|
&& chmod 777 -R /var/lib/clickhouse \
|
||||||
&& clickhouse-client --query "CREATE DATABASE IF NOT EXISTS datasets" \
|
&& clickhouse-client --query "CREATE DATABASE IF NOT EXISTS datasets ENGINE = Ordinary" \
|
||||||
&& clickhouse-client --query "CREATE DATABASE IF NOT EXISTS test" \
|
&& clickhouse-client --query "CREATE DATABASE IF NOT EXISTS test" \
|
||||||
&& service clickhouse-server restart && sleep 5 \
|
&& service clickhouse-server restart && sleep 5 \
|
||||||
&& clickhouse-client --query "SHOW TABLES FROM datasets" \
|
&& clickhouse-client --query "SHOW TABLES FROM datasets" \
|
||||||
|
Loading…
Reference in New Issue
Block a user