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