Skip to content

Commit 1f3c361

Browse files
weigondahlerlend
authored andcommitted
Bug#36036725 'DO 1;' forbidden by rw-splitting
"DO 1;" is treated as multi-statement which are currently forbidden by rw-splitting. Change ====== - allow trailing semicolons after a single query Change-Id: If5d389b5381c63313519ca15d5eb8349a4eb9d4c
1 parent 94a9874 commit 1f3c361

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

router/src/routing/src/classic_query_forwarder.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,11 @@ bool contains_multiple_statements(SqlLexer &&lexer) {
221221
}
222222

223223
if (begin_end_depth == 0) {
224-
// semicolon outside a BEGIN...END block.
225-
if (tkn.id == ';') return true;
224+
if (last_tkn) {
225+
// semicolon outside a BEGIN...END block.
226+
227+
if (last_tkn->id == ';' && tkn.id != END_OF_INPUT) return true;
228+
}
226229
}
227230

228231
last_tkn = tkn;

router/tests/component/test_routing_splitting.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2205,6 +2205,14 @@ TEST_F(RoutingSplittingTest, multi_statements_are_forbidden) {
22052205
EXPECT_EQ(query_res.error().value(),
22062206
4501); // multi-statements are forbidden.
22072207
}
2208+
2209+
// trailing comma is ok.
2210+
{
2211+
auto query_res = cli.query("DO 2;");
2212+
ASSERT_ERROR(query_res);
2213+
EXPECT_EQ(query_res.error().value(),
2214+
1273); // syntax error (from mock-server)
2215+
}
22082216
}
22092217
}
22102218

0 commit comments

Comments
 (0)