Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_50753323
TDengine
提交
07b32ec2
T
TDengine
项目概览
qq_50753323
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
07b32ec2
编写于
12月 21, 2019
作者:
S
slguan
提交者:
GitHub
12月 21, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #985 from taosdata/feature/liaohj
Feature/liaohj
上级
9a0ef41b
f6d56d84
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
155 addition
and
111 deletion
+155
-111
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+18
-13
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+21
-10
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+109
-84
src/inc/taoserror.h
src/inc/taoserror.h
+2
-1
src/rpc/src/tstring.c
src/rpc/src/tstring.c
+2
-1
src/util/src/textbuffer.c
src/util/src/textbuffer.c
+3
-2
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
07b32ec2
...
...
@@ -66,19 +66,24 @@ typedef struct SJoinSubquerySupporter {
char
path
[
PATH_MAX
];
// temporary file path
}
SJoinSubquerySupporter
;
void
tscDestroyDataBlock
(
STableDataBlocks
*
pDataBlock
);
STableDataBlocks
*
tscCreateDataBlock
(
size_t
initialBufSize
,
int32_t
rowSize
,
int32_t
startOffset
,
const
char
*
name
);
void
tscAppendDataBlock
(
SDataBlockList
*
pList
,
STableDataBlocks
*
pBlocks
);
SParamInfo
*
tscAddParamToDataBlock
(
STableDataBlocks
*
pDataBlock
,
char
type
,
uint8_t
timePrec
,
short
bytes
,
uint32_t
offset
);
SDataBlockList
*
tscCreateBlockArrayList
();
void
*
tscDestroyBlockArrayList
(
SDataBlockList
*
pList
);
int32_t
tscCopyDataBlockToPayload
(
SSqlObj
*
pSql
,
STableDataBlocks
*
pDataBlock
);
void
tscFreeUnusedDataBlocks
(
SDataBlockList
*
pList
);
int32_t
tscMergeTableDataBlocks
(
SSqlObj
*
pSql
,
SDataBlockList
*
pDataList
);
STableDataBlocks
*
tscGetDataBlockFromList
(
void
*
pHashList
,
SDataBlockList
*
pDataBlockList
,
int64_t
id
,
int32_t
size
,
int32_t
startOffset
,
int32_t
rowSize
,
const
char
*
tableId
);
int32_t
tscCreateDataBlock
(
size_t
initialSize
,
int32_t
rowSize
,
int32_t
startOffset
,
const
char
*
name
,
STableDataBlocks
**
dataBlocks
);
void
tscAppendDataBlock
(
SDataBlockList
*
pList
,
STableDataBlocks
*
pBlocks
);
void
tscDestroyDataBlock
(
STableDataBlocks
*
pDataBlock
);
SParamInfo
*
tscAddParamToDataBlock
(
STableDataBlocks
*
pDataBlock
,
char
type
,
uint8_t
timePrec
,
short
bytes
,
uint32_t
offset
);
SDataBlockList
*
tscCreateBlockArrayList
();
void
*
tscDestroyBlockArrayList
(
SDataBlockList
*
pList
);
int32_t
tscCopyDataBlockToPayload
(
SSqlObj
*
pSql
,
STableDataBlocks
*
pDataBlock
);
void
tscFreeUnusedDataBlocks
(
SDataBlockList
*
pList
);
int32_t
tscMergeTableDataBlocks
(
SSqlObj
*
pSql
,
SDataBlockList
*
pDataList
);
int32_t
tscGetDataBlockFromList
(
void
*
pHashList
,
SDataBlockList
*
pDataBlockList
,
int64_t
id
,
int32_t
size
,
int32_t
startOffset
,
int32_t
rowSize
,
const
char
*
tableId
,
STableDataBlocks
**
dataBlocks
);
SVnodeSidList
*
tscGetVnodeSidList
(
SMetricMeta
*
pMetricmeta
,
int32_t
vnodeIdx
);
SMeterSidExtInfo
*
tscGetMeterSidInfo
(
SVnodeSidList
*
pSidList
,
int32_t
idx
);
...
...
src/client/src/tscParseInsert.c
浏览文件 @
07b32ec2
...
...
@@ -653,10 +653,13 @@ static int32_t doParseInsertStatement(SSqlObj *pSql, void *pTableHashList, char
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
0
);
SMeterMeta
*
pMeterMeta
=
pMeterMetaInfo
->
pMeterMeta
;
STableDataBlocks
*
dataBuf
=
tscGetDataBlockFromList
(
pTableHashList
,
pCmd
->
pDataBlocks
,
pMeterMeta
->
uid
,
TSDB_DEFAULT_PAYLOAD_SIZE
,
sizeof
(
SShellSubmitBlock
),
pMeterMeta
->
rowSize
,
pMeterMetaInfo
->
name
);
STableDataBlocks
*
dataBuf
=
NULL
;
int32_t
ret
=
tscGetDataBlockFromList
(
pTableHashList
,
pCmd
->
pDataBlocks
,
pMeterMeta
->
uid
,
TSDB_DEFAULT_PAYLOAD_SIZE
,
sizeof
(
SShellSubmitBlock
),
pMeterMeta
->
rowSize
,
pMeterMetaInfo
->
name
,
&
dataBuf
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
}
int32_t
maxNumOfRows
=
tscAllocateMemIfNeed
(
dataBuf
,
pMeterMeta
->
rowSize
);
if
(
0
==
maxNumOfRows
)
{
return
TSDB_CODE_CLI_OUT_OF_MEMORY
;
...
...
@@ -1072,9 +1075,13 @@ int doParserInsertSql(SSqlObj *pSql, char *str) {
strcpy
(
fname
,
full_path
.
we_wordv
[
0
]);
wordfree
(
&
full_path
);
STableDataBlocks
*
pDataBlock
=
tscCreateDataBlock
(
PATH_MAX
,
pMeterMetaInfo
->
pMeterMeta
->
rowSize
,
sizeof
(
SShellSubmitBlock
),
pMeterMetaInfo
->
name
);
STableDataBlocks
*
pDataBlock
=
NULL
;
int32_t
ret
=
tscCreateDataBlock
(
PATH_MAX
,
pMeterMetaInfo
->
pMeterMeta
->
rowSize
,
sizeof
(
SShellSubmitBlock
),
pMeterMetaInfo
->
name
,
&
pDataBlock
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
goto
_error_clean
;
}
tscAppendDataBlock
(
pCmd
->
pDataBlocks
,
pDataBlock
);
strcpy
(
pDataBlock
->
filename
,
fname
);
}
else
if
(
sToken
.
type
==
TK_LP
)
{
...
...
@@ -1314,9 +1321,13 @@ static int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp, char *tmpTokenBuf) {
int32_t
rowSize
=
pMeterMeta
->
rowSize
;
pCmd
->
pDataBlocks
=
tscCreateBlockArrayList
();
STableDataBlocks
*
pTableDataBlock
=
tscCreateDataBlock
(
TSDB_PAYLOAD_SIZE
,
pMeterMeta
->
rowSize
,
sizeof
(
SShellSubmitBlock
),
pMeterMetaInfo
->
name
);
STableDataBlocks
*
pTableDataBlock
=
NULL
;
int32_t
ret
=
tscCreateDataBlock
(
TSDB_PAYLOAD_SIZE
,
pMeterMeta
->
rowSize
,
sizeof
(
SShellSubmitBlock
),
pMeterMetaInfo
->
name
,
&
pTableDataBlock
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
-
1
;
}
tscAppendDataBlock
(
pCmd
->
pDataBlocks
,
pTableDataBlock
);
maxRows
=
tscAllocateMemIfNeed
(
pTableDataBlock
,
rowSize
);
...
...
src/client/src/tscUtil.c
浏览文件 @
07b32ec2
...
...
@@ -22,8 +22,8 @@
#include "tscJoinProcess.h"
#include "tscProfile.h"
#include "tscSecondaryMerge.h"
#include "tscUtil.h"
#include "tschemautil.h"
#include "tscUtil.h"
#include "tsclient.h"
#include "tsqldef.h"
#include "ttimer.h"
...
...
@@ -60,21 +60,20 @@ void tscGetMetricMetaCacheKey(SSqlCmd* pCmd, char* str, uint64_t uid) {
}
// estimate the buffer size
size_t
tbnameCondLen
=
pTagCond
->
tbnameCond
.
cond
!=
NULL
?
strlen
(
pTagCond
->
tbnameCond
.
cond
)
:
0
;
size_t
tbnameCondLen
=
pTagCond
->
tbnameCond
.
cond
!=
NULL
?
strlen
(
pTagCond
->
tbnameCond
.
cond
)
:
0
;
size_t
redundantLen
=
20
;
size_t
bufSize
=
strlen
(
pMeterMetaInfo
->
name
)
+
tbnameCondLen
+
strlen
(
join
)
+
strlen
(
tagIdBuf
);
if
(
cond
!=
NULL
)
{
bufSize
+=
strlen
(
cond
->
cond
);
}
bufSize
=
(
size_t
)
((
bufSize
+
redundantLen
)
*
1
.
5
);
bufSize
=
(
size_t
)((
bufSize
+
redundantLen
)
*
1
.
5
);
char
*
tmp
=
calloc
(
1
,
bufSize
);
int32_t
keyLen
=
snprintf
(
tmp
,
bufSize
,
"%s,%s,%s,%d,%s,[%s],%d"
,
pMeterMetaInfo
->
name
,
(
cond
!=
NULL
?
cond
->
cond
:
NULL
),
(
tbnameCondLen
>
0
?
pTagCond
->
tbnameCond
.
cond
:
NULL
),
pTagCond
->
relType
,
join
,
tagIdBuf
,
pCmd
->
groupbyExpr
.
orderType
);
(
cond
!=
NULL
?
cond
->
cond
:
NULL
),
(
tbnameCondLen
>
0
?
pTagCond
->
tbnameCond
.
cond
:
NULL
),
pTagCond
->
relType
,
join
,
tagIdBuf
,
pCmd
->
groupbyExpr
.
orderType
);
assert
(
keyLen
<=
bufSize
);
...
...
@@ -84,7 +83,7 @@ void tscGetMetricMetaCacheKey(SSqlCmd* pCmd, char* str, uint64_t uid) {
MD5_CTX
ctx
;
MD5Init
(
&
ctx
);
MD5Update
(
&
ctx
,
(
uint8_t
*
)
tmp
,
keyLen
);
MD5Update
(
&
ctx
,
(
uint8_t
*
)
tmp
,
keyLen
);
char
*
pStr
=
base64_encode
(
ctx
.
digest
,
tListLen
(
ctx
.
digest
));
strcpy
(
str
,
pStr
);
}
...
...
@@ -242,11 +241,11 @@ bool tscProjectionQueryOnMetric(SSqlCmd* pCmd) {
return
false
;
}
//for project query, only the following two function is allowed
//
for project query, only the following two function is allowed
for
(
int32_t
i
=
0
;
i
<
pCmd
->
fieldsInfo
.
numOfOutputCols
;
++
i
)
{
int32_t
functionId
=
tscSqlExprGet
(
pCmd
,
i
)
->
functionId
;
if
(
functionId
!=
TSDB_FUNC_PRJ
&&
functionId
!=
TSDB_FUNC_TAGPRJ
&&
functionId
!=
TSDB_FUNC_T
AG
&&
functionId
!=
TSDB_FUNC_T
S
&&
functionId
!=
TSDB_FUNC_ARITHM
)
{
if
(
functionId
!=
TSDB_FUNC_PRJ
&&
functionId
!=
TSDB_FUNC_TAGPRJ
&&
functionId
!=
TSDB_FUNC_TAG
&&
functionId
!=
TSDB_FUNC_TS
&&
functionId
!=
TSDB_FUNC_ARITHM
)
{
return
false
;
}
}
...
...
@@ -261,7 +260,7 @@ bool tscProjectionQueryOnTable(SSqlCmd* pCmd) {
return
false
;
}
}
return
true
;
}
...
...
@@ -458,9 +457,9 @@ void tscDestroyDataBlock(STableDataBlocks* pDataBlock) {
tfree
(
pDataBlock
->
pData
);
tfree
(
pDataBlock
->
params
);
// free the refcount for metermeta
taosRemoveDataFromCache
(
tscCacheHandle
,
(
void
**
)
&
(
pDataBlock
->
pMeterMeta
),
false
);
taosRemoveDataFromCache
(
tscCacheHandle
,
(
void
**
)
&
(
pDataBlock
->
pMeterMeta
),
false
);
tfree
(
pDataBlock
);
}
...
...
@@ -533,23 +532,23 @@ void* tscDestroyBlockArrayList(SDataBlockList* pList) {
}
int32_t
tscCopyDataBlockToPayload
(
SSqlObj
*
pSql
,
STableDataBlocks
*
pDataBlock
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
assert
(
pDataBlock
->
pMeterMeta
!=
NULL
);
pCmd
->
count
=
pDataBlock
->
numOfMeters
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
0
);
//set the correct metermeta object, the metermeta has been locked in pDataBlocks, so it must be in the cache
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
0
);
//
set the correct metermeta object, the metermeta has been locked in pDataBlocks, so it must be in the cache
if
(
pMeterMetaInfo
->
pMeterMeta
!=
pDataBlock
->
pMeterMeta
)
{
strcpy
(
pMeterMetaInfo
->
name
,
pDataBlock
->
meterId
);
taosRemoveDataFromCache
(
tscCacheHandle
,
(
void
**
)
&
(
pMeterMetaInfo
->
pMeterMeta
),
false
);
taosRemoveDataFromCache
(
tscCacheHandle
,
(
void
**
)
&
(
pMeterMetaInfo
->
pMeterMeta
),
false
);
pMeterMetaInfo
->
pMeterMeta
=
pDataBlock
->
pMeterMeta
;
pDataBlock
->
pMeterMeta
=
NULL
;
// delegate the ownership of metermeta to pMeterMetaInfo
pDataBlock
->
pMeterMeta
=
NULL
;
// delegate the ownership of metermeta to pMeterMetaInfo
}
else
{
assert
(
strncmp
(
pMeterMetaInfo
->
name
,
pDataBlock
->
meterId
,
tListLen
(
pDataBlock
->
meterId
))
==
0
);
}
/*
* the submit message consists of : [RPC header|message body|digest]
* the dataBlock only includes the RPC Header buffer and actual submit messsage body, space for digest needs
...
...
@@ -559,15 +558,15 @@ int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock) {
if
(
TSDB_CODE_SUCCESS
!=
ret
)
{
return
ret
;
}
memcpy
(
pCmd
->
payload
,
pDataBlock
->
pData
,
pDataBlock
->
nAllocSize
);
/*
* the payloadLen should be actual message body size
* the old value of payloadLen is the allocated payload size
*/
pCmd
->
payloadLen
=
pDataBlock
->
nAllocSize
-
tsRpcHeadSize
;
assert
(
pCmd
->
allocSize
>=
pCmd
->
payloadLen
+
tsRpcHeadSize
+
sizeof
(
STaosDigest
));
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -587,13 +586,18 @@ void tscFreeUnusedDataBlocks(SDataBlockList* pList) {
* @param rowSize
* @param startOffset
* @param name
* @param
pMeterMeta the ownership of pMeterMeta should be transfer to STableD
ataBlocks
* @param
d
ataBlocks
* @return
*/
STableDataBlocks
*
tscCreateDataBlock
(
size_t
initialSize
,
int32_t
rowSize
,
int32_t
startOffset
,
const
char
*
name
)
{
int32_t
tscCreateDataBlock
(
size_t
initialSize
,
int32_t
rowSize
,
int32_t
startOffset
,
const
char
*
name
,
STableDataBlocks
**
dataBlocks
)
{
STableDataBlocks
*
dataBuf
=
(
STableDataBlocks
*
)
calloc
(
1
,
sizeof
(
STableDataBlocks
));
dataBuf
->
nAllocSize
=
(
uint32_t
)
initialSize
;
if
(
dataBuf
==
NULL
)
{
tscError
(
"failed to allocated memory, reason:%s"
,
strerror
(
errno
));
return
TSDB_CODE_CLI_OUT_OF_MEMORY
;
}
dataBuf
->
nAllocSize
=
(
uint32_t
)
initialSize
;
dataBuf
->
pData
=
calloc
(
1
,
dataBuf
->
nAllocSize
);
dataBuf
->
ordered
=
true
;
dataBuf
->
prevTS
=
INT64_MIN
;
...
...
@@ -603,30 +607,44 @@ STableDataBlocks* tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_
dataBuf
->
tsSource
=
-
1
;
strncpy
(
dataBuf
->
meterId
,
name
,
TSDB_METER_ID_LEN
);
// sure that the metermeta must be in the local client cache
/*
* The metermeta may be released since the metermeta cache are completed clean by other thread
* due to operation such as drop database.
*/
dataBuf
->
pMeterMeta
=
taosGetDataFromCache
(
tscCacheHandle
,
dataBuf
->
meterId
);
assert
(
dataBuf
->
pMeterMeta
!=
NULL
&&
initialSize
>
0
);
assert
(
initialSize
>
0
);
return
dataBuf
;
if
(
dataBuf
->
pMeterMeta
==
NULL
)
{
tfree
(
dataBuf
);
return
TSDB_CODE_QUERY_CACHE_ERASED
;
}
else
{
*
dataBlocks
=
dataBuf
;
return
TSDB_CODE_SUCCESS
;
}
}
STableDataBlocks
*
tscGetDataBlockFromList
(
void
*
pHashList
,
SDataBlockList
*
pDataBlockList
,
int64_t
id
,
int32_t
size
,
int32_t
startOffset
,
int32_t
rowSize
,
const
char
*
tableId
)
{
STableDataBlocks
*
dataBuf
=
NULL
;
int32_t
tscGetDataBlockFromList
(
void
*
pHashList
,
SDataBlockList
*
pDataBlockList
,
int64_t
id
,
int32_t
size
,
int32_t
startOffset
,
int32_t
rowSize
,
const
char
*
tableId
,
STableDataBlocks
**
dataBlocks
)
{
*
dataBlocks
=
NULL
;
STableDataBlocks
**
t1
=
(
STableDataBlocks
**
)
taosGetIntHashData
(
pHashList
,
id
);
STableDataBlocks
**
t1
=
(
STableDataBlocks
**
)
taosGetIntHashData
(
pHashList
,
id
);
if
(
t1
!=
NULL
)
{
dataBuf
=
*
t1
;
*
dataBlocks
=
*
t1
;
}
if
(
dataBuf
==
NULL
)
{
dataBuf
=
tscCreateDataBlock
((
size_t
)
size
,
rowSize
,
startOffset
,
tableId
);
dataBuf
=
*
(
STableDataBlocks
**
)
taosAddIntHash
(
pHashList
,
id
,
(
char
*
)
&
dataBuf
);
tscAppendDataBlock
(
pDataBlockList
,
dataBuf
);
if
(
*
dataBlocks
==
NULL
)
{
int32_t
ret
=
tscCreateDataBlock
((
size_t
)
size
,
rowSize
,
startOffset
,
tableId
,
dataBlocks
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
}
*
dataBlocks
=
*
(
STableDataBlocks
**
)
taosAddIntHash
(
pHashList
,
id
,
(
char
*
)(
*
dataBlocks
));
tscAppendDataBlock
(
pDataBlockList
,
*
dataBlocks
);
}
return
dataBuf
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
tscMergeTableDataBlocks
(
SSqlObj
*
pSql
,
SDataBlockList
*
pTableDataBlockList
)
{
...
...
@@ -638,9 +656,15 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, SDataBlockList* pTableDataBlockLi
for
(
int32_t
i
=
0
;
i
<
pTableDataBlockList
->
nSize
;
++
i
)
{
STableDataBlocks
*
pOneTableBlock
=
pTableDataBlockList
->
pData
[
i
];
STableDataBlocks
*
dataBuf
=
tscGetDataBlockFromList
(
pVnodeDataBlockHashList
,
pVnodeDataBlockList
,
pOneTableBlock
->
vgid
,
TSDB_PAYLOAD_SIZE
,
tsInsertHeadSize
,
0
,
pOneTableBlock
->
meterId
);
STableDataBlocks
*
dataBuf
=
NULL
;
int32_t
ret
=
tscGetDataBlockFromList
(
pVnodeDataBlockHashList
,
pVnodeDataBlockList
,
pOneTableBlock
->
vgid
,
TSDB_PAYLOAD_SIZE
,
tsInsertHeadSize
,
0
,
pOneTableBlock
->
meterId
,
&
dataBuf
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"%p failed to allocate the data buffer block for merging table data"
,
pSql
);
tscDestroyBlockArrayList
(
pTableDataBlockList
);
return
ret
;
}
int64_t
destSize
=
dataBuf
->
size
+
pOneTableBlock
->
size
;
if
(
dataBuf
->
nAllocSize
<
destSize
)
{
...
...
@@ -705,7 +729,7 @@ void tscCloseTscObj(STscObj* pObj) {
}
bool
tscIsInsertOrImportData
(
char
*
sqlstr
)
{
int32_t
index
=
0
;
int32_t
index
=
0
;
SSQLToken
t0
=
tStrGetToken
(
sqlstr
,
&
index
,
false
,
0
,
NULL
);
return
t0
.
type
==
TK_INSERT
||
t0
.
type
==
TK_IMPORT
;
}
...
...
@@ -946,13 +970,13 @@ static void _exprEvic(SSqlExprInfo* pExprInfo, int32_t index) {
SSqlExpr
*
tscSqlExprInsertEmpty
(
SSqlCmd
*
pCmd
,
int32_t
index
,
int16_t
functionId
)
{
SSqlExprInfo
*
pExprInfo
=
&
pCmd
->
exprsInfo
;
_exprCheckSpace
(
pExprInfo
,
pExprInfo
->
numOfExprs
+
1
);
_exprEvic
(
pExprInfo
,
index
);
SSqlExpr
*
pExpr
=
&
pExprInfo
->
pExprs
[
index
];
pExpr
->
functionId
=
functionId
;
pExprInfo
->
numOfExprs
++
;
return
pExpr
;
}
...
...
@@ -1155,7 +1179,7 @@ SColumnBase* tscColumnBaseInfoInsert(SSqlCmd* pCmd, SColumnIndex* pColIndex) {
}
void
tscColumnFilterInfoCopy
(
SColumnFilterInfo
*
dst
,
const
SColumnFilterInfo
*
src
)
{
assert
(
src
!=
NULL
&&
dst
!=
NULL
);
assert
(
src
!=
NULL
&&
dst
!=
NULL
);
assert
(
src
->
filterOnBinary
==
0
||
src
->
filterOnBinary
==
1
);
if
(
src
->
lowerRelOptr
==
TSDB_RELATION_INVALID
&&
src
->
upperRelOptr
==
TSDB_RELATION_INVALID
)
{
...
...
@@ -1164,15 +1188,15 @@ void tscColumnFilterInfoCopy(SColumnFilterInfo* dst, const SColumnFilterInfo* sr
*
dst
=
*
src
;
if
(
dst
->
filterOnBinary
)
{
size_t
len
=
(
size_t
)
dst
->
len
+
1
;
char
*
pTmp
=
calloc
(
1
,
len
);
dst
->
pz
=
(
int64_t
)
pTmp
;
memcpy
((
char
*
)
dst
->
pz
,
(
char
*
)
src
->
pz
,
(
size_t
)
len
);
size_t
len
=
(
size_t
)
dst
->
len
+
1
;
char
*
pTmp
=
calloc
(
1
,
len
);
dst
->
pz
=
(
int64_t
)
pTmp
;
memcpy
((
char
*
)
dst
->
pz
,
(
char
*
)
src
->
pz
,
(
size_t
)
len
);
}
}
void
tscColumnBaseCopy
(
SColumnBase
*
dst
,
const
SColumnBase
*
src
)
{
assert
(
src
!=
NULL
&&
dst
!=
NULL
);
assert
(
src
!=
NULL
&&
dst
!=
NULL
);
*
dst
=
*
src
;
...
...
@@ -1230,7 +1254,7 @@ void tscColumnBaseInfoDestroy(SColumnBaseInfo* pColumnBaseInfo) {
assert
(
pColBase
->
filterInfo
[
j
].
filterOnBinary
==
0
||
pColBase
->
filterInfo
[
j
].
filterOnBinary
==
1
);
if
(
pColBase
->
filterInfo
[
j
].
filterOnBinary
)
{
free
((
char
*
)
pColBase
->
filterInfo
[
j
].
pz
);
free
((
char
*
)
pColBase
->
filterInfo
[
j
].
pz
);
pColBase
->
filterInfo
[
j
].
pz
=
0
;
}
}
...
...
@@ -1390,7 +1414,7 @@ bool tscValidateColumnId(SSqlCmd* pCmd, int32_t colId) {
void
tscTagCondCopy
(
STagCond
*
dest
,
const
STagCond
*
src
)
{
memset
(
dest
,
0
,
sizeof
(
STagCond
));
if
(
src
->
tbnameCond
.
cond
!=
NULL
)
{
dest
->
tbnameCond
.
cond
=
strdup
(
src
->
tbnameCond
.
cond
);
}
...
...
@@ -1403,7 +1427,7 @@ void tscTagCondCopy(STagCond* dest, const STagCond* src) {
if
(
src
->
cond
[
i
].
cond
!=
NULL
)
{
dest
->
cond
[
i
].
cond
=
strdup
(
src
->
cond
[
i
].
cond
);
}
dest
->
cond
[
i
].
uid
=
src
->
cond
[
i
].
uid
;
}
...
...
@@ -1513,10 +1537,10 @@ bool tscShouldFreeAsyncSqlObj(SSqlObj* pSql) {
* data blocks have been submit to vnode.
*/
SDataBlockList
*
pDataBlocks
=
pCmd
->
pDataBlocks
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
);
assert
(
pSql
->
cmd
.
numOfTables
==
1
);
if
(
pDataBlocks
==
NULL
||
pMeterMetaInfo
->
vnodeIndex
>=
pDataBlocks
->
nSize
)
{
tscTrace
(
"%p object should be release since all data blocks have been submit"
,
pSql
);
return
true
;
...
...
@@ -1632,7 +1656,7 @@ void tscResetForNextRetrieve(SSqlRes* pRes) {
}
SSqlObj
*
createSubqueryObj
(
SSqlObj
*
pSql
,
int16_t
tableIndex
,
void
(
*
fp
)(),
void
*
param
,
SSqlObj
*
pPrevSql
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
tableIndex
);
SSqlObj
*
pNew
=
(
SSqlObj
*
)
calloc
(
1
,
sizeof
(
SSqlObj
));
...
...
@@ -1677,7 +1701,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
}
tscColumnBaseInfoCopy
(
&
pNew
->
cmd
.
colList
,
&
pCmd
->
colList
,
(
int16_t
)
tableIndex
);
// set the correct query type
if
(
pPrevSql
!=
NULL
)
{
pNew
->
cmd
.
type
=
pPrevSql
->
cmd
.
type
;
...
...
@@ -1707,14 +1731,14 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
pNew
->
fp
=
fp
;
pNew
->
param
=
param
;
char
key
[
TSDB_MAX_TAGS_LEN
+
1
]
=
{
0
};
tscGetMetricMetaCacheKey
(
pCmd
,
key
,
uid
);
#ifdef _DEBUG_VIEW
printf
(
"the metricmeta key is:%s
\n
"
,
key
);
#endif
char
*
name
=
pMeterMetaInfo
->
name
;
SMeterMetaInfo
*
pFinalInfo
=
NULL
;
...
...
@@ -1739,7 +1763,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
}
tscTrace
(
"%p new subquery %p, tableIndex:%d, vnodeIdx:%d, type:%d"
,
pSql
,
pNew
,
tableIndex
,
pMeterMetaInfo
->
vnodeIndex
,
pNew
->
cmd
.
type
);
pMeterMetaInfo
->
vnodeIndex
,
pNew
->
cmd
.
type
);
return
pNew
;
}
...
...
@@ -1780,40 +1804,41 @@ bool tscIsUpdateQuery(STscObj* pObj) {
SSqlCmd
*
pCmd
=
&
pObj
->
pSql
->
cmd
;
return
((
pCmd
->
command
>=
TSDB_SQL_INSERT
&&
pCmd
->
command
<=
TSDB_SQL_DROP_DNODE
)
||
TSDB_SQL_USE_DB
==
pCmd
->
command
)
?
1
:
0
;
TSDB_SQL_USE_DB
==
pCmd
->
command
)
?
1
:
0
;
}
int32_t
tscInvalidSQLErrMsg
(
char
*
msg
,
const
char
*
additionalInfo
,
const
char
*
sql
)
{
const
char
*
msgFormat1
=
"invalid SQL: %s"
;
const
char
*
msgFormat2
=
"invalid SQL: syntax error near
\"
%s
\"
(%s)"
;
const
char
*
msgFormat3
=
"invalid SQL: syntax error near
\"
%s
\"
"
;
int32_t
tscInvalidSQLErrMsg
(
char
*
msg
,
const
char
*
additionalInfo
,
const
char
*
sql
)
{
const
char
*
msgFormat1
=
"invalid SQL: %s"
;
const
char
*
msgFormat2
=
"invalid SQL: syntax error near
\"
%s
\"
(%s)"
;
const
char
*
msgFormat3
=
"invalid SQL: syntax error near
\"
%s
\"
"
;
const
int32_t
BACKWARD_CHAR_STEP
=
0
;
if
(
sql
==
NULL
)
{
assert
(
additionalInfo
!=
NULL
);
sprintf
(
msg
,
msgFormat1
,
additionalInfo
);
return
TSDB_CODE_INVALID_SQL
;
}
char
buf
[
64
]
=
{
0
};
// only extract part of sql string
char
buf
[
64
]
=
{
0
};
// only extract part of sql string
strncpy
(
buf
,
(
sql
-
BACKWARD_CHAR_STEP
),
tListLen
(
buf
)
-
1
);
if
(
additionalInfo
!=
NULL
)
{
sprintf
(
msg
,
msgFormat2
,
buf
,
additionalInfo
);
}
else
{
sprintf
(
msg
,
msgFormat3
,
buf
);
// no additional information for invalid sql error
sprintf
(
msg
,
msgFormat3
,
buf
);
// no additional information for invalid sql error
}
return
TSDB_CODE_INVALID_SQL
;
}
bool
tscHasReachLimitation
(
SSqlObj
*
pSql
)
{
assert
(
pSql
!=
NULL
&&
pSql
->
cmd
.
globalLimit
!=
0
);
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
return
(
pCmd
->
globalLimit
>
0
&&
pRes
->
numOfTotal
>=
pCmd
->
globalLimit
);
}
src/inc/taoserror.h
浏览文件 @
07b32ec2
...
...
@@ -137,8 +137,9 @@ extern "C" {
#define TSDB_CODE_INVALID_VNODE_STATUS 116
#define TSDB_CODE_FAILED_TO_LOCK_RESOURCES 117
#define TSDB_CODE_TABLE_ID_MISMATCH 118
#define TSDB_CODE_QUERY_CACHE_ERASED 119
#define TSDB_CODE_MAX_ERROR_CODE 1
19
#define TSDB_CODE_MAX_ERROR_CODE 1
20
#ifdef __cplusplus
}
...
...
src/rpc/src/tstring.c
浏览文件 @
07b32ec2
...
...
@@ -242,5 +242,6 @@ char *tsError[] = {"success",
"invalid table id"
,
// 115
"invalid vnode status"
,
"failed to lock resources"
,
"table id/uid mismatch"
,
// 118
"table id/uid mismatch"
,
"client query cache erased"
,
// 119
};
src/util/src/textbuffer.c
浏览文件 @
07b32ec2
...
...
@@ -97,10 +97,11 @@ void tExtMemBufferDestroy(tExtMemBuffer **pMemBuffer) {
// close temp file
if
((
*
pMemBuffer
)
->
dataFile
!=
0
)
{
int32_t
ret
=
fclose
((
*
pMemBuffer
)
->
dataFile
);
if
(
ret
!=
0
)
{
if
(
fclose
((
*
pMemBuffer
)
->
dataFile
)
!=
0
)
{
pError
(
"failed to close file:%s, reason:%s"
,
(
*
pMemBuffer
)
->
dataFilePath
,
strerror
(
errno
));
}
pTrace
(
"remove temp file:%s for external buffer"
,
(
*
pMemBuffer
)
->
dataFilePath
);
unlink
((
*
pMemBuffer
)
->
dataFilePath
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录