Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3f972b90
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看板
提交
3f972b90
编写于
2月 24, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact for user manage
上级
81975c11
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
163 addition
and
176 deletion
+163
-176
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+1
-1
src/client/src/tscServer.c
src/client/src/tscServer.c
+40
-77
src/inc/mnode.h
src/inc/mnode.h
+13
-13
src/inc/taosmsg.h
src/inc/taosmsg.h
+4
-4
src/kit/shell/src/shellMain.c
src/kit/shell/src/shellMain.c
+7
-5
src/mnode/src/mgmtAcct.c
src/mnode/src/mgmtAcct.c
+1
-0
src/mnode/src/mgmtShell.c
src/mnode/src/mgmtShell.c
+4
-1
src/mnode/src/mgmtUser.c
src/mnode/src/mgmtUser.c
+93
-75
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
3f972b90
...
@@ -270,7 +270,7 @@ typedef struct SResRec {
...
@@ -270,7 +270,7 @@ typedef struct SResRec {
struct
STSBuf
;
struct
STSBuf
;
typedef
struct
{
typedef
struct
{
uint8
_t
code
;
int32
_t
code
;
int64_t
numOfRows
;
// num of results in current retrieved
int64_t
numOfRows
;
// num of results in current retrieved
int64_t
numOfTotal
;
// num of total results
int64_t
numOfTotal
;
// num of total results
int64_t
numOfTotalInCurrentClause
;
// num of total result in current subclause
int64_t
numOfTotalInCurrentClause
;
// num of total result in current subclause
...
...
src/client/src/tscServer.c
浏览文件 @
3f972b90
...
@@ -196,7 +196,7 @@ int tscSendMsgToServer(SSqlObj *pSql) {
...
@@ -196,7 +196,7 @@ int tscSendMsgToServer(SSqlObj *pSql) {
}
}
void
tscProcessMsgFromServer
(
char
type
,
void
*
pCont
,
int
contLen
,
void
*
ahandle
,
int32_t
code
)
{
void
tscProcessMsgFromServer
(
char
type
,
void
*
pCont
,
int
contLen
,
void
*
ahandle
,
int32_t
code
)
{
tscPrint
(
"response:%
d is received, pCont:%p, contLen:%d code:%d"
,
type
,
pCont
,
contLen
,
code
);
tscPrint
(
"response:%
s is received, len:%d error:%s"
,
taosMsg
[(
uint8_t
)
type
],
contLen
,
tstrerror
(
code
)
);
SSqlObj
*
pSql
=
(
SSqlObj
*
)
ahandle
;
SSqlObj
*
pSql
=
(
SSqlObj
*
)
ahandle
;
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
{
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
{
tscError
(
"%p sql is already released, signature:%p"
,
pSql
,
pSql
->
signature
);
tscError
(
"%p sql is already released, signature:%p"
,
pSql
,
pSql
->
signature
);
...
@@ -272,7 +272,7 @@ void tscProcessMsgFromServer(char type, void *pCont, int contLen, void *ahandle,
...
@@ -272,7 +272,7 @@ void tscProcessMsgFromServer(char type, void *pCont, int contLen, void *ahandle,
if
(
pRes
->
code
!=
TSDB_CODE_QUERY_CANCELLED
)
{
if
(
pRes
->
code
!=
TSDB_CODE_QUERY_CANCELLED
)
{
assert
(
type
==
pCmd
->
msgType
+
1
);
assert
(
type
==
pCmd
->
msgType
+
1
);
pRes
->
code
=
(
int
8
_t
)
code
;
pRes
->
code
=
(
int
32
_t
)
code
;
pRes
->
rspType
=
type
;
pRes
->
rspType
=
type
;
pRes
->
rspLen
=
contLen
;
pRes
->
rspLen
=
contLen
;
...
@@ -1737,17 +1737,19 @@ int32_t tscBuildAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1737,17 +1737,19 @@ int32_t tscBuildAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
}
int32_t
tscBuildUserMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
int32_t
tscBuildUserMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SCreateUserMsg
*
pAlterMsg
;
STscObj
*
pObj
=
pSql
->
pTscObj
;
char
*
pMsg
,
*
pStart
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
payloadLen
=
sizeof
(
SCreateUserMsg
);
pMsg
=
doBuildMsgHeader
(
pSql
,
&
pStart
);
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
pAlterMsg
=
(
SCreateUserMsg
*
)
pMsg
;
tscError
(
"%p failed to malloc for query msg"
,
pSql
);
return
TSDB_CODE_CLI_OUT_OF_MEMORY
;
}
SCreateUserMsg
*
pAlterMsg
=
(
SCreateUserMsg
*
)
pCmd
->
payload
;
SUserInfo
*
pUser
=
&
pInfo
->
pDCLInfo
->
user
;
SUserInfo
*
pUser
=
&
pInfo
->
pDCLInfo
->
user
;
strncpy
(
pAlterMsg
->
user
,
pUser
->
user
.
z
,
pUser
->
user
.
n
);
strncpy
(
pAlterMsg
->
user
,
pUser
->
user
.
z
,
pUser
->
user
.
n
);
pAlterMsg
->
flag
=
pUser
->
type
;
pAlterMsg
->
flag
=
pUser
->
type
;
if
(
pUser
->
type
==
TSDB_ALTER_USER_PRIVILEGES
)
{
if
(
pUser
->
type
==
TSDB_ALTER_USER_PRIVILEGES
)
{
...
@@ -1758,9 +1760,6 @@ int32_t tscBuildUserMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1758,9 +1760,6 @@ int32_t tscBuildUserMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
strncpy
(
pAlterMsg
->
pass
,
pUser
->
passwd
.
z
,
pUser
->
passwd
.
n
);
strncpy
(
pAlterMsg
->
pass
,
pUser
->
passwd
.
z
,
pUser
->
passwd
.
n
);
}
}
pMsg
+=
sizeof
(
SCreateUserMsg
);
pCmd
->
payloadLen
=
pMsg
-
pStart
;
if
(
pUser
->
type
==
TSDB_ALTER_USER_PASSWD
||
pUser
->
type
==
TSDB_ALTER_USER_PRIVILEGES
)
{
if
(
pUser
->
type
==
TSDB_ALTER_USER_PASSWD
||
pUser
->
type
==
TSDB_ALTER_USER_PRIVILEGES
)
{
pCmd
->
msgType
=
TSDB_MSG_TYPE_ALTER_USER
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_ALTER_USER
;
}
else
{
}
else
{
...
@@ -1871,22 +1870,20 @@ int32_t tscBuildDropDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1871,22 +1870,20 @@ int32_t tscBuildDropDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
}
int32_t
tscBuildDropAcctMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
int32_t
tscBuildDropAcctMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SDropUserMsg
*
pDropMsg
;
STscObj
*
pObj
=
pSql
->
pTscObj
;
char
*
pMsg
,
*
pStart
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
payloadLen
=
sizeof
(
SDropUserMsg
);
pCmd
->
msgType
=
TSDB_MSG_TYPE_DROP_USER
;
pMsg
=
doBuildMsgHeader
(
pSql
,
&
pStart
);
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
pDropMsg
=
(
SDropUserMsg
*
)
pMsg
;
tscError
(
"%p failed to malloc for query msg"
,
pSql
);
return
TSDB_CODE_CLI_OUT_OF_MEMORY
;
}
SDropUserMsg
*
pDropMsg
=
(
SDropUserMsg
*
)
pCmd
->
payload
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
strcpy
(
pDropMsg
->
user
,
pMeterMetaInfo
->
name
);
strcpy
(
pDropMsg
->
user
,
pMeterMetaInfo
->
name
);
pMsg
+=
sizeof
(
SDropUserMsg
);
pCmd
->
payloadLen
=
pMsg
-
pStart
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_DROP_USER
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1911,38 +1908,27 @@ int32_t tscBuildUseDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1911,38 +1908,27 @@ int32_t tscBuildUseDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
}
int32_t
tscBuildShowMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
int32_t
tscBuildShowMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SShowMsg
*
pShowMsg
;
char
*
pMsg
,
*
pStart
;
int
msgLen
=
0
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
STscObj
*
pObj
=
pSql
->
pTscObj
;
STscObj
*
pObj
=
pSql
->
pTscObj
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_SHOW
;
pCmd
->
payloadLen
=
sizeof
(
SShowMsg
)
+
100
;
int32_t
size
=
minMsgSize
()
+
sizeof
(
SMgmtHead
)
+
sizeof
(
SShowMsg
)
+
pCmd
->
payloadLen
+
TSDB_EXTRA_PAYLOAD_SIZE
;
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
size
))
{
tscError
(
"%p failed to malloc for query msg"
,
pSql
);
tscError
(
"%p failed to malloc for show msg"
,
pSql
);
return
TSDB_CODE_CLI_OUT_OF_MEMORY
;
return
-
1
;
}
}
pMsg
=
pCmd
->
payload
+
tsRpcHeadSize
;
SShowMsg
*
pShowMsg
=
(
SShowMsg
*
)
pCmd
->
payload
;
pStart
=
pMsg
;
SMgmtHead
*
pMgmt
=
(
SMgmtHead
*
)
pMsg
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
size_t
nameLen
=
strlen
(
pMeterMetaInfo
->
name
);
size_t
nameLen
=
strlen
(
pMeterMetaInfo
->
name
);
if
(
nameLen
>
0
)
{
if
(
nameLen
>
0
)
{
strcpy
(
p
Mgmt
->
db
,
pMeterMetaInfo
->
name
);
// prefix is set here
strcpy
(
p
ShowMsg
->
db
,
pMeterMetaInfo
->
name
);
// prefix is set here
}
else
{
}
else
{
strcpy
(
p
Mgmt
->
db
,
pObj
->
db
);
strcpy
(
p
ShowMsg
->
db
,
pObj
->
db
);
}
}
pMsg
+=
sizeof
(
SMgmtHead
);
pShowMsg
=
(
SShowMsg
*
)
pMsg
;
SShowInfo
*
pShowInfo
=
&
pInfo
->
pDCLInfo
->
showOpt
;
SShowInfo
*
pShowInfo
=
&
pInfo
->
pDCLInfo
->
showOpt
;
pShowMsg
->
type
=
pShowInfo
->
showType
;
pShowMsg
->
type
=
pShowInfo
->
showType
;
if
(
pShowInfo
->
showType
!=
TSDB_MGMT_TABLE_VNODES
)
{
if
(
pShowInfo
->
showType
!=
TSDB_MGMT_TABLE_VNODES
)
{
...
@@ -1951,22 +1937,15 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1951,22 +1937,15 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
strncpy
(
pShowMsg
->
payload
,
pPattern
->
z
,
pPattern
->
n
);
strncpy
(
pShowMsg
->
payload
,
pPattern
->
z
,
pPattern
->
n
);
pShowMsg
->
payloadLen
=
htons
(
pPattern
->
n
);
pShowMsg
->
payloadLen
=
htons
(
pPattern
->
n
);
}
}
pMsg
+=
(
sizeof
(
SShowMsg
)
+
pPattern
->
n
);
}
else
{
}
else
{
SSQLToken
*
pIpAddr
=
&
pShowInfo
->
prefix
;
SSQLToken
*
pIpAddr
=
&
pShowInfo
->
prefix
;
assert
(
pIpAddr
->
n
>
0
&&
pIpAddr
->
type
>
0
);
assert
(
pIpAddr
->
n
>
0
&&
pIpAddr
->
type
>
0
);
strncpy
(
pShowMsg
->
payload
,
pIpAddr
->
z
,
pIpAddr
->
n
);
strncpy
(
pShowMsg
->
payload
,
pIpAddr
->
z
,
pIpAddr
->
n
);
pShowMsg
->
payloadLen
=
htons
(
pIpAddr
->
n
);
pShowMsg
->
payloadLen
=
htons
(
pIpAddr
->
n
);
pMsg
+=
(
sizeof
(
SShowMsg
)
+
pIpAddr
->
n
);
}
}
pCmd
->
payloadLen
=
pMsg
-
pStart
;
pCmd
->
payloadLen
=
sizeof
(
SShowMsg
)
+
pShowMsg
->
payloadLen
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_SHOW
;
assert
(
msgLen
+
minMsgSize
()
<=
size
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -2186,37 +2165,20 @@ int tscAlterDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -2186,37 +2165,20 @@ int tscAlterDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
}
int
tscBuildRetrieveFromMgmtMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
int
tscBuildRetrieveFromMgmtMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
char
*
pMsg
,
*
pStart
;
int
msgLen
=
0
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
STscObj
*
pObj
=
pSql
->
pTscObj
;
STscObj
*
pObj
=
pSql
->
pTscObj
;
pMsg
=
pCmd
->
payload
+
tsRpcHeadSize
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pStart
=
pMsg
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_RETRIEVE
;
pCmd
->
payloadLen
=
sizeof
(
SRetrieveTableMsg
);
SMgmtHead
*
pMgmt
=
(
SMgmtHead
*
)
pMsg
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
size_t
nameLen
=
strlen
(
pMeterMetaInfo
->
name
);
if
(
nameLen
>
0
)
{
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
strcpy
(
pMgmt
->
db
,
pMeterMetaInfo
->
name
);
tscError
(
"%p failed to malloc for query msg"
,
pSql
);
}
else
{
return
TSDB_CODE_CLI_OUT_OF_MEMORY
;
strcpy
(
pMgmt
->
db
,
pObj
->
db
);
}
}
pMsg
+=
sizeof
(
SMgmtHead
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
SRetrieveTableMsg
*
pRetrieveMsg
=
(
SRetrieveTableMsg
*
)
pCmd
->
payload
;
*
((
uint64_t
*
)
pMsg
)
=
pSql
->
res
.
qhandle
;
pRetrieveMsg
->
qhandle
=
htobe64
(
pSql
->
res
.
qhandle
);
pMsg
+=
sizeof
(
pSql
->
res
.
qhandle
);
pRetrieveMsg
->
free
=
htons
(
pQueryInfo
->
type
);
*
((
uint16_t
*
)
pMsg
)
=
htons
(
pQueryInfo
->
type
);
pMsg
+=
sizeof
(
pQueryInfo
->
type
);
msgLen
=
pMsg
-
pStart
;
pCmd
->
payloadLen
=
msgLen
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_RETRIEVE
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -2999,6 +2961,7 @@ int tscProcessShowRsp(SSqlObj *pSql) {
...
@@ -2999,6 +2961,7 @@ int tscProcessShowRsp(SSqlObj *pSql) {
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
pShow
=
(
SShowRsp
*
)
pRes
->
pRsp
;
pShow
=
(
SShowRsp
*
)
pRes
->
pRsp
;
pShow
->
qhandle
=
htobe64
(
pShow
->
qhandle
);
pRes
->
qhandle
=
pShow
->
qhandle
;
pRes
->
qhandle
=
pShow
->
qhandle
;
tscResetForNextRetrieve
(
pRes
);
tscResetForNextRetrieve
(
pRes
);
...
...
src/inc/mnode.h
浏览文件 @
3f972b90
...
@@ -251,10 +251,10 @@ typedef struct _user_obj {
...
@@ -251,10 +251,10 @@ typedef struct _user_obj {
char
pass
[
TSDB_KEY_LEN
];
char
pass
[
TSDB_KEY_LEN
];
char
acct
[
TSDB_USER_LEN
];
char
acct
[
TSDB_USER_LEN
];
int64_t
createdTime
;
int64_t
createdTime
;
char
superAuth
:
1
;
int8_t
superAuth
;
char
writeAuth
:
1
;
int8_t
writeAuth
;
char
reserved
[
16
];
int8_t
reserved
[
16
];
char
updateEnd
[
1
];
int8_t
updateEnd
[
1
];
struct
_user_obj
*
prev
,
*
next
;
struct
_user_obj
*
prev
,
*
next
;
struct
_acctObj
*
pAcct
;
struct
_acctObj
*
pAcct
;
SQqueryList
*
pQList
;
// query list
SQqueryList
*
pQList
;
// query list
...
@@ -301,15 +301,15 @@ typedef struct {
...
@@ -301,15 +301,15 @@ typedef struct {
}
SSecInfo
;
}
SSecInfo
;
typedef
struct
{
typedef
struct
{
char
type
;
int8_t
type
;
char
db
[
TSDB_DB_NAME_LEN
];
char
db
[
TSDB_DB_NAME_LEN
];
void
*
pNode
;
void
*
pNode
;
short
numOfColumns
;
int16_t
numOfColumns
;
int
rowSize
;
int
32_t
rowSize
;
int
numOfRows
;
int
32_t
numOfRows
;
int
numOfReads
;
int
32_t
numOfReads
;
short
offset
[
TSDB_MAX_COLUMNS
];
int16_t
offset
[
TSDB_MAX_COLUMNS
];
short
bytes
[
TSDB_MAX_COLUMNS
];
int16_t
bytes
[
TSDB_MAX_COLUMNS
];
void
*
signature
;
void
*
signature
;
uint16_t
payloadLen
;
/* length of payload*/
uint16_t
payloadLen
;
/* length of payload*/
char
payload
[];
/* payload for wildcard match in show tables */
char
payload
[];
/* payload for wildcard match in show tables */
...
...
src/inc/taosmsg.h
浏览文件 @
3f972b90
...
@@ -225,8 +225,8 @@ typedef struct {
...
@@ -225,8 +225,8 @@ typedef struct {
typedef
struct
SSchema
{
typedef
struct
SSchema
{
uint8_t
type
;
uint8_t
type
;
char
name
[
TSDB_COL_NAME_LEN
];
char
name
[
TSDB_COL_NAME_LEN
];
shor
t
colId
;
int16_
t
colId
;
shor
t
bytes
;
int16_
t
bytes
;
}
SSchema
;
}
SSchema
;
typedef
struct
{
typedef
struct
{
...
...
src/kit/shell/src/shellMain.c
浏览文件 @
3f972b90
...
@@ -82,12 +82,14 @@ struct arguments args = {
...
@@ -82,12 +82,14 @@ struct arguments args = {
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
/*setlocale(LC_ALL, "en_US.UTF-8"); */
/*setlocale(LC_ALL, "en_US.UTF-8"); */
//
//
if
(
argc
!=
1
)
{
printf
(
"=== this a test for debug usage
\n
"
);
void
*
taos
=
taos_connect
(
NULL
,
"root"
,
"taosdata"
,
NULL
,
0
);
void
*
taos
=
taos_connect
(
NULL
,
"root"
,
"taosdata"
,
NULL
,
0
);
printf
(
"ok
\n
"
);
taos_query
(
taos
,
"drop user a"
);
taos_query
(
taos
,
"create account a pass 'b'"
);
while
(
1
)
{
while
(
1
)
{
sleep
(
1000
);
sleep
(
1000
);
}
}
}
//
//
if
(
!
checkVersion
())
{
if
(
!
checkVersion
())
{
...
...
src/mnode/src/mgmtAcct.c
浏览文件 @
3f972b90
...
@@ -73,6 +73,7 @@ int32_t mgmtAddUserIntoAcct(SAcctObj *pAcct, SUserObj *pUser) {
...
@@ -73,6 +73,7 @@ int32_t mgmtAddUserIntoAcct(SAcctObj *pAcct, SUserObj *pUser) {
pAcct
->
pUser
=
pUser
;
pAcct
->
pUser
=
pUser
;
pAcct
->
acctInfo
.
numOfUsers
++
;
pAcct
->
acctInfo
.
numOfUsers
++
;
pUser
->
pAcct
=
pAcct
;
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
return
0
;
return
0
;
...
...
src/mnode/src/mgmtShell.c
浏览文件 @
3f972b90
...
@@ -1108,7 +1108,10 @@ static void mgmtProcessMsgFromShell(char type, void *pCont, int contLen, void *a
...
@@ -1108,7 +1108,10 @@ static void mgmtProcessMsgFromShell(char type, void *pCont, int contLen, void *a
mError
(
"%s from shell is not processed"
,
taosMsg
[(
int8_t
)
type
]);
mError
(
"%s from shell is not processed"
,
taosMsg
[(
int8_t
)
type
]);
}
}
}
}
rpcFreeCont
(
pCont
);
//TODO free may be cause segment fault
//
// rpcFreeCont(pCont);
}
}
void
mgmtInitProcessShellMsg
()
{
void
mgmtInitProcessShellMsg
()
{
...
...
src/mnode/src/mgmtUser.c
浏览文件 @
3f972b90
...
@@ -96,15 +96,16 @@ int32_t mgmtUpdateUser(SUserObj *pUser) {
...
@@ -96,15 +96,16 @@ int32_t mgmtUpdateUser(SUserObj *pUser) {
}
}
int32_t
mgmtCreateUser
(
SAcctObj
*
pAcct
,
char
*
name
,
char
*
pass
)
{
int32_t
mgmtCreateUser
(
SAcctObj
*
pAcct
,
char
*
name
,
char
*
pass
)
{
SUserObj
*
pUser
;
int32_t
code
=
mgmtCheckUserLimit
(
pAcct
);
int32_t
code
;
code
=
mgmtCheckUserLimit
(
pAcct
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
return
code
;
return
code
;
}
}
pUser
=
(
SUserObj
*
)
sdbGetRow
(
tsUserSdb
,
name
);
if
(
name
[
0
]
==
0
||
pass
[
0
]
==
0
)
{
return
TSDB_CODE_INVALID_MSG
;
}
SUserObj
*
pUser
=
(
SUserObj
*
)
sdbGetRow
(
tsUserSdb
,
name
);
if
(
pUser
!=
NULL
)
{
if
(
pUser
!=
NULL
)
{
mWarn
(
"user:%s is already there"
,
name
);
mWarn
(
"user:%s is already there"
,
name
);
return
TSDB_CODE_USER_ALREADY_EXIST
;
return
TSDB_CODE_USER_ALREADY_EXIST
;
...
@@ -159,88 +160,99 @@ void mgmtCleanUpUsers() {
...
@@ -159,88 +160,99 @@ void mgmtCleanUpUsers() {
}
}
int32_t
mgmtGetUserMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
mgmtGetUserMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
// int32_t cols = 0;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
// SSchema *pSchema = tsGetSchema(pMeta);
if
(
pUser
==
NULL
)
{
//
return
TSDB_CODE_INVALID_USER
;
// pShow->bytes[cols] = TSDB_USER_LEN;
}
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
// strcpy(pSchema[cols].name, "name");
int32_t
cols
=
0
;
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
// cols++;
//
pShow
->
bytes
[
cols
]
=
TSDB_USER_LEN
;
// pShow->bytes[cols] = 6;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
strcpy
(
pSchema
[
cols
].
name
,
"name"
);
// strcpy(pSchema[cols].name, "privilege");
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
cols
++
;
// cols++;
//
pShow
->
bytes
[
cols
]
=
6
;
// pShow->bytes[cols] = 8;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
// pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
strcpy
(
pSchema
[
cols
].
name
,
"privilege"
);
// strcpy(pSchema[cols].name, "created time");
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
cols
++
;
// cols++;
//
pShow
->
bytes
[
cols
]
=
8
;
// pMeta->numOfColumns = htons(cols);
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
// pShow->numOfColumns = cols;
strcpy
(
pSchema
[
cols
].
name
,
"created time"
);
//
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
// pShow->offset[0] = 0;
cols
++
;
// for (int32_t i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
//
pMeta
->
numOfColumns
=
htons
(
cols
);
// pShow->numOfRows = pConn->pAcct->acctInfo.numOfUsers;
strcpy
(
pMeta
->
tableId
,
"show users"
);
// pShow->pNode = pConn->pAcct->pUser;
pShow
->
numOfColumns
=
cols
;
// pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
pShow
->
offset
[
0
]
=
0
;
for
(
int32_t
i
=
1
;
i
<
cols
;
++
i
)
{
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
}
pShow
->
numOfRows
=
pUser
->
pAcct
->
acctInfo
.
numOfUsers
;
pShow
->
pNode
=
pUser
->
pAcct
->
pUser
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
return
0
;
return
0
;
}
}
int32_t
mgmtRetrieveUsers
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
)
{
int32_t
mgmtRetrieveUsers
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
)
{
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
// SUserObj *pUser
= NULL;
SUserObj
*
pUser
=
NULL
;
// char * pWrite
;
int32_t
cols
=
0
;
// int32_t cols = 0
;
char
*
pWrite
;
//
//
while (numOfRows < rows) {
while
(
numOfRows
<
rows
)
{
//
pUser = (SUserObj *)pShow->pNode;
pUser
=
(
SUserObj
*
)
pShow
->
pNode
;
//
if (pUser == NULL) break;
if
(
pUser
==
NULL
)
break
;
//
pShow->pNode = (void *)pUser->next;
pShow
->
pNode
=
(
void
*
)
pUser
->
next
;
//
//
cols = 0;
cols
=
0
;
//
//
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
//
strcpy(pWrite, pUser->user);
strcpy
(
pWrite
,
pUser
->
user
);
//
cols++;
cols
++
;
//
//
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
//
if (pUser->superAuth) {
if
(
pUser
->
superAuth
)
{
//
strcpy(pWrite, "super");
strcpy
(
pWrite
,
"super"
);
//
} else if (pUser->writeAuth) {
}
else
if
(
pUser
->
writeAuth
)
{
//
strcpy(pWrite, "write");
strcpy
(
pWrite
,
"write"
);
//
} else {
}
else
{
//
strcpy(pWrite, "read");
strcpy
(
pWrite
,
"read"
);
//
}
}
//
cols++;
cols
++
;
//
//
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
//
*(int64_t *)pWrite = pUser->createdTime;
*
(
int64_t
*
)
pWrite
=
pUser
->
createdTime
;
//
cols++;
cols
++
;
//
//
numOfRows++;
numOfRows
++
;
//
}
}
//
pShow->numOfReads += numOfRows;
pShow
->
numOfReads
+=
numOfRows
;
return
numOfRows
;
return
numOfRows
;
}
}
void
*
mgmtUserActionInsert
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
void
*
mgmtUserActionInsert
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
SUserObj
*
pUser
=
(
SUserObj
*
)
row
;
SUserObj
*
pUser
=
(
SUserObj
*
)
row
;
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pUser
->
acct
);
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pUser
->
acct
);
pUser
->
pAcct
=
pAcct
;
mgmtAddUserIntoAcct
(
pAcct
,
pUser
);
mgmtAddUserIntoAcct
(
pAcct
,
pUser
);
return
NULL
;
return
NULL
;
}
}
void
*
mgmtUserActionDelete
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
void
*
mgmtUserActionDelete
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
SUserObj
*
pUser
=
(
SUserObj
*
)
row
;
SUserObj
*
pUser
=
(
SUserObj
*
)
row
;
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pUser
->
acct
);
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pUser
->
acct
);
mgmtRemoveUserFromAcct
(
pAcct
,
pUser
);
mgmtRemoveUserFromAcct
(
pAcct
,
pUser
);
return
NULL
;
return
NULL
;
...
@@ -251,30 +263,34 @@ void *mgmtUserActionUpdate(void *row, char *str, int32_t size, int32_t *ssize) {
...
@@ -251,30 +263,34 @@ void *mgmtUserActionUpdate(void *row, char *str, int32_t size, int32_t *ssize) {
}
}
void
*
mgmtUserActionEncode
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
void
*
mgmtUserActionEncode
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
SUserObj
*
pUser
=
(
SUserObj
*
)
row
;
SUserObj
*
pUser
=
(
SUserObj
*
)
row
;
int32_t
tsize
=
pUser
->
updateEnd
-
(
char
*
)
pUser
;
int32_t
tsize
=
pUser
->
updateEnd
-
(
int8_t
*
)
pUser
;
if
(
size
<
tsize
)
{
if
(
size
<
tsize
)
{
*
ssize
=
-
1
;
*
ssize
=
-
1
;
}
else
{
}
else
{
memcpy
(
str
,
pUser
,
tsize
);
memcpy
(
str
,
pUser
,
tsize
);
*
ssize
=
tsize
;
*
ssize
=
tsize
;
}
}
return
NULL
;
return
NULL
;
}
}
void
*
mgmtUserActionDecode
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
void
*
mgmtUserActionDecode
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
SUserObj
*
pUser
=
(
SUserObj
*
)
malloc
(
sizeof
(
SUserObj
));
SUserObj
*
pUser
=
(
SUserObj
*
)
malloc
(
sizeof
(
SUserObj
));
if
(
pUser
==
NULL
)
return
NULL
;
if
(
pUser
==
NULL
)
return
NULL
;
memset
(
pUser
,
0
,
sizeof
(
SUserObj
));
memset
(
pUser
,
0
,
sizeof
(
SUserObj
));
int32_t
tsize
=
pUser
->
updateEnd
-
(
char
*
)
pUser
;
int32_t
tsize
=
pUser
->
updateEnd
-
(
int8_t
*
)
pUser
;
memcpy
(
pUser
,
str
,
tsize
);
memcpy
(
pUser
,
str
,
tsize
);
return
(
void
*
)
pUser
;
return
(
void
*
)
pUser
;
}
}
void
*
mgmtUserActionReset
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
void
*
mgmtUserActionReset
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
SUserObj
*
pUser
=
(
SUserObj
*
)
row
;
SUserObj
*
pUser
=
(
SUserObj
*
)
row
;
int32_t
tsize
=
pUser
->
updateEnd
-
(
char
*
)
pUser
;
int32_t
tsize
=
pUser
->
updateEnd
-
(
int8_t
*
)
pUser
;
memcpy
(
pUser
,
str
,
tsize
);
memcpy
(
pUser
,
str
,
tsize
);
return
NULL
;
return
NULL
;
...
@@ -282,11 +298,13 @@ void *mgmtUserActionReset(void *row, char *str, int32_t size, int32_t *ssize) {
...
@@ -282,11 +298,13 @@ void *mgmtUserActionReset(void *row, char *str, int32_t size, int32_t *ssize) {
void
*
mgmtUserActionDestroy
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
void
*
mgmtUserActionDestroy
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
tfree
(
row
);
tfree
(
row
);
return
NULL
;
return
NULL
;
}
}
SUserObj
*
mgmtGetUserFromConn
(
void
*
pConn
)
{
SUserObj
*
mgmtGetUserFromConn
(
void
*
pConn
)
{
SRpcConnInfo
connInfo
;
SRpcConnInfo
connInfo
;
rpcGetConnInfo
(
pConn
,
&
connInfo
);
rpcGetConnInfo
(
pConn
,
&
connInfo
);
return
mgmtGetUser
(
connInfo
.
user
);
return
mgmtGetUser
(
connInfo
.
user
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录