Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d351e55a
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d351e55a
编写于
3月 15, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0_query_integrate' into feature/scheduler
上级
43d79129
147f684b
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
2132 addition
and
1746 deletion
+2132
-1746
include/common/ttokendef.h
include/common/ttokendef.h
+114
-109
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+2
-1
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+9
-4
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+1
-1
source/dnode/mnode/impl/src/mndInfoSchema.c
source/dnode/mnode/impl/src/mndInfoSchema.c
+2
-1
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+3
-0
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+10
-9
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+1
-1
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+28
-15
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+4
-9
source/libs/parser/src/parTokenizer.c
source/libs/parser/src/parTokenizer.c
+5
-3
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+143
-15
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+1646
-1575
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+60
-0
source/libs/parser/test/parserAstTest.cpp
source/libs/parser/test/parserAstTest.cpp
+102
-1
source/libs/parser/test/parserInsertTest.cpp
source/libs/parser/test/parserInsertTest.cpp
+2
-2
未找到文件。
include/common/ttokendef.h
浏览文件 @
d351e55a
...
...
@@ -40,116 +40,121 @@
#define TK_ALTER 22
#define TK_PRIVILEGE 23
#define TK_DROP 24
#define TK_
SHOW
25
#define TK_
USERS
26
#define TK_
DNODE
27
#define TK_
PORT
28
#define TK_NK_I
NTEGER
29
#define TK_D
NODES
30
#define TK_
NK_ID
31
#define TK_
NK_IPTOKEN
32
#define TK_
DATABASE
33
#define TK_
DATABASES
34
#define TK_
USE
35
#define TK_
IF
36
#define TK_
NOT
37
#define TK_
EXISTS
38
#define TK_
BLOCKS
39
#define TK_
CACHE
40
#define TK_
CACHELAST
41
#define TK_
COMP
42
#define TK_
DAYS
43
#define TK_
FSYNC
44
#define TK_
MAXROWS
45
#define TK_
MINROWS
46
#define TK_
KEEP
47
#define TK_
PRECISION
48
#define TK_
QUORUM
49
#define TK_
REPLICA
50
#define TK_
TTL
51
#define TK_
WAL
52
#define TK_
VGROUPS
53
#define TK_
SINGLE_STABLE
54
#define TK_ST
REAM_MODE
55
#define TK_
TABLE
56
#define TK_
NK_LP
57
#define TK_NK_
RP
58
#define TK_
STABLE
59
#define TK_
TABLES
60
#define TK_
STABLES
61
#define TK_
USING
62
#define TK_
TAGS
63
#define TK_
NK_DOT
64
#define TK_
NK_COMMA
65
#define TK_
COMMENT
66
#define TK_
BOOL
67
#define TK_
TINYINT
68
#define TK_
SMALLINT
69
#define TK_
INT
70
#define TK_
INTEGER
71
#define TK_
BIGINT
72
#define TK_
FLOAT
73
#define TK_
DOUBLE
74
#define TK_
BINARY
75
#define TK_
TIMESTAMP
76
#define TK_
NCHAR
77
#define TK_
UNSIGNED
78
#define TK_
JSON
79
#define TK_
VARCHAR
80
#define TK_
MEDIUMBLOB
81
#define TK_
BLOB
82
#define TK_
VARBINARY
83
#define TK_
DECIMAL
84
#define TK_S
MA
85
#define TK_
DNODE
25
#define TK_
PORT
26
#define TK_
NK_INTEGER
27
#define TK_
NK_ID
28
#define TK_NK_I
PTOKEN
29
#define TK_D
ATABASE
30
#define TK_
USE
31
#define TK_
IF
32
#define TK_
NOT
33
#define TK_
EXISTS
34
#define TK_
BLOCKS
35
#define TK_
CACHE
36
#define TK_
CACHELAST
37
#define TK_
COMP
38
#define TK_
DAYS
39
#define TK_
FSYNC
40
#define TK_
MAXROWS
41
#define TK_
MINROWS
42
#define TK_
KEEP
43
#define TK_
PRECISION
44
#define TK_
QUORUM
45
#define TK_
REPLICA
46
#define TK_
TTL
47
#define TK_
WAL
48
#define TK_
VGROUPS
49
#define TK_
SINGLE_STABLE
50
#define TK_
STREAM_MODE
51
#define TK_
TABLE
52
#define TK_
NK_LP
53
#define TK_
NK_RP
54
#define TK_ST
ABLE
55
#define TK_
USING
56
#define TK_
TAGS
57
#define TK_NK_
DOT
58
#define TK_
NK_COMMA
59
#define TK_
COMMENT
60
#define TK_
BOOL
61
#define TK_
TINYINT
62
#define TK_
SMALLINT
63
#define TK_
INT
64
#define TK_
INTEGER
65
#define TK_
BIGINT
66
#define TK_
FLOAT
67
#define TK_
DOUBLE
68
#define TK_
BINARY
69
#define TK_
TIMESTAMP
70
#define TK_
NCHAR
71
#define TK_
UNSIGNED
72
#define TK_
JSON
73
#define TK_
VARCHAR
74
#define TK_
MEDIUMBLOB
75
#define TK_
BLOB
76
#define TK_
VARBINARY
77
#define TK_
DECIMAL
78
#define TK_
SMA
79
#define TK_
SHOW
80
#define TK_
DNODES
81
#define TK_
USERS
82
#define TK_
DATABASES
83
#define TK_
TABLES
84
#define TK_S
TABLES
85
#define TK_MNODES 86
#define TK_NK_FLOAT 87
#define TK_NK_BOOL 88
#define TK_NK_VARIABLE 89
#define TK_BETWEEN 90
#define TK_IS 91
#define TK_NULL 92
#define TK_NK_LT 93
#define TK_NK_GT 94
#define TK_NK_LE 95
#define TK_NK_GE 96
#define TK_NK_NE 97
#define TK_NK_EQ 98
#define TK_LIKE 99
#define TK_MATCH 100
#define TK_NMATCH 101
#define TK_IN 102
#define TK_FROM 103
#define TK_AS 104
#define TK_JOIN 105
#define TK_ON 106
#define TK_INNER 107
#define TK_SELECT 108
#define TK_DISTINCT 109
#define TK_WHERE 110
#define TK_PARTITION 111
#define TK_BY 112
#define TK_SESSION 113
#define TK_STATE_WINDOW 114
#define TK_INTERVAL 115
#define TK_SLIDING 116
#define TK_FILL 117
#define TK_VALUE 118
#define TK_NONE 119
#define TK_PREV 120
#define TK_LINEAR 121
#define TK_NEXT 122
#define TK_GROUP 123
#define TK_HAVING 124
#define TK_ORDER 125
#define TK_SLIMIT 126
#define TK_SOFFSET 127
#define TK_LIMIT 128
#define TK_OFFSET 129
#define TK_ASC 130
#define TK_DESC 131
#define TK_NULLS 132
#define TK_FIRST 133
#define TK_LAST 134
#define TK_MODULES 87
#define TK_QNODES 88
#define TK_FUNCTIONS 89
#define TK_INDEXES 90
#define TK_FROM 91
#define TK_STREAMS 92
#define TK_LIKE 93
#define TK_NK_FLOAT 94
#define TK_NK_BOOL 95
#define TK_NK_VARIABLE 96
#define TK_BETWEEN 97
#define TK_IS 98
#define TK_NULL 99
#define TK_NK_LT 100
#define TK_NK_GT 101
#define TK_NK_LE 102
#define TK_NK_GE 103
#define TK_NK_NE 104
#define TK_NK_EQ 105
#define TK_MATCH 106
#define TK_NMATCH 107
#define TK_IN 108
#define TK_AS 109
#define TK_JOIN 110
#define TK_ON 111
#define TK_INNER 112
#define TK_SELECT 113
#define TK_DISTINCT 114
#define TK_WHERE 115
#define TK_PARTITION 116
#define TK_BY 117
#define TK_SESSION 118
#define TK_STATE_WINDOW 119
#define TK_INTERVAL 120
#define TK_SLIDING 121
#define TK_FILL 122
#define TK_VALUE 123
#define TK_NONE 124
#define TK_PREV 125
#define TK_LINEAR 126
#define TK_NEXT 127
#define TK_GROUP 128
#define TK_HAVING 129
#define TK_ORDER 130
#define TK_SLIMIT 131
#define TK_SOFFSET 132
#define TK_LIMIT 133
#define TK_OFFSET 134
#define TK_ASC 135
#define TK_DESC 136
#define TK_NULLS 137
#define TK_FIRST 138
#define TK_LAST 139
#define TK_NK_SPACE 300
#define TK_NK_COMMENT 301
...
...
include/libs/nodes/cmdnodes.h
浏览文件 @
d351e55a
...
...
@@ -152,7 +152,8 @@ typedef struct SDropDnodeStmt {
typedef
struct
SShowStmt
{
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
SNode
*
pDbName
;
// SValueNode
SNode
*
pTbNamePattern
;
// SValueNode
}
SShowStmt
;
#ifdef __cplusplus
...
...
include/libs/nodes/nodes.h
浏览文件 @
d351e55a
...
...
@@ -74,25 +74,30 @@ typedef enum ENodeType {
QUERY_NODE_VNODE_MODIF_STMT
,
QUERY_NODE_CREATE_DATABASE_STMT
,
QUERY_NODE_DROP_DATABASE_STMT
,
QUERY_NODE_SHOW_DATABASES_STMT
,
// temp
QUERY_NODE_CREATE_TABLE_STMT
,
QUERY_NODE_CREATE_SUBTABLE_CLAUSE
,
QUERY_NODE_CREATE_MULTI_TABLE_STMT
,
QUERY_NODE_DROP_TABLE_CLAUSE
,
QUERY_NODE_DROP_TABLE_STMT
,
QUERY_NODE_DROP_SUPER_TABLE_STMT
,
QUERY_NODE_SHOW_TABLES_STMT
,
// temp
QUERY_NODE_SHOW_STABLES_STMT
,
QUERY_NODE_CREATE_USER_STMT
,
QUERY_NODE_ALTER_USER_STMT
,
QUERY_NODE_DROP_USER_STMT
,
QUERY_NODE_SHOW_USERS_STMT
,
QUERY_NODE_USE_DATABASE_STMT
,
QUERY_NODE_CREATE_DNODE_STMT
,
QUERY_NODE_DROP_DNODE_STMT
,
QUERY_NODE_SHOW_DATABASES_STMT
,
QUERY_NODE_SHOW_TABLES_STMT
,
QUERY_NODE_SHOW_STABLES_STMT
,
QUERY_NODE_SHOW_USERS_STMT
,
QUERY_NODE_SHOW_DNODES_STMT
,
QUERY_NODE_SHOW_VGROUPS_STMT
,
QUERY_NODE_SHOW_MNODES_STMT
,
QUERY_NODE_SHOW_MODULES_STMT
,
QUERY_NODE_SHOW_QNODES_STMT
,
QUERY_NODE_SHOW_FUNCTIONS_STMT
,
QUERY_NODE_SHOW_INDEXES_STMT
,
QUERY_NODE_SHOW_STREAMS_STMT
,
// logic plan node
QUERY_NODE_LOGIC_PLAN_SCAN
,
...
...
include/libs/nodes/plannodes.h
浏览文件 @
d351e55a
...
...
@@ -217,7 +217,7 @@ typedef struct SSubplan {
ESubplanType
subplanType
;
int32_t
msgType
;
// message type for subplan, used to denote the send message type to vnode.
int32_t
level
;
// the execution level of current subplan, starting from 0 in a top-down manner.
char
dbFName
[
TSDB_DB_FNAME_LEN
];
char
dbFName
[
TSDB_DB_FNAME_LEN
];
SQueryNodeAddr
execNode
;
// for the scan/modify subplan, the optional execution node
SQueryNodeStat
execNodeStat
;
// only for scan subplan
SNodeList
*
pChildren
;
// the datasource subplan,from which to fetch the result
...
...
source/dnode/mnode/impl/src/mndInfoSchema.c
浏览文件 @
d351e55a
...
...
@@ -64,7 +64,7 @@ static const SInfosTableSchema userFuncSchema[] = {{.name = "name", .b
{.
name
=
"precision"
,
.
bytes
=
2
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"status"
,
.
bytes
=
10
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
};
static
const
SInfosTableSchema
userIdxSchema
[]
=
{{.
name
=
"
table_database"
,
.
bytes
=
32
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
static
const
SInfosTableSchema
userIdxSchema
[]
=
{{.
name
=
"
db_name"
,
.
bytes
=
32
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"table_name"
,
.
bytes
=
192
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"index_database"
,
.
bytes
=
32
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"index_name"
,
.
bytes
=
192
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
...
...
@@ -112,6 +112,7 @@ static const SInfosTableSchema userUsersSchema[] = {{.name = "user_name", .
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
};
static
const
SInfosTableSchema
vgroupsSchema
[]
=
{{.
name
=
"vg_id"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"db_name"
,
.
bytes
=
32
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"tables"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"status"
,
.
bytes
=
10
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"onlines"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
...
...
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
d351e55a
...
...
@@ -31,6 +31,9 @@
#define COPY_CHAR_POINT_FIELD(fldname) \
do { \
if (NULL == (pSrc)->fldname) { \
break; \
} \
(pDst)->fldname = strdup((pSrc)->fldname); \
} while (0)
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
d351e55a
...
...
@@ -85,9 +85,7 @@ SNodeptr nodesMakeNode(ENodeType type) {
case
QUERY_NODE_CREATE_DATABASE_STMT
:
return
makeNode
(
type
,
sizeof
(
SCreateDatabaseStmt
));
case
QUERY_NODE_DROP_DATABASE_STMT
:
return
makeNode
(
type
,
sizeof
(
SDropDatabaseStmt
));
case
QUERY_NODE_SHOW_DATABASES_STMT
:
return
makeNode
(
type
,
sizeof
(
SShowStmt
));
return
makeNode
(
type
,
sizeof
(
SDropDatabaseStmt
));
case
QUERY_NODE_CREATE_TABLE_STMT
:
return
makeNode
(
type
,
sizeof
(
SCreateTableStmt
));
case
QUERY_NODE_CREATE_SUBTABLE_CLAUSE
:
...
...
@@ -100,27 +98,30 @@ SNodeptr nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
SDropTableStmt
));
case
QUERY_NODE_DROP_SUPER_TABLE_STMT
:
return
makeNode
(
type
,
sizeof
(
SDropSuperTableStmt
));
case
QUERY_NODE_SHOW_TABLES_STMT
:
case
QUERY_NODE_SHOW_STABLES_STMT
:
return
makeNode
(
type
,
sizeof
(
SShowStmt
));
case
QUERY_NODE_CREATE_USER_STMT
:
return
makeNode
(
type
,
sizeof
(
SCreateUserStmt
));
case
QUERY_NODE_ALTER_USER_STMT
:
return
makeNode
(
type
,
sizeof
(
SAlterUserStmt
));
case
QUERY_NODE_DROP_USER_STMT
:
return
makeNode
(
type
,
sizeof
(
SDropUserStmt
));
case
QUERY_NODE_SHOW_USERS_STMT
:
return
makeNode
(
type
,
sizeof
(
SShowStmt
));
case
QUERY_NODE_USE_DATABASE_STMT
:
return
makeNode
(
type
,
sizeof
(
SUseDatabaseStmt
));
case
QUERY_NODE_CREATE_DNODE_STMT
:
return
makeNode
(
type
,
sizeof
(
SCreateDnodeStmt
));
case
QUERY_NODE_DROP_DNODE_STMT
:
return
makeNode
(
type
,
sizeof
(
SDropDnodeStmt
));
case
QUERY_NODE_SHOW_DATABASES_STMT
:
case
QUERY_NODE_SHOW_TABLES_STMT
:
case
QUERY_NODE_SHOW_STABLES_STMT
:
case
QUERY_NODE_SHOW_USERS_STMT
:
case
QUERY_NODE_SHOW_DNODES_STMT
:
return
makeNode
(
type
,
sizeof
(
SShowStmt
));
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
case
QUERY_NODE_SHOW_MNODES_STMT
:
case
QUERY_NODE_SHOW_MODULES_STMT
:
case
QUERY_NODE_SHOW_QNODES_STMT
:
case
QUERY_NODE_SHOW_FUNCTIONS_STMT
:
case
QUERY_NODE_SHOW_INDEXES_STMT
:
case
QUERY_NODE_SHOW_STREAMS_STMT
:
return
makeNode
(
type
,
sizeof
(
SShowStmt
));
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
return
makeNode
(
type
,
sizeof
(
SScanLogicNode
));
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
d351e55a
...
...
@@ -126,7 +126,7 @@ SNode* createDropTableClause(SAstCreateContext* pCxt, bool ignoreNotExists, SNod
SNode
*
createDropTableStmt
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pTables
);
SNode
*
createDropSuperTableStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SNode
*
pRealTable
);
SNode
*
createUseDatabaseStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDbName
);
SNode
*
createShowStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
const
SToken
*
pDbName
);
SNode
*
createShowStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
SNode
*
pDbName
,
SNode
*
pTbNamePattern
);
SNode
*
createCreateUserStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pUserName
,
const
SToken
*
pPassword
);
SNode
*
createAlterUserStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pUserName
,
int8_t
alterType
,
const
SToken
*
pVal
);
SNode
*
createDropUserStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pUserName
);
...
...
source/libs/parser/inc/sql.y
浏览文件 @
d351e55a
...
...
@@ -41,19 +41,17 @@
%left NK_CONCAT.
//%right NK_BITNOT.
/************************************************ create/alter/drop
/show user
*****************************************/
/************************************************ create/alter/drop
user *****
*****************************************/
cmd ::= CREATE USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createCreateUserStmt(pCxt, &A, &B);}
cmd ::= ALTER USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PASSWD, &B);}
cmd ::= ALTER USER user_name(A) PRIVILEGE NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PRIVILEGES, &B);}
cmd ::= DROP USER user_name(A). { pCxt->pRootNode = createDropUserStmt(pCxt, &A); }
cmd ::= SHOW USERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL); }
/************************************************ create/drop
/show dnode
**********************************************/
/************************************************ create/drop
dnode *****
**********************************************/
cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL);}
cmd ::= CREATE DNODE dnode_host_name(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B);}
cmd ::= DROP DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A);}
cmd ::= DROP DNODE dnode_endpoint(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A);}
cmd ::= SHOW DNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL); }
%type dnode_endpoint { SToken }
%destructor dnode_endpoint { }
...
...
@@ -64,10 +62,9 @@ dnode_endpoint(A) ::= NK_STRING(B).
dnode_host_name(A) ::= NK_ID(B). { A = B; }
dnode_host_name(A) ::= NK_IPTOKEN(B). { A = B; }
/************************************************ create/drop/
show/use database
***************************************/
/************************************************ create/drop/
use database *****
***************************************/
cmd ::= CREATE DATABASE not_exists_opt(A) db_name(B) db_options(C). { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, A, &B, C);}
cmd ::= DROP DATABASE exists_opt(A) db_name(B). { pCxt->pRootNode = createDropDatabaseStmt(pCxt, A, &B); }
cmd ::= SHOW DATABASES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL); }
cmd ::= USE db_name(A). { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &A);}
%type not_exists_opt { bool }
...
...
@@ -101,7 +98,7 @@ db_options(A) ::= db_options(B) VGROUPS NK_INTEGER(C).
db_options(A) ::= db_options(B) SINGLE_STABLE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_SINGLESTABLE, &C); }
db_options(A) ::= db_options(B) STREAM_MODE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_STREAMMODE, &C); }
/************************************************ create/drop
/show table/stable
***************************************/
/************************************************ create/drop
table/stable *****
***************************************/
cmd ::= CREATE TABLE not_exists_opt(A) full_table_name(B)
NK_LP column_def_list(C) NK_RP tags_def_opt(D) table_options(E). { pCxt->pRootNode = createCreateTableStmt(pCxt, A, B, C, D, E);}
cmd ::= CREATE TABLE multi_create_clause(A). { pCxt->pRootNode = createCreateMultiTableStmt(pCxt, A);}
...
...
@@ -109,8 +106,6 @@ cmd ::= CREATE STABLE not_exists_opt(A) full_table_name(B)
NK_LP column_def_list(C) NK_RP tags_def(D) table_options(E). { pCxt->pRootNode = createCreateTableStmt(pCxt, A, B, C, D, E);}
cmd ::= DROP TABLE multi_drop_clause(A). { pCxt->pRootNode = createDropTableStmt(pCxt, A); }
cmd ::= DROP STABLE exists_opt(A) full_table_name(B). { pCxt->pRootNode = createDropSuperTableStmt(pCxt, A, B); }
cmd ::= SHOW TABLES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, NULL); }
cmd ::= SHOW STABLES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, NULL); }
%type multi_create_clause { SNodeList* }
%destructor multi_create_clause { nodesDestroyList($$); }
...
...
@@ -194,12 +189,30 @@ col_name_list(A) ::= col_name_list(B) NK_COMMA col_name(C).
col_name(A) ::= column_name(B). { A = createColumnNode(pCxt, NULL, &B); }
/************************************************ show vgroups ********************************************************/
cmd ::= SHOW VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, NULL); }
cmd ::= SHOW db_name(B) NK_DOT VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &B); }
/************************************************ show vgroups ********************************************************/
cmd ::= SHOW MNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT, NULL); }
/************************************************ show ****************************************************************/
cmd ::= SHOW DNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL, NULL); }
cmd ::= SHOW USERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL, NULL); }
cmd ::= SHOW DATABASES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL, NULL); }
cmd ::= SHOW db_name_cond_opt(A) TABLES like_pattern_opt(B). { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, A, B); }
cmd ::= SHOW db_name_cond_opt(A) STABLES like_pattern_opt(B). { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, A, B); }
cmd ::= SHOW db_name_cond_opt(A) VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, A, NULL); }
cmd ::= SHOW MNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT, NULL, NULL); }
cmd ::= SHOW MODULES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MODULES_STMT, NULL, NULL); }
cmd ::= SHOW QNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT, NULL, NULL); }
cmd ::= SHOW FUNCTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT, NULL, NULL); }
cmd ::= SHOW INDEXES FROM table_name_cond(A) from_db_opt(B). { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, A, B); }
cmd ::= SHOW STREAMS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT, NULL, NULL); }
db_name_cond_opt(A) ::= . { A = NULL; }
db_name_cond_opt(A) ::= db_name(B) NK_DOT. { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); }
like_pattern_opt(A) ::= . { A = NULL; }
like_pattern_opt(A) ::= LIKE NK_STRING(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); }
table_name_cond(A) ::= table_name(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); }
from_db_opt(A) ::= . { A = NULL; }
from_db_opt(A) ::= FROM db_name(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); }
/************************************************ select **************************************************************/
cmd ::= query_expression(A). { pCxt->pRootNode = A; }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
d351e55a
...
...
@@ -21,6 +21,7 @@
do { \
if (NULL == (p)) { \
pCxt->valid = false; \
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "Out of memory"); \
return NULL; \
} \
} while (0)
...
...
@@ -903,17 +904,11 @@ SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName) {
return
(
SNode
*
)
pStmt
;
}
SNode
*
createShowStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
const
SToken
*
pDbName
)
{
if
(
!
checkDbName
(
pCxt
,
pDbName
,
false
))
{
return
NULL
;
}
SNode
*
createShowStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
SNode
*
pDbName
,
SNode
*
pTbNamePattern
)
{
SShowStmt
*
pStmt
=
nodesMakeNode
(
type
);;
CHECK_OUT_OF_MEM
(
pStmt
);
if
(
NULL
!=
pDbName
)
{
strncpy
(
pStmt
->
dbName
,
pDbName
->
z
,
pDbName
->
n
);
}
else
if
(
NULL
!=
pCxt
->
pQueryCxt
->
db
)
{
strcpy
(
pStmt
->
dbName
,
pCxt
->
pQueryCxt
->
db
);
}
pStmt
->
pDbName
=
pDbName
;
pStmt
->
pTbNamePattern
=
pTbNamePattern
;
return
(
SNode
*
)
pStmt
;
}
...
...
source/libs/parser/src/parTokenizer.c
浏览文件 @
d351e55a
...
...
@@ -59,11 +59,13 @@ static SKeyword keywordTable[] = {
{
"FLOAT"
,
TK_FLOAT
},
{
"FROM"
,
TK_FROM
},
{
"FSYNC"
,
TK_FSYNC
},
{
"FUNCTIONS"
,
TK_FUNCTIONS
},
{
"GROUP"
,
TK_GROUP
},
{
"HAVING"
,
TK_HAVING
},
{
"IF"
,
TK_IF
},
{
"IMPORT"
,
TK_IMPORT
},
{
"IN"
,
TK_IN
},
{
"INDEXES"
,
TK_INDEXES
},
{
"INNER"
,
TK_INNER
},
{
"INT"
,
TK_INT
},
{
"INSERT"
,
TK_INSERT
},
...
...
@@ -82,6 +84,7 @@ static SKeyword keywordTable[] = {
{
"MINROWS"
,
TK_MINROWS
},
{
"MINUS"
,
TK_MINUS
},
{
"MNODES"
,
TK_MNODES
},
{
"MODULES"
,
TK_MODULES
},
{
"NCHAR"
,
TK_NCHAR
},
{
"NMATCH"
,
TK_NMATCH
},
{
"NONE"
,
TK_NONE
},
...
...
@@ -97,6 +100,7 @@ static SKeyword keywordTable[] = {
{
"PRECISION"
,
TK_PRECISION
},
{
"PRIVILEGE"
,
TK_PRIVILEGE
},
{
"PREV"
,
TK_PREV
},
{
"QNODES"
,
TK_QNODES
},
{
"QUORUM"
,
TK_QUORUM
},
{
"REPLICA"
,
TK_REPLICA
},
{
"SELECT"
,
TK_SELECT
},
...
...
@@ -111,6 +115,7 @@ static SKeyword keywordTable[] = {
{
"STABLE"
,
TK_STABLE
},
{
"STABLES"
,
TK_STABLES
},
{
"STATE_WINDOW"
,
TK_STATE_WINDOW
},
{
"STREAMS"
,
TK_STREAMS
},
{
"STREAM_MODE"
,
TK_STREAM_MODE
},
{
"TABLE"
,
TK_TABLE
},
{
"TABLES"
,
TK_TABLES
},
...
...
@@ -155,10 +160,8 @@ static SKeyword keywordTable[] = {
// {"UPLUS", TK_UPLUS},
// {"BITNOT", TK_BITNOT},
// {"ACCOUNTS", TK_ACCOUNTS},
// {"MODULES", TK_MODULES},
// {"QUERIES", TK_QUERIES},
// {"CONNECTIONS", TK_CONNECTIONS},
// {"STREAMS", TK_STREAMS},
// {"VARIABLES", TK_VARIABLES},
// {"SCORES", TK_SCORES},
// {"GRANTS", TK_GRANTS},
...
...
@@ -231,7 +234,6 @@ static SKeyword keywordTable[] = {
// {"COMPACT", TK_COMPACT},
// {"MODIFY", TK_MODIFY},
// {"FUNCTION", TK_FUNCTION},
// {"FUNCTIONS", TK_FUNCTIONS},
// {"OUTPUTTYPE", TK_OUTPUTTYPE},
// {"AGGREGATE", TK_AGGREGATE},
// {"BUFSIZE", TK_BUFSIZE},
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
d351e55a
...
...
@@ -1149,12 +1149,12 @@ static int32_t nodeTypeToShowType(ENodeType nt) {
static
int32_t
translateShow
(
STranslateContext
*
pCxt
,
SShowStmt
*
pStmt
)
{
SShowReq
showReq
=
{
.
type
=
nodeTypeToShowType
(
nodeType
(
pStmt
))
};
if
(
'\0'
!=
pStmt
->
dbName
[
0
])
{
SName
name
=
{
0
};
tNameSetDbName
(
&
name
,
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
strlen
(
pStmt
->
dbName
));
char
dbFname
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
&
name
,
showReq
.
db
);
}
//
if ('\0' != pStmt->dbName[0]) {
//
SName name = {0};
//
tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName));
//
char dbFname[TSDB_DB_FNAME_LEN] = {0};
//
tNameGetFullDbName(&name, showReq.db);
//
}
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
...
...
@@ -1302,25 +1302,142 @@ static void destroyTranslateContext(STranslateContext* pCxt) {
}
}
static
int32_t
rewriteShowDatabase
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
)
{
SSelectStmt
*
pStmt
=
nodesMakeNode
(
QUERY_NODE_SELECT_STMT
);
if
(
NULL
==
pStmt
)
{
static
const
char
*
getSysTableName
(
ENodeType
type
)
{
switch
(
type
)
{
case
QUERY_NODE_SHOW_DATABASES_STMT
:
return
TSDB_INS_TABLE_USER_DATABASES
;
case
QUERY_NODE_SHOW_TABLES_STMT
:
return
TSDB_INS_TABLE_USER_TABLES
;
case
QUERY_NODE_SHOW_STABLES_STMT
:
return
TSDB_INS_TABLE_USER_STABLES
;
case
QUERY_NODE_SHOW_USERS_STMT
:
return
TSDB_INS_TABLE_USER_USERS
;
case
QUERY_NODE_SHOW_DNODES_STMT
:
return
TSDB_INS_TABLE_DNODES
;
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
return
TSDB_INS_TABLE_VGROUPS
;
case
QUERY_NODE_SHOW_MNODES_STMT
:
return
TSDB_INS_TABLE_MNODES
;
case
QUERY_NODE_SHOW_MODULES_STMT
:
return
TSDB_INS_TABLE_MODULES
;
case
QUERY_NODE_SHOW_QNODES_STMT
:
return
TSDB_INS_TABLE_QNODES
;
case
QUERY_NODE_SHOW_FUNCTIONS_STMT
:
return
TSDB_INS_TABLE_USER_FUNCTIONS
;
case
QUERY_NODE_SHOW_INDEXES_STMT
:
return
TSDB_INS_TABLE_USER_INDEXES
;
case
QUERY_NODE_SHOW_STREAMS_STMT
:
return
TSDB_INS_TABLE_USER_STREAMS
;
default:
break
;
}
return
NULL
;
}
static
int32_t
createSelectStmtForShow
(
ENodeType
showType
,
SSelectStmt
**
pStmt
)
{
SSelectStmt
*
pSelect
=
nodesMakeNode
(
QUERY_NODE_SELECT_STMT
);
if
(
NULL
==
pSelect
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
SRealTableNode
*
pTable
=
nodesMakeNode
(
QUERY_NODE_REAL_TABLE
);
if
(
NULL
==
pTable
)
{
nodesDestroyNode
(
pS
tm
t
);
nodesDestroyNode
(
pS
elec
t
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
strcpy
(
pTable
->
table
.
dbName
,
TSDB_INFORMATION_SCHEMA_DB
);
strcpy
(
pTable
->
table
.
tableName
,
TSDB_INS_TABLE_USER_DATABASES
);
pStmt
->
pFromTable
=
(
SNode
*
)
pTable
;
strcpy
(
pTable
->
table
.
tableName
,
getSysTableName
(
showType
));
pSelect
->
pFromTable
=
(
SNode
*
)
pTable
;
*
pStmt
=
pSelect
;
nodesDestroyNode
(
pQuery
->
pRoot
);
pQuery
->
pRoot
=
(
SNode
*
)
pStmt
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
createOperatorNode
(
EOperatorType
opType
,
const
char
*
pColName
,
SNode
*
pRight
,
SNode
**
pOp
)
{
if
(
NULL
==
pRight
)
{
return
TSDB_CODE_SUCCESS
;
}
SOperatorNode
*
pOper
=
nodesMakeNode
(
QUERY_NODE_OPERATOR
);
if
(
NULL
==
pOper
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pOper
->
opType
=
OP_TYPE_LIKE
;
pOper
->
pLeft
=
nodesMakeNode
(
QUERY_NODE_COLUMN
);
pOper
->
pRight
=
nodesCloneNode
(
pRight
);
if
(
NULL
==
pOper
->
pLeft
||
NULL
==
pOper
->
pRight
)
{
nodesDestroyNode
(
pOper
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
strcpy
(((
SColumnNode
*
)
pOper
->
pLeft
)
->
colName
,
pColName
);
*
pOp
=
(
SNode
*
)
pOper
;
return
TSDB_CODE_SUCCESS
;
}
static
const
char
*
getTbNameColName
(
ENodeType
type
)
{
return
(
QUERY_NODE_SHOW_STABLES_STMT
==
type
?
"stable_name"
:
"table_name"
);
}
static
int32_t
createLogicCondNode
(
SNode
*
pCond1
,
SNode
*
pCond2
,
SNode
**
pCond
)
{
SLogicConditionNode
*
pCondition
=
nodesMakeNode
(
QUERY_NODE_LOGIC_CONDITION
);
if
(
NULL
==
pCondition
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pCondition
->
condType
=
LOGIC_COND_TYPE_AND
;
pCondition
->
pParameterList
=
nodesMakeList
();
if
(
NULL
==
pCondition
->
pParameterList
)
{
nodesDestroyNode
(
pCondition
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
if
(
TSDB_CODE_SUCCESS
!=
nodesListAppend
(
pCondition
->
pParameterList
,
pCond1
)
||
TSDB_CODE_SUCCESS
!=
nodesListAppend
(
pCondition
->
pParameterList
,
pCond2
))
{
nodesDestroyNode
(
pCondition
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
*
pCond
=
(
SNode
*
)
pCondition
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
createShowCondition
(
const
SShowStmt
*
pShow
,
SSelectStmt
*
pSelect
)
{
SNode
*
pDbCond
=
NULL
;
SNode
*
pTbCond
=
NULL
;
if
(
TSDB_CODE_SUCCESS
!=
createOperatorNode
(
OP_TYPE_EQUAL
,
"db_name"
,
pShow
->
pDbName
,
&
pDbCond
)
||
TSDB_CODE_SUCCESS
!=
createOperatorNode
(
OP_TYPE_LIKE
,
getTbNameColName
(
nodeType
(
pShow
)),
pShow
->
pTbNamePattern
,
&
pTbCond
))
{
nodesDestroyNode
(
pDbCond
);
nodesDestroyNode
(
pTbCond
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
if
(
NULL
!=
pDbCond
&&
NULL
!=
pTbCond
)
{
if
(
TSDB_CODE_SUCCESS
!=
createLogicCondNode
(
pDbCond
,
pTbCond
,
&
pSelect
->
pWhere
))
{
nodesDestroyNode
(
pDbCond
);
nodesDestroyNode
(
pTbCond
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
else
{
pSelect
->
pWhere
=
(
NULL
==
pDbCond
?
pTbCond
:
pDbCond
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
rewriteShow
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
)
{
SSelectStmt
*
pStmt
=
NULL
;
int32_t
code
=
createSelectStmtForShow
(
nodeType
(
pQuery
->
pRoot
),
&
pStmt
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createShowCondition
((
SShowStmt
*
)
pQuery
->
pRoot
,
pStmt
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
nodesDestroyNode
(
pQuery
->
pRoot
);
pQuery
->
pRoot
=
(
SNode
*
)
pStmt
;
}
return
code
;
}
typedef
struct
SVgroupTablesBatch
{
SVCreateTbBatchReq
req
;
SVgroupInfo
info
;
...
...
@@ -1685,7 +1802,18 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
int32_t
code
=
TSDB_CODE_SUCCESS
;
switch
(
nodeType
(
pQuery
->
pRoot
))
{
case
QUERY_NODE_SHOW_DATABASES_STMT
:
code
=
rewriteShowDatabase
(
pCxt
,
pQuery
);
case
QUERY_NODE_SHOW_TABLES_STMT
:
case
QUERY_NODE_SHOW_STABLES_STMT
:
case
QUERY_NODE_SHOW_USERS_STMT
:
case
QUERY_NODE_SHOW_DNODES_STMT
:
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
case
QUERY_NODE_SHOW_MNODES_STMT
:
case
QUERY_NODE_SHOW_MODULES_STMT
:
case
QUERY_NODE_SHOW_QNODES_STMT
:
case
QUERY_NODE_SHOW_FUNCTIONS_STMT
:
case
QUERY_NODE_SHOW_INDEXES_STMT
:
case
QUERY_NODE_SHOW_STREAMS_STMT
:
code
=
rewriteShow
(
pCxt
,
pQuery
);
break
;
case
QUERY_NODE_CREATE_TABLE_STMT
:
if
(
NULL
==
((
SCreateTableStmt
*
)
pQuery
->
pRoot
)
->
pTags
)
{
...
...
source/libs/parser/src/sql.c
浏览文件 @
d351e55a
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
d351e55a
...
...
@@ -26,6 +26,64 @@
#include "mockCatalog.h"
namespace
{
void
generateInformationSchema
(
MockCatalogService
*
mcs
)
{
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"dnodes"
,
TSDB_NORMAL_TABLE
,
1
).
addColumn
(
"id"
,
TSDB_DATA_TYPE_INT
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"mnodes"
,
TSDB_NORMAL_TABLE
,
1
).
addColumn
(
"id"
,
TSDB_DATA_TYPE_INT
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"modules"
,
TSDB_NORMAL_TABLE
,
1
).
addColumn
(
"id"
,
TSDB_DATA_TYPE_INT
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"qnodes"
,
TSDB_NORMAL_TABLE
,
1
).
addColumn
(
"id"
,
TSDB_DATA_TYPE_INT
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_databases"
,
TSDB_NORMAL_TABLE
,
1
).
addColumn
(
"name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_functions"
,
TSDB_NORMAL_TABLE
,
1
).
addColumn
(
"name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_FUNC_NAME_LEN
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_indexes"
,
TSDB_NORMAL_TABLE
,
2
)
.
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
).
addColumn
(
"table_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_stables"
,
TSDB_NORMAL_TABLE
,
2
)
.
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
).
addColumn
(
"stable_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_streams"
,
TSDB_NORMAL_TABLE
,
1
).
addColumn
(
"stream_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_tables"
,
TSDB_NORMAL_TABLE
,
2
)
.
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
).
addColumn
(
"table_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_table_distributed"
,
TSDB_NORMAL_TABLE
,
1
).
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_users"
,
TSDB_NORMAL_TABLE
,
1
).
addColumn
(
"user_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_USER_LEN
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"vgroups"
,
TSDB_NORMAL_TABLE
,
1
).
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
);
builder
.
done
();
}
}
void
generateTestT1
(
MockCatalogService
*
mcs
)
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"test"
,
"t1"
,
TSDB_NORMAL_TABLE
,
6
)
.
setPrecision
(
TSDB_TIME_PRECISION_MILLI
).
setVgid
(
1
).
addColumn
(
"ts"
,
TSDB_DATA_TYPE_TIMESTAMP
)
...
...
@@ -74,6 +132,7 @@ void initMetaDataEnv() {
stub
.
set
(
catalogGetTableMeta
,
__catalogGetTableMeta
);
stub
.
set
(
catalogGetTableHashVgroup
,
__catalogGetTableHashVgroup
);
stub
.
set
(
catalogGetTableDistVgInfo
,
__catalogGetTableDistVgInfo
);
stub
.
set
(
catalogGetDBVgVersion
,
__catalogGetDBVgVersion
);
// {
// AddrAny any("libcatalog.so");
// std::map<std::string,void*> result;
...
...
@@ -117,6 +176,7 @@ void initMetaDataEnv() {
}
void
generateMetaData
()
{
generateInformationSchema
(
mockCatalogService
.
get
());
generateTestT1
(
mockCatalogService
.
get
());
generateTestST1
(
mockCatalogService
.
get
());
mockCatalogService
->
showTables
();
...
...
source/libs/parser/test/parserAstTest.cpp
浏览文件 @
d351e55a
...
...
@@ -295,6 +295,13 @@ TEST_F(ParserTest, createUser) {
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
showUsers
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"show users"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
createDnode
)
{
setDatabase
(
"root"
,
"test"
);
...
...
@@ -305,6 +312,13 @@ TEST_F(ParserTest, createDnode) {
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
showDnodes
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"show dnodes"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
createDatabase
)
{
setDatabase
(
"root"
,
"test"
);
...
...
@@ -333,7 +347,7 @@ TEST_F(ParserTest, createDatabase) {
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
showDatabase
)
{
TEST_F
(
ParserTest
,
showDatabase
s
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"show databases"
);
...
...
@@ -391,3 +405,90 @@ TEST_F(ParserTest, createTable) {
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
showTables
)
{
setDatabase
(
"root"
,
"test"
);
// bind("show tables");
// ASSERT_TRUE(run());
// bind("show test.tables");
// ASSERT_TRUE(run());
bind
(
"show tables like 'c%'"
);
ASSERT_TRUE
(
run
());
bind
(
"show test.tables like 'c%'"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
showStables
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"show stables"
);
ASSERT_TRUE
(
run
());
bind
(
"show test.stables"
);
ASSERT_TRUE
(
run
());
bind
(
"show stables like 'c%'"
);
ASSERT_TRUE
(
run
());
bind
(
"show test.stables like 'c%'"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
showVgroups
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"show vgroups"
);
ASSERT_TRUE
(
run
());
bind
(
"show test.vgroups"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
showMnodes
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"show mnodes"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
showModules
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"show modules"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
showQnodes
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"show qnodes"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
showFunctions
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"show functions"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
showIndexes
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"show indexes from t1"
);
ASSERT_TRUE
(
run
());
bind
(
"show indexes from t1 from test"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
showStreams
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"show streams"
);
ASSERT_TRUE
(
run
());
}
source/libs/parser/test/parserInsertTest.cpp
浏览文件 @
d351e55a
...
...
@@ -131,7 +131,7 @@ private:
TEST_F
(
InsertTest
,
singleTableSingleRowTest
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"insert into t1 values (now, 1,
\"
beijing
\"
)"
);
bind
(
"insert into t1 values (now, 1,
'beijing', 3, 4, 5
)"
);
ASSERT_EQ
(
run
(),
TSDB_CODE_SUCCESS
);
dumpReslut
();
checkReslut
(
1
,
1
);
...
...
@@ -141,7 +141,7 @@ TEST_F(InsertTest, singleTableSingleRowTest) {
TEST_F
(
InsertTest
,
singleTableMultiRowTest
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"insert into t1 values (now, 1,
\"
beijing
\"
)(now+1s, 2,
\"
shanghai
\"
)(now+2s, 3,
\"
guangzhou
\"
)"
);
bind
(
"insert into t1 values (now, 1,
'beijing', 3, 4, 5)(now+1s, 2, 'shanghai', 6, 7, 8)(now+2s, 3, 'guangzhou', 9, 10, 11
)"
);
ASSERT_EQ
(
run
(),
TSDB_CODE_SUCCESS
);
dumpReslut
();
checkReslut
(
1
,
3
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录