Merge pull request #49043 from RoryCrispin/dict-lifetime-validation

Validate direct dictionary lifetime is unset during creation
This commit is contained in:
Alexey Milovidov 2023-09-30 07:54:50 +03:00 committed by GitHub
commit b2b6720737
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 0 deletions

View File

@ -572,11 +572,24 @@ void checkPrimaryKey(const AttributeNameToConfiguration & all_attrs, const Names
}
void checkLifetime(const ASTCreateQuery & query)
{
if (query.dictionary->layout && query.dictionary->layout->layout_type == "direct")
{
if (query.dictionary->lifetime)
throw Exception(
ErrorCodes::BAD_ARGUMENTS,
"'lifetime' parameter is redundant for the dictionary' of layout '{}'",
query.dictionary->layout->layout_type);
}
}
DictionaryConfigurationPtr
getDictionaryConfigurationFromAST(const ASTCreateQuery & query, ContextPtr context, const std::string & database_)
{
checkAST(query);
checkLifetime(query);
AutoPtr<Poco::XML::Document> xml_document(new Poco::XML::Document());
AutoPtr<Poco::XML::Element> document_root(xml_document->createElement("dictionaries"));

View File

@ -0,0 +1,3 @@
CREATE TABLE IF NOT EXISTS dict_source (key UInt64, value String) ENGINE=MergeTree ORDER BY key;
CREATE DICTIONARY dict(`key` UInt64,`value` String) PRIMARY KEY key SOURCE(CLICKHOUSE(table 'dict_source')) LAYOUT(DIRECT()) LIFETIME(0); -- { serverError 36 }