aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/complete/syntax/cursor_token_context.cpp
diff options
context:
space:
mode:
authorvityaman <vityaman.dev@yandex.ru>2025-05-20 13:09:37 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2025-05-20 13:23:38 +0300
commitae913bccb4fd8a8ba5f536c8afe622e2ad229fbc (patch)
tree4145cf25a40302e0888e7174d288f4ed00919738 /yql/essentials/sql/v1/complete/syntax/cursor_token_context.cpp
parent16630d4dfad772e0108e694f76f922e486cd6439 (diff)
downloadydb-ae913bccb4fd8a8ba5f536c8afe622e2ad229fbc.tar.gz
YQL-19747: Recover from unclosed ID_QUOTED
The simplest solution actually is an SQL injection. --- - Related to `YQL-19747` - Related to https://github.com/ydb-platform/ydb/issues/9056 - Related to https://github.com/ydb-platform/ydb/pull/18146 - Related to https://github.com/vityaman/ydb/issues/46 --- Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1283 commit_hash:7043e7cdd1e0d378926783d31cf5f8e055393aaa
Diffstat (limited to 'yql/essentials/sql/v1/complete/syntax/cursor_token_context.cpp')
-rw-r--r--yql/essentials/sql/v1/complete/syntax/cursor_token_context.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/yql/essentials/sql/v1/complete/syntax/cursor_token_context.cpp b/yql/essentials/sql/v1/complete/syntax/cursor_token_context.cpp
index 33aef36847a..445f863a255 100644
--- a/yql/essentials/sql/v1/complete/syntax/cursor_token_context.cpp
+++ b/yql/essentials/sql/v1/complete/syntax/cursor_token_context.cpp
@@ -112,13 +112,13 @@ namespace NSQLComplete {
bool GetStatement(
ILexer::TPtr& lexer,
- TCompletionInput input,
+ const TMaterializedInput& input,
TCompletionInput& output,
size_t& output_position) {
TVector<TString> statements;
NYql::TIssues issues;
if (!NSQLTranslationV1::SplitQueryToStatements(
- TString(input.Text) + ";", lexer,
+ input.Text, lexer,
statements, issues, /* file = */ "",
/* areBlankSkipped = */ false)) {
return false;
@@ -129,7 +129,7 @@ namespace NSQLComplete {
for (const auto& statement : statements) {
if (input.CursorPosition < cursor + statement.size()) {
output = {
- .Text = input.Text.SubStr(cursor, statement.size()),
+ .Text = TStringBuf(input.Text).SubStr(cursor, statement.size()),
.CursorPosition = input.CursorPosition - cursor,
};
return true;
@@ -137,7 +137,8 @@ namespace NSQLComplete {
cursor += statement.size();
}
- output = input;
+ output.Text = TStringBuf(input.Text);
+ output.CursorPosition = input.CursorPosition;
return true;
}