Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5d06474f
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
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看板
提交
5d06474f
编写于
3月 24, 2023
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:send data batch if consume wal where subscribe db
上级
dcaab41a
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
324 addition
and
394 deletion
+324
-394
source/common/src/tdataformat.c
source/common/src/tdataformat.c
+4
-0
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+10
-0
source/dnode/vnode/src/tq/tqExec.c
source/dnode/vnode/src/tq/tqExec.c
+1
-1
source/libs/parser/src/parInsertUtil.c
source/libs/parser/src/parInsertUtil.c
+31
-115
utils/test/c/tmq_taosx_ci.c
utils/test/c/tmq_taosx_ci.c
+278
-278
未找到文件。
source/common/src/tdataformat.c
浏览文件 @
5d06474f
...
@@ -2439,6 +2439,10 @@ _exit:
...
@@ -2439,6 +2439,10 @@ _exit:
int32_t
tColDataAddValueByDataBlock
(
SColData
*
pColData
,
int8_t
type
,
int32_t
bytes
,
int32_t
nRows
,
char
*
lengthOrbitmap
,
int32_t
tColDataAddValueByDataBlock
(
SColData
*
pColData
,
int8_t
type
,
int32_t
bytes
,
int32_t
nRows
,
char
*
lengthOrbitmap
,
char
*
data
)
{
char
*
data
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
if
(
data
==
NULL
){
code
=
tColDataAppendValueImpl
[
pColData
->
flag
][
CV_FLAG_NONE
](
pColData
,
NULL
,
0
);
goto
_exit
;
}
if
(
IS_VAR_DATA_TYPE
(
type
))
{
// var-length data type
if
(
IS_VAR_DATA_TYPE
(
type
))
{
// var-length data type
for
(
int32_t
i
=
0
;
i
<
nRows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
nRows
;
++
i
)
{
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
5d06474f
...
@@ -629,6 +629,14 @@ static int32_t extractDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq*
...
@@ -629,6 +629,14 @@ static int32_t extractDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq*
// process meta
// process meta
if
(
pHead
->
msgType
!=
TDMT_VND_SUBMIT
)
{
if
(
pHead
->
msgType
!=
TDMT_VND_SUBMIT
)
{
if
(
totalRows
>
0
)
{
tqOffsetResetToLog
(
&
taosxRsp
.
rspOffset
,
fetchVer
-
1
);
code
=
tqSendDataRsp
(
pTq
,
pMsg
,
pRequest
,
(
SMqDataRsp
*
)
&
taosxRsp
,
TMQ_MSG_TYPE__TAOSX_RSP
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
taosMemoryFreeClear
(
pCkHead
);
return
code
;
}
tqDebug
(
"fetch meta msg, ver:%"
PRId64
", type:%s"
,
pHead
->
version
,
TMSG_INFO
(
pHead
->
msgType
));
tqDebug
(
"fetch meta msg, ver:%"
PRId64
", type:%s"
,
pHead
->
version
,
TMSG_INFO
(
pHead
->
msgType
));
tqOffsetResetToLog
(
&
metaRsp
.
rspOffset
,
fetchVer
);
tqOffsetResetToLog
(
&
metaRsp
.
rspOffset
,
fetchVer
);
metaRsp
.
resMsgType
=
pHead
->
msgType
;
metaRsp
.
resMsgType
=
pHead
->
msgType
;
...
@@ -656,6 +664,8 @@ static int32_t extractDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq*
...
@@ -656,6 +664,8 @@ static int32_t extractDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq*
if
(
tqTaosxScanLog
(
pTq
,
pHandle
,
submit
,
&
taosxRsp
,
&
totalRows
)
<
0
)
{
if
(
tqTaosxScanLog
(
pTq
,
pHandle
,
submit
,
&
taosxRsp
,
&
totalRows
)
<
0
)
{
tqError
(
"tmq poll: tqTaosxScanLog error %"
PRId64
", in vgId:%d, subkey %s"
,
consumerId
,
vgId
,
tqError
(
"tmq poll: tqTaosxScanLog error %"
PRId64
", in vgId:%d, subkey %s"
,
consumerId
,
vgId
,
pRequest
->
subKey
);
pRequest
->
subKey
);
taosMemoryFreeClear
(
pCkHead
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
return
-
1
;
return
-
1
;
}
}
...
...
source/dnode/vnode/src/tq/tqExec.c
浏览文件 @
5d06474f
...
@@ -346,7 +346,7 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR
...
@@ -346,7 +346,7 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR
SSDataBlock
*
pBlock
=
taosArrayGet
(
pBlocks
,
i
);
SSDataBlock
*
pBlock
=
taosArrayGet
(
pBlocks
,
i
);
tqAddBlockDataToRsp
(
pBlock
,
(
SMqDataRsp
*
)
pRsp
,
taosArrayGetSize
(
pBlock
->
pDataBlock
),
tqAddBlockDataToRsp
(
pBlock
,
(
SMqDataRsp
*
)
pRsp
,
taosArrayGetSize
(
pBlock
->
pDataBlock
),
pTq
->
pVnode
->
config
.
tsdbCfg
.
precision
);
pTq
->
pVnode
->
config
.
tsdbCfg
.
precision
);
totalRows
+=
pBlock
->
info
.
rows
;
*
totalRows
+=
pBlock
->
info
.
rows
;
blockDataFreeRes
(
pBlock
);
blockDataFreeRes
(
pBlock
);
SSchemaWrapper
*
pSW
=
taosArrayGetP
(
pSchemas
,
i
);
SSchemaWrapper
*
pSW
=
taosArrayGetP
(
pSchemas
,
i
);
taosArrayPush
(
pRsp
->
blockSchema
,
&
pSW
);
taosArrayPush
(
pRsp
->
blockSchema
,
&
pSW
);
...
...
source/libs/parser/src/parInsertUtil.c
浏览文件 @
5d06474f
...
@@ -566,75 +566,14 @@ int32_t insBuildVgDataBlocks(SHashObj* pVgroupsHashObj, SArray* pVgDataCxtList,
...
@@ -566,75 +566,14 @@ int32_t insBuildVgDataBlocks(SHashObj* pVgroupsHashObj, SArray* pVgDataCxtList,
return
code
;
return
code
;
}
}
static
int
bindFileds
(
SBoundColInfo
*
pBoundInfo
,
SSchema
*
pSchema
,
TAOS_FIELD
*
fields
,
int
numFields
)
{
static
bool
findFileds
(
SSchema
*
pSchema
,
TAOS_FIELD
*
fields
,
int
numFields
)
{
bool
*
pUseCols
=
taosMemoryCalloc
(
pBoundInfo
->
numOfCols
,
sizeof
(
bool
));
if
(
NULL
==
pUseCols
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pBoundInfo
->
numOfBound
=
0
;
int16_t
lastColIdx
=
-
1
;
// last column found
int32_t
code
=
TSDB_CODE_SUCCESS
;
for
(
int
i
=
0
;
i
<
numFields
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numFields
;
i
++
)
{
SToken
token
;
if
(
strcmp
(
pSchema
->
name
,
fields
[
i
].
name
)
==
0
){
token
.
z
=
fields
[
i
].
name
;
return
true
;
token
.
n
=
strlen
(
fields
[
i
].
name
);
int16_t
t
=
lastColIdx
+
1
;
int16_t
index
=
insFindCol
(
&
token
,
t
,
pBoundInfo
->
numOfCols
,
pSchema
);
if
(
index
<
0
&&
t
>
0
)
{
index
=
insFindCol
(
&
token
,
0
,
t
,
pSchema
);
}
if
(
index
<
0
)
{
uError
(
"can not find column name:%s"
,
token
.
z
);
code
=
TSDB_CODE_PAR_INVALID_COLUMN
;
break
;
}
else
if
(
pUseCols
[
index
])
{
code
=
TSDB_CODE_PAR_INVALID_COLUMN
;
uError
(
"duplicated column name:%s"
,
token
.
z
);
break
;
}
else
{
lastColIdx
=
index
;
pUseCols
[
index
]
=
true
;
pBoundInfo
->
pColIndex
[
pBoundInfo
->
numOfBound
]
=
index
;
++
pBoundInfo
->
numOfBound
;
}
}
}
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
!
pUseCols
[
0
])
{
uError
(
"primary timestamp column can not be null:"
);
code
=
TSDB_CODE_PAR_INVALID_COLUMN
;
}
taosMemoryFree
(
pUseCols
);
return
code
;
}
static
bool
isSameBindFileds
(
SBoundColInfo
*
pBoundInfo
,
SSchema
*
pSchema
,
TAOS_FIELD
*
fields
,
int
numFields
)
{
int16_t
lastColIdx
=
-
1
;
// last column found
for
(
int
i
=
0
;
i
<
numFields
;
i
++
)
{
SToken
token
;
token
.
z
=
fields
[
i
].
name
;
token
.
n
=
strlen
(
fields
[
i
].
name
);
int16_t
t
=
lastColIdx
+
1
;
int16_t
index
=
insFindCol
(
&
token
,
t
,
pBoundInfo
->
numOfCols
,
pSchema
);
if
(
index
<
0
&&
t
>
0
)
{
index
=
insFindCol
(
&
token
,
0
,
t
,
pSchema
);
}
if
(
index
<
0
)
{
uError
(
"can not find column name:%s"
,
token
.
z
);
return
false
;
return
false
;
}
else
{
lastColIdx
=
index
;
if
(
pBoundInfo
->
pColIndex
[
i
]
!=
index
){
return
false
;
}
}
}
return
true
;
}
}
int
rawBlockBindData
(
SQuery
*
query
,
STableMeta
*
pTableMeta
,
void
*
data
,
SVCreateTbReq
*
pCreateTb
,
TAOS_FIELD
*
tFields
,
int
rawBlockBindData
(
SQuery
*
query
,
STableMeta
*
pTableMeta
,
void
*
data
,
SVCreateTbReq
*
pCreateTb
,
TAOS_FIELD
*
tFields
,
...
@@ -648,39 +587,13 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate
...
@@ -648,39 +587,13 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate
goto
end
;
goto
end
;
}
}
do
{
if
(
tmp
==
NULL
){
if
(
tmp
!=
NULL
){
if
(
!
isSameBindFileds
(
&
pTableCxt
->
boundColsInfo
,
getTableColumnSchema
(
pTableMeta
),
tFields
,
numFields
)){
char
*
fieldNames
=
(
char
*
)
taosMemoryCalloc
(
numFields
,
sizeof
(
tFields
[
0
].
name
));
for
(
int
i
=
0
;
i
<
numFields
;
i
++
){
memcpy
(
fieldNames
+
i
*
sizeof
(
tFields
[
0
].
name
),
tFields
[
i
].
name
,
sizeof
(
tFields
[
0
].
name
));
}
ret
=
insGetTableDataCxt
(((
SVnodeModifyOpStmt
*
)(
query
->
pRoot
))
->
pTableBlockHashObj
,
fieldNames
,
numFields
*
sizeof
(
tFields
[
0
].
name
),
pTableMeta
,
&
pCreateTb
,
&
pTableCxt
,
true
);
taosMemoryFree
(
fieldNames
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"insGetTableDataCxt inner error"
);
goto
end
;
}
}
else
{
break
;
}
}
if
(
tFields
!=
NULL
)
{
ret
=
bindFileds
(
&
pTableCxt
->
boundColsInfo
,
getTableColumnSchema
(
pTableMeta
),
tFields
,
numFields
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"bindFileds error"
);
goto
end
;
}
}
// no need to bind, because select * get all fields
ret
=
initTableColSubmitData
(
pTableCxt
);
ret
=
initTableColSubmitData
(
pTableCxt
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"initTableColSubmitData error"
);
uError
(
"initTableColSubmitData error"
);
goto
end
;
goto
end
;
}
}
}
while
(
0
);
}
char
*
p
=
(
char
*
)
data
;
char
*
p
=
(
char
*
)
data
;
// | version | total length | total rows | total columns | flag seg| block group id | column schema | each column
// | version | total length | total rows | total columns | flag seg| block group id | column schema | each column
...
@@ -708,15 +621,15 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate
...
@@ -708,15 +621,15 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate
SSchema
*
pSchema
=
getTableColumnSchema
(
pTableCxt
->
pMeta
);
SSchema
*
pSchema
=
getTableColumnSchema
(
pTableCxt
->
pMeta
);
SBoundColInfo
*
boundInfo
=
&
pTableCxt
->
boundColsInfo
;
SBoundColInfo
*
boundInfo
=
&
pTableCxt
->
boundColsInfo
;
if
(
boundInfo
->
numOfBound
!=
numOfCols
)
{
if
(
numFields
!=
numOfCols
)
{
uError
(
"
boundInfo->numOfBound:%d != numOfCols:%d"
,
boundInfo
->
numOfBound
,
numOfCols
);
uError
(
"
numFields:%d != numOfCols:%d"
,
numFields
,
numOfCols
);
ret
=
TSDB_CODE_INVALID_PARA
;
ret
=
TSDB_CODE_INVALID_PARA
;
goto
end
;
goto
end
;
}
}
for
(
int
c
=
0
;
c
<
boundInfo
->
numOfBound
;
++
c
)
{
for
(
int
c
=
0
;
c
<
boundInfo
->
numOfBound
;
++
c
)
{
SSchema
*
pColSchema
=
&
pSchema
[
boundInfo
->
pColIndex
[
c
]
];
SSchema
*
pColSchema
=
&
pSchema
[
c
];
SColData
*
pCol
=
taosArrayGet
(
pTableCxt
->
pData
->
aCol
,
c
);
SColData
*
pCol
=
taosArrayGet
(
pTableCxt
->
pData
->
aCol
,
c
);
if
(
findFileds
(
pColSchema
,
tFields
,
numFields
)){
if
(
*
fields
!=
pColSchema
->
type
&&
*
(
int32_t
*
)(
fields
+
sizeof
(
int8_t
))
!=
pColSchema
->
bytes
)
{
if
(
*
fields
!=
pColSchema
->
type
&&
*
(
int32_t
*
)(
fields
+
sizeof
(
int8_t
))
!=
pColSchema
->
bytes
)
{
uError
(
"type or bytes not equal"
);
uError
(
"type or bytes not equal"
);
ret
=
TSDB_CODE_INVALID_PARA
;
ret
=
TSDB_CODE_INVALID_PARA
;
...
@@ -738,6 +651,9 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate
...
@@ -738,6 +651,9 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate
}
else
{
}
else
{
pStart
+=
colLength
[
c
];
pStart
+=
colLength
[
c
];
}
}
}
else
{
tColDataAddValueByDataBlock
(
pCol
,
pColSchema
->
type
,
pColSchema
->
bytes
,
numOfRows
,
NULL
,
NULL
);
}
}
}
end:
end:
...
...
utils/test/c/tmq_taosx_ci.c
浏览文件 @
5d06474f
...
@@ -102,284 +102,284 @@ int buildDatabase(TAOS* pConn, TAOS_RES* pRes) {
...
@@ -102,284 +102,284 @@ int buildDatabase(TAOS* pConn, TAOS_RES* pRes) {
/* test for TD-20612 end*/
/* test for TD-20612 end*/
//
pRes = taos_query(pConn,
pRes
=
taos_query
(
pConn
,
//
"create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 "
"create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 "
//
"nchar(8), t4 bool)");
"nchar(8), t4 bool)"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to create super table st1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "create table if not exists ct0 using st1 tags(1000, \"ttt\", true)");
pRes
=
taos_query
(
pConn
,
"create table if not exists ct0 using st1 tags(1000,
\"
ttt
\"
, true)"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to create child table tu1, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to create child table tu1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "insert into ct0 values(1626006833400, 1, 2, 'a')");
pRes
=
taos_query
(
pConn
,
"insert into ct0 values(1626006833400, 1, 2, 'a')"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to insert into ct0, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to insert into ct0, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "create table if not exists ct1 using st1(t1) tags(2000)");
pRes
=
taos_query
(
pConn
,
"create table if not exists ct1 using st1(t1) tags(2000)"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to create child table ct1, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to create child table ct1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "create table if not exists ct2 using st1(t1) tags(NULL)");
pRes
=
taos_query
(
pConn
,
"create table if not exists ct2 using st1(t1) tags(NULL)"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to create child table ct2, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to create child table ct2, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "insert into ct1 values(1626006833600, 3, 4, 'b')");
pRes
=
taos_query
(
pConn
,
"insert into ct1 values(1626006833600, 3, 4, 'b')"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to insert into ct1, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to insert into ct1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "create table if not exists ct3 using st1(t1) tags(3000)");
pRes
=
taos_query
(
pConn
,
"create table if not exists ct3 using st1(t1) tags(3000)"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to create child table ct3, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to create child table ct3, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(
pRes
=
taos_query
(
//
pConn,
pConn
,
//
"insert into ct3 values(1626006833600, 5, 6, 'c') ct1 values(1626006833601, 2, 3, 'sds') (1626006833602, 4, 5, "
"insert into ct3 values(1626006833600, 5, 6, 'c') ct1 values(1626006833601, 2, 3, 'sds') (1626006833602, 4, 5, "
//
"'ddd') ct0 values(1626006833603, 4, 3, 'hwj') ct1 values(now+5s, 23, 32, 's21ds')");
"'ddd') ct0 values(1626006833603, 4, 3, 'hwj') ct1 values(now+5s, 23, 32, 's21ds')"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to insert into ct3, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "alter table st1 add column c4 bigint");
pRes
=
taos_query
(
pConn
,
"alter table st1 add column c4 bigint"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to alter super table st1, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to alter super table st1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "alter table st1 modify column c3 binary(64)");
pRes
=
taos_query
(
pConn
,
"alter table st1 modify column c3 binary(64)"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to alter super table st1, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to alter super table st1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn,
pRes
=
taos_query
(
pConn
,
//
"insert into ct3 values(1626006833605, 53, 63, 'cffffffffffffffffffffffffffff', 8989898899999) "
"insert into ct3 values(1626006833605, 53, 63, 'cffffffffffffffffffffffffffff', 8989898899999) "
//
"(1626006833609, 51, 62, 'c333', 940)");
"(1626006833609, 51, 62, 'c333', 940)"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to insert into ct3, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "insert into ct3 select * from ct1");
pRes
=
taos_query
(
pConn
,
"insert into ct3 select * from ct1"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to insert into ct3, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "alter table st1 add tag t2 binary(64)");
pRes
=
taos_query
(
pConn
,
"alter table st1 add tag t2 binary(64)"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to alter super table st1, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to alter super table st1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "alter table ct3 set tag t1=5000");
pRes
=
taos_query
(
pConn
,
"alter table ct3 set tag t1=5000"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to slter child table ct3, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to slter child table ct3, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "delete from abc1 .ct3 where ts < 1626006833606");
pRes
=
taos_query
(
pConn
,
"delete from abc1 .ct3 where ts < 1626006833606"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to insert into ct3, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
if (g_conf.dropTable) {
if
(
g_conf
.
dropTable
)
{
//
pRes = taos_query(pConn, "drop table ct3, ct1");
pRes
=
taos_query
(
pConn
,
"drop table ct3, ct1"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to drop child table ct3, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to drop child table ct3, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "drop table st1");
pRes
=
taos_query
(
pConn
,
"drop table st1"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to drop super table st1, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to drop super table st1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
}
}
//
//
pRes = taos_query(pConn, "create table if not exists n1(ts timestamp, c1 int, c2 nchar(4))");
pRes
=
taos_query
(
pConn
,
"create table if not exists n1(ts timestamp, c1 int, c2 nchar(4))"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to create normal table n1, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to create normal table n1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "alter table n1 add column c3 bigint");
pRes
=
taos_query
(
pConn
,
"alter table n1 add column c3 bigint"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to alter normal table n1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "alter table n1 modify column c2 nchar(8)");
pRes
=
taos_query
(
pConn
,
"alter table n1 modify column c2 nchar(8)"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to alter normal table n1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "alter table n1 rename column c3 cc3");
pRes
=
taos_query
(
pConn
,
"alter table n1 rename column c3 cc3"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to alter normal table n1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "alter table n1 comment 'hello'");
pRes
=
taos_query
(
pConn
,
"alter table n1 comment 'hello'"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to alter normal table n1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "alter table n1 drop column c1");
pRes
=
taos_query
(
pConn
,
"alter table n1 drop column c1"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to alter normal table n1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "insert into n1 values(now, 'eeee', 8989898899999) (now+9s, 'c333', 940)");
pRes
=
taos_query
(
pConn
,
"insert into n1 values(now, 'eeee', 8989898899999) (now+9s, 'c333', 940)"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to insert into n1, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to insert into n1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
if (g_conf.dropTable) {
if
(
g_conf
.
dropTable
)
{
//
pRes = taos_query(pConn, "drop table n1");
pRes
=
taos_query
(
pConn
,
"drop table n1"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to drop normal table n1, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to drop normal table n1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
}
}
//
//
pRes = taos_query(pConn, "create table jt(ts timestamp, i int) tags(t json)");
pRes
=
taos_query
(
pConn
,
"create table jt(ts timestamp, i int) tags(t json)"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to create super table jt, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to create super table jt, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "create table jt1 using jt tags('{\"k1\":1, \"k2\":\"hello\"}')");
pRes
=
taos_query
(
pConn
,
"create table jt1 using jt tags('{
\"
k1
\"
:1,
\"
k2
\"
:
\"
hello
\"
}')"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to create super table jt, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to create super table jt, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "create table jt2 using jt tags('')");
pRes
=
taos_query
(
pConn
,
"create table jt2 using jt tags('')"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to create super table jt2, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to create super table jt2, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "insert into jt1 values(now, 1)");
pRes
=
taos_query
(
pConn
,
"insert into jt1 values(now, 1)"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to create super table jt1, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to create super table jt1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "insert into jt2 values(now, 11)");
pRes
=
taos_query
(
pConn
,
"insert into jt2 values(now, 11)"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to create super table jt2, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to create super table jt2, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
if (g_conf.dropTable) {
if
(
g_conf
.
dropTable
)
{
//
pRes = taos_query(pConn,
pRes
=
taos_query
(
pConn
,
//
"create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 "
"create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 "
//
"nchar(8), t4 bool)");
"nchar(8), t4 bool)"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to create super table st1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn, "drop table st1");
pRes
=
taos_query
(
pConn
,
"drop table st1"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to drop super table st1, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to drop super table st1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
}
}
//
//
pRes = taos_query(pConn,
pRes
=
taos_query
(
pConn
,
//
"create stable if not exists stt (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 "
"create stable if not exists stt (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 "
//
"nchar(8), t4 bool)");
"nchar(8), t4 bool)"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to create super table stt, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to create super table stt, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(pConn,
pRes
=
taos_query
(
pConn
,
//
"create stable if not exists sttb (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 "
"create stable if not exists sttb (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 "
//
"nchar(8), t4 bool)");
"nchar(8), t4 bool)"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to create super table sttb, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to create super table sttb, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes = taos_query(
pRes
=
taos_query
(
//
pConn,
pConn
,
//
"create table if not exists stt1 using stt tags(2, \"stt1\", true) sttb1 using sttb tags(4, \"sttb1\", true) "
"create table if not exists stt1 using stt tags(2,
\"
stt1
\"
, true) sttb1 using sttb tags(4,
\"
sttb1
\"
, true) "
//
"stt2 using stt tags(43, \"stt2\", false) sttb2 using sttb tags(54, \"sttb2\", true)");
"stt2 using stt tags(43,
\"
stt2
\"
, false) sttb2 using sttb tags(54,
\"
sttb2
\"
, true)"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to create child table stt1, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to create child table stt1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
//
//
pRes =
pRes
=
//
taos_query(pConn,
taos_query
(
pConn
,
//
"insert into stt1 values(now + 2s, 3, 2, 'stt1') stt3 using stt tags(23, \"stt3\", true) values(now + "
"insert into stt1 values(now + 2s, 3, 2, 'stt1') stt3 using stt tags(23,
\"
stt3
\"
, true) values(now + "
//
"1s, 1, 2, 'stt3') sttb3 using sttb tags(4, \"sttb3\", true) values(now + 2s, 13, 22, 'sttb3') "
"1s, 1, 2, 'stt3') sttb3 using sttb tags(4,
\"
sttb3
\"
, true) values(now + 2s, 13, 22, 'sttb3') "
//
"stt4 using stt tags(433, \"stt4\", false) values(now + 3s, 21, 21, 'stt4') sttb4 using sttb "
"stt4 using stt tags(433,
\"
stt4
\"
, false) values(now + 3s, 21, 21, 'stt4') sttb4 using sttb "
//
"tags(543, \"sttb4\", true) values(now + 4s, 16, 25, 'sttb4')");
"tags(543,
\"
sttb4
\"
, true) values(now + 4s, 16, 25, 'sttb4')"
);
//
if (taos_errno(pRes) != 0) {
if
(
taos_errno
(
pRes
)
!=
0
)
{
//
printf("failed to create child table stt1, reason:%s\n", taos_errstr(pRes));
printf
(
"failed to create child table stt1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
//
return -1;
return
-
1
;
//
}
}
//
taos_free_result(pRes);
taos_free_result
(
pRes
);
return
0
;
return
0
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录