Repository: ClickHouse/ClickHouse
File: src/Interpreters/Context.h (C/C++)

Code before:
    String current_database;
    std::unique_ptr<Settings> settings{};  /// Setting for query execution.

    using ProgressCallback = std::function<void(const Progress & progress)>;
    ProgressCallback progress_callback;  /// Callback for tracking progress of query execution.

    using FileProgressCallback = std::function<void(const FileProgress & progress)>;
    FileProgressCallback file_progress_callback; /// Callback for tracking progress of file loading.

    using InteractiveCancelCallback = std::function<bool()>;
    InteractiveCancelCallback interactive_cancel_callback; /// Callback for usage in interactive sessions with CompletedPipelineExecutor

    std::weak_ptr<QueryStatus> process_list_elem;  /// For tracking total resource usage for query.
    bool has_process_list_elem = false;     /// It's impossible to check if weak_ptr was initialized or not
    struct InsertionTableInfo
    {
        StorageID table = StorageID::createEmpty();
        std::optional<Names> column_names;
        std::optional<ColumnsDescription> columns_description;
    };

    InsertionTableInfo insertion_table_info;  /// Saved information about insertion table in query context
    bool is_distributed = false;  /// Whether the current context it used for distributed query

    String default_format;  /// Format, used when server formats data by itself and if query does not have FORMAT specification.
                            /// Thus, used in HTTP interface. If not specified - then some globally default format is used.

    String insert_format; /// Format, used in insert query.

    TemporaryTablesMapping external_tables_mapping;
    Scalars scalars;
    /// Used to store constant values which are different on each instance during distributed plan, such as _shard_num.
    Scalars special_scalars;

    /// Mapping between identifiers and time series tags collected in the context of the currently executed query.
    std::shared_ptr<ContextTimeSeriesTagsCollector> time_series_tags_collector;

    /// Used in s3Cluster table function. With this callback, a worker node could ask an initiator
    /// about next file to read from s3.
    std::optional<ClusterFunctionReadTaskCallback> next_task_callback;
    /// Used in parallel reading from replicas. A replica tells about its intentions to read
    /// some ranges from some part and initiator will tell the replica about whether it is accepted or denied.
    std::optional<MergeTreeReadTaskCallback> merge_tree_read_task_callback;
    std::optional<MergeTreeAllRangesCallback> merge_tree_all_ranges_callback;
    UUID parallel_replicas_group_uuid{UUIDHelpers::Nil};

    BlockMarshallingCallback block_marshalling_callback;

    mutable RuntimeDataflowStatisticsCacheUpdaterPtr dataflow_cache_updater;

    bool is_under_restore = false;

Review comment (suggestion):
`ColumnsDescription` here looks like query metadata and is typically expected to be immutable once captured. Exposing it as `std::shared_ptr<ColumnsDescription>` allows mutation through shared ownership and makes it harder to reason about safety. Consider switching to `std::shared_ptr<const ColumnsDescription>` (and updating setter/getter accordingly) to enforce immutability and prevent accidental modification.
```suggestion
        std::shared_ptr<const ColumnsDescription> columns_description;
```

Code after:

    std::optional<UUID> user_id;
    std::shared_ptr<std::vector<UUID>> current_roles;
    std::shared_ptr<std::vector<UUID>> external_roles;
    std::shared_ptr<const SettingsConstraintsAndProfileIDs> settings_constraints_and_current_profiles;
    mutable std::shared_ptr<const ContextAccess> access;
    mutable bool need_recalculate_access = true;
    String current_database;
    std::unique_ptr<Settings> settings{};  /// Setting for query execution.

    using ProgressCallback = std::function<void(const Progress & progress)>;
    ProgressCallback progress_callback;  /// Callback for tracking progress of query execution.

    using FileProgressCallback = std::function<void(const FileProgress & progress)>;
    FileProgressCallback file_progress_callback; /// Callback for tracking progress of file loading.

    using InteractiveCancelCallback = std::function<bool()>;
    InteractiveCancelCallback interactive_cancel_callback; /// Callback for usage in interactive sessions with CompletedPipelineExecutor

    std::weak_ptr<QueryStatus> process_list_elem;  /// For tracking total resource usage for query.
    bool has_process_list_elem = false;     /// It's impossible to check if weak_ptr was initialized or not
    struct InsertionTableInfo
    {
        StorageID table = StorageID::createEmpty();
        std::optional<Names> column_names;
        std::shared_ptr<ColumnsDescription> columns_description;
    };

    InsertionTableInfo insertion_table_info;  /// Saved information about insertion table in query context
    bool is_distributed = false;  /// Whether the current context it used for distributed query

    String default_format;  /// Format, used when server formats data by itself and if query does not have FORMAT specification.
                            /// Thus, used in HTTP interface. If not specified - then some globally default format is used.

    String insert_format; /// Format, used in insert query.

    TemporaryTablesMapping external_tables_mapping;
    Scalars scalars;
    /// Used to store constant values which are different on each instance during distributed plan, such as _shard_num.
    Scalars special_scalars;

    /// Mapping between identifiers and time series tags collected in the context of the currently executed query.
    std::shared_ptr<ContextTimeSeriesTagsCollector> time_series_tags_collector;

    /// Used in s3Cluster table function. With this callback, a worker node could ask an initiator
    /// about next file to read from s3.
    std::optional<ClusterFunctionReadTaskCallback> next_task_callback;
    /// Used in parallel reading from replicas. A replica tells about its intentions to read
    /// some ranges from some part and initiator will tell the replica about whether it is accepted or denied.
    std::optional<MergeTreeReadTaskCallback> merge_tree_read_task_callback;
    std::optional<MergeTreeAllRangesCallback> merge_tree_all_ranges_callback;