Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
af8fe3ad
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看板
提交
af8fe3ad
编写于
9月 01, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: a privilege problem of show tables
上级
1289093b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
25 addition
and
16 deletion
+25
-16
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+3
-2
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+13
-12
source/libs/parser/src/parAuthenticator.c
source/libs/parser/src/parAuthenticator.c
+7
-0
tests/system-test/0-others/user_control.py
tests/system-test/0-others/user_control.py
+2
-2
未找到文件。
source/libs/parser/src/parAstCreater.c
浏览文件 @
af8fe3ad
...
...
@@ -1251,7 +1251,8 @@ SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName) {
static
bool
needDbShowStmt
(
ENodeType
type
)
{
return
QUERY_NODE_SHOW_TABLES_STMT
==
type
||
QUERY_NODE_SHOW_STABLES_STMT
==
type
||
QUERY_NODE_SHOW_VGROUPS_STMT
==
type
;
QUERY_NODE_SHOW_VGROUPS_STMT
==
type
||
QUERY_NODE_SHOW_INDEXES_STMT
==
type
||
QUERY_NODE_SHOW_TAGS_STMT
==
type
;
}
SNode
*
createShowStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
)
{
...
...
@@ -1264,7 +1265,7 @@ SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type) {
SNode
*
createShowStmtWithCond
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
SNode
*
pDbName
,
SNode
*
pTbName
,
EOperatorType
tableCondType
)
{
CHECK_PARSER_STATUS
(
pCxt
);
if
(
needDbShowStmt
(
type
)
&&
NULL
==
pDbName
&&
NULL
==
pCxt
->
pQueryCxt
->
db
)
{
if
(
needDbShowStmt
(
type
)
&&
NULL
==
pDbName
)
{
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"db not specified"
);
pCxt
->
errCode
=
TSDB_CODE_PAR_SYNTAX_ERROR
;
return
NULL
;
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
af8fe3ad
...
...
@@ -374,8 +374,13 @@ static int32_t collectMetaKeyFromShowIndexes(SCollectMetaKeyCxt* pCxt, SShowStmt
}
static
int32_t
collectMetaKeyFromShowStables
(
SCollectMetaKeyCxt
*
pCxt
,
SShowStmt
*
pStmt
)
{
return
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_STABLES
,
pCxt
->
pMetaCache
);
int32_t
code
=
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_STABLES
,
pCxt
->
pMetaCache
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveUserAuthInCache
(
pCxt
->
pParseCxt
->
acctId
,
pCxt
->
pParseCxt
->
pUser
,
((
SValueNode
*
)
pStmt
->
pDbName
)
->
literal
,
AUTH_TYPE_READ
,
pCxt
->
pMetaCache
);
}
return
code
;
}
static
int32_t
collectMetaKeyFromShowStreams
(
SCollectMetaKeyCxt
*
pCxt
,
SShowStmt
*
pStmt
)
{
...
...
@@ -387,11 +392,11 @@ static int32_t collectMetaKeyFromShowTables(SCollectMetaKeyCxt* pCxt, SShowStmt*
int32_t
code
=
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_TABLES
,
pCxt
->
pMetaCache
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
NULL
!=
pStmt
->
pDbName
)
{
code
=
reserveDbVgInfoInCache
(
pCxt
->
pParseCxt
->
acctId
,
((
SValueNode
*
)
pStmt
->
pDbName
)
->
literal
,
pCxt
->
pMetaCache
);
}
else
{
code
=
reserveDbVgInfoInCache
(
pCxt
->
pParseCxt
->
acctId
,
TSDB_INFORMATION_SCHEMA_DB
,
pCxt
->
pMetaCache
);
}
code
=
reserveDbVgInfoInCache
(
pCxt
->
pParseCxt
->
acctId
,
((
SValueNode
*
)
pStmt
->
pDbName
)
->
literal
,
pCxt
->
pMetaCache
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveUserAuthInCache
(
pCxt
->
pParseCxt
->
acctId
,
pCxt
->
pParseCxt
->
pUser
,
((
SValueNode
*
)
pStmt
->
pDbName
)
->
literal
,
AUTH_TYPE_READ
,
pCxt
->
pMetaCache
);
}
return
code
;
}
...
...
@@ -400,11 +405,7 @@ static int32_t collectMetaKeyFromShowTags(SCollectMetaKeyCxt* pCxt, SShowStmt* p
int32_t
code
=
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_TAGS
,
pCxt
->
pMetaCache
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
NULL
!=
pStmt
->
pDbName
)
{
code
=
reserveDbVgInfoInCache
(
pCxt
->
pParseCxt
->
acctId
,
((
SValueNode
*
)
pStmt
->
pDbName
)
->
literal
,
pCxt
->
pMetaCache
);
}
else
{
code
=
reserveDbVgInfoInCache
(
pCxt
->
pParseCxt
->
acctId
,
TSDB_INFORMATION_SCHEMA_DB
,
pCxt
->
pMetaCache
);
}
code
=
reserveDbVgInfoInCache
(
pCxt
->
pParseCxt
->
acctId
,
((
SValueNode
*
)
pStmt
->
pDbName
)
->
literal
,
pCxt
->
pMetaCache
);
}
return
code
;
}
...
...
source/libs/parser/src/parAuthenticator.c
浏览文件 @
af8fe3ad
...
...
@@ -96,6 +96,10 @@ static int32_t authInsert(SAuthCxt* pCxt, SInsertStmt* pInsert) {
return
code
;
}
static
int32_t
authShowTables
(
SAuthCxt
*
pCxt
,
SShowStmt
*
pStmt
)
{
return
checkAuth
(
pCxt
,
((
SValueNode
*
)
pStmt
->
pDbName
)
->
literal
,
AUTH_TYPE_READ
);
}
static
int32_t
authShowCreateTable
(
SAuthCxt
*
pCxt
,
SShowCreateTableStmt
*
pStmt
)
{
return
checkAuth
(
pCxt
,
pStmt
->
dbName
,
AUTH_TYPE_READ
);
}
...
...
@@ -127,6 +131,9 @@ static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt) {
case
QUERY_NODE_SHOW_VNODES_STMT
:
case
QUERY_NODE_SHOW_SCORES_STMT
:
return
!
pCxt
->
pParseCxt
->
enableSysInfo
?
TSDB_CODE_PAR_PERMISSION_DENIED
:
TSDB_CODE_SUCCESS
;
case
QUERY_NODE_SHOW_TABLES_STMT
:
case
QUERY_NODE_SHOW_STABLES_STMT
:
return
authShowTables
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_CREATE_TABLE_STMT
:
case
QUERY_NODE_SHOW_CREATE_STABLE_STMT
:
return
authShowCreateTable
(
pCxt
,
(
SShowCreateTableStmt
*
)
pStmt
);
...
...
tests/system-test/0-others/user_control.py
浏览文件 @
af8fe3ad
...
...
@@ -282,12 +282,12 @@ class TDTestCase:
use
.
error
(
f
"insert into
{
DBNAME
}
.
{
CTBNAME
}
(ts) values (now())"
)
elif
check_priv
==
PRIVILEGES_WRITE
:
use
.
query
(
f
"use
{
DBNAME
}
"
)
use
.
query
(
f
"show
{
DBNAME
}
.tables"
)
use
.
error
(
f
"show
{
DBNAME
}
.tables"
)
use
.
error
(
f
"select * from
{
DBNAME
}
.
{
CTBNAME
}
"
)
use
.
query
(
f
"insert into
{
DBNAME
}
.
{
CTBNAME
}
(ts) values (now())"
)
elif
check_priv
is
None
:
use
.
error
(
f
"use
{
DBNAME
}
"
)
#
use.error(f"show {DBNAME}.tables")
use
.
error
(
f
"show
{
DBNAME
}
.tables"
)
use
.
error
(
f
"show tables"
)
use
.
error
(
f
"select * from
{
DBNAME
}
.
{
CTBNAME
}
"
)
use
.
error
(
f
"insert into
{
DBNAME
}
.
{
CTBNAME
}
(ts) values (now())"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录