```
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

```
for (const auto & [name, _] : table_join->columns_from_joined_table)
            all_source_columns_set.insert(name);
    }
    normalize(query, result.aliases, all_source_columns_set, select_options.ignore_alias, settings,  true);
    
    
    
    
    removeUnneededColumnsFromSelectClause(select_query, required_result_columns, remove_duplicates);
    
    executeScalarSubqueries(query, getContext(), subquery_depth, result.scalars, select_options.only_analyze);
    if (settings.legacy_column_name_of_tuple_literal)
        markTupleLiteralsAsLegacy(query);
    
    result.rewrite_subqueries = PredicateExpressionsOptimizer(getContext(), tables_with_columns, settings).optimize(*select_query);
    
    if (getContext()->getClientInfo().query_kind == ClientInfo::QueryKind::INITIAL_QUERY)
        TreeOptimizer::apply(query, result, tables_with_columns, getContext());
    
    getArrayJoinedColumns(query, result, select_query, result.source_columns, source_columns_set);
    setJoinStrictness(
        *select_query, settings.join_default_strictness, settings.any_join_distinct_right_table_keys, result.analyzed_join->table_join);
    auto * table_join_ast = select_query->join() ? select_query->join()->table_join->as<ASTTableJoin>() : nullptr;
    if (table_join_ast && tables_with_columns.size() >= 2)
        collectJoinedColumns(*result.analyzed_join, *table_join_ast, tables_with_columns, result.aliases);
    result.aggregates = getAggregates(query, *select_query);
    result.window_function_asts = getWindowFunctions(query, *select_query);
    result.collectUsedColumns(query, true);
    result.required_source_columns_before_expanding_alias_columns = result.required_source_columns.getNames();