Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3e42f5f1
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
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看板
提交
3e42f5f1
编写于
7月 06, 2022
作者:
X
xywang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: fixed compilation errors produced by old gcc version
上级
b9470d7c
变更
70
展开全部
显示空白变更内容
内联
并排
Showing
70 changed file
with
1373 addition
and
1367 deletion
+1373
-1367
deps/TSZ/sz/src/CompressElement.c
deps/TSZ/sz/src/CompressElement.c
+5
-1
deps/TSZ/sz/src/Huffman.c
deps/TSZ/sz/src/Huffman.c
+6
-6
deps/TSZ/sz/src/TightDataPointStorageD.c
deps/TSZ/sz/src/TightDataPointStorageD.c
+23
-23
deps/TSZ/sz/src/TightDataPointStorageF.c
deps/TSZ/sz/src/TightDataPointStorageF.c
+23
-23
deps/cJson/src/cJSON.c
deps/cJson/src/cJSON.c
+6
-6
src/client/src/tscGlobalmerge.c
src/client/src/tscGlobalmerge.c
+5
-5
src/client/src/tscLocal.c
src/client/src/tscLocal.c
+8
-8
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+79
-79
src/client/src/tscParseLineProtocol.c
src/client/src/tscParseLineProtocol.c
+28
-28
src/client/src/tscParseOpenTSDB.c
src/client/src/tscParseOpenTSDB.c
+22
-22
src/client/src/tscPrepare.c
src/client/src/tscPrepare.c
+129
-129
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+292
-292
src/client/src/tscServer.c
src/client/src/tscServer.c
+12
-12
src/client/src/tscStream.c
src/client/src/tscStream.c
+20
-20
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+20
-20
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+14
-14
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+37
-37
src/common/src/tarithoperator.c
src/common/src/tarithoperator.c
+63
-63
src/common/src/tdataformat.c
src/common/src/tdataformat.c
+3
-3
src/common/src/tglobal.c
src/common/src/tglobal.c
+4
-4
src/common/src/tname.c
src/common/src/tname.c
+8
-8
src/common/src/ttypes.c
src/common/src/ttypes.c
+8
-8
src/dnode/src/dnodeCheck.c
src/dnode/src/dnodeCheck.c
+13
-13
src/dnode/src/dnodePeer.c
src/dnode/src/dnodePeer.c
+24
-24
src/dnode/src/dnodeShell.c
src/dnode/src/dnodeShell.c
+14
-14
src/kit/shell/src/shellImport.c
src/kit/shell/src/shellImport.c
+2
-2
src/mnode/src/mnodeCluster.c
src/mnode/src/mnodeCluster.c
+3
-3
src/mnode/src/mnodeMnode.c
src/mnode/src/mnodeMnode.c
+18
-18
src/mnode/src/mnodeSdb.c
src/mnode/src/mnodeSdb.c
+12
-12
src/os/src/detail/osDir.c
src/os/src/detail/osDir.c
+2
-2
src/os/src/detail/osFile.c
src/os/src/detail/osFile.c
+3
-3
src/os/src/detail/osTime.c
src/os/src/detail/osTime.c
+53
-53
src/os/src/linux/osSystem.c
src/os/src/linux/osSystem.c
+2
-2
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+23
-23
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+35
-35
src/query/src/qExtbuffer.c
src/query/src/qExtbuffer.c
+13
-13
src/query/src/qFill.c
src/query/src/qFill.c
+13
-13
src/query/src/qFilter.c
src/query/src/qFilter.c
+15
-15
src/query/src/qHistogram.c
src/query/src/qHistogram.c
+12
-12
src/query/src/qPercentile.c
src/query/src/qPercentile.c
+31
-31
src/query/src/qPlan.c
src/query/src/qPlan.c
+3
-3
src/query/src/qSqlParser.c
src/query/src/qSqlParser.c
+7
-5
src/query/src/qUtil.c
src/query/src/qUtil.c
+3
-3
src/query/src/queryMain.c
src/query/src/queryMain.c
+3
-3
src/rpc/src/rpcCache.c
src/rpc/src/rpcCache.c
+12
-12
src/rpc/src/rpcTcp.c
src/rpc/src/rpcTcp.c
+8
-8
src/rpc/src/rpcUdp.c
src/rpc/src/rpcUdp.c
+5
-5
src/rpc/test/rclient.c
src/rpc/test/rclient.c
+24
-24
src/rpc/test/rsclient.c
src/rpc/test/rsclient.c
+24
-24
src/rpc/test/rserver.c
src/rpc/test/rserver.c
+17
-17
src/sync/src/syncMain.c
src/sync/src/syncMain.c
+55
-55
src/sync/src/syncRetrieve.c
src/sync/src/syncRetrieve.c
+7
-7
src/tsdb/src/tsdbCommit.c
src/tsdb/src/tsdbCommit.c
+3
-3
src/tsdb/src/tsdbFS.c
src/tsdb/src/tsdbFS.c
+4
-4
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+1
-1
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+18
-18
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+10
-10
src/util/src/hash.c
src/util/src/hash.c
+1
-1
src/util/src/tarray.c
src/util/src/tarray.c
+18
-18
src/util/src/tcache.c
src/util/src/tcache.c
+5
-5
src/util/src/tcompare.c
src/util/src/tcompare.c
+2
-2
src/util/src/tmempool.c
src/util/src/tmempool.c
+6
-6
src/util/src/tnettest.c
src/util/src/tnettest.c
+15
-15
src/util/src/tref.c
src/util/src/tref.c
+2
-2
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+2
-2
src/vnode/src/vnodeSync.c
src/vnode/src/vnodeSync.c
+2
-2
src/wal/test/waltest.c
src/wal/test/waltest.c
+4
-4
tests/tsim/src/simExe.c
tests/tsim/src/simExe.c
+2
-2
tests/tsim/src/simParse.c
tests/tsim/src/simParse.c
+5
-5
tests/tsim/src/simSystem.c
tests/tsim/src/simSystem.c
+2
-2
未找到文件。
deps/TSZ/sz/src/CompressElement.c
浏览文件 @
3e42f5f1
...
@@ -7,7 +7,9 @@
...
@@ -7,7 +7,9 @@
* See COPYRIGHT in top-level directory.
* See COPYRIGHT in top-level directory.
*/
*/
#ifndef WINDOWS
#ifndef WINDOWS
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#pragma GCC diagnostic push
#pragma GCC diagnostic push
#endif
#pragma GCC diagnostic ignored "-Wchar-subscripts"
#pragma GCC diagnostic ignored "-Wchar-subscripts"
#endif
#endif
...
@@ -233,5 +235,7 @@ INLINE void updateLossyCompElement_Float(unsigned char* diffBytes, unsigned char
...
@@ -233,5 +235,7 @@ INLINE void updateLossyCompElement_Float(unsigned char* diffBytes, unsigned char
}
}
#ifndef WINDOWS
#ifndef WINDOWS
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
#endif
#endif
#endif
deps/TSZ/sz/src/Huffman.c
浏览文件 @
3e42f5f1
...
@@ -117,7 +117,7 @@ node qremove(HuffmanTree* huffmanTree)
...
@@ -117,7 +117,7 @@ node qremove(HuffmanTree* huffmanTree)
/**
/**
* @out1 should be set to 0.
* @out1 should be set to 0.
* @out2 should be 0 as well.
* @out2 should be 0 as well.
* @i
nde
x: the index of the byte
* @i
d
x: the index of the byte
* */
* */
void
build_code
(
HuffmanTree
*
huffmanTree
,
node
n
,
int
len
,
unsigned
long
out1
,
unsigned
long
out2
)
void
build_code
(
HuffmanTree
*
huffmanTree
,
node
n
,
int
len
,
unsigned
long
out1
,
unsigned
long
out2
)
{
{
...
@@ -136,8 +136,8 @@ void build_code(HuffmanTree *huffmanTree, node n, int len, unsigned long out1, u
...
@@ -136,8 +136,8 @@ void build_code(HuffmanTree *huffmanTree, node n, int len, unsigned long out1, u
huffmanTree
->
cout
[
n
->
c
]
=
(
unsigned
char
)
len
;
huffmanTree
->
cout
[
n
->
c
]
=
(
unsigned
char
)
len
;
return
;
return
;
}
}
int
i
nde
x
=
len
>>
6
;
//=len/64
int
i
d
x
=
len
>>
6
;
//=len/64
if
(
i
nde
x
==
0
)
if
(
i
d
x
==
0
)
{
{
out1
=
out1
<<
1
;
out1
=
out1
<<
1
;
out1
=
out1
|
0
;
out1
=
out1
|
0
;
...
@@ -164,13 +164,13 @@ void build_code(HuffmanTree *huffmanTree, node n, int len, unsigned long out1, u
...
@@ -164,13 +164,13 @@ void build_code(HuffmanTree *huffmanTree, node n, int len, unsigned long out1, u
* */
* */
void
init
(
HuffmanTree
*
huffmanTree
,
int
*
s
,
size_t
length
)
void
init
(
HuffmanTree
*
huffmanTree
,
int
*
s
,
size_t
length
)
{
{
size_t
i
,
i
nde
x
;
size_t
i
,
i
d
x
;
size_t
*
freq
=
(
size_t
*
)
malloc
(
huffmanTree
->
allNodes
*
sizeof
(
size_t
));
size_t
*
freq
=
(
size_t
*
)
malloc
(
huffmanTree
->
allNodes
*
sizeof
(
size_t
));
memset
(
freq
,
0
,
huffmanTree
->
allNodes
*
sizeof
(
size_t
));
memset
(
freq
,
0
,
huffmanTree
->
allNodes
*
sizeof
(
size_t
));
for
(
i
=
0
;
i
<
length
;
i
++
)
for
(
i
=
0
;
i
<
length
;
i
++
)
{
{
i
nde
x
=
s
[
i
];
i
d
x
=
s
[
i
];
freq
[
i
nde
x
]
++
;
freq
[
i
d
x
]
++
;
}
}
for
(
i
=
0
;
i
<
huffmanTree
->
allNodes
;
i
++
)
for
(
i
=
0
;
i
<
huffmanTree
->
allNodes
;
i
++
)
...
...
deps/TSZ/sz/src/TightDataPointStorageD.c
浏览文件 @
3e42f5f1
...
@@ -25,9 +25,9 @@ void new_TightDataPointStorageD_Empty(TightDataPointStorageD **this)
...
@@ -25,9 +25,9 @@ void new_TightDataPointStorageD_Empty(TightDataPointStorageD **this)
int
new_TightDataPointStorageD_fromFlatBytes
(
TightDataPointStorageD
**
this
,
unsigned
char
*
flatBytes
,
size_t
flatBytesLength
,
sz_exedata
*
pde_exe
,
sz_params
*
pde_params
)
int
new_TightDataPointStorageD_fromFlatBytes
(
TightDataPointStorageD
**
this
,
unsigned
char
*
flatBytes
,
size_t
flatBytesLength
,
sz_exedata
*
pde_exe
,
sz_params
*
pde_params
)
{
{
new_TightDataPointStorageD_Empty
(
this
);
new_TightDataPointStorageD_Empty
(
this
);
size_t
i
,
i
nde
x
=
0
;
size_t
i
,
i
d
x
=
0
;
unsigned
char
version
=
flatBytes
[
i
nde
x
++
];
//3
unsigned
char
version
=
flatBytes
[
i
d
x
++
];
//3
unsigned
char
sameRByte
=
flatBytes
[
i
nde
x
++
];
//1
unsigned
char
sameRByte
=
flatBytes
[
i
d
x
++
];
//1
// parse data format
// parse data format
switch
(
version
)
switch
(
version
)
...
@@ -46,15 +46,15 @@ int new_TightDataPointStorageD_fromFlatBytes(TightDataPointStorageD **this, unsi
...
@@ -46,15 +46,15 @@ int new_TightDataPointStorageD_fromFlatBytes(TightDataPointStorageD **this, unsi
pde_params
->
accelerate_pw_rel_compression
=
(
sameRByte
&
0x08
)
>>
3
;
pde_params
->
accelerate_pw_rel_compression
=
(
sameRByte
&
0x08
)
>>
3
;
int
errorBoundMode
=
SZ_ABS
;
int
errorBoundMode
=
SZ_ABS
;
convertBytesToSZParams
(
&
(
flatBytes
[
i
nde
x
]),
pde_params
,
pde_exe
);
convertBytesToSZParams
(
&
(
flatBytes
[
i
d
x
]),
pde_params
,
pde_exe
);
i
nde
x
+=
MetaDataByteLength_double
;
i
d
x
+=
MetaDataByteLength_double
;
int
isRegression
=
(
sameRByte
>>
7
)
&
0x01
;
int
isRegression
=
(
sameRByte
>>
7
)
&
0x01
;
unsigned
char
dsLengthBytes
[
8
];
unsigned
char
dsLengthBytes
[
8
];
for
(
i
=
0
;
i
<
pde_exe
->
SZ_SIZE_TYPE
;
i
++
)
for
(
i
=
0
;
i
<
pde_exe
->
SZ_SIZE_TYPE
;
i
++
)
dsLengthBytes
[
i
]
=
flatBytes
[
i
nde
x
++
];
dsLengthBytes
[
i
]
=
flatBytes
[
i
d
x
++
];
(
*
this
)
->
dataSeriesLength
=
bytesToSize
(
dsLengthBytes
,
pde_exe
->
SZ_SIZE_TYPE
);
(
*
this
)
->
dataSeriesLength
=
bytesToSize
(
dsLengthBytes
,
pde_exe
->
SZ_SIZE_TYPE
);
if
((
*
this
)
->
isLossless
==
1
)
if
((
*
this
)
->
isLossless
==
1
)
...
@@ -65,7 +65,7 @@ int new_TightDataPointStorageD_fromFlatBytes(TightDataPointStorageD **this, unsi
...
@@ -65,7 +65,7 @@ int new_TightDataPointStorageD_fromFlatBytes(TightDataPointStorageD **this, unsi
else
if
(
same
==
1
)
else
if
(
same
==
1
)
{
{
(
*
this
)
->
allSameData
=
1
;
(
*
this
)
->
allSameData
=
1
;
(
*
this
)
->
exactMidBytes
=
&
(
flatBytes
[
i
nde
x
]);
(
*
this
)
->
exactMidBytes
=
&
(
flatBytes
[
i
d
x
]);
return
errorBoundMode
;
return
errorBoundMode
;
}
}
else
else
...
@@ -74,42 +74,42 @@ int new_TightDataPointStorageD_fromFlatBytes(TightDataPointStorageD **this, unsi
...
@@ -74,42 +74,42 @@ int new_TightDataPointStorageD_fromFlatBytes(TightDataPointStorageD **this, unsi
if
(
isRegression
==
1
)
if
(
isRegression
==
1
)
{
{
(
*
this
)
->
raBytes_size
=
flatBytesLength
-
3
-
1
-
MetaDataByteLength_double
-
pde_exe
->
SZ_SIZE_TYPE
;
(
*
this
)
->
raBytes_size
=
flatBytesLength
-
3
-
1
-
MetaDataByteLength_double
-
pde_exe
->
SZ_SIZE_TYPE
;
(
*
this
)
->
raBytes
=
&
(
flatBytes
[
i
nde
x
]);
(
*
this
)
->
raBytes
=
&
(
flatBytes
[
i
d
x
]);
return
errorBoundMode
;
return
errorBoundMode
;
}
}
unsigned
char
byteBuf
[
8
];
unsigned
char
byteBuf
[
8
];
for
(
i
=
0
;
i
<
4
;
i
++
)
for
(
i
=
0
;
i
<
4
;
i
++
)
byteBuf
[
i
]
=
flatBytes
[
i
nde
x
++
];
byteBuf
[
i
]
=
flatBytes
[
i
d
x
++
];
int
max_quant_intervals
=
bytesToInt_bigEndian
(
byteBuf
);
// 4
int
max_quant_intervals
=
bytesToInt_bigEndian
(
byteBuf
);
// 4
pde_params
->
maxRangeRadius
=
max_quant_intervals
/
2
;
pde_params
->
maxRangeRadius
=
max_quant_intervals
/
2
;
for
(
i
=
0
;
i
<
4
;
i
++
)
for
(
i
=
0
;
i
<
4
;
i
++
)
byteBuf
[
i
]
=
flatBytes
[
i
nde
x
++
];
byteBuf
[
i
]
=
flatBytes
[
i
d
x
++
];
(
*
this
)
->
intervals
=
bytesToInt_bigEndian
(
byteBuf
);
// 4
(
*
this
)
->
intervals
=
bytesToInt_bigEndian
(
byteBuf
);
// 4
for
(
i
=
0
;
i
<
8
;
i
++
)
for
(
i
=
0
;
i
<
8
;
i
++
)
byteBuf
[
i
]
=
flatBytes
[
i
nde
x
++
];
byteBuf
[
i
]
=
flatBytes
[
i
d
x
++
];
(
*
this
)
->
medianValue
=
bytesToDouble
(
byteBuf
);
//8
(
*
this
)
->
medianValue
=
bytesToDouble
(
byteBuf
);
//8
(
*
this
)
->
reqLength
=
flatBytes
[
i
nde
x
++
];
//1
(
*
this
)
->
reqLength
=
flatBytes
[
i
d
x
++
];
//1
for
(
i
=
0
;
i
<
8
;
i
++
)
for
(
i
=
0
;
i
<
8
;
i
++
)
byteBuf
[
i
]
=
flatBytes
[
i
nde
x
++
];
byteBuf
[
i
]
=
flatBytes
[
i
d
x
++
];
(
*
this
)
->
realPrecision
=
bytesToDouble
(
byteBuf
);
//8
(
*
this
)
->
realPrecision
=
bytesToDouble
(
byteBuf
);
//8
for
(
i
=
0
;
i
<
pde_exe
->
SZ_SIZE_TYPE
;
i
++
)
for
(
i
=
0
;
i
<
pde_exe
->
SZ_SIZE_TYPE
;
i
++
)
byteBuf
[
i
]
=
flatBytes
[
i
nde
x
++
];
byteBuf
[
i
]
=
flatBytes
[
i
d
x
++
];
(
*
this
)
->
typeArray_size
=
bytesToSize
(
byteBuf
,
pde_exe
->
SZ_SIZE_TYPE
);
(
*
this
)
->
typeArray_size
=
bytesToSize
(
byteBuf
,
pde_exe
->
SZ_SIZE_TYPE
);
for
(
i
=
0
;
i
<
pde_exe
->
SZ_SIZE_TYPE
;
i
++
)
for
(
i
=
0
;
i
<
pde_exe
->
SZ_SIZE_TYPE
;
i
++
)
byteBuf
[
i
]
=
flatBytes
[
i
nde
x
++
];
byteBuf
[
i
]
=
flatBytes
[
i
d
x
++
];
(
*
this
)
->
exactDataNum
=
bytesToSize
(
byteBuf
,
pde_exe
->
SZ_SIZE_TYPE
);
// ST
(
*
this
)
->
exactDataNum
=
bytesToSize
(
byteBuf
,
pde_exe
->
SZ_SIZE_TYPE
);
// ST
for
(
i
=
0
;
i
<
pde_exe
->
SZ_SIZE_TYPE
;
i
++
)
for
(
i
=
0
;
i
<
pde_exe
->
SZ_SIZE_TYPE
;
i
++
)
byteBuf
[
i
]
=
flatBytes
[
i
nde
x
++
];
byteBuf
[
i
]
=
flatBytes
[
i
d
x
++
];
(
*
this
)
->
exactMidBytes_size
=
bytesToSize
(
byteBuf
,
pde_exe
->
SZ_SIZE_TYPE
);
// ST
(
*
this
)
->
exactMidBytes_size
=
bytesToSize
(
byteBuf
,
pde_exe
->
SZ_SIZE_TYPE
);
// ST
size_t
logicLeadNumBitsNum
=
(
*
this
)
->
exactDataNum
*
2
;
size_t
logicLeadNumBitsNum
=
(
*
this
)
->
exactDataNum
*
2
;
...
@@ -122,12 +122,12 @@ int new_TightDataPointStorageD_fromFlatBytes(TightDataPointStorageD **this, unsi
...
@@ -122,12 +122,12 @@ int new_TightDataPointStorageD_fromFlatBytes(TightDataPointStorageD **this, unsi
(
*
this
)
->
leadNumArray_size
=
(
logicLeadNumBitsNum
>>
3
)
+
1
;
(
*
this
)
->
leadNumArray_size
=
(
logicLeadNumBitsNum
>>
3
)
+
1
;
}
}
(
*
this
)
->
typeArray
=
&
flatBytes
[
i
nde
x
];
(
*
this
)
->
typeArray
=
&
flatBytes
[
i
d
x
];
//retrieve the number of states (i.e., stateNum)
//retrieve the number of states (i.e., stateNum)
(
*
this
)
->
allNodes
=
bytesToInt_bigEndian
((
*
this
)
->
typeArray
);
//the first 4 bytes store the stateNum
(
*
this
)
->
allNodes
=
bytesToInt_bigEndian
((
*
this
)
->
typeArray
);
//the first 4 bytes store the stateNum
(
*
this
)
->
stateNum
=
((
*
this
)
->
allNodes
+
1
)
/
2
;
(
*
this
)
->
stateNum
=
((
*
this
)
->
allNodes
+
1
)
/
2
;
i
nde
x
+=
(
*
this
)
->
typeArray_size
;
i
d
x
+=
(
*
this
)
->
typeArray_size
;
// todo need check length
// todo need check length
...
@@ -135,15 +135,15 @@ int new_TightDataPointStorageD_fromFlatBytes(TightDataPointStorageD **this, unsi
...
@@ -135,15 +135,15 @@ int new_TightDataPointStorageD_fromFlatBytes(TightDataPointStorageD **this, unsi
-
pde_exe
->
SZ_SIZE_TYPE
-
pde_exe
->
SZ_SIZE_TYPE
-
pde_exe
->
SZ_SIZE_TYPE
-
pde_exe
->
SZ_SIZE_TYPE
-
pde_exe
->
SZ_SIZE_TYPE
-
pde_exe
->
SZ_SIZE_TYPE
-
(
*
this
)
->
leadNumArray_size
-
(
*
this
)
->
exactMidBytes_size
-
(
*
this
)
->
typeArray_size
;
-
(
*
this
)
->
leadNumArray_size
-
(
*
this
)
->
exactMidBytes_size
-
(
*
this
)
->
typeArray_size
;
(
*
this
)
->
leadNumArray
=
&
flatBytes
[
i
nde
x
];
(
*
this
)
->
leadNumArray
=
&
flatBytes
[
i
d
x
];
i
nde
x
+=
(
*
this
)
->
leadNumArray_size
;
i
d
x
+=
(
*
this
)
->
leadNumArray_size
;
(
*
this
)
->
exactMidBytes
=
&
flatBytes
[
i
nde
x
];
(
*
this
)
->
exactMidBytes
=
&
flatBytes
[
i
d
x
];
i
nde
x
+=
(
*
this
)
->
exactMidBytes_size
;
i
d
x
+=
(
*
this
)
->
exactMidBytes_size
;
(
*
this
)
->
residualMidBits
=
&
flatBytes
[
i
nde
x
];
(
*
this
)
->
residualMidBits
=
&
flatBytes
[
i
d
x
];
return
errorBoundMode
;
return
errorBoundMode
;
...
...
deps/TSZ/sz/src/TightDataPointStorageF.c
浏览文件 @
3e42f5f1
...
@@ -25,15 +25,15 @@ void new_TightDataPointStorageF_Empty(TightDataPointStorageF **this)
...
@@ -25,15 +25,15 @@ void new_TightDataPointStorageF_Empty(TightDataPointStorageF **this)
int
new_TightDataPointStorageF_fromFlatBytes
(
TightDataPointStorageF
**
this
,
unsigned
char
*
flatBytes
,
size_t
flatBytesLength
,
sz_exedata
*
pde_exe
,
sz_params
*
pde_params
)
int
new_TightDataPointStorageF_fromFlatBytes
(
TightDataPointStorageF
**
this
,
unsigned
char
*
flatBytes
,
size_t
flatBytesLength
,
sz_exedata
*
pde_exe
,
sz_params
*
pde_params
)
{
{
new_TightDataPointStorageF_Empty
(
this
);
new_TightDataPointStorageF_Empty
(
this
);
size_t
i
,
i
nde
x
=
0
;
size_t
i
,
i
d
x
=
0
;
//
//
// parse tdps
// parse tdps
//
//
// 1 version(1)
// 1 version(1)
unsigned
char
version
=
flatBytes
[
i
nde
x
++
];
//1
unsigned
char
version
=
flatBytes
[
i
d
x
++
];
//1
unsigned
char
sameRByte
=
flatBytes
[
i
nde
x
++
];
//1
unsigned
char
sameRByte
=
flatBytes
[
i
d
x
++
];
//1
// parse data format
// parse data format
switch
(
version
)
switch
(
version
)
...
@@ -51,12 +51,12 @@ int new_TightDataPointStorageF_fromFlatBytes(TightDataPointStorageF **this, unsi
...
@@ -51,12 +51,12 @@ int new_TightDataPointStorageF_fromFlatBytes(TightDataPointStorageF **this, unsi
pde_exe
->
SZ_SIZE_TYPE
=
((
sameRByte
&
0x40
)
>>
6
)
==
1
?
8
:
4
;
//0100,0000
pde_exe
->
SZ_SIZE_TYPE
=
((
sameRByte
&
0x40
)
>>
6
)
==
1
?
8
:
4
;
//0100,0000
int
errorBoundMode
=
SZ_ABS
;
int
errorBoundMode
=
SZ_ABS
;
// 3 meta(2)
// 3 meta(2)
convertBytesToSZParams
(
&
(
flatBytes
[
i
nde
x
]),
pde_params
,
pde_exe
);
convertBytesToSZParams
(
&
(
flatBytes
[
i
d
x
]),
pde_params
,
pde_exe
);
i
nde
x
+=
MetaDataByteLength
;
i
d
x
+=
MetaDataByteLength
;
// 4 element count(4)
// 4 element count(4)
unsigned
char
dsLengthBytes
[
8
];
unsigned
char
dsLengthBytes
[
8
];
for
(
i
=
0
;
i
<
pde_exe
->
SZ_SIZE_TYPE
;
i
++
)
for
(
i
=
0
;
i
<
pde_exe
->
SZ_SIZE_TYPE
;
i
++
)
dsLengthBytes
[
i
]
=
flatBytes
[
i
nde
x
++
];
dsLengthBytes
[
i
]
=
flatBytes
[
i
d
x
++
];
(
*
this
)
->
dataSeriesLength
=
bytesToSize
(
dsLengthBytes
,
pde_exe
->
SZ_SIZE_TYPE
);
// 4 or 8
(
*
this
)
->
dataSeriesLength
=
bytesToSize
(
dsLengthBytes
,
pde_exe
->
SZ_SIZE_TYPE
);
// 4 or 8
if
((
*
this
)
->
isLossless
==
1
)
if
((
*
this
)
->
isLossless
==
1
)
{
{
...
@@ -66,7 +66,7 @@ int new_TightDataPointStorageF_fromFlatBytes(TightDataPointStorageF **this, unsi
...
@@ -66,7 +66,7 @@ int new_TightDataPointStorageF_fromFlatBytes(TightDataPointStorageF **this, unsi
else
if
(
same
==
1
)
else
if
(
same
==
1
)
{
{
(
*
this
)
->
allSameData
=
1
;
(
*
this
)
->
allSameData
=
1
;
(
*
this
)
->
exactMidBytes
=
&
(
flatBytes
[
i
nde
x
]);
(
*
this
)
->
exactMidBytes
=
&
(
flatBytes
[
i
d
x
]);
return
errorBoundMode
;
return
errorBoundMode
;
}
}
else
else
...
@@ -76,40 +76,40 @@ int new_TightDataPointStorageF_fromFlatBytes(TightDataPointStorageF **this, unsi
...
@@ -76,40 +76,40 @@ int new_TightDataPointStorageF_fromFlatBytes(TightDataPointStorageF **this, unsi
if
(
isRegression
==
1
)
if
(
isRegression
==
1
)
{
{
(
*
this
)
->
raBytes_size
=
flatBytesLength
-
1
-
1
-
MetaDataByteLength
-
pde_exe
->
SZ_SIZE_TYPE
;
(
*
this
)
->
raBytes_size
=
flatBytesLength
-
1
-
1
-
MetaDataByteLength
-
pde_exe
->
SZ_SIZE_TYPE
;
(
*
this
)
->
raBytes
=
&
(
flatBytes
[
i
nde
x
]);
(
*
this
)
->
raBytes
=
&
(
flatBytes
[
i
d
x
]);
return
errorBoundMode
;
return
errorBoundMode
;
}
}
// 5 quant intervals(4)
// 5 quant intervals(4)
unsigned
char
byteBuf
[
8
];
unsigned
char
byteBuf
[
8
];
for
(
i
=
0
;
i
<
4
;
i
++
)
for
(
i
=
0
;
i
<
4
;
i
++
)
byteBuf
[
i
]
=
flatBytes
[
i
nde
x
++
];
byteBuf
[
i
]
=
flatBytes
[
i
d
x
++
];
int
max_quant_intervals
=
bytesToInt_bigEndian
(
byteBuf
);
// 4
int
max_quant_intervals
=
bytesToInt_bigEndian
(
byteBuf
);
// 4
pde_params
->
maxRangeRadius
=
max_quant_intervals
/
2
;
pde_params
->
maxRangeRadius
=
max_quant_intervals
/
2
;
// 6 intervals
// 6 intervals
for
(
i
=
0
;
i
<
4
;
i
++
)
for
(
i
=
0
;
i
<
4
;
i
++
)
byteBuf
[
i
]
=
flatBytes
[
i
nde
x
++
];
byteBuf
[
i
]
=
flatBytes
[
i
d
x
++
];
(
*
this
)
->
intervals
=
bytesToInt_bigEndian
(
byteBuf
);
// 4
(
*
this
)
->
intervals
=
bytesToInt_bigEndian
(
byteBuf
);
// 4
// 7 median
// 7 median
for
(
i
=
0
;
i
<
4
;
i
++
)
for
(
i
=
0
;
i
<
4
;
i
++
)
byteBuf
[
i
]
=
flatBytes
[
i
nde
x
++
];
byteBuf
[
i
]
=
flatBytes
[
i
d
x
++
];
(
*
this
)
->
medianValue
=
bytesToFloat
(
byteBuf
);
//4
(
*
this
)
->
medianValue
=
bytesToFloat
(
byteBuf
);
//4
// 8 reqLength
// 8 reqLength
(
*
this
)
->
reqLength
=
flatBytes
[
i
nde
x
++
];
//1
(
*
this
)
->
reqLength
=
flatBytes
[
i
d
x
++
];
//1
// 9 realPrecision(8)
// 9 realPrecision(8)
for
(
i
=
0
;
i
<
8
;
i
++
)
for
(
i
=
0
;
i
<
8
;
i
++
)
byteBuf
[
i
]
=
flatBytes
[
i
nde
x
++
];
byteBuf
[
i
]
=
flatBytes
[
i
d
x
++
];
(
*
this
)
->
realPrecision
=
bytesToDouble
(
byteBuf
);
//8
(
*
this
)
->
realPrecision
=
bytesToDouble
(
byteBuf
);
//8
// 10 typeArray_size
// 10 typeArray_size
for
(
i
=
0
;
i
<
pde_exe
->
SZ_SIZE_TYPE
;
i
++
)
for
(
i
=
0
;
i
<
pde_exe
->
SZ_SIZE_TYPE
;
i
++
)
byteBuf
[
i
]
=
flatBytes
[
i
nde
x
++
];
byteBuf
[
i
]
=
flatBytes
[
i
d
x
++
];
(
*
this
)
->
typeArray_size
=
bytesToSize
(
byteBuf
,
pde_exe
->
SZ_SIZE_TYPE
);
// 4
(
*
this
)
->
typeArray_size
=
bytesToSize
(
byteBuf
,
pde_exe
->
SZ_SIZE_TYPE
);
// 4
// 11 exactNum
// 11 exactNum
for
(
i
=
0
;
i
<
pde_exe
->
SZ_SIZE_TYPE
;
i
++
)
for
(
i
=
0
;
i
<
pde_exe
->
SZ_SIZE_TYPE
;
i
++
)
byteBuf
[
i
]
=
flatBytes
[
i
nde
x
++
];
byteBuf
[
i
]
=
flatBytes
[
i
d
x
++
];
(
*
this
)
->
exactDataNum
=
bytesToSize
(
byteBuf
,
pde_exe
->
SZ_SIZE_TYPE
);
// ST
(
*
this
)
->
exactDataNum
=
bytesToSize
(
byteBuf
,
pde_exe
->
SZ_SIZE_TYPE
);
// ST
// 12 mid size
// 12 mid size
for
(
i
=
0
;
i
<
pde_exe
->
SZ_SIZE_TYPE
;
i
++
)
for
(
i
=
0
;
i
<
pde_exe
->
SZ_SIZE_TYPE
;
i
++
)
byteBuf
[
i
]
=
flatBytes
[
i
nde
x
++
];
byteBuf
[
i
]
=
flatBytes
[
i
d
x
++
];
(
*
this
)
->
exactMidBytes_size
=
bytesToSize
(
byteBuf
,
pde_exe
->
SZ_SIZE_TYPE
);
// STqq
(
*
this
)
->
exactMidBytes_size
=
bytesToSize
(
byteBuf
,
pde_exe
->
SZ_SIZE_TYPE
);
// STqq
// calc leadNumArray_size
// calc leadNumArray_size
...
@@ -124,20 +124,20 @@ int new_TightDataPointStorageF_fromFlatBytes(TightDataPointStorageF **this, unsi
...
@@ -124,20 +124,20 @@ int new_TightDataPointStorageF_fromFlatBytes(TightDataPointStorageF **this, unsi
}
}
// 13 typeArray
// 13 typeArray
(
*
this
)
->
typeArray
=
&
flatBytes
[
i
nde
x
];
(
*
this
)
->
typeArray
=
&
flatBytes
[
i
d
x
];
//retrieve the number of states (i.e., stateNum)
//retrieve the number of states (i.e., stateNum)
(
*
this
)
->
allNodes
=
bytesToInt_bigEndian
((
*
this
)
->
typeArray
);
//the first 4 bytes store the stateNum
(
*
this
)
->
allNodes
=
bytesToInt_bigEndian
((
*
this
)
->
typeArray
);
//the first 4 bytes store the stateNum
(
*
this
)
->
stateNum
=
((
*
this
)
->
allNodes
+
1
)
/
2
;
(
*
this
)
->
stateNum
=
((
*
this
)
->
allNodes
+
1
)
/
2
;
i
nde
x
+=
(
*
this
)
->
typeArray_size
;
i
d
x
+=
(
*
this
)
->
typeArray_size
;
// 14 leadNumArray
// 14 leadNumArray
(
*
this
)
->
leadNumArray
=
&
flatBytes
[
i
nde
x
];
(
*
this
)
->
leadNumArray
=
&
flatBytes
[
i
d
x
];
i
nde
x
+=
(
*
this
)
->
leadNumArray_size
;
i
d
x
+=
(
*
this
)
->
leadNumArray_size
;
// 15 exactMidBytes
// 15 exactMidBytes
(
*
this
)
->
exactMidBytes
=
&
flatBytes
[
i
nde
x
];
(
*
this
)
->
exactMidBytes
=
&
flatBytes
[
i
d
x
];
i
nde
x
+=
(
*
this
)
->
exactMidBytes_size
;
i
d
x
+=
(
*
this
)
->
exactMidBytes_size
;
// 16 residualMidBits
// 16 residualMidBits
(
*
this
)
->
residualMidBits
=
&
flatBytes
[
i
nde
x
];
(
*
this
)
->
residualMidBits
=
&
flatBytes
[
i
d
x
];
// calc residualMidBits_size
// calc residualMidBits_size
(
*
this
)
->
residualMidBits_size
=
flatBytesLength
-
1
-
1
-
MetaDataByteLength
-
pde_exe
->
SZ_SIZE_TYPE
-
4
-
4
-
4
-
1
-
8
(
*
this
)
->
residualMidBits_size
=
flatBytesLength
-
1
-
1
-
MetaDataByteLength
-
pde_exe
->
SZ_SIZE_TYPE
-
4
-
4
-
4
-
1
-
8
...
...
deps/cJson/src/cJSON.c
浏览文件 @
3e42f5f1
...
@@ -1683,7 +1683,7 @@ CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array)
...
@@ -1683,7 +1683,7 @@ CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array)
return
(
int
)
size
;
return
(
int
)
size
;
}
}
static
cJSON
*
get_array_item
(
const
cJSON
*
array
,
size_t
i
nde
x
)
static
cJSON
*
get_array_item
(
const
cJSON
*
array
,
size_t
i
d
x
)
{
{
cJSON
*
current_child
=
NULL
;
cJSON
*
current_child
=
NULL
;
...
@@ -1693,23 +1693,23 @@ static cJSON* get_array_item(const cJSON *array, size_t index)
...
@@ -1693,23 +1693,23 @@ static cJSON* get_array_item(const cJSON *array, size_t index)
}
}
current_child
=
array
->
child
;
current_child
=
array
->
child
;
while
((
current_child
!=
NULL
)
&&
(
i
nde
x
>
0
))
while
((
current_child
!=
NULL
)
&&
(
i
d
x
>
0
))
{
{
i
nde
x
--
;
i
d
x
--
;
current_child
=
current_child
->
next
;
current_child
=
current_child
->
next
;
}
}
return
current_child
;
return
current_child
;
}
}
CJSON_PUBLIC
(
cJSON
*
)
cJSON_GetArrayItem
(
const
cJSON
*
array
,
int
i
nde
x
)
CJSON_PUBLIC
(
cJSON
*
)
cJSON_GetArrayItem
(
const
cJSON
*
array
,
int
i
d
x
)
{
{
if
(
i
nde
x
<
0
)
if
(
i
d
x
<
0
)
{
{
return
NULL
;
return
NULL
;
}
}
return
get_array_item
(
array
,
(
size_t
)
i
nde
x
);
return
get_array_item
(
array
,
(
size_t
)
i
d
x
);
}
}
static
cJSON
*
get_object_item
(
const
cJSON
*
const
object
,
const
char
*
const
name
,
const
cJSON_bool
case_sensitive
)
static
cJSON
*
get_object_item
(
const
cJSON
*
const
object
,
const
char
*
const
name
,
const
cJSON_bool
case_sensitive
)
...
...
src/client/src/tscGlobalmerge.c
浏览文件 @
3e42f5f1
...
@@ -33,12 +33,12 @@ typedef struct SCompareParam {
...
@@ -33,12 +33,12 @@ typedef struct SCompareParam {
int32_t
groupOrderType
;
int32_t
groupOrderType
;
}
SCompareParam
;
}
SCompareParam
;
static
bool
needToMerge
(
SSDataBlock
*
pBlock
,
SArray
*
columnIndexList
,
int32_t
i
nde
x
,
char
**
buf
)
{
static
bool
needToMerge
(
SSDataBlock
*
pBlock
,
SArray
*
columnIndexList
,
int32_t
i
d
x
,
char
**
buf
)
{
int32_t
ret
=
0
;
int32_t
ret
=
0
;
size_t
size
=
taosArrayGetSize
(
columnIndexList
);
size_t
size
=
taosArrayGetSize
(
columnIndexList
);
if
(
size
>
0
)
{
if
(
size
>
0
)
{
ret
=
compare_aRv
(
pBlock
,
columnIndexList
,
(
int32_t
)
size
,
i
nde
x
,
buf
,
TSDB_ORDER_ASC
);
ret
=
compare_aRv
(
pBlock
,
columnIndexList
,
(
int32_t
)
size
,
i
d
x
,
buf
,
TSDB_ORDER_ASC
);
}
}
// if ret == 0, means the result belongs to the same group
// if ret == 0, means the result belongs to the same group
...
@@ -560,9 +560,9 @@ static void savePrevOrderColumns(char** prevRow, SArray* pColumnList, SSDataBloc
...
@@ -560,9 +560,9 @@ static void savePrevOrderColumns(char** prevRow, SArray* pColumnList, SSDataBloc
int32_t
size
=
(
int32_t
)
taosArrayGetSize
(
pColumnList
);
int32_t
size
=
(
int32_t
)
taosArrayGetSize
(
pColumnList
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SColIndex
*
i
nde
x
=
taosArrayGet
(
pColumnList
,
i
);
SColIndex
*
i
d
x
=
taosArrayGet
(
pColumnList
,
i
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
nde
x
->
colIndex
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
d
x
->
colIndex
);
assert
(
i
nde
x
->
colId
==
pColInfo
->
info
.
colId
);
assert
(
i
d
x
->
colId
==
pColInfo
->
info
.
colId
);
memcpy
(
prevRow
[
i
],
pColInfo
->
pData
+
pColInfo
->
info
.
bytes
*
rowIndex
,
pColInfo
->
info
.
bytes
);
memcpy
(
prevRow
[
i
],
pColInfo
->
pData
+
pColInfo
->
info
.
bytes
*
rowIndex
,
pColInfo
->
info
.
bytes
);
}
}
...
...
src/client/src/tscLocal.c
浏览文件 @
3e42f5f1
...
@@ -152,7 +152,7 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
...
@@ -152,7 +152,7 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
static
int32_t
tscBuildTableSchemaResultFields
(
SSqlObj
*
pSql
,
int32_t
numOfCols
,
int32_t
typeColLength
,
static
int32_t
tscBuildTableSchemaResultFields
(
SSqlObj
*
pSql
,
int32_t
numOfCols
,
int32_t
typeColLength
,
int32_t
noteColLength
)
{
int32_t
noteColLength
)
{
int32_t
rowLen
=
0
;
int32_t
rowLen
=
0
;
SColumnIndex
i
nde
x
=
{
0
};
SColumnIndex
i
d
x
=
{
0
};
pSql
->
cmd
.
numOfCols
=
numOfCols
;
pSql
->
cmd
.
numOfCols
=
numOfCols
;
...
@@ -163,7 +163,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
...
@@ -163,7 +163,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
tstrncpy
(
f
.
name
,
"Field"
,
sizeof
(
f
.
name
));
tstrncpy
(
f
.
name
,
"Field"
,
sizeof
(
f
.
name
));
SInternalField
*
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
SInternalField
*
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
i
nde
x
,
TSDB_DATA_TYPE_BINARY
,
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
i
d
x
,
TSDB_DATA_TYPE_BINARY
,
(
TSDB_COL_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
,
-
1000
,
(
TSDB_COL_NAME_LEN
-
1
),
false
);
(
TSDB_COL_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
,
-
1000
,
(
TSDB_COL_NAME_LEN
-
1
),
false
);
rowLen
+=
((
TSDB_COL_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
);
rowLen
+=
((
TSDB_COL_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
);
...
@@ -173,7 +173,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
...
@@ -173,7 +173,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
tstrncpy
(
f
.
name
,
"Type"
,
sizeof
(
f
.
name
));
tstrncpy
(
f
.
name
,
"Type"
,
sizeof
(
f
.
name
));
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
i
nde
x
,
TSDB_DATA_TYPE_BINARY
,
(
int16_t
)(
typeColLength
+
VARSTR_HEADER_SIZE
),
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
i
d
x
,
TSDB_DATA_TYPE_BINARY
,
(
int16_t
)(
typeColLength
+
VARSTR_HEADER_SIZE
),
-
1000
,
typeColLength
,
false
);
-
1000
,
typeColLength
,
false
);
rowLen
+=
typeColLength
+
VARSTR_HEADER_SIZE
;
rowLen
+=
typeColLength
+
VARSTR_HEADER_SIZE
;
...
@@ -183,7 +183,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
...
@@ -183,7 +183,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
tstrncpy
(
f
.
name
,
"Length"
,
sizeof
(
f
.
name
));
tstrncpy
(
f
.
name
,
"Length"
,
sizeof
(
f
.
name
));
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
i
nde
x
,
TSDB_DATA_TYPE_INT
,
sizeof
(
int32_t
),
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
i
d
x
,
TSDB_DATA_TYPE_INT
,
sizeof
(
int32_t
),
-
1000
,
sizeof
(
int32_t
),
false
);
-
1000
,
sizeof
(
int32_t
),
false
);
rowLen
+=
sizeof
(
int32_t
);
rowLen
+=
sizeof
(
int32_t
);
...
@@ -193,7 +193,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
...
@@ -193,7 +193,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
tstrncpy
(
f
.
name
,
"Note"
,
sizeof
(
f
.
name
));
tstrncpy
(
f
.
name
,
"Note"
,
sizeof
(
f
.
name
));
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
i
nde
x
,
TSDB_DATA_TYPE_BINARY
,
(
int16_t
)(
noteColLength
+
VARSTR_HEADER_SIZE
),
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
i
d
x
,
TSDB_DATA_TYPE_BINARY
,
(
int16_t
)(
noteColLength
+
VARSTR_HEADER_SIZE
),
-
1000
,
noteColLength
,
false
);
-
1000
,
noteColLength
,
false
);
rowLen
+=
noteColLength
+
VARSTR_HEADER_SIZE
;
rowLen
+=
noteColLength
+
VARSTR_HEADER_SIZE
;
...
@@ -415,7 +415,7 @@ static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) {
...
@@ -415,7 +415,7 @@ static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) {
static
int32_t
tscSCreateBuildResultFields
(
SSqlObj
*
pSql
,
BuildType
type
,
const
char
*
ddl
)
{
static
int32_t
tscSCreateBuildResultFields
(
SSqlObj
*
pSql
,
BuildType
type
,
const
char
*
ddl
)
{
int32_t
rowLen
=
0
;
int32_t
rowLen
=
0
;
int16_t
ddlLen
=
(
int16_t
)
strlen
(
ddl
);
int16_t
ddlLen
=
(
int16_t
)
strlen
(
ddl
);
SColumnIndex
i
nde
x
=
{
0
};
SColumnIndex
i
d
x
=
{
0
};
pSql
->
cmd
.
numOfCols
=
2
;
pSql
->
cmd
.
numOfCols
=
2
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
&
pSql
->
cmd
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
&
pSql
->
cmd
);
...
@@ -433,7 +433,7 @@ static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const
...
@@ -433,7 +433,7 @@ static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const
}
}
SInternalField
*
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
SInternalField
*
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
i
nde
x
,
TSDB_DATA_TYPE_BINARY
,
f
.
bytes
,
-
1000
,
f
.
bytes
-
VARSTR_HEADER_SIZE
,
false
);
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
i
d
x
,
TSDB_DATA_TYPE_BINARY
,
f
.
bytes
,
-
1000
,
f
.
bytes
-
VARSTR_HEADER_SIZE
,
false
);
rowLen
+=
f
.
bytes
;
rowLen
+=
f
.
bytes
;
...
@@ -446,7 +446,7 @@ static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const
...
@@ -446,7 +446,7 @@ static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const
}
}
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
i
nde
x
,
TSDB_DATA_TYPE_BINARY
,
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
i
d
x
,
TSDB_DATA_TYPE_BINARY
,
(
int16_t
)(
ddlLen
+
VARSTR_HEADER_SIZE
),
-
1000
,
ddlLen
,
false
);
(
int16_t
)(
ddlLen
+
VARSTR_HEADER_SIZE
),
-
1000
,
ddlLen
,
false
);
rowLen
+=
ddlLen
+
VARSTR_HEADER_SIZE
;
rowLen
+=
ddlLen
+
VARSTR_HEADER_SIZE
;
...
...
src/client/src/tscParseInsert.c
浏览文件 @
3e42f5f1
...
@@ -61,8 +61,8 @@ int initMemRowBuilder(SMemRowBuilder *pBuilder, uint32_t nRows, SParsedDataColIn
...
@@ -61,8 +61,8 @@ int initMemRowBuilder(SMemRowBuilder *pBuilder, uint32_t nRows, SParsedDataColIn
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int
tsParseTime
(
SStrToken
*
pToken
,
int64_t
*
time
,
char
**
next
,
char
*
erro
r
,
int16_t
timePrec
)
{
int
tsParseTime
(
SStrToken
*
pToken
,
int64_t
*
pTime
,
char
**
next
,
char
*
er
r
,
int16_t
timePrec
)
{
int32_t
i
nde
x
=
0
;
int32_t
i
d
x
=
0
;
SStrToken
sToken
;
SStrToken
sToken
;
int64_t
interval
;
int64_t
interval
;
int64_t
useconds
=
0
;
int64_t
useconds
=
0
;
...
@@ -76,8 +76,8 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
...
@@ -76,8 +76,8 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
useconds
=
taosStr2int64
(
pToken
->
z
);
useconds
=
taosStr2int64
(
pToken
->
z
);
}
else
{
}
else
{
// strptime("2001-11-12 18:31:01", "%Y-%m-%d %H:%M:%S", &tm);
// strptime("2001-11-12 18:31:01", "%Y-%m-%d %H:%M:%S", &tm);
if
(
taosParseTime
(
pToken
->
z
,
t
ime
,
pToken
->
n
,
timePrec
,
tsDaylight
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
taosParseTime
(
pToken
->
z
,
pT
ime
,
pToken
->
n
,
timePrec
,
tsDaylight
)
!=
TSDB_CODE_SUCCESS
)
{
return
tscInvalidOperationMsg
(
err
or
,
"invalid timestamp format"
,
pToken
->
z
);
return
tscInvalidOperationMsg
(
err
,
"invalid timestamp format"
,
pToken
->
z
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -87,7 +87,7 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
...
@@ -87,7 +87,7 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
if
(
isspace
(
pToken
->
z
[
k
]))
continue
;
if
(
isspace
(
pToken
->
z
[
k
]))
continue
;
if
(
pToken
->
z
[
k
]
==
','
)
{
if
(
pToken
->
z
[
k
]
==
','
)
{
*
next
=
pTokenEnd
;
*
next
=
pTokenEnd
;
*
t
ime
=
useconds
;
*
pT
ime
=
useconds
;
return
0
;
return
0
;
}
}
...
@@ -99,17 +99,17 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
...
@@ -99,17 +99,17 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
* e.g., now+12a, now-5h
* e.g., now+12a, now-5h
*/
*/
SStrToken
valueToken
;
SStrToken
valueToken
;
i
nde
x
=
0
;
i
d
x
=
0
;
sToken
=
tStrGetToken
(
pTokenEnd
,
&
i
nde
x
,
false
);
sToken
=
tStrGetToken
(
pTokenEnd
,
&
i
d
x
,
false
);
pTokenEnd
+=
i
nde
x
;
pTokenEnd
+=
i
d
x
;
if
(
sToken
.
type
==
TK_MINUS
||
sToken
.
type
==
TK_PLUS
)
{
if
(
sToken
.
type
==
TK_MINUS
||
sToken
.
type
==
TK_PLUS
)
{
i
nde
x
=
0
;
i
d
x
=
0
;
valueToken
=
tStrGetToken
(
pTokenEnd
,
&
i
nde
x
,
false
);
valueToken
=
tStrGetToken
(
pTokenEnd
,
&
i
d
x
,
false
);
pTokenEnd
+=
i
nde
x
;
pTokenEnd
+=
i
d
x
;
if
(
valueToken
.
n
<
2
)
{
if
(
valueToken
.
n
<
2
)
{
return
tscInvalidOperationMsg
(
err
or
,
"value expected in timestamp"
,
sToken
.
z
);
return
tscInvalidOperationMsg
(
err
,
"value expected in timestamp"
,
sToken
.
z
);
}
}
char
unit
=
0
;
char
unit
=
0
;
...
@@ -126,7 +126,7 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
...
@@ -126,7 +126,7 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
*
next
=
pTokenEnd
;
*
next
=
pTokenEnd
;
}
}
*
t
ime
=
useconds
;
*
pT
ime
=
useconds
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -429,7 +429,7 @@ int32_t tsCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start) {
...
@@ -429,7 +429,7 @@ int32_t tsCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start) {
int
tsParseOneRow
(
char
**
str
,
STableDataBlocks
*
pDataBlocks
,
int16_t
timePrec
,
int32_t
*
len
,
char
*
tmpTokenBuf
,
int
tsParseOneRow
(
char
**
str
,
STableDataBlocks
*
pDataBlocks
,
int16_t
timePrec
,
int32_t
*
len
,
char
*
tmpTokenBuf
,
SInsertStatementParam
*
pInsertParam
)
{
SInsertStatementParam
*
pInsertParam
)
{
int32_t
i
nde
x
=
0
;
int32_t
i
d
x
=
0
;
SStrToken
sToken
=
{
0
};
SStrToken
sToken
=
{
0
};
char
*
row
=
pDataBlocks
->
pData
+
pDataBlocks
->
size
;
// skip the SSubmitBlk header
char
*
row
=
pDataBlocks
->
pData
+
pDataBlocks
->
size
;
// skip the SSubmitBlk header
...
@@ -451,9 +451,9 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i
...
@@ -451,9 +451,9 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i
SSchema
*
pSchema
=
&
schema
[
colIndex
];
// get colId here
SSchema
*
pSchema
=
&
schema
[
colIndex
];
// get colId here
i
nde
x
=
0
;
i
d
x
=
0
;
sToken
=
tStrGetToken
(
*
str
,
&
i
nde
x
,
true
);
sToken
=
tStrGetToken
(
*
str
,
&
i
d
x
,
true
);
*
str
+=
i
nde
x
;
*
str
+=
i
d
x
;
if
(
sToken
.
type
==
TK_QUESTION
)
{
if
(
sToken
.
type
==
TK_QUESTION
)
{
if
(
!
isParseBindParam
)
{
if
(
!
isParseBindParam
)
{
...
@@ -560,7 +560,7 @@ int32_t boundIdxCompar(const void *lhs, const void *rhs) {
...
@@ -560,7 +560,7 @@ int32_t boundIdxCompar(const void *lhs, const void *rhs) {
int32_t
tsParseValues
(
char
**
str
,
STableDataBlocks
*
pDataBlock
,
int
maxRows
,
SInsertStatementParam
*
pInsertParam
,
int32_t
tsParseValues
(
char
**
str
,
STableDataBlocks
*
pDataBlock
,
int
maxRows
,
SInsertStatementParam
*
pInsertParam
,
int32_t
*
numOfRows
,
char
*
tmpTokenBuf
)
{
int32_t
*
numOfRows
,
char
*
tmpTokenBuf
)
{
int32_t
i
nde
x
=
0
;
int32_t
i
d
x
=
0
;
int32_t
code
=
0
;
int32_t
code
=
0
;
(
*
numOfRows
)
=
0
;
(
*
numOfRows
)
=
0
;
...
@@ -580,11 +580,11 @@ int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SIn
...
@@ -580,11 +580,11 @@ int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SIn
pDataBlock
->
rowBuilder
.
rowSize
=
extendedRowSize
;
pDataBlock
->
rowBuilder
.
rowSize
=
extendedRowSize
;
while
(
1
)
{
while
(
1
)
{
i
nde
x
=
0
;
i
d
x
=
0
;
sToken
=
tStrGetToken
(
*
str
,
&
i
nde
x
,
false
);
sToken
=
tStrGetToken
(
*
str
,
&
i
d
x
,
false
);
if
(
sToken
.
n
==
0
||
sToken
.
type
!=
TK_LP
)
break
;
if
(
sToken
.
n
==
0
||
sToken
.
type
!=
TK_LP
)
break
;
*
str
+=
i
nde
x
;
*
str
+=
i
d
x
;
if
((
*
numOfRows
)
>=
maxRows
||
pDataBlock
->
size
+
extendedRowSize
>=
pDataBlock
->
nAllocSize
)
{
if
((
*
numOfRows
)
>=
maxRows
||
pDataBlock
->
size
+
extendedRowSize
>=
pDataBlock
->
nAllocSize
)
{
int32_t
tSize
;
int32_t
tSize
;
code
=
tscAllocateMemIfNeed
(
pDataBlock
,
extendedRowSize
,
&
tSize
);
code
=
tscAllocateMemIfNeed
(
pDataBlock
,
extendedRowSize
,
&
tSize
);
...
@@ -605,13 +605,13 @@ int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SIn
...
@@ -605,13 +605,13 @@ int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SIn
pDataBlock
->
size
+=
len
;
pDataBlock
->
size
+=
len
;
i
nde
x
=
0
;
i
d
x
=
0
;
sToken
=
tStrGetToken
(
*
str
,
&
i
nde
x
,
false
);
sToken
=
tStrGetToken
(
*
str
,
&
i
d
x
,
false
);
if
(
sToken
.
n
==
0
||
sToken
.
type
!=
TK_RP
)
{
if
(
sToken
.
n
==
0
||
sToken
.
type
!=
TK_RP
)
{
return
tscSQLSyntaxErrMsg
(
pInsertParam
->
msg
,
") expected"
,
*
str
);
return
tscSQLSyntaxErrMsg
(
pInsertParam
->
msg
,
") expected"
,
*
str
);
}
}
*
str
+=
i
nde
x
;
*
str
+=
i
d
x
;
(
*
numOfRows
)
++
;
(
*
numOfRows
)
++
;
}
}
...
@@ -872,7 +872,7 @@ int validateTableName(char *tblName, int len, SStrToken* psTblToken, bool *dbInc
...
@@ -872,7 +872,7 @@ int validateTableName(char *tblName, int len, SStrToken* psTblToken, bool *dbInc
static
int32_t
tscCheckIfCreateTable
(
char
**
sqlstr
,
SSqlObj
*
pSql
,
char
**
boundColumn
)
{
static
int32_t
tscCheckIfCreateTable
(
char
**
sqlstr
,
SSqlObj
*
pSql
,
char
**
boundColumn
)
{
int32_t
i
nde
x
=
0
;
int32_t
i
d
x
=
0
;
SStrToken
sToken
=
{
0
};
SStrToken
sToken
=
{
0
};
SStrToken
tableToken
=
{
0
};
SStrToken
tableToken
=
{
0
};
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
@@ -887,14 +887,14 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
...
@@ -887,14 +887,14 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
char
*
sql
=
*
sqlstr
;
char
*
sql
=
*
sqlstr
;
// get the token of specified table
// get the token of specified table
i
nde
x
=
0
;
i
d
x
=
0
;
tableToken
=
tStrGetToken
(
sql
,
&
i
nde
x
,
false
);
tableToken
=
tStrGetToken
(
sql
,
&
i
d
x
,
false
);
sql
+=
i
nde
x
;
sql
+=
i
d
x
;
// skip possibly exists column list
// skip possibly exists column list
i
nde
x
=
0
;
i
d
x
=
0
;
sToken
=
tStrGetToken
(
sql
,
&
i
nde
x
,
false
);
sToken
=
tStrGetToken
(
sql
,
&
i
d
x
,
false
);
sql
+=
i
nde
x
;
sql
+=
i
d
x
;
int32_t
numOfColList
=
0
;
int32_t
numOfColList
=
0
;
...
@@ -903,8 +903,8 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
...
@@ -903,8 +903,8 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
*
boundColumn
=
&
sToken
.
z
[
0
];
*
boundColumn
=
&
sToken
.
z
[
0
];
while
(
1
)
{
while
(
1
)
{
i
nde
x
=
0
;
i
d
x
=
0
;
sToken
=
tStrGetToken
(
sql
,
&
i
nde
x
,
false
);
sToken
=
tStrGetToken
(
sql
,
&
i
d
x
,
false
);
if
(
sToken
.
type
==
TK_ILLEGAL
)
{
if
(
sToken
.
type
==
TK_ILLEGAL
)
{
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
"unrecognized token"
,
sToken
.
z
);
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
"unrecognized token"
,
sToken
.
z
);
...
@@ -914,12 +914,12 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
...
@@ -914,12 +914,12 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
break
;
break
;
}
}
sql
+=
i
nde
x
;
sql
+=
i
d
x
;
++
numOfColList
;
++
numOfColList
;
}
}
sToken
=
tStrGetToken
(
sql
,
&
i
nde
x
,
false
);
sToken
=
tStrGetToken
(
sql
,
&
i
d
x
,
false
);
sql
+=
i
nde
x
;
sql
+=
i
d
x
;
}
}
if
(
numOfColList
==
0
&&
(
*
boundColumn
)
!=
NULL
)
{
if
(
numOfColList
==
0
&&
(
*
boundColumn
)
!=
NULL
)
{
...
@@ -929,9 +929,9 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
...
@@ -929,9 +929,9 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
TABLE_INDEX
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
TABLE_INDEX
);
if
(
sToken
.
type
==
TK_USING
)
{
// create table if not exists according to the super table
if
(
sToken
.
type
==
TK_USING
)
{
// create table if not exists according to the super table
i
nde
x
=
0
;
i
d
x
=
0
;
sToken
=
tStrGetToken
(
sql
,
&
i
nde
x
,
false
);
sToken
=
tStrGetToken
(
sql
,
&
i
d
x
,
false
);
sql
+=
i
nde
x
;
sql
+=
i
d
x
;
if
(
sToken
.
type
==
TK_ILLEGAL
)
{
if
(
sToken
.
type
==
TK_ILLEGAL
)
{
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
NULL
,
sql
);
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
NULL
,
sql
);
...
@@ -976,8 +976,8 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
...
@@ -976,8 +976,8 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
SParsedDataColInfo
spd
=
{
0
};
SParsedDataColInfo
spd
=
{
0
};
tscSetBoundColumnInfo
(
&
spd
,
pTagSchema
,
tscGetNumOfTags
(
pSTableMetaInfo
->
pTableMeta
));
tscSetBoundColumnInfo
(
&
spd
,
pTagSchema
,
tscGetNumOfTags
(
pSTableMetaInfo
->
pTableMeta
));
i
nde
x
=
0
;
i
d
x
=
0
;
sToken
=
tStrGetToken
(
sql
,
&
i
nde
x
,
false
);
sToken
=
tStrGetToken
(
sql
,
&
i
d
x
,
false
);
if
(
sToken
.
type
!=
TK_TAGS
&&
sToken
.
type
!=
TK_LP
)
{
if
(
sToken
.
type
!=
TK_TAGS
&&
sToken
.
type
!=
TK_LP
)
{
tscDestroyBoundColumnInfo
(
&
spd
);
tscDestroyBoundColumnInfo
(
&
spd
);
return
tscSQLSyntaxErrMsg
(
pInsertParam
->
msg
,
"keyword TAGS expected"
,
sToken
.
z
);
return
tscSQLSyntaxErrMsg
(
pInsertParam
->
msg
,
"keyword TAGS expected"
,
sToken
.
z
);
...
@@ -998,16 +998,16 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
...
@@ -998,16 +998,16 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
sql
=
end
;
sql
=
end
;
i
nde
x
=
0
;
// keywords of "TAGS"
i
d
x
=
0
;
// keywords of "TAGS"
sToken
=
tStrGetToken
(
sql
,
&
i
nde
x
,
false
);
sToken
=
tStrGetToken
(
sql
,
&
i
d
x
,
false
);
sql
+=
i
nde
x
;
sql
+=
i
d
x
;
}
else
{
}
else
{
sql
+=
i
nde
x
;
sql
+=
i
d
x
;
}
}
i
nde
x
=
0
;
i
d
x
=
0
;
sToken
=
tStrGetToken
(
sql
,
&
i
nde
x
,
false
);
sToken
=
tStrGetToken
(
sql
,
&
i
d
x
,
false
);
sql
+=
i
nde
x
;
sql
+=
i
d
x
;
if
(
sToken
.
type
!=
TK_LP
)
{
if
(
sToken
.
type
!=
TK_LP
)
{
tscDestroyBoundColumnInfo
(
&
spd
);
tscDestroyBoundColumnInfo
(
&
spd
);
...
@@ -1023,9 +1023,9 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
...
@@ -1023,9 +1023,9 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
for
(
int
i
=
0
;
i
<
spd
.
numOfBound
;
++
i
)
{
for
(
int
i
=
0
;
i
<
spd
.
numOfBound
;
++
i
)
{
SSchema
*
pSchema
=
&
pTagSchema
[
spd
.
boundedColumns
[
i
]];
SSchema
*
pSchema
=
&
pTagSchema
[
spd
.
boundedColumns
[
i
]];
i
nde
x
=
0
;
i
d
x
=
0
;
sToken
=
tStrGetToken
(
sql
,
&
i
nde
x
,
true
);
sToken
=
tStrGetToken
(
sql
,
&
i
d
x
,
true
);
sql
+=
i
nde
x
;
sql
+=
i
d
x
;
if
(
TK_ILLEGAL
==
sToken
.
type
)
{
if
(
TK_ILLEGAL
==
sToken
.
type
)
{
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
...
@@ -1097,9 +1097,9 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
...
@@ -1097,9 +1097,9 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
free
(
row
);
free
(
row
);
pInsertParam
->
tagData
.
data
=
pTag
;
pInsertParam
->
tagData
.
data
=
pTag
;
i
nde
x
=
0
;
i
d
x
=
0
;
sToken
=
tStrGetToken
(
sql
,
&
i
nde
x
,
false
);
sToken
=
tStrGetToken
(
sql
,
&
i
d
x
,
false
);
sql
+=
i
nde
x
;
sql
+=
i
d
x
;
if
(
sToken
.
n
==
0
||
sToken
.
type
!=
TK_RP
)
{
if
(
sToken
.
n
==
0
||
sToken
.
type
!=
TK_RP
)
{
return
tscSQLSyntaxErrMsg
(
pInsertParam
->
msg
,
") expected"
,
sToken
.
z
);
return
tscSQLSyntaxErrMsg
(
pInsertParam
->
msg
,
") expected"
,
sToken
.
z
);
}
}
...
@@ -1108,9 +1108,9 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
...
@@ -1108,9 +1108,9 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
* insert into table_name using super_table(tag_name1, tag_name2) tags(tag_val1, tag_val2)
* insert into table_name using super_table(tag_name1, tag_name2) tags(tag_val1, tag_val2)
* (normal_col1, normal_col2) values(normal_col1_val, normal_col2_val);
* (normal_col1, normal_col2) values(normal_col1_val, normal_col2_val);
* */
* */
i
nde
x
=
0
;
i
d
x
=
0
;
sToken
=
tStrGetToken
(
sql
,
&
i
nde
x
,
false
);
sToken
=
tStrGetToken
(
sql
,
&
i
d
x
,
false
);
sql
+=
i
nde
x
;
sql
+=
i
d
x
;
int
numOfColsAfterTags
=
0
;
int
numOfColsAfterTags
=
0
;
if
(
sToken
.
type
==
TK_LP
)
{
if
(
sToken
.
type
==
TK_LP
)
{
if
(
*
boundColumn
!=
NULL
)
{
if
(
*
boundColumn
!=
NULL
)
{
...
@@ -1120,18 +1120,18 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
...
@@ -1120,18 +1120,18 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
}
}
while
(
1
)
{
while
(
1
)
{
i
nde
x
=
0
;
i
d
x
=
0
;
sToken
=
tStrGetToken
(
sql
,
&
i
nde
x
,
false
);
sToken
=
tStrGetToken
(
sql
,
&
i
d
x
,
false
);
if
(
sToken
.
type
==
TK_RP
)
{
if
(
sToken
.
type
==
TK_RP
)
{
break
;
break
;
}
}
if
(
sToken
.
n
==
0
||
sToken
.
type
==
TK_SEMI
||
i
nde
x
==
0
)
{
if
(
sToken
.
n
==
0
||
sToken
.
type
==
TK_SEMI
||
i
d
x
==
0
)
{
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
"unexpected token"
,
sql
);
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
"unexpected token"
,
sql
);
}
}
sql
+=
i
nde
x
;
sql
+=
i
d
x
;
++
numOfColsAfterTags
;
++
numOfColsAfterTags
;
}
}
...
@@ -1139,7 +1139,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
...
@@ -1139,7 +1139,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
return
TSDB_CODE_TSC_SQL_SYNTAX_ERROR
;
return
TSDB_CODE_TSC_SQL_SYNTAX_ERROR
;
}
}
sToken
=
tStrGetToken
(
sql
,
&
i
nde
x
,
false
);
sToken
=
tStrGetToken
(
sql
,
&
i
d
x
,
false
);
}
}
sql
=
sToken
.
z
;
sql
=
sToken
.
z
;
...
@@ -1209,9 +1209,9 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
...
@@ -1209,9 +1209,9 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
i
nde
x
=
0
;
int32_t
i
d
x
=
0
;
SStrToken
sToken
=
tStrGetToken
(
str
,
&
i
nde
x
,
false
);
SStrToken
sToken
=
tStrGetToken
(
str
,
&
i
d
x
,
false
);
str
+=
i
nde
x
;
str
+=
i
d
x
;
if
(
sToken
.
type
!=
TK_LP
)
{
if
(
sToken
.
type
!=
TK_LP
)
{
code
=
tscSQLSyntaxErrMsg
(
pInsertParam
->
msg
,
"( is expected"
,
sToken
.
z
);
code
=
tscSQLSyntaxErrMsg
(
pInsertParam
->
msg
,
"( is expected"
,
sToken
.
z
);
...
@@ -1221,9 +1221,9 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
...
@@ -1221,9 +1221,9 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
bool
isOrdered
=
true
;
bool
isOrdered
=
true
;
int32_t
lastColIdx
=
-
1
;
// last column found
int32_t
lastColIdx
=
-
1
;
// last column found
while
(
1
)
{
while
(
1
)
{
i
nde
x
=
0
;
i
d
x
=
0
;
sToken
=
tStrGetToken
(
str
,
&
i
nde
x
,
false
);
sToken
=
tStrGetToken
(
str
,
&
i
d
x
,
false
);
str
+=
i
nde
x
;
str
+=
i
d
x
;
char
tmpTokenBuf
[
TSDB_MAX_BYTES_PER_ROW
]
=
{
0
};
// used for deleting Escape character backstick(`)
char
tmpTokenBuf
[
TSDB_MAX_BYTES_PER_ROW
]
=
{
0
};
// used for deleting Escape character backstick(`)
strncpy
(
tmpTokenBuf
,
sToken
.
z
,
sToken
.
n
);
strncpy
(
tmpTokenBuf
,
sToken
.
z
,
sToken
.
n
);
...
@@ -1400,8 +1400,8 @@ int tsParseInsertSql(SSqlObj *pSql) {
...
@@ -1400,8 +1400,8 @@ int tsParseInsertSql(SSqlObj *pSql) {
tscDebug
(
"0x%"
PRIx64
" create data block list hashList:%p"
,
pSql
->
self
,
pInsertParam
->
pTableBlockHashList
);
tscDebug
(
"0x%"
PRIx64
" create data block list hashList:%p"
,
pSql
->
self
,
pInsertParam
->
pTableBlockHashList
);
while
(
1
)
{
while
(
1
)
{
int32_t
i
nde
x
=
0
;
int32_t
i
d
x
=
0
;
SStrToken
sToken
=
tStrGetToken
(
str
,
&
i
nde
x
,
false
);
SStrToken
sToken
=
tStrGetToken
(
str
,
&
i
d
x
,
false
);
// no data in the sql string anymore.
// no data in the sql string anymore.
if
(
sToken
.
n
==
0
)
{
if
(
sToken
.
n
==
0
)
{
...
@@ -1465,9 +1465,9 @@ int tsParseInsertSql(SSqlObj *pSql) {
...
@@ -1465,9 +1465,9 @@ int tsParseInsertSql(SSqlObj *pSql) {
goto
_clean
;
goto
_clean
;
}
}
i
nde
x
=
0
;
i
d
x
=
0
;
sToken
=
tStrGetToken
(
str
,
&
i
nde
x
,
false
);
sToken
=
tStrGetToken
(
str
,
&
i
d
x
,
false
);
str
+=
i
nde
x
;
str
+=
i
d
x
;
if
(
sToken
.
n
==
0
||
(
sToken
.
type
!=
TK_FILE
&&
sToken
.
type
!=
TK_VALUES
))
{
if
(
sToken
.
n
==
0
||
(
sToken
.
type
!=
TK_FILE
&&
sToken
.
type
!=
TK_VALUES
))
{
code
=
tscSQLSyntaxErrMsg
(
pInsertParam
->
msg
,
"keyword VALUES or FILE required"
,
sToken
.
z
);
code
=
tscSQLSyntaxErrMsg
(
pInsertParam
->
msg
,
"keyword VALUES or FILE required"
,
sToken
.
z
);
...
@@ -1480,13 +1480,13 @@ int tsParseInsertSql(SSqlObj *pSql) {
...
@@ -1480,13 +1480,13 @@ int tsParseInsertSql(SSqlObj *pSql) {
goto
_clean
;
goto
_clean
;
}
}
i
nde
x
=
0
;
i
d
x
=
0
;
sToken
=
tStrGetToken
(
str
,
&
i
nde
x
,
false
);
sToken
=
tStrGetToken
(
str
,
&
i
d
x
,
false
);
if
(
sToken
.
type
!=
TK_STRING
&&
sToken
.
type
!=
TK_ID
)
{
if
(
sToken
.
type
!=
TK_STRING
&&
sToken
.
type
!=
TK_ID
)
{
code
=
tscSQLSyntaxErrMsg
(
pInsertParam
->
msg
,
"file path is required following keyword FILE"
,
sToken
.
z
);
code
=
tscSQLSyntaxErrMsg
(
pInsertParam
->
msg
,
"file path is required following keyword FILE"
,
sToken
.
z
);
goto
_clean
;
goto
_clean
;
}
}
str
+=
i
nde
x
;
str
+=
i
d
x
;
if
(
sToken
.
n
==
0
)
{
if
(
sToken
.
n
==
0
)
{
code
=
tscSQLSyntaxErrMsg
(
pInsertParam
->
msg
,
"file path is required following keyword FILE"
,
sToken
.
z
);
code
=
tscSQLSyntaxErrMsg
(
pInsertParam
->
msg
,
"file path is required following keyword FILE"
,
sToken
.
z
);
goto
_clean
;
goto
_clean
;
...
@@ -1586,7 +1586,7 @@ int tsInsertInitialCheck(SSqlObj *pSql) {
...
@@ -1586,7 +1586,7 @@ int tsInsertInitialCheck(SSqlObj *pSql) {
return
TSDB_CODE_TSC_NO_WRITE_AUTH
;
return
TSDB_CODE_TSC_NO_WRITE_AUTH
;
}
}
int32_t
i
nde
x
=
0
;
int32_t
i
d
x
=
0
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
count
=
0
;
pCmd
->
count
=
0
;
...
@@ -1596,12 +1596,12 @@ int tsInsertInitialCheck(SSqlObj *pSql) {
...
@@ -1596,12 +1596,12 @@ int tsInsertInitialCheck(SSqlObj *pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoS
(
pCmd
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoS
(
pCmd
);
TSDB_QUERY_SET_TYPE
(
pQueryInfo
->
type
,
TSDB_QUERY_TYPE_INSERT
);
TSDB_QUERY_SET_TYPE
(
pQueryInfo
->
type
,
TSDB_QUERY_TYPE_INSERT
);
SStrToken
sToken
=
tStrGetToken
(
pSql
->
sqlstr
,
&
i
nde
x
,
false
);
SStrToken
sToken
=
tStrGetToken
(
pSql
->
sqlstr
,
&
i
d
x
,
false
);
if
(
sToken
.
type
!=
TK_INSERT
&&
sToken
.
type
!=
TK_IMPORT
)
{
if
(
sToken
.
type
!=
TK_INSERT
&&
sToken
.
type
!=
TK_IMPORT
)
{
return
tscSQLSyntaxErrMsg
(
pInsertParam
->
msg
,
NULL
,
sToken
.
z
);
return
tscSQLSyntaxErrMsg
(
pInsertParam
->
msg
,
NULL
,
sToken
.
z
);
}
}
sToken
=
tStrGetToken
(
pSql
->
sqlstr
,
&
i
nde
x
,
false
);
sToken
=
tStrGetToken
(
pSql
->
sqlstr
,
&
i
d
x
,
false
);
if
(
sToken
.
type
!=
TK_INTO
)
{
if
(
sToken
.
type
!=
TK_INTO
)
{
return
tscSQLSyntaxErrMsg
(
pInsertParam
->
msg
,
"keyword INTO is expected"
,
sToken
.
z
);
return
tscSQLSyntaxErrMsg
(
pInsertParam
->
msg
,
"keyword INTO is expected"
,
sToken
.
z
);
}
}
...
...
src/client/src/tscParseLineProtocol.c
浏览文件 @
3e42f5f1
...
@@ -1966,14 +1966,14 @@ int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value,
...
@@ -1966,14 +1966,14 @@ int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value,
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
parseSmlTimeStamp
(
TAOS_SML_KV
**
pTS
,
const
char
**
i
nde
x
,
SSmlLinesInfo
*
info
)
{
static
int32_t
parseSmlTimeStamp
(
TAOS_SML_KV
**
pTS
,
const
char
**
i
d
x
,
SSmlLinesInfo
*
info
)
{
const
char
*
start
,
*
cur
;
const
char
*
start
,
*
cur
;
int32_t
ret
=
TSDB_CODE_SUCCESS
;
int32_t
ret
=
TSDB_CODE_SUCCESS
;
int
len
=
0
;
int
len
=
0
;
char
key
[]
=
"ts"
;
char
key
[]
=
"ts"
;
char
*
value
=
NULL
;
char
*
value
=
NULL
;
start
=
cur
=
*
i
nde
x
;
start
=
cur
=
*
i
d
x
;
*
pTS
=
calloc
(
1
,
sizeof
(
TAOS_SML_KV
));
*
pTS
=
calloc
(
1
,
sizeof
(
TAOS_SML_KV
));
while
(
*
cur
!=
'\0'
)
{
while
(
*
cur
!=
'\0'
)
{
...
@@ -2013,8 +2013,8 @@ bool checkDuplicateKey(char *key, SHashObj *pHash, SSmlLinesInfo* info) {
...
@@ -2013,8 +2013,8 @@ bool checkDuplicateKey(char *key, SHashObj *pHash, SSmlLinesInfo* info) {
return
false
;
return
false
;
}
}
static
int32_t
parseSmlKey
(
TAOS_SML_KV
*
pKV
,
const
char
**
i
nde
x
,
SHashObj
*
pHash
,
SSmlLinesInfo
*
info
)
{
static
int32_t
parseSmlKey
(
TAOS_SML_KV
*
pKV
,
const
char
**
i
d
x
,
SHashObj
*
pHash
,
SSmlLinesInfo
*
info
)
{
const
char
*
cur
=
*
i
nde
x
;
const
char
*
cur
=
*
i
d
x
;
char
key
[
TSDB_COL_NAME_LEN
+
1
];
// +1 to avoid key[len] over write
char
key
[
TSDB_COL_NAME_LEN
+
1
];
// +1 to avoid key[len] over write
int16_t
len
=
0
;
int16_t
len
=
0
;
...
@@ -2048,12 +2048,12 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash
...
@@ -2048,12 +2048,12 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash
memcpy
(
pKV
->
key
,
key
,
len
+
1
);
memcpy
(
pKV
->
key
,
key
,
len
+
1
);
addEscapeCharToString
(
pKV
->
key
,
len
);
addEscapeCharToString
(
pKV
->
key
,
len
);
tscDebug
(
"SML:0x%"
PRIx64
" Key:%s|len:%d"
,
info
->
id
,
pKV
->
key
,
len
);
tscDebug
(
"SML:0x%"
PRIx64
" Key:%s|len:%d"
,
info
->
id
,
pKV
->
key
,
len
);
*
i
nde
x
=
cur
+
1
;
*
i
d
x
=
cur
+
1
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
parseSmlValue
(
TAOS_SML_KV
*
pKV
,
const
char
**
i
nde
x
,
static
int32_t
parseSmlValue
(
TAOS_SML_KV
*
pKV
,
const
char
**
i
d
x
,
bool
*
is_last_kv
,
SSmlLinesInfo
*
info
,
bool
isTag
)
{
bool
*
is_last_kv
,
SSmlLinesInfo
*
info
,
bool
isTag
)
{
const
char
*
start
,
*
cur
;
const
char
*
start
,
*
cur
;
int32_t
ret
=
TSDB_CODE_SUCCESS
;
int32_t
ret
=
TSDB_CODE_SUCCESS
;
...
@@ -2077,7 +2077,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
...
@@ -2077,7 +2077,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
val_rqoute
val_rqoute
}
val_state
;
}
val_state
;
start
=
cur
=
*
i
nde
x
;
start
=
cur
=
*
i
d
x
;
tag_state
=
tag_common
;
tag_state
=
tag_common
;
val_state
=
val_common
;
val_state
=
val_common
;
...
@@ -2100,17 +2100,17 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
...
@@ -2100,17 +2100,17 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
}
}
if
(
*
cur
==
'"'
)
{
if
(
*
cur
==
'"'
)
{
if
(
cur
==
*
i
nde
x
)
{
if
(
cur
==
*
i
d
x
)
{
tag_state
=
tag_lqoute
;
tag_state
=
tag_lqoute
;
}
}
cur
+=
1
;
cur
+=
1
;
len
+=
1
;
len
+=
1
;
break
;
break
;
}
else
if
(
*
cur
==
'L'
)
{
}
else
if
(
*
cur
==
'L'
)
{
line_len
=
strlen
(
*
i
nde
x
);
line_len
=
strlen
(
*
i
d
x
);
/* common character at the end */
/* common character at the end */
if
(
cur
+
1
>=
*
i
nde
x
+
line_len
)
{
if
(
cur
+
1
>=
*
i
d
x
+
line_len
)
{
*
is_last_kv
=
true
;
*
is_last_kv
=
true
;
kv_done
=
true
;
kv_done
=
true
;
break
;
break
;
...
@@ -2118,7 +2118,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
...
@@ -2118,7 +2118,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
if
(
*
(
cur
+
1
)
==
'"'
)
{
if
(
*
(
cur
+
1
)
==
'"'
)
{
/* string starts here */
/* string starts here */
if
(
cur
+
1
==
*
i
nde
x
+
1
)
{
if
(
cur
+
1
==
*
i
d
x
+
1
)
{
tag_state
=
tag_lqoute
;
tag_state
=
tag_lqoute
;
}
}
cur
+=
2
;
cur
+=
2
;
...
@@ -2224,7 +2224,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
...
@@ -2224,7 +2224,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
}
}
if
(
*
cur
==
'"'
)
{
if
(
*
cur
==
'"'
)
{
if
(
cur
==
*
i
nde
x
)
{
if
(
cur
==
*
i
d
x
)
{
val_state
=
val_lqoute
;
val_state
=
val_lqoute
;
}
else
{
}
else
{
if
(
*
(
cur
-
1
)
!=
'\\'
)
{
if
(
*
(
cur
-
1
)
!=
'\\'
)
{
...
@@ -2238,10 +2238,10 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
...
@@ -2238,10 +2238,10 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
len
+=
1
;
len
+=
1
;
break
;
break
;
}
else
if
(
*
cur
==
'L'
)
{
}
else
if
(
*
cur
==
'L'
)
{
line_len
=
strlen
(
*
i
nde
x
);
line_len
=
strlen
(
*
i
d
x
);
/* common character at the end */
/* common character at the end */
if
(
cur
+
1
>=
*
i
nde
x
+
line_len
)
{
if
(
cur
+
1
>=
*
i
d
x
+
line_len
)
{
*
is_last_kv
=
true
;
*
is_last_kv
=
true
;
kv_done
=
true
;
kv_done
=
true
;
break
;
break
;
...
@@ -2249,13 +2249,13 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
...
@@ -2249,13 +2249,13 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
if
(
*
(
cur
+
1
)
==
'"'
)
{
if
(
*
(
cur
+
1
)
==
'"'
)
{
/* string starts here */
/* string starts here */
if
(
cur
+
1
==
*
i
nde
x
+
1
)
{
if
(
cur
+
1
==
*
i
d
x
+
1
)
{
val_state
=
val_lqoute
;
val_state
=
val_lqoute
;
cur
+=
2
;
cur
+=
2
;
len
+=
2
;
len
+=
2
;
}
else
{
}
else
{
/* MUST at the end of string */
/* MUST at the end of string */
if
(
cur
+
2
>=
*
i
nde
x
+
line_len
)
{
if
(
cur
+
2
>=
*
i
d
x
+
line_len
)
{
cur
+=
2
;
cur
+=
2
;
len
+=
2
;
len
+=
2
;
*
is_last_kv
=
true
;
*
is_last_kv
=
true
;
...
@@ -2385,7 +2385,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
...
@@ -2385,7 +2385,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
}
}
free
(
value
);
free
(
value
);
*
i
nde
x
=
(
*
cur
==
'\0'
)
?
cur
:
cur
+
1
;
*
i
d
x
=
(
*
cur
==
'\0'
)
?
cur
:
cur
+
1
;
return
ret
;
return
ret
;
error:
error:
...
@@ -2395,9 +2395,9 @@ error:
...
@@ -2395,9 +2395,9 @@ error:
return
ret
;
return
ret
;
}
}
static
int32_t
parseSmlMeasurement
(
TAOS_SML_DATA_POINT
*
pSml
,
const
char
**
i
nde
x
,
static
int32_t
parseSmlMeasurement
(
TAOS_SML_DATA_POINT
*
pSml
,
const
char
**
i
d
x
,
uint8_t
*
has_tags
,
SSmlLinesInfo
*
info
)
{
uint8_t
*
has_tags
,
SSmlLinesInfo
*
info
)
{
const
char
*
cur
=
*
i
nde
x
;
const
char
*
cur
=
*
i
d
x
;
int16_t
len
=
0
;
int16_t
len
=
0
;
pSml
->
stableName
=
calloc
(
TSDB_TABLE_NAME_LEN
+
TS_BACKQUOTE_CHAR_SIZE
,
1
);
pSml
->
stableName
=
calloc
(
TSDB_TABLE_NAME_LEN
+
TS_BACKQUOTE_CHAR_SIZE
,
1
);
...
@@ -2441,7 +2441,7 @@ static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **index
...
@@ -2441,7 +2441,7 @@ static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **index
return
TSDB_CODE_TSC_LINE_SYNTAX_ERROR
;
return
TSDB_CODE_TSC_LINE_SYNTAX_ERROR
;
}
}
addEscapeCharToString
(
pSml
->
stableName
,
len
);
addEscapeCharToString
(
pSml
->
stableName
,
len
);
*
i
nde
x
=
cur
+
1
;
*
i
d
x
=
cur
+
1
;
tscDebug
(
"SML:0x%"
PRIx64
" Stable name in measurement:%s|len:%d"
,
info
->
id
,
pSml
->
stableName
,
len
);
tscDebug
(
"SML:0x%"
PRIx64
" Stable name in measurement:%s|len:%d"
,
info
->
id
,
pSml
->
stableName
,
len
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -2464,10 +2464,10 @@ int32_t isValidChildTableName(const char *pTbName, int16_t len, SSmlLinesInfo* i
...
@@ -2464,10 +2464,10 @@ int32_t isValidChildTableName(const char *pTbName, int16_t len, SSmlLinesInfo* i
static
int32_t
parseSmlKvPairs
(
TAOS_SML_KV
**
pKVs
,
int
*
num_kvs
,
static
int32_t
parseSmlKvPairs
(
TAOS_SML_KV
**
pKVs
,
int
*
num_kvs
,
const
char
**
i
nde
x
,
bool
isField
,
const
char
**
i
d
x
,
bool
isField
,
TAOS_SML_DATA_POINT
*
smlData
,
SHashObj
*
pHash
,
TAOS_SML_DATA_POINT
*
smlData
,
SHashObj
*
pHash
,
SSmlLinesInfo
*
info
)
{
SSmlLinesInfo
*
info
)
{
const
char
*
cur
=
*
i
nde
x
;
const
char
*
cur
=
*
i
d
x
;
int32_t
ret
=
TSDB_CODE_SUCCESS
;
int32_t
ret
=
TSDB_CODE_SUCCESS
;
TAOS_SML_KV
*
pkv
;
TAOS_SML_KV
*
pkv
;
bool
is_last_kv
=
false
;
bool
is_last_kv
=
false
;
...
@@ -2555,7 +2555,7 @@ static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs,
...
@@ -2555,7 +2555,7 @@ static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs,
error:
error:
return
ret
;
return
ret
;
done:
done:
*
i
nde
x
=
cur
;
*
i
d
x
=
cur
;
return
ret
;
return
ret
;
}
}
...
@@ -2575,13 +2575,13 @@ static void moveTimeStampToFirstKv(TAOS_SML_DATA_POINT** smlData, TAOS_SML_KV *t
...
@@ -2575,13 +2575,13 @@ static void moveTimeStampToFirstKv(TAOS_SML_DATA_POINT** smlData, TAOS_SML_KV *t
}
}
int32_t
tscParseLine
(
const
char
*
sql
,
TAOS_SML_DATA_POINT
*
smlData
,
SSmlLinesInfo
*
info
)
{
int32_t
tscParseLine
(
const
char
*
sql
,
TAOS_SML_DATA_POINT
*
smlData
,
SSmlLinesInfo
*
info
)
{
const
char
*
i
nde
x
=
sql
;
const
char
*
i
d
x
=
sql
;
int32_t
ret
=
TSDB_CODE_SUCCESS
;
int32_t
ret
=
TSDB_CODE_SUCCESS
;
uint8_t
has_tags
=
0
;
uint8_t
has_tags
=
0
;
TAOS_SML_KV
*
timestamp
=
NULL
;
TAOS_SML_KV
*
timestamp
=
NULL
;
SHashObj
*
keyHashTable
=
taosHashInit
(
32
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
false
);
SHashObj
*
keyHashTable
=
taosHashInit
(
32
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
false
);
ret
=
parseSmlMeasurement
(
smlData
,
&
i
nde
x
,
&
has_tags
,
info
);
ret
=
parseSmlMeasurement
(
smlData
,
&
i
d
x
,
&
has_tags
,
info
);
if
(
ret
)
{
if
(
ret
)
{
tscError
(
"SML:0x%"
PRIx64
" Unable to parse measurement"
,
info
->
id
);
tscError
(
"SML:0x%"
PRIx64
" Unable to parse measurement"
,
info
->
id
);
taosHashCleanup
(
keyHashTable
);
taosHashCleanup
(
keyHashTable
);
...
@@ -2591,7 +2591,7 @@ int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData, SSmlLinesInf
...
@@ -2591,7 +2591,7 @@ int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData, SSmlLinesInf
//Parse Tags
//Parse Tags
if
(
has_tags
)
{
if
(
has_tags
)
{
ret
=
parseSmlKvPairs
(
&
smlData
->
tags
,
&
smlData
->
tagNum
,
&
i
nde
x
,
false
,
smlData
,
keyHashTable
,
info
);
ret
=
parseSmlKvPairs
(
&
smlData
->
tags
,
&
smlData
->
tagNum
,
&
i
d
x
,
false
,
smlData
,
keyHashTable
,
info
);
if
(
ret
)
{
if
(
ret
)
{
tscError
(
"SML:0x%"
PRIx64
" Unable to parse tag"
,
info
->
id
);
tscError
(
"SML:0x%"
PRIx64
" Unable to parse tag"
,
info
->
id
);
taosHashCleanup
(
keyHashTable
);
taosHashCleanup
(
keyHashTable
);
...
@@ -2601,7 +2601,7 @@ int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData, SSmlLinesInf
...
@@ -2601,7 +2601,7 @@ int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData, SSmlLinesInf
tscDebug
(
"SML:0x%"
PRIx64
" Parse tags finished, num of tags:%d"
,
info
->
id
,
smlData
->
tagNum
);
tscDebug
(
"SML:0x%"
PRIx64
" Parse tags finished, num of tags:%d"
,
info
->
id
,
smlData
->
tagNum
);
//Parse fields
//Parse fields
ret
=
parseSmlKvPairs
(
&
smlData
->
fields
,
&
smlData
->
fieldNum
,
&
i
nde
x
,
true
,
smlData
,
keyHashTable
,
info
);
ret
=
parseSmlKvPairs
(
&
smlData
->
fields
,
&
smlData
->
fieldNum
,
&
i
d
x
,
true
,
smlData
,
keyHashTable
,
info
);
if
(
ret
)
{
if
(
ret
)
{
tscError
(
"SML:0x%"
PRIx64
" Unable to parse field"
,
info
->
id
);
tscError
(
"SML:0x%"
PRIx64
" Unable to parse field"
,
info
->
id
);
taosHashCleanup
(
keyHashTable
);
taosHashCleanup
(
keyHashTable
);
...
@@ -2611,7 +2611,7 @@ int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData, SSmlLinesInf
...
@@ -2611,7 +2611,7 @@ int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData, SSmlLinesInf
taosHashCleanup
(
keyHashTable
);
taosHashCleanup
(
keyHashTable
);
//Parse timestamp
//Parse timestamp
ret
=
parseSmlTimeStamp
(
&
timestamp
,
&
i
nde
x
,
info
);
ret
=
parseSmlTimeStamp
(
&
timestamp
,
&
i
d
x
,
info
);
if
(
ret
)
{
if
(
ret
)
{
tscError
(
"SML:0x%"
PRIx64
" Unable to parse timestamp"
,
info
->
id
);
tscError
(
"SML:0x%"
PRIx64
" Unable to parse timestamp"
,
info
->
id
);
return
ret
;
return
ret
;
...
...
src/client/src/tscParseOpenTSDB.c
浏览文件 @
3e42f5f1
...
@@ -33,8 +33,8 @@ static uint64_t genUID() {
...
@@ -33,8 +33,8 @@ static uint64_t genUID() {
return
id
;
return
id
;
}
}
static
int32_t
parseTelnetMetric
(
TAOS_SML_DATA_POINT
*
pSml
,
const
char
**
i
nde
x
,
SSmlLinesInfo
*
info
)
{
static
int32_t
parseTelnetMetric
(
TAOS_SML_DATA_POINT
*
pSml
,
const
char
**
i
d
x
,
SSmlLinesInfo
*
info
)
{
const
char
*
cur
=
*
i
nde
x
;
const
char
*
cur
=
*
i
d
x
;
uint16_t
len
=
0
;
uint16_t
len
=
0
;
pSml
->
stableName
=
tcalloc
(
TSDB_TABLE_NAME_LEN
+
TS_BACKQUOTE_CHAR_SIZE
,
1
);
pSml
->
stableName
=
tcalloc
(
TSDB_TABLE_NAME_LEN
+
TS_BACKQUOTE_CHAR_SIZE
,
1
);
...
@@ -76,13 +76,13 @@ static int32_t parseTelnetMetric(TAOS_SML_DATA_POINT *pSml, const char **index,
...
@@ -76,13 +76,13 @@ static int32_t parseTelnetMetric(TAOS_SML_DATA_POINT *pSml, const char **index,
}
}
addEscapeCharToString
(
pSml
->
stableName
,
len
);
addEscapeCharToString
(
pSml
->
stableName
,
len
);
*
i
nde
x
=
cur
+
1
;
*
i
d
x
=
cur
+
1
;
tscDebug
(
"OTD:0x%"
PRIx64
" Stable name in metric:%s|len:%d"
,
info
->
id
,
pSml
->
stableName
,
len
);
tscDebug
(
"OTD:0x%"
PRIx64
" Stable name in metric:%s|len:%d"
,
info
->
id
,
pSml
->
stableName
,
len
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
parseTelnetTimeStamp
(
TAOS_SML_KV
**
pTS
,
int
*
num_kvs
,
const
char
**
i
nde
x
,
SSmlLinesInfo
*
info
)
{
static
int32_t
parseTelnetTimeStamp
(
TAOS_SML_KV
**
pTS
,
int
*
num_kvs
,
const
char
**
i
d
x
,
SSmlLinesInfo
*
info
)
{
//Timestamp must be the first KV to parse
//Timestamp must be the first KV to parse
assert
(
*
num_kvs
==
0
);
assert
(
*
num_kvs
==
0
);
...
@@ -92,7 +92,7 @@ static int32_t parseTelnetTimeStamp(TAOS_SML_KV **pTS, int *num_kvs, const char
...
@@ -92,7 +92,7 @@ static int32_t parseTelnetTimeStamp(TAOS_SML_KV **pTS, int *num_kvs, const char
char
key
[]
=
OTD_TIMESTAMP_COLUMN_NAME
;
char
key
[]
=
OTD_TIMESTAMP_COLUMN_NAME
;
char
*
value
=
NULL
;
char
*
value
=
NULL
;
start
=
cur
=
*
i
nde
x
;
start
=
cur
=
*
i
d
x
;
//allocate fields for timestamp and value
//allocate fields for timestamp and value
*
pTS
=
tcalloc
(
OTD_MAX_FIELDS_NUM
,
sizeof
(
TAOS_SML_KV
));
*
pTS
=
tcalloc
(
OTD_MAX_FIELDS_NUM
,
sizeof
(
TAOS_SML_KV
));
...
@@ -130,12 +130,12 @@ static int32_t parseTelnetTimeStamp(TAOS_SML_KV **pTS, int *num_kvs, const char
...
@@ -130,12 +130,12 @@ static int32_t parseTelnetTimeStamp(TAOS_SML_KV **pTS, int *num_kvs, const char
addEscapeCharToString
((
*
pTS
)
->
key
,
(
int32_t
)
strlen
(
key
));
addEscapeCharToString
((
*
pTS
)
->
key
,
(
int32_t
)
strlen
(
key
));
*
num_kvs
+=
1
;
*
num_kvs
+=
1
;
*
i
nde
x
=
cur
+
1
;
*
i
d
x
=
cur
+
1
;
return
ret
;
return
ret
;
}
}
static
int32_t
parseTelnetMetricValue
(
TAOS_SML_KV
**
pKVs
,
int
*
num_kvs
,
const
char
**
i
nde
x
,
SSmlLinesInfo
*
info
)
{
static
int32_t
parseTelnetMetricValue
(
TAOS_SML_KV
**
pKVs
,
int
*
num_kvs
,
const
char
**
i
d
x
,
SSmlLinesInfo
*
info
)
{
//skip timestamp
//skip timestamp
TAOS_SML_KV
*
pVal
=
*
pKVs
+
1
;
TAOS_SML_KV
*
pVal
=
*
pKVs
+
1
;
const
char
*
start
,
*
cur
;
const
char
*
start
,
*
cur
;
...
@@ -145,7 +145,7 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
...
@@ -145,7 +145,7 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
char
key
[]
=
OTD_METRIC_VALUE_COLUMN_NAME
;
char
key
[]
=
OTD_METRIC_VALUE_COLUMN_NAME
;
char
*
value
=
NULL
;
char
*
value
=
NULL
;
start
=
cur
=
*
i
nde
x
;
start
=
cur
=
*
i
d
x
;
//if metric value is string
//if metric value is string
if
(
*
cur
==
'"'
)
{
if
(
*
cur
==
'"'
)
{
...
@@ -201,12 +201,12 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
...
@@ -201,12 +201,12 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
addEscapeCharToString
(
pVal
->
key
,
(
int32_t
)
strlen
(
pVal
->
key
));
addEscapeCharToString
(
pVal
->
key
,
(
int32_t
)
strlen
(
pVal
->
key
));
*
num_kvs
+=
1
;
*
num_kvs
+=
1
;
*
i
nde
x
=
cur
+
1
;
*
i
d
x
=
cur
+
1
;
return
ret
;
return
ret
;
}
}
static
int32_t
parseTelnetTagKey
(
TAOS_SML_KV
*
pKV
,
const
char
**
i
nde
x
,
SHashObj
*
pHash
,
SSmlLinesInfo
*
info
)
{
static
int32_t
parseTelnetTagKey
(
TAOS_SML_KV
*
pKV
,
const
char
**
i
d
x
,
SHashObj
*
pHash
,
SSmlLinesInfo
*
info
)
{
const
char
*
cur
=
*
i
nde
x
;
const
char
*
cur
=
*
i
d
x
;
char
key
[
TSDB_COL_NAME_LEN
];
char
key
[
TSDB_COL_NAME_LEN
];
uint16_t
len
=
0
;
uint16_t
len
=
0
;
...
@@ -244,17 +244,17 @@ static int32_t parseTelnetTagKey(TAOS_SML_KV *pKV, const char **index, SHashObj
...
@@ -244,17 +244,17 @@ static int32_t parseTelnetTagKey(TAOS_SML_KV *pKV, const char **index, SHashObj
memcpy
(
pKV
->
key
,
key
,
len
+
1
);
memcpy
(
pKV
->
key
,
key
,
len
+
1
);
addEscapeCharToString
(
pKV
->
key
,
len
);
addEscapeCharToString
(
pKV
->
key
,
len
);
//tscDebug("OTD:0x%"PRIx64" Key:%s|len:%d", info->id, pKV->key, len);
//tscDebug("OTD:0x%"PRIx64" Key:%s|len:%d", info->id, pKV->key, len);
*
i
nde
x
=
cur
+
1
;
*
i
d
x
=
cur
+
1
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
parseTelnetTagValue
(
TAOS_SML_KV
*
pKV
,
const
char
**
i
nde
x
,
static
int32_t
parseTelnetTagValue
(
TAOS_SML_KV
*
pKV
,
const
char
**
i
d
x
,
bool
*
is_last_kv
,
SSmlLinesInfo
*
info
)
{
bool
*
is_last_kv
,
SSmlLinesInfo
*
info
)
{
const
char
*
start
,
*
cur
;
const
char
*
start
,
*
cur
;
char
*
value
=
NULL
;
char
*
value
=
NULL
;
uint16_t
len
=
0
;
uint16_t
len
=
0
;
start
=
cur
=
*
i
nde
x
;
start
=
cur
=
*
i
d
x
;
while
(
1
)
{
while
(
1
)
{
// whitespace or '\0' identifies a value
// whitespace or '\0' identifies a value
...
@@ -290,14 +290,14 @@ static int32_t parseTelnetTagValue(TAOS_SML_KV *pKV, const char **index,
...
@@ -290,14 +290,14 @@ static int32_t parseTelnetTagValue(TAOS_SML_KV *pKV, const char **index,
}
}
tfree
(
value
);
tfree
(
value
);
*
i
nde
x
=
(
*
cur
==
'\0'
)
?
cur
:
cur
+
1
;
*
i
d
x
=
(
*
cur
==
'\0'
)
?
cur
:
cur
+
1
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
parseTelnetTagKvs
(
TAOS_SML_KV
**
pKVs
,
int
*
num_kvs
,
static
int32_t
parseTelnetTagKvs
(
TAOS_SML_KV
**
pKVs
,
int
*
num_kvs
,
const
char
**
i
nde
x
,
char
**
childTableName
,
const
char
**
i
d
x
,
char
**
childTableName
,
SHashObj
*
pHash
,
SSmlLinesInfo
*
info
)
{
SHashObj
*
pHash
,
SSmlLinesInfo
*
info
)
{
const
char
*
cur
=
*
i
nde
x
;
const
char
*
cur
=
*
i
d
x
;
int32_t
ret
=
TSDB_CODE_SUCCESS
;
int32_t
ret
=
TSDB_CODE_SUCCESS
;
TAOS_SML_KV
*
pkv
;
TAOS_SML_KV
*
pkv
;
bool
is_last_kv
=
false
;
bool
is_last_kv
=
false
;
...
@@ -357,11 +357,11 @@ static int32_t parseTelnetTagKvs(TAOS_SML_KV **pKVs, int *num_kvs,
...
@@ -357,11 +357,11 @@ static int32_t parseTelnetTagKvs(TAOS_SML_KV **pKVs, int *num_kvs,
}
}
static
int32_t
tscParseTelnetLine
(
const
char
*
line
,
TAOS_SML_DATA_POINT
*
smlData
,
SSmlLinesInfo
*
info
)
{
static
int32_t
tscParseTelnetLine
(
const
char
*
line
,
TAOS_SML_DATA_POINT
*
smlData
,
SSmlLinesInfo
*
info
)
{
const
char
*
i
nde
x
=
line
;
const
char
*
i
d
x
=
line
;
int32_t
ret
=
TSDB_CODE_SUCCESS
;
int32_t
ret
=
TSDB_CODE_SUCCESS
;
//Parse metric
//Parse metric
ret
=
parseTelnetMetric
(
smlData
,
&
i
nde
x
,
info
);
ret
=
parseTelnetMetric
(
smlData
,
&
i
d
x
,
info
);
if
(
ret
)
{
if
(
ret
)
{
tscError
(
"OTD:0x%"
PRIx64
" Unable to parse metric"
,
info
->
id
);
tscError
(
"OTD:0x%"
PRIx64
" Unable to parse metric"
,
info
->
id
);
return
ret
;
return
ret
;
...
@@ -369,7 +369,7 @@ static int32_t tscParseTelnetLine(const char* line, TAOS_SML_DATA_POINT* smlData
...
@@ -369,7 +369,7 @@ static int32_t tscParseTelnetLine(const char* line, TAOS_SML_DATA_POINT* smlData
tscDebug
(
"OTD:0x%"
PRIx64
" Parse metric finished"
,
info
->
id
);
tscDebug
(
"OTD:0x%"
PRIx64
" Parse metric finished"
,
info
->
id
);
//Parse timestamp
//Parse timestamp
ret
=
parseTelnetTimeStamp
(
&
smlData
->
fields
,
&
smlData
->
fieldNum
,
&
i
nde
x
,
info
);
ret
=
parseTelnetTimeStamp
(
&
smlData
->
fields
,
&
smlData
->
fieldNum
,
&
i
d
x
,
info
);
if
(
ret
)
{
if
(
ret
)
{
tscError
(
"OTD:0x%"
PRIx64
" Unable to parse timestamp"
,
info
->
id
);
tscError
(
"OTD:0x%"
PRIx64
" Unable to parse timestamp"
,
info
->
id
);
return
ret
;
return
ret
;
...
@@ -377,7 +377,7 @@ static int32_t tscParseTelnetLine(const char* line, TAOS_SML_DATA_POINT* smlData
...
@@ -377,7 +377,7 @@ static int32_t tscParseTelnetLine(const char* line, TAOS_SML_DATA_POINT* smlData
tscDebug
(
"OTD:0x%"
PRIx64
" Parse timestamp finished"
,
info
->
id
);
tscDebug
(
"OTD:0x%"
PRIx64
" Parse timestamp finished"
,
info
->
id
);
//Parse value
//Parse value
ret
=
parseTelnetMetricValue
(
&
smlData
->
fields
,
&
smlData
->
fieldNum
,
&
i
nde
x
,
info
);
ret
=
parseTelnetMetricValue
(
&
smlData
->
fields
,
&
smlData
->
fieldNum
,
&
i
d
x
,
info
);
if
(
ret
)
{
if
(
ret
)
{
tscError
(
"OTD:0x%"
PRIx64
" Unable to parse metric value"
,
info
->
id
);
tscError
(
"OTD:0x%"
PRIx64
" Unable to parse metric value"
,
info
->
id
);
return
ret
;
return
ret
;
...
@@ -386,7 +386,7 @@ static int32_t tscParseTelnetLine(const char* line, TAOS_SML_DATA_POINT* smlData
...
@@ -386,7 +386,7 @@ static int32_t tscParseTelnetLine(const char* line, TAOS_SML_DATA_POINT* smlData
//Parse tagKVs
//Parse tagKVs
SHashObj
*
keyHashTable
=
taosHashInit
(
128
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
false
);
SHashObj
*
keyHashTable
=
taosHashInit
(
128
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
false
);
ret
=
parseTelnetTagKvs
(
&
smlData
->
tags
,
&
smlData
->
tagNum
,
&
i
nde
x
,
&
smlData
->
childTableName
,
keyHashTable
,
info
);
ret
=
parseTelnetTagKvs
(
&
smlData
->
tags
,
&
smlData
->
tagNum
,
&
i
d
x
,
&
smlData
->
childTableName
,
keyHashTable
,
info
);
if
(
ret
)
{
if
(
ret
)
{
tscError
(
"OTD:0x%"
PRIx64
" Unable to parse tags"
,
info
->
id
);
tscError
(
"OTD:0x%"
PRIx64
" Unable to parse tags"
,
info
->
id
);
taosHashCleanup
(
keyHashTable
);
taosHashCleanup
(
keyHashTable
);
...
...
src/client/src/tscPrepare.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/client/src/tscSQLParser.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/client/src/tscServer.c
浏览文件 @
3e42f5f1
...
@@ -740,13 +740,13 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab
...
@@ -740,13 +740,13 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab
int32_t
vgId
=
-
1
;
int32_t
vgId
=
-
1
;
if
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
if
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
int32_t
i
nde
x
=
pTableMetaInfo
->
vgroupIndex
;
int32_t
i
d
x
=
pTableMetaInfo
->
vgroupIndex
;
assert
(
i
nde
x
>=
0
);
assert
(
i
d
x
>=
0
);
SVgroupMsg
*
pVgroupInfo
=
NULL
;
SVgroupMsg
*
pVgroupInfo
=
NULL
;
if
(
pTableMetaInfo
->
vgroupList
&&
pTableMetaInfo
->
vgroupList
->
numOfVgroups
>
0
)
{
if
(
pTableMetaInfo
->
vgroupList
&&
pTableMetaInfo
->
vgroupList
->
numOfVgroups
>
0
)
{
assert
(
i
nde
x
<
pTableMetaInfo
->
vgroupList
->
numOfVgroups
);
assert
(
i
d
x
<
pTableMetaInfo
->
vgroupList
->
numOfVgroups
);
pVgroupInfo
=
&
pTableMetaInfo
->
vgroupList
->
vgroups
[
i
nde
x
];
pVgroupInfo
=
&
pTableMetaInfo
->
vgroupList
->
vgroups
[
i
d
x
];
}
else
{
}
else
{
tscError
(
"0x%"
PRIx64
" No vgroup info found"
,
pSql
->
self
);
tscError
(
"0x%"
PRIx64
" No vgroup info found"
,
pSql
->
self
);
...
@@ -756,7 +756,7 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab
...
@@ -756,7 +756,7 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab
vgId
=
pVgroupInfo
->
vgId
;
vgId
=
pVgroupInfo
->
vgId
;
tscSetDnodeEpSet
(
&
pSql
->
epSet
,
pVgroupInfo
);
tscSetDnodeEpSet
(
&
pSql
->
epSet
,
pVgroupInfo
);
tscDebug
(
"0x%"
PRIx64
" query on stable, vgIndex:%d, numOfVgroups:%d"
,
pSql
->
self
,
i
nde
x
,
pTableMetaInfo
->
vgroupList
->
numOfVgroups
);
tscDebug
(
"0x%"
PRIx64
" query on stable, vgIndex:%d, numOfVgroups:%d"
,
pSql
->
self
,
i
d
x
,
pTableMetaInfo
->
vgroupList
->
numOfVgroups
);
}
else
{
}
else
{
vgId
=
pTableMeta
->
vgId
;
vgId
=
pTableMeta
->
vgId
;
...
@@ -778,11 +778,11 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab
...
@@ -778,11 +778,11 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab
pQueryMsg
->
numOfTables
=
htonl
(
1
);
// set the number of tables
pQueryMsg
->
numOfTables
=
htonl
(
1
);
// set the number of tables
pMsg
+=
sizeof
(
STableIdInfo
);
pMsg
+=
sizeof
(
STableIdInfo
);
}
else
{
// it is a subquery of the super table query, this EP info is acquired from vgroupInfo
}
else
{
// it is a subquery of the super table query, this EP info is acquired from vgroupInfo
int32_t
i
nde
x
=
pTableMetaInfo
->
vgroupIndex
;
int32_t
i
d
x
=
pTableMetaInfo
->
vgroupIndex
;
int32_t
numOfVgroups
=
(
int32_t
)
taosArrayGetSize
(
pTableMetaInfo
->
pVgroupTables
);
int32_t
numOfVgroups
=
(
int32_t
)
taosArrayGetSize
(
pTableMetaInfo
->
pVgroupTables
);
assert
(
i
ndex
>=
0
&&
inde
x
<
numOfVgroups
);
assert
(
i
dx
>=
0
&&
id
x
<
numOfVgroups
);
SVgroupTableInfo
*
pTableIdList
=
taosArrayGet
(
pTableMetaInfo
->
pVgroupTables
,
i
nde
x
);
SVgroupTableInfo
*
pTableIdList
=
taosArrayGet
(
pTableMetaInfo
->
pVgroupTables
,
i
d
x
);
// set the vgroup info
// set the vgroup info
tscSetDnodeEpSet
(
&
pSql
->
epSet
,
&
pTableIdList
->
vgInfo
);
tscSetDnodeEpSet
(
&
pSql
->
epSet
,
&
pTableIdList
->
vgInfo
);
...
@@ -792,7 +792,7 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab
...
@@ -792,7 +792,7 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab
pQueryMsg
->
numOfTables
=
htonl
(
numOfTables
);
// set the number of tables
pQueryMsg
->
numOfTables
=
htonl
(
numOfTables
);
// set the number of tables
tscDebug
(
"0x%"
PRIx64
" query on stable, vgId:%d, numOfTables:%d, vgIndex:%d, numOfVgroups:%d"
,
pSql
->
self
,
tscDebug
(
"0x%"
PRIx64
" query on stable, vgId:%d, numOfTables:%d, vgIndex:%d, numOfVgroups:%d"
,
pSql
->
self
,
pTableIdList
->
vgInfo
.
vgId
,
numOfTables
,
i
nde
x
,
numOfVgroups
);
pTableIdList
->
vgInfo
.
vgId
,
numOfTables
,
i
d
x
,
numOfVgroups
);
// serialize each table id info
// serialize each table id info
for
(
int32_t
i
=
0
;
i
<
numOfTables
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfTables
;
++
i
)
{
...
@@ -2557,18 +2557,18 @@ int tscProcessShowRsp(SSqlObj *pSql) {
...
@@ -2557,18 +2557,18 @@ int tscProcessShowRsp(SSqlObj *pSql) {
SFieldInfo
*
pFieldInfo
=
&
pQueryInfo
->
fieldsInfo
;
SFieldInfo
*
pFieldInfo
=
&
pQueryInfo
->
fieldsInfo
;
SColumnIndex
i
nde
x
=
{
0
};
SColumnIndex
i
d
x
=
{
0
};
pSchema
=
pMetaMsg
->
schema
;
pSchema
=
pMetaMsg
->
schema
;
uint64_t
uid
=
pTableMetaInfo
->
pTableMeta
->
id
.
uid
;
uint64_t
uid
=
pTableMetaInfo
->
pTableMeta
->
id
.
uid
;
for
(
int16_t
i
=
0
;
i
<
pMetaMsg
->
numOfColumns
;
++
i
,
++
pSchema
)
{
for
(
int16_t
i
=
0
;
i
<
pMetaMsg
->
numOfColumns
;
++
i
,
++
pSchema
)
{
i
nde
x
.
columnIndex
=
i
;
i
d
x
.
columnIndex
=
i
;
tscColumnListInsert
(
pQueryInfo
->
colList
,
i
,
uid
,
pSchema
);
tscColumnListInsert
(
pQueryInfo
->
colList
,
i
,
uid
,
pSchema
);
TAOS_FIELD
f
=
tscCreateField
(
pSchema
->
type
,
pSchema
->
name
,
pSchema
->
bytes
);
TAOS_FIELD
f
=
tscCreateField
(
pSchema
->
type
,
pSchema
->
name
,
pSchema
->
bytes
);
SInternalField
*
pInfo
=
tscFieldInfoAppend
(
pFieldInfo
,
&
f
);
SInternalField
*
pInfo
=
tscFieldInfoAppend
(
pFieldInfo
,
&
f
);
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
i
nde
x
,
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
i
d
x
,
pTableSchema
[
i
].
type
,
pTableSchema
[
i
].
bytes
,
getNewResColId
(
pCmd
),
pTableSchema
[
i
].
bytes
,
false
);
pTableSchema
[
i
].
type
,
pTableSchema
[
i
].
bytes
,
getNewResColId
(
pCmd
),
pTableSchema
[
i
].
bytes
,
false
);
}
}
...
...
src/client/src/tscStream.c
浏览文件 @
3e42f5f1
...
@@ -424,8 +424,8 @@ static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql) {
...
@@ -424,8 +424,8 @@ static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql) {
return
;
return
;
}
}
}
else
{
}
else
{
int64_t
stime
=
taosTimeTruncate
(
pStream
->
stime
-
1
,
&
pStream
->
interval
,
pStream
->
precision
);
int64_t
st
artT
ime
=
taosTimeTruncate
(
pStream
->
stime
-
1
,
&
pStream
->
interval
,
pStream
->
precision
);
if
(
stime
>=
pStream
->
etime
)
{
if
(
st
artT
ime
>=
pStream
->
etime
)
{
tscDebug
(
"0x%"
PRIx64
" stream:%p, stime:%"
PRId64
" is larger than end time: %"
PRId64
", stop the stream"
,
pStream
->
pSql
->
self
,
pStream
,
tscDebug
(
"0x%"
PRIx64
" stream:%p, stime:%"
PRId64
" is larger than end time: %"
PRId64
", stop the stream"
,
pStream
->
pSql
->
self
,
pStream
,
pStream
->
stime
,
pStream
->
etime
);
pStream
->
stime
,
pStream
->
etime
);
// TODO : How to terminate stream here
// TODO : How to terminate stream here
...
@@ -505,7 +505,7 @@ static int32_t tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) {
...
@@ -505,7 +505,7 @@ static int32_t tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int64_t
tscGetStreamStartTimestamp
(
SSqlObj
*
pSql
,
SSqlStream
*
pStream
,
int64_t
stime
)
{
static
int64_t
tscGetStreamStartTimestamp
(
SSqlObj
*
pSql
,
SSqlStream
*
pStream
,
int64_t
st
artT
ime
)
{
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
&
pSql
->
cmd
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
&
pSql
->
cmd
);
if
(
pStream
->
isProject
)
{
if
(
pStream
->
isProject
)
{
...
@@ -513,31 +513,31 @@ static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, in
...
@@ -513,31 +513,31 @@ static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, in
pStream
->
interval
.
interval
=
tsProjectExecInterval
;
pStream
->
interval
.
interval
=
tsProjectExecInterval
;
pStream
->
interval
.
sliding
=
tsProjectExecInterval
;
pStream
->
interval
.
sliding
=
tsProjectExecInterval
;
if
(
stime
!=
INT64_MIN
)
{
// first projection start from the latest event timestamp
if
(
st
artT
ime
!=
INT64_MIN
)
{
// first projection start from the latest event timestamp
assert
(
stime
>=
pQueryInfo
->
window
.
skey
);
assert
(
st
artT
ime
>=
pQueryInfo
->
window
.
skey
);
stime
+=
1
;
// exclude the last records from table
st
artT
ime
+=
1
;
// exclude the last records from table
}
else
{
}
else
{
stime
=
pQueryInfo
->
window
.
skey
;
st
artT
ime
=
pQueryInfo
->
window
.
skey
;
}
}
}
else
{
// timewindow based aggregation stream
}
else
{
// timewindow based aggregation stream
if
(
stime
==
INT64_MIN
)
{
// no data in meter till now
if
(
st
artT
ime
==
INT64_MIN
)
{
// no data in meter till now
if
(
pQueryInfo
->
window
.
skey
!=
INT64_MIN
)
{
if
(
pQueryInfo
->
window
.
skey
!=
INT64_MIN
)
{
stime
=
pQueryInfo
->
window
.
skey
;
st
artT
ime
=
pQueryInfo
->
window
.
skey
;
}
else
{
}
else
{
return
stime
;
return
st
artT
ime
;
}
}
st
ime
=
taosTimeTruncate
(
st
ime
,
&
pStream
->
interval
,
pStream
->
precision
);
st
artTime
=
taosTimeTruncate
(
startT
ime
,
&
pStream
->
interval
,
pStream
->
precision
);
}
else
{
}
else
{
int64_t
newStime
=
taosTimeTruncate
(
stime
,
&
pStream
->
interval
,
pStream
->
precision
);
int64_t
newStime
=
taosTimeTruncate
(
st
artT
ime
,
&
pStream
->
interval
,
pStream
->
precision
);
if
(
newStime
!=
stime
)
{
if
(
newStime
!=
st
artT
ime
)
{
tscWarn
(
"0x%"
PRIx64
" stream:%p, last timestamp:%"
PRId64
", reset to:%"
PRId64
,
pSql
->
self
,
pStream
,
stime
,
newStime
);
tscWarn
(
"0x%"
PRIx64
" stream:%p, last timestamp:%"
PRId64
", reset to:%"
PRId64
,
pSql
->
self
,
pStream
,
st
artT
ime
,
newStime
);
stime
=
newStime
;
st
artT
ime
=
newStime
;
}
}
}
}
}
}
return
stime
;
return
st
artT
ime
;
}
}
static
int64_t
tscGetLaunchTimestamp
(
const
SSqlStream
*
pStream
)
{
static
int64_t
tscGetLaunchTimestamp
(
const
SSqlStream
*
pStream
)
{
...
@@ -668,7 +668,7 @@ void cbParseSql(void* param, TAOS_RES* res, int code) {
...
@@ -668,7 +668,7 @@ void cbParseSql(void* param, TAOS_RES* res, int code) {
}
}
TAOS_STREAM
*
taos_open_stream_withname
(
TAOS
*
taos
,
const
char
*
dstTable
,
const
char
*
sqlstr
,
void
(
*
fp
)(
void
*
,
TAOS_RES
*
,
TAOS_ROW
),
TAOS_STREAM
*
taos_open_stream_withname
(
TAOS
*
taos
,
const
char
*
dstTable
,
const
char
*
sqlstr
,
void
(
*
fp
)(
void
*
,
TAOS_RES
*
,
TAOS_ROW
),
int64_t
stime
,
void
*
param
,
void
(
*
callback
)(
void
*
),
void
*
cqhandle
)
{
int64_t
st
artT
ime
,
void
*
param
,
void
(
*
callback
)(
void
*
),
void
*
cqhandle
)
{
STscObj
*
pObj
=
(
STscObj
*
)
taos
;
STscObj
*
pObj
=
(
STscObj
*
)
taos
;
if
(
pObj
==
NULL
||
pObj
->
signature
!=
pObj
)
return
NULL
;
if
(
pObj
==
NULL
||
pObj
->
signature
!=
pObj
)
return
NULL
;
...
@@ -697,7 +697,7 @@ TAOS_STREAM *taos_open_stream_withname(TAOS *taos, const char* dstTable, const c
...
@@ -697,7 +697,7 @@ TAOS_STREAM *taos_open_stream_withname(TAOS *taos, const char* dstTable, const c
}
}
pStream
->
ltime
=
INT64_MIN
;
pStream
->
ltime
=
INT64_MIN
;
pStream
->
stime
=
stime
;
pStream
->
stime
=
st
artT
ime
;
pStream
->
fp
=
fp
;
pStream
->
fp
=
fp
;
pStream
->
callback
=
callback
;
pStream
->
callback
=
callback
;
pStream
->
param
=
param
;
pStream
->
param
=
param
;
...
@@ -747,8 +747,8 @@ TAOS_STREAM *taos_open_stream_withname(TAOS *taos, const char* dstTable, const c
...
@@ -747,8 +747,8 @@ TAOS_STREAM *taos_open_stream_withname(TAOS *taos, const char* dstTable, const c
}
}
TAOS_STREAM
*
taos_open_stream
(
TAOS
*
taos
,
const
char
*
sqlstr
,
void
(
*
fp
)(
void
*
,
TAOS_RES
*
,
TAOS_ROW
),
TAOS_STREAM
*
taos_open_stream
(
TAOS
*
taos
,
const
char
*
sqlstr
,
void
(
*
fp
)(
void
*
,
TAOS_RES
*
,
TAOS_ROW
),
int64_t
stime
,
void
*
param
,
void
(
*
callback
)(
void
*
))
{
int64_t
st
artT
ime
,
void
*
param
,
void
(
*
callback
)(
void
*
))
{
return
taos_open_stream_withname
(
taos
,
""
,
sqlstr
,
fp
,
stime
,
param
,
callback
,
NULL
);
return
taos_open_stream_withname
(
taos
,
""
,
sqlstr
,
fp
,
st
artT
ime
,
param
,
callback
,
NULL
);
}
}
void
taos_close_stream
(
TAOS_STREAM
*
handle
)
{
void
taos_close_stream
(
TAOS_STREAM
*
handle
)
{
...
...
src/client/src/tscSubquery.c
浏览文件 @
3e42f5f1
...
@@ -383,7 +383,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, STimeWindow * win) {
...
@@ -383,7 +383,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, STimeWindow * win) {
// todo handle failed to create sub query
// todo handle failed to create sub query
SJoinSupporter
*
tscCreateJoinSupporter
(
SSqlObj
*
pSql
,
int32_t
i
nde
x
)
{
SJoinSupporter
*
tscCreateJoinSupporter
(
SSqlObj
*
pSql
,
int32_t
i
d
x
)
{
SJoinSupporter
*
pSupporter
=
calloc
(
1
,
sizeof
(
SJoinSupporter
));
SJoinSupporter
*
pSupporter
=
calloc
(
1
,
sizeof
(
SJoinSupporter
));
if
(
pSupporter
==
NULL
)
{
if
(
pSupporter
==
NULL
)
{
return
NULL
;
return
NULL
;
...
@@ -391,7 +391,7 @@ SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, int32_t index) {
...
@@ -391,7 +391,7 @@ SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, int32_t index) {
pSupporter
->
pObj
=
pSql
->
self
;
pSupporter
->
pObj
=
pSql
->
self
;
pSupporter
->
subqueryIndex
=
i
nde
x
;
pSupporter
->
subqueryIndex
=
i
d
x
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
&
pSql
->
cmd
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
&
pSql
->
cmd
);
memcpy
(
&
pSupporter
->
interval
,
&
pQueryInfo
->
interval
,
sizeof
(
pSupporter
->
interval
));
memcpy
(
&
pSupporter
->
interval
,
&
pQueryInfo
->
interval
,
sizeof
(
pSupporter
->
interval
));
...
@@ -403,7 +403,7 @@ SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, int32_t index) {
...
@@ -403,7 +403,7 @@ SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, int32_t index) {
pSupporter
->
numOfFillVal
=
pQueryInfo
->
numOfFillVal
;
pSupporter
->
numOfFillVal
=
pQueryInfo
->
numOfFillVal
;
}
}
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pSql
->
cmd
,
i
nde
x
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pSql
->
cmd
,
i
d
x
);
pSupporter
->
uid
=
pTableMetaInfo
->
pTableMeta
->
id
.
uid
;
pSupporter
->
uid
=
pTableMetaInfo
->
pTableMeta
->
id
.
uid
;
assert
(
pSupporter
->
uid
!=
0
);
assert
(
pSupporter
->
uid
!=
0
);
...
@@ -614,7 +614,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
...
@@ -614,7 +614,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
* during the timestamp intersection.
* during the timestamp intersection.
*/
*/
pSupporter
->
limit
=
pQueryInfo
->
limit
;
pSupporter
->
limit
=
pQueryInfo
->
limit
;
SColumnIndex
i
nde
x
=
{.
tableIndex
=
0
,
.
columnIndex
=
PRIMARYKEY_TIMESTAMP_COL_INDEX
};
SColumnIndex
i
d
x
=
{.
tableIndex
=
0
,
.
columnIndex
=
PRIMARYKEY_TIMESTAMP_COL_INDEX
};
SSchema
*
s
=
tscGetTableColumnSchema
(
pTableMetaInfo
->
pTableMeta
,
0
);
SSchema
*
s
=
tscGetTableColumnSchema
(
pTableMetaInfo
->
pTableMeta
,
0
);
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
0
);
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
0
);
...
@@ -626,7 +626,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
...
@@ -626,7 +626,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
int16_t
functionId
=
tscIsProjectionQuery
(
pQueryInfo
)
?
TSDB_FUNC_PRJ
:
TSDB_FUNC_TS
;
int16_t
functionId
=
tscIsProjectionQuery
(
pQueryInfo
)
?
TSDB_FUNC_PRJ
:
TSDB_FUNC_TS
;
tscAddFuncInSelectClause
(
pQueryInfo
,
0
,
functionId
,
&
i
nde
x
,
s
,
TSDB_COL_NORMAL
,
getNewResColId
(
&
pNew
->
cmd
));
tscAddFuncInSelectClause
(
pQueryInfo
,
0
,
functionId
,
&
i
d
x
,
s
,
TSDB_COL_NORMAL
,
getNewResColId
(
&
pNew
->
cmd
));
tscPrintSelNodeList
(
pNew
,
0
);
tscPrintSelNodeList
(
pNew
,
0
);
tscFieldInfoUpdateOffset
(
pQueryInfo
);
tscFieldInfoUpdateOffset
(
pQueryInfo
);
...
@@ -836,8 +836,8 @@ static void issueTsCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj*
...
@@ -836,8 +836,8 @@ static void issueTsCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj*
SSchema
colSchema
=
{.
type
=
TSDB_DATA_TYPE_BINARY
,
.
bytes
=
1
};
SSchema
colSchema
=
{.
type
=
TSDB_DATA_TYPE_BINARY
,
.
bytes
=
1
};
SColumnIndex
i
nde
x
=
{
0
,
PRIMARYKEY_TIMESTAMP_COL_INDEX
};
SColumnIndex
i
d
x
=
{
0
,
PRIMARYKEY_TIMESTAMP_COL_INDEX
};
SExprInfo
*
pExpr
=
tscAddFuncInSelectClause
(
pQueryInfo
,
0
,
TSDB_FUNC_TS_COMP
,
&
i
nde
x
,
&
colSchema
,
TSDB_COL_NORMAL
,
getNewResColId
(
pCmd
));
SExprInfo
*
pExpr
=
tscAddFuncInSelectClause
(
pQueryInfo
,
0
,
TSDB_FUNC_TS_COMP
,
&
i
d
x
,
&
colSchema
,
TSDB_COL_NORMAL
,
getNewResColId
(
pCmd
));
// set the tags value for ts_comp function
// set the tags value for ts_comp function
if
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
if
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
...
@@ -2569,7 +2569,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
...
@@ -2569,7 +2569,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
int32_t
numOfExprs
=
(
int32_t
)
tscNumOfExprs
(
pQueryInfo
);
int32_t
numOfExprs
=
(
int32_t
)
tscNumOfExprs
(
pQueryInfo
);
int32_t
i
nde
x
=
0
;
int32_t
i
d
x
=
0
;
for
(
int32_t
i
=
0
;
i
<
numOfExprs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfExprs
;
++
i
)
{
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
i
);
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
i
);
if
(
pExpr
->
base
.
functionId
==
TSDB_FUNC_TS
&&
pQueryInfo
->
interval
.
interval
>
0
)
{
if
(
pExpr
->
base
.
functionId
==
TSDB_FUNC_TS
&&
pQueryInfo
->
interval
.
interval
>
0
)
{
...
@@ -2578,7 +2578,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
...
@@ -2578,7 +2578,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
SColumnIndex
colIndex
=
{.
tableIndex
=
0
,
.
columnIndex
=
PRIMARYKEY_TIMESTAMP_COL_INDEX
};
SColumnIndex
colIndex
=
{.
tableIndex
=
0
,
.
columnIndex
=
PRIMARYKEY_TIMESTAMP_COL_INDEX
};
SSchema
*
schema
=
tscGetColumnSchemaById
(
pTableMetaInfo1
->
pTableMeta
,
pExpr
->
base
.
colInfo
.
colId
);
SSchema
*
schema
=
tscGetColumnSchemaById
(
pTableMetaInfo1
->
pTableMeta
,
pExpr
->
base
.
colInfo
.
colId
);
SExprInfo
*
p
=
tscAddFuncInSelectClause
(
pNewQueryInfo
,
i
nde
x
++
,
TSDB_FUNC_TS
,
&
colIndex
,
schema
,
TSDB_COL_NORMAL
,
getNewResColId
(
pCmd
));
SExprInfo
*
p
=
tscAddFuncInSelectClause
(
pNewQueryInfo
,
i
d
x
++
,
TSDB_FUNC_TS
,
&
colIndex
,
schema
,
TSDB_COL_NORMAL
,
getNewResColId
(
pCmd
));
p
->
base
.
resColId
=
pExpr
->
base
.
resColId
;
// update the result column id
p
->
base
.
resColId
=
pExpr
->
base
.
resColId
;
// update the result column id
}
else
if
(
pExpr
->
base
.
functionId
==
TSDB_FUNC_STDDEV_DST
)
{
}
else
if
(
pExpr
->
base
.
functionId
==
TSDB_FUNC_STDDEV_DST
)
{
taosArrayPush
(
pSup
->
pColsInfo
,
&
pExpr
->
base
.
resColId
);
taosArrayPush
(
pSup
->
pColsInfo
,
&
pExpr
->
base
.
resColId
);
...
@@ -2587,7 +2587,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
...
@@ -2587,7 +2587,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
SSchema
schema
=
{.
type
=
TSDB_DATA_TYPE_DOUBLE
,
.
bytes
=
sizeof
(
double
)};
SSchema
schema
=
{.
type
=
TSDB_DATA_TYPE_DOUBLE
,
.
bytes
=
sizeof
(
double
)};
tstrncpy
(
schema
.
name
,
pExpr
->
base
.
aliasName
,
tListLen
(
schema
.
name
));
tstrncpy
(
schema
.
name
,
pExpr
->
base
.
aliasName
,
tListLen
(
schema
.
name
));
SExprInfo
*
p
=
tscAddFuncInSelectClause
(
pNewQueryInfo
,
i
nde
x
++
,
TSDB_FUNC_AVG
,
&
colIndex
,
&
schema
,
TSDB_COL_NORMAL
,
getNewResColId
(
pCmd
));
SExprInfo
*
p
=
tscAddFuncInSelectClause
(
pNewQueryInfo
,
i
d
x
++
,
TSDB_FUNC_AVG
,
&
colIndex
,
&
schema
,
TSDB_COL_NORMAL
,
getNewResColId
(
pCmd
));
p
->
base
.
resColId
=
pExpr
->
base
.
resColId
;
// update the result column id
p
->
base
.
resColId
=
pExpr
->
base
.
resColId
;
// update the result column id
}
else
if
(
pExpr
->
base
.
functionId
==
TSDB_FUNC_TAG
)
{
}
else
if
(
pExpr
->
base
.
functionId
==
TSDB_FUNC_TAG
)
{
pSup
->
tagLen
+=
pExpr
->
base
.
resBytes
;
pSup
->
tagLen
+=
pExpr
->
base
.
resBytes
;
...
@@ -2600,7 +2600,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
...
@@ -2600,7 +2600,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
schema
=
tGetTbnameColumnSchema
();
schema
=
tGetTbnameColumnSchema
();
}
}
SExprInfo
*
p
=
tscAddFuncInSelectClause
(
pNewQueryInfo
,
i
nde
x
++
,
TSDB_FUNC_TAG
,
&
colIndex
,
schema
,
TSDB_COL_TAG
,
getNewResColId
(
pCmd
));
SExprInfo
*
p
=
tscAddFuncInSelectClause
(
pNewQueryInfo
,
i
d
x
++
,
TSDB_FUNC_TAG
,
&
colIndex
,
schema
,
TSDB_COL_TAG
,
getNewResColId
(
pCmd
));
if
(
schema
->
type
==
TSDB_DATA_TYPE_JSON
){
if
(
schema
->
type
==
TSDB_DATA_TYPE_JSON
){
p
->
base
.
numOfParams
=
pExpr
->
base
.
numOfParams
;
p
->
base
.
numOfParams
=
pExpr
->
base
.
numOfParams
;
tVariantAssign
(
&
p
->
base
.
param
[
0
],
&
pExpr
->
base
.
param
[
0
]);
tVariantAssign
(
&
p
->
base
.
param
[
0
],
&
pExpr
->
base
.
param
[
0
]);
...
@@ -2618,7 +2618,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
...
@@ -2618,7 +2618,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
SSchema
*
schema
=
tscGetColumnSchemaById
(
pTableMetaInfo1
->
pTableMeta
,
pExpr
->
base
.
colInfo
.
colId
);
SSchema
*
schema
=
tscGetColumnSchemaById
(
pTableMetaInfo1
->
pTableMeta
,
pExpr
->
base
.
colInfo
.
colId
);
//doLimitOutputNormalColOfGroupby
//doLimitOutputNormalColOfGroupby
SExprInfo
*
p
=
tscAddFuncInSelectClause
(
pNewQueryInfo
,
i
nde
x
++
,
TSDB_FUNC_PRJ
,
&
colIndex
,
schema
,
TSDB_COL_NORMAL
,
getNewResColId
(
pCmd
));
SExprInfo
*
p
=
tscAddFuncInSelectClause
(
pNewQueryInfo
,
i
d
x
++
,
TSDB_FUNC_PRJ
,
&
colIndex
,
schema
,
TSDB_COL_NORMAL
,
getNewResColId
(
pCmd
));
p
->
base
.
numOfParams
=
1
;
p
->
base
.
numOfParams
=
1
;
p
->
base
.
param
[
0
].
i64
=
1
;
p
->
base
.
param
[
0
].
i64
=
1
;
p
->
base
.
param
[
0
].
nType
=
TSDB_DATA_TYPE_INT
;
p
->
base
.
param
[
0
].
nType
=
TSDB_DATA_TYPE_INT
;
...
@@ -2660,7 +2660,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
...
@@ -2660,7 +2660,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
"0x%"
PRIx64
" first round subquery:0x%"
PRIx64
" tableIndex:%d, vgroupIndex:%d, numOfVgroups:%d, type:%d, query to retrieve timestamps, "
"0x%"
PRIx64
" first round subquery:0x%"
PRIx64
" tableIndex:%d, vgroupIndex:%d, numOfVgroups:%d, type:%d, query to retrieve timestamps, "
"numOfExpr:%"
PRIzu
", colList:%d, numOfOutputFields:%d, name:%s"
,
"numOfExpr:%"
PRIzu
", colList:%d, numOfOutputFields:%d, name:%s"
,
pSql
->
self
,
pNew
->
self
,
0
,
pTableMetaInfo
->
vgroupIndex
,
pTableMetaInfo
->
vgroupList
->
numOfVgroups
,
pNewQueryInfo
->
type
,
pSql
->
self
,
pNew
->
self
,
0
,
pTableMetaInfo
->
vgroupIndex
,
pTableMetaInfo
->
vgroupList
->
numOfVgroups
,
pNewQueryInfo
->
type
,
tscNumOfExprs
(
pNewQueryInfo
),
i
nde
x
+
1
,
pNewQueryInfo
->
fieldsInfo
.
numOfOutput
,
tNameGetTableName
(
&
pTableMetaInfo
->
name
));
tscNumOfExprs
(
pNewQueryInfo
),
i
d
x
+
1
,
pNewQueryInfo
->
fieldsInfo
.
numOfOutput
,
tNameGetTableName
(
&
pTableMetaInfo
->
name
));
pSql
->
pSubs
=
calloc
(
1
,
POINTER_BYTES
);
pSql
->
pSubs
=
calloc
(
1
,
POINTER_BYTES
);
if
(
pSql
->
pSubs
==
NULL
)
{
if
(
pSql
->
pSubs
==
NULL
)
{
...
@@ -3765,19 +3765,19 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) {
...
@@ -3765,19 +3765,19 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) {
char
*
getScalarExprInputSrc
(
void
*
param
,
const
char
*
name
,
int32_t
colId
)
{
char
*
getScalarExprInputSrc
(
void
*
param
,
const
char
*
name
,
int32_t
colId
)
{
SScalarExprSupport
*
pSupport
=
(
SScalarExprSupport
*
)
param
;
SScalarExprSupport
*
pSupport
=
(
SScalarExprSupport
*
)
param
;
int32_t
i
nde
x
=
-
1
;
int32_t
i
d
x
=
-
1
;
SExprInfo
*
pExpr
=
NULL
;
SExprInfo
*
pExpr
=
NULL
;
for
(
int32_t
i
=
0
;
i
<
pSupport
->
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pSupport
->
numOfCols
;
++
i
)
{
pExpr
=
taosArrayGetP
(
pSupport
->
exprList
,
i
);
pExpr
=
taosArrayGetP
(
pSupport
->
exprList
,
i
);
if
(
strncmp
(
name
,
pExpr
->
base
.
aliasName
,
sizeof
(
pExpr
->
base
.
aliasName
)
-
1
)
==
0
)
{
if
(
strncmp
(
name
,
pExpr
->
base
.
aliasName
,
sizeof
(
pExpr
->
base
.
aliasName
)
-
1
)
==
0
)
{
i
nde
x
=
i
;
i
d
x
=
i
;
break
;
break
;
}
}
}
}
assert
(
i
ndex
>=
0
&&
inde
x
<
pSupport
->
numOfCols
);
assert
(
i
dx
>=
0
&&
id
x
<
pSupport
->
numOfCols
);
return
pSupport
->
data
[
i
nde
x
]
+
pSupport
->
offset
*
pExpr
->
base
.
resBytes
;
return
pSupport
->
data
[
i
d
x
]
+
pSupport
->
offset
*
pExpr
->
base
.
resBytes
;
}
}
TAOS_ROW
doSetResultRowData
(
SSqlObj
*
pSql
)
{
TAOS_ROW
doSetResultRowData
(
SSqlObj
*
pSql
)
{
...
@@ -3960,7 +3960,7 @@ void* createQInfoFromQueryNode(SQueryInfo* pQueryInfo, STableGroupInfo* pTableGr
...
@@ -3960,7 +3960,7 @@ void* createQInfoFromQueryNode(SQueryInfo* pQueryInfo, STableGroupInfo* pTableGr
pthread_mutex_init
(
&
pQInfo
->
lock
,
NULL
);
pthread_mutex_init
(
&
pQInfo
->
lock
,
NULL
);
tsem_init
(
&
pQInfo
->
ready
,
0
,
0
);
tsem_init
(
&
pQInfo
->
ready
,
0
,
0
);
int32_t
i
nde
x
=
0
;
int32_t
i
d
x
=
0
;
for
(
int32_t
i
=
0
;
i
<
numOfGroups
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfGroups
;
++
i
)
{
SArray
*
pa
=
taosArrayGetP
(
pQueryAttr
->
tableGroupInfo
.
pGroupList
,
i
);
SArray
*
pa
=
taosArrayGetP
(
pQueryAttr
->
tableGroupInfo
.
pGroupList
,
i
);
...
@@ -3977,7 +3977,7 @@ void* createQInfoFromQueryNode(SQueryInfo* pQueryInfo, STableGroupInfo* pTableGr
...
@@ -3977,7 +3977,7 @@ void* createQInfoFromQueryNode(SQueryInfo* pQueryInfo, STableGroupInfo* pTableGr
STableKeyInfo
*
info
=
taosArrayGet
(
pa
,
j
);
STableKeyInfo
*
info
=
taosArrayGet
(
pa
,
j
);
window
.
skey
=
info
->
lastKey
;
window
.
skey
=
info
->
lastKey
;
void
*
buf
=
(
char
*
)
pQInfo
->
pBuf
+
i
nde
x
*
sizeof
(
STableQueryInfo
);
void
*
buf
=
(
char
*
)
pQInfo
->
pBuf
+
i
d
x
*
sizeof
(
STableQueryInfo
);
STableQueryInfo
*
item
=
createTableQueryInfo
(
pQueryAttr
,
info
->
pTable
,
pQueryAttr
->
groupbyColumn
,
window
,
buf
);
STableQueryInfo
*
item
=
createTableQueryInfo
(
pQueryAttr
,
info
->
pTable
,
pQueryAttr
->
groupbyColumn
,
window
,
buf
);
if
(
item
==
NULL
)
{
if
(
item
==
NULL
)
{
goto
_cleanup
;
goto
_cleanup
;
...
@@ -3988,7 +3988,7 @@ void* createQInfoFromQueryNode(SQueryInfo* pQueryInfo, STableGroupInfo* pTableGr
...
@@ -3988,7 +3988,7 @@ void* createQInfoFromQueryNode(SQueryInfo* pQueryInfo, STableGroupInfo* pTableGr
STableId
id
=
{.
tid
=
0
,
.
uid
=
0
};
STableId
id
=
{.
tid
=
0
,
.
uid
=
0
};
taosHashPut
(
pRuntimeEnv
->
tableqinfoGroupInfo
.
map
,
&
id
.
tid
,
sizeof
(
id
.
tid
),
&
item
,
POINTER_BYTES
);
taosHashPut
(
pRuntimeEnv
->
tableqinfoGroupInfo
.
map
,
&
id
.
tid
,
sizeof
(
id
.
tid
),
&
item
,
POINTER_BYTES
);
i
nde
x
+=
1
;
i
d
x
+=
1
;
}
}
}
}
...
...
src/client/src/tscSystem.c
浏览文件 @
3e42f5f1
...
@@ -87,24 +87,24 @@ int32_t tscAcquireRpc(const char *key, const char *user, const char *secretEncry
...
@@ -87,24 +87,24 @@ int32_t tscAcquireRpc(const char *key, const char *user, const char *secretEncry
return
0
;
return
0
;
}
}
SRpcInit
rpcInit
;
SRpcInit
rpcInit
ial
;
memset
(
&
rpcInit
,
0
,
sizeof
(
rpcInit
));
memset
(
&
rpcInit
ial
,
0
,
sizeof
(
rpcInitial
));
rpcInit
.
localPort
=
0
;
rpcInit
ial
.
localPort
=
0
;
rpcInit
.
label
=
"TSC"
;
rpcInit
ial
.
label
=
"TSC"
;
rpcInit
.
numOfThreads
=
tscNumOfThreads
;
rpcInit
ial
.
numOfThreads
=
tscNumOfThreads
;
rpcInit
.
cfp
=
tscProcessMsgFromServer
;
rpcInit
ial
.
cfp
=
tscProcessMsgFromServer
;
rpcInit
.
sessions
=
tsMaxConnections
;
rpcInit
ial
.
sessions
=
tsMaxConnections
;
rpcInit
.
connType
=
TAOS_CONN_CLIENT
;
rpcInit
ial
.
connType
=
TAOS_CONN_CLIENT
;
rpcInit
.
user
=
(
char
*
)
user
;
rpcInit
ial
.
user
=
(
char
*
)
user
;
rpcInit
.
idleTime
=
tsShellActivityTimer
*
1000
;
rpcInit
ial
.
idleTime
=
tsShellActivityTimer
*
1000
;
rpcInit
.
ckey
=
"key"
;
rpcInit
ial
.
ckey
=
"key"
;
rpcInit
.
spi
=
1
;
rpcInit
ial
.
spi
=
1
;
rpcInit
.
secret
=
(
char
*
)
secretEncrypt
;
rpcInit
ial
.
secret
=
(
char
*
)
secretEncrypt
;
SRpcObj
rpcObj
;
SRpcObj
rpcObj
;
memset
(
&
rpcObj
,
0
,
sizeof
(
rpcObj
));
memset
(
&
rpcObj
,
0
,
sizeof
(
rpcObj
));
tstrncpy
(
rpcObj
.
key
,
key
,
sizeof
(
rpcObj
.
key
));
tstrncpy
(
rpcObj
.
key
,
key
,
sizeof
(
rpcObj
.
key
));
rpcObj
.
pDnodeConn
=
rpcOpen
(
&
rpcInit
);
rpcObj
.
pDnodeConn
=
rpcOpen
(
&
rpcInit
ial
);
if
(
rpcObj
.
pDnodeConn
==
NULL
)
{
if
(
rpcObj
.
pDnodeConn
==
NULL
)
{
pthread_mutex_unlock
(
&
rpcObjMutex
);
pthread_mutex_unlock
(
&
rpcObjMutex
);
tscError
(
"failed to init connection to server"
);
tscError
(
"failed to init connection to server"
);
...
...
src/client/src/tscUtil.c
浏览文件 @
3e42f5f1
...
@@ -2283,10 +2283,10 @@ void tscCloseTscObj(void *param) {
...
@@ -2283,10 +2283,10 @@ void tscCloseTscObj(void *param) {
}
}
bool
tscIsInsertData
(
char
*
sqlstr
)
{
bool
tscIsInsertData
(
char
*
sqlstr
)
{
int32_t
i
nde
x
=
0
;
int32_t
i
d
x
=
0
;
do
{
do
{
SStrToken
t0
=
tStrGetToken
(
sqlstr
,
&
i
nde
x
,
false
);
SStrToken
t0
=
tStrGetToken
(
sqlstr
,
&
i
d
x
,
false
);
if
(
t0
.
type
!=
TK_LP
)
{
if
(
t0
.
type
!=
TK_LP
)
{
return
t0
.
type
==
TK_INSERT
||
t0
.
type
==
TK_IMPORT
;
return
t0
.
type
==
TK_INSERT
||
t0
.
type
==
TK_IMPORT
;
}
}
...
@@ -2356,12 +2356,12 @@ SInternalField* tscFieldInfoAppend(SFieldInfo* pFieldInfo, TAOS_FIELD* pField) {
...
@@ -2356,12 +2356,12 @@ SInternalField* tscFieldInfoAppend(SFieldInfo* pFieldInfo, TAOS_FIELD* pField) {
return
taosArrayPush
(
pFieldInfo
->
internalField
,
&
info
);
return
taosArrayPush
(
pFieldInfo
->
internalField
,
&
info
);
}
}
SInternalField
*
tscFieldInfoInsert
(
SFieldInfo
*
pFieldInfo
,
int32_t
i
nde
x
,
TAOS_FIELD
*
field
)
{
SInternalField
*
tscFieldInfoInsert
(
SFieldInfo
*
pFieldInfo
,
int32_t
i
d
x
,
TAOS_FIELD
*
field
)
{
pFieldInfo
->
numOfOutput
++
;
pFieldInfo
->
numOfOutput
++
;
struct
SInternalField
info
=
{
.
pExpr
=
NULL
,
.
visible
=
true
};
struct
SInternalField
info
=
{
.
pExpr
=
NULL
,
.
visible
=
true
};
info
.
field
=
*
field
;
info
.
field
=
*
field
;
return
taosArrayInsert
(
pFieldInfo
->
internalField
,
i
nde
x
,
&
info
);
return
taosArrayInsert
(
pFieldInfo
->
internalField
,
i
d
x
,
&
info
);
}
}
void
tscFieldInfoUpdateOffset
(
SQueryInfo
*
pQueryInfo
)
{
void
tscFieldInfoUpdateOffset
(
SQueryInfo
*
pQueryInfo
)
{
...
@@ -2376,18 +2376,18 @@ void tscFieldInfoUpdateOffset(SQueryInfo* pQueryInfo) {
...
@@ -2376,18 +2376,18 @@ void tscFieldInfoUpdateOffset(SQueryInfo* pQueryInfo) {
}
}
}
}
SInternalField
*
tscFieldInfoGetInternalField
(
SFieldInfo
*
pFieldInfo
,
int32_t
i
nde
x
)
{
SInternalField
*
tscFieldInfoGetInternalField
(
SFieldInfo
*
pFieldInfo
,
int32_t
i
d
x
)
{
assert
(
i
nde
x
<
pFieldInfo
->
numOfOutput
);
assert
(
i
d
x
<
pFieldInfo
->
numOfOutput
);
return
TARRAY_GET_ELEM
(
pFieldInfo
->
internalField
,
i
nde
x
);
return
TARRAY_GET_ELEM
(
pFieldInfo
->
internalField
,
i
d
x
);
}
}
TAOS_FIELD
*
tscFieldInfoGetField
(
SFieldInfo
*
pFieldInfo
,
int32_t
i
nde
x
)
{
TAOS_FIELD
*
tscFieldInfoGetField
(
SFieldInfo
*
pFieldInfo
,
int32_t
i
d
x
)
{
assert
(
i
nde
x
<
pFieldInfo
->
numOfOutput
);
assert
(
i
d
x
<
pFieldInfo
->
numOfOutput
);
return
&
((
SInternalField
*
)
TARRAY_GET_ELEM
(
pFieldInfo
->
internalField
,
i
nde
x
))
->
field
;
return
&
((
SInternalField
*
)
TARRAY_GET_ELEM
(
pFieldInfo
->
internalField
,
i
d
x
))
->
field
;
}
}
int32_t
tscFieldInfoGetOffset
(
SQueryInfo
*
pQueryInfo
,
int32_t
i
nde
x
)
{
int32_t
tscFieldInfoGetOffset
(
SQueryInfo
*
pQueryInfo
,
int32_t
i
d
x
)
{
SInternalField
*
pInfo
=
tscFieldInfoGetInternalField
(
&
pQueryInfo
->
fieldsInfo
,
i
nde
x
);
SInternalField
*
pInfo
=
tscFieldInfoGetInternalField
(
&
pQueryInfo
->
fieldsInfo
,
i
d
x
);
assert
(
pInfo
!=
NULL
&&
pInfo
->
pExpr
->
pExpr
==
NULL
);
assert
(
pInfo
!=
NULL
&&
pInfo
->
pExpr
->
pExpr
==
NULL
);
return
pInfo
->
pExpr
->
base
.
offset
;
return
pInfo
->
pExpr
->
base
.
offset
;
...
@@ -2608,16 +2608,16 @@ SExprInfo* tscExprCreate(STableMetaInfo* pTableMetaInfo, int16_t functionId, SCo
...
@@ -2608,16 +2608,16 @@ SExprInfo* tscExprCreate(STableMetaInfo* pTableMetaInfo, int16_t functionId, SCo
return
pExpr
;
return
pExpr
;
}
}
SExprInfo
*
tscExprInsert
(
SQueryInfo
*
pQueryInfo
,
int32_t
i
nde
x
,
int16_t
functionId
,
SColumnIndex
*
pColIndex
,
int16_t
type
,
SExprInfo
*
tscExprInsert
(
SQueryInfo
*
pQueryInfo
,
int32_t
i
d
x
,
int16_t
functionId
,
SColumnIndex
*
pColIndex
,
int16_t
type
,
int16_t
size
,
int16_t
resColId
,
int16_t
interSize
,
bool
isTagCol
)
{
int16_t
size
,
int16_t
resColId
,
int16_t
interSize
,
bool
isTagCol
)
{
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pQueryInfo
->
exprList
);
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pQueryInfo
->
exprList
);
if
(
i
nde
x
==
num
)
{
if
(
i
d
x
==
num
)
{
return
tscExprAppend
(
pQueryInfo
,
functionId
,
pColIndex
,
type
,
size
,
resColId
,
interSize
,
isTagCol
);
return
tscExprAppend
(
pQueryInfo
,
functionId
,
pColIndex
,
type
,
size
,
resColId
,
interSize
,
isTagCol
);
}
}
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
pColIndex
->
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
pColIndex
->
tableIndex
);
SExprInfo
*
pExpr
=
tscExprCreate
(
pTableMetaInfo
,
functionId
,
pColIndex
,
type
,
size
,
resColId
,
interSize
,
isTagCol
);
SExprInfo
*
pExpr
=
tscExprCreate
(
pTableMetaInfo
,
functionId
,
pColIndex
,
type
,
size
,
resColId
,
interSize
,
isTagCol
);
taosArrayInsert
(
pQueryInfo
->
exprList
,
i
nde
x
,
&
pExpr
);
taosArrayInsert
(
pQueryInfo
->
exprList
,
i
d
x
,
&
pExpr
);
return
pExpr
;
return
pExpr
;
}
}
...
@@ -2629,10 +2629,10 @@ SExprInfo* tscExprAppend(SQueryInfo* pQueryInfo, int16_t functionId, SColumnInde
...
@@ -2629,10 +2629,10 @@ SExprInfo* tscExprAppend(SQueryInfo* pQueryInfo, int16_t functionId, SColumnInde
return
pExpr
;
return
pExpr
;
}
}
SExprInfo
*
tscExprUpdate
(
SQueryInfo
*
pQueryInfo
,
int32_t
i
nde
x
,
int16_t
functionId
,
int16_t
srcColumnIndex
,
SExprInfo
*
tscExprUpdate
(
SQueryInfo
*
pQueryInfo
,
int32_t
i
d
x
,
int16_t
functionId
,
int16_t
srcColumnIndex
,
int16_t
type
,
int16_t
size
)
{
int16_t
type
,
int16_t
size
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
i
nde
x
);
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
i
d
x
);
if
(
pExpr
==
NULL
)
{
if
(
pExpr
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -2649,8 +2649,8 @@ SExprInfo* tscExprUpdate(SQueryInfo* pQueryInfo, int32_t index, int16_t function
...
@@ -2649,8 +2649,8 @@ SExprInfo* tscExprUpdate(SQueryInfo* pQueryInfo, int32_t index, int16_t function
return
pExpr
;
return
pExpr
;
}
}
bool
tscMultiRoundQuery
(
SQueryInfo
*
pQueryInfo
,
int32_t
i
nde
x
)
{
bool
tscMultiRoundQuery
(
SQueryInfo
*
pQueryInfo
,
int32_t
i
d
x
)
{
if
(
!
UTIL_TABLE_IS_SUPER_TABLE
(
pQueryInfo
->
pTableMetaInfo
[
i
nde
x
]))
{
if
(
!
UTIL_TABLE_IS_SUPER_TABLE
(
pQueryInfo
->
pTableMetaInfo
[
i
d
x
]))
{
return
false
;
return
false
;
}
}
...
@@ -2694,8 +2694,8 @@ void tscExprAddParams(SSqlExpr* pExpr, char* argument, int32_t type, int32_t byt
...
@@ -2694,8 +2694,8 @@ void tscExprAddParams(SSqlExpr* pExpr, char* argument, int32_t type, int32_t byt
assert
(
pExpr
->
numOfParams
<=
3
);
assert
(
pExpr
->
numOfParams
<=
3
);
}
}
SExprInfo
*
tscExprGet
(
SQueryInfo
*
pQueryInfo
,
int32_t
i
nde
x
)
{
SExprInfo
*
tscExprGet
(
SQueryInfo
*
pQueryInfo
,
int32_t
i
d
x
)
{
return
taosArrayGetP
(
pQueryInfo
->
exprList
,
i
nde
x
);
return
taosArrayGetP
(
pQueryInfo
->
exprList
,
i
d
x
);
}
}
/*
/*
...
@@ -3263,8 +3263,8 @@ void tscGetSrcColumnInfo(SSrcColumnInfo* pColInfo, SQueryInfo* pQueryInfo) {
...
@@ -3263,8 +3263,8 @@ void tscGetSrcColumnInfo(SSrcColumnInfo* pColInfo, SQueryInfo* pQueryInfo) {
if
(
TSDB_COL_IS_TAG
(
pExpr
->
base
.
colInfo
.
flag
))
{
if
(
TSDB_COL_IS_TAG
(
pExpr
->
base
.
colInfo
.
flag
))
{
SSchema
*
pTagSchema
=
tscGetTableTagSchema
(
pTableMetaInfo
->
pTableMeta
);
SSchema
*
pTagSchema
=
tscGetTableTagSchema
(
pTableMetaInfo
->
pTableMeta
);
int16_t
i
nde
x
=
pExpr
->
base
.
colInfo
.
colIndex
;
int16_t
i
d
x
=
pExpr
->
base
.
colInfo
.
colIndex
;
pColInfo
[
i
].
type
=
(
i
ndex
!=
-
1
)
?
pTagSchema
[
inde
x
].
type
:
TSDB_DATA_TYPE_BINARY
;
pColInfo
[
i
].
type
=
(
i
dx
!=
-
1
)
?
pTagSchema
[
id
x
].
type
:
TSDB_DATA_TYPE_BINARY
;
}
else
{
}
else
{
pColInfo
[
i
].
type
=
pSchema
[
pExpr
->
base
.
colInfo
.
colIndex
].
type
;
pColInfo
[
i
].
type
=
pSchema
[
pExpr
->
base
.
colInfo
.
colIndex
].
type
;
}
}
...
@@ -3344,7 +3344,7 @@ SQueryInfo* tscGetQueryInfoS(SSqlCmd* pCmd) {
...
@@ -3344,7 +3344,7 @@ SQueryInfo* tscGetQueryInfoS(SSqlCmd* pCmd) {
return
pQueryInfo
;
return
pQueryInfo
;
}
}
STableMetaInfo
*
tscGetTableMetaInfoByUid
(
SQueryInfo
*
pQueryInfo
,
uint64_t
uid
,
int32_t
*
i
nde
x
)
{
STableMetaInfo
*
tscGetTableMetaInfoByUid
(
SQueryInfo
*
pQueryInfo
,
uint64_t
uid
,
int32_t
*
i
d
x
)
{
int32_t
k
=
-
1
;
int32_t
k
=
-
1
;
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
...
@@ -3354,8 +3354,8 @@ STableMetaInfo* tscGetTableMetaInfoByUid(SQueryInfo* pQueryInfo, uint64_t uid, i
...
@@ -3354,8 +3354,8 @@ STableMetaInfo* tscGetTableMetaInfoByUid(SQueryInfo* pQueryInfo, uint64_t uid, i
}
}
}
}
if
(
i
nde
x
!=
NULL
)
{
if
(
i
d
x
!=
NULL
)
{
*
i
nde
x
=
k
;
*
i
d
x
=
k
;
}
}
assert
(
k
!=
-
1
);
assert
(
k
!=
-
1
);
...
@@ -3578,19 +3578,19 @@ void tscFreeVgroupTableInfo(SArray* pVgroupTables) {
...
@@ -3578,19 +3578,19 @@ void tscFreeVgroupTableInfo(SArray* pVgroupTables) {
taosArrayDestroy
(
&
pVgroupTables
);
taosArrayDestroy
(
&
pVgroupTables
);
}
}
void
tscRemoveVgroupTableGroup
(
SArray
*
pVgroupTable
,
int32_t
i
nde
x
)
{
void
tscRemoveVgroupTableGroup
(
SArray
*
pVgroupTable
,
int32_t
i
d
x
)
{
assert
(
pVgroupTable
!=
NULL
&&
i
nde
x
>=
0
);
assert
(
pVgroupTable
!=
NULL
&&
i
d
x
>=
0
);
size_t
size
=
taosArrayGetSize
(
pVgroupTable
);
size_t
size
=
taosArrayGetSize
(
pVgroupTable
);
assert
(
size
>
i
nde
x
);
assert
(
size
>
i
d
x
);
SVgroupTableInfo
*
pInfo
=
taosArrayGet
(
pVgroupTable
,
i
nde
x
);
SVgroupTableInfo
*
pInfo
=
taosArrayGet
(
pVgroupTable
,
i
d
x
);
// for(int32_t j = 0; j < pInfo->vgInfo.numOfEps; ++j) {
// for(int32_t j = 0; j < pInfo->vgInfo.numOfEps; ++j) {
// tfree(pInfo->vgInfo.epAddr[j].fqdn);
// tfree(pInfo->vgInfo.epAddr[j].fqdn);
// }
// }
taosArrayDestroy
(
&
pInfo
->
itemList
);
taosArrayDestroy
(
&
pInfo
->
itemList
);
taosArrayRemove
(
pVgroupTable
,
i
nde
x
);
taosArrayRemove
(
pVgroupTable
,
i
d
x
);
}
}
void
tscVgroupTableCopy
(
SVgroupTableInfo
*
info
,
SVgroupTableInfo
*
pInfo
)
{
void
tscVgroupTableCopy
(
SVgroupTableInfo
*
info
,
SVgroupTableInfo
*
pInfo
)
{
...
@@ -4065,15 +4065,15 @@ static void tscSubqueryRetrieveCallback(void* param, TAOS_RES* tres, int code) {
...
@@ -4065,15 +4065,15 @@ static void tscSubqueryRetrieveCallback(void* param, TAOS_RES* tres, int code) {
SSqlObj
*
pParentSql
=
ps
->
pParentSql
;
SSqlObj
*
pParentSql
=
ps
->
pParentSql
;
SSqlObj
*
pSql
=
tres
;
SSqlObj
*
pSql
=
tres
;
int32_t
i
nde
x
=
ps
->
subqueryIndex
;
int32_t
i
d
x
=
ps
->
subqueryIndex
;
bool
ret
=
subAndCheckDone
(
pSql
,
pParentSql
,
i
nde
x
);
bool
ret
=
subAndCheckDone
(
pSql
,
pParentSql
,
i
d
x
);
// TODO refactor
// TODO refactor
tfree
(
ps
);
tfree
(
ps
);
pSql
->
param
=
NULL
;
pSql
->
param
=
NULL
;
if
(
!
ret
)
{
if
(
!
ret
)
{
tscDebug
(
"0x%"
PRIx64
" sub:0x%"
PRIx64
" orderOfSub:%d completed, not all subquery finished"
,
pParentSql
->
self
,
pSql
->
self
,
i
nde
x
);
tscDebug
(
"0x%"
PRIx64
" sub:0x%"
PRIx64
" orderOfSub:%d completed, not all subquery finished"
,
pParentSql
->
self
,
pSql
->
self
,
i
d
x
);
return
;
return
;
}
}
...
@@ -4094,13 +4094,13 @@ static void tscSubqueryCompleteCallback(void* param, TAOS_RES* tres, int code) {
...
@@ -4094,13 +4094,13 @@ static void tscSubqueryCompleteCallback(void* param, TAOS_RES* tres, int code) {
if
(
pSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
pSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
)
{
SSqlObj
*
pParentSql
=
ps
->
pParentSql
;
SSqlObj
*
pParentSql
=
ps
->
pParentSql
;
int32_t
i
nde
x
=
ps
->
subqueryIndex
;
int32_t
i
d
x
=
ps
->
subqueryIndex
;
bool
ret
=
subAndCheckDone
(
pSql
,
pParentSql
,
i
nde
x
);
bool
ret
=
subAndCheckDone
(
pSql
,
pParentSql
,
i
d
x
);
tscFreeRetrieveSup
(
&
pSql
->
param
);
tscFreeRetrieveSup
(
&
pSql
->
param
);
if
(
!
ret
)
{
if
(
!
ret
)
{
tscDebug
(
"0x%"
PRIx64
" sub:0x%"
PRIx64
" orderOfSub:%d completed, not all subquery finished"
,
pParentSql
->
self
,
pSql
->
self
,
i
nde
x
);
tscDebug
(
"0x%"
PRIx64
" sub:0x%"
PRIx64
" orderOfSub:%d completed, not all subquery finished"
,
pParentSql
->
self
,
pSql
->
self
,
i
d
x
);
return
;
return
;
}
}
...
...
src/common/src/tarithoperator.c
浏览文件 @
3e42f5f1
...
@@ -60,37 +60,37 @@ void calc_i32_i32_add(void *left, void *right, int32_t numLeft, int32_t numRight
...
@@ -60,37 +60,37 @@ void calc_i32_i32_add(void *left, void *right, int32_t numLeft, int32_t numRight
}
}
}
}
typedef
double
(
*
_arithmetic_getVectorDoubleValue_fn_t
)(
void
*
src
,
int32_t
i
nde
x
);
typedef
double
(
*
_arithmetic_getVectorDoubleValue_fn_t
)(
void
*
src
,
int32_t
i
d
x
);
double
getVectorDoubleValue_TINYINT
(
void
*
src
,
int32_t
i
nde
x
)
{
double
getVectorDoubleValue_TINYINT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
double
)
*
((
int8_t
*
)
src
+
i
nde
x
);
return
(
double
)
*
((
int8_t
*
)
src
+
i
d
x
);
}
}
double
getVectorDoubleValue_UTINYINT
(
void
*
src
,
int32_t
i
nde
x
)
{
double
getVectorDoubleValue_UTINYINT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
double
)
*
((
uint8_t
*
)
src
+
i
nde
x
);
return
(
double
)
*
((
uint8_t
*
)
src
+
i
d
x
);
}
}
double
getVectorDoubleValue_SMALLINT
(
void
*
src
,
int32_t
i
nde
x
)
{
double
getVectorDoubleValue_SMALLINT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
double
)
*
((
int16_t
*
)
src
+
i
nde
x
);
return
(
double
)
*
((
int16_t
*
)
src
+
i
d
x
);
}
}
double
getVectorDoubleValue_USMALLINT
(
void
*
src
,
int32_t
i
nde
x
)
{
double
getVectorDoubleValue_USMALLINT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
double
)
*
((
uint16_t
*
)
src
+
i
nde
x
);
return
(
double
)
*
((
uint16_t
*
)
src
+
i
d
x
);
}
}
double
getVectorDoubleValue_INT
(
void
*
src
,
int32_t
i
nde
x
)
{
double
getVectorDoubleValue_INT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
double
)
*
((
int32_t
*
)
src
+
i
nde
x
);
return
(
double
)
*
((
int32_t
*
)
src
+
i
d
x
);
}
}
double
getVectorDoubleValue_UINT
(
void
*
src
,
int32_t
i
nde
x
)
{
double
getVectorDoubleValue_UINT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
double
)
*
((
uint32_t
*
)
src
+
i
nde
x
);
return
(
double
)
*
((
uint32_t
*
)
src
+
i
d
x
);
}
}
double
getVectorDoubleValue_BIGINT
(
void
*
src
,
int32_t
i
nde
x
)
{
double
getVectorDoubleValue_BIGINT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
double
)
*
((
int64_t
*
)
src
+
i
nde
x
);
return
(
double
)
*
((
int64_t
*
)
src
+
i
d
x
);
}
}
double
getVectorDoubleValue_UBIGINT
(
void
*
src
,
int32_t
i
nde
x
)
{
double
getVectorDoubleValue_UBIGINT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
double
)
*
((
uint64_t
*
)
src
+
i
nde
x
);
return
(
double
)
*
((
uint64_t
*
)
src
+
i
d
x
);
}
}
double
getVectorDoubleValue_FLOAT
(
void
*
src
,
int32_t
i
nde
x
)
{
double
getVectorDoubleValue_FLOAT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
double
)
*
((
float
*
)
src
+
i
nde
x
);
return
(
double
)
*
((
float
*
)
src
+
i
d
x
);
}
}
double
getVectorDoubleValue_DOUBLE
(
void
*
src
,
int32_t
i
nde
x
)
{
double
getVectorDoubleValue_DOUBLE
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
double
)
*
((
double
*
)
src
+
i
nde
x
);
return
(
double
)
*
((
double
*
)
src
+
i
d
x
);
}
}
_arithmetic_getVectorDoubleValue_fn_t
getVectorDoubleValueFn
(
int32_t
srcType
)
{
_arithmetic_getVectorDoubleValue_fn_t
getVectorDoubleValueFn
(
int32_t
srcType
)
{
_arithmetic_getVectorDoubleValue_fn_t
p
=
NULL
;
_arithmetic_getVectorDoubleValue_fn_t
p
=
NULL
;
...
@@ -121,40 +121,40 @@ _arithmetic_getVectorDoubleValue_fn_t getVectorDoubleValueFn(int32_t srcType) {
...
@@ -121,40 +121,40 @@ _arithmetic_getVectorDoubleValue_fn_t getVectorDoubleValueFn(int32_t srcType) {
}
}
typedef
void
*
(
*
_arithmetic_getVectorValueAddr_fn_t
)(
void
*
src
,
int32_t
i
nde
x
);
typedef
void
*
(
*
_arithmetic_getVectorValueAddr_fn_t
)(
void
*
src
,
int32_t
i
d
x
);
void
*
getVectorValueAddr_BOOL
(
void
*
src
,
int32_t
i
nde
x
)
{
void
*
getVectorValueAddr_BOOL
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
void
*
)((
bool
*
)
src
+
i
nde
x
);
return
(
void
*
)((
bool
*
)
src
+
i
d
x
);
}
}
void
*
getVectorValueAddr_TINYINT
(
void
*
src
,
int32_t
i
nde
x
)
{
void
*
getVectorValueAddr_TINYINT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
void
*
)((
int8_t
*
)
src
+
i
nde
x
);
return
(
void
*
)((
int8_t
*
)
src
+
i
d
x
);
}
}
void
*
getVectorValueAddr_UTINYINT
(
void
*
src
,
int32_t
i
nde
x
)
{
void
*
getVectorValueAddr_UTINYINT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
void
*
)((
uint8_t
*
)
src
+
i
nde
x
);
return
(
void
*
)((
uint8_t
*
)
src
+
i
d
x
);
}
}
void
*
getVectorValueAddr_SMALLINT
(
void
*
src
,
int32_t
i
nde
x
)
{
void
*
getVectorValueAddr_SMALLINT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
void
*
)((
int16_t
*
)
src
+
i
nde
x
);
return
(
void
*
)((
int16_t
*
)
src
+
i
d
x
);
}
}
void
*
getVectorValueAddr_USMALLINT
(
void
*
src
,
int32_t
i
nde
x
)
{
void
*
getVectorValueAddr_USMALLINT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
void
*
)((
uint16_t
*
)
src
+
i
nde
x
);
return
(
void
*
)((
uint16_t
*
)
src
+
i
d
x
);
}
}
void
*
getVectorValueAddr_INT
(
void
*
src
,
int32_t
i
nde
x
)
{
void
*
getVectorValueAddr_INT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
void
*
)((
int32_t
*
)
src
+
i
nde
x
);
return
(
void
*
)((
int32_t
*
)
src
+
i
d
x
);
}
}
void
*
getVectorValueAddr_UINT
(
void
*
src
,
int32_t
i
nde
x
)
{
void
*
getVectorValueAddr_UINT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
void
*
)((
uint32_t
*
)
src
+
i
nde
x
);
return
(
void
*
)((
uint32_t
*
)
src
+
i
d
x
);
}
}
void
*
getVectorValueAddr_BIGINT
(
void
*
src
,
int32_t
i
nde
x
)
{
void
*
getVectorValueAddr_BIGINT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
void
*
)((
int64_t
*
)
src
+
i
nde
x
);
return
(
void
*
)((
int64_t
*
)
src
+
i
d
x
);
}
}
void
*
getVectorValueAddr_UBIGINT
(
void
*
src
,
int32_t
i
nde
x
)
{
void
*
getVectorValueAddr_UBIGINT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
void
*
)((
uint64_t
*
)
src
+
i
nde
x
);
return
(
void
*
)((
uint64_t
*
)
src
+
i
d
x
);
}
}
void
*
getVectorValueAddr_FLOAT
(
void
*
src
,
int32_t
i
nde
x
)
{
void
*
getVectorValueAddr_FLOAT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
void
*
)((
float
*
)
src
+
i
nde
x
);
return
(
void
*
)((
float
*
)
src
+
i
d
x
);
}
}
void
*
getVectorValueAddr_DOUBLE
(
void
*
src
,
int32_t
i
nde
x
)
{
void
*
getVectorValueAddr_DOUBLE
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
void
*
)((
double
*
)
src
+
i
nde
x
);
return
(
void
*
)((
double
*
)
src
+
i
d
x
);
}
}
_arithmetic_getVectorValueAddr_fn_t
getVectorValueAddrFn
(
int32_t
srcType
)
{
_arithmetic_getVectorValueAddr_fn_t
getVectorValueAddrFn
(
int32_t
srcType
)
{
...
@@ -403,34 +403,34 @@ void vectorRemainder(void *left, int32_t len1, int32_t _left_type, void *right,
...
@@ -403,34 +403,34 @@ void vectorRemainder(void *left, int32_t len1, int32_t _left_type, void *right,
}
}
}
}
typedef
int64_t
(
*
_arithmetic_getVectorBigintValue_fn_t
)(
void
*
src
,
int32_t
i
nde
x
);
typedef
int64_t
(
*
_arithmetic_getVectorBigintValue_fn_t
)(
void
*
src
,
int32_t
i
d
x
);
int64_t
getVectorBigintValue_BOOL
(
void
*
src
,
int32_t
i
nde
x
)
{
int64_t
getVectorBigintValue_BOOL
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
int64_t
)
*
((
bool
*
)
src
+
i
nde
x
);
return
(
int64_t
)
*
((
bool
*
)
src
+
i
d
x
);
}
}
int64_t
getVectorBigintValue_TINYINT
(
void
*
src
,
int32_t
i
nde
x
)
{
int64_t
getVectorBigintValue_TINYINT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
int64_t
)
*
((
int8_t
*
)
src
+
i
nde
x
);
return
(
int64_t
)
*
((
int8_t
*
)
src
+
i
d
x
);
}
}
int64_t
getVectorBigintValue_UTINYINT
(
void
*
src
,
int32_t
i
nde
x
)
{
int64_t
getVectorBigintValue_UTINYINT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
int64_t
)
*
((
uint8_t
*
)
src
+
i
nde
x
);
return
(
int64_t
)
*
((
uint8_t
*
)
src
+
i
d
x
);
}
}
int64_t
getVectorBigintValue_SMALLINT
(
void
*
src
,
int32_t
i
nde
x
)
{
int64_t
getVectorBigintValue_SMALLINT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
int64_t
)
*
((
int16_t
*
)
src
+
i
nde
x
);
return
(
int64_t
)
*
((
int16_t
*
)
src
+
i
d
x
);
}
}
int64_t
getVectorBigintValue_USMALLINT
(
void
*
src
,
int32_t
i
nde
x
)
{
int64_t
getVectorBigintValue_USMALLINT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
int64_t
)
*
((
uint16_t
*
)
src
+
i
nde
x
);
return
(
int64_t
)
*
((
uint16_t
*
)
src
+
i
d
x
);
}
}
int64_t
getVectorBigintValue_INT
(
void
*
src
,
int32_t
i
nde
x
)
{
int64_t
getVectorBigintValue_INT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
int64_t
)
*
((
int32_t
*
)
src
+
i
nde
x
);
return
(
int64_t
)
*
((
int32_t
*
)
src
+
i
d
x
);
}
}
int64_t
getVectorBigintValue_UINT
(
void
*
src
,
int32_t
i
nde
x
)
{
int64_t
getVectorBigintValue_UINT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
int64_t
)
*
((
uint32_t
*
)
src
+
i
nde
x
);
return
(
int64_t
)
*
((
uint32_t
*
)
src
+
i
d
x
);
}
}
int64_t
getVectorBigintValue_BIGINT
(
void
*
src
,
int32_t
i
nde
x
)
{
int64_t
getVectorBigintValue_BIGINT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
int64_t
)
*
((
int64_t
*
)
src
+
i
nde
x
);
return
(
int64_t
)
*
((
int64_t
*
)
src
+
i
d
x
);
}
}
int64_t
getVectorBigintValue_UBIGINT
(
void
*
src
,
int32_t
i
nde
x
)
{
int64_t
getVectorBigintValue_UBIGINT
(
void
*
src
,
int32_t
i
d
x
)
{
return
(
int64_t
)
*
((
uint64_t
*
)
src
+
i
nde
x
);
return
(
int64_t
)
*
((
uint64_t
*
)
src
+
i
d
x
);
}
}
_arithmetic_getVectorBigintValue_fn_t
getVectorBigintValueFn
(
int32_t
srcType
)
{
_arithmetic_getVectorBigintValue_fn_t
getVectorBigintValueFn
(
int32_t
srcType
)
{
...
...
src/common/src/tdataformat.c
浏览文件 @
3e42f5f1
...
@@ -304,14 +304,14 @@ bool isNEleNull(SDataCol *pCol, int nEle) {
...
@@ -304,14 +304,14 @@ bool isNEleNull(SDataCol *pCol, int nEle) {
return
true
;
return
true
;
}
}
static
FORCE_INLINE
void
dataColSetNullAt
(
SDataCol
*
pCol
,
int
i
nde
x
)
{
static
FORCE_INLINE
void
dataColSetNullAt
(
SDataCol
*
pCol
,
int
i
d
x
)
{
if
(
IS_VAR_DATA_TYPE
(
pCol
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pCol
->
type
))
{
pCol
->
dataOff
[
i
nde
x
]
=
pCol
->
len
;
pCol
->
dataOff
[
i
d
x
]
=
pCol
->
len
;
char
*
ptr
=
POINTER_SHIFT
(
pCol
->
pData
,
pCol
->
len
);
char
*
ptr
=
POINTER_SHIFT
(
pCol
->
pData
,
pCol
->
len
);
setVardataNull
(
ptr
,
pCol
->
type
);
setVardataNull
(
ptr
,
pCol
->
type
);
pCol
->
len
+=
varDataTLen
(
ptr
);
pCol
->
len
+=
varDataTLen
(
ptr
);
}
else
{
}
else
{
setNull
(
POINTER_SHIFT
(
pCol
->
pData
,
TYPE_BYTES
[
pCol
->
type
]
*
i
nde
x
),
pCol
->
type
,
pCol
->
bytes
);
setNull
(
POINTER_SHIFT
(
pCol
->
pData
,
TYPE_BYTES
[
pCol
->
type
]
*
i
d
x
),
pCol
->
type
,
pCol
->
bytes
);
pCol
->
len
+=
TYPE_BYTES
[
pCol
->
type
];
pCol
->
len
+=
TYPE_BYTES
[
pCol
->
type
];
}
}
}
}
...
...
src/common/src/tglobal.c
浏览文件 @
3e42f5f1
...
@@ -407,10 +407,10 @@ bool taosCfgDynamicOptions(char *msg) {
...
@@ -407,10 +407,10 @@ bool taosCfgDynamicOptions(char *msg) {
return
false
;
return
false
;
}
}
void
taosAddDataDir
(
int
i
nde
x
,
char
*
v1
,
int
level
,
int
primary
)
{
void
taosAddDataDir
(
int
i
d
x
,
char
*
v1
,
int
level
,
int
primary
)
{
tstrncpy
(
tsDiskCfg
[
i
nde
x
].
dir
,
v1
,
TSDB_FILENAME_LEN
);
tstrncpy
(
tsDiskCfg
[
i
d
x
].
dir
,
v1
,
TSDB_FILENAME_LEN
);
tsDiskCfg
[
i
nde
x
].
level
=
level
;
tsDiskCfg
[
i
d
x
].
level
=
level
;
tsDiskCfg
[
i
nde
x
].
primary
=
primary
;
tsDiskCfg
[
i
d
x
].
primary
=
primary
;
uTrace
(
"dataDir:%s, level:%d primary:%d is configured"
,
v1
,
level
,
primary
);
uTrace
(
"dataDir:%s, level:%d primary:%d is configured"
,
v1
,
level
,
primary
);
}
}
...
...
src/common/src/tname.c
浏览文件 @
3e42f5f1
...
@@ -407,29 +407,29 @@ void tNameAssign(SName* dst, const SName* src) {
...
@@ -407,29 +407,29 @@ void tNameAssign(SName* dst, const SName* src) {
memcpy
(
dst
,
src
,
sizeof
(
SName
));
memcpy
(
dst
,
src
,
sizeof
(
SName
));
}
}
int32_t
tNameSetDbName
(
SName
*
dst
,
const
char
*
acct
,
SStrToken
*
dbToken
)
{
int32_t
tNameSetDbName
(
SName
*
dst
,
const
char
*
acc
n
t
,
SStrToken
*
dbToken
)
{
assert
(
dst
!=
NULL
&&
dbToken
!=
NULL
&&
acct
!=
NULL
);
assert
(
dst
!=
NULL
&&
dbToken
!=
NULL
&&
acc
n
t
!=
NULL
);
// too long account id or too long db name
// too long account id or too long db name
if
(
strlen
(
acct
)
>=
tListLen
(
dst
->
acctId
)
||
dbToken
->
n
>=
tListLen
(
dst
->
dbname
))
{
if
(
strlen
(
acc
n
t
)
>=
tListLen
(
dst
->
acctId
)
||
dbToken
->
n
>=
tListLen
(
dst
->
dbname
))
{
return
-
1
;
return
-
1
;
}
}
dst
->
type
=
TSDB_DB_NAME_T
;
dst
->
type
=
TSDB_DB_NAME_T
;
tstrncpy
(
dst
->
acctId
,
acct
,
tListLen
(
dst
->
acctId
));
tstrncpy
(
dst
->
acctId
,
acc
n
t
,
tListLen
(
dst
->
acctId
));
tstrncpy
(
dst
->
dbname
,
dbToken
->
z
,
dbToken
->
n
+
1
);
tstrncpy
(
dst
->
dbname
,
dbToken
->
z
,
dbToken
->
n
+
1
);
return
0
;
return
0
;
}
}
int32_t
tNameSetAcctId
(
SName
*
dst
,
const
char
*
acct
)
{
int32_t
tNameSetAcctId
(
SName
*
dst
,
const
char
*
acc
n
t
)
{
assert
(
dst
!=
NULL
&&
acct
!=
NULL
);
assert
(
dst
!=
NULL
&&
acc
n
t
!=
NULL
);
// too long account id or too long db name
// too long account id or too long db name
if
(
strlen
(
acct
)
>=
tListLen
(
dst
->
acctId
))
{
if
(
strlen
(
acc
n
t
)
>=
tListLen
(
dst
->
acctId
))
{
return
-
1
;
return
-
1
;
}
}
tstrncpy
(
dst
->
acctId
,
acct
,
tListLen
(
dst
->
acctId
));
tstrncpy
(
dst
->
acctId
,
acc
n
t
,
tListLen
(
dst
->
acctId
));
assert
(
strlen
(
dst
->
acctId
)
>
0
);
assert
(
strlen
(
dst
->
acctId
)
>
0
);
...
...
src/common/src/ttypes.c
浏览文件 @
3e42f5f1
...
@@ -259,8 +259,8 @@ static void getStatics_u64(const void *pData, int32_t numOfRow, int64_t *min, in
...
@@ -259,8 +259,8 @@ static void getStatics_u64(const void *pData, int32_t numOfRow, int64_t *min, in
static
void
getStatics_f
(
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
static
void
getStatics_f
(
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int64_t
*
sum
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
float
*
data
=
(
float
*
)
pData
;
float
*
data
=
(
float
*
)
pData
;
float
fmin
=
FLT_MAX
;
float
f
l
min
=
FLT_MAX
;
float
fmax
=
-
FLT_MAX
;
float
f
l
max
=
-
FLT_MAX
;
double
dsum
=
0
;
double
dsum
=
0
;
*
minIndex
=
0
;
*
minIndex
=
0
;
*
maxIndex
=
0
;
*
maxIndex
=
0
;
...
@@ -276,20 +276,20 @@ static void getStatics_f(const void *pData, int32_t numOfRow, int64_t *min, int6
...
@@ -276,20 +276,20 @@ static void getStatics_f(const void *pData, int32_t numOfRow, int64_t *min, int6
float
fv
=
GET_FLOAT_VAL
((
const
char
*
)
&
(
data
[
i
]));
float
fv
=
GET_FLOAT_VAL
((
const
char
*
)
&
(
data
[
i
]));
dsum
+=
fv
;
dsum
+=
fv
;
if
(
fmin
>
fv
)
{
if
(
f
l
min
>
fv
)
{
fmin
=
fv
;
f
l
min
=
fv
;
*
minIndex
=
i
;
*
minIndex
=
i
;
}
}
if
(
fmax
<
fv
)
{
if
(
f
l
max
<
fv
)
{
fmax
=
fv
;
f
l
max
=
fv
;
*
maxIndex
=
i
;
*
maxIndex
=
i
;
}
}
}
}
SET_DOUBLE_VAL
(
sum
,
dsum
);
SET_DOUBLE_VAL
(
sum
,
dsum
);
SET_DOUBLE_VAL
(
max
,
fmax
);
SET_DOUBLE_VAL
(
max
,
f
l
max
);
SET_DOUBLE_VAL
(
min
,
fmin
);
SET_DOUBLE_VAL
(
min
,
f
l
min
);
}
}
static
void
getStatics_d
(
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
static
void
getStatics_d
(
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
...
...
src/dnode/src/dnodeCheck.c
浏览文件 @
3e42f5f1
...
@@ -229,12 +229,12 @@ static void dnodeAllocCheckItem() {
...
@@ -229,12 +229,12 @@ static void dnodeAllocCheckItem() {
}
}
void
dnodeCleanupCheck
()
{
void
dnodeCleanupCheck
()
{
for
(
ECheckItemType
i
ndex
=
0
;
index
<
TSDB_CHECK_ITEM_MAX
;
++
inde
x
)
{
for
(
ECheckItemType
i
dx
=
0
;
idx
<
TSDB_CHECK_ITEM_MAX
;
++
id
x
)
{
if
(
tsCheckItem
[
i
ndex
].
enable
&&
tsCheckItem
[
inde
x
].
stopFp
)
{
if
(
tsCheckItem
[
i
dx
].
enable
&&
tsCheckItem
[
id
x
].
stopFp
)
{
(
*
tsCheckItem
[
i
nde
x
].
stopFp
)();
(
*
tsCheckItem
[
i
d
x
].
stopFp
)();
}
}
if
(
tsCheckItem
[
i
nde
x
].
cleanUpFp
)
{
if
(
tsCheckItem
[
i
d
x
].
cleanUpFp
)
{
(
*
tsCheckItem
[
i
nde
x
].
cleanUpFp
)();
(
*
tsCheckItem
[
i
d
x
].
cleanUpFp
)();
}
}
}
}
}
}
...
@@ -242,19 +242,19 @@ void dnodeCleanupCheck() {
...
@@ -242,19 +242,19 @@ void dnodeCleanupCheck() {
int32_t
dnodeInitCheck
()
{
int32_t
dnodeInitCheck
()
{
dnodeAllocCheckItem
();
dnodeAllocCheckItem
();
for
(
ECheckItemType
i
ndex
=
0
;
index
<
TSDB_CHECK_ITEM_MAX
;
++
inde
x
)
{
for
(
ECheckItemType
i
dx
=
0
;
idx
<
TSDB_CHECK_ITEM_MAX
;
++
id
x
)
{
if
(
tsCheckItem
[
i
nde
x
].
initFp
)
{
if
(
tsCheckItem
[
i
d
x
].
initFp
)
{
if
((
*
tsCheckItem
[
i
nde
x
].
initFp
)()
!=
0
)
{
if
((
*
tsCheckItem
[
i
d
x
].
initFp
)()
!=
0
)
{
dError
(
"failed to init check item:%s"
,
tsCheckItem
[
i
nde
x
].
name
);
dError
(
"failed to init check item:%s"
,
tsCheckItem
[
i
d
x
].
name
);
return
-
1
;
return
-
1
;
}
}
}
}
}
}
for
(
ECheckItemType
i
ndex
=
0
;
index
<
TSDB_CHECK_ITEM_MAX
;
++
inde
x
)
{
for
(
ECheckItemType
i
dx
=
0
;
idx
<
TSDB_CHECK_ITEM_MAX
;
++
id
x
)
{
if
(
tsCheckItem
[
i
ndex
].
enable
&&
tsCheckItem
[
inde
x
].
startFp
)
{
if
(
tsCheckItem
[
i
dx
].
enable
&&
tsCheckItem
[
id
x
].
startFp
)
{
if
((
*
tsCheckItem
[
i
nde
x
].
startFp
)()
!=
0
)
{
if
((
*
tsCheckItem
[
i
d
x
].
startFp
)()
!=
0
)
{
dError
(
"failed to check item:%s"
,
tsCheckItem
[
i
nde
x
].
name
);
dError
(
"failed to check item:%s"
,
tsCheckItem
[
i
d
x
].
name
);
exit
(
-
1
);
exit
(
-
1
);
}
}
}
}
...
...
src/dnode/src/dnodePeer.c
浏览文件 @
3e42f5f1
...
@@ -56,17 +56,17 @@ int32_t dnodeInitServer() {
...
@@ -56,17 +56,17 @@ int32_t dnodeInitServer() {
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_DM_GRANT
]
=
dnodeDispatchToMPeerQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_DM_GRANT
]
=
dnodeDispatchToMPeerQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_DM_STATUS
]
=
dnodeDispatchToMPeerQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_DM_STATUS
]
=
dnodeDispatchToMPeerQueue
;
SRpcInit
rpcInit
;
SRpcInit
rpcInit
al
;
memset
(
&
rpcInit
,
0
,
sizeof
(
rpcInit
));
memset
(
&
rpcInit
al
,
0
,
sizeof
(
rpcInital
));
rpcInit
.
localPort
=
tsDnodeDnodePort
;
rpcInit
al
.
localPort
=
tsDnodeDnodePort
;
rpcInit
.
label
=
"DND-S"
;
rpcInit
al
.
label
=
"DND-S"
;
rpcInit
.
numOfThreads
=
1
;
rpcInit
al
.
numOfThreads
=
1
;
rpcInit
.
cfp
=
dnodeProcessReqMsgFromDnode
;
rpcInit
al
.
cfp
=
dnodeProcessReqMsgFromDnode
;
rpcInit
.
sessions
=
TSDB_MAX_VNODES
<<
4
;
rpcInit
al
.
sessions
=
TSDB_MAX_VNODES
<<
4
;
rpcInit
.
connType
=
TAOS_CONN_SERVER
;
rpcInit
al
.
connType
=
TAOS_CONN_SERVER
;
rpcInit
.
idleTime
=
tsShellActivityTimer
*
1000
;
rpcInit
al
.
idleTime
=
tsShellActivityTimer
*
1000
;
tsServerRpc
=
rpcOpen
(
&
rpcInit
);
tsServerRpc
=
rpcOpen
(
&
rpcInit
al
);
if
(
tsServerRpc
==
NULL
)
{
if
(
tsServerRpc
==
NULL
)
{
dError
(
"failed to init inter-dnodes RPC server"
);
dError
(
"failed to init inter-dnodes RPC server"
);
return
-
1
;
return
-
1
;
...
@@ -123,19 +123,19 @@ static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcEpSet *pEpSet) {
...
@@ -123,19 +123,19 @@ static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcEpSet *pEpSet) {
int32_t
dnodeInitClient
()
{
int32_t
dnodeInitClient
()
{
char
secret
[
TSDB_KEY_LEN
]
=
"secret"
;
char
secret
[
TSDB_KEY_LEN
]
=
"secret"
;
SRpcInit
rpcInit
;
SRpcInit
rpcInit
al
;
memset
(
&
rpcInit
,
0
,
sizeof
(
rpcInit
));
memset
(
&
rpcInit
al
,
0
,
sizeof
(
rpcInital
));
rpcInit
.
label
=
"DND-C"
;
rpcInit
al
.
label
=
"DND-C"
;
rpcInit
.
numOfThreads
=
1
;
rpcInit
al
.
numOfThreads
=
1
;
rpcInit
.
cfp
=
dnodeProcessRspFromDnode
;
rpcInit
al
.
cfp
=
dnodeProcessRspFromDnode
;
rpcInit
.
sessions
=
TSDB_MAX_VNODES
<<
4
;
rpcInit
al
.
sessions
=
TSDB_MAX_VNODES
<<
4
;
rpcInit
.
connType
=
TAOS_CONN_CLIENT
;
rpcInit
al
.
connType
=
TAOS_CONN_CLIENT
;
rpcInit
.
idleTime
=
tsShellActivityTimer
*
1000
;
rpcInit
al
.
idleTime
=
tsShellActivityTimer
*
1000
;
rpcInit
.
user
=
"t"
;
rpcInit
al
.
user
=
"t"
;
rpcInit
.
ckey
=
"key"
;
rpcInit
al
.
ckey
=
"key"
;
rpcInit
.
secret
=
secret
;
rpcInit
al
.
secret
=
secret
;
tsClientRpc
=
rpcOpen
(
&
rpcInit
);
tsClientRpc
=
rpcOpen
(
&
rpcInit
al
);
if
(
tsClientRpc
==
NULL
)
{
if
(
tsClientRpc
==
NULL
)
{
dError
(
"failed to init mnode rpc client"
);
dError
(
"failed to init mnode rpc client"
);
return
-
1
;
return
-
1
;
...
...
src/dnode/src/dnodeShell.c
浏览文件 @
3e42f5f1
...
@@ -83,18 +83,18 @@ int32_t dnodeInitShell() {
...
@@ -83,18 +83,18 @@ int32_t dnodeInitShell() {
numOfThreads
=
1
;
numOfThreads
=
1
;
}
}
SRpcInit
rpcInit
;
SRpcInit
rpcInit
al
;
memset
(
&
rpcInit
,
0
,
sizeof
(
rpcInit
));
memset
(
&
rpcInit
al
,
0
,
sizeof
(
rpcInital
));
rpcInit
.
localPort
=
tsDnodeShellPort
;
rpcInit
al
.
localPort
=
tsDnodeShellPort
;
rpcInit
.
label
=
"SHELL"
;
rpcInit
al
.
label
=
"SHELL"
;
rpcInit
.
numOfThreads
=
numOfThreads
;
rpcInit
al
.
numOfThreads
=
numOfThreads
;
rpcInit
.
cfp
=
dnodeProcessMsgFromShell
;
rpcInit
al
.
cfp
=
dnodeProcessMsgFromShell
;
rpcInit
.
sessions
=
tsMaxShellConns
;
rpcInit
al
.
sessions
=
tsMaxShellConns
;
rpcInit
.
connType
=
TAOS_CONN_SERVER
;
rpcInit
al
.
connType
=
TAOS_CONN_SERVER
;
rpcInit
.
idleTime
=
tsShellActivityTimer
*
1000
;
rpcInit
al
.
idleTime
=
tsShellActivityTimer
*
1000
;
rpcInit
.
afp
=
dnodeRetrieveUserAuthInfo
;
rpcInit
al
.
afp
=
dnodeRetrieveUserAuthInfo
;
tsShellRpc
=
rpcOpen
(
&
rpcInit
);
tsShellRpc
=
rpcOpen
(
&
rpcInit
al
);
if
(
tsShellRpc
==
NULL
)
{
if
(
tsShellRpc
==
NULL
)
{
dError
(
"failed to init shell rpc server"
);
dError
(
"failed to init shell rpc server"
);
return
-
1
;
return
-
1
;
...
@@ -258,10 +258,10 @@ SDnodeStatisInfo dnodeGetStatisInfo() {
...
@@ -258,10 +258,10 @@ SDnodeStatisInfo dnodeGetStatisInfo() {
return
info
;
return
info
;
}
}
int32_t
dnodeGetHttpStatusInfo
(
int32_t
i
nde
x
)
{
int32_t
dnodeGetHttpStatusInfo
(
int32_t
i
d
x
)
{
int32_t
httpStatus
=
0
;
int32_t
httpStatus
=
0
;
#ifdef HTTP_EMBEDDED
#ifdef HTTP_EMBEDDED
httpStatus
=
httpGetStatusCodeCount
(
i
nde
x
);
httpStatus
=
httpGetStatusCodeCount
(
i
d
x
);
#endif
#endif
return
httpStatus
;
return
httpStatus
;
}
}
...
...
src/kit/shell/src/shellImport.c
浏览文件 @
3e42f5f1
...
@@ -93,8 +93,8 @@ static void shellCheckTablesSQLFile(const char *directoryName)
...
@@ -93,8 +93,8 @@ static void shellCheckTablesSQLFile(const char *directoryName)
{
{
sprintf
(
shellTablesSQLFile
,
"%s/tables.sql"
,
directoryName
);
sprintf
(
shellTablesSQLFile
,
"%s/tables.sql"
,
directoryName
);
struct
stat
fstat
;
struct
stat
status
;
if
(
stat
(
shellTablesSQLFile
,
&
fstat
)
<
0
)
{
if
(
stat
(
shellTablesSQLFile
,
&
status
)
<
0
)
{
shellTablesSQLFile
[
0
]
=
0
;
shellTablesSQLFile
[
0
]
=
0
;
}
}
}
}
...
...
src/mnode/src/mnodeCluster.c
浏览文件 @
3e42f5f1
...
@@ -145,8 +145,8 @@ static int32_t mnodeCreateCluster() {
...
@@ -145,8 +145,8 @@ static int32_t mnodeCreateCluster() {
SClusterObj
*
pCluster
=
malloc
(
sizeof
(
SClusterObj
));
SClusterObj
*
pCluster
=
malloc
(
sizeof
(
SClusterObj
));
memset
(
pCluster
,
0
,
sizeof
(
SClusterObj
));
memset
(
pCluster
,
0
,
sizeof
(
SClusterObj
));
pCluster
->
createdTime
=
taosGetTimestampMs
();
pCluster
->
createdTime
=
taosGetTimestampMs
();
bool
g
etuid
=
taosGetSystemUid
(
pCluster
->
uid
);
bool
bG
etuid
=
taosGetSystemUid
(
pCluster
->
uid
);
if
(
!
g
etuid
)
{
if
(
!
bG
etuid
)
{
strcpy
(
pCluster
->
uid
,
"tdengine2.0"
);
strcpy
(
pCluster
->
uid
,
"tdengine2.0"
);
mError
(
"failed to get uid from system, set to default val %s"
,
pCluster
->
uid
);
mError
(
"failed to get uid from system, set to default val %s"
,
pCluster
->
uid
);
}
else
{
}
else
{
...
...
src/mnode/src/mnodeMnode.c
浏览文件 @
3e42f5f1
...
@@ -210,7 +210,7 @@ void mnodeUpdateMnodeEpSet(SMInfos *pMinfos) {
...
@@ -210,7 +210,7 @@ void mnodeUpdateMnodeEpSet(SMInfos *pMinfos) {
mInfos
=
*
pMinfos
;
mInfos
=
*
pMinfos
;
}
else
{
}
else
{
mInfo
(
"vgId:1, update mnodes epSet, numOfMnodes:%d"
,
mnodeGetMnodesNum
());
mInfo
(
"vgId:1, update mnodes epSet, numOfMnodes:%d"
,
mnodeGetMnodesNum
());
int32_t
i
nde
x
=
0
;
int32_t
i
d
x
=
0
;
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
while
(
1
)
{
while
(
1
)
{
SMnodeObj
*
pMnode
=
NULL
;
SMnodeObj
*
pMnode
=
NULL
;
...
@@ -220,10 +220,10 @@ void mnodeUpdateMnodeEpSet(SMInfos *pMinfos) {
...
@@ -220,10 +220,10 @@ void mnodeUpdateMnodeEpSet(SMInfos *pMinfos) {
SDnodeObj
*
pDnode
=
mnodeGetDnode
(
pMnode
->
mnodeId
);
SDnodeObj
*
pDnode
=
mnodeGetDnode
(
pMnode
->
mnodeId
);
if
(
pDnode
!=
NULL
)
{
if
(
pDnode
!=
NULL
)
{
set
=
true
;
set
=
true
;
mInfos
.
mnodeInfos
[
i
nde
x
].
mnodeId
=
pMnode
->
mnodeId
;
mInfos
.
mnodeInfos
[
i
d
x
].
mnodeId
=
pMnode
->
mnodeId
;
strcpy
(
mInfos
.
mnodeInfos
[
i
nde
x
].
mnodeEp
,
pDnode
->
dnodeEp
);
strcpy
(
mInfos
.
mnodeInfos
[
i
d
x
].
mnodeEp
,
pDnode
->
dnodeEp
);
if
(
pMnode
->
role
==
TAOS_SYNC_ROLE_MASTER
)
mInfos
.
inUse
=
i
nde
x
;
if
(
pMnode
->
role
==
TAOS_SYNC_ROLE_MASTER
)
mInfos
.
inUse
=
i
d
x
;
i
nde
x
++
;
i
d
x
++
;
}
else
{
}
else
{
set
=
false
;
set
=
false
;
}
}
...
@@ -232,7 +232,7 @@ void mnodeUpdateMnodeEpSet(SMInfos *pMinfos) {
...
@@ -232,7 +232,7 @@ void mnodeUpdateMnodeEpSet(SMInfos *pMinfos) {
mnodeDecMnodeRef
(
pMnode
);
mnodeDecMnodeRef
(
pMnode
);
}
}
mInfos
.
mnodeNum
=
i
nde
x
;
mInfos
.
mnodeNum
=
i
d
x
;
if
(
mInfos
.
mnodeNum
<
sdbGetReplicaNum
())
{
if
(
mInfos
.
mnodeNum
<
sdbGetReplicaNum
())
{
set
=
false
;
set
=
false
;
mDebug
(
"vgId:1, mnodes info not synced, current:%d syncCfgNum:%d"
,
mInfos
.
mnodeNum
,
sdbGetReplicaNum
());
mDebug
(
"vgId:1, mnodes info not synced, current:%d syncCfgNum:%d"
,
mInfos
.
mnodeNum
,
sdbGetReplicaNum
());
...
@@ -251,23 +251,23 @@ void mnodeUpdateMnodeEpSet(SMInfos *pMinfos) {
...
@@ -251,23 +251,23 @@ void mnodeUpdateMnodeEpSet(SMInfos *pMinfos) {
tsMEpForPeer
.
numOfEps
=
tsMInfos
.
mnodeNum
;
tsMEpForPeer
.
numOfEps
=
tsMInfos
.
mnodeNum
;
mInfo
(
"vgId:1, mnodes epSet is set, num:%d inUse:%d"
,
tsMInfos
.
mnodeNum
,
tsMInfos
.
inUse
);
mInfo
(
"vgId:1, mnodes epSet is set, num:%d inUse:%d"
,
tsMInfos
.
mnodeNum
,
tsMInfos
.
inUse
);
for
(
int
i
ndex
=
0
;
index
<
mInfos
.
mnodeNum
;
++
inde
x
)
{
for
(
int
i
dx
=
0
;
idx
<
mInfos
.
mnodeNum
;
++
id
x
)
{
SMInfo
*
pInfo
=
&
tsMInfos
.
mnodeInfos
[
i
nde
x
];
SMInfo
*
pInfo
=
&
tsMInfos
.
mnodeInfos
[
i
d
x
];
taosGetFqdnPortFromEp
(
pInfo
->
mnodeEp
,
tsMEpForShell
.
fqdn
[
i
ndex
],
&
tsMEpForShell
.
port
[
inde
x
]);
taosGetFqdnPortFromEp
(
pInfo
->
mnodeEp
,
tsMEpForShell
.
fqdn
[
i
dx
],
&
tsMEpForShell
.
port
[
id
x
]);
taosGetFqdnPortFromEp
(
pInfo
->
mnodeEp
,
tsMEpForPeer
.
fqdn
[
i
ndex
],
&
tsMEpForPeer
.
port
[
inde
x
]);
taosGetFqdnPortFromEp
(
pInfo
->
mnodeEp
,
tsMEpForPeer
.
fqdn
[
i
dx
],
&
tsMEpForPeer
.
port
[
id
x
]);
tsMEpForPeer
.
port
[
i
ndex
]
=
tsMEpForPeer
.
port
[
inde
x
]
+
TSDB_PORT_DNODEDNODE
;
tsMEpForPeer
.
port
[
i
dx
]
=
tsMEpForPeer
.
port
[
id
x
]
+
TSDB_PORT_DNODEDNODE
;
mInfo
(
"vgId:1, mnode:%d, fqdn:%s shell:%u peer:%u"
,
pInfo
->
mnodeId
,
tsMEpForShell
.
fqdn
[
i
nde
x
],
mInfo
(
"vgId:1, mnode:%d, fqdn:%s shell:%u peer:%u"
,
pInfo
->
mnodeId
,
tsMEpForShell
.
fqdn
[
i
d
x
],
tsMEpForShell
.
port
[
i
ndex
],
tsMEpForPeer
.
port
[
inde
x
]);
tsMEpForShell
.
port
[
i
dx
],
tsMEpForPeer
.
port
[
id
x
]);
tsMEpForShell
.
port
[
i
ndex
]
=
htons
(
tsMEpForShell
.
port
[
inde
x
]);
tsMEpForShell
.
port
[
i
dx
]
=
htons
(
tsMEpForShell
.
port
[
id
x
]);
tsMEpForPeer
.
port
[
i
ndex
]
=
htons
(
tsMEpForPeer
.
port
[
inde
x
]);
tsMEpForPeer
.
port
[
i
dx
]
=
htons
(
tsMEpForPeer
.
port
[
id
x
]);
pInfo
->
mnodeId
=
htonl
(
pInfo
->
mnodeId
);
pInfo
->
mnodeId
=
htonl
(
pInfo
->
mnodeId
);
}
}
}
else
{
}
else
{
mInfo
(
"vgId:1, mnodes epSet not set, num:%d inUse:%d"
,
tsMInfos
.
mnodeNum
,
tsMInfos
.
inUse
);
mInfo
(
"vgId:1, mnodes epSet not set, num:%d inUse:%d"
,
tsMInfos
.
mnodeNum
,
tsMInfos
.
inUse
);
for
(
int
i
ndex
=
0
;
index
<
tsMInfos
.
mnodeNum
;
++
inde
x
)
{
for
(
int
i
dx
=
0
;
idx
<
tsMInfos
.
mnodeNum
;
++
id
x
)
{
mInfo
(
"vgId:1, index:%d, ep:%s:%u"
,
i
ndex
,
tsMEpForShell
.
fqdn
[
index
],
htons
(
tsMEpForShell
.
port
[
inde
x
]));
mInfo
(
"vgId:1, index:%d, ep:%s:%u"
,
i
dx
,
tsMEpForShell
.
fqdn
[
idx
],
htons
(
tsMEpForShell
.
port
[
id
x
]));
}
}
}
}
...
...
src/mnode/src/mnodeSdb.c
浏览文件 @
3e42f5f1
...
@@ -331,7 +331,7 @@ int32_t sdbUpdateSync(void *pMnodes) {
...
@@ -331,7 +331,7 @@ int32_t sdbUpdateSync(void *pMnodes) {
mDebug
(
"vgId:1, update sync config, pMnodes:%p"
,
pMnodes
);
mDebug
(
"vgId:1, update sync config, pMnodes:%p"
,
pMnodes
);
SSyncCfg
syncCfg
=
{
0
};
SSyncCfg
syncCfg
=
{
0
};
int32_t
i
nde
x
=
0
;
int32_t
i
d
x
=
0
;
if
(
pMinfos
==
NULL
)
{
if
(
pMinfos
==
NULL
)
{
mDebug
(
"vgId:1, mInfos not input, use mInfos in sdb, numOfMnodes:%d"
,
syncCfg
.
replica
);
mDebug
(
"vgId:1, mInfos not input, use mInfos in sdb, numOfMnodes:%d"
,
syncCfg
.
replica
);
...
@@ -342,29 +342,29 @@ int32_t sdbUpdateSync(void *pMnodes) {
...
@@ -342,29 +342,29 @@ int32_t sdbUpdateSync(void *pMnodes) {
pIter
=
mnodeGetNextMnode
(
pIter
,
&
pMnode
);
pIter
=
mnodeGetNextMnode
(
pIter
,
&
pMnode
);
if
(
pMnode
==
NULL
)
break
;
if
(
pMnode
==
NULL
)
break
;
syncCfg
.
nodeInfo
[
i
nde
x
].
nodeId
=
pMnode
->
mnodeId
;
syncCfg
.
nodeInfo
[
i
d
x
].
nodeId
=
pMnode
->
mnodeId
;
SDnodeObj
*
pDnode
=
mnodeGetDnode
(
pMnode
->
mnodeId
);
SDnodeObj
*
pDnode
=
mnodeGetDnode
(
pMnode
->
mnodeId
);
if
(
pDnode
!=
NULL
)
{
if
(
pDnode
!=
NULL
)
{
syncCfg
.
nodeInfo
[
i
nde
x
].
nodePort
=
pDnode
->
dnodePort
+
TSDB_PORT_SYNC
;
syncCfg
.
nodeInfo
[
i
d
x
].
nodePort
=
pDnode
->
dnodePort
+
TSDB_PORT_SYNC
;
tstrncpy
(
syncCfg
.
nodeInfo
[
i
nde
x
].
nodeFqdn
,
pDnode
->
dnodeFqdn
,
TSDB_FQDN_LEN
);
tstrncpy
(
syncCfg
.
nodeInfo
[
i
d
x
].
nodeFqdn
,
pDnode
->
dnodeFqdn
,
TSDB_FQDN_LEN
);
i
nde
x
++
;
i
d
x
++
;
}
}
mnodeDecDnodeRef
(
pDnode
);
mnodeDecDnodeRef
(
pDnode
);
mnodeDecMnodeRef
(
pMnode
);
mnodeDecMnodeRef
(
pMnode
);
}
}
syncCfg
.
replica
=
i
nde
x
;
syncCfg
.
replica
=
i
d
x
;
}
else
{
}
else
{
mDebug
(
"vgId:1, mInfos input, numOfMnodes:%d"
,
pMinfos
->
mnodeNum
);
mDebug
(
"vgId:1, mInfos input, numOfMnodes:%d"
,
pMinfos
->
mnodeNum
);
for
(
i
ndex
=
0
;
index
<
pMinfos
->
mnodeNum
;
++
inde
x
)
{
for
(
i
dx
=
0
;
idx
<
pMinfos
->
mnodeNum
;
++
id
x
)
{
SMInfo
*
node
=
&
pMinfos
->
mnodeInfos
[
i
nde
x
];
SMInfo
*
node
=
&
pMinfos
->
mnodeInfos
[
i
d
x
];
syncCfg
.
nodeInfo
[
i
nde
x
].
nodeId
=
node
->
mnodeId
;
syncCfg
.
nodeInfo
[
i
d
x
].
nodeId
=
node
->
mnodeId
;
taosGetFqdnPortFromEp
(
node
->
mnodeEp
,
syncCfg
.
nodeInfo
[
i
ndex
].
nodeFqdn
,
&
syncCfg
.
nodeInfo
[
inde
x
].
nodePort
);
taosGetFqdnPortFromEp
(
node
->
mnodeEp
,
syncCfg
.
nodeInfo
[
i
dx
].
nodeFqdn
,
&
syncCfg
.
nodeInfo
[
id
x
].
nodePort
);
syncCfg
.
nodeInfo
[
i
nde
x
].
nodePort
+=
TSDB_PORT_SYNC
;
syncCfg
.
nodeInfo
[
i
d
x
].
nodePort
+=
TSDB_PORT_SYNC
;
}
}
syncCfg
.
replica
=
i
nde
x
;
syncCfg
.
replica
=
i
d
x
;
mnodeUpdateMnodeEpSet
(
pMnodes
);
mnodeUpdateMnodeEpSet
(
pMnodes
);
}
}
...
...
src/os/src/detail/osDir.c
浏览文件 @
3e42f5f1
...
@@ -45,8 +45,8 @@ void taosRemoveDir(char *rootDir) {
...
@@ -45,8 +45,8 @@ void taosRemoveDir(char *rootDir) {
uInfo
(
"dir:%s is removed"
,
rootDir
);
uInfo
(
"dir:%s is removed"
,
rootDir
);
}
}
bool
taosDirExist
(
const
char
*
dir
name
)
{
bool
taosDirExist
(
const
char
*
dir
)
{
return
access
(
dir
name
,
F_OK
)
==
0
;
return
access
(
dir
,
F_OK
)
==
0
;
}
}
int
taosMkDir
(
const
char
*
path
,
mode_t
mode
)
{
int
taosMkDir
(
const
char
*
path
,
mode_t
mode
)
{
...
...
src/os/src/detail/osFile.c
浏览文件 @
3e42f5f1
...
@@ -71,11 +71,11 @@ void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath) {
...
@@ -71,11 +71,11 @@ void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath) {
strcat
(
tmpPath
,
"-%d-%s"
);
strcat
(
tmpPath
,
"-%d-%s"
);
}
}
char
rand
[
32
]
=
{
0
};
char
rand
_num
[
32
]
=
{
0
};
sprintf
(
rand
,
"%"
PRIu64
,
atomic_add_fetch_64
(
&
seqId
,
1
));
sprintf
(
rand
_num
,
"%"
PRIu64
,
atomic_add_fetch_64
(
&
seqId
,
1
));
snprintf
(
dstPath
,
PATH_MAX
,
tmpPath
,
getpid
(),
rand
);
snprintf
(
dstPath
,
PATH_MAX
,
tmpPath
,
getpid
(),
rand
_num
);
}
}
#endif
#endif
...
...
src/os/src/detail/osTime.c
浏览文件 @
3e42f5f1
...
@@ -89,19 +89,19 @@ static bool checkTzPresent(char *str, int32_t len);
...
@@ -89,19 +89,19 @@ static bool checkTzPresent(char *str, int32_t len);
int32_t
taosGetTimestampSec
()
{
return
(
int32_t
)
time
(
NULL
);
}
int32_t
taosGetTimestampSec
()
{
return
(
int32_t
)
time
(
NULL
);
}
int32_t
taosParseTime
(
char
*
timestr
,
int64_t
*
t
ime
,
int32_t
len
,
int32_t
timePrec
,
int8_t
day_light
)
{
int32_t
taosParseTime
(
char
*
timestr
,
int64_t
*
pT
ime
,
int32_t
len
,
int32_t
timePrec
,
int8_t
day_light
)
{
/* parse datatime string in with tz */
/* parse datatime string in with tz */
if
(
strnchr
(
timestr
,
'T'
,
len
,
false
)
!=
NULL
)
{
if
(
strnchr
(
timestr
,
'T'
,
len
,
false
)
!=
NULL
)
{
if
(
checkTzPresent
(
timestr
,
len
))
{
if
(
checkTzPresent
(
timestr
,
len
))
{
return
parseTimeWithTz
(
timestr
,
t
ime
,
timePrec
,
'T'
);
return
parseTimeWithTz
(
timestr
,
pT
ime
,
timePrec
,
'T'
);
}
else
{
}
else
{
return
parseLocaltime
(
timestr
,
t
ime
,
timePrec
,
'T'
,
day_light
);
return
parseLocaltime
(
timestr
,
pT
ime
,
timePrec
,
'T'
,
day_light
);
}
}
}
else
{
}
else
{
if
(
checkTzPresent
(
timestr
,
len
))
{
if
(
checkTzPresent
(
timestr
,
len
))
{
return
parseTimeWithTz
(
timestr
,
t
ime
,
timePrec
,
0
);
return
parseTimeWithTz
(
timestr
,
pT
ime
,
timePrec
,
0
);
}
else
{
}
else
{
return
parseLocaltime
(
timestr
,
t
ime
,
timePrec
,
0
,
day_light
);
return
parseLocaltime
(
timestr
,
pT
ime
,
timePrec
,
0
,
day_light
);
}
}
}
}
}
}
...
@@ -121,8 +121,8 @@ bool checkTzPresent(char *str, int32_t len) {
...
@@ -121,8 +121,8 @@ bool checkTzPresent(char *str, int32_t len) {
}
}
FORCE_INLINE
int32_t
taos_parse_time
(
char
*
timestr
,
int64_t
*
t
ime
,
int32_t
len
,
int32_t
timePrec
,
int8_t
day_light
)
{
FORCE_INLINE
int32_t
taos_parse_time
(
char
*
timestr
,
int64_t
*
pT
ime
,
int32_t
len
,
int32_t
timePrec
,
int8_t
day_light
)
{
return
taosParseTime
(
timestr
,
t
ime
,
len
,
timePrec
,
day_light
);
return
taosParseTime
(
timestr
,
pT
ime
,
len
,
timePrec
,
day_light
);
}
}
char
*
forwardToTimeStringEnd
(
char
*
str
)
{
char
*
forwardToTimeStringEnd
(
char
*
str
)
{
...
@@ -243,7 +243,7 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
...
@@ -243,7 +243,7 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
* 2013-04-12T15:52:01+0800
* 2013-04-12T15:52:01+0800
* 2013-04-12T15:52:01.123+0800
* 2013-04-12T15:52:01.123+0800
*/
*/
int32_t
parseTimeWithTz
(
char
*
timestr
,
int64_t
*
t
ime
,
int32_t
timePrec
,
char
delim
)
{
int32_t
parseTimeWithTz
(
char
*
timestr
,
int64_t
*
pT
ime
,
int32_t
timePrec
,
char
delim
)
{
int64_t
factor
=
(
timePrec
==
TSDB_TIME_PRECISION_MILLI
)
?
1000
:
int64_t
factor
=
(
timePrec
==
TSDB_TIME_PRECISION_MILLI
)
?
1000
:
(
timePrec
==
TSDB_TIME_PRECISION_MICRO
?
1000000
:
1000000000
);
(
timePrec
==
TSDB_TIME_PRECISION_MICRO
?
1000000
:
1000000000
);
...
@@ -277,14 +277,14 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec, char del
...
@@ -277,14 +277,14 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec, char del
if
((
str
[
0
]
==
'Z'
||
str
[
0
]
==
'z'
)
&&
str
[
1
]
==
'\0'
)
{
if
((
str
[
0
]
==
'Z'
||
str
[
0
]
==
'z'
)
&&
str
[
1
]
==
'\0'
)
{
/* utc time, no millisecond, return directly*/
/* utc time, no millisecond, return directly*/
*
t
ime
=
seconds
*
factor
;
*
pT
ime
=
seconds
*
factor
;
}
else
if
(
str
[
0
]
==
'.'
)
{
}
else
if
(
str
[
0
]
==
'.'
)
{
str
+=
1
;
str
+=
1
;
if
((
fraction
=
parseFraction
(
str
,
&
str
,
timePrec
))
<
0
)
{
if
((
fraction
=
parseFraction
(
str
,
&
str
,
timePrec
))
<
0
)
{
return
-
1
;
return
-
1
;
}
}
*
t
ime
=
seconds
*
factor
+
fraction
;
*
pT
ime
=
seconds
*
factor
+
fraction
;
char
seg
=
str
[
0
];
char
seg
=
str
[
0
];
if
(
seg
!=
'Z'
&&
seg
!=
'z'
&&
seg
!=
'+'
&&
seg
!=
'-'
)
{
if
(
seg
!=
'Z'
&&
seg
!=
'z'
&&
seg
!=
'+'
&&
seg
!=
'-'
)
{
...
@@ -297,18 +297,18 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec, char del
...
@@ -297,18 +297,18 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec, char del
return
-
1
;
return
-
1
;
}
}
*
t
ime
+=
tzOffset
*
factor
;
*
pT
ime
+=
tzOffset
*
factor
;
}
}
}
else
if
(
str
[
0
]
==
'+'
||
str
[
0
]
==
'-'
)
{
}
else
if
(
str
[
0
]
==
'+'
||
str
[
0
]
==
'-'
)
{
*
t
ime
=
seconds
*
factor
+
fraction
;
*
pT
ime
=
seconds
*
factor
+
fraction
;
// parse the timezone
// parse the timezone
if
(
parseTimezone
(
str
,
&
tzOffset
)
==
-
1
)
{
if
(
parseTimezone
(
str
,
&
tzOffset
)
==
-
1
)
{
return
-
1
;
return
-
1
;
}
}
*
t
ime
+=
tzOffset
*
factor
;
*
pT
ime
+=
tzOffset
*
factor
;
}
else
{
}
else
{
return
-
1
;
return
-
1
;
}
}
...
@@ -316,8 +316,8 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec, char del
...
@@ -316,8 +316,8 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec, char del
return
0
;
return
0
;
}
}
int32_t
parseLocaltime
(
char
*
timestr
,
int64_t
*
t
ime
,
int32_t
timePrec
,
char
delim
,
bool
withDST
)
{
int32_t
parseLocaltime
(
char
*
timestr
,
int64_t
*
pT
ime
,
int32_t
timePrec
,
char
delim
,
bool
withDST
)
{
*
t
ime
=
0
;
*
pT
ime
=
0
;
struct
tm
tm
=
{
0
};
struct
tm
tm
=
{
0
};
if
(
withDST
)
{
if
(
withDST
)
{
tm
.
tm_isdst
=
-
1
;
tm
.
tm_isdst
=
-
1
;
...
@@ -357,65 +357,65 @@ int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec, char deli
...
@@ -357,65 +357,65 @@ int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec, char deli
int64_t
factor
=
(
timePrec
==
TSDB_TIME_PRECISION_MILLI
)
?
1000
:
int64_t
factor
=
(
timePrec
==
TSDB_TIME_PRECISION_MILLI
)
?
1000
:
(
timePrec
==
TSDB_TIME_PRECISION_MICRO
?
1000000
:
1000000000
);
(
timePrec
==
TSDB_TIME_PRECISION_MICRO
?
1000000
:
1000000000
);
*
t
ime
=
factor
*
seconds
+
fraction
;
*
pT
ime
=
factor
*
seconds
+
fraction
;
return
0
;
return
0
;
}
}
int64_t
convertTimePrecision
(
int64_t
time
,
int32_t
fromPrecision
,
int32_t
toPrecision
)
{
int64_t
convertTimePrecision
(
int64_t
time
Stamp
,
int32_t
fromPrecision
,
int32_t
toPrecision
)
{
assert
(
fromPrecision
==
TSDB_TIME_PRECISION_MILLI
||
assert
(
fromPrecision
==
TSDB_TIME_PRECISION_MILLI
||
fromPrecision
==
TSDB_TIME_PRECISION_MICRO
||
fromPrecision
==
TSDB_TIME_PRECISION_MICRO
||
fromPrecision
==
TSDB_TIME_PRECISION_NANO
);
fromPrecision
==
TSDB_TIME_PRECISION_NANO
);
assert
(
toPrecision
==
TSDB_TIME_PRECISION_MILLI
||
assert
(
toPrecision
==
TSDB_TIME_PRECISION_MILLI
||
toPrecision
==
TSDB_TIME_PRECISION_MICRO
||
toPrecision
==
TSDB_TIME_PRECISION_MICRO
||
toPrecision
==
TSDB_TIME_PRECISION_NANO
);
toPrecision
==
TSDB_TIME_PRECISION_NANO
);
double
tempResult
=
(
double
)
time
;
double
tempResult
=
(
double
)
time
Stamp
;
switch
(
fromPrecision
)
{
switch
(
fromPrecision
)
{
case
TSDB_TIME_PRECISION_MILLI
:
{
case
TSDB_TIME_PRECISION_MILLI
:
{
switch
(
toPrecision
)
{
switch
(
toPrecision
)
{
case
TSDB_TIME_PRECISION_MILLI
:
case
TSDB_TIME_PRECISION_MILLI
:
return
time
;
return
time
Stamp
;
case
TSDB_TIME_PRECISION_MICRO
:
case
TSDB_TIME_PRECISION_MICRO
:
tempResult
*=
1000
;
tempResult
*=
1000
;
time
*=
1000
;
time
Stamp
*=
1000
;
goto
end_
;
goto
end_
;
case
TSDB_TIME_PRECISION_NANO
:
case
TSDB_TIME_PRECISION_NANO
:
tempResult
*=
1000000
;
tempResult
*=
1000000
;
time
*=
1000000
;
time
Stamp
*=
1000000
;
goto
end_
;
goto
end_
;
}
}
}
// end from milli
}
// end from milli
case
TSDB_TIME_PRECISION_MICRO
:
{
case
TSDB_TIME_PRECISION_MICRO
:
{
switch
(
toPrecision
)
{
switch
(
toPrecision
)
{
case
TSDB_TIME_PRECISION_MILLI
:
case
TSDB_TIME_PRECISION_MILLI
:
return
time
/
1000
;
return
time
Stamp
/
1000
;
case
TSDB_TIME_PRECISION_MICRO
:
case
TSDB_TIME_PRECISION_MICRO
:
return
time
;
return
time
Stamp
;
case
TSDB_TIME_PRECISION_NANO
:
case
TSDB_TIME_PRECISION_NANO
:
tempResult
*=
1000
;
tempResult
*=
1000
;
time
*=
1000
;
time
Stamp
*=
1000
;
goto
end_
;
goto
end_
;
}
}
}
//end from micro
}
//end from micro
case
TSDB_TIME_PRECISION_NANO
:
{
case
TSDB_TIME_PRECISION_NANO
:
{
switch
(
toPrecision
)
{
switch
(
toPrecision
)
{
case
TSDB_TIME_PRECISION_MILLI
:
case
TSDB_TIME_PRECISION_MILLI
:
return
time
/
1000000
;
return
time
Stamp
/
1000000
;
case
TSDB_TIME_PRECISION_MICRO
:
case
TSDB_TIME_PRECISION_MICRO
:
return
time
/
1000
;
return
time
Stamp
/
1000
;
case
TSDB_TIME_PRECISION_NANO
:
case
TSDB_TIME_PRECISION_NANO
:
return
time
;
return
time
Stamp
;
}
}
}
//end from nano
}
//end from nano
default:
{
default:
{
assert
(
0
);
assert
(
0
);
return
time
;
// only to pass windows compilation
return
time
Stamp
;
// only to pass windows compilation
}
}
}
//end switch fromPrecision
}
//end switch fromPrecision
end_:
end_:
if
(
tempResult
>=
(
double
)
INT64_MAX
)
return
INT64_MAX
;
if
(
tempResult
>=
(
double
)
INT64_MAX
)
return
INT64_MAX
;
if
(
tempResult
<=
(
double
)
INT64_MIN
)
return
INT64_MIN
+
1
;
// INT64_MIN means NULL
if
(
tempResult
<=
(
double
)
INT64_MIN
)
return
INT64_MIN
+
1
;
// INT64_MIN means NULL
return
time
;
return
time
Stamp
;
}
}
static
int32_t
getDuration
(
int64_t
val
,
char
unit
,
int64_t
*
result
,
int32_t
timePrecision
)
{
static
int32_t
getDuration
(
int64_t
val
,
char
unit
,
int64_t
*
result
,
int32_t
timePrecision
)
{
...
@@ -517,18 +517,18 @@ int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* durati
...
@@ -517,18 +517,18 @@ int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* durati
return
getDuration
(
*
duration
,
*
unit
,
duration
,
timePrecision
);
return
getDuration
(
*
duration
,
*
unit
,
duration
,
timePrecision
);
}
}
int64_t
taosTimeAdd
(
int64_t
t
,
int64_t
duration
,
char
unit
,
int32_t
precision
)
{
int64_t
taosTimeAdd
(
int64_t
t
imeStamp
,
int64_t
duration
,
char
unit
,
int32_t
precision
)
{
if
(
duration
==
0
)
{
if
(
duration
==
0
)
{
return
t
;
return
t
imeStamp
;
}
}
if
(
unit
==
'y'
)
{
if
(
unit
==
'y'
)
{
duration
*=
12
;
duration
*=
12
;
}
else
if
(
unit
!=
'n'
)
{
}
else
if
(
unit
!=
'n'
)
{
return
t
+
duration
;
return
t
imeStamp
+
duration
;
}
}
struct
tm
tm
;
struct
tm
tm
;
time_t
tt
=
(
time_t
)(
t
/
TSDB_TICK_PER_SECOND
(
precision
));
time_t
tt
=
(
time_t
)(
t
imeStamp
/
TSDB_TICK_PER_SECOND
(
precision
));
localtime_r
(
&
tt
,
&
tm
);
localtime_r
(
&
tt
,
&
tm
);
int
mon
=
tm
.
tm_year
*
12
+
tm
.
tm_mon
+
(
int
)
duration
;
int
mon
=
tm
.
tm_year
*
12
+
tm
.
tm_mon
+
(
int
)
duration
;
tm
.
tm_year
=
mon
/
12
;
tm
.
tm_year
=
mon
/
12
;
...
@@ -537,18 +537,18 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
...
@@ -537,18 +537,18 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
return
(
int64_t
)(
mktime
(
&
tm
)
*
TSDB_TICK_PER_SECOND
(
precision
));
return
(
int64_t
)(
mktime
(
&
tm
)
*
TSDB_TICK_PER_SECOND
(
precision
));
}
}
int64_t
taosTimeSub
(
int64_t
t
,
int64_t
duration
,
char
unit
,
int32_t
precision
)
{
int64_t
taosTimeSub
(
int64_t
t
imeStamp
,
int64_t
duration
,
char
unit
,
int32_t
precision
)
{
if
(
duration
==
0
)
{
if
(
duration
==
0
)
{
return
t
;
return
t
imeStamp
;
}
}
if
(
unit
==
'y'
)
{
if
(
unit
==
'y'
)
{
duration
*=
12
;
duration
*=
12
;
}
else
if
(
unit
!=
'n'
)
{
}
else
if
(
unit
!=
'n'
)
{
return
t
-
duration
;
return
t
imeStamp
-
duration
;
}
}
struct
tm
tm
;
struct
tm
tm
;
time_t
tt
=
(
time_t
)(
t
/
TSDB_TICK_PER_SECOND
(
precision
));
time_t
tt
=
(
time_t
)(
t
imeStamp
/
TSDB_TICK_PER_SECOND
(
precision
));
localtime_r
(
&
tt
,
&
tm
);
localtime_r
(
&
tt
,
&
tm
);
int
mon
=
tm
.
tm_year
*
12
+
tm
.
tm_mon
-
(
int
)
duration
;
int
mon
=
tm
.
tm_year
*
12
+
tm
.
tm_mon
-
(
int
)
duration
;
tm
.
tm_year
=
mon
/
12
;
tm
.
tm_year
=
mon
/
12
;
...
@@ -572,12 +572,12 @@ int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char
...
@@ -572,12 +572,12 @@ int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char
ekey
/=
(
int64_t
)(
TSDB_TICK_PER_SECOND
(
precision
));
ekey
/=
(
int64_t
)(
TSDB_TICK_PER_SECOND
(
precision
));
struct
tm
tm
;
struct
tm
tm
;
time_t
t
=
(
time_t
)
skey
;
time_t
t
imeStamp
=
(
time_t
)
skey
;
localtime_r
(
&
t
,
&
tm
);
localtime_r
(
&
t
imeStamp
,
&
tm
);
int
smon
=
tm
.
tm_year
*
12
+
tm
.
tm_mon
;
int
smon
=
tm
.
tm_year
*
12
+
tm
.
tm_mon
;
t
=
(
time_t
)
ekey
;
t
imeStamp
=
(
time_t
)
ekey
;
localtime_r
(
&
t
,
&
tm
);
localtime_r
(
&
t
imeStamp
,
&
tm
);
int
emon
=
tm
.
tm_year
*
12
+
tm
.
tm_mon
;
int
emon
=
tm
.
tm_year
*
12
+
tm
.
tm_mon
;
if
(
unit
==
'y'
)
{
if
(
unit
==
'y'
)
{
...
@@ -587,13 +587,13 @@ int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char
...
@@ -587,13 +587,13 @@ int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char
return
(
emon
-
smon
)
/
(
int32_t
)
interval
;
return
(
emon
-
smon
)
/
(
int32_t
)
interval
;
}
}
int64_t
taosTimeTruncate
(
int64_t
t
,
const
SInterval
*
pInterval
,
int32_t
precision
)
{
int64_t
taosTimeTruncate
(
int64_t
t
imeStamp
,
const
SInterval
*
pInterval
,
int32_t
precision
)
{
if
(
pInterval
->
sliding
==
0
)
{
if
(
pInterval
->
sliding
==
0
)
{
assert
(
pInterval
->
interval
==
0
);
assert
(
pInterval
->
interval
==
0
);
return
t
;
return
t
imeStamp
;
}
}
int64_t
start
=
t
;
int64_t
start
=
t
imeStamp
;
if
(
pInterval
->
slidingUnit
==
'n'
||
pInterval
->
slidingUnit
==
'y'
)
{
if
(
pInterval
->
slidingUnit
==
'n'
||
pInterval
->
slidingUnit
==
'y'
)
{
start
/=
(
int64_t
)(
TSDB_TICK_PER_SECOND
(
precision
));
start
/=
(
int64_t
)(
TSDB_TICK_PER_SECOND
(
precision
));
struct
tm
tm
;
struct
tm
tm
;
...
@@ -616,7 +616,7 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
...
@@ -616,7 +616,7 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
start
=
(
int64_t
)(
mktime
(
&
tm
)
*
TSDB_TICK_PER_SECOND
(
precision
));
start
=
(
int64_t
)(
mktime
(
&
tm
)
*
TSDB_TICK_PER_SECOND
(
precision
));
}
else
{
}
else
{
int64_t
delta
=
t
-
pInterval
->
interval
;
int64_t
delta
=
t
imeStamp
-
pInterval
->
interval
;
int32_t
factor
=
(
delta
>=
0
)
?
1
:
-
1
;
int32_t
factor
=
(
delta
>=
0
)
?
1
:
-
1
;
start
=
(
delta
/
pInterval
->
sliding
+
factor
)
*
pInterval
->
sliding
;
start
=
(
delta
/
pInterval
->
sliding
+
factor
)
*
pInterval
->
sliding
;
...
@@ -643,7 +643,7 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
...
@@ -643,7 +643,7 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
if
(
start
<
0
||
INT64_MAX
-
start
>
pInterval
->
interval
-
1
)
{
if
(
start
<
0
||
INT64_MAX
-
start
>
pInterval
->
interval
-
1
)
{
end
=
start
+
pInterval
->
interval
-
1
;
end
=
start
+
pInterval
->
interval
-
1
;
while
(
end
<
t
&&
((
start
+
pInterval
->
sliding
)
<=
INT64_MAX
))
{
// move forward to the correct time window
while
(
end
<
t
imeStamp
&&
((
start
+
pInterval
->
sliding
)
<=
INT64_MAX
))
{
// move forward to the correct time window
start
+=
pInterval
->
sliding
;
start
+=
pInterval
->
sliding
;
if
(
start
<
0
||
INT64_MAX
-
start
>
pInterval
->
interval
-
1
)
{
if
(
start
<
0
||
INT64_MAX
-
start
>
pInterval
->
interval
-
1
)
{
...
@@ -660,7 +660,7 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
...
@@ -660,7 +660,7 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
if
(
pInterval
->
offset
>
0
)
{
if
(
pInterval
->
offset
>
0
)
{
start
=
taosTimeAdd
(
start
,
pInterval
->
offset
,
pInterval
->
offsetUnit
,
precision
);
start
=
taosTimeAdd
(
start
,
pInterval
->
offset
,
pInterval
->
offsetUnit
,
precision
);
if
(
start
>
t
)
{
if
(
start
>
t
imeStamp
)
{
start
=
taosTimeAdd
(
start
,
-
pInterval
->
interval
,
pInterval
->
intervalUnit
,
precision
);
start
=
taosTimeAdd
(
start
,
-
pInterval
->
interval
,
pInterval
->
intervalUnit
,
precision
);
}
}
}
}
...
@@ -680,14 +680,14 @@ const char* fmtts(int64_t ts) {
...
@@ -680,14 +680,14 @@ const char* fmtts(int64_t ts) {
struct
tm
tm
;
struct
tm
tm
;
if
(
ts
>
-
62135625943
&&
ts
<
32503651200
)
{
if
(
ts
>
-
62135625943
&&
ts
<
32503651200
)
{
time_t
t
=
(
time_t
)
ts
;
time_t
t
imeStamp
=
(
time_t
)
ts
;
localtime_r
(
&
t
,
&
tm
);
localtime_r
(
&
t
imeStamp
,
&
tm
);
pos
+=
strftime
(
buf
+
pos
,
sizeof
(
buf
),
"s=%Y-%m-%d %H:%M:%S"
,
&
tm
);
pos
+=
strftime
(
buf
+
pos
,
sizeof
(
buf
),
"s=%Y-%m-%d %H:%M:%S"
,
&
tm
);
}
}
if
(
ts
>
-
62135625943000
&&
ts
<
32503651200000
)
{
if
(
ts
>
-
62135625943000
&&
ts
<
32503651200000
)
{
time_t
t
=
(
time_t
)(
ts
/
1000
);
time_t
t
imeStamp
=
(
time_t
)(
ts
/
1000
);
localtime_r
(
&
t
,
&
tm
);
localtime_r
(
&
t
imeStamp
,
&
tm
);
if
(
pos
>
0
)
{
if
(
pos
>
0
)
{
buf
[
pos
++
]
=
' '
;
buf
[
pos
++
]
=
' '
;
buf
[
pos
++
]
=
'|'
;
buf
[
pos
++
]
=
'|'
;
...
@@ -698,8 +698,8 @@ const char* fmtts(int64_t ts) {
...
@@ -698,8 +698,8 @@ const char* fmtts(int64_t ts) {
}
}
{
{
time_t
t
=
(
time_t
)(
ts
/
1000000
);
time_t
t
imeStamp
=
(
time_t
)(
ts
/
1000000
);
localtime_r
(
&
t
,
&
tm
);
localtime_r
(
&
t
imeStamp
,
&
tm
);
if
(
pos
>
0
)
{
if
(
pos
>
0
)
{
buf
[
pos
++
]
=
' '
;
buf
[
pos
++
]
=
' '
;
buf
[
pos
++
]
=
'|'
;
buf
[
pos
++
]
=
'|'
;
...
...
src/os/src/linux/osSystem.c
浏览文件 @
3e42f5f1
...
@@ -33,9 +33,9 @@ void* taosLoadDll(const char *filename) {
...
@@ -33,9 +33,9 @@ void* taosLoadDll(const char *filename) {
void
*
taosLoadSym
(
void
*
handle
,
char
*
name
)
{
void
*
taosLoadSym
(
void
*
handle
,
char
*
name
)
{
void
*
sym
=
dlsym
(
handle
,
name
);
void
*
sym
=
dlsym
(
handle
,
name
);
char
*
err
or
=
NULL
;
char
*
err
=
NULL
;
if
((
err
or
=
dlerror
())
!=
NULL
)
{
if
((
err
=
dlerror
())
!=
NULL
)
{
uWarn
(
"load sym:%s failed, error:%s"
,
name
,
dlerror
());
uWarn
(
"load sym:%s failed, error:%s"
,
name
,
dlerror
());
return
NULL
;
return
NULL
;
}
}
...
...
src/query/src/qAggMain.c
浏览文件 @
3e42f5f1
...
@@ -991,14 +991,14 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin,
...
@@ -991,14 +991,14 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin,
}
}
void
*
tval
=
NULL
;
void
*
tval
=
NULL
;
int16_t
i
nde
x
=
0
;
int16_t
i
d
x
=
0
;
if
(
isMin
)
{
if
(
isMin
)
{
tval
=
&
pCtx
->
preAggVals
.
statis
.
min
;
tval
=
&
pCtx
->
preAggVals
.
statis
.
min
;
i
nde
x
=
pCtx
->
preAggVals
.
statis
.
minIndex
;
i
d
x
=
pCtx
->
preAggVals
.
statis
.
minIndex
;
}
else
{
}
else
{
tval
=
&
pCtx
->
preAggVals
.
statis
.
max
;
tval
=
&
pCtx
->
preAggVals
.
statis
.
max
;
i
nde
x
=
pCtx
->
preAggVals
.
statis
.
maxIndex
;
i
d
x
=
pCtx
->
preAggVals
.
statis
.
maxIndex
;
}
}
TSKEY
key
=
TSKEY_INITIAL_VAL
;
TSKEY
key
=
TSKEY_INITIAL_VAL
;
...
@@ -1014,7 +1014,7 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin,
...
@@ -1014,7 +1014,7 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin,
// }
// }
// the index is the original position, not the relative position
// the index is the original position, not the relative position
key
=
pCtx
->
ptsList
[
i
nde
x
];
key
=
pCtx
->
ptsList
[
i
d
x
];
}
}
if
(
IS_SIGNED_NUMERIC_TYPE
(
pCtx
->
inputType
))
{
if
(
IS_SIGNED_NUMERIC_TYPE
(
pCtx
->
inputType
))
{
...
@@ -1693,15 +1693,15 @@ static void first_function(SQLFunctionCtx *pCtx) {
...
@@ -1693,15 +1693,15 @@ static void first_function(SQLFunctionCtx *pCtx) {
SET_VAL
(
pCtx
,
notNullElems
,
1
);
SET_VAL
(
pCtx
,
notNullElems
,
1
);
}
}
static
void
first_data_assign_impl
(
SQLFunctionCtx
*
pCtx
,
char
*
pData
,
int32_t
i
nde
x
)
{
static
void
first_data_assign_impl
(
SQLFunctionCtx
*
pCtx
,
char
*
pData
,
int32_t
i
d
x
)
{
int64_t
*
timestamp
=
GET_TS_LIST
(
pCtx
);
int64_t
*
timestamp
=
GET_TS_LIST
(
pCtx
);
SFirstLastInfo
*
pInfo
=
(
SFirstLastInfo
*
)(
pCtx
->
pOutput
+
pCtx
->
inputBytes
);
SFirstLastInfo
*
pInfo
=
(
SFirstLastInfo
*
)(
pCtx
->
pOutput
+
pCtx
->
inputBytes
);
if
(
pInfo
->
hasResult
!=
DATA_SET_FLAG
||
timestamp
[
i
nde
x
]
<
pInfo
->
ts
)
{
if
(
pInfo
->
hasResult
!=
DATA_SET_FLAG
||
timestamp
[
i
d
x
]
<
pInfo
->
ts
)
{
memcpy
(
pCtx
->
pOutput
,
pData
,
pCtx
->
inputBytes
);
memcpy
(
pCtx
->
pOutput
,
pData
,
pCtx
->
inputBytes
);
pInfo
->
hasResult
=
DATA_SET_FLAG
;
pInfo
->
hasResult
=
DATA_SET_FLAG
;
pInfo
->
ts
=
timestamp
[
i
nde
x
];
pInfo
->
ts
=
timestamp
[
i
d
x
];
DO_UPDATE_TAG_COLUMNS
(
pCtx
,
pInfo
->
ts
);
DO_UPDATE_TAG_COLUMNS
(
pCtx
,
pInfo
->
ts
);
}
}
...
@@ -1831,19 +1831,19 @@ static void last_function(SQLFunctionCtx *pCtx) {
...
@@ -1831,19 +1831,19 @@ static void last_function(SQLFunctionCtx *pCtx) {
SET_VAL
(
pCtx
,
notNullElems
,
1
);
SET_VAL
(
pCtx
,
notNullElems
,
1
);
}
}
static
void
last_data_assign_impl
(
SQLFunctionCtx
*
pCtx
,
char
*
pData
,
int32_t
i
nde
x
)
{
static
void
last_data_assign_impl
(
SQLFunctionCtx
*
pCtx
,
char
*
pData
,
int32_t
i
d
x
)
{
int64_t
*
timestamp
=
GET_TS_LIST
(
pCtx
);
int64_t
*
timestamp
=
GET_TS_LIST
(
pCtx
);
SFirstLastInfo
*
pInfo
=
(
SFirstLastInfo
*
)(
pCtx
->
pOutput
+
pCtx
->
inputBytes
);
SFirstLastInfo
*
pInfo
=
(
SFirstLastInfo
*
)(
pCtx
->
pOutput
+
pCtx
->
inputBytes
);
if
(
pInfo
->
hasResult
!=
DATA_SET_FLAG
||
pInfo
->
ts
<
timestamp
[
i
nde
x
])
{
if
(
pInfo
->
hasResult
!=
DATA_SET_FLAG
||
pInfo
->
ts
<
timestamp
[
i
d
x
])
{
#if defined(_DEBUG_VIEW)
#if defined(_DEBUG_VIEW)
qDebug
(
"assign index:%d, ts:%"
PRId64
", val:%d, "
,
i
ndex
,
timestamp
[
inde
x
],
*
(
int32_t
*
)
pData
);
qDebug
(
"assign index:%d, ts:%"
PRId64
", val:%d, "
,
i
dx
,
timestamp
[
id
x
],
*
(
int32_t
*
)
pData
);
#endif
#endif
memcpy
(
pCtx
->
pOutput
,
pData
,
pCtx
->
inputBytes
);
memcpy
(
pCtx
->
pOutput
,
pData
,
pCtx
->
inputBytes
);
pInfo
->
hasResult
=
DATA_SET_FLAG
;
pInfo
->
hasResult
=
DATA_SET_FLAG
;
pInfo
->
ts
=
timestamp
[
i
nde
x
];
pInfo
->
ts
=
timestamp
[
i
d
x
];
DO_UPDATE_TAG_COLUMNS
(
pCtx
,
pInfo
->
ts
);
DO_UPDATE_TAG_COLUMNS
(
pCtx
,
pInfo
->
ts
);
}
}
...
@@ -3476,16 +3476,16 @@ static void diff_function(SQLFunctionCtx *pCtx) {
...
@@ -3476,16 +3476,16 @@ static void diff_function(SQLFunctionCtx *pCtx) {
char
*
getScalarExprColumnData
(
void
*
param
,
const
char
*
name
,
int32_t
colId
)
{
char
*
getScalarExprColumnData
(
void
*
param
,
const
char
*
name
,
int32_t
colId
)
{
SScalarExprSupport
*
pSupport
=
(
SScalarExprSupport
*
)
param
;
SScalarExprSupport
*
pSupport
=
(
SScalarExprSupport
*
)
param
;
int32_t
i
nde
x
=
-
1
;
int32_t
i
d
x
=
-
1
;
for
(
int32_t
i
=
0
;
i
<
pSupport
->
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pSupport
->
numOfCols
;
++
i
)
{
if
(
colId
==
pSupport
->
colList
[
i
].
colId
)
{
if
(
colId
==
pSupport
->
colList
[
i
].
colId
)
{
i
nde
x
=
i
;
i
d
x
=
i
;
break
;
break
;
}
}
}
}
assert
(
i
nde
x
>=
0
);
assert
(
i
d
x
>=
0
);
return
pSupport
->
data
[
i
ndex
]
+
pSupport
->
offset
*
pSupport
->
colList
[
inde
x
].
bytes
;
return
pSupport
->
data
[
i
dx
]
+
pSupport
->
offset
*
pSupport
->
colList
[
id
x
].
bytes
;
}
}
static
void
scalar_expr_function
(
SQLFunctionCtx
*
pCtx
)
{
static
void
scalar_expr_function
(
SQLFunctionCtx
*
pCtx
)
{
...
@@ -3694,14 +3694,14 @@ static double twa_get_area(SPoint1 s, SPoint1 e) {
...
@@ -3694,14 +3694,14 @@ static double twa_get_area(SPoint1 s, SPoint1 e) {
return
val
;
return
val
;
}
}
static
int32_t
twa_function_impl
(
SQLFunctionCtx
*
pCtx
,
int32_t
i
nde
x
,
int32_t
size
)
{
static
int32_t
twa_function_impl
(
SQLFunctionCtx
*
pCtx
,
int32_t
i
d
x
,
int32_t
size
)
{
int32_t
notNullElems
=
0
;
int32_t
notNullElems
=
0
;
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
STwaInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
STwaInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
TSKEY
*
tsList
=
GET_TS_LIST
(
pCtx
);
TSKEY
*
tsList
=
GET_TS_LIST
(
pCtx
);
int32_t
i
=
i
nde
x
;
int32_t
i
=
i
d
x
;
int32_t
step
=
GET_FORWARD_DIRECTION_FACTOR
(
pCtx
->
order
);
int32_t
step
=
GET_FORWARD_DIRECTION_FACTOR
(
pCtx
->
order
);
SPoint1
*
last
=
&
pInfo
->
p
;
SPoint1
*
last
=
&
pInfo
->
p
;
...
@@ -3712,7 +3712,7 @@ static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t index, int32_t si
...
@@ -3712,7 +3712,7 @@ static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t index, int32_t si
assert
(
last
->
key
==
INT64_MIN
);
assert
(
last
->
key
==
INT64_MIN
);
last
->
key
=
tsList
[
i
];
last
->
key
=
tsList
[
i
];
GET_TYPED_DATA
(
last
->
val
,
double
,
pCtx
->
inputType
,
GET_INPUT_DATA
(
pCtx
,
i
nde
x
));
GET_TYPED_DATA
(
last
->
val
,
double
,
pCtx
->
inputType
,
GET_INPUT_DATA
(
pCtx
,
i
d
x
));
pInfo
->
dOutput
+=
twa_get_area
(
pCtx
->
start
,
*
last
);
pInfo
->
dOutput
+=
twa_get_area
(
pCtx
->
start
,
*
last
);
...
@@ -3722,7 +3722,7 @@ static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t index, int32_t si
...
@@ -3722,7 +3722,7 @@ static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t index, int32_t si
i
+=
step
;
i
+=
step
;
}
else
if
(
pInfo
->
p
.
key
==
INT64_MIN
)
{
}
else
if
(
pInfo
->
p
.
key
==
INT64_MIN
)
{
last
->
key
=
tsList
[
i
];
last
->
key
=
tsList
[
i
];
GET_TYPED_DATA
(
last
->
val
,
double
,
pCtx
->
inputType
,
GET_INPUT_DATA
(
pCtx
,
i
nde
x
));
GET_TYPED_DATA
(
last
->
val
,
double
,
pCtx
->
inputType
,
GET_INPUT_DATA
(
pCtx
,
i
d
x
));
pInfo
->
hasResult
=
DATA_SET_FLAG
;
pInfo
->
hasResult
=
DATA_SET_FLAG
;
pInfo
->
win
.
skey
=
last
->
key
;
pInfo
->
win
.
skey
=
last
->
key
;
...
@@ -4672,13 +4672,13 @@ static SSampleFuncInfo* getSampleFuncOutputInfo(SQLFunctionCtx *pCtx) {
...
@@ -4672,13 +4672,13 @@ static SSampleFuncInfo* getSampleFuncOutputInfo(SQLFunctionCtx *pCtx) {
}
}
}
}
static
void
assignResultSample
(
SQLFunctionCtx
*
pCtx
,
SSampleFuncInfo
*
pInfo
,
int32_t
i
nde
x
,
int64_t
ts
,
void
*
pData
,
uint16_t
type
,
int16_t
bytes
,
char
*
inputTags
)
{
static
void
assignResultSample
(
SQLFunctionCtx
*
pCtx
,
SSampleFuncInfo
*
pInfo
,
int32_t
i
d
x
,
int64_t
ts
,
void
*
pData
,
uint16_t
type
,
int16_t
bytes
,
char
*
inputTags
)
{
assignVal
(
pInfo
->
values
+
i
nde
x
*
bytes
,
pData
,
bytes
,
type
);
assignVal
(
pInfo
->
values
+
i
d
x
*
bytes
,
pData
,
bytes
,
type
);
*
(
pInfo
->
timeStamps
+
i
nde
x
)
=
ts
;
*
(
pInfo
->
timeStamps
+
i
d
x
)
=
ts
;
SExtTagsInfo
*
pTagInfo
=
&
pCtx
->
tagInfo
;
SExtTagsInfo
*
pTagInfo
=
&
pCtx
->
tagInfo
;
int32_t
posTag
=
0
;
int32_t
posTag
=
0
;
char
*
tags
=
pInfo
->
taglists
+
i
nde
x
*
pTagInfo
->
tagsLen
;
char
*
tags
=
pInfo
->
taglists
+
i
d
x
*
pTagInfo
->
tagsLen
;
if
(
pCtx
->
currentStage
==
MERGE_STAGE
)
{
if
(
pCtx
->
currentStage
==
MERGE_STAGE
)
{
assert
(
inputTags
!=
NULL
);
assert
(
inputTags
!=
NULL
);
memcpy
(
tags
,
inputTags
,
(
size_t
)
pTagInfo
->
tagsLen
);
memcpy
(
tags
,
inputTags
,
(
size_t
)
pTagInfo
->
tagsLen
);
...
...
src/query/src/qExecutor.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/query/src/qExtbuffer.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/query/src/qFill.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/query/src/qFilter.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/query/src/qHistogram.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/query/src/qPercentile.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/query/src/qPlan.c
浏览文件 @
3e42f5f1
...
@@ -126,9 +126,9 @@ static SQueryNode* doAddTableColumnNode(SQueryInfo* pQueryInfo, STableMetaInfo*
...
@@ -126,9 +126,9 @@ static SQueryNode* doAddTableColumnNode(SQueryInfo* pQueryInfo, STableMetaInfo*
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumn
*
pCol
=
taosArrayGetP
(
tableCols
,
i
);
SColumn
*
pCol
=
taosArrayGetP
(
tableCols
,
i
);
SColumnIndex
i
nde
x
=
{.
tableIndex
=
0
,
.
columnIndex
=
pCol
->
columnIndex
};
SColumnIndex
i
d
x
=
{.
tableIndex
=
0
,
.
columnIndex
=
pCol
->
columnIndex
};
STableMetaInfo
*
pTableMetaInfo1
=
tscGetMetaInfo
(
pQueryInfo
,
i
nde
x
.
tableIndex
);
STableMetaInfo
*
pTableMetaInfo1
=
tscGetMetaInfo
(
pQueryInfo
,
i
d
x
.
tableIndex
);
SExprInfo
*
p
=
tscExprCreate
(
pTableMetaInfo1
,
TSDB_FUNC_PRJ
,
&
i
nde
x
,
pCol
->
info
.
type
,
pCol
->
info
.
bytes
,
SExprInfo
*
p
=
tscExprCreate
(
pTableMetaInfo1
,
TSDB_FUNC_PRJ
,
&
i
d
x
,
pCol
->
info
.
type
,
pCol
->
info
.
bytes
,
pCol
->
info
.
colId
,
0
,
TSDB_COL_NORMAL
);
pCol
->
info
.
colId
,
0
,
TSDB_COL_NORMAL
);
strncpy
(
p
->
base
.
aliasName
,
pSchema
[
pCol
->
columnIndex
].
name
,
tListLen
(
p
->
base
.
aliasName
));
strncpy
(
p
->
base
.
aliasName
,
pSchema
[
pCol
->
columnIndex
].
name
,
tListLen
(
p
->
base
.
aliasName
));
...
...
src/query/src/qSqlParser.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/query/src/qUtil.c
浏览文件 @
3e42f5f1
...
@@ -172,9 +172,9 @@ void clearResultRow(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pResultRow, int16
...
@@ -172,9 +172,9 @@ void clearResultRow(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pResultRow, int16
}
}
// TODO refactor: use macro
// TODO refactor: use macro
SResultRowCellInfo
*
getResultCell
(
const
SResultRow
*
pRow
,
int32_t
i
nde
x
,
int32_t
*
offset
)
{
SResultRowCellInfo
*
getResultCell
(
const
SResultRow
*
pRow
,
int32_t
i
d
x
,
int32_t
*
offset
)
{
assert
(
i
nde
x
>=
0
&&
offset
!=
NULL
);
assert
(
i
d
x
>=
0
&&
offset
!=
NULL
);
return
(
SResultRowCellInfo
*
)((
char
*
)
pRow
->
pCellInfo
+
offset
[
i
nde
x
]);
return
(
SResultRowCellInfo
*
)((
char
*
)
pRow
->
pCellInfo
+
offset
[
i
d
x
]);
}
}
size_t
getResultRowSize
(
SQueryRuntimeEnv
*
pRuntimeEnv
)
{
size_t
getResultRowSize
(
SQueryRuntimeEnv
*
pRuntimeEnv
)
{
...
...
src/query/src/queryMain.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/rpc/src/rpcCache.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/rpc/src/rpcTcp.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/rpc/src/rpcUdp.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/rpc/test/rclient.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/rpc/test/rsclient.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/rpc/test/rserver.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/sync/src/syncMain.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/sync/src/syncRetrieve.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/tsdb/src/tsdbCommit.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/tsdb/src/tsdbFS.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/tsdb/src/tsdbMain.c
浏览文件 @
3e42f5f1
...
@@ -343,7 +343,7 @@ int32_t tsdbConfigRepo(STsdbRepo *repo, STsdbCfg *pCfg) {
...
@@ -343,7 +343,7 @@ int32_t tsdbConfigRepo(STsdbRepo *repo, STsdbCfg *pCfg) {
#endif
#endif
}
}
uint32_t
tsdbGetFileInfo
(
STsdbRepo
*
repo
,
char
*
name
,
uint32_t
*
index
,
uint32_t
eindex
,
int64_t
*
size
)
{
uint32_t
tsdbGetFileInfo
(
STsdbRepo
*
repo
,
char
*
name
,
uint32_t
*
s
index
,
uint32_t
eindex
,
int64_t
*
size
)
{
// TODO
// TODO
return
0
;
return
0
;
#if 0
#if 0
...
...
src/tsdb/src/tsdbMeta.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/tsdb/src/tsdbRead.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/util/src/hash.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/util/src/tarray.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/util/src/tcache.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/util/src/tcompare.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/util/src/tmempool.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/util/src/tnettest.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/util/src/tref.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/vnode/src/vnodeMain.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/vnode/src/vnodeSync.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
src/wal/test/waltest.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
tests/tsim/src/simExe.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
tests/tsim/src/simParse.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
tests/tsim/src/simSystem.c
浏览文件 @
3e42f5f1
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录