Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
98cd9450
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看板
未验证
提交
98cd9450
编写于
7月 12, 2023
作者:
D
dapan1121
提交者:
GitHub
7月 12, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #22031 from taosdata/enh/TS-2500
enh: add show create database command for system dbs
上级
2cfdd234
c3cc217b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
37 addition
and
20 deletion
+37
-20
source/libs/command/src/command.c
source/libs/command/src/command.c
+18
-14
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+4
-0
tests/system-test/0-others/show.py
tests/system-test/0-others/show.py
+15
-6
未找到文件。
source/libs/command/src/command.c
浏览文件 @
98cd9450
...
@@ -286,20 +286,24 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName, ch
...
@@ -286,20 +286,24 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName, ch
hashPrefix
=
pCfg
->
hashPrefix
+
dbFNameLen
+
1
;
hashPrefix
=
pCfg
->
hashPrefix
+
dbFNameLen
+
1
;
}
}
len
+=
sprintf
(
if
(
IS_SYS_DBNAME
(
dbName
))
{
buf2
+
VARSTR_HEADER_SIZE
,
len
+=
sprintf
(
buf2
+
VARSTR_HEADER_SIZE
,
"CREATE DATABASE `%s`"
,
dbName
);
"CREATE DATABASE `%s` BUFFER %d CACHESIZE %d CACHEMODEL '%s' COMP %d DURATION %dm "
}
else
{
"WAL_FSYNC_PERIOD %d MAXROWS %d MINROWS %d STT_TRIGGER %d KEEP %dm,%dm,%dm PAGES %d PAGESIZE %d PRECISION '%s' REPLICA %d "
len
+=
sprintf
(
"WAL_LEVEL %d VGROUPS %d SINGLE_STABLE %d TABLE_PREFIX %d TABLE_SUFFIX %d TSDB_PAGESIZE %d "
buf2
+
VARSTR_HEADER_SIZE
,
"WAL_RETENTION_PERIOD %d WAL_RETENTION_SIZE %"
PRId64
,
"CREATE DATABASE `%s` BUFFER %d CACHESIZE %d CACHEMODEL '%s' COMP %d DURATION %dm "
dbName
,
pCfg
->
buffer
,
pCfg
->
cacheSize
,
cacheModelStr
(
pCfg
->
cacheLast
),
pCfg
->
compression
,
pCfg
->
daysPerFile
,
"WAL_FSYNC_PERIOD %d MAXROWS %d MINROWS %d STT_TRIGGER %d KEEP %dm,%dm,%dm PAGES %d PAGESIZE %d PRECISION '%s' REPLICA %d "
pCfg
->
walFsyncPeriod
,
pCfg
->
maxRows
,
pCfg
->
minRows
,
pCfg
->
sstTrigger
,
pCfg
->
daysToKeep0
,
pCfg
->
daysToKeep1
,
pCfg
->
daysToKeep2
,
"WAL_LEVEL %d VGROUPS %d SINGLE_STABLE %d TABLE_PREFIX %d TABLE_SUFFIX %d TSDB_PAGESIZE %d "
pCfg
->
pages
,
pCfg
->
pageSize
,
prec
,
pCfg
->
replications
,
pCfg
->
walLevel
,
pCfg
->
numOfVgroups
,
"WAL_RETENTION_PERIOD %d WAL_RETENTION_SIZE %"
PRId64
,
1
==
pCfg
->
numOfStables
,
hashPrefix
,
pCfg
->
hashSuffix
,
pCfg
->
tsdbPageSize
,
pCfg
->
walRetentionPeriod
,
pCfg
->
walRetentionSize
);
dbName
,
pCfg
->
buffer
,
pCfg
->
cacheSize
,
cacheModelStr
(
pCfg
->
cacheLast
),
pCfg
->
compression
,
pCfg
->
daysPerFile
,
pCfg
->
walFsyncPeriod
,
pCfg
->
maxRows
,
pCfg
->
minRows
,
pCfg
->
sstTrigger
,
pCfg
->
daysToKeep0
,
pCfg
->
daysToKeep1
,
pCfg
->
daysToKeep2
,
if
(
retentions
)
{
pCfg
->
pages
,
pCfg
->
pageSize
,
prec
,
pCfg
->
replications
,
pCfg
->
walLevel
,
pCfg
->
numOfVgroups
,
len
+=
sprintf
(
buf2
+
VARSTR_HEADER_SIZE
+
len
,
" RETENTIONS %s"
,
retentions
);
1
==
pCfg
->
numOfStables
,
hashPrefix
,
pCfg
->
hashSuffix
,
pCfg
->
tsdbPageSize
,
pCfg
->
walRetentionPeriod
,
pCfg
->
walRetentionSize
);
taosMemoryFree
(
retentions
);
if
(
retentions
)
{
len
+=
sprintf
(
buf2
+
VARSTR_HEADER_SIZE
+
len
,
" RETENTIONS %s"
,
retentions
);
taosMemoryFree
(
retentions
);
}
}
}
(
varDataLen
(
buf2
))
=
len
;
(
varDataLen
(
buf2
))
=
len
;
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
98cd9450
...
@@ -509,6 +509,10 @@ static int32_t getDBVgVersion(STranslateContext* pCxt, const char* pDbFName, int
...
@@ -509,6 +509,10 @@ static int32_t getDBVgVersion(STranslateContext* pCxt, const char* pDbFName, int
}
}
static
int32_t
getDBCfg
(
STranslateContext
*
pCxt
,
const
char
*
pDbName
,
SDbCfgInfo
*
pInfo
)
{
static
int32_t
getDBCfg
(
STranslateContext
*
pCxt
,
const
char
*
pDbName
,
SDbCfgInfo
*
pInfo
)
{
if
(
IS_SYS_DBNAME
(
pDbName
))
{
return
TSDB_CODE_SUCCESS
;
}
SParseContext
*
pParCxt
=
pCxt
->
pParseCxt
;
SParseContext
*
pParCxt
=
pCxt
->
pParseCxt
;
SName
name
;
SName
name
;
tNameSetDbName
(
&
name
,
pCxt
->
pParseCxt
->
acctId
,
pDbName
,
strlen
(
pDbName
));
tNameSetDbName
(
&
name
,
pCxt
->
pParseCxt
->
acctId
,
pDbName
,
strlen
(
pDbName
));
...
...
tests/system-test/0-others/show.py
浏览文件 @
98cd9450
...
@@ -81,12 +81,20 @@ class TDTestCase:
...
@@ -81,12 +81,20 @@ class TDTestCase:
tag_sql
+=
f
"
{
k
}
{
v
}
, "
tag_sql
+=
f
"
{
k
}
{
v
}
, "
create_stb_sql
=
f
'create stable
{
stbname
}
(
{
column_sql
[:
-
2
]
}
) tags (
{
tag_sql
[:
-
2
]
}
)'
create_stb_sql
=
f
'create stable
{
stbname
}
(
{
column_sql
[:
-
2
]
}
) tags (
{
tag_sql
[:
-
2
]
}
)'
return
create_stb_sql
return
create_stb_sql
def
set_create_database_sql
(
self
,
sql_dict
):
def
set_create_database_sql
(
self
,
sql_dict
):
create_sql
=
'create'
create_sql
=
'create'
for
key
,
value
in
sql_dict
.
items
():
for
key
,
value
in
sql_dict
.
items
():
create_sql
+=
f
'
{
key
}
{
value
}
'
create_sql
+=
f
'
{
key
}
{
value
}
'
return
create_sql
return
create_sql
def
show_create_sysdb_sql
(
self
):
sysdb_list
=
{
'information_schema'
,
'performance_schema'
}
for
db
in
sysdb_list
:
tdSql
.
query
(
f
'show create database
{
db
}
'
)
tdSql
.
checkEqual
(
f
'
{
db
}
'
,
tdSql
.
queryResult
[
0
][
0
])
tdSql
.
checkEqual
(
f
'CREATE DATABASE `
{
db
}
`'
,
tdSql
.
queryResult
[
0
][
1
])
def
show_create_sql
(
self
):
def
show_create_sql
(
self
):
create_db_sql
=
self
.
set_create_database_sql
(
self
.
db_param
)
create_db_sql
=
self
.
set_create_database_sql
(
self
.
db_param
)
print
(
create_db_sql
)
print
(
create_db_sql
)
...
@@ -106,7 +114,7 @@ class TDTestCase:
...
@@ -106,7 +114,7 @@ class TDTestCase:
tdSql
.
query
(
'show vnodes 1'
)
tdSql
.
query
(
'show vnodes 1'
)
tdSql
.
checkRows
(
self
.
vgroups
)
tdSql
.
checkRows
(
self
.
vgroups
)
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
column_dict
=
{
column_dict
=
{
'`ts`'
:
'timestamp'
,
'`ts`'
:
'timestamp'
,
'`col1`'
:
'tinyint'
,
'`col1`'
:
'tinyint'
,
...
@@ -122,7 +130,7 @@ class TDTestCase:
...
@@ -122,7 +130,7 @@ class TDTestCase:
'`col11`'
:
'bool'
,
'`col11`'
:
'bool'
,
'`col12`'
:
'varchar(20)'
,
'`col12`'
:
'varchar(20)'
,
'`col13`'
:
'nchar(20)'
'`col13`'
:
'nchar(20)'
}
}
tag_dict
=
{
tag_dict
=
{
'`t1`'
:
'tinyint'
,
'`t1`'
:
'tinyint'
,
...
@@ -139,7 +147,7 @@ class TDTestCase:
...
@@ -139,7 +147,7 @@ class TDTestCase:
'`t12`'
:
'varchar(20)'
,
'`t12`'
:
'varchar(20)'
,
'`t13`'
:
'nchar(20)'
,
'`t13`'
:
'nchar(20)'
,
'`t14`'
:
'timestamp'
'`t14`'
:
'timestamp'
}
}
create_table_sql
=
self
.
set_stb_sql
(
self
.
stbname
,
column_dict
,
tag_dict
)
create_table_sql
=
self
.
set_stb_sql
(
self
.
stbname
,
column_dict
,
tag_dict
)
tdSql
.
execute
(
create_table_sql
)
tdSql
.
execute
(
create_table_sql
)
...
@@ -150,7 +158,7 @@ class TDTestCase:
...
@@ -150,7 +158,7 @@ class TDTestCase:
tag_sql
=
'('
tag_sql
=
'('
for
tag_keys
in
tag_dict
.
keys
():
for
tag_keys
in
tag_dict
.
keys
():
tag_sql
+=
f
'
{
tag_keys
}
, '
tag_sql
+=
f
'
{
tag_keys
}
, '
tags
=
f
'
{
tag_sql
[:
-
2
]
}
)'
tags
=
f
'
{
tag_sql
[:
-
2
]
}
)'
sql
=
f
'create table
{
self
.
tbname
}
using
{
self
.
stbname
}
{
tags
}
tags (1, 1, 1, 1, 1, 1, 1, 1, 1.000000e+00, 1.000000e+00, true, "abc", "abc123", 0)'
sql
=
f
'create table
{
self
.
tbname
}
using
{
self
.
stbname
}
{
tags
}
tags (1, 1, 1, 1, 1, 1, 1, 1, 1.000000e+00, 1.000000e+00, true, "abc", "abc123", 0)'
tdSql
.
query
(
f
'show create table
{
self
.
tbname
}
'
)
tdSql
.
query
(
f
'show create table
{
self
.
tbname
}
'
)
query_result
=
tdSql
.
queryResult
query_result
=
tdSql
.
queryResult
...
@@ -173,7 +181,7 @@ class TDTestCase:
...
@@ -173,7 +181,7 @@ class TDTestCase:
taosd_info
=
os
.
popen
(
'taosd -V'
).
read
()
taosd_info
=
os
.
popen
(
'taosd -V'
).
read
()
taosd_gitinfo
=
re
.
findall
(
"^gitinfo.*"
,
taosd_info
,
re
.
M
)
taosd_gitinfo
=
re
.
findall
(
"^gitinfo.*"
,
taosd_info
,
re
.
M
)
tdSql
.
checkEqual
(
taosd_gitinfo_sql
,
taosd_gitinfo
[
0
])
tdSql
.
checkEqual
(
taosd_gitinfo_sql
,
taosd_gitinfo
[
0
])
def
show_base
(
self
):
def
show_base
(
self
):
for
sql
in
[
'dnodes'
,
'mnodes'
,
'cluster'
]:
for
sql
in
[
'dnodes'
,
'mnodes'
,
'cluster'
]:
tdSql
.
query
(
f
'show
{
sql
}
'
)
tdSql
.
query
(
f
'show
{
sql
}
'
)
...
@@ -191,6 +199,7 @@ class TDTestCase:
...
@@ -191,6 +199,7 @@ class TDTestCase:
self
.
ins_check
()
self
.
ins_check
()
self
.
perf_check
()
self
.
perf_check
()
self
.
show_create_sql
()
self
.
show_create_sql
()
self
.
show_create_sysdb_sql
()
def
stop
(
self
):
def
stop
(
self
):
tdSql
.
close
()
tdSql
.
close
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录