Skip to content

Commit

Permalink
Revert "Merge pull request #9048 from ClickHouse/fix_mutation_order"
Browse files Browse the repository at this point in the history
This reverts commit 5be678f.
  • Loading branch information
tavplubix committed Feb 14, 2020
1 parent ed91b04 commit 4fd80be
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 107 deletions.
34 changes: 0 additions & 34 deletions dbms/src/Interpreters/MutationsInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <Parsers/ASTExpressionList.h>
#include <Parsers/ASTSelectQuery.h>
#include <Parsers/formatAST.h>
#include <Parsers/ASTOrderByElement.h>
#include <IO/WriteHelpers.h>


Expand Down Expand Up @@ -524,39 +523,6 @@ ASTPtr MutationsInterpreter::prepareInterpreterSelectQuery(std::vector<Stage> &p
}
select->setExpression(ASTSelectQuery::Expression::WHERE, std::move(where_expression));
}
auto metadata = storage->getInMemoryMetadata();
/// We have to execute select in order of primary key
/// because we don't sort results additionaly and don't have
/// any guarantees on data order without ORDER BY. It's almost free, because we
/// have optimization for data read in primary key order.
if (metadata.order_by_ast)
{
ASTPtr dummy;

ASTPtr key_expr;
if (metadata.primary_key_ast)
key_expr = metadata.primary_key_ast;
else
key_expr = metadata.order_by_ast;

bool empty = false;
/// In all other cases we cannot have empty key
if (auto key_function = key_expr->as<ASTFunction>())
empty = key_function->arguments->children.size() == 0;

/// Not explicitely spicified empty key
if (!empty)
{
auto order_by_expr = std::make_shared<ASTOrderByElement>(1, 1, false, dummy, false, dummy, dummy, dummy);


order_by_expr->children.push_back(key_expr);
auto res = std::make_shared<ASTExpressionList>();
res->children.push_back(order_by_expr);

select->setExpression(ASTSelectQuery::Expression::ORDER_BY, std::move(res));
}
}

return select;
}
Expand Down
6 changes: 0 additions & 6 deletions dbms/src/Storages/MergeTree/StorageFromMergeTreeDataPart.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ class StorageFromMergeTreeDataPart : public ext::shared_ptr_helper<StorageFromMe
return part->storage.mayBenefitFromIndexForIn(left_in_operand, query_context);
}

StorageInMemoryMetadata getInMemoryMetadata() const override
{
return part->storage.getInMemoryMetadata();
}


protected:
StorageFromMergeTreeDataPart(const MergeTreeData::DataPartPtr & part_)
: IStorage(part_->storage.getVirtuals()), part(part_)
Expand Down
7 changes: 4 additions & 3 deletions dbms/src/Storages/StorageReplicatedMergeTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3128,7 +3128,6 @@ void StorageReplicatedMergeTree::alter(

if (params.isSettingsAlter())
{
lockStructureExclusively(table_lock_holder, query_context.getCurrentQueryId());
/// We don't replicate storage_settings_ptr ALTER. It's local operation.
/// Also we don't upgrade alter lock to table structure lock.
LOG_DEBUG(log, "ALTER storage_settings_ptr only");
Expand Down Expand Up @@ -3172,7 +3171,9 @@ void StorageReplicatedMergeTree::alter(
std::vector<ChangedNode> changed_nodes;

{
/// We can safely read structure, because we guarded with alter_intention_lock
/// Just to read current structure. Alter will be done in separate thread.
auto table_lock = lockStructureForShare(false, query_context.getCurrentQueryId());

if (is_readonly)
throw Exception("Can't ALTER readonly table", ErrorCodes::TABLE_IS_READ_ONLY);

Expand Down Expand Up @@ -3213,13 +3214,13 @@ void StorageReplicatedMergeTree::alter(
/// Perform settings update locally
if (!new_changes.empty())
{
lockStructureExclusively(table_lock_holder, query_context.getCurrentQueryId());
IDatabase::ASTModifier settings_modifier = getSettingsModifier(new_changes);

changeSettings(new_changes, table_lock_holder);

global_context.getDatabase(current_database_name)->alterTable(
query_context, current_table_name, getColumns(), getIndices(), getConstraints(), settings_modifier);

}

/// Modify shared metadata nodes in ZooKeeper.
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 4fd80be

Please sign in to comment.