**How to reproduce**
```
for i in {1..1000}; do echo 'Hello, world!' | clickhouse-local --query "SELECT * FROM table" --structure 's String' | wc -c; done
```

This script hangs.
{
    DatabasePtr system_database = DatabaseCatalog::instance().tryGetDatabase(DatabaseCatalog::SYSTEM_DATABASE);
    if (!system_database)
    {
        
        system_database = std::make_shared<DatabaseMemory>(DatabaseCatalog::SYSTEM_DATABASE, context);
        DatabaseCatalog::instance().attachDatabase(DatabaseCatalog::SYSTEM_DATABASE, system_database);
    }
    attachSystemTablesLocal(*system_database);
}
int LocalServer::main(const std::vector<std::string> & )
try
{
    Poco::Logger * log = &logger();
    ThreadStatus thread_status;
    UseSSL use_ssl;
    if (!config().has("query") && !config().has("table-structure") && !config().has("queries-file")) 
    {
        if (config().hasOption("verbose"))
            std::cerr << "There are no queries to process." << '\n';
        return Application::EXIT_OK;
    }
    if (config().has("query") && config().has("queries-file"))
    {