Skip to content

Commit 064d022

Browse files
Backport ClickHouse#82820 to 25.6: Fix exception safety in union/intersect/except_default_mode rewrite
1 parent a35a604 commit 064d022

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/Interpreters/SelectIntersectExceptQueryVisitor.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ void SelectIntersectExceptQueryMatcher::visit(ASTPtr & ast, Data & data)
3232

3333
void SelectIntersectExceptQueryMatcher::visit(ASTSelectWithUnionQuery & ast, Data & data)
3434
{
35-
auto union_modes = std::move(ast.list_of_modes);
35+
auto union_modes = ast.list_of_modes;
3636

3737
if (union_modes.empty())
3838
return;
3939

40-
auto selects = std::move(ast.list_of_selects->children);
40+
auto selects = ast.list_of_selects->children;
4141

4242
if (union_modes.size() + 1 != selects.size())
4343
throw Exception(ErrorCodes::LOGICAL_ERROR, "Incorrect ASTSelectWithUnionQuery (modes: {}, selects: {})",
@@ -59,7 +59,7 @@ void SelectIntersectExceptQueryMatcher::visit(ASTSelectWithUnionQuery & ast, Dat
5959
else if (data.except_default_mode == SetOperationMode::DISTINCT)
6060
mode = SelectUnionMode::EXCEPT_DISTINCT;
6161
else
62-
throw Exception(DB::ErrorCodes::EXPECTED_ALL_OR_DISTINCT,
62+
throw Exception(ErrorCodes::EXPECTED_ALL_OR_DISTINCT,
6363
"Expected ALL or DISTINCT in EXCEPT query, because setting (except_default_mode) is empty");
6464
}
6565
else if (mode == SelectUnionMode::INTERSECT_DEFAULT)
@@ -69,7 +69,7 @@ void SelectIntersectExceptQueryMatcher::visit(ASTSelectWithUnionQuery & ast, Dat
6969
else if (data.intersect_default_mode == SetOperationMode::DISTINCT)
7070
mode = SelectUnionMode::INTERSECT_DISTINCT;
7171
else
72-
throw Exception(DB::ErrorCodes::EXPECTED_ALL_OR_DISTINCT,
72+
throw Exception(ErrorCodes::EXPECTED_ALL_OR_DISTINCT,
7373
"Expected ALL or DISTINCT in INTERSECT query, because setting (intersect_default_mode) is empty");
7474
}
7575

tests/queries/0_stateless/03550_union_intersect_except_default_mode_rewrite_exception_safety.reference

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(SELECT 1 EXCEPT SELECT 1) SETTINGS except_default_mode = ''; -- { serverError EXPECTED_ALL_OR_DISTINCT }

0 commit comments

Comments
 (0)