2017-05-23 18:01:50 +00:00
|
|
|
#include <Interpreters/Context.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Interpreters/InterpreterCheckQuery.h>
|
2018-08-05 06:01:41 +00:00
|
|
|
#include <Storages/IStorage.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Parsers/ASTCheckQuery.h>
|
|
|
|
#include <DataStreams/OneBlockInputStream.h>
|
|
|
|
#include <DataTypes/DataTypesNumber.h>
|
|
|
|
#include <Columns/ColumnsNumber.h>
|
2017-07-13 20:58:19 +00:00
|
|
|
#include <Common/typeid_cast.h>
|
2015-10-12 14:53:16 +00:00
|
|
|
|
2014-08-05 10:52:06 +00:00
|
|
|
|
2015-06-18 02:11:05 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
2014-08-05 10:52:06 +00:00
|
|
|
|
2017-05-23 18:01:50 +00:00
|
|
|
InterpreterCheckQuery::InterpreterCheckQuery(const ASTPtr & query_ptr_, const Context & context_)
|
2017-04-01 07:20:54 +00:00
|
|
|
: query_ptr(query_ptr_), context(context_)
|
2015-10-12 14:53:16 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-18 02:11:05 +00:00
|
|
|
BlockIO InterpreterCheckQuery::execute()
|
2014-08-05 10:52:06 +00:00
|
|
|
{
|
2019-03-15 16:14:13 +00:00
|
|
|
const auto & alter = query_ptr->as<ASTCheckQuery &>();
|
|
|
|
const String & table_name = alter.table;
|
|
|
|
String database_name = alter.database.empty() ? context.getCurrentDatabase() : alter.database;
|
2017-04-01 07:20:54 +00:00
|
|
|
|
|
|
|
StoragePtr table = context.getTable(database_name, table_name);
|
|
|
|
|
2018-08-05 06:01:41 +00:00
|
|
|
auto column = ColumnUInt8::create();
|
2018-10-22 08:54:54 +00:00
|
|
|
column->insertValue(UInt64(table->checkData()));
|
2018-08-05 06:01:41 +00:00
|
|
|
result = Block{{ std::move(column), std::make_shared<DataTypeUInt8>(), "result" }};
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2018-08-05 06:01:41 +00:00
|
|
|
BlockIO res;
|
|
|
|
res.in = std::make_shared<OneBlockInputStream>(result);
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2018-08-05 06:01:41 +00:00
|
|
|
return res;
|
2014-08-05 10:52:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|