Do not try to resolve temporary tables from global context

This commit is contained in:
Azat Khuzhin 2021-11-12 22:13:09 +03:00
parent 69cd19a342
commit fa317e96e8
3 changed files with 14 additions and 3 deletions

View File

@ -2821,6 +2821,10 @@ StorageID Context::resolveStorageIDImpl(StorageID storage_id, StorageNamespace w
}
bool look_for_external_table = where & StorageNamespace::ResolveExternal;
/// Global context should not contain temporary tables
if (isGlobalContext() && getApplicationType() != ApplicationType::LOCAL)
look_for_external_table = false;
bool in_current_database = where & StorageNamespace::ResolveCurrentDatabase;
bool in_specified_database = where & StorageNamespace::ResolveGlobal;
@ -2838,9 +2842,6 @@ StorageID Context::resolveStorageIDImpl(StorageID storage_id, StorageNamespace w
if (look_for_external_table)
{
/// Global context should not contain temporary tables
assert(!isGlobalContext() || getApplicationType() == ApplicationType::LOCAL);
auto resolved_id = StorageID::createEmpty();
auto try_resolve = [&](ContextPtr context) -> bool
{

View File

@ -0,0 +1,5 @@
-- { echo }
SELECT * FROM remote('127.1', system.one, 1 IN id); -- { serverError UNKNOWN_TABLE }
SELECT * FROM remote('127.1', system.one, 1 IN dummy); -- { serverError UNKNOWN_TABLE }
SELECT * FROM remote('127.1', view(SELECT * FROM system.one), 1 IN id); -- { serverError UNKNOWN_TABLE }
SELECT * FROM remote('127.1', view(SELECT number AS id FROM numbers(2)), 1 IN id); -- { serverError UNKNOWN_TABLE }

View File

@ -0,0 +1,5 @@
-- { echo }
SELECT * FROM remote('127.1', system.one, 1 IN id); -- { serverError UNKNOWN_TABLE }
SELECT * FROM remote('127.1', system.one, 1 IN dummy); -- { serverError UNKNOWN_TABLE }
SELECT * FROM remote('127.1', view(SELECT * FROM system.one), 1 IN id); -- { serverError UNKNOWN_TABLE }
SELECT * FROM remote('127.1', view(SELECT number AS id FROM numbers(2)), 1 IN id); -- { serverError UNKNOWN_TABLE }