Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5a6d3762
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5a6d3762
编写于
12月 05, 2019
作者:
L
lihui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[1292]
上级
60629d31
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
61 addition
and
14 deletion
+61
-14
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+52
-13
src/kit/shell/src/shellEngine.c
src/kit/shell/src/shellEngine.c
+2
-0
src/util/src/ttokenizer.c
src/util/src/ttokenizer.c
+7
-1
未找到文件。
src/client/src/tscParseInsert.c
浏览文件 @
5a6d3762
...
...
@@ -392,7 +392,7 @@ static int32_t tsCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start
}
int
tsParseOneRowData
(
char
**
str
,
STableDataBlocks
*
pDataBlocks
,
SSchema
schema
[],
SParsedDataColInfo
*
spd
,
char
*
error
,
int16_t
timePrec
)
{
int16_t
timePrec
,
int32_t
*
code
,
char
*
tmpTokenBuf
)
{
int32_t
index
=
0
;
bool
isPrevOptr
;
SSQLToken
sToken
=
{
0
};
...
...
@@ -418,6 +418,7 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[
}
strcpy
(
error
,
"client out of memory"
);
*
code
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
return
-
1
;
}
...
...
@@ -425,23 +426,42 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[
(
sToken
.
type
!=
TK_FLOAT
)
&&
(
sToken
.
type
!=
TK_BOOL
)
&&
(
sToken
.
type
!=
TK_NULL
))
||
(
sToken
.
n
==
0
)
||
(
sToken
.
type
==
TK_RP
))
{
tscInvalidSQLErrMsg
(
error
,
"invalid data or symbol"
,
sToken
.
z
);
*
code
=
TSDB_CODE_INVALID_SQL
;
return
-
1
;
}
// Remove quotation marks
if
(
TK_STRING
==
sToken
.
type
)
{
sToken
.
z
++
;
sToken
.
n
-=
2
;
// delete escape character: \\, \', \"
char
delim
=
sToken
.
z
[
0
];
int32_t
cnt
=
0
;
int32_t
j
=
0
;
for
(
int32_t
i
=
1
;
i
<
sToken
.
n
-
1
;
++
i
)
{
if
(
sToken
.
z
[
i
]
==
delim
||
sToken
.
z
[
i
]
==
'\\'
)
{
if
(
sToken
.
z
[
i
+
1
]
==
delim
)
{
cnt
++
;
continue
;
}
}
tmpTokenBuf
[
j
]
=
sToken
.
z
[
i
];
j
++
;
}
sToken
.
z
=
tmpTokenBuf
;
sToken
.
n
-=
2
+
cnt
;
}
bool
isPrimaryKey
=
(
colIndex
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
);
int32_t
ret
=
tsParseOneColumnData
(
pSchema
,
&
sToken
,
start
,
error
,
str
,
isPrimaryKey
,
timePrec
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
*
code
=
TSDB_CODE_INVALID_SQL
;
return
-
1
;
// NOTE: here 0 mean error!
}
if
(
isPrimaryKey
&&
tsCheckTimestamp
(
pDataBlocks
,
start
)
!=
TSDB_CODE_SUCCESS
)
{
tscInvalidSQLErrMsg
(
error
,
"client time/server time can not be mixed up"
,
sToken
.
z
);
*
code
=
TSDB_CODE_INVALID_TIME_STAMP
;
return
-
1
;
}
}
...
...
@@ -476,7 +496,7 @@ static int32_t rowDataCompar(const void *lhs, const void *rhs) {
}
int
tsParseValues
(
char
**
str
,
STableDataBlocks
*
pDataBlock
,
SMeterMeta
*
pMeterMeta
,
int
maxRows
,
SParsedDataColInfo
*
spd
,
char
*
error
)
{
SParsedDataColInfo
*
spd
,
char
*
error
,
int32_t
*
code
,
char
*
tmpTokenBuf
)
{
int32_t
index
=
0
;
SSQLToken
sToken
;
...
...
@@ -487,6 +507,7 @@ int tsParseValues(char **str, STableDataBlocks *pDataBlock, SMeterMeta *pMeterMe
if
(
spd
->
hasVal
[
0
]
==
false
)
{
strcpy
(
error
,
"primary timestamp column can not be null"
);
*
code
=
TSDB_CODE_INVALID_SQL
;
return
-
1
;
}
...
...
@@ -500,12 +521,13 @@ int tsParseValues(char **str, STableDataBlocks *pDataBlock, SMeterMeta *pMeterMe
int32_t
tSize
=
tscAllocateMemIfNeed
(
pDataBlock
,
pMeterMeta
->
rowSize
);
if
(
0
==
tSize
)
{
strcpy
(
error
,
"client out of memory"
);
*
code
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
return
-
1
;
}
maxRows
+=
tSize
;
}
int32_t
len
=
tsParseOneRowData
(
str
,
pDataBlock
,
pSchema
,
spd
,
error
,
precision
);
int32_t
len
=
tsParseOneRowData
(
str
,
pDataBlock
,
pSchema
,
spd
,
error
,
precision
,
code
,
tmpTokenBuf
);
if
(
len
<=
0
)
{
// error message has been set in tsParseOneRowData
return
-
1
;
}
...
...
@@ -517,6 +539,7 @@ int tsParseValues(char **str, STableDataBlocks *pDataBlock, SMeterMeta *pMeterMe
*
str
+=
index
;
if
(
sToken
.
n
==
0
||
sToken
.
type
!=
TK_RP
)
{
tscInvalidSQLErrMsg
(
error
,
") expected"
,
*
str
);
*
code
=
TSDB_CODE_INVALID_SQL
;
return
-
1
;
}
...
...
@@ -525,6 +548,7 @@ int tsParseValues(char **str, STableDataBlocks *pDataBlock, SMeterMeta *pMeterMe
if
(
numOfRows
<=
0
)
{
strcpy
(
error
,
"no any data points"
);
*
code
=
TSDB_CODE_INVALID_SQL
;
return
-
1
;
}
else
{
return
numOfRows
;
...
...
@@ -637,9 +661,16 @@ static int32_t doParseInsertStatement(SSqlObj *pSql, void *pTableHashList, char
return
TSDB_CODE_CLI_OUT_OF_MEMORY
;
}
int32_t
numOfRows
=
tsParseValues
(
str
,
dataBuf
,
pMeterMeta
,
maxNumOfRows
,
spd
,
pCmd
->
payload
);
int32_t
code
=
TSDB_CODE_INVALID_SQL
;
char
*
tmpTokenBuf
=
calloc
(
1
,
4096
);
// used for deleting Escape character: \\, \', \"
if
(
NULL
==
tmpTokenBuf
)
{
return
TSDB_CODE_CLI_OUT_OF_MEMORY
;
}
int32_t
numOfRows
=
tsParseValues
(
str
,
dataBuf
,
pMeterMeta
,
maxNumOfRows
,
spd
,
pCmd
->
payload
,
&
code
,
tmpTokenBuf
);
free
(
tmpTokenBuf
);
if
(
numOfRows
<=
0
)
{
return
TSDB_CODE_INVALID_SQL
;
return
code
;
}
for
(
uint32_t
i
=
0
;
i
<
dataBuf
->
numOfParams
;
++
i
)
{
...
...
@@ -1173,7 +1204,7 @@ static int doPackSendDataBlock(SSqlObj *pSql, int32_t numOfRows, STableDataBlock
return
TSDB_CODE_SUCCESS
;
}
static
int
tscInsertDataFromFile
(
SSqlObj
*
pSql
,
FILE
*
fp
)
{
static
int
tscInsertDataFromFile
(
SSqlObj
*
pSql
,
FILE
*
fp
,
char
*
tmpTokenBuf
)
{
size_t
readLen
=
0
;
char
*
line
=
NULL
;
size_t
n
=
0
;
...
...
@@ -1216,10 +1247,10 @@ static int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp) {
maxRows
+=
tSize
;
}
len
=
tsParseOneRowData
(
&
lineptr
,
pTableDataBlock
,
pSchema
,
&
spd
,
pCmd
->
payload
,
pMeterMeta
->
precision
);
len
=
tsParseOneRowData
(
&
lineptr
,
pTableDataBlock
,
pSchema
,
&
spd
,
pCmd
->
payload
,
pMeterMeta
->
precision
,
&
code
,
tmpTokenBuf
);
if
(
len
<=
0
||
pTableDataBlock
->
numOfParams
>
0
)
{
pSql
->
res
.
code
=
TSDB_CODE_INVALID_SQL
;
return
-
1
;
pSql
->
res
.
code
=
code
;
return
(
-
code
)
;
}
pTableDataBlock
->
size
+=
len
;
...
...
@@ -1349,7 +1380,15 @@ void tscProcessMultiVnodesInsertForFile(SSqlObj *pSql) {
continue
;
}
int
nrows
=
tscInsertDataFromFile
(
pSql
,
fp
);
char
*
tmpTokenBuf
=
calloc
(
1
,
4096
);
// used for deleting Escape character: \\, \', \"
if
(
NULL
==
tmpTokenBuf
)
{
tscError
(
"%p calloc failed"
,
pSql
);
continue
;
}
int
nrows
=
tscInsertDataFromFile
(
pSql
,
fp
,
tmpTokenBuf
);
free
(
tmpTokenBuf
);
pCmd
->
pDataBlocks
=
tscDestroyBlockArrayList
(
pCmd
->
pDataBlocks
);
if
(
nrows
<
0
)
{
...
...
src/kit/shell/src/shellEngine.c
浏览文件 @
5a6d3762
...
...
@@ -151,6 +151,8 @@ void shellReplaceCtrlChar(char *str) {
}
break
;
default:
*
pstr
=
*
str
;
pstr
++
;
break
;
}
ctrlOn
=
false
;
...
...
src/util/src/ttokenizer.c
浏览文件 @
5a6d3762
...
...
@@ -418,7 +418,12 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
int
delim
=
z
[
0
];
bool
strEnd
=
false
;
for
(
i
=
1
;
z
[
i
];
i
++
)
{
if
(
z
[
i
]
==
delim
)
{
if
(
z
[
i
]
==
'\\'
)
{
i
++
;
continue
;
}
if
(
z
[
i
]
==
delim
)
{
if
(
z
[
i
+
1
]
==
delim
)
{
i
++
;
}
else
{
...
...
@@ -427,6 +432,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
}
}
}
if
(
z
[
i
])
i
++
;
if
(
strEnd
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录