```
DROP TABLE IF EXISTS foo;

CREATE TABLE foo (timestamp DateTime, x UInt64)
ENGINE = MergeTree PARTITION BY toYYYYMMDD(timestamp)
ORDER BY (timestamp);

INSERT INTO foo (timestamp, x) SELECT toDateTime('2020-01-01 00:05:00'), number from system.numbers_mt LIMIT 100;

SELECT count() FROM system.mutations; -- ok

ALTER TABLE foo UPDATE x = 1 WHERE x = (SELECT x from foo WHERE x = 1);

SELECT count() FROM system.mutations; -- stuck

```
{
    ASTs & elements = select_query->select()->children;
    std::set<String> all_column_names;
    std::set<String> assigned_column_names;
    for (auto & expr : elements)
        all_column_names.insert(expr->getAliasOrColumnName());
    for (auto & expr : elements)
    {
        auto name = expr->getAliasOrColumnName();
        if (!assigned_column_names.insert(name).second)
        {
            size_t i = 1;
            while (all_column_names.end() != all_column_names.find(name + "_" + toString(i)))
                ++i;
            name = name + "_" + toString(i);
            expr = expr->clone();   
            expr->setAlias(name);
            all_column_names.insert(name);
            assigned_column_names.insert(name);
        }
    }
}
void removeUnneededColumnsFromSelectClause(const ASTSelectQuery * select_query, const Names & required_result_columns, bool remove_dups)