From a1820916213e1d0ea9eee76567d65637b7672115 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Tue, 11 Feb 2014 18:54:31 +0000 Subject: [PATCH] storages: support for CREATE MATERIALIZED VIEW IF NOT EXISTS [METR-9965] --- dbms/src/Parsers/ParserCreateQuery.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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);