Merge pull request #69941 from ClickHouse/backport/24.8/69907

Backport #69907 to 24.8: Don't check dependencies during CREATE OR REPLACE VIEW during DROP of old table
This commit is contained in:
robot-ch-test-poll1 2024-09-25 21:16:02 +04:00 committed by GitHub
commit 7c7a657591
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 0 deletions

View File

@ -1528,6 +1528,9 @@ bool InterpreterCreateQuery::doCreateTable(ASTCreateQuery & create,
drop_ast->no_ddl_lock = true;
auto drop_context = Context::createCopy(context);
/// Don't check dependencies during DROP of the view, because we will recreate
/// it with the same name and all dependencies will remain valid.
drop_context->setSetting("check_table_dependencies", false);
InterpreterDropQuery interpreter(drop_ast, drop_context);
interpreter.execute();
}

View File

@ -0,0 +1,21 @@
drop table if exists test;
drop view if exists v;
drop dictionary if exists dict;
create table test (x UInt32, v String) engine=Memory;
create view v (x UInt32, v String) as select x, v from test;
CREATE DICTIONARY dict
(
x UInt64,
v String
)
PRIMARY KEY x
SOURCE(CLICKHOUSE(TABLE 'v'))
LAYOUT(FLAT())
LIFETIME(MIN 0 MAX 1000);
drop view v; -- {serverError HAVE_DEPENDENT_OBJECTS}
create or replace view v (x UInt32, v String, y UInt32) as select x, v, 42 as y from test;
drop dictionary dict;
drop view v;
drop table test;