Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
adff7af9
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看板
提交
adff7af9
编写于
9月 08, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: add table_prefix and table_suffix options to database
上级
d32b8fa0
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
115 addition
and
1 deletion
+115
-1
include/util/tutil.h
include/util/tutil.h
+12
-1
source/common/src/systable.c
source/common/src/systable.c
+2
-0
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+16
-0
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+1
-0
tests/script/tsim/table/hash.sim
tests/script/tsim/table/hash.sim
+84
-0
未找到文件。
include/util/tutil.h
浏览文件 @
adff7af9
...
...
@@ -69,7 +69,18 @@ static FORCE_INLINE void taosEncryptPass_c(uint8_t *inBuf, size_t len, char *tar
memcpy
(
target
,
buf
,
TSDB_PASSWORD_LEN
);
}
#define taosGetTbHashVal(tbname, tblen, method, prefix, suffix) MurmurHash3_32((tbname), (tblen))
FORCE_INLINE
int32_t
taosGetTbHashVal
(
const
char
*
tbname
,
int32_t
tblen
,
int32_t
method
,
int32_t
prefix
,
int32_t
suffix
)
{
if
(
prefix
==
0
&&
suffix
==
0
)
{
return
MurmurHash3_32
(
tbname
,
tblen
);
}
else
{
if
(
tblen
<=
(
prefix
+
suffix
))
{
return
MurmurHash3_32
(
tbname
,
tblen
);
}
else
{
return
MurmurHash3_32
(
tbname
+
prefix
,
tblen
-
prefix
-
suffix
);
}
}
}
#ifdef __cplusplus
}
...
...
source/common/src/systable.c
浏览文件 @
adff7af9
...
...
@@ -103,6 +103,8 @@ static const SSysDbTableSchema userDBSchema[] = {
{.
name
=
"wal_roll_period"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
,
.
sysInfo
=
true
},
{.
name
=
"wal_segment_size"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_BIGINT
,
.
sysInfo
=
true
},
{.
name
=
"sst_trigger"
,
.
bytes
=
2
,
.
type
=
TSDB_DATA_TYPE_SMALLINT
,
.
sysInfo
=
true
},
{.
name
=
"table_prefix"
,
.
bytes
=
2
,
.
type
=
TSDB_DATA_TYPE_SMALLINT
,
.
sysInfo
=
true
},
{.
name
=
"table_suffix"
,
.
bytes
=
2
,
.
type
=
TSDB_DATA_TYPE_SMALLINT
,
.
sysInfo
=
true
},
};
static
const
SSysDbTableSchema
userFuncSchema
[]
=
{
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
adff7af9
...
...
@@ -513,6 +513,12 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
return
-
1
;
}
if
(
dbObj
.
cfg
.
hashPrefix
>
0
)
{
int32_t
dbLen
=
strlen
(
dbObj
.
name
)
+
1
;
mInfo
(
"db:%s, hashPrefix adjust from %d to %d"
,
dbObj
.
name
,
dbObj
.
cfg
.
hashPrefix
,
dbObj
.
cfg
.
hashPrefix
+
dbLen
);
dbObj
.
cfg
.
hashPrefix
+=
dbLen
;
}
SVgObj
*
pVgroups
=
NULL
;
if
(
mndAllocVgroup
(
pMnode
,
&
dbObj
,
&
pVgroups
)
!=
0
)
{
mError
(
"db:%s, failed to create since %s"
,
pCreate
->
db
,
terrstr
());
...
...
@@ -1710,6 +1716,16 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
rows
,
(
const
char
*
)
&
pDb
->
cfg
.
sstTrigger
,
false
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
int16_t
hashPrefix
=
pDb
->
cfg
.
hashPrefix
;
if
(
hashPrefix
>
0
)
{
hashPrefix
=
pDb
->
cfg
.
hashPrefix
-
strlen
(
pDb
->
name
)
-
1
;
}
colDataAppend
(
pColInfo
,
rows
,
(
const
char
*
)
&
hashPrefix
,
false
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
rows
,
(
const
char
*
)
&
pDb
->
cfg
.
hashSuffix
,
false
);
}
taosMemoryFree
(
buf
);
...
...
tests/script/jenkins/basic.txt
浏览文件 @
adff7af9
...
...
@@ -221,6 +221,7 @@
./test.sh -f tsim/table/describe.sim
./test.sh -f tsim/table/double.sim
./test.sh -f tsim/table/float.sim
./test.sh -f tsim/table/hash.sim
./test.sh -f tsim/table/int.sim
./test.sh -f tsim/table/limit.sim
./test.sh -f tsim/table/smallint.sim
...
...
tests/script/tsim/table/hash.sim
0 → 100644
浏览文件 @
adff7af9
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
#=========== prepare
#sql create database d1 vgroups 2
sql create database d1 vgroups 2 table_prefix 3 table_suffix 2
sql select * from information_schema.ins_databases
print $data(d1)[27] $data(d1)[28]
if $data(d1)[27] != 3 then
return -1
endi
if $data(d1)[28] != 2 then
return -1
endi
sql use d1;
sql create table st (ts timestamp, i int) tags (j int);
sql create table st_ct_1 using st tags(3) st_ct_2 using st tags(4) st_ct_3 using st tags(5) st_ct_4 using st tags(6) st_ct_5 using st tags(7)
sql insert into st_ct_1 values(now+1s, 1)
sql insert into st_ct_1 values(now+2s, 2)
sql insert into st_ct_1 values(now+3s, 3)
sql insert into st_ct_2 values(now+1s, 1)
sql insert into st_ct_2 values(now+2s, 2)
sql insert into st_ct_2 values(now+3s, 3)
sql insert into st_ct_3 values(now+1s, 1)
sql insert into st_ct_3 values(now+2s, 2)
sql insert into st_ct_3 values(now+3s, 2)
sql insert into st_ct_4 values(now+1s, 1)
sql insert into st_ct_4 values(now+2s, 2)
sql insert into st_ct_4 values(now+3s, 2)
sql insert into st_ct_5 values(now+1s, 1)
sql insert into st_ct_5 values(now+2s, 2)
sql insert into st_ct_5 values(now+3s, 2)
# check query
sql select * from st
if $rows != 15 then
return -1
endi
# check table vgroup
sql select * from information_schema.ins_tables where db_name = 'd1'
if $data(st_ct_1)[6] != 2 then
return -1
endi
if $data(st_ct_2)[6] != 2 then
return -1
endi
if $data(st_ct_3)[6] != 2 then
return -1
endi
if $data(st_ct_4)[6] != 2 then
return -1
endi
if $data(st_ct_5)[6] != 2 then
return -1
endi
# check invalid table name
sql create table c1 using st tags(3)
sql create table c12 using st tags(3)
sql create table c123 using st tags(3)
sql create table c1234 using st tags(3)
sql create table c12345 using st tags(3)
sql select * from information_schema.ins_tables where db_name = 'd1'
if $data(c1)[6] != 2 then
return -1
endi
if $data(c12)[6] != 3 then
return -1
endi
if $data(c123)[6] != 2 then
return -1
endi
if $data(c1234)[6] != 3 then
return -1
endi
if $data(c12345)[6] != 3 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录