Allow parsing both variants of BACKUP EXCEPT TABLES query

This commit is contained in:
Konstantin Bogdanov 2024-11-26 03:45:15 +01:00
parent 66b874dafd
commit 81f6e993e9
No known key found for this signature in database

View File

@ -9,6 +9,7 @@
#include <Parsers/ParserPartition.h>
#include <Parsers/ParserSetQuery.h>
#include <Parsers/parseDatabaseAndTableName.h>
#include <Common/Exception.h>
#include <Common/assert_cast.h>
#include <boost/range/algorithm_ext/erase.hpp>
@ -16,6 +17,11 @@
namespace DB
{
namespace ErrorCodes
{
extern const int SYNTAX_ERROR;
}
namespace
{
using Kind = ASTBackupQuery::Kind;
@ -78,19 +84,20 @@ namespace
auto parse_list_element = [&]
{
DatabaseAndTableName table_name;
if (database_name)
{
ASTPtr ast;
if (!ParserIdentifier{}.parse(pos, ast, expected))
return false;
if (!parseDatabaseAndTableName(pos, expected, table_name.first, table_name.second))
return false;
if (database_name && table_name.first.empty())
table_name.first = *database_name;
table_name.second = getIdentifierName(ast);
}
else
{
if (!parseDatabaseAndTableName(pos, expected, table_name.first, table_name.second))
return false;
}
if (database_name && table_name.first != *database_name)
throw Exception(
ErrorCodes::SYNTAX_ERROR,
"Database name in EXCEPT TABLES clause doesn't match the database name in DATABASE clause: {} != {}",
table_name.first,
*database_name
);
result.emplace(std::move(table_name));
return true;