Repository: ClickHouse/ClickHouse
File: src/Storages/System/StorageSystemTables.cpp (C++)

Code before:
                columns[res_index++]->insertDefault();
                return;
            }

            NameToNameMap query_parameters_array = getSelectParamters(metadata_snapshot);
            if (!query_parameters_array.empty())
            {
                Array changes;
                for (const auto & [key, value] : query_parameters_array)
                    changes.push_back(Tuple{key, value});
                columns[res_index++]->insert(changes);
            }
            else
                columns[res_index++]->insertDefault();
        }
    }


    void showTablesQuery(MutableColumns & res_columns, bool need_to_check_access_for_tables)
    {
        auto table_details = database->getLightweightTablesIterator(context,
                                /* filter_by_table_name */ {},
                                /* skip_not_loaded */ false);

        const auto access = context->getAccess();
        for (auto & table_detail: table_details)
        {
            size_t src_index = 0;
            size_t res_index = 0;

            if (need_to_check_access_for_tables && !access->isGranted(AccessType::SHOW_TABLES, database_name, table_detail.name))
                continue;

            if (columns_mask[src_index++])
                res_columns[res_index++]->insert(database_name);

            if (columns_mask[src_index++])
                res_columns[res_index++]->insert(table_detail.name);
        }
    }

    Chunk generate() override
    {
        if (done)
            return {};

        MutableColumns res_columns = getPort().getHeader().cloneEmptyColumns();

        const auto access = context->getAccess();
        const bool need_to_check_access_for_databases = !access->isGranted(AccessType::SHOW_TABLES);


Review comment (suggestion):
The loop variable `table_detail` should be `const auto &` instead of `auto &` since it's not being modified in the loop body.
```suggestion
        for (const auto & table_detail: table_details)
```

Code after:
                columns[res_index++]->insertDefault();
        }
    }


    size_t fillTableNamesOnly(MutableColumns & res_columns, bool need_to_check_access_for_tables)
    {
        auto table_details = database->getLightweightTablesIterator(context,
                                /* filter_by_table_name */ {},
                                /* skip_not_loaded */ false);

        size_t count = 0;

        const auto access = context->getAccess();
        for (const auto & table_detail: table_details)
        {
            size_t src_index = 0;
            size_t res_index = 0;

            if (need_to_check_access_for_tables && !access->isGranted(AccessType::SHOW_TABLES, database_name, table_detail.name))
                continue;

            if (columns_mask[src_index++])
                res_columns[res_index++]->insert(database_name);

            if (columns_mask[src_index++])
                res_columns[res_index++]->insert(table_detail.name);

            ++count;
        }
        ++database_idx;
        return count;
    }

    Chunk generate() override
    {
        if (done)
            return {};

        MutableColumns res_columns = getPort().getHeader().cloneEmptyColumns();

        const auto access = context->getAccess();
        const bool need_to_check_access_for_databases = !access->isGranted(AccessType::SHOW_TABLES);

        size_t rows_count = 0;
        while (rows_count < max_block_size)
        {
            if (tables_it && !tables_it->isValid())
                ++database_idx;

            while (database_idx < databases->size() && (!tables_it || !tables_it->isValid()))