Skip to content

Commit

Permalink
minor code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
aziz-mu committed Nov 15, 2022
1 parent 18f4943 commit bbfe0fe
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tools/shell/embedded_shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ EmbeddedShell::EmbeddedShell(

void EmbeddedShell::run() {
char* line;
string query;
stringstream ss;
while ((line = linenoise(continueLine ? ALTPROMPT : PROMPT)) != nullptr) {
auto lineStr = string(line);
if (continueLine) {
Expand Down Expand Up @@ -207,14 +209,14 @@ void EmbeddedShell::run() {
} else if (lineStr.rfind(shellCommand.SHOW_REL) == 0) {
printRelSchema(lineStr.substr(shellCommand.SHOW_REL.length()));
} else if (!lineStr.empty()) {
stringstream ss(lineStr);
string thisQuery;
while (getline(ss, thisQuery, ';')) {
ss.clear();
ss.str(lineStr);
while (getline(ss, query, ';')) {
if (ss.eof() && ss.peek() == -1) {
continueLine = true;
currLine += thisQuery + " ";
currLine += query + " ";
} else {
auto queryResult = conn->query(thisQuery);
auto queryResult = conn->query(query);
if (queryResult->isSuccess()) {
printExecutionResult(*queryResult);
} else {
Expand Down

0 comments on commit bbfe0fe

Please sign in to comment.