Skip to content

Commit

Permalink
Fixed shell incorrect command seg fault (kuzudb#3173)
Browse files Browse the repository at this point in the history
I have read and agree to the CLA of the Kuzu repository.
  • Loading branch information
MSebanc authored Mar 29, 2024
1 parent 20e5cbb commit cf71770
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
7 changes: 1 addition & 6 deletions tools/shell/embedded_shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@

#include "common/task_system/progress_bar.h"

// TODO: REMOVE
#ifdef _WIN32
#include <windows.h>
#endif

using namespace kuzu::common;
using namespace kuzu::utf8proc;

Expand All @@ -51,7 +46,7 @@ struct ShellCommand {
const char* QUIT = ":quit";
const char* MAX_ROWS = ":max_rows";
const char* MAX_WIDTH = ":max_width";
const std::array<const char*, 6> commandList = {HELP, CLEAR, QUIT, MAX_ROWS, MAX_WIDTH};
const std::array<const char*, 5> commandList = {HELP, CLEAR, QUIT, MAX_ROWS, MAX_WIDTH};
} shellCommand;

const char* TAB = " ";
Expand Down
25 changes: 13 additions & 12 deletions tools/shell/test/test_shell_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,16 @@ def test_max_width(temp_db, csv_path) -> None:
result.check_not_stdout("| ... |")
result.check_stdout("(1 column)")

def test_bad_command(temp_db) -> None:
test = ShellTest().add_argument(temp_db).statement(":maxrows").statement(":quiy").statement("clearr;")
result = test.run()
result.check_stdout(
'Error: Unknown command: ":maxrows". Enter ":help" for help',
)
result.check_stdout('Did you mean: ":max_rows"?')
result.check_stdout('Error: Unknown command: ":quiy". Enter ":help" for help')
result.check_stdout('Did you mean: ":quit"?')
result.check_stdout(
'Error: "clearr;" is not a valid Cypher query. Did you mean to issue a CLI command, e.g., ":clear"?',
)

def test_bad_command(temp_db) -> None:
test = ShellTest().add_argument(temp_db).statement(":maxrows").statement(":quiy").statement("clearr;")
result = test.run()
result.check_stdout(
'Error: Unknown command: ":maxrows". Enter ":help" for help',
)
result.check_stdout('Did you mean: ":max_rows"?')
result.check_stdout('Error: Unknown command: ":quiy". Enter ":help" for help')
result.check_stdout('Did you mean: ":quit"?')
result.check_stdout(
'Error: "clearr;" is not a valid Cypher query. Did you mean to issue a CLI command, e.g., ":clear"?',
)

0 comments on commit cf71770

Please sign in to comment.