未验证 提交 29df9d60 编写于 作者: D dapan1121 提交者: GitHub

Merge pull request #19987 from taosdata/fix/TD-22454-MAIN

fix:  exit call kill query and not to obtain dbname if have -s argument
...@@ -28,7 +28,7 @@ void pressOtherKey(char c); ...@@ -28,7 +28,7 @@ void pressOtherKey(char c);
bool shellAutoInit(); bool shellAutoInit();
// set conn // set conn
void shellSetConn(TAOS* conn); void shellSetConn(TAOS* conn, bool runOnce);
// exit shell auto funciton, shell exit call once // exit shell auto funciton, shell exit call once
void shellAutoExit(); void shellAutoExit();
......
...@@ -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
...@@ -375,7 +376,7 @@ void showHelp() { ...@@ -375,7 +376,7 @@ void showHelp() {
----- C ----- \n\ ----- C ----- \n\
create table <tb_name> using <stb_name> tags ...\n\ create table <tb_name> using <stb_name> tags ...\n\
create database <db_name> <db_options> ...\n\ create database <db_name> <db_options> ...\n\
create dnode \"fqdn:port\"n\ create dnode \"fqdn:port\" ...\n\
create index ...\n\ create index ...\n\
create mnode on dnode <dnode_id> ;\n\ create mnode on dnode <dnode_id> ;\n\
create qnode on dnode <dnode_id> ;\n\ create qnode on dnode <dnode_id> ;\n\
...@@ -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);
...@@ -1160,5 +1161,8 @@ int32_t shellExecute() { ...@@ -1160,5 +1161,8 @@ int32_t shellExecute() {
taosThreadJoin(spid, NULL); taosThreadJoin(spid, NULL);
shellCleanupHistory(); shellCleanupHistory();
taos_kill_query(shell.conn);
taos_close(shell.conn);
return 0; return 0;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册