fix bug
This commit is contained in:
parent
29408010b0
commit
fce7a9d299
|
@ -381,6 +381,7 @@ void tscQueueAsyncError(void(*fp), void *param, int32_t code) {
|
|||
taosScheduleTask(tscQhandle, &schedMsg);
|
||||
}
|
||||
|
||||
|
||||
void tscQueueAsyncRes(SSqlObj *pSql) {
|
||||
if (pSql == NULL || pSql->signature != pSql) {
|
||||
tscDebug("%p SqlObj is freed, not add into queue async res", pSql);
|
||||
|
@ -390,7 +391,10 @@ void tscQueueAsyncRes(SSqlObj *pSql) {
|
|||
tscError("%p add into queued async res, code:%s", pSql, tstrerror(pSql->res.code));
|
||||
|
||||
SSqlRes *pRes = &pSql->res;
|
||||
assert(pSql->fp != NULL && pSql->fetchFp != NULL);
|
||||
|
||||
if (pSql->fp == NULL || pSql->fetchFp == NULL){
|
||||
return;
|
||||
}
|
||||
|
||||
pSql->fp = pSql->fetchFp;
|
||||
(*pSql->fp)(pSql->param, pSql, pRes->code);
|
||||
|
|
|
@ -86,6 +86,6 @@ extern void set_terminal_mode();
|
|||
extern int get_old_terminal_mode(struct termios* tio);
|
||||
extern void reset_terminal_mode();
|
||||
extern SShellArguments args;
|
||||
extern TAOS_RES* result;
|
||||
extern int64_t result;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -46,7 +46,7 @@ char CONTINUE_PROMPT[] = " -> ";
|
|||
int prompt_size = 6;
|
||||
#endif
|
||||
|
||||
TAOS_RES *result = NULL;
|
||||
int64_t result = 0;
|
||||
SShellHistory history;
|
||||
|
||||
#define DEFAULT_MAX_BINARY_DISPLAY_WIDTH 30
|
||||
|
@ -294,17 +294,20 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
|
|||
|
||||
st = taosGetTimestampUs();
|
||||
|
||||
TAOS_RES* pSql = taos_query_h(con, command, &result);
|
||||
TAOS_RES* tmpSql = NULL;
|
||||
TAOS_RES* pSql = taos_query_h(con, command, &tmpSql);
|
||||
if (taos_errno(pSql)) {
|
||||
taos_error(pSql, st);
|
||||
return;
|
||||
}
|
||||
|
||||
result = ((SSqlObj*)tmpSql)->self;
|
||||
|
||||
if (regex_match(command, "^\\s*use\\s+[a-zA-Z0-9_]+\\s*;\\s*$", REG_EXTENDED | REG_ICASE)) {
|
||||
fprintf(stdout, "Database changed.\n\n");
|
||||
fflush(stdout);
|
||||
|
||||
atomic_store_ptr(&result, 0);
|
||||
atomic_store_64(&result, 0);
|
||||
taos_free_result(pSql);
|
||||
return;
|
||||
}
|
||||
|
@ -313,7 +316,7 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
|
|||
int error_no = 0;
|
||||
int numOfRows = shellDumpResult(pSql, fname, &error_no, printMode);
|
||||
if (numOfRows < 0) {
|
||||
atomic_store_ptr(&result, 0);
|
||||
atomic_store_64(&result, 0);
|
||||
taos_free_result(pSql);
|
||||
return;
|
||||
}
|
||||
|
@ -336,7 +339,7 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
|
|||
wordfree(&full_path);
|
||||
}
|
||||
|
||||
atomic_store_ptr(&result, 0);
|
||||
atomic_store_64(&result, 0);
|
||||
taos_free_result(pSql);
|
||||
}
|
||||
|
||||
|
@ -501,7 +504,7 @@ static int dumpResultToFile(const char* fname, TAOS_RES* tres) {
|
|||
row = taos_fetch_row(tres);
|
||||
} while( row != NULL);
|
||||
|
||||
result = NULL;
|
||||
result = 0;
|
||||
fclose(fp);
|
||||
|
||||
return numOfRows;
|
||||
|
|
|
@ -22,8 +22,10 @@ pthread_t pid;
|
|||
|
||||
void shellQueryInterruptHandler(int signum) {
|
||||
#ifdef LINUX
|
||||
void* pResHandle = atomic_val_compare_exchange_64(&result, result, 0);
|
||||
taos_stop_query(pResHandle);
|
||||
int64_t rid = atomic_val_compare_exchange_64(&result, result, 0);
|
||||
SSqlObj* pSql = taosAcquireRef(tscObjRef, rid);
|
||||
taos_stop_query(pSql);
|
||||
taosReleaseRef(tscObjRef, rid);
|
||||
#else
|
||||
printf("\nReceive ctrl+c or other signal, quit shell.\n");
|
||||
exit(0);
|
||||
|
|
Loading…
Reference in New Issue