提交 2f32b3a2 编写于 作者: A Alex Duan

fix: need not obtain db name if input argument include -s

上级 ca5dfb28
......@@ -332,6 +332,7 @@ bool varMode = false; // enter var names list mode
TAOS* varCon = NULL;
SShellCmd* varCmd = NULL;
bool varRunOnce = false;
SMatch* lastMatch = NULL; // save last match result
int cntDel = 0; // delete byte count after next press tab
......@@ -637,10 +638,11 @@ bool shellAutoInit() {
}
// set conn
void shellSetConn(TAOS* conn) {
varCon = conn;
void shellSetConn(TAOS* conn, bool runOnce) {
varCon = conn;
varRunOnce = runOnce;
// init database and stable
updateTireValue(WT_VAR_DBNAME, false);
if (!runOnce) updateTireValue(WT_VAR_DBNAME, false);
}
// exit shell auto funciton, shell exit call once
......@@ -784,6 +786,12 @@ int writeVarNames(int type, TAOS_RES* tres) {
return numOfRows;
}
void setThreadNull(int type) {
taosThreadMutexLock(&tiresMutex);
threads[type] = NULL;
taosThreadMutexUnlock(&tiresMutex);
}
bool firstMatchCommand(TAOS* con, SShellCmd* cmd);
//
// thread obtain var thread from db server
......@@ -799,6 +807,7 @@ void* varObtainThread(void* param) {
TAOS_RES* pSql = taos_query(varCon, varSqls[type]);
if (taos_errno(pSql)) {
taos_free_result(pSql);
setThreadNull(type);
return NULL;
}
......@@ -814,6 +823,7 @@ void* varObtainThread(void* param) {
firstMatchCommand(varCon, varCmd);
}
setThreadNull(type);
return NULL;
}
......@@ -1977,7 +1987,7 @@ void callbackAutoTab(char* sqlstr, TAOS* pSql, bool usedb) {
if (dealUseDB(sql)) {
// change to new db
updateTireValue(WT_VAR_STABLE, false);
if (varRunOnce) updateTireValue(WT_VAR_STABLE, false);
return;
}
......
......@@ -1097,10 +1097,11 @@ int32_t shellExecute() {
}
#endif
shellSetConn(shell.conn);
bool runOnce = pArgs->commands != NULL || pArgs->file[0] != 0;
shellSetConn(shell.conn, runOnce);
shellReadHistory();
if (pArgs->commands != NULL || pArgs->file[0] != 0) {
if (runOnce) {
if (pArgs->commands != NULL) {
printf("%s%s\r\n", shell.info.promptHeader, pArgs->commands);
char *cmd = strdup(pArgs->commands);
......@@ -1116,6 +1117,7 @@ int32_t shellExecute() {
ws_close(shell.ws_conn);
} else {
#endif
taos_kill_query(shell.conn);
taos_close(shell.conn);
#ifdef WEBSOCKET
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册