提交 cd46ca0f 编写于 作者: A Alex Duan

fix(shell): add help command and fix crete table filed complete include binary

上级 f58396ea
......@@ -39,4 +39,7 @@ void callbackAutoTab(char* sqlstr, TAOS* pSql, bool usedb);
// introduction
void printfIntroduction();
// show all commands help
void showHelp();
#endif
......@@ -108,6 +108,7 @@ SWords shellCommands[] = {
{"drop topic <topic_name> ;", 0, 0, NULL},
{"drop stream <stream_name> ;", 0, 0, NULL},
{"explain select", 0, 0, NULL}, // 44 append sub sql
{"help;", 0, 0, NULL},
{"grant all on <anyword> to <user_name> ;", 0, 0, NULL},
{"grant read on <anyword> to <user_name> ;", 0, 0, NULL},
{"grant write on <anyword> to <user_name> ;", 0, 0, NULL},
......@@ -386,6 +387,8 @@ void showHelp() {
drop stream <stream_name> ;\n\
----- E ----- \n\
explain select clause ...\n\
----- H ----- \n\
help;\n\
----- I ----- \n\
insert into <tb_name> values(...) ;\n\
insert into <tb_name> using <stb_name> tags(...) values(...) ;\n\
......@@ -1478,24 +1481,36 @@ bool matchSelectQuery(TAOS* con, SShellCmd* cmd) {
// if is input create fields or tags area, return true
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) {
// like 'create table st'
return false;
ret = false;
break;
}
char* right = strrchr(p, ')');
char* right = strrchr(p1, ')');
if (right == NULL) {
// like 'create table st( '
return true;
ret = true;
break;
}
if (left > right) {
// 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;
}
taosMemoryFree(p1);
return ret;
}
bool matchCreateTable(TAOS* con, SShellCmd* cmd) {
......
......@@ -134,6 +134,12 @@ int32_t shellRunCommand(char *command, bool recordHistory) {
return 0;
}
// add help or help;
if(strcmp(command, "help") == 0 || strcmp(command, "help;") == 0) {
showHelp();
return 0;
}
if (recordHistory) shellRecordCommandToHistory(command);
char quote = 0, *cmd = command;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册