Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0f940389
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看板
未验证
提交
0f940389
编写于
12月 20, 2021
作者:
S
Shengliang Guan
提交者:
GitHub
12月 20, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #9223 from taosdata/feature/3.0_liaohj
Feature/3.0 liaohj
上级
ca2191d6
b710e581
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
95 addition
and
36 deletion
+95
-36
include/common/tmsgtype.h
include/common/tmsgtype.h
+2
-2
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+1
-1
source/client/src/clientMsgHandler.c
source/client/src/clientMsgHandler.c
+15
-2
source/client/src/tscEnv.c
source/client/src/tscEnv.c
+0
-1
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+43
-17
source/libs/parser/inc/astToMsg.h
source/libs/parser/inc/astToMsg.h
+2
-1
source/libs/parser/src/astToMsg.c
source/libs/parser/src/astToMsg.c
+20
-3
source/libs/parser/src/astValidate.c
source/libs/parser/src/astValidate.c
+7
-1
source/libs/parser/src/queryInfoUtil.c
source/libs/parser/src/queryInfoUtil.c
+1
-4
source/libs/parser/test/mockCatalogService.cpp
source/libs/parser/test/mockCatalogService.cpp
+3
-3
source/libs/qcom/src/querymsg.c
source/libs/qcom/src/querymsg.c
+1
-1
未找到文件。
include/common/tmsgtype.h
浏览文件 @
0f940389
...
...
@@ -35,7 +35,7 @@ enum {
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_SELECT
,
"select"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_FETCH
,
"fetch"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_INSERT
,
"insert"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_UPDATE_TAG
S
_VAL
,
"update-tag-val"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_UPDATE_TAG_VAL
,
"update-tag-val"
)
// the SQL below is for mgmt node
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_MGMT
,
"mgmt"
)
...
...
@@ -54,7 +54,7 @@ enum {
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_ALTER_TABLE
,
"alter-table"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_ALTER_DB
,
"alter-db"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_SYNC_DB_REPLICA
,
"sync db-replica"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_SYNC_DB_REPLICA
,
"sync db-replica"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_CREATE_MNODE
,
"create-mnode"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_DROP_MNODE
,
"drop-mnode"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_CREATE_DNODE
,
"create-dnode"
)
...
...
source/client/src/clientImpl.c
浏览文件 @
0f940389
...
...
@@ -153,7 +153,7 @@ TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) {
void
*
output
=
NULL
;
int32_t
outputLen
=
0
;
code
=
qParseQuerySql
(
pRequest
->
sqlstr
,
sqlLen
,
pRequest
->
requestId
,
&
type
,
&
output
,
&
outputLen
,
pRequest
->
msgBuf
,
ERROR_MSG_BUF_DEFAULT_SIZE
);
if
(
type
==
TSDB_SQL_CREATE_USER
||
type
==
TSDB_SQL_SHOW
||
type
==
TSDB_SQL_DROP_USER
||
type
==
TSDB_SQL_
CREATE_DB
)
{
if
(
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
)
{
pRequest
->
type
=
type
;
pRequest
->
body
.
param
=
output
;
pRequest
->
body
.
paramLen
=
outputLen
;
...
...
source/client/src/clientMsgHandler.c
浏览文件 @
0f940389
...
...
@@ -407,7 +407,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
}
// single table query error need to be handled here.
if ((cmd == TSDB_SQL_SELECT || cmd == TSDB_SQL_UPDATE_TAG
S
_VAL) &&
if ((cmd == TSDB_SQL_SELECT || cmd == TSDB_SQL_UPDATE_TAG_VAL) &&
(((rpcMsg->code == TSDB_CODE_TDB_INVALID_TABLE_ID || rpcMsg->code == TSDB_CODE_VND_INVALID_VGROUP_ID)) ||
rpcMsg->code == TSDB_CODE_RPC_NETWORK_UNAVAIL || rpcMsg->code == TSDB_CODE_APP_NOT_READY)) {
...
...
@@ -3176,6 +3176,15 @@ int32_t doBuildMsgSupp(SRequestObj *pRequest, SRequestMsgBody* pMsgBody) {
case
TSDB_SQL_CREATE_USER
:
pMsgBody
->
msgType
=
TSDB_MSG_TYPE_CREATE_USER
;
break
;
case
TSDB_SQL_DROP_USER
:
pMsgBody
->
msgType
=
TSDB_MSG_TYPE_DROP_USER
;
break
;
case
TSDB_SQL_CREATE_ACCT
:
pMsgBody
->
msgType
=
TSDB_MSG_TYPE_CREATE_ACCT
;
break
;
case
TSDB_SQL_DROP_ACCT
:
pMsgBody
->
msgType
=
TSDB_MSG_TYPE_DROP_ACCT
;
break
;
case
TSDB_SQL_CREATE_DB
:
{
pMsgBody
->
msgType
=
TSDB_MSG_TYPE_CREATE_DB
;
...
...
@@ -3328,7 +3337,7 @@ void initMsgHandleFp() {
tscBuildMsg[TSDB_SQL_DROP_DNODE] = tscBuildDropDnodeMsg;
tscBuildMsg[TSDB_SQL_CFG_DNODE] = tscBuildCfgDnodeMsg;
tscBuildMsg[TSDB_SQL_ALTER_TABLE] = tscBuildAlterTableMsg;
tscBuildMsg[TSDB_SQL_UPDATE_TAG
S
_VAL] = tscBuildUpdateTagMsg;
tscBuildMsg[TSDB_SQL_UPDATE_TAG_VAL] = tscBuildUpdateTagMsg;
tscBuildMsg[TSDB_SQL_ALTER_DB] = tscAlterDbMsg;
tscBuildMsg[TSDB_SQL_COMPACT_VNODE] = tscBuildCompactMsg;
...
...
@@ -3383,6 +3392,10 @@ void initMsgHandleFp() {
handleRequestRspFp
[
TSDB_SQL_CONNECT
]
=
processConnectRsp
;
buildRequestMsgFp
[
TSDB_SQL_CREATE_USER
]
=
doBuildMsgSupp
;
buildRequestMsgFp
[
TSDB_SQL_DROP_USER
]
=
doBuildMsgSupp
;
buildRequestMsgFp
[
TSDB_SQL_CREATE_ACCT
]
=
doBuildMsgSupp
;
buildRequestMsgFp
[
TSDB_SQL_DROP_ACCT
]
=
doBuildMsgSupp
;
buildRequestMsgFp
[
TSDB_SQL_SHOW
]
=
doBuildMsgSupp
;
handleRequestRspFp
[
TSDB_SQL_SHOW
]
=
processShowRsp
;
...
...
source/client/src/tscEnv.c
浏览文件 @
0f940389
...
...
@@ -189,7 +189,6 @@ static void doDestroyRequest(void* p) {
tfree
(
pRequest
->
pInfo
);
if
(
pRequest
->
body
.
pResInfo
!=
NULL
)
{
tfree
(
pRequest
->
body
.
pResInfo
->
pData
);
tfree
(
pRequest
->
body
.
pResInfo
->
pMsg
);
tfree
(
pRequest
->
body
.
pResInfo
);
}
...
...
source/client/test/clientTests.cpp
浏览文件 @
0f940389
...
...
@@ -40,13 +40,13 @@ TEST(testCase, driverInit_Test) {
TEST
(
testCase
,
connect_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"ubuntu"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
//
assert(pConn != NULL);
taos_close
(
pConn
);
}
TEST
(
testCase
,
create_user_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"ubuntu"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
//
assert(pConn != NULL);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"create user abc pass 'abc'"
);
if
(
taos_errno
(
pRes
)
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -57,23 +57,36 @@ TEST(testCase, create_user_Test) {
taos_close
(
pConn
);
}
//TEST(testCase, drop_user_Test) {
// TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
// assert(pConn != NULL);
//
// TAOS_RES* pRes = taos_query(pConn, "drop user abc");
// if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
// printf("failed to create user, reason:%s\n", taos_errstr(pRes));
// }
//
// taos_free_result(pRes);
// taos_close(pConn);
//}
TEST
(
testCase
,
create_account_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"ubuntu"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
TEST
(
testCase
,
show_user_Test
)
{
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"create account aabc pass 'abc'"
);
if
(
taos_errno
(
pRes
)
!=
TSDB_CODE_SUCCESS
)
{
printf
(
"failed to create user, reason:%s
\n
"
,
taos_errstr
(
pRes
));
}
taos_free_result
(
pRes
);
taos_close
(
pConn
);
}
TEST
(
testCase
,
drop_account_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"ubuntu"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"drop account aabc"
);
if
(
taos_errno
(
pRes
)
!=
TSDB_CODE_SUCCESS
)
{
printf
(
"failed to create user, reason:%s
\n
"
,
taos_errstr
(
pRes
));
}
taos_free_result
(
pRes
);
taos_close
(
pConn
);
}
TEST
(
testCase
,
show_user_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"ubuntu"
,
"root"
,
"taosdata"
,
NULL
,
0
);
// assert(pConn != NULL);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"show users"
);
TAOS_ROW
pRow
=
NULL
;
...
...
@@ -89,10 +102,23 @@ TEST(testCase, show_user_Test) {
taos_close
(
pConn
);
}
TEST
(
testCase
,
show_db
_Test
)
{
TEST
(
testCase
,
drop_user
_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"ubuntu"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"drop user abc"
);
if
(
taos_errno
(
pRes
)
!=
TSDB_CODE_SUCCESS
)
{
printf
(
"failed to create user, reason:%s
\n
"
,
taos_errstr
(
pRes
));
}
taos_free_result
(
pRes
);
taos_close
(
pConn
);
}
TEST
(
testCase
,
show_db_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"ubuntu"
,
"root"
,
"taosdata"
,
NULL
,
0
);
// assert(pConn != NULL);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"show databases"
);
TAOS_ROW
pRow
=
NULL
;
...
...
@@ -112,7 +138,7 @@ TEST(testCase, create_db_Test) {
TAOS
*
pConn
=
taos_connect
(
"ubuntu"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"create database abc"
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"create database abc
1
"
);
TAOS_FIELD
*
pFields
=
taos_fetch_fields
(
pRes
);
ASSERT_TRUE
(
pFields
==
NULL
);
...
...
source/libs/parser/inc/astToMsg.h
浏览文件 @
0f940389
...
...
@@ -4,7 +4,8 @@
#include "parserInt.h"
#include "taosmsg.h"
SCreateUserMsg
*
buildUserManipulationMsg
(
SSqlInfo
*
pInfo
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SCreateUserMsg
*
buildUserManipulationMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SDropUserMsg
*
buildDropUserMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SShowMsg
*
buildShowMsg
(
SShowInfo
*
pShowInfo
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SCreateDbMsg
*
buildCreateDbMsg
(
SCreateDbInfo
*
pCreateDbInfo
,
char
*
msgBuf
,
int32_t
msgLen
);
...
...
source/libs/parser/src/astToMsg.c
浏览文件 @
0f940389
#include "parserInt.h"
#include "parserUtil.h"
SCreateUserMsg
*
buildUserManipulationMsg
(
SSqlInfo
*
pInfo
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
)
{
SCreateUserMsg
*
buildUserManipulationMsg
(
SSqlInfo
*
pInfo
,
int
32_t
*
outputLen
,
int
64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
)
{
SCreateUserMsg
*
pMsg
=
(
SCreateUserMsg
*
)
calloc
(
1
,
sizeof
(
SCreateUserMsg
));
if
(
pMsg
==
NULL
)
{
// tscError("0x%" PRIx64 " failed to malloc for query msg", id);
...
...
@@ -20,6 +20,24 @@ SCreateUserMsg* buildUserManipulationMsg(SSqlInfo* pInfo, int64_t id, char* msgB
strncpy
(
pMsg
->
pass
,
pUser
->
passwd
.
z
,
pUser
->
passwd
.
n
);
}
*
outputLen
=
sizeof
(
SUserInfo
);
return
pMsg
;
}
SDropUserMsg
*
buildDropUserMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
msgLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgBufLen
)
{
SToken
*
pName
=
taosArrayGet
(
pInfo
->
pMiscInfo
->
a
,
0
);
if
(
pName
->
n
>=
TSDB_USER_LEN
)
{
return
NULL
;
}
SDropUserMsg
*
pMsg
=
calloc
(
1
,
sizeof
(
SDropUserMsg
));
if
(
pMsg
==
NULL
)
{
return
NULL
;
}
strncpy
(
pMsg
->
user
,
pName
->
z
,
pName
->
n
);
*
msgLen
=
sizeof
(
SDropUserMsg
);
return
pMsg
;
}
...
...
@@ -89,7 +107,7 @@ static int32_t setTimePrecision(SCreateDbMsg* pMsg, const SCreateDbInfo* pCreate
pMsg
->
precision
=
TSDB_TIME_PRECISION_MILLI
;
// millisecond by default
SToken
*
pToken
=
&
pCreateDbInfo
->
precision
;
SToken
*
pToken
=
(
SToken
*
)
&
pCreateDbInfo
->
precision
;
if
(
pToken
->
n
>
0
)
{
pToken
->
n
=
strdequote
(
pToken
->
z
);
...
...
@@ -141,7 +159,6 @@ int32_t setDbOptions(SCreateDbMsg* pCreateDbMsg, const SCreateDbInfo* pCreateDbS
// todo configurable
pCreateDbMsg
->
numOfVgroups
=
htonl
(
2
);
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/parser/src/astValidate.c
浏览文件 @
0f940389
...
...
@@ -4224,7 +4224,13 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, int64_t id, void** output, in
}
}
*
output
=
buildUserManipulationMsg
(
pInfo
,
id
,
msgBuf
,
msgBufLen
);
*
output
=
buildUserManipulationMsg
(
pInfo
,
outputLen
,
id
,
msgBuf
,
msgBufLen
);
break
;
}
case
TSDB_SQL_DROP_ACCT
:
case
TSDB_SQL_DROP_USER
:
{
*
output
=
buildDropUserMsg
(
pInfo
,
outputLen
,
id
,
msgBuf
,
msgBufLen
);
break
;
}
...
...
source/libs/parser/src/queryInfoUtil.c
浏览文件 @
0f940389
#include "os.h"
#include "queryInfoUtil.h"
#include <function.h>
#include "astGenerator.h"
#include "function.h"
#include "os.h"
#include "parser.h"
#include "parserInt.h"
#include "parserUtil.h"
static
struct
SSchema
_s
=
{
...
...
source/libs/parser/test/mockCatalogService.cpp
浏览文件 @
0f940389
...
...
@@ -38,7 +38,7 @@ public:
virtual
TableBuilder
&
setVgid
(
int16_t
vgid
)
{
schema
()
->
vgId
=
vgid
;
meta_
->
vgs
.
emplace_back
(
SVgroupInfo
{.
vgId
=
vgid
,
.
numOfEps
=
3
,
.
epAddr
=
{{
"dnode_1"
,
6030
},
{
"dnode_2"
,
6030
},
{
"dnode_3"
,
6030
}}});
meta_
->
vgs
.
emplace_back
(
SVgroupInfo
{.
vgId
=
vgid
,
.
hashBegin
=
0
,
.
hashEnd
=
0
,
.
inUse
=
0
,
.
numOfEps
=
3
,
.
epAddr
=
{{
"dnode_1"
,
6030
},
{
"dnode_2"
,
6030
},
{
"dnode_3"
,
6030
}}});
return
*
this
;
}
...
...
@@ -118,9 +118,9 @@ public:
meta_
[
db
][
tbname
].
reset
(
new
MockTableMeta
());
meta_
[
db
][
tbname
]
->
schema
.
reset
(
table
.
release
());
meta_
[
db
][
tbname
]
->
schema
->
uid
=
id_
++
;
meta_
[
db
][
tbname
]
->
vgs
.
emplace_back
(
SVgroupInfo
{.
vgId
=
vgid
,
.
numOfEps
=
3
,
.
epAddr
=
{{
"dnode_1"
,
6030
},
{
"dnode_2"
,
6030
},
{
"dnode_3"
,
6030
}}});
meta_
[
db
][
tbname
]
->
vgs
.
emplace_back
(
(
SVgroupInfo
){.
vgId
=
vgid
,
.
hashBegin
=
0
,
.
hashEnd
=
0
,
.
inUse
=
0
,
.
numOfEps
=
3
,
.
epAddr
=
{{
"dnode_1"
,
6030
},
{
"dnode_2"
,
6030
},
{
"dnode_3"
,
6030
}}});
// super table
meta_
[
db
][
stbname
]
->
vgs
.
emplace_back
(
SVgroupInfo
{.
vgId
=
vgid
,
.
numOfEps
=
3
,
.
epAddr
=
{{
"dnode_1"
,
6030
},
{
"dnode_2"
,
6030
},
{
"dnode_3"
,
6030
}}});
meta_
[
db
][
stbname
]
->
vgs
.
emplace_back
(
(
SVgroupInfo
){.
vgId
=
vgid
,
.
hashBegin
=
0
,
.
hashEnd
=
0
,
.
inUse
=
0
,
.
numOfEps
=
3
,
.
epAddr
=
{{
"dnode_1"
,
6030
},
{
"dnode_2"
,
6030
},
{
"dnode_3"
,
6030
}}});
}
void
showTables
()
const
{
...
...
source/libs/qcom/src/querymsg.c
浏览文件 @
0f940389
...
...
@@ -294,7 +294,7 @@ void msgInit() {
tscBuildMsg[TSDB_SQL_DROP_DNODE] = tscBuildDropDnodeMsg;
tscBuildMsg[TSDB_SQL_CFG_DNODE] = tscBuildCfgDnodeMsg;
tscBuildMsg[TSDB_SQL_ALTER_TABLE] = tscBuildAlterTableMsg;
tscBuildMsg[TSDB_SQL_UPDATE_TAG
S
_VAL] = tscBuildUpdateTagMsg;
tscBuildMsg[TSDB_SQL_UPDATE_TAG_VAL] = tscBuildUpdateTagMsg;
tscBuildMsg[TSDB_SQL_ALTER_DB] = tscAlterDbMsg;
tscBuildMsg[TSDB_SQL_COMPACT_VNODE] = tscBuildCompactMsg;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录