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

feat: auto tab add create function

上级 d4c63827
......@@ -92,7 +92,7 @@ SWords shellCommands[] = {
{"create qnode on dnode <dnode_id> ;", 0, 0, NULL},
{"create stream <anyword> into <anyword> as select", 0, 0, NULL}, // 26 append sub sql
{"create topic <anyword> as select", 0, 0, NULL}, // 27 append sub sql
{"create function ", 0, 0, NULL},
{"create function <anyword> as <anyword> outputtype <data_types> language <language>", 0, 0, NULL},
{"create user <anyword> pass <anyword> sysinfo 0;", 0, 0, NULL},
{"create user <anyword> pass <anyword> sysinfo 1;", 0, 0, NULL},
{"describe <all_table>", 0, 0, NULL},
......@@ -105,7 +105,7 @@ SWords shellCommands[] = {
{"drop qnode on dnode <dnode_id> ;", 0, 0, NULL},
{"drop user <user_name> ;", 0, 0, NULL},
// 40
{"drop function", 0, 0, NULL},
{"drop function <udf_name> ;", 0, 0, NULL},
{"drop consumer group <anyword> on ", 0, 0, NULL},
{"drop topic <topic_name> ;", 0, 0, NULL},
{"drop stream <stream_name> ;", 0, 0, NULL},
......@@ -272,6 +272,8 @@ char* key_systable[] = {
"ins_subscriptions", "ins_streams", "ins_stream_tasks", "ins_vnodes", "ins_user_privileges", "perf_connections",
"perf_queries", "perf_consumers", "perf_trans", "perf_apps"};
char* language[] = {"\'Python\'", "\'C\'"}
//
// ------- global variant define ---------
//
......@@ -291,25 +293,29 @@ bool waitAutoFill = false;
#define WT_VAR_USERNAME 4
#define WT_VAR_TOPIC 5
#define WT_VAR_STREAM 6
#define WT_VAR_ALLTABLE 7
#define WT_VAR_FUNC 8
#define WT_VAR_KEYWORD 9
#define WT_VAR_TBACTION 10
#define WT_VAR_DBOPTION 11
#define WT_VAR_ALTER_DBOPTION 12
#define WT_VAR_DATATYPE 13
#define WT_VAR_KEYTAGS 14
#define WT_VAR_ANYWORD 15
#define WT_VAR_TBOPTION 16
#define WT_VAR_USERACTION 17
#define WT_VAR_KEYSELECT 18
#define WT_VAR_SYSTABLE 19
#define WT_VAR_CNT 20
#define WT_FROM_DB_MAX 6 // max get content from db
#define WT_VAR_UDFNAME 7
#define WT_FROM_DB_MAX 7 // max get content from db
#define WT_FROM_DB_CNT (WT_FROM_DB_MAX + 1)
#define WT_VAR_ALLTABLE 8
#define WT_VAR_FUNC 9
#define WT_VAR_KEYWORD 10
#define WT_VAR_TBACTION 11
#define WT_VAR_DBOPTION 12
#define WT_VAR_ALTER_DBOPTION 13
#define WT_VAR_DATATYPE 14
#define WT_VAR_KEYTAGS 15
#define WT_VAR_ANYWORD 16
#define WT_VAR_TBOPTION 17
#define WT_VAR_USERACTION 18
#define WT_VAR_KEYSELECT 19
#define WT_VAR_SYSTABLE 20
#define WT_VAR_LANGUAGE 21
#define WT_VAR_CNT 22
#define WT_TEXT 0xFF
char dbName[256] = ""; // save use database name;
......@@ -319,13 +325,13 @@ TdThreadMutex tiresMutex;
// save thread handle obtain var name from db server
TdThread* threads[WT_FROM_DB_CNT];
// obtain var name with sql from server
char varTypes[WT_VAR_CNT][64] = {"<db_name>", "<stb_name>", "<tb_name>", "<dnode_id>", "<user_name>",
"<topic_name>", "<stream_name>", "<all_table>", "<function>", "<keyword>",
"<tb_actions>", "<db_options>", "<alter_db_options>", "<data_types>", "<key_tags>",
"<anyword>", "<tb_options>", "<user_actions>", "<key_select>"};
char varTypes[WT_VAR_CNT][64] = {
"<db_name>", "<stb_name>", "<tb_name>", "<dnode_id >", "<user_name>", "<topic_name>", "<stream_name>",
"<udf_name>", "<all_table>", "<function>", "<keyword>", "<tb_actions>", "<db_options>", "<alter_db_options>",
"<data_types>", "<key_tags>", "<anyword>", "<tb_options>", "<user_actions>", "<key_select>", "sys_table", "language"};
char varSqls[WT_FROM_DB_CNT][64] = {"show databases;", "show stables;", "show tables;", "show dnodes;",
"show users;", "show topics;", "show streams;"};
"show users;", "show topics;", "show streams;", "show functions;"};
// var words current cursor, if user press any one key except tab, cursorVar can be reset to -1
int cursorVar = -1;
......@@ -390,7 +396,7 @@ void showHelp() {
create qnode on dnode <dnode_id> ;\n\
create stream <stream_name> into <stb_name> as select ...\n\
create topic <topic_name> as select ...\n\
create function ...\n\
create function <udf_name> as <file_name> outputtype <data_types> language \'C\' | \'Python\' ;\n\
create user <user_name> pass <password> ...\n\
----- D ----- \n\
describe <all_table>\n\
......@@ -401,7 +407,7 @@ void showHelp() {
drop mnode on dnode <dnode_id> ;\n\
drop qnode on dnode <dnode_id> ;\n\
drop user <user_name> ;\n\
drop function <function_name>;\n\
drop function <udf_name>;\n\
drop consumer group ... \n\
drop topic <topic_name> ;\n\
drop stream <stream_name> ;\n\
......@@ -643,6 +649,7 @@ bool shellAutoInit() {
GenerateVarType(WT_VAR_USERACTION, user_actions, sizeof(user_actions) / sizeof(char*));
GenerateVarType(WT_VAR_KEYSELECT, key_select, sizeof(key_select) / sizeof(char*));
GenerateVarType(WT_VAR_SYSTABLE, key_systable, sizeof(key_systable) / sizeof(char*));
GenerateVarType(WT_VAR_LANGUAGE, key_systable, sizeof(language) / sizeof(char*));
return true;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册