fix: continue coding

This commit is contained in:
shenglian zhou 2023-09-19 14:03:06 +08:00
parent 94a616fcc1
commit 2773f1e9ac
7 changed files with 29 additions and 20 deletions

View File

@ -273,7 +273,7 @@ typedef struct SShowStmt {
SNode* pDbName; // SValueNode
SNode* pTbName; // SValueNode
EOperatorType tableCondType;
SValueNode* pKind; // show databases: user/system, show tables: normal/child, others NULL
EShowKind showKind; // show databases: user/system, show tables: normal/child, others NULL
} SShowStmt;
typedef struct SShowCreateDatabaseStmt {

View File

@ -277,6 +277,14 @@ typedef enum ETimeLineMode {
TIME_LINE_GLOBAL,
} ETimeLineMode;
typedef enum EShowKind {
SHOW_KIND_NONE = 1,
SHOW_KIND_TABLES_NORMAL,
SHOW_KIND_TABLES_CHILD,
SHOW_KIND_DATABASES_USER,
SHOW_KIND_DATABASES_SYSTEM
} EShowKind;
typedef struct SFillNode {
ENodeType type; // QUERY_NODE_FILL
EFillMode mode;

View File

@ -181,7 +181,7 @@ SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int
SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, SToken* pTagName, SNode* pVal);
SNode* setAlterSuperTableType(SNode* pStmt);
SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName);
SNode* setShowKind(SAstCreateContext* pCxt, SNode* pStmt, SNode* pKind);
SNode* setShowKind(SAstCreateContext* pCxt, SNode* pStmt, EShowKind showKind);
SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type);
SNode* createShowStmtWithCond(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, SNode* pTbName,
EOperatorType tableCondType);

View File

@ -530,11 +530,15 @@ tag_item(A) ::= column_name(B).
tag_item(A) ::= column_name(B) column_alias(C). { A = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &B), &C); }
tag_item(A) ::= column_name(B) AS column_alias(C). { A = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &B), &C); }
db_kind_opt(A) ::= . { A = NULL; }
db_kind_opt(A) ::= NK_STRING(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); }
%type db_kind_opt { EShowKind }
%destructor db_kind_opt { }
db_kind_opt(A) ::= . { A = SHOW_KIND_NONE; }
db_kind_opt(A) ::= USER. { A = SHOW_KIND_DATABASES_USER; }
db_kind_opt(A) ::= SYSTEM. { A = SHOW_KIND_DATABASES_SYSTEM; }
table_kind_opt(A) ::= . { A = NULL; }
table_kind_opt(A) ::= NK_STRING(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); }
table_kind_opt(A) ::= . { A = SHOW_KIND_NONE; }
table_kind_opt(A) ::= NORMAL. { A = SHOW_KIND_TABLES_NORMAL; }
table_kind_opt(A) ::= CHILD. { A = SHOW_KIND_TABLES_CHILD; }
/************************************************ create index ********************************************************/
cmd ::= CREATE SMA INDEX not_exists_opt(D)
col_name(A) ON full_table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, A, B, NULL, C); }

View File

@ -1552,15 +1552,9 @@ SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type) {
return (SNode*)pStmt;
}
SNode* setShowKind(SAstCreateContext* pCxt, SNode* pStmt, SNode* pKind) {
//TODO: check show
if ((nodeType(pStmt) == QUERY_NODE_SHOW_TABLES_STMT ||
nodeType(pStmt) == QUERY_NODE_SHOW_DATABASES_STMT) && nodeType(pKind) == QUERY_NODE_VALUE) {
SShowStmt* pShowStmt = (SShowStmt*)pStmt;
pShowStmt->pKind = (SValueNode*)pKind;
} else {
//pCxt->errCode = generateSyntaxErrMsgExt(pCxt->msgBuf, code, "shall be normal|child, user/system");
}
SNode* setShowKind(SAstCreateContext* pCxt, SNode* pStmt, EShowKind showKind) {
SShowStmt* pShow = (SShowStmt*)pStmt;
pShow->showKind = showKind;
return pStmt;
}

View File

@ -57,6 +57,7 @@ static SKeyword keywordTable[] = {
{"CACHESIZE", TK_CACHESIZE},
{"CASE", TK_CASE},
{"CAST", TK_CAST},
{"CHILD", TK_CHILD},
{"CLIENT_VERSION", TK_CLIENT_VERSION},
{"CLUSTER", TK_CLUSTER},
{"COLUMN", TK_COLUMN},
@ -149,6 +150,7 @@ static SKeyword keywordTable[] = {
{"MNODES", TK_MNODES},
{"MODIFY", TK_MODIFY},
{"MODULES", TK_MODULES},
{"NORMAL", TK_NORMAL},
{"NCHAR", TK_NCHAR},
{"NEXT", TK_NEXT},
{"NMATCH", TK_NMATCH},
@ -224,6 +226,7 @@ static SKeyword keywordTable[] = {
{"SUBSCRIPTIONS", TK_SUBSCRIPTIONS},
{"SUBTABLE", TK_SUBTABLE},
{"SYSINFO", TK_SYSINFO},
{"SYSTEM", TK_SYSTEM},
{"TABLE", TK_TABLE},
{"TABLES", TK_TABLES},
{"TABLE_PREFIX", TK_TABLE_PREFIX},

View File

@ -8079,19 +8079,19 @@ static int32_t addShowChildTablesCond(SSelectStmt* pSelect) {
static int32_t addShowKindCond(const SShowStmt* pShow, SSelectStmt* pSelect) {
if (pShow->type != QUERY_NODE_SHOW_DATABASES_STMT && pShow->type != QUERY_NODE_SHOW_TABLES_STMT ||
pShow->pKind == NULL) {
pShow->showKind == SHOW_KIND_NONE) {
return TSDB_CODE_SUCCESS;
}
if (pShow->type == QUERY_NODE_SHOW_DATABASES_STMT) {
if (strcasecmp(pShow->pKind->literal, "USER") == 0) {
if (pShow->showKind == SHOW_KIND_DATABASES_USER) {
addShowUserDatabasesCond(pSelect);
} else if (strcasecmp(pShow->pKind->literal, "SYSTEM") == 0) {
} else if (pShow->showKind == SHOW_KIND_DATABASES_SYSTEM) {
addShowSystemDatabasesCond(pSelect);
}
} else if (pShow->type == QUERY_NODE_SHOW_TABLES_STMT) {
if (strcasecmp(pShow->pKind->literal, "NORMAL") == 0) {
if (pShow->showKind == SHOW_KIND_TABLES_NORMAL) {
addShowNormalTablesCond(pSelect);
} else if (strcasecmp(pShow->pKind->literal, "CHILD") == 0) {
} else if (pShow->showKind == SHOW_KIND_TABLES_CHILD) {
addShowChildTablesCond(pSelect);
}
}