Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e0ca1aff
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
e0ca1aff
编写于
12月 29, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: escape error in create topic/stream
上级
6e9b5d1b
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
2365 addition
and
2291 deletion
+2365
-2291
include/util/tdef.h
include/util/tdef.h
+10
-9
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+10
-11
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+9
-2
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+53
-11
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+2283
-2258
未找到文件。
include/util/tdef.h
浏览文件 @
e0ca1aff
...
...
@@ -189,12 +189,13 @@ typedef enum ELogicConditionType {
#define TSDB_MAX_COLUMNS 4096
#define TSDB_MIN_COLUMNS 2 // PRIMARY COLUMN(timestamp) + other columns
#define TSDB_NODE_NAME_LEN 64
#define TSDB_TABLE_NAME_LEN 193 // it is a null-terminated string
#define TSDB_TOPIC_NAME_LEN 193 // it is a null-terminated string
#define TSDB_CGROUP_LEN 193 // it is a null-terminated string
#define TSDB_DB_NAME_LEN 65
#define TSDB_DB_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_NODE_NAME_LEN 64
#define TSDB_TABLE_NAME_LEN 193 // it is a null-terminated string
#define TSDB_TOPIC_NAME_LEN 193 // it is a null-terminated string
#define TSDB_CGROUP_LEN 193 // it is a null-terminated string
#define TSDB_STREAM_NAME_LEN 193 // it is a null-terminated string
#define TSDB_DB_NAME_LEN 65
#define TSDB_DB_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_FUNC_NAME_LEN 65
#define TSDB_FUNC_COMMENT_LEN 1024 * 1024
...
...
@@ -212,8 +213,8 @@ typedef enum ELogicConditionType {
#define TSDB_INDEX_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_INDEX_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_TYPE_STR_MAX_LEN 32
#define TSDB_TABLE_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_TOPIC_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_T
ABLE
_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_STREAM_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_
TABLE
_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_TOPIC_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_T
OPIC
_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_STREAM_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_
STREAM
_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_SUBSCRIBE_KEY_LEN (TSDB_CGROUP_LEN + TSDB_TOPIC_FNAME_LEN + 2)
#define TSDB_PARTITION_KEY_LEN (TSDB_SUBSCRIBE_KEY_LEN + 20)
#define TSDB_COL_NAME_LEN 65
...
...
@@ -310,7 +311,7 @@ typedef enum ELogicConditionType {
#define TSDB_MIN_KEEP (1 * 1440) // data in db to be reserved. unit minute
#define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved.
#define TSDB_MAX_KEEP_NS (365 * 292 * 1440) // data in db to be reserved.
#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years
#define TSDB_DEFAULT_KEEP (3650 * 1440)
// ten years
#define TSDB_MIN_MINROWS_FBLOCK 10
#define TSDB_MAX_MINROWS_FBLOCK 1000
#define TSDB_DEFAULT_MINROWS_FBLOCK 100
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
e0ca1aff
...
...
@@ -186,6 +186,7 @@ SNode* createDropUserStmt(SAstCreateContext* pCxt, SToken* pUserName);
SNode
*
createCreateDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pFqdn
,
const
SToken
*
pPort
);
SNode
*
createDropDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
,
bool
force
);
SNode
*
createAlterDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
,
const
SToken
*
pConfig
,
const
SToken
*
pValue
);
SNode
*
createRealTableNodeForIndexName
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
SToken
*
pIndexName
);
SNode
*
createCreateIndexStmt
(
SAstCreateContext
*
pCxt
,
EIndexType
type
,
bool
ignoreExists
,
SNode
*
pIndexName
,
SNode
*
pRealTable
,
SNodeList
*
pCols
,
SNode
*
pOptions
);
SNode
*
createIndexOption
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pFuncs
,
SNode
*
pInterval
,
SNode
*
pOffset
,
SNode
*
pSliding
,
...
...
@@ -193,15 +194,13 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt
SNode
*
createDropIndexStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SNode
*
pIndexName
);
SNode
*
createCreateComponentNodeStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
const
SToken
*
pDnodeId
);
SNode
*
createDropComponentNodeStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
const
SToken
*
pDnodeId
);
SNode
*
createCreateTopicStmtUseQuery
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
SNode
*
pQuery
);
SNode
*
createCreateTopicStmtUseDb
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
SToken
*
pSubDbName
,
bool
withMeta
);
SNode
*
createCreateTopicStmtUseTable
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
SNode
*
pRealTable
,
bool
withMeta
);
SNode
*
createDropTopicStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
const
SToken
*
pTopicName
);
SNode
*
createDropCGroupStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
const
SToken
*
pCGroupId
,
const
SToken
*
pTopicName
);
SNode
*
createCreateTopicStmtUseQuery
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SToken
*
pTopicName
,
SNode
*
pQuery
);
SNode
*
createCreateTopicStmtUseDb
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SToken
*
pTopicName
,
SToken
*
pSubDbName
,
bool
withMeta
);
SNode
*
createCreateTopicStmtUseTable
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SToken
*
pTopicName
,
SNode
*
pRealTable
,
bool
withMeta
);
SNode
*
createDropTopicStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SToken
*
pTopicName
);
SNode
*
createDropCGroupStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
const
SToken
*
pCGroupId
,
SToken
*
pTopicName
);
SNode
*
createAlterLocalStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pConfig
,
const
SToken
*
pValue
);
SNode
*
createDefaultExplainOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
setExplainVerbose
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
const
SToken
*
pVal
);
...
...
@@ -214,9 +213,9 @@ SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool
const
SToken
*
pLibPath
,
SDataType
dataType
,
int32_t
bufSize
);
SNode
*
createDropFunctionStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
const
SToken
*
pFuncName
);
SNode
*
createStreamOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
createCreateStreamStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pStreamName
,
SNode
*
pRealTable
,
SNode
*
createCreateStreamStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SToken
*
pStreamName
,
SNode
*
pRealTable
,
SNode
*
pOptions
,
SNodeList
*
pTags
,
SNode
*
pSubtable
,
SNode
*
pQuery
);
SNode
*
createDropStreamStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
const
SToken
*
pStreamName
);
SNode
*
createDropStreamStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SToken
*
pStreamName
);
SNode
*
createKillStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
const
SToken
*
pId
);
SNode
*
createKillQueryStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pQueryId
);
SNode
*
createBalanceVgroupStmt
(
SAstCreateContext
*
pCxt
);
...
...
source/libs/parser/inc/sql.y
浏览文件 @
e0ca1aff
...
...
@@ -459,8 +459,11 @@ tag_item(A) ::= column_name(B) AS column_alias(C).
/************************************************ create index ********************************************************/
cmd ::= CREATE SMA INDEX not_exists_opt(D)
full_table_name(A) ON full_table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, A, B, NULL, C); }
cmd ::= DROP INDEX exists_opt(B) full_table_name(A). { pCxt->pRootNode = createDropIndexStmt(pCxt, B, A); }
full_index_name(A) ON full_table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, A, B, NULL, C); }
cmd ::= DROP INDEX exists_opt(B) full_index_name(A). { pCxt->pRootNode = createDropIndexStmt(pCxt, B, A); }
full_index_name(A) ::= index_name(B). { A = createRealTableNodeForIndexName(pCxt, NULL, &B); }
full_index_name(A) ::= db_name(B) NK_DOT index_name(C). { A = createRealTableNodeForIndexName(pCxt, &B, &C); }
index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL
NK_LP duration_literal(C) NK_RP sliding_opt(D) sma_stream_opt(E). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), NULL, D, E); }
...
...
@@ -657,6 +660,10 @@ stream_name(A) ::= NK_ID(B).
%destructor cgroup_name { }
cgroup_name(A) ::= NK_ID(B). { A = B; }
%type index_name { SToken }
%destructor index_name { }
index_name(A) ::= NK_ID(B). { A = B; }
/************************************************ expression **********************************************************/
expr_or_subquery(A) ::= expression(B). { A = B; }
//expr_or_subquery(A) ::= subquery(B). { A = createTempTableNode(pCxt, releaseRawExprNode(pCxt, B), NULL); }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
e0ca1aff
...
...
@@ -201,6 +201,24 @@ static bool checkIndexName(SAstCreateContext* pCxt, SToken* pIndexName) {
return
true
;
}
static
bool
checkTopicName
(
SAstCreateContext
*
pCxt
,
SToken
*
pTopicName
)
{
trimEscape
(
pTopicName
);
if
(
pTopicName
->
n
>=
TSDB_TOPIC_NAME_LEN
)
{
pCxt
->
errCode
=
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME
,
pTopicName
->
z
);
return
false
;
}
return
true
;
}
static
bool
checkStreamName
(
SAstCreateContext
*
pCxt
,
SToken
*
pStreamName
)
{
trimEscape
(
pStreamName
);
if
(
pStreamName
->
n
>=
TSDB_STREAM_NAME_LEN
)
{
pCxt
->
errCode
=
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME
,
pStreamName
->
z
);
return
false
;
}
return
true
;
}
static
bool
checkComment
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pCommentToken
,
bool
demand
)
{
if
(
NULL
==
pCommentToken
)
{
pCxt
->
errCode
=
demand
?
TSDB_CODE_PAR_SYNTAX_ERROR
:
TSDB_CODE_SUCCESS
;
...
...
@@ -1509,6 +1527,13 @@ SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const
return
(
SNode
*
)
pStmt
;
}
SNode
*
createRealTableNodeForIndexName
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
SToken
*
pIndexName
)
{
if
(
!
checkIndexName
(
pCxt
,
pIndexName
))
{
return
NULL
;
}
return
createRealTableNode
(
pCxt
,
pDbName
,
pIndexName
,
NULL
);
}
SNode
*
createCreateIndexStmt
(
SAstCreateContext
*
pCxt
,
EIndexType
type
,
bool
ignoreExists
,
SNode
*
pIndexName
,
SNode
*
pRealTable
,
SNodeList
*
pCols
,
SNode
*
pOptions
)
{
CHECK_PARSER_STATUS
(
pCxt
);
...
...
@@ -1567,9 +1592,11 @@ SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, cons
return
(
SNode
*
)
pStmt
;
}
SNode
*
createCreateTopicStmtUseQuery
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
SNode
*
pQuery
)
{
SNode
*
createCreateTopicStmtUseQuery
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SToken
*
pTopicName
,
SNode
*
pQuery
)
{
CHECK_PARSER_STATUS
(
pCxt
);
if
(
!
checkTopicName
(
pCxt
,
pTopicName
))
{
return
NULL
;
}
SCreateTopicStmt
*
pStmt
=
(
SCreateTopicStmt
*
)
nodesMakeNode
(
QUERY_NODE_CREATE_TOPIC_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
COPY_STRING_FORM_ID_TOKEN
(
pStmt
->
topicName
,
pTopicName
);
...
...
@@ -1578,10 +1605,10 @@ SNode* createCreateTopicStmtUseQuery(SAstCreateContext* pCxt, bool ignoreExists,
return
(
SNode
*
)
pStmt
;
}
SNode
*
createCreateTopicStmtUseDb
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopic
Name
,
SToken
*
pSubDbName
,
bool
withMeta
)
{
SNode
*
createCreateTopicStmtUseDb
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SToken
*
pTopicName
,
SToken
*
pSubDb
Name
,
bool
withMeta
)
{
CHECK_PARSER_STATUS
(
pCxt
);
if
(
!
checkDbName
(
pCxt
,
pSubDbName
,
true
))
{
if
(
!
check
TopicName
(
pCxt
,
pTopicName
)
||
!
check
DbName
(
pCxt
,
pSubDbName
,
true
))
{
return
NULL
;
}
SCreateTopicStmt
*
pStmt
=
(
SCreateTopicStmt
*
)
nodesMakeNode
(
QUERY_NODE_CREATE_TOPIC_STMT
);
...
...
@@ -1593,9 +1620,12 @@ SNode* createCreateTopicStmtUseDb(SAstCreateContext* pCxt, bool ignoreExists, co
return
(
SNode
*
)
pStmt
;
}
SNode
*
createCreateTopicStmtUseTable
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicNam
e
,
SNode
*
pRealTable
,
bool
withMeta
)
{
SNode
*
createCreateTopicStmtUseTable
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SToken
*
pTopicName
,
SNode
*
pRealTabl
e
,
bool
withMeta
)
{
CHECK_PARSER_STATUS
(
pCxt
);
if
(
!
checkTopicName
(
pCxt
,
pTopicName
))
{
return
NULL
;
}
SCreateTopicStmt
*
pStmt
=
(
SCreateTopicStmt
*
)
nodesMakeNode
(
QUERY_NODE_CREATE_TOPIC_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
COPY_STRING_FORM_ID_TOKEN
(
pStmt
->
topicName
,
pTopicName
);
...
...
@@ -1607,8 +1637,11 @@ SNode* createCreateTopicStmtUseTable(SAstCreateContext* pCxt, bool ignoreExists,
return
(
SNode
*
)
pStmt
;
}
SNode
*
createDropTopicStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
const
SToken
*
pTopicName
)
{
SNode
*
createDropTopicStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SToken
*
pTopicName
)
{
CHECK_PARSER_STATUS
(
pCxt
);
if
(
!
checkTopicName
(
pCxt
,
pTopicName
))
{
return
NULL
;
}
SDropTopicStmt
*
pStmt
=
(
SDropTopicStmt
*
)
nodesMakeNode
(
QUERY_NODE_DROP_TOPIC_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
COPY_STRING_FORM_ID_TOKEN
(
pStmt
->
topicName
,
pTopicName
);
...
...
@@ -1617,8 +1650,11 @@ SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const
}
SNode
*
createDropCGroupStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
const
SToken
*
pCGroupId
,
const
SToken
*
pTopicName
)
{
SToken
*
pTopicName
)
{
CHECK_PARSER_STATUS
(
pCxt
);
if
(
!
checkTopicName
(
pCxt
,
pTopicName
))
{
return
NULL
;
}
SDropCGroupStmt
*
pStmt
=
(
SDropCGroupStmt
*
)
nodesMakeNode
(
QUERY_NODE_DROP_CGROUP_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
pStmt
->
ignoreNotExists
=
ignoreNotExists
;
...
...
@@ -1730,9 +1766,12 @@ SNode* createStreamOptions(SAstCreateContext* pCxt) {
return
(
SNode
*
)
pOptions
;
}
SNode
*
createCreateStreamStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pStreamName
,
SNode
*
pRealTable
,
SNode
*
createCreateStreamStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SToken
*
pStreamName
,
SNode
*
pRealTable
,
SNode
*
pOptions
,
SNodeList
*
pTags
,
SNode
*
pSubtable
,
SNode
*
pQuery
)
{
CHECK_PARSER_STATUS
(
pCxt
);
if
(
!
checkStreamName
(
pCxt
,
pStreamName
))
{
return
NULL
;
}
SCreateStreamStmt
*
pStmt
=
(
SCreateStreamStmt
*
)
nodesMakeNode
(
QUERY_NODE_CREATE_STREAM_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
COPY_STRING_FORM_ID_TOKEN
(
pStmt
->
streamName
,
pStreamName
);
...
...
@@ -1749,8 +1788,11 @@ SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const
return
(
SNode
*
)
pStmt
;
}
SNode
*
createDropStreamStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
const
SToken
*
pStreamName
)
{
SNode
*
createDropStreamStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SToken
*
pStreamName
)
{
CHECK_PARSER_STATUS
(
pCxt
);
if
(
!
checkStreamName
(
pCxt
,
pStreamName
))
{
return
NULL
;
}
SDropStreamStmt
*
pStmt
=
(
SDropStreamStmt
*
)
nodesMakeNode
(
QUERY_NODE_DROP_STREAM_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
COPY_STRING_FORM_ID_TOKEN
(
pStmt
->
streamName
,
pStreamName
);
...
...
source/libs/parser/src/sql.c
浏览文件 @
e0ca1aff
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录