Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
df3c4573
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看板
提交
df3c4573
编写于
2月 26, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bugs in regression tests.
上级
ae453f80
变更
13
展开全部
隐藏空白更改
内联
并排
Showing
13 changed file
with
354 addition
and
294 deletion
+354
-294
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+1
-1
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+4
-7
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+5
-0
src/client/src/tscJoinProcess.c
src/client/src/tscJoinProcess.c
+7
-4
src/client/src/tscLocal.c
src/client/src/tscLocal.c
+9
-0
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+67
-55
src/client/src/tscSecondaryMerge.c
src/client/src/tscSecondaryMerge.c
+168
-153
src/client/src/tscServer.c
src/client/src/tscServer.c
+22
-17
src/client/src/tscSql.c
src/client/src/tscSql.c
+4
-1
src/client/src/tscStream.c
src/client/src/tscStream.c
+0
-2
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+63
-53
src/inc/tsqlfunction.h
src/inc/tsqlfunction.h
+3
-0
src/system/detail/src/vnodeRead.c
src/system/detail/src/vnodeRead.c
+1
-1
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
df3c4573
...
...
@@ -154,7 +154,7 @@ SSqlExpr* tscSqlExprUpdate(SQueryInfo* pQueryInfo, int32_t index, int16_t functi
int32_t
tscSqlExprNumOfExprs
(
SQueryInfo
*
pQueryInfo
);
SSqlExpr
*
tscSqlExprGet
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
);
void
tscSqlExprCopy
(
SSqlExprInfo
*
dst
,
const
SSqlExprInfo
*
src
,
uint64_t
uid
);
void
tscSqlExprCopy
(
SSqlExprInfo
*
dst
,
const
SSqlExprInfo
*
src
,
uint64_t
uid
,
bool
deepcopy
);
void
*
tscSqlExprDestroy
(
SSqlExpr
*
pExpr
);
void
tscSqlExprInfoDestroy
(
SSqlExprInfo
*
pExprInfo
);
...
...
src/client/inc/tsclient.h
浏览文件 @
df3c4573
...
...
@@ -96,9 +96,9 @@ typedef struct SFieldInfo {
}
SFieldInfo
;
typedef
struct
SSqlExprInfo
{
int16_t
numOfAlloc
;
int16_t
numOfExprs
;
SSqlExpr
*
pExprs
;
int16_t
numOfAlloc
;
int16_t
numOfExprs
;
SSqlExpr
**
pExprs
;
}
SSqlExprInfo
;
typedef
struct
SColumnBase
{
...
...
@@ -283,12 +283,11 @@ typedef struct {
int64_t
useconds
;
int64_t
offset
;
// offset value from vnode during projection query of stable
int
row
;
int16_t
numOf
nchar
;
int16_t
numOf
Cols
;
int16_t
precision
;
int32_t
numOfGroups
;
SResRec
*
pGroupRec
;
char
*
data
;
short
*
bytes
;
void
**
tsrow
;
char
**
buffer
;
// Buffer used to put multibytes encoded using unicode (wchar_t)
SColumnIndex
*
pColumnIndex
;
...
...
@@ -406,8 +405,6 @@ int taos_retrieve(TAOS_RES *res);
int32_t
tscTansformSQLFunctionForSTableQuery
(
SQueryInfo
*
pQueryInfo
);
void
tscRestoreSQLFunctionForMetricQuery
(
SQueryInfo
*
pQueryInfo
);
void
tscClearSqlMetaInfoForce
(
SSqlCmd
*
pCmd
);
int32_t
tscCreateResPointerInfo
(
SSqlRes
*
pRes
,
SQueryInfo
*
pQueryInfo
);
void
tscDestroyResPointerInfo
(
SSqlRes
*
pRes
);
...
...
src/client/src/tscFunctionImpl.c
浏览文件 @
df3c4573
...
...
@@ -300,6 +300,10 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI
return
TSDB_CODE_SUCCESS
;
}
bool
stableQueryFunctChanged
(
int32_t
funcId
)
{
return
(
aAggs
[
funcId
].
stableFuncId
!=
funcId
);
}
/**
* the numOfRes should be kept, since it may be used later
* and allow the ResultInfo to be re initialized
...
...
@@ -3558,6 +3562,7 @@ void spread_function_finalizer(SQLFunctionCtx *pCtx) {
}
GET_RES_INFO
(
pCtx
)
->
numOfRes
=
1
;
// todo add test case
doFinalizer
(
pCtx
);
}
/*
...
...
src/client/src/tscJoinProcess.c
浏览文件 @
df3c4573
...
...
@@ -275,6 +275,7 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
pSubQueryInfo
->
tsBuf
=
NULL
;
// free result for async object will also free sqlObj
assert
(
pSubQueryInfo
->
exprsInfo
.
numOfExprs
==
1
);
// ts_comp query only requires one resutl columns
taos_free_result
(
pPrevSub
);
SSqlObj
*
pNew
=
createSubqueryObj
(
pSql
,
(
int16_t
)
i
,
tscJoinQueryCallback
,
pSupporter
,
NULL
);
...
...
@@ -299,18 +300,20 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
tscColumnBaseInfoCopy
(
&
pQueryInfo
->
colList
,
&
pSupporter
->
colList
,
0
);
tscTagCondCopy
(
&
pQueryInfo
->
tagCond
,
&
pSupporter
->
tagCond
);
tscSqlExprCopy
(
&
pQueryInfo
->
exprsInfo
,
&
pSupporter
->
exprsInfo
,
pSupporter
->
uid
);
tscSqlExprCopy
(
&
pQueryInfo
->
exprsInfo
,
&
pSupporter
->
exprsInfo
,
pSupporter
->
uid
,
false
);
tscFieldInfoCopyAll
(
&
pQueryInfo
->
fieldsInfo
,
&
pSupporter
->
fieldsInfo
);
pSupporter
->
exprsInfo
.
numOfExprs
=
0
;
pSupporter
->
fieldsInfo
.
numOfOutputCols
=
0
;
/*
* if the first column of the secondary query is not ts function, add this function.
* Because this column is required to filter with timestamp after intersecting.
*/
if
(
pSupporter
->
exprsInfo
.
pExprs
[
0
]
.
functionId
!=
TSDB_FUNC_TS
)
{
if
(
pSupporter
->
exprsInfo
.
pExprs
[
0
]
->
functionId
!=
TSDB_FUNC_TS
)
{
tscAddTimestampColumn
(
pQueryInfo
,
TSDB_FUNC_TS
,
0
);
}
// todo refactor function name
SQueryInfo
*
pNewQueryInfo
=
tscGetQueryInfoDetail
(
&
pNew
->
cmd
,
0
);
assert
(
pNew
->
numOfSubs
==
0
&&
pNew
->
cmd
.
numOfClause
==
1
&&
pNewQueryInfo
->
numOfTables
==
1
);
...
...
src/client/src/tscLocal.c
浏览文件 @
df3c4573
...
...
@@ -251,6 +251,13 @@ static int32_t tscBuildMeterSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
tscFieldInfoSetValue
(
&
pQueryInfo
->
fieldsInfo
,
3
,
TSDB_DATA_TYPE_BINARY
,
"Note"
,
noteColLength
);
rowLen
+=
noteColLength
;
//set the sqlexpr part
SColumnIndex
index
=
{
0
};
pQueryInfo
->
fieldsInfo
.
pSqlExpr
[
0
]
=
tscSqlExprInsert
(
pQueryInfo
,
0
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_BINARY
,
TSDB_COL_NAME_LEN
,
TSDB_COL_NAME_LEN
);
pQueryInfo
->
fieldsInfo
.
pSqlExpr
[
1
]
=
tscSqlExprInsert
(
pQueryInfo
,
1
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_BINARY
,
typeColLength
,
typeColLength
);
pQueryInfo
->
fieldsInfo
.
pSqlExpr
[
2
]
=
tscSqlExprInsert
(
pQueryInfo
,
2
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_INT
,
sizeof
(
int32_t
),
sizeof
(
int32_t
));
pQueryInfo
->
fieldsInfo
.
pSqlExpr
[
3
]
=
tscSqlExprInsert
(
pQueryInfo
,
3
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_BINARY
,
noteColLength
,
noteColLength
);
return
rowLen
;
}
...
...
@@ -455,6 +462,8 @@ void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnNa
tscInitResObjForLocalQuery
(
pSql
,
1
,
valueLength
);
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
pQueryInfo
,
0
);
pQueryInfo
->
fieldsInfo
.
pSqlExpr
[
0
]
=
pQueryInfo
->
exprsInfo
.
pExprs
[
0
];
strncpy
(
pRes
->
data
,
val
,
pField
->
bytes
);
}
...
...
src/client/src/tscSQLParser.c
浏览文件 @
df3c4573
此差异已折叠。
点击以展开。
src/client/src/tscSecondaryMerge.c
浏览文件 @
df3c4573
此差异已折叠。
点击以展开。
src/client/src/tscServer.c
浏览文件 @
df3c4573
...
...
@@ -643,9 +643,9 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSubquerySu
tscColumnBaseInfoUpdateTableIndex
(
&
pNewQueryInfo
->
colList
,
0
);
tscColumnBaseInfoCopy
(
&
pSupporter
->
colList
,
&
pNewQueryInfo
->
colList
,
0
);
tscSqlExprCopy
(
&
pSupporter
->
exprsInfo
,
&
pNewQueryInfo
->
exprsInfo
,
pSupporter
->
uid
);
tscSqlExprCopy
(
&
pSupporter
->
exprsInfo
,
&
pNewQueryInfo
->
exprsInfo
,
pSupporter
->
uid
,
false
);
tscFieldInfoCopyAll
(
&
pSupporter
->
fieldsInfo
,
&
pNewQueryInfo
->
fieldsInfo
);
tscTagCondCopy
(
&
pSupporter
->
tagCond
,
&
pNewQueryInfo
->
tagCond
);
pNew
->
cmd
.
numOfCols
=
0
;
...
...
@@ -656,6 +656,10 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSubquerySu
pSupporter
->
groupbyExpr
=
pNewQueryInfo
->
groupbyExpr
;
memset
(
&
pNewQueryInfo
->
groupbyExpr
,
0
,
sizeof
(
SSqlGroupbyExpr
));
// this data needs to be transfer to support struct
pNewQueryInfo
->
fieldsInfo
.
numOfOutputCols
=
0
;
pNewQueryInfo
->
exprsInfo
.
numOfExprs
=
0
;
// set the ts,tags that involved in join, as the output column of intermediate result
tscClearSubqueryInfo
(
&
pNew
->
cmd
);
...
...
@@ -1537,7 +1541,7 @@ static int32_t tscEstimateQueryMsgSize(SSqlCmd *pCmd, int32_t clauseIndex) {
int32_t
srcColListSize
=
pQueryInfo
->
colList
.
numOfCols
*
sizeof
(
SColumnInfo
);
int32_t
exprSize
=
sizeof
(
SSqlFuncExprMsg
)
*
pQueryInfo
->
fieldsInfo
.
numOfOutputCol
s
;
int32_t
exprSize
=
sizeof
(
SSqlFuncExprMsg
)
*
pQueryInfo
->
exprsInfo
.
numOfExpr
s
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
// meter query without tags values
...
...
@@ -1546,11 +1550,10 @@ static int32_t tscEstimateQueryMsgSize(SSqlCmd *pCmd, int32_t clauseIndex) {
}
SMetricMeta
*
pMetricMeta
=
pMeterMetaInfo
->
pMetricMeta
;
SVnodeSidList
*
pVnodeSidList
=
tscGetVnodeSidList
(
pMetricMeta
,
pMeterMetaInfo
->
vnodeIndex
);
int32_t
meterInfoSize
=
(
pMetricMeta
->
tagLen
+
sizeof
(
SMeterSidExtInfo
))
*
pVnodeSidList
->
numOfSids
;
int32_t
outputColumnSize
=
pQueryInfo
->
fieldsInfo
.
numOfOutputCol
s
*
sizeof
(
SSqlFuncExprMsg
);
int32_t
outputColumnSize
=
pQueryInfo
->
exprsInfo
.
numOfExpr
s
*
sizeof
(
SSqlFuncExprMsg
);
int32_t
size
=
meterInfoSize
+
outputColumnSize
+
srcColListSize
+
exprSize
+
MIN_QUERY_MSG_PKT_SIZE
;
if
(
pQueryInfo
->
tsBuf
!=
NULL
)
{
...
...
@@ -1787,7 +1790,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pSqlFuncExpr
->
functionId
=
htons
(
pExpr
->
functionId
);
pSqlFuncExpr
->
numOfParams
=
htons
(
pExpr
->
numOfParams
);
pMsg
+=
(
sizeof
(
SSqlFuncExprMsg
)
-
TSDB_COL_NAME_LEN
);
pMsg
+=
sizeof
(
SSqlFuncExprMsg
);
for
(
int32_t
j
=
0
;
j
<
pExpr
->
numOfParams
;
++
j
)
{
pSqlFuncExpr
->
arg
[
j
].
argType
=
htons
((
uint16_t
)
pExpr
->
param
[
j
].
nType
);
...
...
@@ -1862,6 +1865,9 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
*
((
int16_t
*
)
pMsg
)
+=
pCol
->
flag
;
pMsg
+=
sizeof
(
pCol
->
flag
);
memcpy
(
pMsg
,
pCol
->
name
,
tListLen
(
pCol
->
name
));
pMsg
+=
tListLen
(
pCol
->
name
);
}
}
...
...
@@ -2491,16 +2497,8 @@ static int tscSetResultPointer(SQueryInfo *pQueryInfo, SSqlRes *pRes) {
}
for
(
int
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutputCols
;
++
i
)
{
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
pQueryInfo
,
i
);
int16_t
offset
=
tscFieldInfoGetOffset
(
pQueryInfo
,
i
);
pRes
->
bytes
[
i
]
=
pField
->
bytes
;
// if (pQueryInfo->order.order == TSQL_SO_DESC) {
// pRes->bytes[i] = -pRes->bytes[i];
// pRes->tsrow[i] = ((pRes->data + offset * pRes->numOfRows) + (pRes->numOfRows - 1) * pField->bytes);
// } else {
pRes
->
tsrow
[
i
]
=
(
pRes
->
data
+
offset
*
pRes
->
numOfRows
);
// }
int16_t
offset
=
tscFieldInfoGetOffset
(
pQueryInfo
,
i
);
pRes
->
tsrow
[
i
]
=
(
pRes
->
data
+
offset
*
pRes
->
numOfRows
);
}
return
0
;
...
...
@@ -2725,8 +2723,10 @@ static int32_t tscEstimateMetricMetaMsgSize(SSqlCmd *pCmd) {
int32_t
joinCondLen
=
(
TSDB_METER_ID_LEN
+
sizeof
(
int16_t
))
*
2
;
int32_t
elemSize
=
sizeof
(
SMetricMetaElemMsg
)
*
pQueryInfo
->
numOfTables
;
int32_t
colSize
=
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
*
sizeof
(
SColIndexEx
);
int32_t
len
=
tagLen
+
joinCondLen
+
elemSize
+
defaultSize
;
int32_t
len
=
tagLen
+
joinCondLen
+
elemSize
+
colSize
+
defaultSize
;
return
MAX
(
len
,
TSDB_DEFAULT_PAYLOAD_SIZE
);
}
...
...
@@ -2854,6 +2854,7 @@ int tscBuildMetricMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pDestCol
->
colIdx
=
htons
(
pCol
->
colIdx
);
pDestCol
->
colId
=
htons
(
pDestCol
->
colId
);
pDestCol
->
flag
=
htons
(
pDestCol
->
flag
);
strncpy
(
pDestCol
->
name
,
pCol
->
name
,
tListLen
(
pCol
->
name
));
pMsg
+=
sizeof
(
SColIndexEx
);
}
...
...
@@ -3291,6 +3292,7 @@ int tscProcessShowRsp(SSqlObj *pSql) {
int32_t
size
=
pMeta
->
numOfColumns
*
sizeof
(
SSchema
)
+
sizeof
(
SMeterMeta
);
pMeterMetaInfo
->
pMeterMeta
=
(
SMeterMeta
*
)
taosAddDataIntoCache
(
tscCacheHandle
,
key
,
(
char
*
)
pMeta
,
size
,
tsMeterMetaKeepTimer
);
pCmd
->
numOfCols
=
pQueryInfo
->
fieldsInfo
.
numOfOutputCols
;
SSchema
*
pMeterSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
...
...
@@ -3301,6 +3303,9 @@ int tscProcessShowRsp(SSqlObj *pSql) {
index
.
columnIndex
=
i
;
tscColumnBaseInfoInsert
(
pQueryInfo
,
&
index
);
tscFieldInfoSetValFromSchema
(
&
pQueryInfo
->
fieldsInfo
,
i
,
&
pMeterSchema
[
i
]);
pQueryInfo
->
fieldsInfo
.
pSqlExpr
[
i
]
=
tscSqlExprInsert
(
pQueryInfo
,
i
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
pMeterSchema
[
i
].
type
,
pMeterSchema
[
i
].
bytes
,
pMeterSchema
[
i
].
bytes
);
}
tscFieldInfoCalOffset
(
pQueryInfo
);
...
...
src/client/src/tscSql.c
浏览文件 @
df3c4573
...
...
@@ -441,7 +441,10 @@ static void **doSetResultRowData(SSqlObj *pSql) {
int32_t
num
=
0
;
for
(
int
i
=
0
;
i
<
tscNumOfFields
(
pQueryInfo
);
++
i
)
{
if
(
pQueryInfo
->
fieldsInfo
.
pSqlExpr
[
i
]
!=
NULL
)
{
pRes
->
tsrow
[
i
]
=
TSC_GET_RESPTR_BASE
(
pRes
,
pQueryInfo
,
i
)
+
pRes
->
bytes
[
i
]
*
pRes
->
row
;
SSqlExpr
*
pExpr
=
pQueryInfo
->
fieldsInfo
.
pSqlExpr
[
i
];
pRes
->
tsrow
[
i
]
=
TSC_GET_RESPTR_BASE
(
pRes
,
pQueryInfo
,
i
)
+
pExpr
->
resBytes
*
pRes
->
row
;
}
else
{
assert
(
0
);
}
// primary key column cannot be null in interval query, no need to check
...
...
src/client/src/tscStream.c
浏览文件 @
df3c4573
...
...
@@ -246,8 +246,6 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
int32_t
retry
=
tsProjectExecInterval
;
tscError
(
"%p stream:%p, retrieve no data, code:%d, retry in %"
PRId64
"ms"
,
pSql
,
pStream
,
numOfRows
,
retry
);
tscClearSqlMetaInfoForce
(
&
(
pStream
->
pSql
->
cmd
));
tscSetRetryTimer
(
pStream
,
pStream
->
pSql
,
retry
);
return
;
}
...
...
src/client/src/tscUtil.c
浏览文件 @
df3c4573
...
...
@@ -336,35 +336,17 @@ void tscClearInterpInfo(SQueryInfo* pQueryInfo) {
tfree
(
pQueryInfo
->
defaultVal
);
}
void
tscClearSqlMetaInfoForce
(
SSqlCmd
*
pCmd
)
{
/* remove the metermeta/metricmeta in cache */
// taosRemoveDataFromCache(tscCacheHandle, (void**)&(pCmd->pMeterMeta), true);
// taosRemoveDataFromCache(tscCacheHandle, (void**)&(pCmd->pMetricMeta), true);
}
int32_t
tscCreateResPointerInfo
(
SSqlRes
*
pRes
,
SQueryInfo
*
pQueryInfo
)
{
if
(
pRes
->
tsrow
==
NULL
)
{
//
int32_t
numOfOutputCols
=
pQueryInfo
->
fieldsInfo
.
numOfOutputCols
;
pRes
->
numOfnchar
=
numOfOutputCols
;
// for (int32_t i = 0; i < numOfOutputCols; ++i) {
// TAOS_FIELD* pField = tscFieldInfoGetField(pQueryInfo, i);
// if (pField->type == TSDB_DATA_TYPE_NCHAR) {
// pRes->numOfnchar++;
// }
// }
pRes
->
numOfCols
=
numOfOutputCols
;
pRes
->
tsrow
=
calloc
(
1
,
(
POINTER_BYTES
+
sizeof
(
short
))
*
numOfOutputCols
+
POINTER_BYTES
*
pRes
->
numOfnchar
);
pRes
->
bytes
=
calloc
(
numOfOutputCols
,
sizeof
(
short
));
// if (pRes->numOfnchar > 0) {
pRes
->
buffer
=
calloc
(
POINTER_BYTES
,
numOfOutputCols
);
// }
pRes
->
tsrow
=
calloc
(
POINTER_BYTES
,
numOfOutputCols
);
pRes
->
buffer
=
calloc
(
POINTER_BYTES
,
numOfOutputCols
);
// not enough memory
if
(
pRes
->
tsrow
==
NULL
||
pRes
->
bytes
==
NULL
||
(
pRes
->
buffer
==
NULL
&&
pRes
->
numOfnchar
>
0
))
{
if
(
pRes
->
tsrow
==
NULL
||
(
pRes
->
buffer
==
NULL
&&
pRes
->
numOfCols
>
0
))
{
tfree
(
pRes
->
tsrow
);
tfree
(
pRes
->
bytes
);
tfree
(
pRes
->
buffer
);
pRes
->
code
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
...
...
@@ -377,13 +359,12 @@ int32_t tscCreateResPointerInfo(SSqlRes* pRes, SQueryInfo* pQueryInfo) {
void
tscDestroyResPointerInfo
(
SSqlRes
*
pRes
)
{
if
(
pRes
->
buffer
!=
NULL
)
{
// assert(pRes->numOfnchar > 0);
// free all buffers containing the multibyte string
for
(
int
i
=
0
;
i
<
pRes
->
numOf
nchar
;
i
++
)
{
for
(
int
i
=
0
;
i
<
pRes
->
numOf
Cols
;
i
++
)
{
tfree
(
pRes
->
buffer
[
i
]);
}
pRes
->
numOf
nchar
=
0
;
pRes
->
numOf
Cols
=
0
;
}
tfree
(
pRes
->
pRsp
);
...
...
@@ -392,7 +373,6 @@ void tscDestroyResPointerInfo(SSqlRes* pRes) {
tfree
(
pRes
->
pGroupRec
);
tfree
(
pRes
->
pColumnIndex
);
tfree
(
pRes
->
buffer
);
tfree
(
pRes
->
bytes
);
pRes
->
data
=
NULL
;
// pRes->data points to the buffer of pRsp, no need to free
}
...
...
@@ -930,10 +910,10 @@ void tscFieldInfoSetBinExpr(SFieldInfo* pFieldInfo, int32_t index, SSqlFunctionE
void
tscFieldInfoCalOffset
(
SQueryInfo
*
pQueryInfo
)
{
SSqlExprInfo
*
pExprInfo
=
&
pQueryInfo
->
exprsInfo
;
pExprInfo
->
pExprs
[
0
]
.
offset
=
0
;
pExprInfo
->
pExprs
[
0
]
->
offset
=
0
;
for
(
int32_t
i
=
1
;
i
<
pExprInfo
->
numOfExprs
;
++
i
)
{
pExprInfo
->
pExprs
[
i
]
.
offset
=
pExprInfo
->
pExprs
[
i
-
1
].
offset
+
pExprInfo
->
pExprs
[
i
-
1
].
resBytes
;
pExprInfo
->
pExprs
[
i
]
->
offset
=
pExprInfo
->
pExprs
[
i
-
1
]
->
offset
+
pExprInfo
->
pExprs
[
i
-
1
]
->
resBytes
;
}
}
...
...
@@ -957,10 +937,10 @@ void tscFieldInfoUpdateOffsetForInterResult(SQueryInfo* pQueryInfo) {
return
;
}
pExprInfo
->
pExprs
[
0
]
.
offset
=
0
;
pExprInfo
->
pExprs
[
0
]
->
offset
=
0
;
for
(
int32_t
i
=
1
;
i
<
pExprInfo
->
numOfExprs
;
++
i
)
{
pExprInfo
->
pExprs
[
i
]
.
offset
=
pExprInfo
->
pExprs
[
i
-
1
].
offset
+
pExprInfo
->
pExprs
[
i
-
1
].
resBytes
;
pExprInfo
->
pExprs
[
i
]
->
offset
=
pExprInfo
->
pExprs
[
i
-
1
]
->
offset
+
pExprInfo
->
pExprs
[
i
-
1
]
->
resBytes
;
}
}
...
...
@@ -976,6 +956,8 @@ void tscFieldInfoCopy(SFieldInfo* src, SFieldInfo* dst, const int32_t* indexList
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
assert
(
indexList
[
i
]
>=
0
&&
indexList
[
i
]
<=
src
->
numOfOutputCols
);
tscFieldInfoSetValFromField
(
dst
,
i
,
&
src
->
pFields
[
indexList
[
i
]]);
dst
->
pVisibleCols
[
i
]
=
src
->
pVisibleCols
[
indexList
[
i
]];
dst
->
pSqlExpr
[
i
]
=
src
->
pSqlExpr
[
indexList
[
i
]];
}
}
}
...
...
@@ -984,14 +966,14 @@ void tscFieldInfoCopyAll(SFieldInfo* dst, SFieldInfo* src) {
*
dst
=
*
src
;
dst
->
pFields
=
malloc
(
sizeof
(
TAOS_FIELD
)
*
dst
->
numOfAlloc
);
// dst->pOffset = malloc(sizeof(short) * dst->numOfAlloc);
dst
->
pVisibleCols
=
malloc
(
sizeof
(
bool
)
*
dst
->
numOfAlloc
);
dst
->
pSqlExpr
=
malloc
(
POINTER_BYTES
*
dst
->
numOfAlloc
);
dst
->
pExpr
=
malloc
(
POINTER_BYTES
*
dst
->
numOfAlloc
);
memcpy
(
dst
->
pFields
,
src
->
pFields
,
sizeof
(
TAOS_FIELD
)
*
dst
->
numOfOutputCols
);
// memcpy(dst->pOffset, src->pOffset, sizeof(short) * dst->numOfOutputCols);
memcpy
(
dst
->
pVisibleCols
,
src
->
pVisibleCols
,
sizeof
(
bool
)
*
dst
->
numOfOutputCols
);
memcpy
(
dst
->
pSqlExpr
,
src
->
pSqlExpr
,
POINTER_BYTES
*
dst
->
numOfOutputCols
);
memcpy
(
dst
->
pExpr
,
src
->
pExpr
,
POINTER_BYTES
*
dst
->
numOfOutputCols
);
}
TAOS_FIELD
*
tscFieldInfoGetField
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
)
{
...
...
@@ -1009,7 +991,7 @@ int16_t tscFieldInfoGetOffset(SQueryInfo* pQueryInfo, int32_t index) {
return
0
;
}
return
pQueryInfo
->
exprsInfo
.
pExprs
[
index
]
.
offset
;
return
pQueryInfo
->
exprsInfo
.
pExprs
[
index
]
->
offset
;
}
int32_t
tscFieldInfoCompare
(
SFieldInfo
*
pFieldInfo1
,
SFieldInfo
*
pFieldInfo2
)
{
...
...
@@ -1039,7 +1021,7 @@ int32_t tscGetResRowLength(SQueryInfo* pQueryInfo) {
int32_t
size
=
0
;
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
i
)
{
size
+=
pQueryInfo
->
exprsInfo
.
pExprs
[
i
]
.
resBytes
;
size
+=
pQueryInfo
->
exprsInfo
.
pExprs
[
i
]
->
resBytes
;
}
return
size
;
...
...
@@ -1050,7 +1032,6 @@ void tscClearFieldInfo(SFieldInfo* pFieldInfo) {
return
;
}
// tfree(pFieldInfo->pOffset);
tfree
(
pFieldInfo
->
pFields
);
tfree
(
pFieldInfo
->
pVisibleCols
);
tfree
(
pFieldInfo
->
pSqlExpr
);
...
...
@@ -1101,11 +1082,12 @@ SSqlExpr* tscSqlExprInsertEmpty(SQueryInfo* pQueryInfo, int32_t index, int16_t f
_exprCheckSpace
(
pExprInfo
,
pExprInfo
->
numOfExprs
+
1
);
_exprEvic
(
pExprInfo
,
index
);
SSqlExpr
*
pExpr
=
&
pExprInfo
->
pExprs
[
index
]
;
SSqlExpr
*
pExpr
=
calloc
(
1
,
sizeof
(
SSqlExpr
))
;
pExpr
->
functionId
=
functionId
;
pExprInfo
->
numOfExprs
++
;
pExprInfo
->
pExprs
[
index
]
=
pExpr
;
return
pExpr
;
}
...
...
@@ -1118,8 +1100,9 @@ SSqlExpr* tscSqlExprInsert(SQueryInfo* pQueryInfo, int32_t index, int16_t functi
_exprCheckSpace
(
pExprInfo
,
pExprInfo
->
numOfExprs
+
1
);
_exprEvic
(
pExprInfo
,
index
);
SSqlExpr
*
pExpr
=
&
pExprInfo
->
pExprs
[
index
];
SSqlExpr
*
pExpr
=
calloc
(
1
,
sizeof
(
SSqlExpr
));
pExprInfo
->
pExprs
[
index
]
=
pExpr
;
pExpr
->
functionId
=
functionId
;
int16_t
numOfCols
=
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
;
...
...
@@ -1161,7 +1144,7 @@ SSqlExpr* tscSqlExprUpdate(SQueryInfo* pQueryInfo, int32_t index, int16_t functi
return
NULL
;
}
SSqlExpr
*
pExpr
=
&
pExprInfo
->
pExprs
[
index
];
SSqlExpr
*
pExpr
=
pExprInfo
->
pExprs
[
index
];
pExpr
->
functionId
=
functionId
;
...
...
@@ -1196,7 +1179,7 @@ SSqlExpr* tscSqlExprGet(SQueryInfo* pQueryInfo, int32_t index) {
return
NULL
;
}
return
&
pQueryInfo
->
exprsInfo
.
pExprs
[
index
];
return
pQueryInfo
->
exprsInfo
.
pExprs
[
index
];
}
void
*
tscSqlExprDestroy
(
SSqlExpr
*
pExpr
)
{
...
...
@@ -1208,6 +1191,8 @@ void* tscSqlExprDestroy(SSqlExpr* pExpr) {
tVariantDestroy
(
&
pExpr
->
param
[
i
]);
}
tfree
(
pExpr
);
return
NULL
;
}
...
...
@@ -1219,8 +1204,8 @@ void tscSqlExprInfoDestroy(SSqlExprInfo* pExprInfo) {
return
;
}
for
(
int32_t
i
=
0
;
i
<
pExprInfo
->
numOf
Alloc
;
++
i
)
{
tscSqlExprDestroy
(
&
pExprInfo
->
pExprs
[
i
]);
for
(
int32_t
i
=
0
;
i
<
pExprInfo
->
numOf
Exprs
;
++
i
)
{
tscSqlExprDestroy
(
pExprInfo
->
pExprs
[
i
]);
}
tfree
(
pExprInfo
->
pExprs
);
...
...
@@ -1230,27 +1215,40 @@ void tscSqlExprInfoDestroy(SSqlExprInfo* pExprInfo) {
}
void
tscSqlExprCopy
(
SSqlExprInfo
*
dst
,
const
SSqlExprInfo
*
src
,
uint64_t
tableuid
)
{
void
tscSqlExprCopy
(
SSqlExprInfo
*
dst
,
const
SSqlExprInfo
*
src
,
uint64_t
tableuid
,
bool
deepcopy
)
{
if
(
src
==
NULL
)
{
return
;
}
*
dst
=
*
src
;
dst
->
pExprs
=
calloc
(
dst
->
numOfAlloc
,
sizeof
(
SSqlExpr
));
dst
->
pExprs
=
calloc
(
dst
->
numOfAlloc
,
POINTER_BYTES
);
int16_t
num
=
0
;
for
(
int32_t
i
=
0
;
i
<
src
->
numOfExprs
;
++
i
)
{
if
(
src
->
pExprs
[
i
].
uid
==
tableuid
)
{
dst
->
pExprs
[
num
++
]
=
src
->
pExprs
[
i
];
if
(
src
->
pExprs
[
i
]
->
uid
==
tableuid
)
{
if
(
deepcopy
)
{
dst
->
pExprs
[
num
]
=
calloc
(
1
,
sizeof
(
SSqlExpr
));
*
dst
->
pExprs
[
num
]
=
*
src
->
pExprs
[
i
];
}
else
{
dst
->
pExprs
[
num
]
=
src
->
pExprs
[
i
];
}
num
++
;
}
}
dst
->
numOfExprs
=
num
;
for
(
int32_t
i
=
0
;
i
<
dst
->
numOfExprs
;
++
i
)
{
for
(
int32_t
j
=
0
;
j
<
src
->
pExprs
[
i
].
numOfParams
;
++
j
)
{
tVariantAssign
(
&
dst
->
pExprs
[
i
].
param
[
j
],
&
src
->
pExprs
[
i
].
param
[
j
]);
if
(
deepcopy
)
{
for
(
int32_t
i
=
0
;
i
<
dst
->
numOfExprs
;
++
i
)
{
for
(
int32_t
j
=
0
;
j
<
src
->
pExprs
[
i
]
->
numOfParams
;
++
j
)
{
tVariantAssign
(
&
dst
->
pExprs
[
i
]
->
param
[
j
],
&
src
->
pExprs
[
i
]
->
param
[
j
]);
}
}
}
}
static
void
clearVal
(
SColumnBase
*
pBase
)
{
...
...
@@ -2005,7 +2003,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
}
uint64_t
uid
=
pMeterMetaInfo
->
pMeterMeta
->
uid
;
tscSqlExprCopy
(
&
pNewQueryInfo
->
exprsInfo
,
&
pQueryInfo
->
exprsInfo
,
uid
);
tscSqlExprCopy
(
&
pNewQueryInfo
->
exprsInfo
,
&
pQueryInfo
->
exprsInfo
,
uid
,
true
);
int32_t
numOfOutputCols
=
pNewQueryInfo
->
exprsInfo
.
numOfExprs
;
...
...
@@ -2020,7 +2018,19 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
tscFieldInfoCopy
(
&
pQueryInfo
->
fieldsInfo
,
&
pNewQueryInfo
->
fieldsInfo
,
indexList
,
numOfOutputCols
);
free
(
indexList
);
// make sure the the sqlExpr for each fields is correct
// todo handle the agg arithmetic expression
for
(
int32_t
f
=
0
;
f
<
pNewQueryInfo
->
fieldsInfo
.
numOfOutputCols
;
++
f
)
{
char
*
name
=
pNewQueryInfo
->
fieldsInfo
.
pFields
[
f
].
name
;
for
(
int32_t
k1
=
0
;
k1
<
pNewQueryInfo
->
exprsInfo
.
numOfExprs
;
++
k1
)
{
SSqlExpr
*
pExpr1
=
tscSqlExprGet
(
pNewQueryInfo
,
k1
);
if
(
strcmp
(
name
,
pExpr1
->
aliasName
)
==
0
)
{
pNewQueryInfo
->
fieldsInfo
.
pSqlExpr
[
f
]
=
pExpr1
;
}
}
}
tscFieldInfoUpdateOffsetForInterResult
(
pNewQueryInfo
);
}
...
...
src/inc/tsqlfunction.h
浏览文件 @
df3c4573
...
...
@@ -298,6 +298,9 @@ void getStatistics(char *priData, char *data, int32_t size, int32_t numOfRow, in
bool
top_bot_datablock_filter
(
SQLFunctionCtx
*
pCtx
,
int32_t
functionId
,
char
*
minval
,
char
*
maxval
);
bool
stableQueryFunctChanged
(
int32_t
funcId
);
void
resetResultInfo
(
SResultInfo
*
pResInfo
);
void
initResultInfo
(
SResultInfo
*
pResInfo
);
void
setResultInfoBuf
(
SResultInfo
*
pResInfo
,
int32_t
size
,
bool
superTable
);
...
...
src/system/detail/src/vnodeRead.c
浏览文件 @
df3c4573
...
...
@@ -1056,7 +1056,7 @@ int32_t vnodeConvertQueryMeterMsg(SQueryMeterMsg *pQueryMsg) {
pExprMsg
->
functionId
=
htons
(
pExprMsg
->
functionId
);
pExprMsg
->
numOfParams
=
htons
(
pExprMsg
->
numOfParams
);
pMsg
+=
(
sizeof
(
SSqlFuncExprMsg
)
-
TSDB_COL_NAME_LEN
);
pMsg
+=
sizeof
(
SSqlFuncExprMsg
);
for
(
int32_t
j
=
0
;
j
<
pExprMsg
->
numOfParams
;
++
j
)
{
pExprMsg
->
arg
[
j
].
argType
=
htons
(
pExprMsg
->
arg
[
j
].
argType
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录