Fix nullpointer dereference in AddDefaultDatabaseVisitor

This commit is contained in:
alesapin 2021-09-30 18:56:55 +03:00
parent 7bc6b8fd70
commit f31c35de48
3 changed files with 20 additions and 1 deletions

View File

@ -138,7 +138,12 @@ private:
/// XXX: for some unknown reason this place assumes that argument can't be an alias,
/// like in the similar code in `MarkTableIdentifierVisitor`.
if (auto * identifier = child->children[i]->as<ASTIdentifier>())
child->children[i] = identifier->createTable();
{
/// If identifier is broken then can do nothing and get an exception
auto maybe_table_identifier = identifier->createTable();
if (maybe_table_identifier)
child->children[i] = maybe_table_identifier;
}
/// Second argument of the "in" function (or similar) may be a table name or a subselect.
/// Rewrite the table name or descend into subselect.

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,13 @@
DROP TABLE IF EXISTS alter_table;
CREATE TABLE alter_table (a UInt8, b Int16)
ENGINE = MergeTree
ORDER BY a;
ALTER TABLE alter_table
MODIFY COLUMN `b` DateTime DEFAULT now(([NULL, NULL, NULL, [-2147483648], [NULL, NULL, NULL, NULL, NULL, NULL, NULL]] AND (1048576 AND NULL) AND (NULL AND 1048575 AND NULL AND -2147483649) AND NULL) IN (test_01103.t1_distr.id)); --{serverError 47}
SELECT 1;
DROP TABLE IF EXISTS alter_table;