Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a72fe775
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a72fe775
编写于
2月 14, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
serialize show req
上级
54584fd1
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
181 addition
and
79 deletion
+181
-79
include/common/tmsg.h
include/common/tmsg.h
+8
-3
source/common/src/tmsg.c
source/common/src/tmsg.c
+45
-1
source/dnode/mgmt/impl/test/sut/src/sut.cpp
source/dnode/mgmt/impl/test/sut/src/sut.cpp
+9
-5
source/dnode/mnode/impl/src/mndShow.c
source/dnode/mnode/impl/src/mndShow.c
+25
-20
source/dnode/mnode/impl/test/acct/acct.cpp
source/dnode/mnode/impl/test/acct/acct.cpp
+6
-3
source/dnode/mnode/impl/test/show/show.cpp
source/dnode/mnode/impl/test/show/show.cpp
+12
-8
source/libs/parser/inc/astToMsg.h
source/libs/parser/inc/astToMsg.h
+21
-7
source/libs/parser/src/astToMsg.c
source/libs/parser/src/astToMsg.c
+54
-29
source/libs/parser/src/dCDAstProcess.c
source/libs/parser/src/dCDAstProcess.c
+1
-3
未找到文件。
include/common/tmsg.h
浏览文件 @
a72fe775
...
...
@@ -275,6 +275,7 @@ typedef struct {
int32_t
tSerializeSMCreateStbReq
(
void
**
buf
,
SMCreateStbReq
*
pReq
);
void
*
tDeserializeSMCreateStbReq
(
void
*
buf
,
SMCreateStbReq
*
pReq
);
void
tFreeSMCreateStbReq
(
SMCreateStbReq
*
pReq
);
typedef
struct
{
char
name
[
TSDB_TABLE_FNAME_LEN
];
...
...
@@ -888,12 +889,16 @@ typedef struct {
* payloadLen is the length of payload
*/
typedef
struct
{
int
8
_t
type
;
int
32
_t
type
;
char
db
[
TSDB_DB_FNAME_LEN
];
int
16
_t
payloadLen
;
char
payload
[]
;
int
32
_t
payloadLen
;
char
*
payload
;
}
SShowReq
;
int32_t
tSerializeSShowReq
(
void
*
buf
,
int32_t
bufLen
,
SShowReq
*
pReq
);
int32_t
tDeserializeSShowReq
(
void
*
buf
,
int32_t
bufLen
,
SShowReq
*
pReq
);
void
tFreeSShowReq
(
SShowReq
*
pReq
);
typedef
struct
{
char
db
[
TSDB_DB_FNAME_LEN
];
int32_t
numOfVgroup
;
...
...
source/common/src/tmsg.c
浏览文件 @
a72fe775
...
...
@@ -440,6 +440,11 @@ void *tDeserializeSMCreateStbReq(void *buf, SMCreateStbReq *pReq) {
return
buf
;
}
void
tFreeSMCreateStbReq
(
SMCreateStbReq
*
pReq
)
{
taosArrayDestroy
(
pReq
->
pColumns
);
taosArrayDestroy
(
pReq
->
pTags
);
}
int32_t
tSerializeSMDropStbReq
(
void
**
buf
,
SMDropStbReq
*
pReq
)
{
int32_t
tlen
=
0
;
...
...
@@ -1469,4 +1474,43 @@ void tFreeSUseDbBatchRsp(SUseDbBatchRsp *pRsp) {
}
taosArrayDestroy
(
pRsp
->
pArray
);
}
\ No newline at end of file
}
int32_t
tSerializeSShowReq
(
void
*
buf
,
int32_t
bufLen
,
SShowReq
*
pReq
)
{
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
type
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
db
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
payloadLen
)
<
0
)
return
-
1
;
if
(
pReq
->
payloadLen
>
0
)
{
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
payload
)
<
0
)
return
-
1
;
}
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tCoderClear
(
&
encoder
);
return
tlen
;
}
int32_t
tDeserializeSShowReq
(
void
*
buf
,
int32_t
bufLen
,
SShowReq
*
pReq
)
{
SCoder
decoder
=
{
0
};
tCoderInit
(
&
decoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_DECODER
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
type
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
db
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
payloadLen
)
<
0
)
return
-
1
;
if
(
pReq
->
payloadLen
>
0
)
{
pReq
->
payload
=
malloc
(
pReq
->
payloadLen
);
if
(
pReq
->
payload
==
NULL
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
payload
)
<
0
)
return
-
1
;
}
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
return
0
;
}
void
tFreeSShowReq
(
SShowReq
*
pReq
)
{
free
(
pReq
->
payload
);
}
source/dnode/mgmt/impl/test/sut/src/sut.cpp
浏览文件 @
a72fe775
...
...
@@ -80,12 +80,16 @@ SRpcMsg* Testbase::SendReq(tmsg_t msgType, void* pCont, int32_t contLen) {
}
void
Testbase
::
SendShowMetaReq
(
int8_t
showType
,
const
char
*
db
)
{
int32_t
contLen
=
sizeof
(
SShowReq
);
SShowReq
*
pShow
=
(
SShowReq
*
)
rpcMallocCont
(
contLen
);
pShow
->
type
=
showType
;
strcpy
(
pShow
->
db
,
db
);
SShowReq
showReq
=
{
0
};
showReq
.
type
=
showType
;
//strcpy(showReq.db, db);
SRpcMsg
*
pRsp
=
SendReq
(
TDMT_MND_SHOW
,
pShow
,
contLen
);
int32_t
contLen
=
tSerializeSShowReq
(
NULL
,
0
,
&
showReq
);
char
*
pReq
=
(
char
*
)
rpcMallocCont
(
contLen
);
tSerializeSShowReq
(
pReq
,
contLen
,
&
showReq
);
tFreeSShowReq
(
&
showReq
);
SRpcMsg
*
pRsp
=
SendReq
(
TDMT_MND_SHOW
,
pReq
,
contLen
);
SShowRsp
*
pShowRsp
=
(
SShowRsp
*
)
pRsp
->
pCont
;
ASSERT
(
pShowRsp
!=
nullptr
);
...
...
source/dnode/mnode/impl/src/mndShow.c
浏览文件 @
a72fe775
...
...
@@ -118,27 +118,28 @@ static void mndReleaseShowObj(SShowObj *pShow, bool forceRemove) {
static
int32_t
mndProcessShowReq
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pMnode
;
SShowMgmt
*
pMgmt
=
&
pMnode
->
showMgmt
;
SShowReq
*
pShowReq
=
pReq
->
rpcMsg
.
pCont
;
int8_t
type
=
pShowReq
->
type
;
int16_t
payloadLen
=
htonl
(
pShowReq
->
payloadLen
);
int32_t
code
=
-
1
;
SShowReq
showReq
=
{
0
};
if
(
type
<=
TSDB_MGMT_TABLE_START
||
type
>=
TSDB_MGMT_TABLE_MAX
)
{
if
(
tDeserializeSShowReq
(
pReq
->
rpcMsg
.
pCont
,
pReq
->
rpcMsg
.
contLen
,
&
showReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
SHOW_OVER
;
}
if
(
showReq
.
type
<=
TSDB_MGMT_TABLE_START
||
showReq
.
type
>=
TSDB_MGMT_TABLE_MAX
)
{
terrno
=
TSDB_CODE_MND_INVALID_MSG_TYPE
;
mError
(
"failed to process show-meta req since %s"
,
terrstr
());
return
-
1
;
goto
SHOW_OVER
;
}
ShowMetaFp
metaFp
=
pMgmt
->
metaFps
[
type
];
ShowMetaFp
metaFp
=
pMgmt
->
metaFps
[
showReq
.
type
];
if
(
metaFp
==
NULL
)
{
terrno
=
TSDB_CODE_MND_INVALID_MSG_TYPE
;
mError
(
"failed to process show-meta req:%s since %s"
,
mndShowStr
(
type
),
terrstr
());
return
-
1
;
goto
SHOW_OVER
;
}
SShowObj
*
pShow
=
mndCreateShowObj
(
pMnode
,
pS
howReq
);
SShowObj
*
pShow
=
mndCreateShowObj
(
pMnode
,
&
s
howReq
);
if
(
pShow
==
NULL
)
{
mError
(
"failed to process show-meta req:%s since %s"
,
mndShowStr
(
type
),
terrstr
());
return
-
1
;
goto
SHOW_OVER
;
}
int32_t
size
=
sizeof
(
SShowRsp
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
+
TSDB_EXTRA_PAYLOAD_SIZE
;
...
...
@@ -146,26 +147,30 @@ static int32_t mndProcessShowReq(SMnodeMsg *pReq) {
if
(
pRsp
==
NULL
)
{
mndReleaseShowObj
(
pShow
,
true
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mError
(
"show:0x%"
PRIx64
", failed to process show-meta req:%s since malloc rsp error"
,
pShow
->
id
,
mndShowStr
(
type
));
return
-
1
;
goto
SHOW_OVER
;
}
int32_t
code
=
(
*
metaFp
)(
pReq
,
pShow
,
&
pRsp
->
tableMeta
);
mDebug
(
"show:0x%"
PRIx64
", get meta finished, numOfRows:%d cols:%d
type:%s, result:%s"
,
pShow
->
id
,
pShow
->
numOfRows
,
pShow
->
numOf
Columns
,
mndShowStr
(
type
),
tstrerror
(
code
));
code
=
(
*
metaFp
)(
pReq
,
pShow
,
&
pRsp
->
tableMeta
);
mDebug
(
"show:0x%"
PRIx64
", get meta finished, numOfRows:%d cols:%d
showReq.type:%s, result:%s"
,
pShow
->
id
,
pShow
->
numOf
Rows
,
pShow
->
numOfColumns
,
mndShowStr
(
showReq
.
type
),
tstrerror
(
code
));
if
(
code
==
TSDB_CODE_SUCCESS
)
{
pReq
->
contLen
=
sizeof
(
SShowRsp
)
+
sizeof
(
SSchema
)
*
pShow
->
numOfColumns
;
pReq
->
pCont
=
pRsp
;
pRsp
->
showId
=
htobe64
(
pShow
->
id
);
mndReleaseShowObj
(
pShow
,
false
);
return
TSDB_CODE_SUCCESS
;
}
else
{
rpcFreeCont
(
pRsp
);
mndReleaseShowObj
(
pShow
,
true
);
return
code
;
}
SHOW_OVER:
if
(
code
!=
0
)
{
mError
(
"failed to process show-meta req since %s"
,
terrstr
());
}
tFreeSShowReq
(
&
showReq
);
return
code
;
}
static
int32_t
mndProcessRetrieveReq
(
SMnodeMsg
*
pReq
)
{
...
...
source/dnode/mnode/impl/test/acct/acct.cpp
浏览文件 @
a72fe775
...
...
@@ -56,10 +56,13 @@ TEST_F(MndTestAcct, 03_Drop_Acct) {
}
TEST_F
(
MndTestAcct
,
04
_Show_Acct
)
{
int32_t
contLen
=
sizeof
(
SShowReq
);
SShowReq
showReq
=
{
0
};
showReq
.
type
=
TSDB_MGMT_TABLE_ACCT
;
SShowReq
*
pReq
=
(
SShowReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
type
=
TSDB_MGMT_TABLE_ACCT
;
int32_t
contLen
=
tSerializeSShowReq
(
NULL
,
0
,
&
showReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSShowReq
(
pReq
,
contLen
,
&
showReq
);
tFreeSShowReq
(
&
showReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_SHOW
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
...
source/dnode/mnode/impl/test/show/show.cpp
浏览文件 @
a72fe775
...
...
@@ -26,11 +26,13 @@ class MndTestShow : public ::testing::Test {
Testbase
MndTestShow
::
test
;
TEST_F
(
MndTestShow
,
01
_ShowMsg_InvalidMsgMax
)
{
int32_t
contLen
=
sizeof
(
SShowReq
);
SShowReq
showReq
=
{
0
};
showReq
.
type
=
TSDB_MGMT_TABLE_MAX
;
SShowReq
*
pReq
=
(
SShowReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
type
=
TSDB_MGMT_TABLE_MAX
;
strcpy
(
pReq
->
db
,
""
);
int32_t
contLen
=
tSerializeSShowReq
(
NULL
,
0
,
&
showReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSShowReq
(
pReq
,
contLen
,
&
showReq
);
tFreeSShowReq
(
&
showReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_SHOW
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
...
@@ -38,11 +40,13 @@ TEST_F(MndTestShow, 01_ShowMsg_InvalidMsgMax) {
}
TEST_F
(
MndTestShow
,
02
_ShowMsg_InvalidMsgStart
)
{
int32_t
contLen
=
sizeof
(
SShowReq
);
SShowReq
showReq
=
{
0
};
showReq
.
type
=
TSDB_MGMT_TABLE_START
;
SShowReq
*
pReq
=
(
SShowReq
*
)
rpcMallocCont
(
sizeof
(
SShowReq
));
pReq
->
type
=
TSDB_MGMT_TABLE_START
;
strcpy
(
pReq
->
db
,
""
);
int32_t
contLen
=
tSerializeSShowReq
(
NULL
,
0
,
&
showReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSShowReq
(
pReq
,
contLen
,
&
showReq
);
tFreeSShowReq
(
&
showReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_SHOW
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
...
source/libs/parser/inc/astToMsg.h
浏览文件 @
a72fe775
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_ASTTOMSG_H
#define TDENGINE_ASTTOMSG_H
#include "parserInt.h"
#include "tmsg.h"
char
*
buildUserManipulationMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
char
*
buildAcctManipulationMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
char
*
buildDropUserMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SShowReq
*
buildShowMsg
(
SShowInfo
*
pShowInfo
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
char
*
buildCreateDbMsg
(
SCreateDbInfo
*
pCreateDbInfo
,
int32_t
*
len
,
SParseContext
*
pCtx
,
SMsgBuf
*
pMsgBuf
);
char
*
buildCreateStbReq
(
SCreateTableSql
*
pCreateTableSql
,
int32_t
*
l
en
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
char
*
buildDropStableReq
(
SSqlInfo
*
pInfo
,
int32_t
*
l
en
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
char
*
buildCreateDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
l
en
,
SMsgBuf
*
pMsgBuf
);
char
*
buildDropDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
l
en
,
SMsgBuf
*
pMsgBuf
);
char
*
buildShowMsg
(
SShowInfo
*
pShowInfo
,
int32_t
*
outputLen
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
char
*
buildCreateDbMsg
(
SCreateDbInfo
*
pCreateDbInfo
,
int32_t
*
outputLen
,
SParseContext
*
pCtx
,
SMsgBuf
*
pMsgBuf
);
char
*
buildCreateStbReq
(
SCreateTableSql
*
pCreateTableSql
,
int32_t
*
outputL
en
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
char
*
buildDropStableReq
(
SSqlInfo
*
pInfo
,
int32_t
*
outputL
en
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
char
*
buildCreateDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputL
en
,
SMsgBuf
*
pMsgBuf
);
char
*
buildDropDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputL
en
,
SMsgBuf
*
pMsgBuf
);
#endif // TDENGINE_ASTTOMSG_H
source/libs/parser/src/astToMsg.c
浏览文件 @
a72fe775
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "astGenerator.h"
#include "parserInt.h"
#include "parserUtil.h"
...
...
@@ -11,7 +26,7 @@ char* buildUserManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id,
createReq
.
superUser
=
(
int8_t
)
pUser
->
type
;
if
(
pUser
->
type
==
TSDB_ALTER_USER_PRIVILEGES
)
{
//
pMsg->privilege = (char)pCmd->count;
// pMsg->privilege = (char)pCmd->count;
}
else
{
strncpy
(
createReq
.
pass
,
pUser
->
passwd
.
z
,
pUser
->
passwd
.
n
);
}
...
...
@@ -71,7 +86,7 @@ char* buildAcctManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id,
return
pReq
;
}
char
*
buildDropUserMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
msg
Len
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgBufLen
)
{
char
*
buildDropUserMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
output
Len
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgBufLen
)
{
SDropUserReq
dropReq
=
{
0
};
SToken
*
pName
=
taosArrayGet
(
pInfo
->
pMiscInfo
->
a
,
0
);
...
...
@@ -89,30 +104,26 @@ char* buildDropUserMsg(SSqlInfo* pInfo, int32_t* msgLen, int64_t id, char* msgBu
}
tSerializeSDropUserReq
(
pReq
,
tlen
,
&
dropReq
);
*
msg
Len
=
tlen
;
*
output
Len
=
tlen
;
return
pReq
;
}
SShowReq
*
buildShowMsg
(
SShowInfo
*
pShowInfo
,
SParseContext
*
pCtx
,
SMsgBuf
*
pMsgBuf
)
{
SShowReq
*
pShowMsg
=
calloc
(
1
,
sizeof
(
SShowReq
));
if
(
pShowMsg
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
pShowMsg
;
}
char
*
buildShowMsg
(
SShowInfo
*
pShowInfo
,
int32_t
*
outputLen
,
SParseContext
*
pCtx
,
SMsgBuf
*
pMsgBuf
)
{
SShowReq
showReq
=
{.
type
=
pShowInfo
->
showType
};
pShowMsg
->
type
=
pShowInfo
->
showType
;
if
(
pShowInfo
->
showType
!=
TSDB_MGMT_TABLE_VNODES
)
{
SToken
*
pPattern
=
&
pShowInfo
->
pattern
;
if
(
pPattern
->
type
>
0
)
{
// only show tables support wildcard query
strncpy
(
pShowMsg
->
payload
,
pPattern
->
z
,
pPattern
->
n
);
pShowMsg
->
payloadLen
=
htons
(
pPattern
->
n
);
showReq
.
payloadLen
=
pPattern
->
n
;
showReq
.
payload
=
malloc
(
showReq
.
payloadLen
);
strncpy
(
showReq
.
payload
,
pPattern
->
z
,
pPattern
->
n
);
}
}
else
{
SToken
*
pEpAddr
=
&
pShowInfo
->
prefix
;
assert
(
pEpAddr
->
n
>
0
&&
pEpAddr
->
type
>
0
);
s
trncpy
(
pShowMsg
->
payload
,
pEpAddr
->
z
,
pEpAddr
->
n
);
pShowMsg
->
payloadLen
=
htons
(
pEpAddr
->
n
);
showReq
.
payloadLen
=
pEpAddr
->
n
;
s
howReq
.
payload
=
malloc
(
showReq
.
payloadLe
n
);
strncpy
(
showReq
.
payload
,
pEpAddr
->
z
,
pEpAddr
->
n
);
}
if
(
pShowInfo
->
showType
==
TSDB_MGMT_TABLE_STB
||
pShowInfo
->
showType
==
TSDB_MGMT_TABLE_VGROUP
)
{
...
...
@@ -121,22 +132,32 @@ SShowReq* buildShowMsg(SShowInfo* pShowInfo, SParseContext* pCtx, SMsgBuf* pMsgB
if
(
pShowInfo
->
prefix
.
n
>
0
)
{
if
(
pShowInfo
->
prefix
.
n
>=
TSDB_DB_FNAME_LEN
)
{
terrno
=
buildInvalidOperationMsg
(
pMsgBuf
,
"prefix name is too long"
);
t
free
(
pShowMsg
);
t
FreeSShowReq
(
&
showReq
);
return
NULL
;
}
tNameSetDbName
(
&
n
,
pCtx
->
acctId
,
pShowInfo
->
prefix
.
z
,
pShowInfo
->
prefix
.
n
);
}
else
if
(
pCtx
->
db
==
NULL
||
strlen
(
pCtx
->
db
)
==
0
)
{
terrno
=
buildInvalidOperationMsg
(
pMsgBuf
,
"database is not specified"
);
t
free
(
pShowMsg
);
t
FreeSShowReq
(
&
showReq
);
return
NULL
;
}
else
{
tNameSetDbName
(
&
n
,
pCtx
->
acctId
,
pCtx
->
db
,
strlen
(
pCtx
->
db
));
}
tNameGetFullDbName
(
&
n
,
pShowMsg
->
db
);
tNameGetFullDbName
(
&
n
,
showReq
.
db
);
}
int32_t
tlen
=
tSerializeSShowReq
(
NULL
,
0
,
&
showReq
);
void
*
pReq
=
malloc
(
tlen
);
if
(
pReq
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
return
pShowMsg
;
tSerializeSShowReq
(
pReq
,
tlen
,
&
showReq
);
tFreeSShowReq
(
&
showReq
);
*
outputLen
=
tlen
;
return
pReq
;
}
static
int32_t
setKeepOption
(
SCreateDbReq
*
pMsg
,
const
SCreateDbInfo
*
pCreateDb
,
SMsgBuf
*
pMsgBuf
)
{
...
...
@@ -330,7 +351,7 @@ static int32_t doCheckDbOptions(SCreateDbReq* pCreate, SMsgBuf* pMsgBuf) {
return
TSDB_CODE_SUCCESS
;
}
char
*
buildCreateDbMsg
(
SCreateDbInfo
*
pCreateDbInfo
,
int32_t
*
l
en
,
SParseContext
*
pCtx
,
SMsgBuf
*
pMsgBuf
)
{
char
*
buildCreateDbMsg
(
SCreateDbInfo
*
pCreateDbInfo
,
int32_t
*
outputL
en
,
SParseContext
*
pCtx
,
SMsgBuf
*
pMsgBuf
)
{
SCreateDbReq
createReq
=
{
0
};
if
(
setDbOptions
(
&
createReq
,
pCreateDbInfo
,
pMsgBuf
)
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -360,11 +381,12 @@ char* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, int32_t* len, SParseContext
}
tSerializeSCreateDbReq
(
pReq
,
tlen
,
&
createReq
);
*
l
en
=
tlen
;
*
outputL
en
=
tlen
;
return
pReq
;
}
char
*
buildCreateStbReq
(
SCreateTableSql
*
pCreateTableSql
,
int32_t
*
len
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
)
{
char
*
buildCreateStbReq
(
SCreateTableSql
*
pCreateTableSql
,
int32_t
*
outputLen
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
)
{
SMCreateStbReq
createReq
=
{
0
};
createReq
.
igExists
=
pCreateTableSql
->
existCheck
?
1
:
0
;
createReq
.
pColumns
=
pCreateTableSql
->
colInfo
.
pColumns
;
...
...
@@ -374,11 +396,13 @@ char* buildCreateStbReq(SCreateTableSql* pCreateTableSql, int32_t* len, SParseCo
SName
n
=
{
0
};
if
(
createSName
(
&
n
,
&
pCreateTableSql
->
name
,
pParseCtx
,
pMsgBuf
)
!=
0
)
{
tFreeSMCreateStbReq
(
&
createReq
);
return
NULL
;
}
if
(
tNameExtractFullName
(
&
n
,
createReq
.
name
)
!=
0
)
{
buildInvalidOperationMsg
(
pMsgBuf
,
"invalid table name or database not specified"
);
tFreeSMCreateStbReq
(
&
createReq
);
return
NULL
;
}
...
...
@@ -391,11 +415,12 @@ char* buildCreateStbReq(SCreateTableSql* pCreateTableSql, int32_t* len, SParseCo
void
*
pBuf
=
pReq
;
tSerializeSMCreateStbReq
(
&
pBuf
,
&
createReq
);
*
len
=
tlen
;
tFreeSMCreateStbReq
(
&
createReq
);
*
outputLen
=
tlen
;
return
pReq
;
}
char
*
buildDropStableReq
(
SSqlInfo
*
pInfo
,
int32_t
*
l
en
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
)
{
char
*
buildDropStableReq
(
SSqlInfo
*
pInfo
,
int32_t
*
outputL
en
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
)
{
SToken
*
tableName
=
taosArrayGet
(
pInfo
->
pMiscInfo
->
a
,
0
);
SName
name
=
{
0
};
...
...
@@ -420,11 +445,11 @@ char* buildDropStableReq(SSqlInfo* pInfo, int32_t* len, SParseContext* pParseCtx
void
*
pBuf
=
pReq
;
tSerializeSMDropStbReq
(
&
pBuf
,
&
dropReq
);
*
l
en
=
tlen
;
*
outputL
en
=
tlen
;
return
pReq
;
}
char
*
buildCreateDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
l
en
,
SMsgBuf
*
pMsgBuf
)
{
char
*
buildCreateDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputL
en
,
SMsgBuf
*
pMsgBuf
)
{
const
char
*
msg1
=
"invalid host name (name too long, maximum length 128)"
;
const
char
*
msg2
=
"dnode name can not be string"
;
const
char
*
msg3
=
"port should be an integer that is less than 65535 and greater than 0"
;
...
...
@@ -469,11 +494,11 @@ char* buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMsgBuf) {
}
tSerializeSCreateDnodeReq
(
pReq
,
tlen
,
&
createReq
);
*
l
en
=
tlen
;
*
outputL
en
=
tlen
;
return
pReq
;
}
char
*
buildDropDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
l
en
,
SMsgBuf
*
pMsgBuf
)
{
char
*
buildDropDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputL
en
,
SMsgBuf
*
pMsgBuf
)
{
SDropDnodeReq
dropReq
=
{
0
};
SToken
*
pzName
=
taosArrayGet
(
pInfo
->
pMiscInfo
->
a
,
0
);
...
...
@@ -494,6 +519,6 @@ char* buildDropDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMsgBuf) {
}
tSerializeSDropDnodeReq
(
pReq
,
tlen
,
&
dropReq
);
*
l
en
=
tlen
;
*
outputL
en
=
tlen
;
return
pReq
;
}
\ No newline at end of file
source/libs/parser/src/dCDAstProcess.c
浏览文件 @
a72fe775
...
...
@@ -114,12 +114,10 @@ static int32_t setShowInfo(SShowInfo* pShowInfo, SParseContext* pCtx, void** out
}
*
pEpSet
=
pCtx
->
mgmtEpSet
;
*
output
=
buildShowMsg
(
pShowInfo
,
pCtx
,
pMsgBuf
);
*
output
=
buildShowMsg
(
pShowInfo
,
outputLen
,
pCtx
,
pMsgBuf
);
if
(
*
output
==
NULL
)
{
return
terrno
;
}
*
outputLen
=
sizeof
(
SShowReq
)
/* + htons(pShowMsg->payloadLen)*/
;
}
return
TSDB_CODE_SUCCESS
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录