Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
148b7835
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
148b7835
编写于
8月 29, 2019
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix the issue #433
上级
1977ea45
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
52 addition
and
10 deletion
+52
-10
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+2
-0
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+48
-9
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+2
-1
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
148b7835
...
...
@@ -171,6 +171,8 @@ typedef struct STagCond {
typedef
struct
STableDataBlocks
{
char
meterId
[
TSDB_METER_ID_LEN
];
int8_t
tsSource
;
int64_t
vgid
;
int64_t
size
;
...
...
src/client/src/tscParseInsert.c
浏览文件 @
148b7835
...
...
@@ -53,6 +53,11 @@
return TSDB_CODE_INVALID_SQL; \
} while (0)
static
enum
{
TSDB_USE_SERVER_TS
=
0
,
TSDB_USE_CLI_TS
=
1
,
};
static
void
setErrMsg
(
char
*
msg
,
char
*
sql
);
static
int32_t
tscAllocateMemIfNeed
(
STableDataBlocks
*
pDataBlock
,
int32_t
rowSize
);
...
...
@@ -166,6 +171,40 @@ int tsParseTime(char *value, int32_t valuelen, int64_t *time, char **next, char
return
TSDB_CODE_SUCCESS
;
}
/*
* The server time/client time should not be mixed up in one sql string
* Do not employ sort operation is not involved if server time is used.
*/
static
int32_t
tsCheckTimestamp
(
STableDataBlocks
*
pDataBlocks
,
const
char
*
start
)
{
// once the data block is disordered, we do NOT keep previous timestamp any more
if
(
!
pDataBlocks
->
ordered
)
{
return
TSDB_CODE_SUCCESS
;
}
TSKEY
k
=
*
(
TSKEY
*
)
start
;
if
(
k
==
0
)
{
if
(
pDataBlocks
->
tsSource
==
TSDB_USE_CLI_TS
)
{
return
-
1
;
}
else
if
(
pDataBlocks
->
tsSource
==
-
1
)
{
pDataBlocks
->
tsSource
=
TSDB_USE_SERVER_TS
;
}
}
else
{
if
(
pDataBlocks
->
tsSource
==
TSDB_USE_SERVER_TS
)
{
return
-
1
;
}
else
if
(
pDataBlocks
->
tsSource
==
-
1
)
{
pDataBlocks
->
tsSource
=
TSDB_USE_CLI_TS
;
}
}
if
(
k
<=
pDataBlocks
->
prevTS
&&
(
pDataBlocks
->
tsSource
==
TSDB_USE_CLI_TS
))
{
pDataBlocks
->
ordered
=
false
;
}
pDataBlocks
->
prevTS
=
k
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
tsParseOneColumnData
(
SSchema
*
pSchema
,
char
*
value
,
int
valuelen
,
char
*
payload
,
char
*
msg
,
char
**
str
,
bool
primaryKey
,
int16_t
timePrec
)
{
int64_t
temp
;
...
...
@@ -391,20 +430,15 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[
valuelen
++
;
}
bool
isPrimaryKey
=
(
colIndex
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
);
int32_t
ret
=
tsParseOneColumnData
(
&
schema
[
colIndex
],
value
,
valuelen
,
start
,
error
,
str
,
colIndex
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
,
timePrec
);
if
(
ret
!=
0
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
-
1
;
// NOTE: here 0 mean error!
}
// once the data block is disordered, we do NOT keep previous timestamp any more
if
(
colIndex
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
&&
pDataBlocks
->
ordered
)
{
TSKEY
k
=
*
(
TSKEY
*
)
start
;
if
(
k
<=
pDataBlocks
->
prevTS
)
{
pDataBlocks
->
ordered
=
false
;
}
pDataBlocks
->
prevTS
=
k
;
if
(
isPrimaryKey
&&
tsCheckTimestamp
(
pDataBlocks
,
start
)
!=
TSDB_CODE_SUCCESS
)
{
return
-
1
;
}
}
...
...
@@ -551,6 +585,11 @@ void sortRemoveDuplicates(STableDataBlocks *dataBuf) {
// size is less than the total size, since duplicated rows may be removed yet.
assert
(
pBlocks
->
numOfRows
*
dataBuf
->
rowSize
+
sizeof
(
SShellSubmitBlock
)
==
dataBuf
->
size
);
// if use server time, this block must be ordered
if
(
dataBuf
->
tsSource
==
TSDB_USE_SERVER_TS
)
{
assert
(
dataBuf
->
ordered
);
}
if
(
!
dataBuf
->
ordered
)
{
char
*
pBlockData
=
pBlocks
->
payLoad
;
qsort
(
pBlockData
,
pBlocks
->
numOfRows
,
dataBuf
->
rowSize
,
rowDataCompar
);
...
...
src/client/src/tscUtil.c
浏览文件 @
148b7835
...
...
@@ -338,7 +338,8 @@ STableDataBlocks* tscCreateDataBlock(int32_t size) {
STableDataBlocks
*
dataBuf
=
(
STableDataBlocks
*
)
calloc
(
1
,
sizeof
(
STableDataBlocks
));
dataBuf
->
nAllocSize
=
(
uint32_t
)
size
;
dataBuf
->
pData
=
calloc
(
1
,
dataBuf
->
nAllocSize
);
dataBuf
->
ordered
=
true
;
dataBuf
->
tsSource
=
-
1
;
dataBuf
->
prevTS
=
INT64_MIN
;
return
dataBuf
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录