From 380ab2dacc3ec2db6716e7bb0d01db66a5051967 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 25 Mar 2015 05:49:29 +0300 Subject: [PATCH] dbms: added (ignored) table and FROM/JOIN subquery aliases [#METR-15573]. --- dbms/src/Parsers/ParserJoin.cpp | 4 ++++ dbms/src/Parsers/ParserSelectQuery.cpp | 4 ++++ dbms/tests/queries/0_stateless/00138_table_aliases.reference | 2 ++ dbms/tests/queries/0_stateless/00138_table_aliases.sql | 2 ++ 4 files changed, 12 insertions(+) create mode 100644 dbms/tests/queries/0_stateless/00138_table_aliases.reference create mode 100644 dbms/tests/queries/0_stateless/00138_table_aliases.sql diff --git a/dbms/src/Parsers/ParserJoin.cpp b/dbms/src/Parsers/ParserJoin.cpp index a8d2d839915..7f60a8499de 100644 --- a/dbms/src/Parsers/ParserJoin.cpp +++ b/dbms/src/Parsers/ParserJoin.cpp @@ -73,6 +73,10 @@ bool ParserJoin::parseImpl(Pos & pos, Pos end, ASTPtr & node, Expected & expecte ws.ignore(pos, end); + /// Может быть указан алиас. На данный момент, он ничего не значит и не используется. + ParserAlias().ignore(pos, end); + ws.ignore(pos, end); + if (!s_using.ignore(pos, end, expected)) return false; diff --git a/dbms/src/Parsers/ParserSelectQuery.cpp b/dbms/src/Parsers/ParserSelectQuery.cpp index ed7f2f94fa7..5e6e99cf106 100644 --- a/dbms/src/Parsers/ParserSelectQuery.cpp +++ b/dbms/src/Parsers/ParserSelectQuery.cpp @@ -125,6 +125,10 @@ bool ParserSelectQuery::parseImpl(Pos & pos, Pos end, ASTPtr & node, Expected & } else return false; + + /// Может быть указан алиас. На данный момент, он ничего не значит и не используется. + ParserAlias().ignore(pos, end); + ws.ignore(pos, end); } /** FINAL и SAMPLE может быть здесь или после всех JOIN-ов diff --git a/dbms/tests/queries/0_stateless/00138_table_aliases.reference b/dbms/tests/queries/0_stateless/00138_table_aliases.reference new file mode 100644 index 00000000000..738256fa6ec --- /dev/null +++ b/dbms/tests/queries/0_stateless/00138_table_aliases.reference @@ -0,0 +1,2 @@ +0 +1 Hello diff --git a/dbms/tests/queries/0_stateless/00138_table_aliases.sql b/dbms/tests/queries/0_stateless/00138_table_aliases.sql new file mode 100644 index 00000000000..58fe2ac65e9 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00138_table_aliases.sql @@ -0,0 +1,2 @@ +SELECT * FROM `system`.`one` AS `xxx`; +SELECT 1 AS k, s FROM `system`.`one` AS `xxx` ANY LEFT JOIN (SELECT 1 AS k, 'Hello' AS s) AS `yyy` USING k;