**Describe the bug**
`SELECT i FROM generateRandom('i Array(Int8)', 1048575, 10, 1048577) LIMIT 1048575`

Memory limit should be respected.
BlockIO res;
    String query_for_logging;
    try
    {
        
        if (context.hasQueryParameters())
        {
            ReplaceQueryParameterVisitor visitor(context.getQueryParameters());
            visitor.visit(ast);
            query = serializeAST(*ast);
        }
        
        
        
        query_for_logging = prepareQueryForLogging(query, context);
        logQuery(query_for_logging, context, internal);
        
        if (settings.enable_global_with_statement)
        {
            ApplyWithGlobalVisitor().visit(ast);
            query = serializeAST(*ast);
        }
        
        checkASTSizeLimits(*ast, settings);
        
        ProcessList::EntryPtr process_list_entry;
        if (!internal && !ast->as<ASTShowProcesslistQuery>())
        {
            
            process_list_entry = context.getProcessList().insert(query_for_logging, ast.get(), context);