提交 5d022462 编写于 作者: K kailixu

Merge branch '2.6' into feat/TS-1883-2.6

...@@ -33,5 +33,7 @@ void shellAutoExit(); ...@@ -33,5 +33,7 @@ void shellAutoExit();
// callback autotab module // callback autotab module
void callbackAutoTab(char* sqlstr, TAOS* pSql, bool usedb); void callbackAutoTab(char* sqlstr, TAOS* pSql, bool usedb);
// show all commands help
void showHelp();
#endif #endif
...@@ -1438,25 +1438,37 @@ bool matchSelectQuery(TAOS * con, Command * cmd) { ...@@ -1438,25 +1438,37 @@ bool matchSelectQuery(TAOS * con, Command * cmd) {
} }
// if is input create fields or tags area, return true // if is input create fields or tags area, return true
bool isCreateFieldsArea(char * p) { bool isCreateFieldsArea(char* p) {
char * left = strrchr(p, '('); // put to while, support like create table st(ts timestamp, bin1 binary(16), bin2 + blank + TAB
char* p1 = strdup(p);
bool ret = false;
while (1) {
char* left = strrchr(p1, '(');
if (left == NULL) { if (left == NULL) {
// like 'create table st' // like 'create table st'
return false; ret = false;
break;
} }
char * right = strrchr(p, ')'); char* right = strrchr(p1, ')');
if(right == NULL) { if (right == NULL) {
// like 'create table st( ' // like 'create table st( '
return true; ret = true;
break;
} }
if (left > right) { if (left > right) {
// like 'create table st( ts timestamp, age int) tags(area ' // like 'create table st( ts timestamp, age int) tags(area '
return true; ret = true;
break;
} }
return false; // set string end by small for next strrchr search
*left = 0;
}
free(p1);
return ret;
} }
bool matchCreateTable(TAOS * con, Command * cmd) { bool matchCreateTable(TAOS * con, Command * cmd) {
......
...@@ -216,6 +216,14 @@ int32_t shellRunCommand(TAOS* con, char* command) { ...@@ -216,6 +216,14 @@ int32_t shellRunCommand(TAOS* con, char* command) {
return 0; return 0;
} }
// add help or help;
#ifndef WINDOWS
if (strcmp(command, "help") == 0 || strcmp(command, "help;") == 0) {
showHelp();
return 0;
}
#endif
/* Update the history vector. */ /* Update the history vector. */
if (history.hstart == history.hend || if (history.hstart == history.hend ||
history.hist[(history.hend + MAX_HISTORY_SIZE - 1) % MAX_HISTORY_SIZE] == NULL || history.hist[(history.hend + MAX_HISTORY_SIZE - 1) % MAX_HISTORY_SIZE] == NULL ||
...@@ -377,7 +385,7 @@ void shellRunCommandOnServer(TAOS *con, char command[]) { ...@@ -377,7 +385,7 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
} else { } else {
int num_rows_affacted = taos_affected_rows(pSql); int num_rows_affacted = taos_affected_rows(pSql);
et = taosGetTimestampUs(); et = taosGetTimestampUs();
printf("Query OK, %d row(s) affected(%.6fs)\n", num_rows_affacted, (et - st) / 1E6); printf("Query OK, %d row(s) affected (%.6fs)\n", num_rows_affacted, (et - st) / 1E6);
#ifndef WINDOWS #ifndef WINDOWS
// call auto tab // call auto tab
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册