Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6307883f
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看板
提交
6307883f
编写于
12月 23, 2021
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-12450 perfect parser interface
上级
1d62d95e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
18 addition
and
15 deletion
+18
-15
include/libs/parser/parsenodes.h
include/libs/parser/parsenodes.h
+1
-0
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+2
-2
source/libs/parser/src/astValidate.c
source/libs/parser/src/astValidate.c
+9
-9
source/libs/parser/src/parser.c
source/libs/parser/src/parser.c
+6
-4
未找到文件。
include/libs/parser/parsenodes.h
浏览文件 @
6307883f
...
...
@@ -162,6 +162,7 @@ typedef struct SInsertStmtInfo {
typedef
struct
SDclStmtInfo
{
int16_t
nodeType
;
int16_t
msgType
;
char
*
pMsg
;
int32_t
msgLen
;
}
SDclStmtInfo
;
...
...
source/client/src/clientImpl.c
浏览文件 @
6307883f
...
...
@@ -155,13 +155,13 @@ TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) {
int32_t
code
=
qParseQuerySql
(
&
cxt
,
&
pQuery
);
if
(
qIsDclQuery
(
pQuery
))
{
SDclStmtInfo
*
pDcl
=
(
SDclStmtInfo
*
)
pQuery
;
pRequest
->
type
=
pDcl
->
node
Type
;
pRequest
->
type
=
pDcl
->
msg
Type
;
pRequest
->
body
.
requestMsg
=
(
SReqMsgInfo
){.
pMsg
=
pDcl
->
pMsg
,
.
len
=
pDcl
->
msgLen
};
SRequestMsgBody
body
=
buildRequestMsgImpl
(
pRequest
);
SEpSet
*
pEpSet
=
&
pTscObj
->
pAppInfo
->
mgmtEp
.
epSet
;
if
(
pDcl
->
node
Type
==
TSDB_MSG_TYPE_CREATE_TABLE
)
{
if
(
pDcl
->
msg
Type
==
TSDB_MSG_TYPE_CREATE_TABLE
)
{
struct
SCatalog
*
pCatalog
=
NULL
;
char
buf
[
12
]
=
{
0
};
...
...
source/libs/parser/src/astValidate.c
浏览文件 @
6307883f
...
...
@@ -4358,7 +4358,7 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStm
}
pDcl
->
pMsg
=
(
char
*
)
buildUserManipulationMsg
(
pInfo
,
&
pDcl
->
msgLen
,
pCtx
->
requestId
,
msgBuf
,
msgBufLen
);
pDcl
->
node
Type
=
(
pInfo
->
type
==
TSDB_SQL_CREATE_USER
)
?
TSDB_MSG_TYPE_CREATE_USER
:
TSDB_MSG_TYPE_ALTER_USER
;
pDcl
->
msg
Type
=
(
pInfo
->
type
==
TSDB_SQL_CREATE_USER
)
?
TSDB_MSG_TYPE_CREATE_USER
:
TSDB_MSG_TYPE_ALTER_USER
;
break
;
}
...
...
@@ -4395,20 +4395,20 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStm
}
pDcl
->
pMsg
=
(
char
*
)
buildAcctManipulationMsg
(
pInfo
,
&
pDcl
->
msgLen
,
pCtx
->
requestId
,
msgBuf
,
msgBufLen
);
pDcl
->
node
Type
=
(
pInfo
->
type
==
TSDB_SQL_CREATE_ACCT
)
?
TSDB_MSG_TYPE_CREATE_ACCT
:
TSDB_MSG_TYPE_ALTER_ACCT
;
pDcl
->
msg
Type
=
(
pInfo
->
type
==
TSDB_SQL_CREATE_ACCT
)
?
TSDB_MSG_TYPE_CREATE_ACCT
:
TSDB_MSG_TYPE_ALTER_ACCT
;
break
;
}
case
TSDB_SQL_DROP_ACCT
:
case
TSDB_SQL_DROP_USER
:
{
pDcl
->
pMsg
=
(
char
*
)
buildDropUserMsg
(
pInfo
,
&
pDcl
->
msgLen
,
pCtx
->
requestId
,
msgBuf
,
msgBufLen
);
pDcl
->
node
Type
=
(
pInfo
->
type
==
TSDB_SQL_DROP_ACCT
)
?
TSDB_MSG_TYPE_DROP_ACCT
:
TSDB_MSG_TYPE_DROP_USER
;
pDcl
->
msg
Type
=
(
pInfo
->
type
==
TSDB_SQL_DROP_ACCT
)
?
TSDB_MSG_TYPE_DROP_ACCT
:
TSDB_MSG_TYPE_DROP_USER
;
break
;
}
case
TSDB_SQL_SHOW
:
{
code
=
setShowInfo
(
&
pInfo
->
pMiscInfo
->
showOpt
,
pCtx
,
(
void
**
)
&
pDcl
->
pMsg
,
&
pDcl
->
msgLen
,
pMsgBuf
);
pDcl
->
node
Type
=
TSDB_MSG_TYPE_SHOW
;
pDcl
->
msg
Type
=
TSDB_MSG_TYPE_SHOW
;
break
;
}
...
...
@@ -4431,7 +4431,7 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStm
pDcl
->
pMsg
=
(
char
*
)
pUseDbMsg
;
pDcl
->
msgLen
=
sizeof
(
SUseDbMsg
);
pDcl
->
node
Type
=
TSDB_MSG_TYPE_USE_DB
;
pDcl
->
msg
Type
=
TSDB_MSG_TYPE_USE_DB
;
break
;
}
...
...
@@ -4461,7 +4461,7 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStm
pDcl
->
pMsg
=
(
char
*
)
pCreateMsg
;
pDcl
->
msgLen
=
sizeof
(
SCreateDbMsg
);
pDcl
->
node
Type
=
(
pInfo
->
type
==
TSDB_SQL_CREATE_DB
)
?
TSDB_MSG_TYPE_CREATE_DB
:
TSDB_MSG_TYPE_ALTER_DB
;
pDcl
->
msg
Type
=
(
pInfo
->
type
==
TSDB_SQL_CREATE_DB
)
?
TSDB_MSG_TYPE_CREATE_DB
:
TSDB_MSG_TYPE_ALTER_DB
;
break
;
}
...
...
@@ -4483,7 +4483,7 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStm
pDropDbMsg
->
ignoreNotExists
=
pInfo
->
pMiscInfo
->
existsCheck
?
1
:
0
;
assert
(
code
==
TSDB_CODE_SUCCESS
&&
name
.
type
==
TSDB_DB_NAME_T
);
pDcl
->
node
Type
=
TSDB_MSG_TYPE_DROP_DB
;
pDcl
->
msg
Type
=
TSDB_MSG_TYPE_DROP_DB
;
pDcl
->
msgLen
=
sizeof
(
SDropDbMsg
);
pDcl
->
pMsg
=
(
char
*
)
pDropDbMsg
;
return
TSDB_CODE_SUCCESS
;
...
...
@@ -4497,7 +4497,7 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStm
return
code
;
}
pDcl
->
pMsg
=
(
char
*
)
buildCreateTableMsg
(
pCreateTable
,
&
pDcl
->
msgLen
,
pCtx
,
pMsgBuf
);
pDcl
->
node
Type
=
(
pCreateTable
->
type
==
TSQL_CREATE_TABLE
)
?
TSDB_MSG_TYPE_CREATE_TABLE
:
TSDB_MSG_TYPE_CREATE_STB
;
pDcl
->
msg
Type
=
(
pCreateTable
->
type
==
TSQL_CREATE_TABLE
)
?
TSDB_MSG_TYPE_CREATE_TABLE
:
TSDB_MSG_TYPE_CREATE_STB
;
}
else
if
(
pCreateTable
->
type
==
TSQL_CREATE_CTABLE
)
{
// if ((code = doCheckForCreateFromStable(pSql, pInfo)) != TSDB_CODE_SUCCESS) {
// return code;
...
...
@@ -4517,7 +4517,7 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStm
return
terrno
;
}
pDcl
->
node
Type
=
TSDB_MSG_TYPE_DROP_STB
;
pDcl
->
msg
Type
=
TSDB_MSG_TYPE_DROP_STB
;
return
TSDB_CODE_SUCCESS
;
break
;
}
...
...
source/libs/parser/src/parser.c
浏览文件 @
6307883f
...
...
@@ -32,10 +32,7 @@ bool isInsertSql(const char* pStr, size_t length) {
}
bool
qIsDclQuery
(
const
SQueryNode
*
pQuery
)
{
int16_t
type
=
pQuery
->
type
;
return
type
==
TSDB_SQL_CREATE_USER
||
type
==
TSDB_SQL_SHOW
||
type
==
TSDB_SQL_DROP_USER
||
type
==
TSDB_SQL_DROP_ACCT
||
type
==
TSDB_SQL_CREATE_DB
||
type
==
TSDB_SQL_CREATE_ACCT
||
type
==
TSDB_SQL_CREATE_TABLE
||
type
==
TSDB_SQL_USE_DB
;
return
TSDB_SQL_INSERT
!=
pQuery
->
type
&&
TSDB_SQL_SELECT
!=
pQuery
->
type
;
}
int32_t
parseQuerySql
(
SParseContext
*
pCxt
,
SQueryNode
**
pQuery
)
{
...
...
@@ -48,6 +45,11 @@ int32_t parseQuerySql(SParseContext* pCxt, SQueryNode** pQuery) {
if
(
!
isDqlSqlStatement
(
&
info
))
{
SDclStmtInfo
*
pDcl
=
calloc
(
1
,
sizeof
(
SQueryStmtInfo
));
if
(
NULL
==
pDcl
)
{
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
// set correct error code.
return
terrno
;
}
pDcl
->
nodeType
=
info
.
type
;
int32_t
code
=
qParserValidateDclSqlNode
(
&
info
,
&
pCxt
->
ctx
,
pDcl
,
pCxt
->
pMsg
,
pCxt
->
msgLen
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
*
pQuery
=
(
SQueryNode
*
)
pDcl
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录