Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8b02719e
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
8b02719e
编写于
11月 29, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:[TD-20612] error if write raw with some cols
上级
829a7631
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
83 addition
and
65 deletion
+83
-65
source/client/src/clientRawBlockWrite.c
source/client/src/clientRawBlockWrite.c
+57
-65
utils/test/c/tmq_taosx_ci.c
utils/test/c/tmq_taosx_ci.c
+26
-0
未找到文件。
source/client/src/clientRawBlockWrite.c
浏览文件 @
8b02719e
...
...
@@ -1262,22 +1262,19 @@ int taos_write_raw_block_with_fields(TAOS* taos, int rows, char* pData, const ch
}
uint64_t
suid
=
(
TSDB_NORMAL_TABLE
==
pTableMeta
->
tableType
?
0
:
pTableMeta
->
suid
);
uint64_t
uid
=
pTableMeta
->
uid
;
int32_t
numOfCols
=
numField
s
;
int32_t
numOfCols
=
pTableMeta
->
tableInfo
.
numOfColumn
s
;
uint16_t
fLen
=
0
;
int32_t
rowSize
=
0
;
int16_t
nVar
=
0
;
for
(
int
k
=
0
;
k
<
numOfCols
;
k
++
){
for
(
int
i
=
0
;
i
<
pTableMeta
->
tableInfo
.
numOfColumns
;
i
++
)
{
SSchema
*
schema
=
pTableMeta
->
schema
+
i
;
if
(
strcmp
(
schema
->
name
,
fields
[
k
].
name
)
!=
0
)
continue
;
fLen
+=
TYPE_BYTES
[
schema
->
type
];
rowSize
+=
schema
->
bytes
;
if
(
IS_VAR_DATA_TYPE
(
schema
->
type
))
{
nVar
++
;
}
}
}
fLen
-=
sizeof
(
TSKEY
);
...
...
@@ -1298,14 +1295,14 @@ int taos_write_raw_block_with_fields(TAOS* taos, int rows, char* pData, const ch
int32_t
dataLen
=
0
;
// | version | total length | total rows | total columns | flag seg| block group id | column schema | each column length |
char
*
pStart
=
pData
+
getVersion1BlockMetaSize
(
pData
,
num
OfCol
s
);
char
*
pStart
=
pData
+
getVersion1BlockMetaSize
(
pData
,
num
Field
s
);
int32_t
*
colLength
=
(
int32_t
*
)
pStart
;
pStart
+=
sizeof
(
int32_t
)
*
num
OfCol
s
;
pStart
+=
sizeof
(
int32_t
)
*
num
Field
s
;
SResultColumn
*
pCol
=
taosMemoryCalloc
(
num
OfCol
s
,
sizeof
(
SResultColumn
));
SResultColumn
*
pCol
=
taosMemoryCalloc
(
num
Field
s
,
sizeof
(
SResultColumn
));
for
(
int32_t
i
=
0
;
i
<
num
OfCol
s
;
++
i
)
{
if
(
IS_VAR_DATA_TYPE
(
pTableMeta
->
schema
[
i
].
type
))
{
for
(
int32_t
i
=
0
;
i
<
num
Field
s
;
++
i
)
{
if
(
IS_VAR_DATA_TYPE
(
fields
[
i
].
type
))
{
pCol
[
i
].
offset
=
(
int32_t
*
)
pStart
;
pStart
+=
rows
*
sizeof
(
int32_t
);
}
else
{
...
...
@@ -1317,36 +1314,35 @@ int taos_write_raw_block_with_fields(TAOS* taos, int rows, char* pData, const ch
pStart
+=
colLength
[
i
];
}
SHashObj
*
schemaHash
=
taosHashInit
(
16
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
for
(
int
i
=
0
;
i
<
numFields
;
i
++
)
{
TAOS_FIELD
*
schema
=
&
fields
[
i
];
taosHashPut
(
schemaHash
,
schema
->
name
,
strlen
(
schema
->
name
),
&
i
,
sizeof
(
int32_t
));
}
for
(
int32_t
j
=
0
;
j
<
rows
;
j
++
)
{
tdSRowResetBuf
(
&
rb
,
rowData
);
int32_t
offset
=
0
;
for
(
int32_t
k
=
0
;
k
<
numOfCols
;
k
++
)
{
const
SSchema
*
pColumn
=
NULL
;
for
(
int
i
=
0
;
i
<
pTableMeta
->
tableInfo
.
numOfColumns
;
i
++
)
{
if
(
strcmp
((
pTableMeta
->
schema
+
i
)
->
name
,
fields
[
k
].
name
)
==
0
)
{
pColumn
=
pTableMeta
->
schema
+
i
;
break
;
}
}
if
(
pColumn
==
NULL
){
uError
(
"column not exist:%s"
,
fields
[
k
].
name
);
code
=
TSDB_CODE_INVALID_PARA
;
goto
end
;
}
if
(
IS_VAR_DATA_TYPE
(
pColumn
->
type
))
{
if
(
pCol
[
k
].
offset
[
j
]
!=
-
1
)
{
char
*
data
=
pCol
[
k
].
pData
+
pCol
[
k
].
offset
[
j
];
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NORM
,
data
,
true
,
offset
,
k
);
}
else
{
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NULL
,
NULL
,
false
,
offset
,
k
);
}
}
else
{
if
(
!
colDataIsNull_f
(
pCol
[
k
].
nullbitmap
,
j
))
{
char
*
data
=
pCol
[
k
].
pData
+
pColumn
->
bytes
*
j
;
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NORM
,
data
,
true
,
offset
,
k
);
const
SSchema
*
pColumn
=
&
pTableMeta
->
schema
[
k
];
int32_t
*
index
=
taosHashGet
(
schemaHash
,
pColumn
->
name
,
strlen
(
pColumn
->
name
));
if
(
!
index
)
{
// add none
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NONE
,
NULL
,
false
,
offset
,
k
);
}
else
{
if
(
IS_VAR_DATA_TYPE
(
pColumn
->
type
))
{
if
(
pCol
[
k
].
offset
[
j
]
!=
-
1
)
{
char
*
data
=
pCol
[
k
].
pData
+
pCol
[
k
].
offset
[
j
];
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NORM
,
data
,
true
,
offset
,
k
);
}
else
{
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NULL
,
NULL
,
false
,
offset
,
k
);
}
}
else
{
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NULL
,
NULL
,
false
,
offset
,
k
);
if
(
!
colDataIsNull_f
(
pCol
[
k
].
nullbitmap
,
j
))
{
char
*
data
=
pCol
[
k
].
pData
+
pColumn
->
bytes
*
j
;
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NORM
,
data
,
true
,
offset
,
k
);
}
else
{
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NULL
,
NULL
,
false
,
offset
,
k
);
}
}
}
...
...
@@ -1360,6 +1356,7 @@ int taos_write_raw_block_with_fields(TAOS* taos, int rows, char* pData, const ch
dataLen
+=
rowLen
;
}
taosHashCleanup
(
schemaHash
);
taosMemoryFree
(
pCol
);
blk
->
uid
=
htobe64
(
uid
);
...
...
@@ -1704,8 +1701,8 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
uint16_t
fLen
=
0
;
int32_t
rowSize
=
0
;
int16_t
nVar
=
0
;
for
(
int
i
=
0
;
i
<
p
SW
->
nCol
s
;
i
++
)
{
SSchema
*
schema
=
&
p
SW
->
pS
chema
[
i
];
for
(
int
i
=
0
;
i
<
p
TableMeta
->
tableInfo
.
numOfColumn
s
;
i
++
)
{
SSchema
*
schema
=
&
p
TableMeta
->
s
chema
[
i
];
fLen
+=
TYPE_BYTES
[
schema
->
type
];
rowSize
+=
schema
->
bytes
;
if
(
IS_VAR_DATA_TYPE
(
schema
->
type
))
{
...
...
@@ -1716,7 +1713,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
int32_t
rows
=
rspObj
.
resInfo
.
numOfRows
;
int32_t
extendedRowSize
=
rowSize
+
TD_ROW_HEAD_LEN
-
sizeof
(
TSKEY
)
+
nVar
*
sizeof
(
VarDataOffsetT
)
+
(
int32_t
)
TD_BITMAP_BYTES
(
p
SW
->
nCol
s
-
1
);
(
int32_t
)
TD_BITMAP_BYTES
(
p
TableMeta
->
tableInfo
.
numOfColumn
s
-
1
);
int32_t
schemaLen
=
0
;
int32_t
submitLen
=
sizeof
(
SSubmitBlk
)
+
schemaLen
+
rows
*
extendedRowSize
;
...
...
@@ -1763,14 +1760,14 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
SRowBuilder
rb
=
{
0
};
tdSRowInit
(
&
rb
,
sver
);
tdSRowSetTpInfo
(
&
rb
,
p
SW
->
nCol
s
,
fLen
);
tdSRowSetTpInfo
(
&
rb
,
p
TableMeta
->
tableInfo
.
numOfColumn
s
,
fLen
);
int32_t
totalLen
=
0
;
//
SHashObj* schemaHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
//
for (int i = 0; i < pSW->nCols; i++) {
//
SSchema* schema = &pSW->pSchema[i];
//
taosHashPut(schemaHash, schema->name, strlen(schema->name), &i, sizeof(int32_t));
//
}
SHashObj
*
schemaHash
=
taosHashInit
(
16
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
for
(
int
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
SSchema
*
schema
=
&
pSW
->
pSchema
[
i
];
taosHashPut
(
schemaHash
,
schema
->
name
,
strlen
(
schema
->
name
),
&
i
,
sizeof
(
int32_t
));
}
for
(
int32_t
j
=
0
;
j
<
rows
;
j
++
)
{
tdSRowResetBuf
(
&
rb
,
rowData
);
...
...
@@ -1779,29 +1776,22 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
rspObj
.
resInfo
.
current
+=
1
;
int32_t
offset
=
0
;
for
(
int32_t
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
const
SSchema
*
pColumn
=
NULL
;
for
(
int32_t
k
=
0
;
k
<
pTableMeta
->
tableInfo
.
numOfColumns
;
k
++
)
{
if
(
strcmp
(
pTableMeta
->
schema
[
k
].
name
,
pSW
->
pSchema
[
i
].
name
)
==
0
)
{
pColumn
=
&
pTableMeta
->
schema
[
k
];
break
;
}
}
if
(
pColumn
==
NULL
){
uError
(
"column not exist:%s"
,
pSW
->
pSchema
[
i
].
name
);
code
=
TSDB_CODE_INVALID_PARA
;
goto
end
;
}
char
*
colData
=
rspObj
.
resInfo
.
row
[
i
];
if
(
!
colData
)
{
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NULL
,
NULL
,
false
,
offset
,
i
);
for
(
int32_t
k
=
0
;
k
<
pTableMeta
->
tableInfo
.
numOfColumns
;
k
++
)
{
const
SSchema
*
pColumn
=
&
pTableMeta
->
schema
[
k
];
int32_t
*
index
=
taosHashGet
(
schemaHash
,
pColumn
->
name
,
strlen
(
pColumn
->
name
));
if
(
!
index
)
{
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NONE
,
NULL
,
false
,
offset
,
k
);
}
else
{
if
(
IS_VAR_DATA_TYPE
(
pColumn
->
type
))
{
colData
-=
VARSTR_HEADER_SIZE
;
char
*
colData
=
rspObj
.
resInfo
.
row
[
*
index
];
if
(
!
colData
)
{
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NULL
,
NULL
,
false
,
offset
,
k
);
}
else
{
if
(
IS_VAR_DATA_TYPE
(
pColumn
->
type
))
{
colData
-=
VARSTR_HEADER_SIZE
;
}
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NORM
,
colData
,
true
,
offset
,
k
);
}
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NORM
,
colData
,
true
,
offset
,
i
);
}
if
(
pColumn
->
colId
!=
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
offset
+=
TYPE_BYTES
[
pColumn
->
type
];
}
...
...
@@ -1812,6 +1802,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
totalLen
+=
rowLen
;
}
taosHashCleanup
(
schemaHash
);
blk
->
uid
=
htobe64
(
uid
);
blk
->
suid
=
htobe64
(
suid
);
blk
->
sversion
=
htonl
(
sver
);
...
...
@@ -1882,6 +1873,7 @@ end:
return
code
;
}
static
int32_t
tmqWriteRawMetaDataImpl
(
TAOS
*
taos
,
void
*
data
,
int32_t
dataLen
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
SHashObj
*
pVgHash
=
NULL
;
...
...
@@ -2094,7 +2086,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
const
SSchema
*
pColumn
=
&
pTableMeta
->
schema
[
k
];
int32_t
*
index
=
taosHashGet
(
schemaHash
,
pColumn
->
name
,
strlen
(
pColumn
->
name
));
if
(
!
index
)
{
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_N
ULL
,
NULL
,
false
,
offset
,
k
);
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_N
ONE
,
NULL
,
false
,
offset
,
k
);
}
else
{
char
*
colData
=
rspObj
.
resInfo
.
row
[
*
index
];
if
(
!
colData
)
{
...
...
@@ -2175,7 +2167,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
launchQueryImpl
(
pRequest
,
pQuery
,
true
,
NULL
);
code
=
pRequest
->
code
;
end:
end:
tDeleteSTaosxRsp
(
&
rspObj
.
rsp
);
rspObj
.
resInfo
.
pRspMsg
=
NULL
;
doFreeReqResultInfo
(
&
rspObj
.
resInfo
);
...
...
utils/test/c/tmq_taosx_ci.c
浏览文件 @
8b02719e
...
...
@@ -76,6 +76,32 @@ static void msg_process(TAOS_RES* msg) {
}
int
buildDatabase
(
TAOS
*
pConn
,
TAOS_RES
*
pRes
){
/* test for TD-20612 start*/
// pRes = taos_query(pConn,"create table tb1 (ts timestamp, c1 int, c2 int)");
// if (taos_errno(pRes) != 0) {
// printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes));
// return -1;
// }
// taos_free_result(pRes);
//
// pRes = taos_query(pConn,"insert into tb1 (ts, c1) values(1669092069069, 0)");
// if (taos_errno(pRes) != 0) {
// printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes));
// return -1;
// }
// taos_free_result(pRes);
//
// pRes = taos_query(pConn,"insert into tb1 (ts, c2) values(1669092069069, 1)");
// if (taos_errno(pRes) != 0) {
// printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes));
// return -1;
// }
// taos_free_result(pRes);
//
// return 0;
/* test for TD-20612 end*/
pRes
=
taos_query
(
pConn
,
"create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 "
"nchar(8), t4 bool)"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录