diff --git a/src/kit/shell/src/shellAuto.c b/src/kit/shell/src/shellAuto.c index 8b695663290f91ec42bf11157786ba1fd2c8a965..916ce1fa494e41d7c0b22a3c59ad279d4706181b 100644 --- a/src/kit/shell/src/shellAuto.c +++ b/src/kit/shell/src/shellAuto.c @@ -83,11 +83,11 @@ SWords shellCommands[] = { {"delete from where", 0, 0, NULL}, #endif {"drop database ", 0, 0, NULL}, + {"drop table ", 0, 0, NULL}, {"drop dnode ", 0, 0, NULL}, + {"drop user ;", 0, 0, NULL}, {"drop function", 0, 0, NULL}, {"drop topic", 0, 0, NULL}, - {"drop table ;", 0, 0, NULL}, - {"drop user ;", 0, 0, NULL}, {"kill connection", 0, 0, NULL}, {"kill query", 0, 0, NULL}, {"kill stream", 0, 0, NULL}, @@ -366,10 +366,10 @@ void showHelp() { describe ;\n\ delete from where ... \n\ drop database ;\n\ + drop table ;\n\ drop dnode ;\n\ drop function ;\n\ drop topic ;\n\ - drop table ;\n\ drop user ;\n\ ----- K ----- \n\ kill connection ; \n\ @@ -1087,12 +1087,14 @@ bool firstMatchCommand(TAOS * con, Command * cmd) { if (match == NULL) { // not match , nothing to do freeCommand(input); + free(input); return false; } // print to screen printScreen(con, cmd, match); freeCommand(input); + free(input); return true; } @@ -1145,6 +1147,9 @@ bool nextMatchCommand(TAOS * con, Command * cmd, SWords * firstMatch) { match = matchCommand(input, false); if (match == NULL) { freeCommand(input); + if (input->source) + free(input->source); + free(input); return false; } } @@ -1158,6 +1163,7 @@ bool nextMatchCommand(TAOS * con, Command * cmd, SWords * firstMatch) { input->source = NULL; } freeCommand(input); + free(input); return true; } @@ -1247,22 +1253,20 @@ bool fieldsInputEnd(char* sql) { } // not in ',' - char * p = strrchr(sql, ','); + char * p3 = strrchr(sql, ','); + char * p = p3; // like select ts, age,' ' if (p) { ++p; - bool allBlank = true; - int cnt = 0; // blank count , continue many blank is one blank - char * plast = NULL; + bool allBlank = true; // after last ',' all char is blank + int cnt = 0; // blank count , like ' ' as one blank + char * plast = NULL; // last blank position while(*p) { - if (*p != ' ') { - allBlank = false; - plast = NULL; + if (*p == ' ') { + plast = p; + cnt ++; } else { - if(plast == NULL) { - plast = p; - cnt ++; - } + allBlank = false; } ++p; } @@ -1272,14 +1276,19 @@ bool fieldsInputEnd(char* sql) { return false; } - // if last char not ' ', then not end field, like select count(*), su + tab can fill sum( + // like 'select count(*),sum(age) fr' need return true + if (plast && plast > p3 && p2 > p1 && plast > p2 && p1 > p3) { + return true; + } + + // if last char not ' ', then not end field, like 'select count(*), su' can fill sum( if(sql[strlen(sql)-1] != ' ' && cnt <= 1) { return false; } } - char * p3 = strrchr(sql, ' '); - if(p3 == NULL) { + char * p4 = strrchr(sql, ' '); + if(p4 == NULL) { // only one word return false; } diff --git a/src/kit/shell/src/tire.c b/src/kit/shell/src/tire.c index 1ea27f5b9b7e0ffa65aa8ec6fcb1928cf89ffab4..b4dc7976bd53f11cccbac2f5db600edeeee861d5 100644 --- a/src/kit/shell/src/tire.c +++ b/src/kit/shell/src/tire.c @@ -58,13 +58,14 @@ void freeTire(STire* tire) { // free from list StrName * item = tire->head; while (item) { + StrName * next = item->next; // free string tfree(item->name); // free node tfree(item); // move next - item = item->next; + item = next; } tire->head = tire->tail = NULL;