mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Merge pull request #56489 from evillique/fix-drop-ttl-dependency
Fix startup failure due to TTL dependency
This commit is contained in:
commit
02ce2a0e83
@ -1,4 +1,5 @@
|
||||
#include <Databases/DDLLoadingDependencyVisitor.h>
|
||||
#include <Databases/DDLDependencyVisitor.h>
|
||||
#include <Dictionaries/getDictionaryConfigurationFromAST.h>
|
||||
#include <Interpreters/Context.h>
|
||||
#include <Interpreters/misc.h>
|
||||
@ -7,6 +8,7 @@
|
||||
#include <Parsers/ASTIdentifier.h>
|
||||
#include <Parsers/ASTLiteral.h>
|
||||
#include <Parsers/ASTSelectWithUnionQuery.h>
|
||||
#include <Parsers/ASTTTLElement.h>
|
||||
#include <Poco/String.h>
|
||||
|
||||
|
||||
@ -22,6 +24,7 @@ TableNamesSet getLoadingDependenciesFromCreateQuery(ContextPtr global_context, c
|
||||
data.default_database = global_context->getCurrentDatabase();
|
||||
data.create_query = ast;
|
||||
data.global_context = global_context;
|
||||
data.table_name = table;
|
||||
TableLoadingDependenciesVisitor visitor{data};
|
||||
visitor.visit(ast);
|
||||
data.dependencies.erase(table);
|
||||
@ -113,6 +116,12 @@ void DDLLoadingDependencyVisitor::visit(const ASTFunctionWithKeyValueArguments &
|
||||
|
||||
void DDLLoadingDependencyVisitor::visit(const ASTStorage & storage, Data & data)
|
||||
{
|
||||
if (storage.ttl_table)
|
||||
{
|
||||
auto ttl_dependensies = getDependenciesFromCreateQuery(data.global_context, data.table_name, storage.ttl_table->ptr());
|
||||
data.dependencies.merge(ttl_dependensies);
|
||||
}
|
||||
|
||||
if (!storage.engine)
|
||||
return;
|
||||
|
||||
|
@ -38,6 +38,7 @@ public:
|
||||
TableNamesSet dependencies;
|
||||
ContextPtr global_context;
|
||||
ASTPtr create_query;
|
||||
QualifiedTableName table_name;
|
||||
};
|
||||
|
||||
using Visitor = ConstInDepthNodeVisitor<DDLLoadingDependencyVisitor, true>;
|
||||
|
24
tests/queries/0_stateless/02908_table_ttl_dependency.sh
Executable file
24
tests/queries/0_stateless/02908_table_ttl_dependency.sh
Executable file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tags: no-ordinary-database
|
||||
# Tag no-ordinary-database: requires UUID
|
||||
|
||||
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CUR_DIR"/../shell_config.sh
|
||||
|
||||
$CLICKHOUSE_CLIENT -nm -q "
|
||||
DROP TABLE IF EXISTS 02908_dependent;
|
||||
DROP TABLE IF EXISTS 02908_main;
|
||||
|
||||
CREATE TABLE 02908_main (a UInt32) ENGINE = MergeTree ORDER BY a;
|
||||
CREATE TABLE 02908_dependent (a UInt32, ts DateTime) ENGINE = MergeTree ORDER BY a TTL ts + 1 WHERE a IN (SELECT a FROM ${CLICKHOUSE_DATABASE}.02908_main);
|
||||
"
|
||||
|
||||
$CLICKHOUSE_CLIENT -nm -q "
|
||||
DROP TABLE 02908_main;
|
||||
" 2>&1 | grep -F -q "HAVE_DEPENDENT_OBJECTS"
|
||||
|
||||
$CLICKHOUSE_CLIENT -nm -q "
|
||||
DROP TABLE 02908_dependent;
|
||||
DROP TABLE 02908_main;
|
||||
"
|
Loading…
Reference in New Issue
Block a user