Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
03a18757
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
03a18757
编写于
8月 19, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:error in snapshot for taosx
上级
fbc69a10
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
133 addition
and
15 deletion
+133
-15
examples/c/tmq_taosx.c
examples/c/tmq_taosx.c
+7
-0
include/common/tdataformat.h
include/common/tdataformat.h
+1
-0
source/client/src/taosx.c
source/client/src/taosx.c
+28
-3
source/common/src/tdataformat.c
source/common/src/tdataformat.c
+20
-0
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+29
-0
source/dnode/vnode/src/meta/metaSnapshot.c
source/dnode/vnode/src/meta/metaSnapshot.c
+30
-11
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+17
-0
source/libs/tdb/src/db/tdbBtree.c
source/libs/tdb/src/db/tdbBtree.c
+1
-1
未找到文件。
examples/c/tmq_taosx.c
浏览文件 @
03a18757
...
...
@@ -163,6 +163,13 @@ int32_t init_env() {
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create table if not exists ct4 using st1(t3) tags('ct4')"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create child table ct4, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"insert into ct3 values(1626006833600, 5, 6, 'c') ct1 values(1626006833601, 2, 3, 'sds') (1626006833602, 4, 5, 'ddd') ct0 values(1626006833602, 4, 3, 'hwj') ct1 values(now+5s, 23, 32, 's21ds')"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to insert into ct3, reason:%s
\n
"
,
taos_errstr
(
pRes
));
...
...
include/common/tdataformat.h
浏览文件 @
03a18757
...
...
@@ -100,6 +100,7 @@ char *tTagValToData(const STagVal *pTagVal, bool isJson);
int32_t
tEncodeTag
(
SEncoder
*
pEncoder
,
const
STag
*
pTag
);
int32_t
tDecodeTag
(
SDecoder
*
pDecoder
,
STag
**
ppTag
);
int32_t
tTagToValArray
(
const
STag
*
pTag
,
SArray
**
ppArray
);
void
tTagSetCid
(
const
STag
*
pTag
,
int16_t
iTag
,
int16_t
cid
);
void
debugPrintSTag
(
STag
*
pTag
,
const
char
*
tag
,
int32_t
ln
);
// TODO: remove
int32_t
parseJsontoTagData
(
const
char
*
json
,
SArray
*
pTagVals
,
STag
**
ppTag
,
void
*
pMsgBuf
);
...
...
source/client/src/taosx.c
浏览文件 @
03a18757
...
...
@@ -765,6 +765,28 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
}
taosArrayPush
(
pRequest
->
tableList
,
&
pName
);
// change tag cid to new cid
if
(
pCreateReq
->
type
==
TSDB_CHILD_TABLE
){
STableMeta
*
pTableMeta
=
NULL
;
code
=
catalogGetTableMeta
(
pCatalog
,
&
conn
,
&
pName
,
&
pTableMeta
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"taosCreateTable:catalogGetTableMeta failed. table name: %s"
,
pCreateReq
->
name
);
taosMemoryFreeClear
(
pTableMeta
);
goto
end
;
}
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pCreateReq
->
ctb
.
tagName
);
i
++
){
char
*
tName
=
taosArrayGet
(
pCreateReq
->
ctb
.
tagName
,
i
);
for
(
int32_t
j
=
pTableMeta
->
tableInfo
.
numOfColumns
;
j
<
pTableMeta
->
tableInfo
.
numOfColumns
+
pTableMeta
->
tableInfo
.
numOfTags
;
j
++
){
SSchema
*
tag
=
&
pTableMeta
->
schema
[
j
];
if
(
strcmp
(
tag
->
name
,
tName
)
==
0
){
tTagSetCid
((
STag
*
)
pCreateReq
->
ctb
.
pTag
,
i
,
tag
->
colId
);
}
}
}
taosMemoryFreeClear
(
pTableMeta
);
}
SVgroupCreateTableBatch
*
pTableBatch
=
taosHashGet
(
pVgroupHashmap
,
&
pInfo
.
vgId
,
sizeof
(
pInfo
.
vgId
));
if
(
pTableBatch
==
NULL
)
{
SVgroupCreateTableBatch
tBatch
=
{
0
};
...
...
@@ -1436,15 +1458,18 @@ static int32_t tmqWriteRaw(TAOS* taos, void* data, int32_t dataLen) {
uError
(
"WriteRaw:catalogGetTableMeta failed. table name: %s"
,
tbName
);
goto
end
;
}
// pSW->pSchema should be same as pTableMeta->schema
ASSERT
(
pSW
->
nCols
==
pTableMeta
->
tableInfo
.
numOfColumns
);
uint64_t
suid
=
(
TSDB_NORMAL_TABLE
==
pTableMeta
->
tableType
?
0
:
pTableMeta
->
suid
);
uint64_t
uid
=
pTableMeta
->
uid
;
int16_t
sver
=
pTableMeta
->
sversion
;
taosMemoryFreeClear
(
pTableMeta
);
void
*
blkSchema
=
POINTER_SHIFT
(
blk
,
sizeof
(
SSubmitBlk
));
STSRow
*
rowData
=
POINTER_SHIFT
(
blkSchema
,
schemaLen
);
SRowBuilder
rb
=
{
0
};
tdSRowInit
(
&
rb
,
pSW
->
version
);
tdSRowInit
(
&
rb
,
sver
);
tdSRowSetTpInfo
(
&
rb
,
pSW
->
nCols
,
fLen
);
int32_t
dataLen
=
0
;
...
...
@@ -1457,7 +1482,7 @@ static int32_t tmqWriteRaw(TAOS* taos, void* data, int32_t dataLen) {
int32_t
offset
=
0
;
for
(
int32_t
k
=
0
;
k
<
pSW
->
nCols
;
k
++
)
{
const
SSchema
*
pColumn
=
&
pSW
->
pSchema
[
k
];
char
*
data
=
rspObj
.
resInfo
.
row
[
k
];
char
*
data
=
rspObj
.
resInfo
.
row
[
k
];
if
(
!
data
)
{
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NULL
,
NULL
,
false
,
offset
,
k
);
}
else
{
...
...
@@ -1476,7 +1501,7 @@ static int32_t tmqWriteRaw(TAOS* taos, void* data, int32_t dataLen) {
blk
->
uid
=
htobe64
(
uid
);
blk
->
suid
=
htobe64
(
suid
);
blk
->
sversion
=
htonl
(
pSW
->
version
);
blk
->
sversion
=
htonl
(
sver
);
blk
->
schemaLen
=
htonl
(
schemaLen
);
blk
->
numOfRows
=
htonl
(
rows
);
blk
->
dataLen
=
htonl
(
dataLen
);
...
...
source/common/src/tdataformat.c
浏览文件 @
03a18757
...
...
@@ -1064,6 +1064,26 @@ _err:
return
code
;
}
void
tTagSetCid
(
const
STag
*
pTag
,
int16_t
iTag
,
int16_t
cid
)
{
uint8_t
*
p
=
NULL
;
int8_t
isLarge
=
pTag
->
flags
&
TD_TAG_LARGE
;
int16_t
offset
=
0
;
if
(
isLarge
)
{
p
=
(
uint8_t
*
)
&
((
int16_t
*
)
pTag
->
idx
)[
pTag
->
nTag
];
}
else
{
p
=
(
uint8_t
*
)
&
pTag
->
idx
[
pTag
->
nTag
];
}
if
(
isLarge
)
{
offset
=
((
int16_t
*
)
pTag
->
idx
)[
iTag
];
}
else
{
offset
=
pTag
->
idx
[
iTag
];
}
tPutI16v
(
p
+
offset
,
cid
);
}
#if 1 // ===================================================================================================================
int
tdInitTSchemaBuilder
(
STSchemaBuilder
*
pBuilder
,
schema_ver_t
version
)
{
if
(
pBuilder
==
NULL
)
return
-
1
;
...
...
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
03a18757
...
...
@@ -833,6 +833,35 @@ const void *metaGetTableTagVal(void *pTag, int16_t type, STagVal *val) {
if
(
!
find
)
{
return
NULL
;
}
if
(
IS_VAR_DATA_TYPE
(
val
->
type
))
{
char
*
buf
=
taosMemoryCalloc
(
val
->
nData
+
1
,
1
);
memcpy
(
buf
,
val
->
pData
,
val
->
nData
);
metaDebug
(
"metaTag table val varchar index:%d cid:%d type:%d value:%s"
,
1
,
val
->
cid
,
val
->
type
,
buf
);
taosMemoryFree
(
buf
);
}
else
{
double
dval
=
0
;
GET_TYPED_DATA
(
dval
,
double
,
val
->
type
,
&
val
->
i64
);
metaDebug
(
"metaTag table val number index:%d cid:%d type:%d value:%f"
,
1
,
val
->
cid
,
val
->
type
,
dval
);
}
SArray
*
pTagVals
=
NULL
;
tTagToValArray
((
STag
*
)
pTag
,
&
pTagVals
);
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pTagVals
);
i
++
)
{
STagVal
*
pTagVal
=
(
STagVal
*
)
taosArrayGet
(
pTagVals
,
i
);
if
(
IS_VAR_DATA_TYPE
(
pTagVal
->
type
))
{
char
*
buf
=
taosMemoryCalloc
(
pTagVal
->
nData
+
1
,
1
);
memcpy
(
buf
,
pTagVal
->
pData
,
pTagVal
->
nData
);
metaDebug
(
"metaTag table varchar index:%d cid:%d type:%d value:%s"
,
i
,
pTagVal
->
cid
,
pTagVal
->
type
,
buf
);
taosMemoryFree
(
buf
);
}
else
{
double
dval
=
0
;
GET_TYPED_DATA
(
dval
,
double
,
pTagVal
->
type
,
&
pTagVal
->
i64
);
metaDebug
(
"metaTag table number index:%d cid:%d type:%d value:%f"
,
i
,
pTagVal
->
cid
,
pTagVal
->
type
,
dval
);
}
}
return
val
;
}
...
...
source/dnode/vnode/src/meta/metaSnapshot.c
浏览文件 @
03a18757
...
...
@@ -198,7 +198,6 @@ _err:
typedef
struct
STableInfoForChildTable
{
char
*
tableName
;
SArray
*
tagName
;
SSchemaWrapper
*
schemaRow
;
SSchemaWrapper
*
tagRow
;
}
STableInfoForChildTable
;
...
...
@@ -206,8 +205,8 @@ typedef struct STableInfoForChildTable{
static
void
destroySTableInfoForChildTable
(
void
*
data
)
{
STableInfoForChildTable
*
pData
=
(
STableInfoForChildTable
*
)
data
;
taosMemoryFree
(
pData
->
tableName
);
taosArrayDestroy
(
pData
->
tagName
);
tDeleteSSchemaWrapper
(
pData
->
schemaRow
);
tDeleteSSchemaWrapper
(
pData
->
tagRow
);
}
static
void
MoveToSnapShotVersion
(
SSnapContext
*
ctx
){
...
...
@@ -243,11 +242,7 @@ static void saveSuperTableInfoForChildTable(SMetaEntry *me, SHashObj *suidInfo){
}
STableInfoForChildTable
dataTmp
=
{
0
};
dataTmp
.
tableName
=
strdup
(
me
->
name
);
dataTmp
.
tagName
=
taosArrayInit
(
me
->
stbEntry
.
schemaTag
.
nCols
,
TSDB_COL_NAME_LEN
);
for
(
int
i
=
0
;
i
<
me
->
stbEntry
.
schemaTag
.
nCols
;
i
++
){
SSchema
*
schema
=
&
me
->
stbEntry
.
schemaTag
.
pSchema
[
i
];
taosArrayPush
(
dataTmp
.
tagName
,
schema
->
name
);
}
dataTmp
.
schemaRow
=
tCloneSSchemaWrapper
(
&
me
->
stbEntry
.
schemaRow
);
dataTmp
.
tagRow
=
tCloneSSchemaWrapper
(
&
me
->
stbEntry
.
schemaTag
);
taosHashPut
(
suidInfo
,
&
me
->
uid
,
sizeof
(
tb_uid_t
),
&
dataTmp
,
sizeof
(
STableInfoForChildTable
));
...
...
@@ -484,14 +479,37 @@ int32_t getMetafromSnapShot(SSnapContext* ctx, void **pBuf, int32_t *contLen, in
ASSERT
(
data
);
SVCreateTbReq
req
=
{
0
};
req
.
type
=
T
D
_CHILD_TABLE
;
req
.
type
=
T
SDB
_CHILD_TABLE
;
req
.
name
=
me
.
name
;
req
.
uid
=
me
.
uid
;
req
.
commentLen
=
-
1
;
req
.
ctb
.
suid
=
me
.
ctbEntry
.
suid
;
req
.
ctb
.
tagNum
=
taosArrayGetSize
(
data
->
tagName
)
;
req
.
ctb
.
tagNum
=
data
->
tagRow
->
nCols
;
req
.
ctb
.
name
=
data
->
tableName
;
SArray
*
tagName
=
taosArrayInit
(
req
.
ctb
.
tagNum
,
TSDB_COL_NAME_LEN
);
STag
*
p
=
(
STag
*
)
me
.
ctbEntry
.
pTags
;
if
(
tTagIsJson
(
p
)){
if
(
p
->
nTag
!=
0
)
{
SSchema
*
schema
=
&
data
->
tagRow
->
pSchema
[
0
];
taosArrayPush
(
tagName
,
schema
->
name
);
}
}
else
{
SArray
*
pTagVals
=
NULL
;
if
(
tTagToValArray
((
const
STag
*
)
p
,
&
pTagVals
)
!=
0
)
{
ASSERT
(
0
);
}
int16_t
nCols
=
taosArrayGetSize
(
pTagVals
);
for
(
int
j
=
0
;
j
<
nCols
;
++
j
)
{
STagVal
*
pTagVal
=
(
STagVal
*
)
taosArrayGet
(
pTagVals
,
j
);
for
(
int
i
=
0
;
i
<
data
->
tagRow
->
nCols
;
i
++
){
SSchema
*
schema
=
&
data
->
tagRow
->
pSchema
[
i
];
if
(
schema
->
colId
==
pTagVal
->
cid
){
taosArrayPush
(
tagName
,
schema
->
name
);
}
}
}
}
// SIdInfo* sidInfo = (SIdInfo*)taosHashGet(ctx->idVersion, &me.ctbEntry.suid, sizeof(tb_uid_t));
// if(sidInfo->version >= idInfo->version){
// // need parse tag
...
...
@@ -508,12 +526,13 @@ int32_t getMetafromSnapShot(SSnapContext* ctx, void **pBuf, int32_t *contLen, in
req
.
ctb
.
pTag
=
me
.
ctbEntry
.
pTags
;
// }
req
.
ctb
.
tagName
=
data
->
tagName
;
req
.
ctb
.
tagName
=
tagName
;
ret
=
buildNormalChildTableInfo
(
&
req
,
pBuf
,
contLen
);
*
type
=
TDMT_VND_CREATE_TABLE
;
taosArrayDestroy
(
tagName
);
}
else
if
(
ctx
->
subType
==
TOPIC_SUB_TYPE__DB
){
SVCreateTbReq
req
=
{
0
};
req
.
type
=
T
D
_NORMAL_TABLE
;
req
.
type
=
T
SDB
_NORMAL_TABLE
;
req
.
name
=
me
.
name
;
req
.
uid
=
me
.
uid
;
req
.
commentLen
=
-
1
;
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
03a18757
...
...
@@ -416,6 +416,23 @@ int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq) {
me
.
ctbEntry
.
suid
=
pReq
->
ctb
.
suid
;
me
.
ctbEntry
.
pTags
=
pReq
->
ctb
.
pTag
;
SArray
*
pTagVals
=
NULL
;
int32_t
code
=
tTagToValArray
((
STag
*
)
pReq
->
ctb
.
pTag
,
&
pTagVals
);
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pTagVals
);
i
++
)
{
STagVal
*
pTagVal
=
(
STagVal
*
)
taosArrayGet
(
pTagVals
,
i
);
if
(
IS_VAR_DATA_TYPE
(
pTagVal
->
type
))
{
char
*
buf
=
taosMemoryCalloc
(
pTagVal
->
nData
+
1
,
1
);
memcpy
(
buf
,
pTagVal
->
pData
,
pTagVal
->
nData
);
metaDebug
(
"metaTag table:%s varchar index:%d cid:%d type:%d value:%s"
,
pReq
->
name
,
i
,
pTagVal
->
cid
,
pTagVal
->
type
,
buf
);
taosMemoryFree
(
buf
);
}
else
{
double
val
=
0
;
GET_TYPED_DATA
(
val
,
double
,
pTagVal
->
type
,
&
pTagVal
->
i64
);
metaDebug
(
"metaTag table:%s number index:%d cid:%d type:%d value:%f"
,
pReq
->
name
,
i
,
pTagVal
->
cid
,
pTagVal
->
type
,
val
);
}
}
++
pMeta
->
pVnode
->
config
.
vndStats
.
numOfCTables
;
}
else
{
me
.
ntbEntry
.
ctime
=
pReq
->
ctime
;
...
...
source/libs/tdb/src/db/tdbBtree.c
浏览文件 @
03a18757
...
...
@@ -1401,7 +1401,7 @@ static int tdbBtreeDecodeCell(SPage *pPage, const SCell *pCell, SCellDecoder *pD
pDecoder
->
pgno
=
0
;
TDB_CELLDECODER_SET_FREE_NIL
(
pDecoder
);
tdbDebug
(
"tdb btc decoder set nil: %p/0x%x "
,
pDecoder
,
pDecoder
->
freeKV
);
//
tdbDebug("tdb btc decoder set nil: %p/0x%x ", pDecoder, pDecoder->freeKV);
// 1. Decode header part
if
(
!
leaf
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录