2021-08-18 22:19:14 +00:00
|
|
|
#include <Interpreters/InterpreterBackupQuery.h>
|
2022-05-02 17:09:51 +00:00
|
|
|
|
2022-04-20 07:38:12 +00:00
|
|
|
#include <Backups/BackupsWorker.h>
|
|
|
|
#include <Columns/ColumnString.h>
|
2022-05-02 17:09:51 +00:00
|
|
|
#include <Columns/ColumnsNumber.h>
|
2022-04-20 07:38:12 +00:00
|
|
|
#include <DataTypes/DataTypeEnum.h>
|
|
|
|
#include <DataTypes/DataTypeString.h>
|
2022-05-02 17:09:51 +00:00
|
|
|
#include <DataTypes/DataTypeUUID.h>
|
|
|
|
#include <DataTypes/DataTypesNumber.h>
|
|
|
|
#include <Interpreters/Context.h>
|
2022-04-20 07:38:12 +00:00
|
|
|
#include <Processors/Sources/SourceFromSingleChunk.h>
|
2022-04-29 06:45:27 +00:00
|
|
|
#include <Common/logger_useful.h>
|
2021-08-18 22:19:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2022-01-28 17:33:35 +00:00
|
|
|
|
2022-05-01 13:36:32 +00:00
|
|
|
namespace
|
|
|
|
{
|
2022-05-02 17:09:51 +00:00
|
|
|
Block getResultRow(const BackupsWorker::Info & info)
|
2021-08-18 22:19:14 +00:00
|
|
|
{
|
2022-04-20 07:38:12 +00:00
|
|
|
Block res_columns;
|
|
|
|
|
2022-05-02 17:09:51 +00:00
|
|
|
auto column_uuid = ColumnUUID::create();
|
|
|
|
column_uuid->insert(info.uuid);
|
|
|
|
res_columns.insert(0, {std::move(column_uuid), std::make_shared<DataTypeUUID>(), "uuid"});
|
2022-04-20 07:38:12 +00:00
|
|
|
|
|
|
|
auto column_backup_name = ColumnString::create();
|
2022-05-02 17:09:51 +00:00
|
|
|
column_backup_name->insert(info.backup_name);
|
2022-04-20 07:38:12 +00:00
|
|
|
res_columns.insert(1, {std::move(column_backup_name), std::make_shared<DataTypeString>(), "backup_name"});
|
|
|
|
|
|
|
|
auto column_status = ColumnInt8::create();
|
2022-05-02 17:09:51 +00:00
|
|
|
column_status->insert(static_cast<Int8>(info.status));
|
2022-04-20 07:38:12 +00:00
|
|
|
res_columns.insert(2, {std::move(column_status), std::make_shared<DataTypeEnum8>(getBackupStatusEnumValues()), "status"});
|
|
|
|
|
|
|
|
return res_columns;
|
2021-08-18 22:19:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BlockIO InterpreterBackupQuery::execute()
|
|
|
|
{
|
2022-05-02 17:09:51 +00:00
|
|
|
auto & backups_worker = context->getBackupsWorker();
|
|
|
|
UUID uuid = backups_worker.start(query_ptr, context);
|
2022-04-20 07:38:12 +00:00
|
|
|
BlockIO res_io;
|
2022-05-02 17:09:51 +00:00
|
|
|
res_io.pipeline = QueryPipeline(std::make_shared<SourceFromSingleChunk>(getResultRow(backups_worker.getInfo(uuid))));
|
2022-04-20 07:38:12 +00:00
|
|
|
return res_io;
|
2021-08-18 22:19:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|