diff --git a/dbms/src/Parsers/ParserCreateQuery.cpp b/dbms/src/Parsers/ParserCreateQuery.cpp index 2c65aab08f8..47c91727bcb 100644 --- a/dbms/src/Parsers/ParserCreateQuery.cpp +++ b/dbms/src/Parsers/ParserCreateQuery.cpp @@ -329,15 +329,22 @@ bool ParserCreateQuery::parseImpl(Pos & pos, Pos end, ASTPtr & node, String & ex } } else { /// VIEW or MATERIALIZED VIEW - if (s_materialized.ignore(pos, end, expected)) + if (s_materialized.ignore(pos, end, expected) && ws.ignore(pos, end, expected)) is_materialized_view = true; else is_view = true; - ws.ignore(pos, end, expected); - if (!s_view.ignore(pos, end, expected)) + if (!s_view.ignore(pos, end, expected) || !ws.ignore(pos, end, expected)) return false; - ws.ignore(pos, end); + + if (s_if.ignore(pos, end, expected) + && ws.ignore(pos, end) + && s_not.ignore(pos, end, expected) + && ws.ignore(pos, end) + && s_exists.ignore(pos, end, expected) + && ws.ignore(pos, end)) + if_not_exists = true; + if (!name_p.parse(pos, end, table, expected)) return false; ws.ignore(pos, end);