Skip to content

Commit e7e47a9

Browse files
committed
BUG#37528585 MySQL Shell Auto-complete crashes shell
An incorrect handling of non existing members in the autocompletion chain caused the problem. Change-Id: Id239be6f02290977c9d5c1ce37ca6152f7a3c63f
1 parent 29e2c7c commit e7e47a9

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

mysqlshdk/scripting/polyglot/polyglot_context.cc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024, Oracle and/or its affiliates.
2+
* Copyright (c) 2024, 2025, Oracle and/or its affiliates.
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License, version 2.0,
@@ -148,13 +148,17 @@ const std::vector<std::string> &Polyglot_context::keywords() const {
148148
std::tuple<bool, polyglot::Store, std::string> Polyglot_context::get_member_of(
149149
const poly_value obj, const std::string &name) {
150150
auto member = get_member(thread(), obj, name);
151-
auto type = to_string(thread(), type_info(member));
152-
if (shcore::str_beginswith(type, "m.")) {
153-
type = type.substr(2);
151+
if (member) {
152+
auto type = to_string(thread(), type_info(member));
153+
if (shcore::str_beginswith(type, "m.")) {
154+
type = type.substr(2);
155+
}
156+
157+
return {is_executable(thread(), member), Store(thread(), member),
158+
std::move(type)};
154159
}
155160

156-
return {is_executable(thread(), member), Store(thread(), member),
157-
std::move(type)};
161+
return {false, Store(nullptr), ""};
158162
}
159163

160164
std::vector<std::pair<bool, std::string>> Polyglot_context::get_members_of(

unittest/completion_frontend_t.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2024, Oracle and/or its affiliates.
2+
* Copyright (c) 2017, 2025, Oracle and/or its affiliates.
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License, version 2.0,
@@ -2422,4 +2422,9 @@ TEST_F(Completer_frontend, bug_34365581) {
24222422
execute("DROP SCHEMA ogÓrek;");
24232423
}
24242424

2425+
TEST_F(Completer_frontend, bug_37528585) {
2426+
execute("\\js");
2427+
EXPECT_NO_THROW(complete("shell.unexisting."));
2428+
}
2429+
24252430
} // namespace mysqlsh

0 commit comments

Comments
 (0)