Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
afcc90a4
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看板
提交
afcc90a4
编写于
6月 24, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-719]
上级
5d87d141
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
35 addition
and
60 deletion
+35
-60
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+2
-6
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+31
-52
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+1
-1
src/inc/taosdef.h
src/inc/taosdef.h
+1
-1
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
afcc90a4
...
...
@@ -171,11 +171,7 @@ typedef struct STableDataBlocks {
* to avoid it to be removed from cache
*/
STableMeta
*
pTableMeta
;
union
{
char
*
filename
;
char
*
pData
;
};
char
*
pData
;
// for parameter ('?') binding
uint32_t
numOfAllocedParams
;
...
...
@@ -398,7 +394,7 @@ void waitForQueryRsp(void *param, TAOS_RES *tres, int code) ;
int
doAsyncParseSql
(
SSqlObj
*
pSql
);
void
doAsyncQuery
(
STscObj
*
pObj
,
SSqlObj
*
pSql
,
void
(
*
fp
)(),
void
*
param
,
const
char
*
sqlstr
,
size_t
sqlLen
);
void
tscProcessMultiVnodesI
nse
rtFromFile
(
SSqlObj
*
pSql
);
void
tscProcessMultiVnodesI
mpo
rtFromFile
(
SSqlObj
*
pSql
);
void
tscKillSTableQuery
(
SSqlObj
*
pSql
);
void
tscInitResObjForLocalQuery
(
SSqlObj
*
pObj
,
int32_t
numOfRes
,
int32_t
rowLen
);
bool
tscIsUpdateQuery
(
SSqlObj
*
pSql
);
...
...
src/client/src/tscParseInsert.c
浏览文件 @
afcc90a4
...
...
@@ -1153,29 +1153,19 @@ int tsParseInsertSql(SSqlObj *pSql) {
goto
_error
;
}
char
fname
[
PATH_MAX
]
=
{
0
};
strncpy
(
fname
,
sToken
.
z
,
sToken
.
n
);
strdequote
(
fname
);
strncpy
(
pCmd
->
payload
,
sToken
.
z
,
sToken
.
n
);
strdequote
(
pCmd
->
payload
);
// todo refactor extract method
wordexp_t
full_path
;
if
(
wordexp
(
fname
,
&
full_path
,
0
)
!=
0
)
{
if
(
wordexp
(
pCmd
->
payload
,
&
full_path
,
0
)
!=
0
)
{
code
=
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
"invalid filename"
,
sToken
.
z
);
goto
_error
;
}
strcpy
(
fname
,
full_path
.
we_wordv
[
0
]);
wordfree
(
&
full_path
);
STableDataBlocks
*
pDataBlock
=
NULL
;
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
int32_t
ret
=
tscCreateDataBlock
(
PATH_MAX
,
tinfo
.
rowSize
,
sizeof
(
SSubmitBlk
),
pTableMetaInfo
->
name
,
pTableMeta
,
&
pDataBlock
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
tstrncpy
(
pCmd
->
payload
,
full_path
.
we_wordv
[
0
],
pCmd
->
allocSize
);
wordfree
(
&
full_path
);
taosArrayPush
(
pCmd
->
pDataBlocks
,
&
pDataBlock
);
strcpy
(
pDataBlock
->
filename
,
fname
);
}
else
if
(
sToken
.
type
==
TK_LP
)
{
/* insert into tablename(col1, col2,..., coln) values(v1, v2,... vn); */
STableMeta
*
pTableMeta
=
tscGetTableMetaInfoFromCmd
(
pCmd
,
pCmd
->
clauseIndex
,
0
)
->
pTableMeta
;
...
...
@@ -1424,10 +1414,18 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int code) {
int32_t
count
=
0
;
int32_t
maxRows
=
0
;
STableDataBlocks
*
pTableDataBlock
=
taosArrayGetP
(
pSql
->
cmd
.
pDataBlocks
,
0
);
p
TableDataBlock
->
size
=
pTableDataBlock
->
headerSize
;
tscDestroyBlockArrayList
(
pSql
->
cmd
.
pDataBlocks
);
p
Cmd
->
pDataBlocks
=
taosArrayInit
(
1
,
POINTER_BYTES
)
;
STableDataBlocks
*
pTableDataBlock
=
NULL
;
int32_t
ret
=
tscCreateDataBlock
(
TSDB_PAYLOAD_SIZE
,
tinfo
.
rowSize
,
sizeof
(
SSubmitBlk
),
pTableMetaInfo
->
name
,
pTableMeta
,
&
pTableDataBlock
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
// return ret;
}
taosArrayPush
(
pCmd
->
pDataBlocks
,
&
pTableDataBlock
);
tscAllocateMemIfNeed
(
pTableDataBlock
,
tinfo
.
rowSize
,
&
maxRows
);
char
*
tokenBuf
=
calloc
(
1
,
4096
);
while
((
readLen
=
getline
(
&
line
,
&
n
,
fp
))
!=
-
1
)
{
...
...
@@ -1559,52 +1557,33 @@ static UNUSED_FUNC int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp, char *tmpT
return
numOfRows
;
}
void
tscProcessMultiVnodesI
nse
rtFromFile
(
SSqlObj
*
pSql
)
{
void
tscProcessMultiVnodesI
mpo
rtFromFile
(
SSqlObj
*
pSql
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
if
(
pCmd
->
command
!=
TSDB_SQL_INSERT
)
{
return
;
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
STableComInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
assert
(
pCmd
->
dataSourceType
==
DATA_FROM_DATA_FILE
/* && pCmd->pDataBlocks != NULL*/
);
SArray
*
pDataBlockList
=
pCmd
->
pDataBlocks
;
STableDataBlocks
*
pDataBlock
=
taosArrayGetP
(
pDataBlockList
,
0
);
char
path
[
PATH_MAX
]
=
{
0
};
SImportFileSupport
*
pSupporter
=
calloc
(
1
,
sizeof
(
SImportFileSupport
));
pSupporter
->
pSql
=
pSql
;
assert
(
pCmd
->
dataSourceType
==
DATA_FROM_DATA_FILE
&&
strlen
(
pCmd
->
payload
)
!=
0
);
SImportFileSupport
*
pSupporter
=
calloc
(
1
,
sizeof
(
SImportFileSupport
));
SSqlObj
*
pNew
=
createSubqueryObj
(
pSql
,
0
,
parseFileSendDataBlock
,
pSupporter
,
TSDB_SQL_INSERT
,
NULL
);
pNew
->
cmd
.
pDataBlocks
=
taosArrayInit
(
4
,
POINTER_BYTES
);
pCmd
->
count
=
1
;
STableDataBlocks
*
pTableDataBlock
=
NULL
;
int32_t
ret
=
tscCreateDataBlock
(
TSDB_PAYLOAD_SIZE
,
tinfo
.
rowSize
,
sizeof
(
SSubmitBlk
),
pTableMetaInfo
->
name
,
pTableMeta
,
&
pTableDataBlock
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
// return ret;
}
taosArrayPush
(
pNew
->
cmd
.
pDataBlocks
,
&
pTableDataBlock
);
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
TSDB_PAYLOAD_SIZE
))
{
tscError
(
"%p failed to malloc when insert file"
,
pSql
);
}
pCmd
->
count
=
1
;
FILE
*
fp
=
fopen
(
pCmd
->
payload
,
"r"
);
if
(
fp
==
NULL
)
{
pSql
->
res
.
code
=
TAOS_SYSTEM_ERROR
(
errno
);
tscError
(
"%p failed to open file %s to load data from file, code:%s"
,
pSql
,
pCmd
->
payload
,
tstrerror
(
pSql
->
res
.
code
));
tstrncpy
(
path
,
pDataBlock
->
filename
,
sizeof
(
path
));
tfree
(
pSupporter
)
tscQueueAsyncRes
(
pSql
);
FILE
*
fp
=
fopen
(
path
,
"r"
);
if
(
fp
==
NULL
)
{
tscError
(
"%p failed to open file %s to load data from file, reason:%s"
,
pSql
,
path
,
strerror
(
errno
));
// continue;// todo handle error
}
return
;
}
pSupporter
->
fp
=
fp
;
pSupporter
->
pSql
=
pSql
;
pSupporter
->
fp
=
fp
;
parseFileSendDataBlock
(
pSupporter
,
pNew
,
0
);
parseFileSendDataBlock
(
pSupporter
,
pNew
,
0
);
}
src/client/src/tscUtil.c
浏览文件 @
afcc90a4
...
...
@@ -1880,7 +1880,7 @@ void tscDoQuery(SSqlObj* pSql) {
}
if
(
pCmd
->
dataSourceType
==
DATA_FROM_DATA_FILE
)
{
tscProcessMultiVnodesI
nse
rtFromFile
(
pSql
);
tscProcessMultiVnodesI
mpo
rtFromFile
(
pSql
);
}
else
{
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
uint16_t
type
=
pQueryInfo
->
type
;
...
...
src/inc/taosdef.h
浏览文件 @
afcc90a4
...
...
@@ -245,7 +245,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
#define TSDB_DEFAULT_PKT_SIZE 65480 //same as RPC_MAX_UDP_SIZE
#define TSDB_PAYLOAD_SIZE TSDB_DEFAULT_PKT_SIZE
#define TSDB_DEFAULT_PAYLOAD_SIZE
2048 // default payload siz
e
#define TSDB_DEFAULT_PAYLOAD_SIZE
5120 // default payload size, greater than PATH_MAX valu
e
#define TSDB_EXTRA_PAYLOAD_SIZE 128 // extra bytes for auth
#define TSDB_CQ_SQL_SIZE 1024
#define TSDB_MAX_VNODES 256
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录