feat: first parser and ast generation
This commit is contained in:
parent
47f3f74a8f
commit
48b5411ba9
|
@ -168,6 +168,7 @@ typedef struct SColumnDefNode {
|
|||
SDataType dataType;
|
||||
char comments[TSDB_TB_COMMENT_LEN];
|
||||
bool sma;
|
||||
bool isPK;
|
||||
} SColumnDefNode;
|
||||
|
||||
typedef struct SCreateTableStmt {
|
||||
|
|
|
@ -171,7 +171,7 @@ SNode* createCompactStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode* pStart
|
|||
SNode* createDefaultTableOptions(SAstCreateContext* pCxt);
|
||||
SNode* createAlterTableOptions(SAstCreateContext* pCxt);
|
||||
SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, void* pVal);
|
||||
SNode* createColumnDefNode(SAstCreateContext* pCxt, SToken* pColName, SDataType dataType, const SToken* pComment);
|
||||
SNode* createColumnDefNode(SAstCreateContext* pCxt, SToken* pColName, SDataType dataType, const SToken* pComment, bool bPrimaryKey);
|
||||
SNode* createCreateTableStmt(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNodeList* pCols,
|
||||
SNodeList* pTags, SNode* pOptions);
|
||||
SNode* createCreateSubTableClause(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNode* pUseRealTable,
|
||||
|
|
|
@ -381,7 +381,8 @@ full_table_name(A) ::= db_name(B) NK_DOT table_name(C).
|
|||
column_def_list(A) ::= column_def(B). { A = createNodeList(pCxt, B); }
|
||||
column_def_list(A) ::= column_def_list(B) NK_COMMA column_def(C). { A = addNodeToList(pCxt, B, C); }
|
||||
|
||||
column_def(A) ::= column_name(B) type_name(C). { A = createColumnDefNode(pCxt, &B, C, NULL); }
|
||||
column_def(A) ::= column_name(B) type_name(C). { A = createColumnDefNode(pCxt, &B, C, NULL, false); }
|
||||
column_def(A) ::= column_name(B) type_name(C) PRIMARY KEY. { A = createColumnDefNode(pCxt, &B, C, NULL, true); }
|
||||
//column_def(A) ::= column_name(B) type_name(C) COMMENT NK_STRING(D). { A = createColumnDefNode(pCxt, &B, C, &D); }
|
||||
|
||||
%type type_name { SDataType }
|
||||
|
|
|
@ -1462,7 +1462,7 @@ SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType
|
|||
return pOptions;
|
||||
}
|
||||
|
||||
SNode* createColumnDefNode(SAstCreateContext* pCxt, SToken* pColName, SDataType dataType, const SToken* pComment) {
|
||||
SNode* createColumnDefNode(SAstCreateContext* pCxt, SToken* pColName, SDataType dataType, const SToken* pComment, bool bPrimaryKey) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
if (!checkColumnName(pCxt, pColName) || !checkComment(pCxt, pComment, false)) {
|
||||
return NULL;
|
||||
|
@ -1479,6 +1479,7 @@ SNode* createColumnDefNode(SAstCreateContext* pCxt, SToken* pColName, SDataType
|
|||
trimString(pComment->z, pComment->n, pCol->comments, sizeof(pCol->comments));
|
||||
}
|
||||
pCol->sma = true;
|
||||
pCol->isPK = bPrimaryKey;
|
||||
return (SNode*)pCol;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue