mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 01:22:04 +00:00
dbms: fixed error [#METR-17286].
This commit is contained in:
parent
7a7a2ac6e0
commit
fa9553307e
@ -22,6 +22,11 @@ public:
|
|||||||
: context(context_), query_ptr(query_ptr_)
|
: context(context_), query_ptr(query_ptr_)
|
||||||
{
|
{
|
||||||
storage = context.getTable(database, table);
|
storage = context.getTable(database, table);
|
||||||
|
|
||||||
|
/** TODO Это очень важная строчка. При любой вставке в таблицу один из stream-ов должен владеть lock-ом.
|
||||||
|
* Хотя сейчас любая вставка в таблицу делается через PushingToViewsBlockOutputStream,
|
||||||
|
* но ясно, что здесь - не лучшее место для этой функциональности.
|
||||||
|
*/
|
||||||
addTableLock(storage->lockStructure(true));
|
addTableLock(storage->lockStructure(true));
|
||||||
|
|
||||||
Dependencies dependencies = context.getDependencies(database, table);
|
Dependencies dependencies = context.getDependencies(database, table);
|
||||||
|
@ -6,8 +6,11 @@
|
|||||||
#include <DB/IO/WriteBufferFromString.h>
|
#include <DB/IO/WriteBufferFromString.h>
|
||||||
#include <DB/IO/WriteHelpers.h>
|
#include <DB/IO/WriteHelpers.h>
|
||||||
|
|
||||||
#include <DB/DataStreams/MaterializingBlockInputStream.h>
|
|
||||||
#include <DB/DataStreams/NullAndDoCopyBlockInputStream.h>
|
#include <DB/DataStreams/NullAndDoCopyBlockInputStream.h>
|
||||||
|
#include <DB/DataStreams/ProhibitColumnsBlockOutputStream.h>
|
||||||
|
#include <DB/DataStreams/MaterializingBlockOutputStream.h>
|
||||||
|
#include <DB/DataStreams/AddingDefaultBlockOutputStream.h>
|
||||||
|
#include <DB/DataStreams/PushingToViewsBlockOutputStream.h>
|
||||||
|
|
||||||
#include <DB/Parsers/ASTCreateQuery.h>
|
#include <DB/Parsers/ASTCreateQuery.h>
|
||||||
#include <DB/Parsers/ASTNameTypePair.h>
|
#include <DB/Parsers/ASTNameTypePair.h>
|
||||||
@ -251,11 +254,24 @@ BlockIO InterpreterCreateQuery::executeImpl(bool assume_metadata_exists)
|
|||||||
/// Если запрос CREATE SELECT, то вставим в таблицу данные
|
/// Если запрос CREATE SELECT, то вставим в таблицу данные
|
||||||
if (create.select && storage_name != "View" && (storage_name != "MaterializedView" || create.is_populate))
|
if (create.select && storage_name != "View" && (storage_name != "MaterializedView" || create.is_populate))
|
||||||
{
|
{
|
||||||
|
auto table_lock = res->lockStructure(true);
|
||||||
|
|
||||||
|
/// Также см. InterpreterInsertQuery.
|
||||||
|
BlockOutputStreamPtr out{
|
||||||
|
new ProhibitColumnsBlockOutputStream{
|
||||||
|
new AddingDefaultBlockOutputStream{
|
||||||
|
new MaterializingBlockOutputStream{
|
||||||
|
new PushingToViewsBlockOutputStream{create.database, create.table, context, query_ptr}
|
||||||
|
},
|
||||||
|
columns, column_defaults, context, context.getSettingsRef().strict_insert_defaults
|
||||||
|
},
|
||||||
|
materialized_columns
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
BlockIO io;
|
BlockIO io;
|
||||||
io.in_sample = select_sample;
|
io.in_sample = select_sample;
|
||||||
io.in = new NullAndDoCopyBlockInputStream(
|
io.in = new NullAndDoCopyBlockInputStream(interpreter_select->execute().in, out);
|
||||||
new MaterializingBlockInputStream(interpreter_select->execute().in),
|
|
||||||
res->write(query_ptr, context.getSettingsRef()));
|
|
||||||
|
|
||||||
return io;
|
return io;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user