Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d6f294ac
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看板
未验证
提交
d6f294ac
编写于
3月 23, 2022
作者:
X
Xiaoyu Wang
提交者:
GitHub
3月 23, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10920 from taosdata/feature/3.0_wxy
TD-13077 `string` identifier implement
上级
2bd78018
255777ec
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
50 addition
and
32 deletion
+50
-32
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+11
-11
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+38
-20
source/util/src/tutil.c
source/util/src/tutil.c
+1
-1
未找到文件。
source/libs/parser/inc/parAst.h
浏览文件 @
d6f294ac
...
...
@@ -84,7 +84,7 @@ SToken getTokenFromRawExprNode(SAstCreateContext* pCxt, SNode* pNode);
SNodeList
*
createNodeList
(
SAstCreateContext
*
pCxt
,
SNode
*
pNode
);
SNodeList
*
addNodeToList
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pList
,
SNode
*
pNode
);
SNode
*
createColumnNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pTableAlias
,
const
SToken
*
pColumnName
);
SNode
*
createColumnNode
(
SAstCreateContext
*
pCxt
,
SToken
*
pTableAlias
,
SToken
*
pColumnName
);
SNode
*
createValueNode
(
SAstCreateContext
*
pCxt
,
int32_t
dataType
,
const
SToken
*
pLiteral
);
SNode
*
createDurationValueNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pLiteral
);
SNode
*
createDefaultDatabaseCondValue
(
SAstCreateContext
*
pCxt
);
...
...
@@ -95,7 +95,7 @@ SNode* createBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNo
SNode
*
createNotBetweenAnd
(
SAstCreateContext
*
pCxt
,
SNode
*
pExpr
,
SNode
*
pLeft
,
SNode
*
pRight
);
SNode
*
createFunctionNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pFuncName
,
SNodeList
*
pParameterList
);
SNode
*
createNodeListNode
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pList
);
SNode
*
createRealTableNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDbName
,
const
SToken
*
pTableName
,
const
SToken
*
pTableAlias
);
SNode
*
createRealTableNode
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
SToken
*
pTableName
,
SToken
*
pTableAlias
);
SNode
*
createTempTableNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pSubquery
,
const
SToken
*
pTableAlias
);
SNode
*
createJoinTableNode
(
SAstCreateContext
*
pCxt
,
EJoinType
type
,
SNode
*
pLeft
,
SNode
*
pRight
,
SNode
*
pJoinCond
);
SNode
*
createLimitNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pLimit
,
const
SToken
*
pOffset
);
...
...
@@ -120,9 +120,9 @@ SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode*
SNode
*
createDefaultDatabaseOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
createDefaultAlterDatabaseOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
setDatabaseOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
EDatabaseOptionType
type
,
const
SToken
*
pVal
);
SNode
*
createCreateDatabaseStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pDbName
,
SNode
*
pOptions
);
SNode
*
createDropDatabaseStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
const
SToken
*
pDbName
);
SNode
*
createAlterDatabaseStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDbName
,
SNode
*
pOptions
);
SNode
*
createCreateDatabaseStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SToken
*
pDbName
,
SNode
*
pOptions
);
SNode
*
createDropDatabaseStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SToken
*
pDbName
);
SNode
*
createAlterDatabaseStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
SNode
*
pOptions
);
SNode
*
createDefaultTableOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
createDefaultAlterTableOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
setTableOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
ETableOptionType
type
,
const
SToken
*
pVal
);
...
...
@@ -142,17 +142,17 @@ SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable,
SNode
*
createAlterTableDropCol
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
int8_t
alterType
,
const
SToken
*
pColName
);
SNode
*
createAlterTableRenameCol
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
int8_t
alterType
,
const
SToken
*
pOldColName
,
const
SToken
*
pNewColName
);
SNode
*
createAlterTableSetTag
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
const
SToken
*
pTagName
,
SNode
*
pVal
);
SNode
*
createUseDatabaseStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDbName
);
SNode
*
createUseDatabaseStmt
(
SAstCreateContext
*
pCxt
,
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
);
SNode
*
createCreateUserStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pUserName
,
const
SToken
*
pPassword
);
SNode
*
createAlterUserStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pUserName
,
int8_t
alterType
,
const
SToken
*
pVal
);
SNode
*
createDropUserStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pUserName
);
SNode
*
createCreateDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pFqdn
,
const
SToken
*
pPort
);
SNode
*
createDropDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
);
SNode
*
createAlterDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
,
const
SToken
*
pConfig
,
const
SToken
*
pValue
);
SNode
*
createCreateIndexStmt
(
SAstCreateContext
*
pCxt
,
EIndexType
type
,
const
SToken
*
pIndexName
,
const
SToken
*
pTableName
,
SNodeList
*
pCols
,
SNode
*
pOptions
);
SNode
*
createCreateIndexStmt
(
SAstCreateContext
*
pCxt
,
EIndexType
type
,
SToken
*
pIndexName
,
SToken
*
pTableName
,
SNodeList
*
pCols
,
SNode
*
pOptions
);
SNode
*
createIndexOption
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pFuncs
,
SNode
*
pInterval
,
SNode
*
pOffset
,
SNode
*
pSliding
);
SNode
*
createDropIndexStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pIndexName
,
const
SToken
*
pTableName
);
SNode
*
createDropIndexStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pIndexName
,
SToken
*
pTableName
);
SNode
*
createCreateQnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnodeId
);
SNode
*
createDropQnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnodeId
);
SNode
*
createCreateTopicStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
SNode
*
pQuery
,
const
SToken
*
pSubscribeDbName
);
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
d6f294ac
...
...
@@ -331,7 +331,14 @@ void initAstCreateContext(SParseContext* pParseCxt, SAstCreateContext* pCxt) {
initSetTableOptionFp
();
}
static
bool
checkUserName
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pUserName
)
{
static
void
trimEscape
(
SToken
*
pName
)
{
if
(
NULL
!=
pName
&&
pName
->
n
>
1
&&
'`'
==
pName
->
z
[
0
])
{
pName
->
z
+=
1
;
pName
->
n
-=
2
;
}
}
static
bool
checkUserName
(
SAstCreateContext
*
pCxt
,
SToken
*
pUserName
)
{
if
(
NULL
==
pUserName
)
{
pCxt
->
valid
=
false
;
}
else
{
...
...
@@ -340,6 +347,7 @@ static bool checkUserName(SAstCreateContext* pCxt, const SToken* pUserName) {
pCxt
->
valid
=
false
;
}
}
trimEscape
(
pUserName
);
return
pCxt
->
valid
;
}
...
...
@@ -412,38 +420,43 @@ static bool checkPort(SAstCreateContext* pCxt, const SToken* pPortToken, int32_t
return
pCxt
->
valid
;
}
static
bool
checkDbName
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDbName
,
bool
query
)
{
static
bool
checkDbName
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
bool
query
)
{
if
(
NULL
==
pDbName
)
{
pCxt
->
valid
=
(
query
?
NULL
!=
pCxt
->
pQueryCxt
->
db
:
true
);
}
else
{
pCxt
->
valid
=
pDbName
->
n
<
TSDB_DB_NAME_LEN
?
true
:
false
;
}
trimEscape
(
pDbName
);
return
pCxt
->
valid
;
}
static
bool
checkTableName
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pTableName
)
{
static
bool
checkTableName
(
SAstCreateContext
*
pCxt
,
SToken
*
pTableName
)
{
if
(
NULL
==
pTableName
)
{
pCxt
->
valid
=
true
;
}
else
{
pCxt
->
valid
=
pTableName
->
n
<
TSDB_TABLE_NAME_LEN
?
true
:
false
;
}
trimEscape
(
pTableName
);
return
pCxt
->
valid
;
}
static
bool
checkColumnName
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pColumnName
)
{
static
bool
checkColumnName
(
SAstCreateContext
*
pCxt
,
SToken
*
pColumnName
)
{
if
(
NULL
==
pColumnName
)
{
pCxt
->
valid
=
true
;
}
else
{
pCxt
->
valid
=
pColumnName
->
n
<
TSDB_COL_NAME_LEN
?
true
:
false
;
}
trimEscape
(
pColumnName
);
return
pCxt
->
valid
;
}
static
bool
checkIndexName
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pIndexName
)
{
static
bool
checkIndexName
(
SAstCreateContext
*
pCxt
,
SToken
*
pIndexName
)
{
if
(
NULL
==
pIndexName
)
{
return
false
;
pCxt
->
valid
=
false
;
}
else
{
pCxt
->
valid
=
pIndexName
->
n
<
TSDB_INDEX_NAME_LEN
?
true
:
false
;
}
pCxt
->
valid
=
pIndexName
->
n
<
TSDB_INDEX_NAME_LEN
?
true
:
false
;
trimEscape
(
pIndexName
)
;
return
pCxt
->
valid
;
}
...
...
@@ -498,7 +511,7 @@ SNodeList* addNodeToList(SAstCreateContext* pCxt, SNodeList* pList, SNode* pNode
return
pList
;
}
SNode
*
createColumnNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pTableAlias
,
const
SToken
*
pColumnName
)
{
SNode
*
createColumnNode
(
SAstCreateContext
*
pCxt
,
SToken
*
pTableAlias
,
SToken
*
pColumnName
)
{
if
(
!
checkTableName
(
pCxt
,
pTableAlias
)
||
!
checkColumnName
(
pCxt
,
pColumnName
))
{
return
NULL
;
}
...
...
@@ -603,8 +616,8 @@ SNode* createNodeListNode(SAstCreateContext* pCxt, SNodeList* pList) {
return
(
SNode
*
)
list
;
}
SNode
*
createRealTableNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDbName
,
const
SToken
*
pTableName
,
const
SToken
*
pTableAlias
)
{
if
(
!
checkDbName
(
pCxt
,
pDbName
,
true
)
||
!
checkTableName
(
pCxt
,
pTableName
))
{
SNode
*
createRealTableNode
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
SToken
*
pTableName
,
SToken
*
pTableAlias
)
{
if
(
!
checkDbName
(
pCxt
,
pDbName
,
true
)
||
!
checkTableName
(
pCxt
,
pTableName
)
||
!
checkTableName
(
pCxt
,
pTableAlias
)
)
{
return
NULL
;
}
SRealTableNode
*
realTable
=
(
SRealTableNode
*
)
nodesMakeNode
(
QUERY_NODE_REAL_TABLE
);
...
...
@@ -620,7 +633,9 @@ SNode* createRealTableNode(SAstCreateContext* pCxt, const SToken* pDbName, const
strncpy
(
realTable
->
table
.
tableAlias
,
pTableName
->
z
,
pTableName
->
n
);
}
strncpy
(
realTable
->
table
.
tableName
,
pTableName
->
z
,
pTableName
->
n
);
strcpy
(
realTable
->
useDbName
,
pCxt
->
pQueryCxt
->
db
);
if
(
NULL
!=
pCxt
->
pQueryCxt
->
db
)
{
strcpy
(
realTable
->
useDbName
,
pCxt
->
pQueryCxt
->
db
);
}
return
(
SNode
*
)
realTable
;
}
...
...
@@ -839,7 +854,7 @@ SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOpti
return
(
SNode
*
)
setDbOptionFuncs
[
type
](
pCxt
,
(
SDatabaseOptions
*
)
pOptions
,
pVal
);
}
SNode
*
createCreateDatabaseStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pDbName
,
SNode
*
pOptions
)
{
SNode
*
createCreateDatabaseStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SToken
*
pDbName
,
SNode
*
pOptions
)
{
if
(
!
checkDbName
(
pCxt
,
pDbName
,
false
))
{
return
NULL
;
}
...
...
@@ -851,7 +866,7 @@ SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, cons
return
(
SNode
*
)
pStmt
;
}
SNode
*
createDropDatabaseStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
const
SToken
*
pDbName
)
{
SNode
*
createDropDatabaseStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SToken
*
pDbName
)
{
if
(
!
checkDbName
(
pCxt
,
pDbName
,
false
))
{
return
NULL
;
}
...
...
@@ -862,7 +877,7 @@ SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, con
return
(
SNode
*
)
pStmt
;
}
SNode
*
createAlterDatabaseStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDbName
,
SNode
*
pOptions
)
{
SNode
*
createAlterDatabaseStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
SNode
*
pOptions
)
{
if
(
!
checkDbName
(
pCxt
,
pDbName
,
false
))
{
return
NULL
;
}
...
...
@@ -1031,7 +1046,10 @@ SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, const
return
(
SNode
*
)
pStmt
;
}
SNode
*
createUseDatabaseStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDbName
)
{
SNode
*
createUseDatabaseStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
)
{
if
(
!
checkDbName
(
pCxt
,
pDbName
,
false
))
{
return
NULL
;
}
SUseDatabaseStmt
*
pStmt
=
(
SUseDatabaseStmt
*
)
nodesMakeNode
(
QUERY_NODE_USE_DATABASE_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
strncpy
(
pStmt
->
dbName
,
pDbName
->
z
,
pDbName
->
n
);
...
...
@@ -1055,7 +1073,7 @@ SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, S
return
(
SNode
*
)
pStmt
;
}
SNode
*
createCreateUserStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pUserName
,
const
SToken
*
pPassword
)
{
SNode
*
createCreateUserStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pUserName
,
const
SToken
*
pPassword
)
{
char
password
[
TSDB_USET_PASSWORD_LEN
]
=
{
0
};
if
(
!
checkUserName
(
pCxt
,
pUserName
)
||
!
checkPassword
(
pCxt
,
pPassword
,
password
))
{
return
NULL
;
...
...
@@ -1067,7 +1085,7 @@ SNode* createCreateUserStmt(SAstCreateContext* pCxt, const SToken* pUserName, co
return
(
SNode
*
)
pStmt
;
}
SNode
*
createAlterUserStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pUserName
,
int8_t
alterType
,
const
SToken
*
pVal
)
{
SNode
*
createAlterUserStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pUserName
,
int8_t
alterType
,
const
SToken
*
pVal
)
{
if
(
!
checkUserName
(
pCxt
,
pUserName
))
{
return
NULL
;
}
...
...
@@ -1086,7 +1104,7 @@ SNode* createAlterUserStmt(SAstCreateContext* pCxt, const SToken* pUserName, int
return
(
SNode
*
)
pStmt
;
}
SNode
*
createDropUserStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pUserName
)
{
SNode
*
createDropUserStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pUserName
)
{
if
(
!
checkUserName
(
pCxt
,
pUserName
))
{
return
NULL
;
}
...
...
@@ -1142,7 +1160,7 @@ SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const
return
(
SNode
*
)
pStmt
;
}
SNode
*
createCreateIndexStmt
(
SAstCreateContext
*
pCxt
,
EIndexType
type
,
const
SToken
*
pIndexName
,
const
SToken
*
pTableName
,
SNodeList
*
pCols
,
SNode
*
pOptions
)
{
SNode
*
createCreateIndexStmt
(
SAstCreateContext
*
pCxt
,
EIndexType
type
,
SToken
*
pIndexName
,
SToken
*
pTableName
,
SNodeList
*
pCols
,
SNode
*
pOptions
)
{
if
(
!
checkIndexName
(
pCxt
,
pIndexName
)
||
!
checkTableName
(
pCxt
,
pTableName
))
{
return
NULL
;
}
...
...
@@ -1166,7 +1184,7 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt
return
(
SNode
*
)
pOptions
;
}
SNode
*
createDropIndexStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pIndexName
,
const
SToken
*
pTableName
)
{
SNode
*
createDropIndexStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pIndexName
,
SToken
*
pTableName
)
{
if
(
!
checkIndexName
(
pCxt
,
pIndexName
)
||
!
checkTableName
(
pCxt
,
pTableName
))
{
return
NULL
;
}
...
...
source/util/src/tutil.c
浏览文件 @
d6f294ac
...
...
@@ -233,7 +233,7 @@ char *strntolower(char *dst, const char *src, int32_t n) {
}
}
else
if
(
c
>=
'A'
&&
c
<=
'Z'
)
{
c
-=
'A'
-
'a'
;
}
else
if
(
c
==
'\''
||
c
==
'"'
)
{
}
else
if
(
c
==
'\''
||
c
==
'"'
||
c
==
'`'
)
{
quote
=
c
;
}
*
p
++
=
c
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录