Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
王长生-AnH
TDengine
提交
6dbca070
T
TDengine
项目概览
王长生-AnH
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
5
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,发现更多精彩内容 >>
提交
6dbca070
编写于
4月 23, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/develop' into feature/alter
上级
6a851fde
39308636
变更
36
展开全部
隐藏空白更改
内联
并排
Showing
36 changed file
with
2681 addition
and
2290 deletion
+2681
-2290
.travis.yml
.travis.yml
+3
-3
cmake/platform.inc
cmake/platform.inc
+1
-1
packaging/tools/makepkg.sh
packaging/tools/makepkg.sh
+1
-1
src/CMakeLists.txt
src/CMakeLists.txt
+1
-1
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+36
-45
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+134
-161
src/client/src/tscAsync.c
src/client/src/tscAsync.c
+10
-9
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+5
-5
src/client/src/tscLocal.c
src/client/src/tscLocal.c
+59
-40
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+4
-4
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+250
-224
src/client/src/tscSchemaUtil.c
src/client/src/tscSchemaUtil.c
+3
-3
src/client/src/tscSecondaryMerge.c
src/client/src/tscSecondaryMerge.c
+66
-52
src/client/src/tscServer.c
src/client/src/tscServer.c
+71
-85
src/client/src/tscSql.c
src/client/src/tscSql.c
+46
-31
src/client/src/tscStream.c
src/client/src/tscStream.c
+15
-15
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+53
-50
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+298
-563
src/inc/taos.h
src/inc/taos.h
+13
-0
src/inc/taosdef.h
src/inc/taosdef.h
+1
-13
src/inc/taosmsg.h
src/inc/taosmsg.h
+13
-13
src/inc/tsdb.h
src/inc/tsdb.h
+1
-1
src/kit/CMakeLists.txt
src/kit/CMakeLists.txt
+2
-2
src/kit/taosdump/CMakeLists.txt
src/kit/taosdump/CMakeLists.txt
+1
-0
src/kit/taosdump/taosdump.c
src/kit/taosdump/taosdump.c
+3
-4
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+6
-3
src/query/inc/queryExecutor.h
src/query/inc/queryExecutor.h
+4
-5
src/query/inc/queryUtil.h
src/query/inc/queryUtil.h
+5
-0
src/query/inc/tsqlfunction.h
src/query/inc/tsqlfunction.h
+1
-1
src/query/src/queryExecutor.c
src/query/src/queryExecutor.c
+993
-924
src/query/src/queryFilterFunc.c
src/query/src/queryFilterFunc.c
+558
-0
src/query/src/queryUtil.c
src/query/src/queryUtil.c
+4
-4
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+13
-20
src/util/inc/tarray.h
src/util/inc/tarray.h
+2
-2
src/util/src/talgo.c
src/util/src/talgo.c
+3
-3
src/util/src/tarray.c
src/util/src/tarray.c
+2
-2
未找到文件。
.travis.yml
浏览文件 @
6dbca070
...
@@ -44,7 +44,7 @@ matrix:
...
@@ -44,7 +44,7 @@ matrix:
case $TRAVIS_OS_NAME in
case $TRAVIS_OS_NAME in
linux)
linux)
cd ${TRAVIS_BUILD_DIR}/debug
cd ${TRAVIS_BUILD_DIR}/debug
sudo
make install || travis_terminate $?
make install || travis_terminate $?
pip install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python2/
pip install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python2/
pip3 install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python3/
pip3 install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python3/
...
@@ -149,7 +149,7 @@ matrix:
...
@@ -149,7 +149,7 @@ matrix:
case $TRAVIS_OS_NAME in
case $TRAVIS_OS_NAME in
linux)
linux)
cd ${TRAVIS_BUILD_DIR}/debug
cd ${TRAVIS_BUILD_DIR}/debug
sudo
make install || travis_terminate $?
make install || travis_terminate $?
pip install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python2/
pip install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python2/
pip3 install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python3/
pip3 install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python3/
...
@@ -162,7 +162,7 @@ matrix:
...
@@ -162,7 +162,7 @@ matrix:
travis_terminate $?
travis_terminate $?
fi
fi
sudo
pkill taosd
pkill taosd
sleep 1
sleep 1
cd ${TRAVIS_BUILD_DIR}
cd ${TRAVIS_BUILD_DIR}
...
...
cmake/platform.inc
浏览文件 @
6dbca070
...
@@ -62,7 +62,7 @@ IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
...
@@ -62,7 +62,7 @@ IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
IF
(
$
{
CMAKE_SIZEOF_VOID_P
}
MATCHES
8
)
IF
(
$
{
CMAKE_SIZEOF_VOID_P
}
MATCHES
8
)
SET
(
TD_LINUX_64
TRUE
)
SET
(
TD_LINUX_64
TRUE
)
SET
(
TD_OS_DIR
$
{
TD_COMMUNITY_DIR
}
/
src
/
os
/
linux
)
SET
(
TD_OS_DIR
$
{
TD_COMMUNITY_DIR
}
/
src
/
os
/
linux
)
ADD_DEFINITIONS
(
-
D_M_X64
)
ADD_DEFINITIONS
(
-
D_M_X64
-
D_DEBUG_VIEW
)
MESSAGE
(
STATUS
"The current platform is Linux 64-bit"
)
MESSAGE
(
STATUS
"The current platform is Linux 64-bit"
)
ELSEIF
(
$
{
CMAKE_SIZEOF_VOID_P
}
MATCHES
4
)
ELSEIF
(
$
{
CMAKE_SIZEOF_VOID_P
}
MATCHES
4
)
IF
(
TD_ARM
)
IF
(
TD_ARM
)
...
...
packaging/tools/makepkg.sh
浏览文件 @
6dbca070
...
@@ -43,7 +43,7 @@ lib_files="${build_dir}/lib/libtaos.so.${version}"
...
@@ -43,7 +43,7 @@ lib_files="${build_dir}/lib/libtaos.so.${version}"
header_files
=
"
${
code_dir
}
/inc/taos.h
${
code_dir
}
/inc/taoserror.h"
header_files
=
"
${
code_dir
}
/inc/taos.h
${
code_dir
}
/inc/taoserror.h"
cfg_dir
=
"
${
top_dir
}
/packaging/cfg"
cfg_dir
=
"
${
top_dir
}
/packaging/cfg"
install_files
=
"
${
script_dir
}
/install.sh"
install_files
=
"
${
script_dir
}
/install.sh"
nginx_dir
=
"
${
code_dir
}
/../../enterprise/src/
module
s/web"
nginx_dir
=
"
${
code_dir
}
/../../enterprise/src/
plugin
s/web"
# Init file
# Init file
#init_dir=${script_dir}/deb
#init_dir=${script_dir}/deb
...
...
src/CMakeLists.txt
浏览文件 @
6dbca070
...
@@ -15,4 +15,4 @@ ADD_SUBDIRECTORY(vnode)
...
@@ -15,4 +15,4 @@ ADD_SUBDIRECTORY(vnode)
ADD_SUBDIRECTORY
(
tsdb
)
ADD_SUBDIRECTORY
(
tsdb
)
ADD_SUBDIRECTORY
(
wal
)
ADD_SUBDIRECTORY
(
wal
)
ADD_SUBDIRECTORY
(
dnode
)
ADD_SUBDIRECTORY
(
dnode
)
#
ADD_SUBDIRECTORY(connector/jdbc)
ADD_SUBDIRECTORY
(
connector/jdbc
)
src/client/inc/tscUtil.h
浏览文件 @
6dbca070
...
@@ -57,8 +57,8 @@ typedef struct SJoinSubquerySupporter {
...
@@ -57,8 +57,8 @@ typedef struct SJoinSubquerySupporter {
int64_t
interval
;
// interval time
int64_t
interval
;
// interval time
SLimitVal
limit
;
// limit info
SLimitVal
limit
;
// limit info
uint64_t
uid
;
// query meter uid
uint64_t
uid
;
// query meter uid
S
ColumnBaseInfo
colList
;
// previous query information
S
Array
*
colList
;
// previous query information
S
SqlExprInfo
exprsInfo
;
S
Array
*
exprsInfo
;
SFieldInfo
fieldsInfo
;
SFieldInfo
fieldsInfo
;
STagCond
tagCond
;
STagCond
tagCond
;
SSqlGroupbyExpr
groupbyExpr
;
SSqlGroupbyExpr
groupbyExpr
;
...
@@ -69,8 +69,9 @@ typedef struct SJoinSubquerySupporter {
...
@@ -69,8 +69,9 @@ typedef struct SJoinSubquerySupporter {
int32_t
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
,
STableMeta
*
pTableMeta
,
STableDataBlocks
**
dataBlocks
);
STableMeta
*
pTableMeta
,
STableDataBlocks
**
dataBlocks
);
void
tscAppendDataBlock
(
SDataBlockList
*
pList
,
STableDataBlocks
*
pBlocks
);
void
tscAppendDataBlock
(
SDataBlockList
*
pList
,
STableDataBlocks
*
pBlocks
);
void
tscDestroyDataBlock
(
STableDataBlocks
*
pDataBlock
);
void
tscDestroyDataBlock
(
STableDataBlocks
*
pDataBlock
);
void
tscSortRemoveDataBlockDupRows
(
STableDataBlocks
*
dataBuf
);
SParamInfo
*
tscAddParamToDataBlock
(
STableDataBlocks
*
pDataBlock
,
char
type
,
uint8_t
timePrec
,
short
bytes
,
SParamInfo
*
tscAddParamToDataBlock
(
STableDataBlocks
*
pDataBlock
,
char
type
,
uint8_t
timePrec
,
short
bytes
,
uint32_t
offset
);
uint32_t
offset
);
...
@@ -85,8 +86,7 @@ int32_t tscGetDataBlockFromList(void* pHashList, SDataBlockList* pDataBlockList,
...
@@ -85,8 +86,7 @@ int32_t tscGetDataBlockFromList(void* pHashList, SDataBlockList* pDataBlockList,
int32_t
startOffset
,
int32_t
rowSize
,
const
char
*
tableId
,
STableMeta
*
pTableMeta
,
int32_t
startOffset
,
int32_t
rowSize
,
const
char
*
tableId
,
STableMeta
*
pTableMeta
,
STableDataBlocks
**
dataBlocks
);
STableDataBlocks
**
dataBlocks
);
SVnodeSidList
*
tscGetVnodeSidList
(
SSuperTableMeta
*
pMetricmeta
,
int32_t
vnodeIdx
);
UNUSED_FUNC
STableIdInfo
*
tscGetMeterSidInfo
(
SVnodeSidList
*
pSidList
,
int32_t
idx
);
STableIdInfo
*
tscGetMeterSidInfo
(
SVnodeSidList
*
pSidList
,
int32_t
idx
);
/**
/**
*
*
...
@@ -106,7 +106,7 @@ bool tscIsProjectionQueryOnSTable(SQueryInfo* pQueryInfo, int32_t tableIndex);
...
@@ -106,7 +106,7 @@ bool tscIsProjectionQueryOnSTable(SQueryInfo* pQueryInfo, int32_t tableIndex);
bool
tscProjectionQueryOnTable
(
SQueryInfo
*
pQueryInfo
);
bool
tscProjectionQueryOnTable
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsTwoStageSTableQuery
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
bool
tscIsTwoStageSTableQuery
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
bool
tscQueryOn
Metric
(
SSqlCmd
*
pCmd
);
bool
tscQueryOn
STable
(
SSqlCmd
*
pCmd
);
bool
tscQueryTags
(
SQueryInfo
*
pQueryInfo
);
bool
tscQueryTags
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsSelectivityWithTagQuery
(
SSqlCmd
*
pCmd
);
bool
tscIsSelectivityWithTagQuery
(
SSqlCmd
*
pCmd
);
...
@@ -115,60 +115,58 @@ void tscAddSpecialColumnForSelect(SQueryInfo* pQueryInfo, int32_t outputColIndex
...
@@ -115,60 +115,58 @@ void tscAddSpecialColumnForSelect(SQueryInfo* pQueryInfo, int32_t outputColIndex
void
addRequiredTagColumn
(
SQueryInfo
*
pQueryInfo
,
int32_t
tagColIndex
,
int32_t
tableIndex
);
void
addRequiredTagColumn
(
SQueryInfo
*
pQueryInfo
,
int32_t
tagColIndex
,
int32_t
tableIndex
);
int32_t
setMeterID
(
STableMetaInfo
*
pTableMetaInfo
,
SSQLToken
*
pzTableName
,
SSqlObj
*
pSql
);
int32_t
tscSetTableId
(
STableMetaInfo
*
pTableMetaInfo
,
SSQLToken
*
pzTableName
,
SSqlObj
*
pSql
);
void
tscClearInterpInfo
(
SQueryInfo
*
pQueryInfo
);
void
tscClearInterpInfo
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsInsertOrImportData
(
char
*
sqlstr
);
bool
tscIsInsertOrImportData
(
char
*
sqlstr
);
/* use for keep current db info temporarily, for handle table with db prefix */
/* use for keep current db info temporarily, for handle table with db prefix */
// todo remove it
void
tscGetDBInfoFromMeterId
(
char
*
tableId
,
char
*
db
);
void
tscGetDBInfoFromMeterId
(
char
*
tableId
,
char
*
db
);
int
tscAllocPayload
(
SSqlCmd
*
pCmd
,
int
size
);
int
tscAllocPayload
(
SSqlCmd
*
pCmd
,
int
size
);
void
tscFieldInfoSetValFromSchema
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
,
SSchema
*
pSchema
);
TAOS_FIELD
tscCreateField
(
int8_t
type
,
const
char
*
name
,
int16_t
bytes
);
void
tscFieldInfoSetValFromField
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
,
TAOS_FIELD
*
pField
);
void
tscFieldInfoSetValue
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
,
int8_t
type
,
const
char
*
name
,
int16_t
bytes
);
void
tscFieldInfoUpdateVisible
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
,
bool
visible
);
void
tscFieldInfoSetExpr
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
,
SSqlExpr
*
pExpr
);
void
tscFieldInfoSetBinExpr
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
,
SSqlFunctionExpr
*
pExpr
);
void
tscFieldInfoCalOffset
(
SQueryInfo
*
pQueryInfo
);
SFieldSupInfo
*
tscFieldInfoAppend
(
SFieldInfo
*
pFieldInfo
,
TAOS_FIELD
*
pField
);
void
tscFieldInfoCopy
(
SFieldInfo
*
src
,
SFieldInfo
*
dst
,
const
int32_t
*
indexList
,
int32_t
size
);
SFieldSupInfo
*
tscFieldInfoInsert
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
,
TAOS_FIELD
*
field
);
void
tscFieldInfoCopyAll
(
SFieldInfo
*
dst
,
SFieldInfo
*
src
);
SFieldSupInfo
*
tscFieldInfoGetSupp
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
);
TAOS_FIELD
*
tscFieldInfoGetField
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
);
void
tscFieldInfoUpdateOffset
(
SQueryInfo
*
pQueryInfo
);
void
tscFieldInfoCopy
(
SFieldInfo
*
dst
,
const
SFieldInfo
*
src
);
void
tscFieldInfoUpdateOffsetForInterResult
(
SQueryInfo
*
pQueryInfo
);
void
tscFieldInfoUpdateOffsetForInterResult
(
SQueryInfo
*
pQueryInfo
);
TAOS_FIELD
*
tscFieldInfoGetField
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
);
int16_t
tscFieldInfoGetOffset
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
);
int16_t
tscFieldInfoGetOffset
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
);
void
tscFieldInfoClear
(
SFieldInfo
*
pFieldInfo
);
int32_t
tscGetResRowLength
(
SQueryInfo
*
pQueryInfo
);
void
tscClearFieldInfo
(
SFieldInfo
*
pFieldInfo
);
int32_t
tscNumOfFields
(
SQueryInfo
*
pQueryInfo
);
int32_t
tscNumOfFields
(
SQueryInfo
*
pQueryInfo
);
int32_t
tscFieldInfoCompare
(
SFieldInfo
*
pFieldInfo1
,
SFieldInfo
*
pFieldInfo2
);
int32_t
tscFieldInfoCompare
(
const
SFieldInfo
*
pFieldInfo1
,
const
SFieldInfo
*
pFieldInfo2
);
void
addExprParams
(
SSqlExpr
*
pExpr
,
char
*
argument
,
int32_t
type
,
int32_t
bytes
,
int16_t
tableIndex
);
void
addExprParams
(
SSqlExpr
*
pExpr
,
char
*
argument
,
int32_t
type
,
int32_t
bytes
,
int16_t
tableIndex
);
int32_t
tscGetResRowLength
(
SArray
*
pExprList
);
SSqlExpr
*
tscSqlExprInsert
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
,
int16_t
functionId
,
SColumnIndex
*
pColIndex
,
int16_t
type
,
SSqlExpr
*
tscSqlExprInsert
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
,
int16_t
functionId
,
SColumnIndex
*
pColIndex
,
int16_t
type
,
int16_t
size
,
int16_t
interSize
);
SSqlExpr
*
tscSqlExprAppend
(
SQueryInfo
*
pQueryInfo
,
int16_t
functionId
,
SColumnIndex
*
pColIndex
,
int16_t
type
,
int16_t
size
,
int16_t
interSize
);
int16_t
size
,
int16_t
interSize
);
SSqlExpr
*
tscSqlExprInsertEmpty
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
,
int16_t
functionId
);
SSqlExpr
*
tscSqlExprUpdate
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
,
int16_t
functionId
,
int16_t
srcColumnIndex
,
int16_t
type
,
SSqlExpr
*
tscSqlExprUpdate
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
,
int16_t
functionId
,
int16_t
srcColumnIndex
,
int16_t
type
,
int16_t
size
);
int16_t
size
);
int32_t
tscSqlExprNumOfExprs
(
SQueryInfo
*
pQueryInfo
);
int32_t
tscSqlExprNumOfExprs
(
SQueryInfo
*
pQueryInfo
);
SSqlExpr
*
tscSqlExprGet
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
);
SSqlExpr
*
tscSqlExprGet
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
);
void
tscSqlExprCopy
(
SSqlExprInfo
*
dst
,
const
SSqlExprInfo
*
src
,
uint64_t
uid
,
bool
deepcopy
);
SArray
*
tscSqlExprCopy
(
const
SArray
*
src
,
uint64_t
uid
,
bool
deepcopy
);
void
*
tscSqlExprDestroy
(
SSqlExpr
*
pExpr
);
void
tscSqlExprInfoDestroy
(
SArray
*
pExprInfo
);
void
tscSqlExprInfoDestroy
(
SSqlExprInfo
*
pExprInfo
);
SColumnBase
*
tscColumnBaseInfoInsert
(
SQueryInfo
*
pQueryInfo
,
SColumnIndex
*
colIndex
);
SColumn
*
tscColumnClone
(
const
SColumn
*
src
);
void
tscColumnFilterInfoCopy
(
SColumnFilterInfo
*
dst
,
const
SColumnFilterInfo
*
src
);
SColumn
*
tscColumnListInsert
(
SArray
*
pColList
,
SColumnIndex
*
colIndex
);
void
tscColumnBaseCopy
(
SColumnBase
*
dst
,
const
SColumnBase
*
src
);
void
tscColumnListCopy
(
SArray
*
dst
,
const
SArray
*
src
,
int16_t
tableIndex
);
void
tscColumnListDestroy
(
SArray
*
pColList
);
void
tscColumnBaseInfoCopy
(
SColumnBaseInfo
*
dst
,
const
SColumnBaseInfo
*
src
,
int16_t
tableIndex
);
SColumnFilterInfo
*
tscFilterInfoClone
(
const
SColumnFilterInfo
*
src
,
int32_t
numOfFilters
);
SColumnBase
*
tscColumnBaseInfoGet
(
SColumnBaseInfo
*
pColumnBaseInfo
,
int32_t
index
);
void
tscColumnBaseInfoUpdateTableIndex
(
SColumnBaseInfo
*
pColList
,
int16_t
tableIndex
);
void
tscColumnBaseInfoReserve
(
SColumnBaseInfo
*
pColumnBaseInfo
,
int32_t
size
);
void
tscColumnBaseInfoDestroy
(
SColumnBaseInfo
*
pColumnBaseInfo
);
int32_t
tscValidateName
(
SSQLToken
*
pToken
);
int32_t
tscValidateName
(
SSQLToken
*
pToken
);
...
@@ -188,17 +186,16 @@ void tscGetSrcColumnInfo(SSrcColumnInfo* pColInfo, SQueryInfo* pQueryInfo);
...
@@ -188,17 +186,16 @@ void tscGetSrcColumnInfo(SSrcColumnInfo* pColInfo, SQueryInfo* pQueryInfo);
void
tscSetFreeHeatBeat
(
STscObj
*
pObj
);
void
tscSetFreeHeatBeat
(
STscObj
*
pObj
);
bool
tscShouldFreeHeatBeat
(
SSqlObj
*
pHb
);
bool
tscShouldFreeHeatBeat
(
SSqlObj
*
pHb
);
void
tscCleanSqlCmd
(
SSqlCmd
*
pCmd
);
void
tscCleanSqlCmd
(
SSqlCmd
*
pCmd
);
bool
tscShould
FreeAsyncSqlObj
(
SSqlObj
*
pSql
);
bool
tscShould
BeFreed
(
SSqlObj
*
pSql
);
void
tsc
RemoveAllMeter
MetaInfo
(
SQueryInfo
*
pQueryInfo
,
const
char
*
address
,
bool
removeFromCache
);
void
tsc
ClearAllTable
MetaInfo
(
SQueryInfo
*
pQueryInfo
,
const
char
*
address
,
bool
removeFromCache
);
STableMetaInfo
*
tscGetTableMetaInfoFromCmd
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
,
int32_t
tableIndex
);
STableMetaInfo
*
tscGetTableMetaInfoFromCmd
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
,
int32_t
tableIndex
);
STableMetaInfo
*
tscGetMetaInfo
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
STableMetaInfo
*
tscGetMetaInfo
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
SQueryInfo
*
tscGetQueryInfoDetail
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
);
SQueryInfo
*
tscGetQueryInfoDetail
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
);
int32_t
tscGetQueryInfoDetailSafely
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
,
SQueryInfo
**
pQueryInfo
);
int32_t
tscGetQueryInfoDetailSafely
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
,
SQueryInfo
**
pQueryInfo
);
STableMetaInfo
*
tscGetMeterMetaInfoByUid
(
SQueryInfo
*
pQueryInfo
,
uint64_t
uid
,
int32_t
*
index
);
void
tscClearMeterMetaInfo
(
STableMetaInfo
*
pTableMetaInfo
,
bool
removeFromCache
);
void
tscClearMeterMetaInfo
(
STableMetaInfo
*
pTableMetaInfo
,
bool
removeFromCache
);
STableMetaInfo
*
tscAddTableMetaInfo
(
SQueryInfo
*
pQueryInfo
,
const
char
*
name
,
STableMeta
*
pTableMeta
,
STableMetaInfo
*
tscAddTableMetaInfo
(
SQueryInfo
*
pQueryInfo
,
const
char
*
name
,
STableMeta
*
pTableMeta
,
SVgroupsInfo
*
vgroupList
,
int16_t
numOfTags
,
int16_t
*
tags
);
SVgroupsInfo
*
vgroupList
,
int16_t
numOfTags
,
int16_t
*
tags
);
...
@@ -208,7 +205,6 @@ int32_t tscAddSubqueryInfo(SSqlCmd *pCmd);
...
@@ -208,7 +205,6 @@ int32_t tscAddSubqueryInfo(SSqlCmd *pCmd);
void
tscFreeSubqueryInfo
(
SSqlCmd
*
pCmd
);
void
tscFreeSubqueryInfo
(
SSqlCmd
*
pCmd
);
void
tscClearSubqueryInfo
(
SSqlCmd
*
pCmd
);
void
tscClearSubqueryInfo
(
SSqlCmd
*
pCmd
);
void
tscGetMetricMetaCacheKey
(
SQueryInfo
*
pQueryInfo
,
char
*
keyStr
,
uint64_t
uid
);
int
tscGetSTableVgroupInfo
(
SSqlObj
*
pSql
,
int32_t
clauseIndex
);
int
tscGetSTableVgroupInfo
(
SSqlObj
*
pSql
,
int32_t
clauseIndex
);
int
tscGetTableMeta
(
SSqlObj
*
pSql
,
STableMetaInfo
*
pTableMetaInfo
);
int
tscGetTableMeta
(
SSqlObj
*
pSql
,
STableMetaInfo
*
pTableMetaInfo
);
int
tscGetMeterMetaEx
(
SSqlObj
*
pSql
,
STableMetaInfo
*
pTableMetaInfo
,
bool
createIfNotExists
);
int
tscGetMeterMetaEx
(
SSqlObj
*
pSql
,
STableMetaInfo
*
pTableMetaInfo
,
bool
createIfNotExists
);
...
@@ -242,11 +238,6 @@ void doAddGroupColumnForSubquery(SQueryInfo* pQueryInfo, int32_t tagIndex);
...
@@ -242,11 +238,6 @@ void doAddGroupColumnForSubquery(SQueryInfo* pQueryInfo, int32_t tagIndex);
int16_t
tscGetJoinTagColIndexByUid
(
STagCond
*
pTagCond
,
uint64_t
uid
);
int16_t
tscGetJoinTagColIndexByUid
(
STagCond
*
pTagCond
,
uint64_t
uid
);
TAOS
*
taos_connect_a
(
char
*
ip
,
char
*
user
,
char
*
pass
,
char
*
db
,
uint16_t
port
,
void
(
*
fp
)(
void
*
,
TAOS_RES
*
,
int
),
void
*
param
,
void
**
taos
);
void
sortRemoveDuplicates
(
STableDataBlocks
*
dataBuf
);
void
tscPrintSelectClause
(
SSqlObj
*
pSql
,
int32_t
subClauseIndex
);
void
tscPrintSelectClause
(
SSqlObj
*
pSql
,
int32_t
subClauseIndex
);
bool
hasMoreVnodesToTry
(
SSqlObj
*
pSql
);
bool
hasMoreVnodesToTry
(
SSqlObj
*
pSql
);
...
...
src/client/inc/tsclient.h
浏览文件 @
6dbca070
...
@@ -22,32 +22,30 @@ extern "C" {
...
@@ -22,32 +22,30 @@ extern "C" {
#include "os.h"
#include "os.h"
#include "qsqlparser.h"
#include "qsqltype.h"
#include "qtsbuf.h"
#include "taos.h"
#include "taos.h"
#include "taosdef.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "taosmsg.h"
#include "tarray.h"
#include "tarray.h"
#include "tglobal.h"
#include "tglobal.h"
#include "trpc.h"
#include "tsqlfunction.h"
#include "tsqlfunction.h"
#include "tutil.h"
#include "tutil.h"
#define TSC_GET_RESPTR_BASE(res, _queryinfo, col) (res->data + ((_queryinfo)->fieldsInfo.pSqlExpr[col]->offset) * res->numOfRows)
#include "qsqlparser.h"
#include "qsqltype.h"
#include "qtsbuf.h"
#include "queryExecutor.h"
// forward declaration
// forward declaration
struct
SSqlInfo
;
struct
SSqlInfo
;
struct
SLocalReducer
;
typedef
SCMSTableVgroupRspMsg
SVgroupsInfo
;
// data source from sql string or from file
enum
{
DATA_FROM_SQL_STRING
=
1
,
DATA_FROM_DATA_FILE
=
2
,
};
typedef
struct
SSqlGroupbyExpr
{
typedef
SCMSTableVgroupRspMsg
SVgroupsInfo
;
int16_t
tableIndex
;
int16_t
numOfGroupCols
;
SColIndex
columnInfo
[
TSDB_MAX_TAGS
];
// group by columns information
int16_t
orderIndex
;
// order by column index
int16_t
orderType
;
// order by type: asc/desc
}
SSqlGroupbyExpr
;
typedef
struct
STableComInfo
{
typedef
struct
STableComInfo
{
uint8_t
numOfTags
;
uint8_t
numOfTags
;
...
@@ -57,20 +55,23 @@ typedef struct STableComInfo {
...
@@ -57,20 +55,23 @@ typedef struct STableComInfo {
}
STableComInfo
;
}
STableComInfo
;
typedef
struct
STableMeta
{
typedef
struct
STableMeta
{
//super table if it is created according to super table, otherwise, tableInfo is used
// super table if it is created according to super table, otherwise, tableInfo is used
union
{
struct
STableMeta
*
pSTable
;
STableComInfo
tableInfo
;
};
union
{
uint8_t
tableType
;
struct
STableMeta
*
pSTable
;
int16_t
sversion
;
STableComInfo
tableInfo
;
};
uint8_t
tableType
;
int16_t
sversion
;
SCMVgroupInfo
vgroupInfo
;
SCMVgroupInfo
vgroupInfo
;
int32_t
sid
;
// the index of one table in a virtual node
int32_t
sid
;
// the index of one table in a virtual node
uint64_t
uid
;
// unique id of a table
uint64_t
uid
;
// unique id of a table
SSchema
schema
[];
// if the table is TSDB_CHILD_TABLE, schema is acquired by super table meta info
SSchema
schema
[];
// if the table is TSDB_CHILD_TABLE, schema is acquired by super table meta info
}
STableMeta
;
}
STableMeta
;
typedef
struct
STableMetaInfo
{
typedef
struct
STableMetaInfo
{
STableMeta
*
pTableMeta
;
// table meta, cached in client side and acquried by name
STableMeta
*
pTableMeta
;
// table meta, cached in client side and acquried by name
SVgroupsInfo
*
vgroupList
;
SVgroupsInfo
*
vgroupList
;
/*
/*
* 1. keep the vnode index during the multi-vnode super table projection query
* 1. keep the vnode index during the multi-vnode super table projection query
* 2. keep the vnode index for multi-vnode insertion
* 2. keep the vnode index for multi-vnode insertion
...
@@ -83,16 +84,16 @@ typedef struct STableMetaInfo {
...
@@ -83,16 +84,16 @@ typedef struct STableMetaInfo {
/* the structure for sql function in select clause */
/* the structure for sql function in select clause */
typedef
struct
SSqlExpr
{
typedef
struct
SSqlExpr
{
char
aliasName
[
TSDB_COL_NAME_LEN
];
// as aliasName
char
aliasName
[
TSDB_COL_NAME_LEN
];
// as aliasName
SColIndex
colInfo
;
SColIndex
colInfo
;
int64_t
uid
;
// refactor use the pointer
int64_t
uid
;
// refactor use the pointer
int16_t
functionId
;
// function id in aAgg array
int16_t
functionId
;
// function id in aAgg array
int16_t
resType
;
// return value type
int16_t
resType
;
// return value type
int16_t
resBytes
;
// length of return value
int16_t
resBytes
;
// length of return value
int16_t
interResBytes
;
// inter result buffer size
int16_t
interResBytes
;
// inter result buffer size
int16_t
numOfParams
;
// argument value of each function
int16_t
numOfParams
;
// argument value of each function
tVariant
param
[
3
];
// parameters are not more than 3
tVariant
param
[
3
];
// parameters are not more than 3
int32_t
offset
;
// sub result column value of arithmetic expression.
int32_t
offset
;
// sub result column value of arithmetic expression.
}
SSqlExpr
;
}
SSqlExpr
;
typedef
struct
SColumnIndex
{
typedef
struct
SColumnIndex
{
...
@@ -100,46 +101,27 @@ typedef struct SColumnIndex {
...
@@ -100,46 +101,27 @@ typedef struct SColumnIndex {
int16_t
columnIndex
;
int16_t
columnIndex
;
}
SColumnIndex
;
}
SColumnIndex
;
typedef
struct
SFieldInfo
{
typedef
struct
SFieldSupInfo
{
int16_t
numOfOutputCols
;
// number of column in result
bool
visible
;
int16_t
numOfAlloc
;
// allocated size
SArithExprInfo
*
pArithExprInfo
;
TAOS_FIELD
*
pFields
;
SSqlExpr
*
pSqlExpr
;
}
SFieldSupInfo
;
/*
typedef
struct
SFieldInfo
{
* define if this column is belong to the queried result, it may be add by parser to faciliate
int16_t
numOfOutput
;
// number of column in result
* the query process
SArray
*
pFields
;
// SArray<TAOS_FIELD>
*
SArray
*
pSupportInfo
;
// SArray<SFieldSupInfo>
* NOTE: these hidden columns always locate at the end of the output columns
*/
bool
*
pVisibleCols
;
int32_t
numOfHiddenCols
;
// the number of column not belongs to the queried result columns
SSqlFunctionExpr
**
pExpr
;
// used for aggregation arithmetic express,such as count(*)+count(*)
SSqlExpr
**
pSqlExpr
;
}
SFieldInfo
;
}
SFieldInfo
;
typedef
struct
SSqlExprInfo
{
typedef
struct
SColumn
{
int16_t
numOfAlloc
;
int16_t
numOfExprs
;
SSqlExpr
**
pExprs
;
}
SSqlExprInfo
;
typedef
struct
SColumnBase
{
SColumnIndex
colIndex
;
SColumnIndex
colIndex
;
int32_t
numOfFilters
;
int32_t
numOfFilters
;
SColumnFilterInfo
*
filterInfo
;
SColumnFilterInfo
*
filterInfo
;
}
SColumnBase
;
}
SColumn
;
typedef
struct
SColumnBaseInfo
{
int16_t
numOfAlloc
;
int16_t
numOfCols
;
SColumnBase
*
pColList
;
}
SColumnBaseInfo
;
struct
SLocalReducer
;
typedef
struct
SCond
{
typedef
struct
SCond
{
uint64_t
uid
;
uint64_t
uid
;
int32_t
len
;
// length of tag query condition data
int32_t
len
;
// length of tag query condition data
char
*
cond
;
char
*
cond
;
}
SCond
;
}
SCond
;
...
@@ -166,7 +148,7 @@ typedef struct STagCond {
...
@@ -166,7 +148,7 @@ typedef struct STagCond {
SJoinInfo
joinInfo
;
SJoinInfo
joinInfo
;
// for different table, the query condition must be seperated
// for different table, the query condition must be seperated
SArray
*
pCond
;
SArray
*
pCond
;
}
STagCond
;
}
STagCond
;
typedef
struct
SParamInfo
{
typedef
struct
SParamInfo
{
...
@@ -207,7 +189,7 @@ typedef struct STableDataBlocks {
...
@@ -207,7 +189,7 @@ typedef struct STableDataBlocks {
SParamInfo
*
params
;
SParamInfo
*
params
;
}
STableDataBlocks
;
}
STableDataBlocks
;
typedef
struct
SDataBlockList
{
typedef
struct
SDataBlockList
{
// todo remove
uint32_t
nSize
;
uint32_t
nSize
;
uint32_t
nAlloc
;
uint32_t
nAlloc
;
STableDataBlocks
**
pData
;
STableDataBlocks
**
pData
;
...
@@ -218,14 +200,14 @@ typedef struct SQueryInfo {
...
@@ -218,14 +200,14 @@ typedef struct SQueryInfo {
uint16_t
type
;
// query/insert/import type
uint16_t
type
;
// query/insert/import type
char
slidingTimeUnit
;
char
slidingTimeUnit
;
int64_t
etime
,
stime
;
STimeWindow
window
;
int64_t
intervalTime
;
// aggregation time interval
int64_t
intervalTime
;
// aggregation time interval
int64_t
slidingTime
;
// sliding window in mseconds
int64_t
slidingTime
;
// sliding window in mseconds
SSqlGroupbyExpr
groupbyExpr
;
// group by tags info
SSqlGroupbyExpr
groupbyExpr
;
// group by tags info
S
ColumnBaseInfo
colList
;
S
Array
*
colList
;
// SArray<SColumn*>
SFieldInfo
fieldsInfo
;
SFieldInfo
fieldsInfo
;
S
SqlExprInfo
exprsInfo
;
S
Array
*
exprsInfo
;
// SArray<SSqlExpr*>
SLimitVal
limit
;
SLimitVal
limit
;
SLimitVal
slimit
;
SLimitVal
slimit
;
STagCond
tagCond
;
STagCond
tagCond
;
...
@@ -242,19 +224,13 @@ typedef struct SQueryInfo {
...
@@ -242,19 +224,13 @@ typedef struct SQueryInfo {
int64_t
prjOffset
;
int64_t
prjOffset
;
}
SQueryInfo
;
}
SQueryInfo
;
// data source from sql string or from file
enum
{
DATA_FROM_SQL_STRING
=
1
,
DATA_FROM_DATA_FILE
=
2
,
};
typedef
struct
{
typedef
struct
{
int
command
;
int
command
;
uint8_t
msgType
;
uint8_t
msgType
;
union
{
union
{
bool
existsCheck
;
// check if the table exists or not
bool
existsCheck
;
// check if the table exists or not
bool
autoCreated
;
// if the table is missing, on-the-fly create it. during getmeterMeta
bool
autoCreated
;
// if the table is missing, on-the-fly create it. during getmeterMeta
int8_t
dataSourceType
;
// load data from file or not
int8_t
dataSourceType
;
// load data from file or not
};
};
...
@@ -271,11 +247,11 @@ typedef struct {
...
@@ -271,11 +247,11 @@ typedef struct {
int32_t
payloadLen
;
int32_t
payloadLen
;
SQueryInfo
**
pQueryInfo
;
SQueryInfo
**
pQueryInfo
;
int32_t
numOfClause
;
int32_t
numOfClause
;
SDataBlockList
*
pDataBlocks
;
// submit data blocks after parsing sql
SDataBlockList
*
pDataBlocks
;
// submit data blocks after parsing sql
char
*
curSql
;
// current sql, resume position of sql after parsing paused
char
*
curSql
;
// current sql, resume position of sql after parsing paused
void
*
pTableList
;
// referred table involved in sql
void
*
pTableList
;
// referred table involved in sql
// for parameter ('?') binding and batch processing
// for parameter ('?') binding and batch processing
int32_t
batchSize
;
int32_t
batchSize
;
int32_t
numOfParams
;
int32_t
numOfParams
;
...
@@ -286,50 +262,48 @@ typedef struct SResRec {
...
@@ -286,50 +262,48 @@ typedef struct SResRec {
int
numOfTotal
;
int
numOfTotal
;
}
SResRec
;
}
SResRec
;
struct
STSBuf
;
typedef
struct
{
typedef
struct
{
int64_t
numOfRows
;
// num of results in current retrieved
int64_t
numOfRows
;
// num of results in current retrieved
int64_t
numOfTotal
;
// num of total results
int64_t
numOfTotal
;
// num of total results
int64_t
numOfTotalInCurrentClause
;
// num of total result in current subclause
int64_t
numOfTotalInCurrentClause
;
// num of total result in current subclause
char
*
pRsp
;
char
*
pRsp
;
int32_t
rspType
;
int32_t
rspType
;
int32_t
rspLen
;
int32_t
rspLen
;
uint64_t
qhandle
;
uint64_t
qhandle
;
int64_t
uid
;
int64_t
uid
;
int64_t
useconds
;
int64_t
useconds
;
int64_t
offset
;
// offset value from vnode during projection query of stable
int64_t
offset
;
// offset value from vnode during projection query of stable
int32_t
row
;
int32_t
row
;
int16_t
numOfCols
;
int16_t
numOfCols
;
int16_t
precision
;
int16_t
precision
;
bool
completed
;
bool
completed
;
int32_t
code
;
int32_t
code
;
int32_t
numOfGroups
;
int32_t
numOfGroups
;
SResRec
*
pGroupRec
;
SResRec
*
pGroupRec
;
char
*
data
;
char
*
data
;
void
**
tsrow
;
void
**
tsrow
;
char
**
buffer
;
// Buffer used to put multibytes encoded using unicode (wchar_t)
char
**
buffer
;
// Buffer used to put multibytes encoded using unicode (wchar_t)
SColumnIndex
*
pColumnIndex
;
SColumnIndex
*
pColumnIndex
;
struct
SLocalReducer
*
pLocalReducer
;
struct
SLocalReducer
*
pLocalReducer
;
}
SSqlRes
;
}
SSqlRes
;
typedef
struct
STscObj
{
typedef
struct
STscObj
{
void
*
signature
;
void
*
signature
;
void
*
pTimer
;
void
*
pTimer
;
char
mgmtIp
[
TSDB_USER_LEN
];
char
mgmtIp
[
TSDB_USER_LEN
];
uint16_t
mgmtPort
;
uint16_t
mgmtPort
;
char
user
[
TSDB_USER_LEN
];
char
user
[
TSDB_USER_LEN
];
char
pass
[
TSDB_KEY_LEN
];
char
pass
[
TSDB_KEY_LEN
];
char
acctId
[
TSDB_DB_NAME_LEN
];
char
acctId
[
TSDB_DB_NAME_LEN
];
char
db
[
TSDB_TABLE_ID_LEN
];
char
db
[
TSDB_TABLE_ID_LEN
];
char
sversion
[
TSDB_VERSION_LEN
];
char
sversion
[
TSDB_VERSION_LEN
];
char
writeAuth
:
1
;
char
writeAuth
:
1
;
char
superAuth
:
1
;
char
superAuth
:
1
;
struct
SSqlObj
*
pSql
;
struct
SSqlObj
*
pSql
;
struct
SSqlObj
*
pHb
;
struct
SSqlObj
*
pHb
;
struct
SSqlObj
*
sqlList
;
struct
SSqlObj
*
sqlList
;
struct
SSqlStream
*
streamList
;
struct
SSqlStream
*
streamList
;
pthread_mutex_t
mutex
;
pthread_mutex_t
mutex
;
}
STscObj
;
}
STscObj
;
typedef
struct
SSqlObj
{
typedef
struct
SSqlObj
{
...
@@ -337,23 +311,23 @@ typedef struct SSqlObj {
...
@@ -337,23 +311,23 @@ typedef struct SSqlObj {
STscObj
*
pTscObj
;
STscObj
*
pTscObj
;
void
(
*
fp
)();
void
(
*
fp
)();
void
(
*
fetchFp
)();
void
(
*
fetchFp
)();
void
*
param
;
void
*
param
;
uint32_t
ip
;
uint32_t
ip
;
short
vnode
;
short
vnode
;
int64_t
stime
;
int64_t
stime
;
uint32_t
queryId
;
uint32_t
queryId
;
void
*
pStream
;
void
*
pStream
;
void
*
pSubscription
;
void
*
pSubscription
;
char
*
sqlstr
;
char
*
sqlstr
;
char
retry
;
char
retry
;
char
maxRetry
;
char
maxRetry
;
SRpcIpSet
ipList
;
SRpcIpSet
ipList
;
char
freed
:
4
;
char
freed
:
4
;
char
listed
:
4
;
char
listed
:
4
;
tsem_t
rspSem
;
tsem_t
rspSem
;
SSqlCmd
cmd
;
SSqlCmd
cmd
;
SSqlRes
res
;
SSqlRes
res
;
uint8_t
numOfSubs
;
uint8_t
numOfSubs
;
struct
SSqlObj
**
pSubs
;
struct
SSqlObj
**
pSubs
;
struct
SSqlObj
*
prev
,
*
next
;
struct
SSqlObj
*
prev
,
*
next
;
}
SSqlObj
;
}
SSqlObj
;
...
@@ -387,13 +361,10 @@ typedef struct SSqlStream {
...
@@ -387,13 +361,10 @@ typedef struct SSqlStream {
}
SSqlStream
;
}
SSqlStream
;
int32_t
tscInitRpc
(
const
char
*
user
,
const
char
*
secret
);
int32_t
tscInitRpc
(
const
char
*
user
,
const
char
*
secret
);
void
tscInitMsgsFp
();
// tscSql API
int
tsParseSql
(
SSqlObj
*
pSql
,
bool
multiVnodeInsertion
);
int
tsParseSql
(
SSqlObj
*
pSql
,
bool
multiVnodeInsertion
);
void
tscInitMsgsFp
();
extern
int
(
*
tscBuildMsg
[
TSDB_SQL_MAX
])(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
);
void
tscProcessMsgFromServer
(
SRpcMsg
*
rpcMsg
);
void
tscProcessMsgFromServer
(
SRpcMsg
*
rpcMsg
);
int
tscProcessSql
(
SSqlObj
*
pSql
);
int
tscProcessSql
(
SSqlObj
*
pSql
);
...
@@ -406,12 +377,8 @@ int tscProcessLocalCmd(SSqlObj *pSql);
...
@@ -406,12 +377,8 @@ int tscProcessLocalCmd(SSqlObj *pSql);
int
tscCfgDynamicOptions
(
char
*
msg
);
int
tscCfgDynamicOptions
(
char
*
msg
);
int
taos_retrieve
(
TAOS_RES
*
res
);
int
taos_retrieve
(
TAOS_RES
*
res
);
/*
int32_t
tscTansformSQLFuncForSTableQuery
(
SQueryInfo
*
pQueryInfo
);
* transfer function for metric query in stream computing, the function need to be change
void
tscRestoreSQLFuncForSTableQuery
(
SQueryInfo
*
pQueryInfo
);
* before send query message to vnode
*/
int32_t
tscTansformSQLFunctionForSTableQuery
(
SQueryInfo
*
pQueryInfo
);
void
tscRestoreSQLFunctionForMetricQuery
(
SQueryInfo
*
pQueryInfo
);
int32_t
tscCreateResPointerInfo
(
SSqlRes
*
pRes
,
SQueryInfo
*
pQueryInfo
);
int32_t
tscCreateResPointerInfo
(
SSqlRes
*
pRes
,
SQueryInfo
*
pQueryInfo
);
void
tscDestroyResPointerInfo
(
SSqlRes
*
pRes
);
void
tscDestroyResPointerInfo
(
SSqlRes
*
pRes
);
...
@@ -441,10 +408,13 @@ void tscFreeSqlObj(SSqlObj *pObj);
...
@@ -441,10 +408,13 @@ void tscFreeSqlObj(SSqlObj *pObj);
void
tscCloseTscObj
(
STscObj
*
pObj
);
void
tscCloseTscObj
(
STscObj
*
pObj
);
void
doAsyncQuery
(
STscObj
*
pObj
,
SSqlObj
*
pSql
,
void
(
*
fp
)(),
void
*
param
,
const
char
*
sqlstr
,
size_t
sqlLen
);
TAOS
*
taos_connect_a
(
char
*
ip
,
char
*
user
,
char
*
pass
,
char
*
db
,
uint16_t
port
,
void
(
*
fp
)(
void
*
,
TAOS_RES
*
,
int
),
void
*
param
,
void
**
taos
);
void
doAsyncQuery
(
STscObj
*
pObj
,
SSqlObj
*
pSql
,
void
(
*
fp
)(),
void
*
param
,
const
char
*
sqlstr
,
size_t
sqlLen
);
void
tscProcessMultiVnodesInsertFromFile
(
SSqlObj
*
pSql
);
void
tscProcessMultiVnodesInsertFromFile
(
SSqlObj
*
pSql
);
void
tscKill
Metric
Query
(
SSqlObj
*
pSql
);
void
tscKill
STable
Query
(
SSqlObj
*
pSql
);
void
tscInitResObjForLocalQuery
(
SSqlObj
*
pObj
,
int32_t
numOfRes
,
int32_t
rowLen
);
void
tscInitResObjForLocalQuery
(
SSqlObj
*
pObj
,
int32_t
numOfRes
,
int32_t
rowLen
);
bool
tscIsUpdateQuery
(
STscObj
*
pObj
);
bool
tscIsUpdateQuery
(
STscObj
*
pObj
);
bool
tscHasReachLimitation
(
SQueryInfo
*
pQueryInfo
,
SSqlRes
*
pRes
);
bool
tscHasReachLimitation
(
SQueryInfo
*
pQueryInfo
,
SSqlRes
*
pRes
);
...
@@ -453,19 +423,22 @@ char *tscGetErrorMsgPayload(SSqlCmd *pCmd);
...
@@ -453,19 +423,22 @@ char *tscGetErrorMsgPayload(SSqlCmd *pCmd);
int32_t
tscInvalidSQLErrMsg
(
char
*
msg
,
const
char
*
additionalInfo
,
const
char
*
sql
);
int32_t
tscInvalidSQLErrMsg
(
char
*
msg
,
const
char
*
additionalInfo
,
const
char
*
sql
);
void
tscQueueAsyncFreeResult
(
SSqlObj
*
pSql
);
void
tscQueueAsyncFreeResult
(
SSqlObj
*
pSql
);
int32_t
tscToSQLCmd
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
);
int32_t
tscToSQLCmd
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
);
char
*
tscGetResultColumnChr
(
SSqlRes
*
pRes
,
SQueryInfo
*
pQueryInfo
,
int32_t
column
);
extern
void
*
pVnodeConn
;
extern
void
*
pTscMgmtConn
;
extern
void
*
pVnodeConn
;
extern
void
*
tscCacheHandle
;
extern
void
*
pTscMgmtConn
;
extern
int
slaveIndex
;
extern
void
*
tscCacheHandle
;
extern
void
*
tscTmr
;
extern
int
slaveIndex
;
extern
void
*
tscQhandle
;
extern
void
*
tscTmr
;
extern
int
tscKeepConn
[];
extern
void
*
tscQhandle
;
extern
int
tsInsertHeadSize
;
extern
int
tscKeepConn
[];
extern
int
tscNumOfThreads
;
extern
int
tsInsertHeadSize
;
extern
SRpcIpSet
tscMgmtIpSet
;
extern
int
tscNumOfThreads
;
extern
SRpcIpSet
tscMgmtIpSet
;
extern
int
(
*
tscBuildMsg
[
TSDB_SQL_MAX
])(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
);
typedef
void
(
*
__async_cb_func_t
)(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
);
typedef
void
(
*
__async_cb_func_t
)(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
);
...
...
src/client/src/tscAsync.c
浏览文件 @
6dbca070
...
@@ -287,9 +287,9 @@ void tscAsyncFetchSingleRowProxy(void *param, TAOS_RES *tres, int numOfRows) {
...
@@ -287,9 +287,9 @@ void tscAsyncFetchSingleRowProxy(void *param, TAOS_RES *tres, int numOfRows) {
}
}
for
(
int
i
=
0
;
i
<
pCmd
->
numOfCols
;
++
i
){
for
(
int
i
=
0
;
i
<
pCmd
->
numOfCols
;
++
i
){
S
SqlExpr
*
pExpr
=
pQueryInfo
->
fieldsInfo
.
pSqlExpr
[
i
]
;
S
FieldSupInfo
*
pSup
=
taosArrayGet
(
pQueryInfo
->
fieldsInfo
.
pSupportInfo
,
i
)
;
if
(
pExpr
!=
NULL
)
{
if
(
p
Sup
->
pSql
Expr
!=
NULL
)
{
pRes
->
tsrow
[
i
]
=
TSC_GET_RESPTR_BASE
(
pRes
,
pQueryInfo
,
i
)
+
p
Expr
->
resBytes
*
pRes
->
row
;
// pRes->tsrow[i] = TSC_GET_RESPTR_BASE(pRes, pQueryInfo, i) + pSup->pSql
Expr->resBytes * pRes->row;
}
else
{
}
else
{
//todo add
//todo add
}
}
...
@@ -308,11 +308,12 @@ void tscProcessFetchRow(SSchedMsg *pMsg) {
...
@@ -308,11 +308,12 @@ void tscProcessFetchRow(SSchedMsg *pMsg) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
for
(
int
i
=
0
;
i
<
pCmd
->
numOfCols
;
++
i
)
{
for
(
int
i
=
0
;
i
<
pCmd
->
numOfCols
;
++
i
)
{
SSqlExpr
*
pExpr
=
pQueryInfo
->
fieldsInfo
.
pSqlExpr
[
i
];
SFieldSupInfo
*
pSup
=
taosArrayGet
(
pQueryInfo
->
fieldsInfo
.
pSupportInfo
,
i
);
if
(
pExpr
!=
NULL
)
{
pRes
->
tsrow
[
i
]
=
TSC_GET_RESPTR_BASE
(
pRes
,
pQueryInfo
,
i
)
+
pExpr
->
resBytes
*
pRes
->
row
;
if
(
pSup
->
pSqlExpr
!=
NULL
)
{
pRes
->
tsrow
[
i
]
=
tscGetResultColumnChr
(
pRes
,
pQueryInfo
,
i
);
}
else
{
}
else
{
//
todo add
//
todo add
}
}
}
}
...
@@ -332,7 +333,7 @@ void tscProcessAsyncRes(SSchedMsg *pMsg) {
...
@@ -332,7 +333,7 @@ void tscProcessAsyncRes(SSchedMsg *pMsg) {
int
code
=
pRes
->
code
;
int
code
=
pRes
->
code
;
// in case of async insert, restore the user specified callback function
// in case of async insert, restore the user specified callback function
bool
shouldFree
=
tscShould
FreeAsyncSqlObj
(
pSql
);
bool
shouldFree
=
tscShould
BeFreed
(
pSql
);
if
(
cmd
==
TSDB_SQL_INSERT
)
{
if
(
cmd
==
TSDB_SQL_INSERT
)
{
assert
(
pSql
->
fp
!=
NULL
);
assert
(
pSql
->
fp
!=
NULL
);
...
@@ -487,7 +488,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
...
@@ -487,7 +488,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
*/
*/
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
tscTansformSQLFunc
tion
ForSTableQuery
(
pQueryInfo
);
tscTansformSQLFuncForSTableQuery
(
pQueryInfo
);
tscIncStreamExecutionCount
(
pSql
->
pStream
);
tscIncStreamExecutionCount
(
pSql
->
pStream
);
}
else
{
}
else
{
tscTrace
(
"%p get tableMeta successfully"
,
pSql
);
tscTrace
(
"%p get tableMeta successfully"
,
pSql
);
...
...
src/client/src/tscFunctionImpl.c
浏览文件 @
6dbca070
...
@@ -2940,7 +2940,7 @@ static void col_project_function_f(SQLFunctionCtx *pCtx, int32_t index) {
...
@@ -2940,7 +2940,7 @@ static void col_project_function_f(SQLFunctionCtx *pCtx, int32_t index) {
char
*
pData
=
GET_INPUT_CHAR_INDEX
(
pCtx
,
index
);
char
*
pData
=
GET_INPUT_CHAR_INDEX
(
pCtx
,
index
);
memcpy
(
pCtx
->
aOutputBuf
,
pData
,
pCtx
->
inputBytes
);
memcpy
(
pCtx
->
aOutputBuf
,
pData
,
pCtx
->
inputBytes
);
pCtx
->
aOutputBuf
+=
pCtx
->
inputBytes
/* * GET_FORWARD_DIRECTION_FACTOR(pCtx->order)*/
;
pCtx
->
aOutputBuf
+=
pCtx
->
inputBytes
;
}
}
/**
/**
...
@@ -3297,7 +3297,7 @@ static void diff_function_f(SQLFunctionCtx *pCtx, int32_t index) {
...
@@ -3297,7 +3297,7 @@ static void diff_function_f(SQLFunctionCtx *pCtx, int32_t index) {
char
*
arithmetic_callback_function
(
void
*
param
,
char
*
name
,
int32_t
colId
)
{
char
*
arithmetic_callback_function
(
void
*
param
,
char
*
name
,
int32_t
colId
)
{
SArithmeticSupport
*
pSupport
=
(
SArithmeticSupport
*
)
param
;
SArithmeticSupport
*
pSupport
=
(
SArithmeticSupport
*
)
param
;
S
SqlFunctionExpr
*
pExpr
=
pSupport
->
p
Expr
;
S
ArithExprInfo
*
pExpr
=
pSupport
->
pArith
Expr
;
int32_t
colIndex
=
-
1
;
int32_t
colIndex
=
-
1
;
for
(
int32_t
i
=
0
;
i
<
pExpr
->
binExprInfo
.
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pExpr
->
binExprInfo
.
numOfCols
;
++
i
)
{
...
@@ -3315,7 +3315,7 @@ static void arithmetic_function(SQLFunctionCtx *pCtx) {
...
@@ -3315,7 +3315,7 @@ static void arithmetic_function(SQLFunctionCtx *pCtx) {
GET_RES_INFO
(
pCtx
)
->
numOfRes
+=
pCtx
->
size
;
GET_RES_INFO
(
pCtx
)
->
numOfRes
+=
pCtx
->
size
;
SArithmeticSupport
*
sas
=
(
SArithmeticSupport
*
)
pCtx
->
param
[
1
].
pz
;
SArithmeticSupport
*
sas
=
(
SArithmeticSupport
*
)
pCtx
->
param
[
1
].
pz
;
tSQLBinaryExprCalcTraverse
(
sas
->
pExpr
->
binExprInfo
.
pBinExpr
,
pCtx
->
size
,
pCtx
->
aOutputBuf
,
sas
,
pCtx
->
order
,
tSQLBinaryExprCalcTraverse
(
sas
->
p
Arith
Expr
->
binExprInfo
.
pBinExpr
,
pCtx
->
size
,
pCtx
->
aOutputBuf
,
sas
,
pCtx
->
order
,
arithmetic_callback_function
);
arithmetic_callback_function
);
pCtx
->
aOutputBuf
+=
pCtx
->
outputBytes
*
pCtx
->
size
;
pCtx
->
aOutputBuf
+=
pCtx
->
outputBytes
*
pCtx
->
size
;
...
@@ -3327,10 +3327,10 @@ static void arithmetic_function_f(SQLFunctionCtx *pCtx, int32_t index) {
...
@@ -3327,10 +3327,10 @@ static void arithmetic_function_f(SQLFunctionCtx *pCtx, int32_t index) {
SArithmeticSupport
*
sas
=
(
SArithmeticSupport
*
)
pCtx
->
param
[
1
].
pz
;
SArithmeticSupport
*
sas
=
(
SArithmeticSupport
*
)
pCtx
->
param
[
1
].
pz
;
sas
->
offset
=
index
;
sas
->
offset
=
index
;
tSQLBinaryExprCalcTraverse
(
sas
->
pExpr
->
binExprInfo
.
pBinExpr
,
1
,
pCtx
->
aOutputBuf
,
sas
,
pCtx
->
order
,
tSQLBinaryExprCalcTraverse
(
sas
->
p
Arith
Expr
->
binExprInfo
.
pBinExpr
,
1
,
pCtx
->
aOutputBuf
,
sas
,
pCtx
->
order
,
arithmetic_callback_function
);
arithmetic_callback_function
);
pCtx
->
aOutputBuf
+=
pCtx
->
outputBytes
/* * GET_FORWARD_DIRECTION_FACTOR(pCtx->order)*/
;
pCtx
->
aOutputBuf
+=
pCtx
->
outputBytes
;
}
}
#define LIST_MINMAX_N(ctx, minOutput, maxOutput, elemCnt, data, type, tsdbType, numOfNotNullElem) \
#define LIST_MINMAX_N(ctx, minOutput, maxOutput, elemCnt, data, type, tsdbType, numOfNotNullElem) \
...
...
src/client/src/tscLocal.c
浏览文件 @
6dbca070
...
@@ -130,13 +130,13 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
...
@@ -130,13 +130,13 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
SSchema
*
pSchema
=
tscGetTableSchema
(
pMeta
);
SSchema
*
pSchema
=
tscGetTableSchema
(
pMeta
);
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
pQuery
Info
,
0
);
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fields
Info
,
0
);
strncpy
(
pRes
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
0
)
*
totalNumOfRows
+
pField
->
bytes
*
i
,
pSchema
[
i
].
name
,
strncpy
(
pRes
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
0
)
*
totalNumOfRows
+
pField
->
bytes
*
i
,
pSchema
[
i
].
name
,
TSDB_COL_NAME_LEN
);
TSDB_COL_NAME_LEN
);
char
*
type
=
tDataTypeDesc
[
pSchema
[
i
].
type
].
aName
;
char
*
type
=
tDataTypeDesc
[
pSchema
[
i
].
type
].
aName
;
pField
=
tscFieldInfoGetField
(
pQuery
Info
,
1
);
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fields
Info
,
1
);
strncpy
(
pRes
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
1
)
*
totalNumOfRows
+
pField
->
bytes
*
i
,
type
,
pField
->
bytes
);
strncpy
(
pRes
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
1
)
*
totalNumOfRows
+
pField
->
bytes
*
i
,
type
,
pField
->
bytes
);
int32_t
bytes
=
pSchema
[
i
].
bytes
;
int32_t
bytes
=
pSchema
[
i
].
bytes
;
...
@@ -144,10 +144,10 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
...
@@ -144,10 +144,10 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
bytes
=
bytes
/
TSDB_NCHAR_SIZE
;
bytes
=
bytes
/
TSDB_NCHAR_SIZE
;
}
}
pField
=
tscFieldInfoGetField
(
pQuery
Info
,
2
);
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fields
Info
,
2
);
*
(
int32_t
*
)(
pRes
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
2
)
*
totalNumOfRows
+
pField
->
bytes
*
i
)
=
bytes
;
*
(
int32_t
*
)(
pRes
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
2
)
*
totalNumOfRows
+
pField
->
bytes
*
i
)
=
bytes
;
pField
=
tscFieldInfoGetField
(
pQuery
Info
,
3
);
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fields
Info
,
3
);
if
(
i
>=
tscGetNumOfColumns
(
pMeta
)
&&
tscGetNumOfTags
(
pMeta
)
!=
0
)
{
if
(
i
>=
tscGetNumOfColumns
(
pMeta
)
&&
tscGetNumOfTags
(
pMeta
)
!=
0
)
{
strncpy
(
pRes
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
3
)
*
totalNumOfRows
+
pField
->
bytes
*
i
,
"tag"
,
strncpy
(
pRes
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
3
)
*
totalNumOfRows
+
pField
->
bytes
*
i
,
"tag"
,
strlen
(
"tag"
)
+
1
);
strlen
(
"tag"
)
+
1
);
...
@@ -162,18 +162,18 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
...
@@ -162,18 +162,18 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
char
*
pTagValue
=
tsGetTagsValue
(
pMeta
);
char
*
pTagValue
=
tsGetTagsValue
(
pMeta
);
for
(
int32_t
i
=
numOfRows
;
i
<
totalNumOfRows
;
++
i
)
{
for
(
int32_t
i
=
numOfRows
;
i
<
totalNumOfRows
;
++
i
)
{
// field name
// field name
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
pQuery
Info
,
0
);
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fields
Info
,
0
);
strncpy
(
pRes
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
0
)
*
totalNumOfRows
+
pField
->
bytes
*
i
,
pSchema
[
i
].
name
,
strncpy
(
pRes
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
0
)
*
totalNumOfRows
+
pField
->
bytes
*
i
,
pSchema
[
i
].
name
,
TSDB_COL_NAME_LEN
);
TSDB_COL_NAME_LEN
);
// type name
// type name
pField
=
tscFieldInfoGetField
(
pQuery
Info
,
1
);
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fields
Info
,
1
);
char
*
type
=
tDataTypeDesc
[
pSchema
[
i
].
type
].
aName
;
char
*
type
=
tDataTypeDesc
[
pSchema
[
i
].
type
].
aName
;
strncpy
(
pRes
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
1
)
*
totalNumOfRows
+
pField
->
bytes
*
i
,
type
,
pField
->
bytes
);
strncpy
(
pRes
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
1
)
*
totalNumOfRows
+
pField
->
bytes
*
i
,
type
,
pField
->
bytes
);
// type length
// type length
int32_t
bytes
=
pSchema
[
i
].
bytes
;
int32_t
bytes
=
pSchema
[
i
].
bytes
;
pField
=
tscFieldInfoGetField
(
pQuery
Info
,
2
);
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fields
Info
,
2
);
if
(
pSchema
[
i
].
type
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
pSchema
[
i
].
type
==
TSDB_DATA_TYPE_NCHAR
)
{
bytes
=
bytes
/
TSDB_NCHAR_SIZE
;
bytes
=
bytes
/
TSDB_NCHAR_SIZE
;
}
}
...
@@ -181,7 +181,7 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
...
@@ -181,7 +181,7 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
*
(
int32_t
*
)(
pRes
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
2
)
*
totalNumOfRows
+
pField
->
bytes
*
i
)
=
bytes
;
*
(
int32_t
*
)(
pRes
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
2
)
*
totalNumOfRows
+
pField
->
bytes
*
i
)
=
bytes
;
// tag value
// tag value
pField
=
tscFieldInfoGetField
(
pQuery
Info
,
3
);
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fields
Info
,
3
);
char
*
target
=
pRes
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
3
)
*
totalNumOfRows
+
pField
->
bytes
*
i
;
char
*
target
=
pRes
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
3
)
*
totalNumOfRows
+
pField
->
bytes
*
i
;
if
(
isNull
(
pTagValue
,
pSchema
[
i
].
type
))
{
if
(
isNull
(
pTagValue
,
pSchema
[
i
].
type
))
{
...
@@ -236,31 +236,47 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
...
@@ -236,31 +236,47 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
static
int32_t
tscBuildMeterSchemaResultFields
(
SSqlObj
*
pSql
,
int32_t
numOfCols
,
int32_t
typeColLength
,
static
int32_t
tscBuildMeterSchemaResultFields
(
SSqlObj
*
pSql
,
int32_t
numOfCols
,
int32_t
typeColLength
,
int32_t
noteColLength
)
{
int32_t
noteColLength
)
{
int32_t
rowLen
=
0
;
int32_t
rowLen
=
0
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SColumnIndex
index
=
{
0
};
pCmd
->
numOfCols
=
numOfCols
;
pSql
->
cmd
.
numOfCols
=
numOfCols
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pC
md
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
c
md
,
0
);
pQueryInfo
->
order
.
order
=
TSDB_ORDER_ASC
;
pQueryInfo
->
order
.
order
=
TSDB_ORDER_ASC
;
tscFieldInfoSetValue
(
&
pQueryInfo
->
fieldsInfo
,
0
,
TSDB_DATA_TYPE_BINARY
,
"Field"
,
TSDB_COL_NAME_LEN
);
TAOS_FIELD
f
=
{.
type
=
TSDB_DATA_TYPE_BINARY
,
.
bytes
=
TSDB_COL_NAME_LEN
};
strncpy
(
f
.
name
,
"Field"
,
TSDB_COL_NAME_LEN
);
SFieldSupInfo
*
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
->
pSqlExpr
=
tscSqlExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_BINARY
,
TSDB_COL_NAME_LEN
,
TSDB_COL_NAME_LEN
);
rowLen
+=
TSDB_COL_NAME_LEN
;
rowLen
+=
TSDB_COL_NAME_LEN
;
tscFieldInfoSetValue
(
&
pQueryInfo
->
fieldsInfo
,
1
,
TSDB_DATA_TYPE_BINARY
,
"Type"
,
typeColLength
);
f
.
bytes
=
typeColLength
;
f
.
type
=
TSDB_DATA_TYPE_BINARY
;
strncpy
(
f
.
name
,
"Type"
,
TSDB_COL_NAME_LEN
);
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
->
pSqlExpr
=
tscSqlExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_BINARY
,
typeColLength
,
typeColLength
);
rowLen
+=
typeColLength
;
rowLen
+=
typeColLength
;
tscFieldInfoSetValue
(
&
pQueryInfo
->
fieldsInfo
,
2
,
TSDB_DATA_TYPE_INT
,
"Length"
,
sizeof
(
int32_t
));
f
.
bytes
=
sizeof
(
int32_t
);
f
.
type
=
TSDB_DATA_TYPE_INT
;
strncpy
(
f
.
name
,
"Length"
,
TSDB_COL_NAME_LEN
);
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
->
pSqlExpr
=
tscSqlExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_INT
,
sizeof
(
int32_t
),
sizeof
(
int32_t
));
rowLen
+=
sizeof
(
int32_t
);
rowLen
+=
sizeof
(
int32_t
);
tscFieldInfoSetValue
(
&
pQueryInfo
->
fieldsInfo
,
3
,
TSDB_DATA_TYPE_BINARY
,
"Note"
,
noteColLength
);
f
.
bytes
=
noteColLength
;
rowLen
+=
noteColLength
;
f
.
type
=
TSDB_DATA_TYPE_BINARY
;
strncpy
(
f
.
name
,
"Note"
,
TSDB_COL_NAME_LEN
);
//set the sqlexpr part
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
SColumnIndex
index
=
{
0
};
pInfo
->
pSqlExpr
=
tscSqlExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_BINARY
,
noteColLength
,
noteColLength
);
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
);
rowLen
+=
noteColLength
;
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
;
return
rowLen
;
}
}
...
@@ -280,7 +296,7 @@ static int32_t tscProcessDescribeTable(SSqlObj *pSql) {
...
@@ -280,7 +296,7 @@ static int32_t tscProcessDescribeTable(SSqlObj *pSql) {
int32_t
rowLen
=
int32_t
rowLen
=
tscBuildMeterSchemaResultFields
(
pSql
,
NUM_OF_DESCRIBE_TABLE_COLUMNS
,
TYPE_COLUMN_LENGTH
,
note_field_length
);
tscBuildMeterSchemaResultFields
(
pSql
,
NUM_OF_DESCRIBE_TABLE_COLUMNS
,
TYPE_COLUMN_LENGTH
,
note_field_length
);
tscFieldInfo
Cal
Offset
(
pQueryInfo
);
tscFieldInfo
Update
Offset
(
pQueryInfo
);
return
tscSetValueToResObj
(
pSql
,
rowLen
);
return
tscSetValueToResObj
(
pSql
,
rowLen
);
}
}
...
@@ -310,7 +326,7 @@ static int tscBuildMetricTagProjectionResult(SSqlObj *pSql) {
...
@@ -310,7 +326,7 @@ static int tscBuildMetricTagProjectionResult(SSqlObj *pSql) {
}
}
int32_t totalNumOfResults = pMetricMeta->numOfTables;
int32_t totalNumOfResults = pMetricMeta->numOfTables;
int32_t rowLen = tscGetResRowLength(pQueryInfo);
int32_t rowLen = tscGetResRowLength(pQueryInfo
->exprsInfo
);
tscInitResObjForLocalQuery(pSql, totalNumOfResults, rowLen);
tscInitResObjForLocalQuery(pSql, totalNumOfResults, rowLen);
...
@@ -321,7 +337,7 @@ static int tscBuildMetricTagProjectionResult(SSqlObj *pSql) {
...
@@ -321,7 +337,7 @@ static int tscBuildMetricTagProjectionResult(SSqlObj *pSql) {
for (int32_t j = 0; j < pSidList->numOfSids; ++j) {
for (int32_t j = 0; j < pSidList->numOfSids; ++j) {
STableIdInfo *pSidExt = tscGetMeterSidInfo(pSidList, j);
STableIdInfo *pSidExt = tscGetMeterSidInfo(pSidList, j);
for (int32_t k = 0; k < pQueryInfo->fieldsInfo.numOfOutput
Cols
; ++k) {
for (int32_t k = 0; k < pQueryInfo->fieldsInfo.numOfOutput; ++k) {
SColIndex *pColIndex = &tscSqlExprGet(pQueryInfo, k)->colInfo;
SColIndex *pColIndex = &tscSqlExprGet(pQueryInfo, k)->colInfo;
int16_t offsetId = pColIndex->colIdx;
int16_t offsetId = pColIndex->colIdx;
...
@@ -329,7 +345,7 @@ static int tscBuildMetricTagProjectionResult(SSqlObj *pSql) {
...
@@ -329,7 +345,7 @@ static int tscBuildMetricTagProjectionResult(SSqlObj *pSql) {
assert(0);
assert(0);
char * val = NULL;//pSidExt->tags + vOffset[offsetId];
char * val = NULL;//pSidExt->tags + vOffset[offsetId];
TAOS_FIELD *pField = tscFieldInfoGetField(
pQuery
Info, k);
TAOS_FIELD *pField = tscFieldInfoGetField(
&pQueryInfo->fields
Info, k);
memcpy(pRes->data + tscFieldInfoGetOffset(pQueryInfo, k) * totalNumOfResults + pField->bytes * rowIdx, val,
memcpy(pRes->data + tscFieldInfoGetOffset(pQueryInfo, k) * totalNumOfResults + pField->bytes * rowIdx, val,
(size_t)pField->bytes);
(size_t)pField->bytes);
...
@@ -350,17 +366,17 @@ static int tscBuildMetricTagSqlFunctionResult(SSqlObj *pSql) {
...
@@ -350,17 +366,17 @@ static int tscBuildMetricTagSqlFunctionResult(SSqlObj *pSql) {
#if 0
#if 0
SSuperTableMeta *pMetricMeta = tscGetMetaInfo(pQueryInfo, 0)->pMetricMeta;
SSuperTableMeta *pMetricMeta = tscGetMetaInfo(pQueryInfo, 0)->pMetricMeta;
int32_t totalNumOfResults = 1; // count function only produce one result
int32_t totalNumOfResults = 1; // count function only produce one result
int32_t rowLen = tscGetResRowLength(pQueryInfo);
int32_t rowLen = tscGetResRowLength(pQueryInfo
->exprsInfo
);
tscInitResObjForLocalQuery(pSql, totalNumOfResults, rowLen);
tscInitResObjForLocalQuery(pSql, totalNumOfResults, rowLen);
int32_t rowIdx = 0;
int32_t rowIdx = 0;
for (int32_t i = 0; i < totalNumOfResults; ++i) {
for (int32_t i = 0; i < totalNumOfResults; ++i) {
for (int32_t k = 0; k < pQueryInfo->fieldsInfo.numOfOutput
Cols
; ++k) {
for (int32_t k = 0; k < pQueryInfo->fieldsInfo.numOfOutput; ++k) {
SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, i);
SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, i);
if (pExpr->colInfo.colIdx == -1 && pExpr->functionId == TSDB_FUNC_COUNT) {
if (pExpr->colInfo.colIdx == -1 && pExpr->functionId == TSDB_FUNC_COUNT) {
TAOS_FIELD *pField = tscFieldInfoGetField(
pQuery
Info, k);
TAOS_FIELD *pField = tscFieldInfoGetField(
&pQueryInfo->fields
Info, k);
memcpy(pRes->data + tscFieldInfoGetOffset(pQueryInfo, i) * totalNumOfResults + pField->bytes * rowIdx,
memcpy(pRes->data + tscFieldInfoGetOffset(pQueryInfo, i) * totalNumOfResults + pField->bytes * rowIdx,
&pMetricMeta->numOfTables, sizeof(pMetricMeta->numOfTables));
&pMetricMeta->numOfTables, sizeof(pMetricMeta->numOfTables));
...
@@ -388,7 +404,7 @@ static int tscProcessQueryTags(SSqlObj *pSql) {
...
@@ -388,7 +404,7 @@ static int tscProcessQueryTags(SSqlObj *pSql) {
return
pSql
->
res
.
code
;
return
pSql
->
res
.
code
;
}
}
SSqlExpr
*
pExpr
=
t
scSqlExprGet
(
pQuery
Info
,
0
);
SSqlExpr
*
pExpr
=
t
aosArrayGetP
(
pQueryInfo
->
exprs
Info
,
0
);
if
(
pExpr
->
functionId
==
TSDB_FUNC_COUNT
)
{
if
(
pExpr
->
functionId
==
TSDB_FUNC_COUNT
)
{
return
tscBuildMetricTagSqlFunctionResult
(
pSql
);
return
tscBuildMetricTagSqlFunctionResult
(
pSql
);
}
else
{
}
else
{
...
@@ -399,7 +415,7 @@ static int tscProcessQueryTags(SSqlObj *pSql) {
...
@@ -399,7 +415,7 @@ static int tscProcessQueryTags(SSqlObj *pSql) {
static
void
tscProcessCurrentUser
(
SSqlObj
*
pSql
)
{
static
void
tscProcessCurrentUser
(
SSqlObj
*
pSql
)
{
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SSqlExpr
*
pExpr
=
t
scSqlExprGet
(
pQuery
Info
,
0
);
SSqlExpr
*
pExpr
=
t
aosArrayGetP
(
pQueryInfo
->
exprs
Info
,
0
);
tscSetLocalQueryResult
(
pSql
,
pSql
->
pTscObj
->
user
,
pExpr
->
aliasName
,
TSDB_USER_LEN
);
tscSetLocalQueryResult
(
pSql
,
pSql
->
pTscObj
->
user
,
pExpr
->
aliasName
,
TSDB_USER_LEN
);
}
}
...
@@ -414,7 +430,7 @@ static void tscProcessCurrentDB(SSqlObj *pSql) {
...
@@ -414,7 +430,7 @@ static void tscProcessCurrentDB(SSqlObj *pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SSqlExpr
*
pExpr
=
t
scSqlExprGet
(
pQuery
Info
,
0
);
SSqlExpr
*
pExpr
=
t
aosArrayGetP
(
pQueryInfo
->
exprs
Info
,
0
);
tscSetLocalQueryResult
(
pSql
,
db
,
pExpr
->
aliasName
,
TSDB_DB_NAME_LEN
);
tscSetLocalQueryResult
(
pSql
,
db
,
pExpr
->
aliasName
,
TSDB_DB_NAME_LEN
);
}
}
...
@@ -422,14 +438,14 @@ static void tscProcessServerVer(SSqlObj *pSql) {
...
@@ -422,14 +438,14 @@ static void tscProcessServerVer(SSqlObj *pSql) {
const
char
*
v
=
pSql
->
pTscObj
->
sversion
;
const
char
*
v
=
pSql
->
pTscObj
->
sversion
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SSqlExpr
*
pExpr
=
t
scSqlExprGet
(
pQuery
Info
,
0
);
SSqlExpr
*
pExpr
=
t
aosArrayGetP
(
pQueryInfo
->
exprs
Info
,
0
);
tscSetLocalQueryResult
(
pSql
,
v
,
pExpr
->
aliasName
,
tListLen
(
pSql
->
pTscObj
->
sversion
));
tscSetLocalQueryResult
(
pSql
,
v
,
pExpr
->
aliasName
,
tListLen
(
pSql
->
pTscObj
->
sversion
));
}
}
static
void
tscProcessClientVer
(
SSqlObj
*
pSql
)
{
static
void
tscProcessClientVer
(
SSqlObj
*
pSql
)
{
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SSqlExpr
*
pExpr
=
t
scSqlExprGet
(
pQuery
Info
,
0
);
SSqlExpr
*
pExpr
=
t
aosArrayGetP
(
pQueryInfo
->
exprs
Info
,
0
);
tscSetLocalQueryResult
(
pSql
,
version
,
pExpr
->
aliasName
,
strlen
(
version
));
tscSetLocalQueryResult
(
pSql
,
version
,
pExpr
->
aliasName
,
strlen
(
version
));
}
}
...
@@ -449,7 +465,7 @@ static void tscProcessServStatus(SSqlObj *pSql) {
...
@@ -449,7 +465,7 @@ static void tscProcessServStatus(SSqlObj *pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SSqlExpr
*
pExpr
=
t
scSqlExprGet
(
pQuery
Info
,
0
);
SSqlExpr
*
pExpr
=
t
aosArrayGetP
(
pQueryInfo
->
exprs
Info
,
0
);
tscSetLocalQueryResult
(
pSql
,
"1"
,
pExpr
->
aliasName
,
2
);
tscSetLocalQueryResult
(
pSql
,
"1"
,
pExpr
->
aliasName
,
2
);
}
}
...
@@ -462,13 +478,16 @@ void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnNa
...
@@ -462,13 +478,16 @@ void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnNa
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
pQueryInfo
->
order
.
order
=
TSDB_ORDER_ASC
;
pQueryInfo
->
order
.
order
=
TSDB_ORDER_ASC
;
tscClearFieldInfo
(
&
pQueryInfo
->
fieldsInfo
);
tscFieldInfoClear
(
&
pQueryInfo
->
fieldsInfo
);
TAOS_FIELD
f
=
tscCreateField
(
TSDB_DATA_TYPE_BINARY
,
columnName
,
valueLength
);
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
tscFieldInfoSetValue
(
&
pQueryInfo
->
fieldsInfo
,
0
,
TSDB_DATA_TYPE_BINARY
,
columnName
,
valueLength
);
tscInitResObjForLocalQuery
(
pSql
,
1
,
valueLength
);
tscInitResObjForLocalQuery
(
pSql
,
1
,
valueLength
);
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
pQueryInfo
,
0
);
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fieldsInfo
,
0
);
pQueryInfo
->
fieldsInfo
.
pSqlExpr
[
0
]
=
pQueryInfo
->
exprsInfo
.
pExprs
[
0
];
SFieldSupInfo
*
pInfo
=
tscFieldInfoGetSupp
(
&
pQueryInfo
->
fieldsInfo
,
0
);
pInfo
->
pSqlExpr
=
taosArrayGetP
(
pQueryInfo
->
exprsInfo
,
0
);
strncpy
(
pRes
->
data
,
val
,
pField
->
bytes
);
strncpy
(
pRes
->
data
,
val
,
pField
->
bytes
);
}
}
...
...
src/client/src/tscParseInsert.c
浏览文件 @
6dbca070
...
@@ -613,7 +613,7 @@ static void tsSetBlockInfo(SSubmitBlk *pBlocks, const STableMeta *pTableMeta, in
...
@@ -613,7 +613,7 @@ static void tsSetBlockInfo(SSubmitBlk *pBlocks, const STableMeta *pTableMeta, in
}
}
// data block is disordered, sort it in ascending order
// data block is disordered, sort it in ascending order
void
sortRemoveDuplicate
s
(
STableDataBlocks
*
dataBuf
)
{
void
tscSortRemoveDataBlockDupRow
s
(
STableDataBlocks
*
dataBuf
)
{
SSubmitBlk
*
pBlocks
=
(
SSubmitBlk
*
)
dataBuf
->
pData
;
SSubmitBlk
*
pBlocks
=
(
SSubmitBlk
*
)
dataBuf
->
pData
;
// size is less than the total size, since duplicated rows may be removed yet.
// size is less than the total size, since duplicated rows may be removed yet.
...
@@ -779,7 +779,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
...
@@ -779,7 +779,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
}
}
STableMetaInfo
*
pSTableMeterMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
STABLE_INDEX
);
STableMetaInfo
*
pSTableMeterMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
STABLE_INDEX
);
setMeterID
(
pSTableMeterMetaInfo
,
&
sToken
,
pSql
);
tscSetTableId
(
pSTableMeterMetaInfo
,
&
sToken
,
pSql
);
strncpy
(
pTag
->
name
,
pSTableMeterMetaInfo
->
name
,
TSDB_TABLE_ID_LEN
);
strncpy
(
pTag
->
name
,
pSTableMeterMetaInfo
->
name
,
TSDB_TABLE_ID_LEN
);
code
=
tscGetTableMeta
(
pSql
,
pSTableMeterMetaInfo
);
code
=
tscGetTableMeta
(
pSql
,
pSTableMeterMetaInfo
);
...
@@ -922,7 +922,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
...
@@ -922,7 +922,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
return
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
"invalid table name"
,
*
sqlstr
);
return
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
"invalid table name"
,
*
sqlstr
);
}
}
int32_t
ret
=
setMeterID
(
pTableMetaInfo
,
&
tableToken
,
pSql
);
int32_t
ret
=
tscSetTableId
(
pTableMetaInfo
,
&
tableToken
,
pSql
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
return
ret
;
}
}
...
@@ -1059,7 +1059,7 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
...
@@ -1059,7 +1059,7 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
goto
_error_clean
;
goto
_error_clean
;
}
}
if
((
code
=
setMeterID
(
pTableMetaInfo
,
&
sToken
,
pSql
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
tscSetTableId
(
pTableMetaInfo
,
&
sToken
,
pSql
))
!=
TSDB_CODE_SUCCESS
)
{
goto
_error_clean
;
goto
_error_clean
;
}
}
...
...
src/client/src/tscSQLParser.c
浏览文件 @
6dbca070
此差异已折叠。
点击以展开。
src/client/src/tscSchemaUtil.c
浏览文件 @
6dbca070
...
@@ -161,9 +161,9 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg, size_t* size
...
@@ -161,9 +161,9 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg, size_t* size
pTableMeta
->
tableType
=
pTableMetaMsg
->
tableType
;
pTableMeta
->
tableType
=
pTableMetaMsg
->
tableType
;
pTableMeta
->
tableInfo
=
(
STableComInfo
)
{
pTableMeta
->
tableInfo
=
(
STableComInfo
)
{
.
numOfTags
=
pTableMetaMsg
->
numOfTags
,
.
numOfTags
=
pTableMetaMsg
->
numOfTags
,
.
precision
=
pTableMetaMsg
->
precision
,
.
numOfColumns
=
pTableMetaMsg
->
numOfColumns
,
.
numOfColumns
=
pTableMetaMsg
->
numOfColumns
,
.
precision
=
pTableMetaMsg
->
precision
};
};
pTableMeta
->
sid
=
pTableMetaMsg
->
sid
;
pTableMeta
->
sid
=
pTableMetaMsg
->
sid
;
...
@@ -172,7 +172,7 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg, size_t* size
...
@@ -172,7 +172,7 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg, size_t* size
memcpy
(
pTableMeta
->
schema
,
pTableMetaMsg
->
schema
,
schemaSize
);
memcpy
(
pTableMeta
->
schema
,
pTableMetaMsg
->
schema
,
schemaSize
);
int32_t
numOfTotalCols
=
pTableMeta
->
tableInfo
.
numOfColumns
+
pTableMeta
->
tableInfo
.
numOfTags
;
int32_t
numOfTotalCols
=
pTableMeta
->
tableInfo
.
numOfColumns
;
for
(
int32_t
i
=
0
;
i
<
numOfTotalCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfTotalCols
;
++
i
)
{
pTableMeta
->
tableInfo
.
rowSize
+=
pTableMeta
->
schema
[
i
].
bytes
;
pTableMeta
->
tableInfo
.
rowSize
+=
pTableMeta
->
schema
[
i
].
bytes
;
}
}
...
...
src/client/src/tscSecondaryMerge.c
浏览文件 @
6dbca070
...
@@ -61,7 +61,9 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SSqlRes *pRes, SLocalReducer *pRedu
...
@@ -61,7 +61,9 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SSqlRes *pRes, SLocalReducer *pRedu
* merge requirement. So, the final result in pRes structure is formatted in accordance with the pCmd object.
* merge requirement. So, the final result in pRes structure is formatted in accordance with the pCmd object.
*/
*/
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
i
)
{
size_t
size
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SQLFunctionCtx
*
pCtx
=
&
pReducer
->
pCtx
[
i
];
SQLFunctionCtx
*
pCtx
=
&
pReducer
->
pCtx
[
i
];
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
...
@@ -108,10 +110,10 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SSqlRes *pRes, SLocalReducer *pRedu
...
@@ -108,10 +110,10 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SSqlRes *pRes, SLocalReducer *pRedu
int16_t
n
=
0
;
int16_t
n
=
0
;
int16_t
tagLen
=
0
;
int16_t
tagLen
=
0
;
SQLFunctionCtx
**
pTagCtx
=
calloc
(
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
,
POINTER_BYTES
);
SQLFunctionCtx
**
pTagCtx
=
calloc
(
pQueryInfo
->
fieldsInfo
.
numOfOutput
,
POINTER_BYTES
);
SQLFunctionCtx
*
pCtx
=
NULL
;
SQLFunctionCtx
*
pCtx
=
NULL
;
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
if
(
pExpr
->
functionId
==
TSDB_FUNC_TAG_DUMMY
||
pExpr
->
functionId
==
TSDB_FUNC_TS_DUMMY
)
{
if
(
pExpr
->
functionId
==
TSDB_FUNC_TAG_DUMMY
||
pExpr
->
functionId
==
TSDB_FUNC_TS_DUMMY
)
{
tagLen
+=
pExpr
->
resBytes
;
tagLen
+=
pExpr
->
resBytes
;
...
@@ -254,12 +256,13 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
...
@@ -254,12 +256,13 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
// the input data format follows the old format, but output in a new format.
// the input data format follows the old format, but output in a new format.
// so, all the input must be parsed as old format
// so, all the input must be parsed as old format
pReducer
->
pCtx
=
(
SQLFunctionCtx
*
)
calloc
(
pQueryInfo
->
exprsInfo
.
numOfExprs
,
sizeof
(
SQLFunctionCtx
));
size_t
size
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
pReducer
->
pCtx
=
(
SQLFunctionCtx
*
)
calloc
(
size
,
sizeof
(
SQLFunctionCtx
));
pReducer
->
rowSize
=
pMemBuffer
[
0
]
->
nElemSize
;
pReducer
->
rowSize
=
pMemBuffer
[
0
]
->
nElemSize
;
tscRestoreSQLFunc
tionForMetric
Query
(
pQueryInfo
);
tscRestoreSQLFunc
ForSTable
Query
(
pQueryInfo
);
tscFieldInfo
Cal
Offset
(
pQueryInfo
);
tscFieldInfo
Update
Offset
(
pQueryInfo
);
if
(
pReducer
->
rowSize
>
pMemBuffer
[
0
]
->
pageSize
)
{
if
(
pReducer
->
rowSize
>
pMemBuffer
[
0
]
->
pageSize
)
{
assert
(
false
);
// todo fixed row size is larger than the minimum page size;
assert
(
false
);
// todo fixed row size is larger than the minimum page size;
...
@@ -279,7 +282,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
...
@@ -279,7 +282,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
pReducer
->
nResultBufSize
=
pMemBuffer
[
0
]
->
pageSize
*
16
;
pReducer
->
nResultBufSize
=
pMemBuffer
[
0
]
->
pageSize
*
16
;
pReducer
->
pResultBuf
=
(
tFilePage
*
)
calloc
(
1
,
pReducer
->
nResultBufSize
+
sizeof
(
tFilePage
));
pReducer
->
pResultBuf
=
(
tFilePage
*
)
calloc
(
1
,
pReducer
->
nResultBufSize
+
sizeof
(
tFilePage
));
int32_t
finalRowLength
=
tscGetResRowLength
(
pQueryInfo
);
int32_t
finalRowLength
=
tscGetResRowLength
(
pQueryInfo
->
exprsInfo
);
pReducer
->
resColModel
=
finalmodel
;
pReducer
->
resColModel
=
finalmodel
;
pReducer
->
resColModel
->
capacity
=
pReducer
->
nResultBufSize
/
finalRowLength
;
pReducer
->
resColModel
->
capacity
=
pReducer
->
nResultBufSize
/
finalRowLength
;
assert
(
finalRowLength
<=
pReducer
->
rowSize
);
assert
(
finalRowLength
<=
pReducer
->
rowSize
);
...
@@ -301,7 +304,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
...
@@ -301,7 +304,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
}
}
pReducer
->
pTempBuffer
->
numOfElems
=
0
;
pReducer
->
pTempBuffer
->
numOfElems
=
0
;
pReducer
->
pResInfo
=
calloc
(
(
size_t
)
pQueryInfo
->
exprsInfo
.
numOfExprs
,
sizeof
(
SResultInfo
));
pReducer
->
pResInfo
=
calloc
(
size
,
sizeof
(
SResultInfo
));
tscCreateResPointerInfo
(
pRes
,
pQueryInfo
);
tscCreateResPointerInfo
(
pRes
,
pQueryInfo
);
tscInitSqlContext
(
pCmd
,
pRes
,
pReducer
,
pDesc
);
tscInitSqlContext
(
pCmd
,
pRes
,
pReducer
,
pDesc
);
...
@@ -324,7 +327,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
...
@@ -324,7 +327,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
STableComInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
STableComInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
int16_t
prec
=
tinfo
.
precision
;
int16_t
prec
=
tinfo
.
precision
;
int64_t
stime
=
(
pQueryInfo
->
stime
<
pQueryInfo
->
etime
)
?
pQueryInfo
->
stime
:
pQueryInfo
->
etime
;
int64_t
stime
=
(
pQueryInfo
->
window
.
skey
<
pQueryInfo
->
window
.
ekey
)
?
pQueryInfo
->
window
.
skey
:
pQueryInfo
->
window
.
ekey
;
int64_t
revisedSTime
=
int64_t
revisedSTime
=
taosGetIntervalStartTimestamp
(
stime
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
slidingTimeUnit
,
prec
);
taosGetIntervalStartTimestamp
(
stime
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
slidingTimeUnit
,
prec
);
...
@@ -332,7 +335,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
...
@@ -332,7 +335,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
taosInitInterpoInfo
(
pInterpoInfo
,
pQueryInfo
->
order
.
order
,
revisedSTime
,
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
,
taosInitInterpoInfo
(
pInterpoInfo
,
pQueryInfo
->
order
.
order
,
revisedSTime
,
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
,
pReducer
->
rowSize
);
pReducer
->
rowSize
);
int32_t
startIndex
=
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
-
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
;
int32_t
startIndex
=
pQueryInfo
->
fieldsInfo
.
numOfOutput
-
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
;
if
(
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
>
0
)
{
if
(
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
>
0
)
{
pInterpoInfo
->
pTags
[
0
]
=
(
char
*
)
pInterpoInfo
->
pTags
+
POINTER_BYTES
*
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
;
pInterpoInfo
->
pTags
[
0
]
=
(
char
*
)
pInterpoInfo
->
pTags
+
POINTER_BYTES
*
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
;
...
@@ -462,7 +465,7 @@ void tscDestroyLocalReducer(SSqlObj *pSql) {
...
@@ -462,7 +465,7 @@ void tscDestroyLocalReducer(SSqlObj *pSql) {
taosDestoryInterpoInfo
(
&
pLocalReducer
->
interpolationInfo
);
taosDestoryInterpoInfo
(
&
pLocalReducer
->
interpolationInfo
);
if
(
pLocalReducer
->
pCtx
!=
NULL
)
{
if
(
pLocalReducer
->
pCtx
!=
NULL
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
i
)
{
SQLFunctionCtx
*
pCtx
=
&
pLocalReducer
->
pCtx
[
i
];
SQLFunctionCtx
*
pCtx
=
&
pLocalReducer
->
pCtx
[
i
];
tVariantDestroy
(
&
pCtx
->
tag
);
tVariantDestroy
(
&
pCtx
->
tag
);
...
@@ -480,7 +483,7 @@ void tscDestroyLocalReducer(SSqlObj *pSql) {
...
@@ -480,7 +483,7 @@ void tscDestroyLocalReducer(SSqlObj *pSql) {
tfree
(
pLocalReducer
->
pResultBuf
);
tfree
(
pLocalReducer
->
pResultBuf
);
if
(
pLocalReducer
->
pResInfo
!=
NULL
)
{
if
(
pLocalReducer
->
pResInfo
!=
NULL
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
i
)
{
tfree
(
pLocalReducer
->
pResInfo
[
i
].
interResultBuf
);
tfree
(
pLocalReducer
->
pResInfo
[
i
].
interResultBuf
);
}
}
...
@@ -532,7 +535,7 @@ static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SSqlCmd *pCm
...
@@ -532,7 +535,7 @@ static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SSqlCmd *pCm
}
}
if
(
numOfGroupByCols
>
0
)
{
if
(
numOfGroupByCols
>
0
)
{
int32_t
startCols
=
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
-
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
;
int32_t
startCols
=
pQueryInfo
->
fieldsInfo
.
numOfOutput
-
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
;
// tags value locate at the last columns
// tags value locate at the last columns
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
;
++
i
)
{
...
@@ -612,8 +615,10 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
...
@@ -612,8 +615,10 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
pRes
->
code
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
pRes
->
code
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
return
pRes
->
code
;
return
pRes
->
code
;
}
}
pSchema
=
(
SSchema
*
)
calloc
(
1
,
sizeof
(
SSchema
)
*
pQueryInfo
->
exprsInfo
.
numOfExprs
);
size_t
size
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
pSchema
=
(
SSchema
*
)
calloc
(
1
,
sizeof
(
SSchema
)
*
size
);
if
(
pSchema
==
NULL
)
{
if
(
pSchema
==
NULL
)
{
tscError
(
"%p failed to allocate memory"
,
pSql
);
tscError
(
"%p failed to allocate memory"
,
pSql
);
pRes
->
code
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
pRes
->
code
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
...
@@ -621,7 +626,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
...
@@ -621,7 +626,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
}
}
int32_t
rlen
=
0
;
int32_t
rlen
=
0
;
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
pSchema
[
i
].
bytes
=
pExpr
->
resBytes
;
pSchema
[
i
].
bytes
=
pExpr
->
resBytes
;
...
@@ -634,8 +639,8 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
...
@@ -634,8 +639,8 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
if
(
rlen
!=
0
)
{
if
(
rlen
!=
0
)
{
capacity
=
nBufferSizes
/
rlen
;
capacity
=
nBufferSizes
/
rlen
;
}
}
pModel
=
createColumnModel
(
pSchema
,
pQueryInfo
->
exprsInfo
.
numOfExprs
,
capacity
);
pModel
=
createColumnModel
(
pSchema
,
size
,
capacity
);
size_t
numOfSubs
=
pTableMetaInfo
->
vgroupList
->
numOfVgroups
;
size_t
numOfSubs
=
pTableMetaInfo
->
vgroupList
->
numOfVgroups
;
for
(
int32_t
i
=
0
;
i
<
numOfSubs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfSubs
;
++
i
)
{
...
@@ -649,8 +654,8 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
...
@@ -649,8 +654,8 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
}
}
// final result depends on the fields number
// final result depends on the fields number
memset
(
pSchema
,
0
,
sizeof
(
SSchema
)
*
pQueryInfo
->
exprsInfo
.
numOfExprs
);
memset
(
pSchema
,
0
,
sizeof
(
SSchema
)
*
size
);
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
SSchema
*
p1
=
tscGetTableColumnSchema
(
pTableMetaInfo
->
pTableMeta
,
pExpr
->
colInfo
.
colIndex
);
SSchema
*
p1
=
tscGetTableColumnSchema
(
pTableMetaInfo
->
pTableMeta
,
pExpr
->
colInfo
.
colIndex
);
...
@@ -683,8 +688,8 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
...
@@ -683,8 +688,8 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
pSchema
[
i
].
bytes
=
bytes
;
pSchema
[
i
].
bytes
=
bytes
;
strcpy
(
pSchema
[
i
].
name
,
pModel
->
pFields
[
i
].
field
.
name
);
strcpy
(
pSchema
[
i
].
name
,
pModel
->
pFields
[
i
].
field
.
name
);
}
}
*
pFinalModel
=
createColumnModel
(
pSchema
,
pQueryInfo
->
exprsInfo
.
numOfExprs
,
capacity
);
*
pFinalModel
=
createColumnModel
(
pSchema
,
size
,
capacity
);
tfree
(
pSchema
);
tfree
(
pSchema
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -782,7 +787,7 @@ void savePrevRecordAndSetupInterpoInfo(SLocalReducer *pLocalReducer, SQueryInfo
...
@@ -782,7 +787,7 @@ void savePrevRecordAndSetupInterpoInfo(SLocalReducer *pLocalReducer, SQueryInfo
STableComInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
STableComInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
int16_t
prec
=
tinfo
.
precision
;
int16_t
prec
=
tinfo
.
precision
;
int64_t
stime
=
(
pQueryInfo
->
stime
<
pQueryInfo
->
etime
)
?
pQueryInfo
->
stime
:
pQueryInfo
->
etime
;
int64_t
stime
=
(
pQueryInfo
->
window
.
skey
<
pQueryInfo
->
window
.
ekey
)
?
pQueryInfo
->
window
.
skey
:
pQueryInfo
->
window
.
ekey
;
int64_t
revisedSTime
=
int64_t
revisedSTime
=
taosGetIntervalStartTimestamp
(
stime
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
slidingTimeUnit
,
prec
);
taosGetIntervalStartTimestamp
(
stime
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
slidingTimeUnit
,
prec
);
...
@@ -800,7 +805,7 @@ void savePrevRecordAndSetupInterpoInfo(SLocalReducer *pLocalReducer, SQueryInfo
...
@@ -800,7 +805,7 @@ void savePrevRecordAndSetupInterpoInfo(SLocalReducer *pLocalReducer, SQueryInfo
// static void reversedCopyResultToDstBuf(SQueryInfo* pQueryInfo, SSqlRes *pRes, tFilePage *pFinalDataPage) {
// static void reversedCopyResultToDstBuf(SQueryInfo* pQueryInfo, SSqlRes *pRes, tFilePage *pFinalDataPage) {
//
//
// for (int32_t i = 0; i < pQueryInfo->exprsInfo.numOfExprs; ++i) {
// for (int32_t i = 0; i < pQueryInfo->exprsInfo.numOfExprs; ++i) {
// TAOS_FIELD *pField = tscFieldInfoGetField(
pQuery
Info, i);
// TAOS_FIELD *pField = tscFieldInfoGetField(
&pQueryInfo->fields
Info, i);
//
//
// int32_t offset = tscFieldInfoGetOffset(pQueryInfo, i);
// int32_t offset = tscFieldInfoGetOffset(pQueryInfo, i);
// char * src = pFinalDataPage->data + (pRes->numOfRows - 1) * pField->bytes + pRes->numOfRows * offset;
// char * src = pFinalDataPage->data + (pRes->numOfRows - 1) * pField->bytes + pRes->numOfRows * offset;
...
@@ -817,8 +822,10 @@ void savePrevRecordAndSetupInterpoInfo(SLocalReducer *pLocalReducer, SQueryInfo
...
@@ -817,8 +822,10 @@ void savePrevRecordAndSetupInterpoInfo(SLocalReducer *pLocalReducer, SQueryInfo
static
void
reversedCopyFromInterpolationToDstBuf
(
SQueryInfo
*
pQueryInfo
,
SSqlRes
*
pRes
,
tFilePage
**
pResPages
,
static
void
reversedCopyFromInterpolationToDstBuf
(
SQueryInfo
*
pQueryInfo
,
SSqlRes
*
pRes
,
tFilePage
**
pResPages
,
SLocalReducer
*
pLocalReducer
)
{
SLocalReducer
*
pLocalReducer
)
{
assert
(
0
);
assert
(
0
);
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
i
)
{
size_t
size
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
pQueryInfo
,
i
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fieldsInfo
,
i
);
int32_t
offset
=
tscFieldInfoGetOffset
(
pQueryInfo
,
i
);
int32_t
offset
=
tscFieldInfoGetOffset
(
pQueryInfo
,
i
);
assert
(
offset
==
getColumnModelOffset
(
pLocalReducer
->
resColModel
,
i
));
assert
(
offset
==
getColumnModelOffset
(
pLocalReducer
->
resColModel
,
i
));
...
@@ -894,7 +901,7 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
...
@@ -894,7 +901,7 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
savePrevRecordAndSetupInterpoInfo
(
pLocalReducer
,
pQueryInfo
,
&
pLocalReducer
->
interpolationInfo
);
savePrevRecordAndSetupInterpoInfo
(
pLocalReducer
,
pQueryInfo
,
&
pLocalReducer
->
interpolationInfo
);
}
}
int32_t
rowSize
=
tscGetResRowLength
(
pQueryInfo
);
int32_t
rowSize
=
tscGetResRowLength
(
pQueryInfo
->
exprsInfo
);
memcpy
(
pRes
->
data
,
pFinalDataPage
->
data
,
pRes
->
numOfRows
*
rowSize
);
memcpy
(
pRes
->
data
,
pFinalDataPage
->
data
,
pRes
->
numOfRows
*
rowSize
);
pFinalDataPage
->
numOfElems
=
0
;
pFinalDataPage
->
numOfElems
=
0
;
...
@@ -905,18 +912,18 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
...
@@ -905,18 +912,18 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
SInterpolationInfo
*
pInterpoInfo
=
&
pLocalReducer
->
interpolationInfo
;
SInterpolationInfo
*
pInterpoInfo
=
&
pLocalReducer
->
interpolationInfo
;
int64_t
actualETime
=
(
pQueryInfo
->
stime
<
pQueryInfo
->
etime
)
?
pQueryInfo
->
etime
:
pQueryInfo
->
stime
;
int64_t
actualETime
=
(
pQueryInfo
->
window
.
skey
<
pQueryInfo
->
window
.
ekey
)
?
pQueryInfo
->
window
.
ekey
:
pQueryInfo
->
window
.
skey
;
tFilePage
**
pResPages
=
malloc
(
POINTER_BYTES
*
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
);
tFilePage
**
pResPages
=
malloc
(
POINTER_BYTES
*
pQueryInfo
->
fieldsInfo
.
numOfOutput
);
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
i
)
{
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
pQuery
Info
,
i
);
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fields
Info
,
i
);
pResPages
[
i
]
=
calloc
(
1
,
sizeof
(
tFilePage
)
+
pField
->
bytes
*
pLocalReducer
->
resColModel
->
capacity
);
pResPages
[
i
]
=
calloc
(
1
,
sizeof
(
tFilePage
)
+
pField
->
bytes
*
pLocalReducer
->
resColModel
->
capacity
);
}
}
char
**
srcData
=
(
char
**
)
malloc
((
POINTER_BYTES
+
sizeof
(
int32_t
))
*
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
);
char
**
srcData
=
(
char
**
)
malloc
((
POINTER_BYTES
+
sizeof
(
int32_t
))
*
pQueryInfo
->
fieldsInfo
.
numOfOutput
);
int32_t
*
functions
=
(
int32_t
*
)((
char
*
)
srcData
+
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
*
sizeof
(
void
*
));
int32_t
*
functions
=
(
int32_t
*
)((
char
*
)
srcData
+
pQueryInfo
->
fieldsInfo
.
numOfOutput
*
sizeof
(
void
*
));
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
i
)
{
srcData
[
i
]
=
srcData
[
i
]
=
pLocalReducer
->
pBufForInterpo
+
tscFieldInfoGetOffset
(
pQueryInfo
,
i
)
*
pInterpoInfo
->
numOfRawDataInRows
;
pLocalReducer
->
pBufForInterpo
+
tscFieldInfoGetOffset
(
pQueryInfo
,
i
)
*
pInterpoInfo
->
numOfRawDataInRows
;
functions
[
i
]
=
tscSqlExprGet
(
pQueryInfo
,
i
)
->
functionId
;
functions
[
i
]
=
tscSqlExprGet
(
pQueryInfo
,
i
)
->
functionId
;
...
@@ -943,8 +950,8 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
...
@@ -943,8 +950,8 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
newRows
-=
pQueryInfo
->
limit
.
offset
;
newRows
-=
pQueryInfo
->
limit
.
offset
;
if
(
pQueryInfo
->
limit
.
offset
>
0
)
{
if
(
pQueryInfo
->
limit
.
offset
>
0
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
i
)
{
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
pQuery
Info
,
i
);
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fields
Info
,
i
);
memmove
(
pResPages
[
i
]
->
data
,
pResPages
[
i
]
->
data
+
pField
->
bytes
*
pQueryInfo
->
limit
.
offset
,
memmove
(
pResPages
[
i
]
->
data
,
pResPages
[
i
]
->
data
+
pField
->
bytes
*
pQueryInfo
->
limit
.
offset
,
newRows
*
pField
->
bytes
);
newRows
*
pField
->
bytes
);
}
}
...
@@ -992,8 +999,8 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
...
@@ -992,8 +999,8 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
}
}
if
(
pQueryInfo
->
order
.
order
==
TSDB_ORDER_ASC
)
{
if
(
pQueryInfo
->
order
.
order
==
TSDB_ORDER_ASC
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
i
)
{
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
pQuery
Info
,
i
);
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fields
Info
,
i
);
int16_t
offset
=
getColumnModelOffset
(
pLocalReducer
->
resColModel
,
i
);
int16_t
offset
=
getColumnModelOffset
(
pLocalReducer
->
resColModel
,
i
);
memcpy
(
pRes
->
data
+
offset
*
pRes
->
numOfRows
,
pResPages
[
i
]
->
data
,
pField
->
bytes
*
pRes
->
numOfRows
);
memcpy
(
pRes
->
data
+
offset
*
pRes
->
numOfRows
,
pResPages
[
i
]
->
data
,
pField
->
bytes
*
pRes
->
numOfRows
);
}
}
...
@@ -1003,7 +1010,7 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
...
@@ -1003,7 +1010,7 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
}
}
pFinalDataPage
->
numOfElems
=
0
;
pFinalDataPage
->
numOfElems
=
0
;
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
i
)
{
tfree
(
pResPages
[
i
]);
tfree
(
pResPages
[
i
]);
}
}
tfree
(
pResPages
);
tfree
(
pResPages
);
...
@@ -1030,8 +1037,9 @@ static void savePreviousRow(SLocalReducer *pLocalReducer, tFilePage *tmpBuffer)
...
@@ -1030,8 +1037,9 @@ static void savePreviousRow(SLocalReducer *pLocalReducer, tFilePage *tmpBuffer)
static
void
doExecuteSecondaryMerge
(
SSqlCmd
*
pCmd
,
SLocalReducer
*
pLocalReducer
,
bool
needInit
)
{
static
void
doExecuteSecondaryMerge
(
SSqlCmd
*
pCmd
,
SLocalReducer
*
pLocalReducer
,
bool
needInit
)
{
// the tag columns need to be set before all functions execution
// the tag columns need to be set before all functions execution
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
size_t
size
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
for
(
int32_t
j
=
0
;
j
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
size
;
++
j
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
j
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
j
);
SQLFunctionCtx
*
pCtx
=
&
pLocalReducer
->
pCtx
[
j
];
SQLFunctionCtx
*
pCtx
=
&
pLocalReducer
->
pCtx
[
j
];
...
@@ -1051,7 +1059,7 @@ static void doExecuteSecondaryMerge(SSqlCmd *pCmd, SLocalReducer *pLocalReducer,
...
@@ -1051,7 +1059,7 @@ static void doExecuteSecondaryMerge(SSqlCmd *pCmd, SLocalReducer *pLocalReducer,
}
}
}
}
for
(
int32_t
j
=
0
;
j
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
size
;
++
j
)
{
int32_t
functionId
=
tscSqlExprGet
(
pQueryInfo
,
j
)
->
functionId
;
int32_t
functionId
=
tscSqlExprGet
(
pQueryInfo
,
j
)
->
functionId
;
if
(
functionId
==
TSDB_FUNC_TAG_DUMMY
||
functionId
==
TSDB_FUNC_TS_DUMMY
)
{
if
(
functionId
==
TSDB_FUNC_TAG_DUMMY
||
functionId
==
TSDB_FUNC_TS_DUMMY
)
{
continue
;
continue
;
...
@@ -1071,8 +1079,9 @@ static void handleUnprocessedRow(SSqlCmd *pCmd, SLocalReducer *pLocalReducer, tF
...
@@ -1071,8 +1079,9 @@ static void handleUnprocessedRow(SSqlCmd *pCmd, SLocalReducer *pLocalReducer, tF
static
int64_t
getNumOfResultLocal
(
SQueryInfo
*
pQueryInfo
,
SQLFunctionCtx
*
pCtx
)
{
static
int64_t
getNumOfResultLocal
(
SQueryInfo
*
pQueryInfo
,
SQLFunctionCtx
*
pCtx
)
{
int64_t
maxOutput
=
0
;
int64_t
maxOutput
=
0
;
for
(
int32_t
j
=
0
;
j
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
j
)
{
size_t
size
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
for
(
int32_t
j
=
0
;
j
<
size
;
++
j
)
{
// SSqlExpr* pExpr = pQueryInfo->fieldsInfo.pSqlExpr[j];
// SSqlExpr* pExpr = pQueryInfo->fieldsInfo.pSqlExpr[j];
// if (pExpr == NULL) {
// if (pExpr == NULL) {
// assert(pQueryInfo->fieldsInfo.pExpr[j] != NULL);
// assert(pQueryInfo->fieldsInfo.pExpr[j] != NULL);
...
@@ -1107,7 +1116,9 @@ static int64_t getNumOfResultLocal(SQueryInfo *pQueryInfo, SQLFunctionCtx *pCtx)
...
@@ -1107,7 +1116,9 @@ static int64_t getNumOfResultLocal(SQueryInfo *pQueryInfo, SQLFunctionCtx *pCtx)
*/
*/
static
void
fillMultiRowsOfTagsVal
(
SQueryInfo
*
pQueryInfo
,
int32_t
numOfRes
,
SLocalReducer
*
pLocalReducer
)
{
static
void
fillMultiRowsOfTagsVal
(
SQueryInfo
*
pQueryInfo
,
int32_t
numOfRes
,
SLocalReducer
*
pLocalReducer
)
{
int32_t
maxBufSize
=
0
;
// find the max tags column length to prepare the buffer
int32_t
maxBufSize
=
0
;
// find the max tags column length to prepare the buffer
for
(
int32_t
k
=
0
;
k
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
k
)
{
size_t
size
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
for
(
int32_t
k
=
0
;
k
<
size
;
++
k
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
k
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
k
);
if
(
maxBufSize
<
pExpr
->
resBytes
&&
pExpr
->
functionId
==
TSDB_FUNC_TAG
)
{
if
(
maxBufSize
<
pExpr
->
resBytes
&&
pExpr
->
functionId
==
TSDB_FUNC_TAG
)
{
maxBufSize
=
pExpr
->
resBytes
;
maxBufSize
=
pExpr
->
resBytes
;
...
@@ -1117,7 +1128,7 @@ static void fillMultiRowsOfTagsVal(SQueryInfo *pQueryInfo, int32_t numOfRes, SLo
...
@@ -1117,7 +1128,7 @@ static void fillMultiRowsOfTagsVal(SQueryInfo *pQueryInfo, int32_t numOfRes, SLo
assert
(
maxBufSize
>=
0
);
assert
(
maxBufSize
>=
0
);
char
*
buf
=
malloc
((
size_t
)
maxBufSize
);
char
*
buf
=
malloc
((
size_t
)
maxBufSize
);
for
(
int32_t
k
=
0
;
k
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
k
)
{
for
(
int32_t
k
=
0
;
k
<
size
;
++
k
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
k
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
k
);
if
(
pExpr
->
functionId
!=
TSDB_FUNC_TAG
)
{
if
(
pExpr
->
functionId
!=
TSDB_FUNC_TAG
)
{
continue
;
continue
;
...
@@ -1139,7 +1150,9 @@ static void fillMultiRowsOfTagsVal(SQueryInfo *pQueryInfo, int32_t numOfRes, SLo
...
@@ -1139,7 +1150,9 @@ static void fillMultiRowsOfTagsVal(SQueryInfo *pQueryInfo, int32_t numOfRes, SLo
}
}
int32_t
finalizeRes
(
SQueryInfo
*
pQueryInfo
,
SLocalReducer
*
pLocalReducer
)
{
int32_t
finalizeRes
(
SQueryInfo
*
pQueryInfo
,
SLocalReducer
*
pLocalReducer
)
{
for
(
int32_t
k
=
0
;
k
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
k
)
{
size_t
size
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
for
(
int32_t
k
=
0
;
k
<
size
;
++
k
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
k
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
k
);
aAggs
[
pExpr
->
functionId
].
xFinalize
(
&
pLocalReducer
->
pCtx
[
k
]);
aAggs
[
pExpr
->
functionId
].
xFinalize
(
&
pLocalReducer
->
pCtx
[
k
]);
}
}
...
@@ -1242,7 +1255,7 @@ bool doGenerateFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool no
...
@@ -1242,7 +1255,7 @@ bool doGenerateFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool no
#endif
#endif
SInterpolationInfo
*
pInterpoInfo
=
&
pLocalReducer
->
interpolationInfo
;
SInterpolationInfo
*
pInterpoInfo
=
&
pLocalReducer
->
interpolationInfo
;
int32_t
startIndex
=
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
-
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
;
int32_t
startIndex
=
pQueryInfo
->
fieldsInfo
.
numOfOutput
-
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
;
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
;
++
i
)
{
int16_t
offset
=
getColumnModelOffset
(
pModel
,
startIndex
+
i
);
int16_t
offset
=
getColumnModelOffset
(
pModel
,
startIndex
+
i
);
...
@@ -1258,7 +1271,7 @@ bool doGenerateFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool no
...
@@ -1258,7 +1271,7 @@ bool doGenerateFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool no
}
}
void
resetOutputBuf
(
SQueryInfo
*
pQueryInfo
,
SLocalReducer
*
pLocalReducer
)
{
// reset output buffer to the beginning
void
resetOutputBuf
(
SQueryInfo
*
pQueryInfo
,
SLocalReducer
*
pLocalReducer
)
{
// reset output buffer to the beginning
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
i
)
{
pLocalReducer
->
pCtx
[
i
].
aOutputBuf
=
pLocalReducer
->
pCtx
[
i
].
aOutputBuf
=
pLocalReducer
->
pResultBuf
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
i
)
*
pLocalReducer
->
resColModel
->
capacity
;
pLocalReducer
->
pResultBuf
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
i
)
*
pLocalReducer
->
resColModel
->
capacity
;
}
}
...
@@ -1282,7 +1295,7 @@ static void resetEnvForNewResultset(SSqlRes *pRes, SSqlCmd *pCmd, SLocalReducer
...
@@ -1282,7 +1295,7 @@ static void resetEnvForNewResultset(SSqlRes *pRes, SSqlCmd *pCmd, SLocalReducer
// for group result interpolation, do not return if not data is generated
// for group result interpolation, do not return if not data is generated
if
(
pQueryInfo
->
interpoType
!=
TSDB_INTERPO_NONE
)
{
if
(
pQueryInfo
->
interpoType
!=
TSDB_INTERPO_NONE
)
{
int64_t
stime
=
(
pQueryInfo
->
stime
<
pQueryInfo
->
etime
)
?
pQueryInfo
->
stime
:
pQueryInfo
->
etime
;
int64_t
stime
=
(
pQueryInfo
->
window
.
skey
<
pQueryInfo
->
window
.
ekey
)
?
pQueryInfo
->
window
.
skey
:
pQueryInfo
->
window
.
ekey
;
int64_t
newTime
=
int64_t
newTime
=
taosGetIntervalStartTimestamp
(
stime
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
slidingTimeUnit
,
precision
);
taosGetIntervalStartTimestamp
(
stime
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
slidingTimeUnit
,
precision
);
...
@@ -1348,7 +1361,7 @@ static bool doHandleLastRemainData(SSqlObj *pSql) {
...
@@ -1348,7 +1361,7 @@ static bool doHandleLastRemainData(SSqlObj *pSql) {
prevGroupCompleted
)
{
prevGroupCompleted
)
{
// if interpoType == TSDB_INTERPO_NONE, return directly
// if interpoType == TSDB_INTERPO_NONE, return directly
if
(
pQueryInfo
->
interpoType
!=
TSDB_INTERPO_NONE
)
{
if
(
pQueryInfo
->
interpoType
!=
TSDB_INTERPO_NONE
)
{
int64_t
etime
=
(
pQueryInfo
->
stime
<
pQueryInfo
->
etime
)
?
pQueryInfo
->
etime
:
pQueryInfo
->
stime
;
int64_t
etime
=
(
pQueryInfo
->
window
.
skey
<
pQueryInfo
->
window
.
ekey
)
?
pQueryInfo
->
window
.
ekey
:
pQueryInfo
->
window
.
skey
;
etime
=
taosGetRevisedEndKey
(
etime
,
pQueryInfo
->
order
.
order
,
pQueryInfo
->
intervalTime
,
etime
=
taosGetRevisedEndKey
(
etime
,
pQueryInfo
->
order
.
order
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
slidingTimeUnit
,
precision
);
pQueryInfo
->
slidingTimeUnit
,
precision
);
...
@@ -1386,8 +1399,9 @@ static void doProcessResultInNextWindow(SSqlObj *pSql, int32_t numOfRes) {
...
@@ -1386,8 +1399,9 @@ static void doProcessResultInNextWindow(SSqlObj *pSql, int32_t numOfRes) {
SLocalReducer
*
pLocalReducer
=
pRes
->
pLocalReducer
;
SLocalReducer
*
pLocalReducer
=
pRes
->
pLocalReducer
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
size_t
size
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
for
(
int32_t
k
=
0
;
k
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
k
)
{
for
(
int32_t
k
=
0
;
k
<
size
;
++
k
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
k
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
k
);
SQLFunctionCtx
*
pCtx
=
&
pLocalReducer
->
pCtx
[
k
];
SQLFunctionCtx
*
pCtx
=
&
pLocalReducer
->
pCtx
[
k
];
...
...
src/client/src/tscServer.c
浏览文件 @
6dbca070
...
@@ -359,13 +359,13 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg) {
...
@@ -359,13 +359,13 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg) {
/*
/*
* Whether to free sqlObj or not should be decided before call the user defined function, since this SqlObj
* Whether to free sqlObj or not should be decided before call the user defined function, since this SqlObj
* may be freed in UDF, and reused by other threads before tscShould
FreeAsyncSqlObj
called, in which case
* may be freed in UDF, and reused by other threads before tscShould
BeFreed
called, in which case
* tscShould
FreeAsyncSqlObj
checks an object which is actually allocated by other threads.
* tscShould
BeFreed
checks an object which is actually allocated by other threads.
*
*
* If this block of memory is re-allocated for an insert thread, in which tscKeepConn[command] equals to 0,
* If this block of memory is re-allocated for an insert thread, in which tscKeepConn[command] equals to 0,
* the tscShould
FreeAsyncSqlObj
will success and tscFreeSqlObj free it immediately.
* the tscShould
BeFreed
will success and tscFreeSqlObj free it immediately.
*/
*/
bool
shouldFree
=
tscShould
FreeAsyncSqlObj
(
pSql
);
bool
shouldFree
=
tscShould
BeFreed
(
pSql
);
(
*
pSql
->
fp
)(
pSql
->
param
,
taosres
,
rpcMsg
->
code
);
(
*
pSql
->
fp
)(
pSql
->
param
,
taosres
,
rpcMsg
->
code
);
if
(
shouldFree
)
{
if
(
shouldFree
)
{
...
@@ -458,7 +458,7 @@ int tscProcessSql(SSqlObj *pSql) {
...
@@ -458,7 +458,7 @@ int tscProcessSql(SSqlObj *pSql) {
return
doProcessSql
(
pSql
);
return
doProcessSql
(
pSql
);
}
}
void
tscKill
Metric
Query
(
SSqlObj
*
pSql
)
{
void
tscKill
STable
Query
(
SSqlObj
*
pSql
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
...
@@ -572,9 +572,11 @@ static int32_t tscEstimateQueryMsgSize(SSqlCmd *pCmd, int32_t clauseIndex) {
...
@@ -572,9 +572,11 @@ static int32_t tscEstimateQueryMsgSize(SSqlCmd *pCmd, int32_t clauseIndex) {
const
static
int32_t
MIN_QUERY_MSG_PKT_SIZE
=
TSDB_MAX_BYTES_PER_ROW
*
5
;
const
static
int32_t
MIN_QUERY_MSG_PKT_SIZE
=
TSDB_MAX_BYTES_PER_ROW
*
5
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
clauseIndex
);
int32_t
srcColListSize
=
pQueryInfo
->
colList
.
numOfCols
*
sizeof
(
SColumnInfo
);
int32_t
srcColListSize
=
taosArrayGetSize
(
pQueryInfo
->
colList
)
*
sizeof
(
SColumnInfo
);
int32_t
exprSize
=
sizeof
(
SSqlFuncExprMsg
)
*
pQueryInfo
->
exprsInfo
.
numOfExprs
;
size_t
numOfExprs
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
int32_t
exprSize
=
sizeof
(
SSqlFuncMsg
)
*
numOfExprs
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
// meter query without tags values
// meter query without tags values
...
@@ -583,20 +585,6 @@ static int32_t tscEstimateQueryMsgSize(SSqlCmd *pCmd, int32_t clauseIndex) {
...
@@ -583,20 +585,6 @@ static int32_t tscEstimateQueryMsgSize(SSqlCmd *pCmd, int32_t clauseIndex) {
}
}
int32_t
size
=
4096
;
int32_t
size
=
4096
;
#if 0
SSuperTableMeta *pMetricMeta = pTableMetaInfo->pMetricMeta;
SVnodeSidList *pVnodeSidList = tscGetVnodeSidList(pMetricMeta, pTableMetaInfo->vgroupIndex);
int32_t meterInfoSize = (pMetricMeta->tagLen + sizeof(STableIdInfo)) * pVnodeSidList->numOfSids;
int32_t outputColumnSize = pQueryInfo->exprsInfo.numOfExprs * sizeof(SSqlFuncExprMsg);
int32_t size = meterInfoSize + outputColumnSize + srcColListSize + exprSize + MIN_QUERY_MSG_PKT_SIZE;
if (pQueryInfo->tsBuf != NULL) {
size += pQueryInfo->tsBuf->fileSize;
}
#endif
return
size
;
return
size
;
}
}
...
@@ -629,7 +617,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -629,7 +617,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
if
(
pQueryInfo
->
colList
.
numOfCols
<=
0
)
{
if
(
taosArrayGetSize
(
pQueryInfo
->
colList
)
<=
0
)
{
tscError
(
"%p illegal value of numOfCols in query msg: %d"
,
pSql
,
tscGetNumOfColumns
(
pTableMeta
));
tscError
(
"%p illegal value of numOfCols in query msg: %d"
,
pSql
,
tscGetNumOfColumns
(
pTableMeta
));
return
-
1
;
return
-
1
;
}
}
...
@@ -674,17 +662,6 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -674,17 +662,6 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pSql
->
ipList
.
ip
[
i
]
=
pVgroupInfo
->
ipAddr
[
i
].
ip
;
pSql
->
ipList
.
ip
[
i
]
=
pVgroupInfo
->
ipAddr
[
i
].
ip
;
}
}
#if 0
SVnodeSidList *pVnodeSidList = tscGetVnodeSidList(pMetricMeta, pTableMetaInfo->vgroupIndex);
uint32_t vnodeId = pVnodeSidList->vpeerDesc[pVnodeSidList->index].vnode;
numOfTables = pVnodeSidList->numOfSids;
if (numOfTables <= 0) {
tscError("%p vid:%d,error numOfTables in query message:%d", pSql, vnodeId, numOfTables);
return -1; // error
}
#endif
tscTrace
(
"%p query on super table, numOfVgroup:%d, vgroupIndex:%d"
,
pSql
,
pTableMetaInfo
->
vgroupList
->
numOfVgroups
,
index
);
tscTrace
(
"%p query on super table, numOfVgroup:%d, vgroupIndex:%d"
,
pSql
,
pTableMetaInfo
->
vgroupList
->
numOfVgroups
,
index
);
pQueryMsg
->
head
.
vgId
=
htonl
(
pVgroupInfo
->
vgId
);
pQueryMsg
->
head
.
vgId
=
htonl
(
pVgroupInfo
->
vgId
);
...
@@ -692,11 +669,11 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -692,11 +669,11 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
}
if
(
pQueryInfo
->
order
.
order
==
TSDB_ORDER_ASC
)
{
if
(
pQueryInfo
->
order
.
order
==
TSDB_ORDER_ASC
)
{
pQueryMsg
->
window
.
skey
=
htobe64
(
pQueryInfo
->
stime
);
pQueryMsg
->
window
.
skey
=
htobe64
(
pQueryInfo
->
window
.
skey
);
pQueryMsg
->
window
.
ekey
=
htobe64
(
pQueryInfo
->
etime
);
pQueryMsg
->
window
.
ekey
=
htobe64
(
pQueryInfo
->
window
.
ekey
);
}
else
{
}
else
{
pQueryMsg
->
window
.
skey
=
htobe64
(
pQueryInfo
->
etime
);
pQueryMsg
->
window
.
skey
=
htobe64
(
pQueryInfo
->
window
.
ekey
);
pQueryMsg
->
window
.
ekey
=
htobe64
(
pQueryInfo
->
stime
);
pQueryMsg
->
window
.
ekey
=
htobe64
(
pQueryInfo
->
window
.
skey
);
}
}
pQueryMsg
->
numOfTables
=
htonl
(
numOfTables
);
pQueryMsg
->
numOfTables
=
htonl
(
numOfTables
);
...
@@ -705,37 +682,38 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -705,37 +682,38 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pQueryMsg
->
interpoType
=
htons
(
pQueryInfo
->
interpoType
);
pQueryMsg
->
interpoType
=
htons
(
pQueryInfo
->
interpoType
);
pQueryMsg
->
limit
=
htobe64
(
pQueryInfo
->
limit
.
limit
);
pQueryMsg
->
limit
=
htobe64
(
pQueryInfo
->
limit
.
limit
);
pQueryMsg
->
offset
=
htobe64
(
pQueryInfo
->
limit
.
offset
);
pQueryMsg
->
offset
=
htobe64
(
pQueryInfo
->
limit
.
offset
);
pQueryMsg
->
numOfCols
=
htons
(
pQueryInfo
->
colList
.
numOfCols
);
pQueryMsg
->
numOfCols
=
htons
(
taosArrayGetSize
(
pQueryInfo
->
colList
)
);
pQueryMsg
->
intervalTime
=
htobe64
(
pQueryInfo
->
intervalTime
);
pQueryMsg
->
intervalTime
=
htobe64
(
pQueryInfo
->
intervalTime
);
pQueryMsg
->
slidingTime
=
htobe64
(
pQueryInfo
->
slidingTime
);
pQueryMsg
->
slidingTime
=
htobe64
(
pQueryInfo
->
slidingTime
);
pQueryMsg
->
slidingTimeUnit
=
pQueryInfo
->
slidingTimeUnit
;
pQueryMsg
->
slidingTimeUnit
=
pQueryInfo
->
slidingTimeUnit
;
pQueryMsg
->
numOfGroupCols
=
htons
(
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
);
pQueryMsg
->
numOfGroupCols
=
htons
(
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
);
pQueryMsg
->
queryType
=
htons
(
pQueryInfo
->
type
);
pQueryMsg
->
queryType
=
htons
(
pQueryInfo
->
type
);
pQueryMsg
->
numOfOutputCols
=
htons
(
pQueryInfo
->
exprsInfo
.
numOfExprs
);
size_t
numOfOutput
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
int32_t
numOfOutput
=
pQueryInfo
->
fieldsInfo
.
numOfOutputCols
;
pQueryMsg
->
numOfOutput
=
htons
(
numOfOutput
)
;
if
(
numOfOutput
<
0
)
{
if
(
numOfOutput
<
0
)
{
tscError
(
"%p illegal value of number of output columns in query msg: %d"
,
pSql
,
numOfOutput
);
tscError
(
"%p illegal value of number of output columns in query msg: %d"
,
pSql
,
numOfOutput
);
return
-
1
;
return
-
1
;
}
}
// set column list ids
// set column list ids
char
*
pMsg
=
(
char
*
)(
pQueryMsg
->
colList
)
+
pQueryInfo
->
colList
.
numOfCols
*
sizeof
(
SColumnInfo
);
size_t
numOfCols
=
taosArrayGetSize
(
pQueryInfo
->
colList
);
char
*
pMsg
=
(
char
*
)(
pQueryMsg
->
colList
)
+
numOfCols
*
sizeof
(
SColumnInfo
);
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMeta
);
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMeta
);
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
colList
.
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnBase
*
pCol
=
tscColumnBaseInfoGet
(
&
pQueryInfo
->
colList
,
i
);
SColumn
*
pCol
=
taosArrayGetP
(
pQueryInfo
->
colList
,
i
);
SSchema
*
pColSchema
=
&
pSchema
[
pCol
->
colIndex
.
columnIndex
];
SSchema
*
pColSchema
=
&
pSchema
[
pCol
->
colIndex
.
columnIndex
];
if
(
pCol
->
colIndex
.
columnIndex
>=
tscGetNumOfColumns
(
pTableMeta
)
||
pColSchema
->
type
<
TSDB_DATA_TYPE_BOOL
||
pColSchema
->
type
>
TSDB_DATA_TYPE_NCHAR
)
{
tscError
(
"%p sid:%d uid:%"
PRIu64
" id:%s, column index out of range, numOfColumns:%d, index:%d, column name:%s"
,
pSql
,
pTableMeta
->
sid
,
pTableMeta
->
uid
,
pTableMetaInfo
->
name
,
tscGetNumOfColumns
(
pTableMeta
),
pCol
->
colIndex
,
pColSchema
->
name
);
// if (pCol->colIndex.columnIndex >= tscGetNumOfColumns(pTableMeta) || pColSchema->type < TSDB_DATA_TYPE_BOOL ||
return
-
1
;
// 0 means build msg failed
// pColSchema->type > TSDB_DATA_TYPE_NCHAR) {
}
// tscError("%p vid:%d sid:%d id:%s, column index out of range, numOfColumns:%d, index:%d, column name:%s", pSql,
// htons(pQueryMsg->vnode), pTableMeta->sid, pTableMetaInfo->name, tscGetNumOfColumns(pTableMeta), pCol->colIndex,
// pColSchema->name);
//
// return -1; // 0 means build msg failed
// }
pQueryMsg
->
colList
[
i
].
colId
=
htons
(
pColSchema
->
colId
);
pQueryMsg
->
colList
[
i
].
colId
=
htons
(
pColSchema
->
colId
);
pQueryMsg
->
colList
[
i
].
bytes
=
htons
(
pColSchema
->
bytes
);
pQueryMsg
->
colList
[
i
].
bytes
=
htons
(
pColSchema
->
bytes
);
...
@@ -747,11 +725,11 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -747,11 +725,11 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SColumnFilterInfo
*
pColFilter
=
&
pCol
->
filterInfo
[
f
];
SColumnFilterInfo
*
pColFilter
=
&
pCol
->
filterInfo
[
f
];
SColumnFilterInfo
*
pFilterMsg
=
(
SColumnFilterInfo
*
)
pMsg
;
SColumnFilterInfo
*
pFilterMsg
=
(
SColumnFilterInfo
*
)
pMsg
;
pFilterMsg
->
filter
OnBinary
=
htons
(
pColFilter
->
filterOnBinary
);
pFilterMsg
->
filter
str
=
htons
(
pColFilter
->
filterstr
);
pMsg
+=
sizeof
(
SColumnFilterInfo
);
pMsg
+=
sizeof
(
SColumnFilterInfo
);
if
(
pColFilter
->
filter
OnBinary
)
{
if
(
pColFilter
->
filter
str
)
{
pFilterMsg
->
len
=
htobe64
(
pColFilter
->
len
);
pFilterMsg
->
len
=
htobe64
(
pColFilter
->
len
);
memcpy
(
pMsg
,
(
void
*
)
pColFilter
->
pz
,
pColFilter
->
len
+
1
);
memcpy
(
pMsg
,
(
void
*
)
pColFilter
->
pz
,
pColFilter
->
len
+
1
);
pMsg
+=
(
pColFilter
->
len
+
1
);
// append the additional filter binary info
pMsg
+=
(
pColFilter
->
len
+
1
);
// append the additional filter binary info
...
@@ -772,7 +750,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -772,7 +750,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
bool
hasArithmeticFunction
=
false
;
bool
hasArithmeticFunction
=
false
;
SSqlFunc
ExprMsg
*
pSqlFuncExpr
=
(
SSqlFuncExpr
Msg
*
)
pMsg
;
SSqlFunc
Msg
*
pSqlFuncExpr
=
(
SSqlFunc
Msg
*
)
pMsg
;
for
(
int32_t
i
=
0
;
i
<
tscSqlExprNumOfExprs
(
pQueryInfo
);
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
tscSqlExprNumOfExprs
(
pQueryInfo
);
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
...
@@ -792,7 +770,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -792,7 +770,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pSqlFuncExpr
->
functionId
=
htons
(
pExpr
->
functionId
);
pSqlFuncExpr
->
functionId
=
htons
(
pExpr
->
functionId
);
pSqlFuncExpr
->
numOfParams
=
htons
(
pExpr
->
numOfParams
);
pSqlFuncExpr
->
numOfParams
=
htons
(
pExpr
->
numOfParams
);
pMsg
+=
sizeof
(
SSqlFunc
Expr
Msg
);
pMsg
+=
sizeof
(
SSqlFuncMsg
);
for
(
int32_t
j
=
0
;
j
<
pExpr
->
numOfParams
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
pExpr
->
numOfParams
;
++
j
)
{
pSqlFuncExpr
->
arg
[
j
].
argType
=
htons
((
uint16_t
)
pExpr
->
param
[
j
].
nType
);
pSqlFuncExpr
->
arg
[
j
].
argType
=
htons
((
uint16_t
)
pExpr
->
param
[
j
].
nType
);
...
@@ -808,13 +786,14 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -808,13 +786,14 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
}
}
}
pSqlFuncExpr
=
(
SSqlFunc
Expr
Msg
*
)
pMsg
;
pSqlFuncExpr
=
(
SSqlFuncMsg
*
)
pMsg
;
}
}
int32_t
len
=
0
;
int32_t
len
=
0
;
if
(
hasArithmeticFunction
)
{
if
(
hasArithmeticFunction
)
{
SColumnBase
*
pColBase
=
pQueryInfo
->
colList
.
pColList
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
colList
.
numOfCols
;
++
i
)
{
SColumn
*
pColBase
=
taosArrayGetP
(
pQueryInfo
->
colList
,
i
);
char
*
name
=
pSchema
[
pColBase
[
i
].
colIndex
.
columnIndex
].
name
;
char
*
name
=
pSchema
[
pColBase
[
i
].
colIndex
.
columnIndex
].
name
;
int32_t
lenx
=
strlen
(
name
);
int32_t
lenx
=
strlen
(
name
);
memcpy
(
pMsg
,
name
,
lenx
);
memcpy
(
pMsg
,
name
,
lenx
);
...
@@ -853,7 +832,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -853,7 +832,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
}
if
(
pQueryInfo
->
interpoType
!=
TSDB_INTERPO_NONE
)
{
if
(
pQueryInfo
->
interpoType
!=
TSDB_INTERPO_NONE
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
i
)
{
*
((
int64_t
*
)
pMsg
)
=
htobe64
(
pQueryInfo
->
defaultVal
[
i
]);
*
((
int64_t
*
)
pMsg
)
=
htobe64
(
pQueryInfo
->
defaultVal
[
i
]);
pMsg
+=
sizeof
(
pQueryInfo
->
defaultVal
[
0
]);
pMsg
+=
sizeof
(
pQueryInfo
->
defaultVal
[
0
]);
}
}
...
@@ -1258,7 +1237,7 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1258,7 +1237,7 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pSchema
=
(
SSchema
*
)
pCreateTableMsg
->
schema
;
pSchema
=
(
SSchema
*
)
pCreateTableMsg
->
schema
;
for
(
int
i
=
0
;
i
<
pCmd
->
numOfCols
+
pCmd
->
count
;
++
i
)
{
for
(
int
i
=
0
;
i
<
pCmd
->
numOfCols
+
pCmd
->
count
;
++
i
)
{
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
pQuery
Info
,
i
);
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fields
Info
,
i
);
pSchema
->
type
=
pField
->
type
;
pSchema
->
type
=
pField
->
type
;
strcpy
(
pSchema
->
name
,
pField
->
name
);
strcpy
(
pSchema
->
name
,
pField
->
name
);
...
@@ -1277,7 +1256,7 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1277,7 +1256,7 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
}
}
}
tsc
ClearFieldInfo
(
&
pQueryInfo
->
fieldsInfo
);
tsc
FieldInfoClear
(
&
pQueryInfo
->
fieldsInfo
);
msgLen
=
pMsg
-
(
char
*
)
pCreateTableMsg
;
msgLen
=
pMsg
-
(
char
*
)
pCreateTableMsg
;
pCreateTableMsg
->
contLen
=
htonl
(
msgLen
);
pCreateTableMsg
->
contLen
=
htonl
(
msgLen
);
...
@@ -1325,7 +1304,7 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1325,7 +1304,7 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SSchema
*
pSchema
=
pAlterTableMsg
->
schema
;
SSchema
*
pSchema
=
pAlterTableMsg
->
schema
;
for
(
int
i
=
0
;
i
<
tscNumOfFields
(
pQueryInfo
);
++
i
)
{
for
(
int
i
=
0
;
i
<
tscNumOfFields
(
pQueryInfo
);
++
i
)
{
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
pQuery
Info
,
i
);
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fields
Info
,
i
);
pSchema
->
type
=
pField
->
type
;
pSchema
->
type
=
pField
->
type
;
strcpy
(
pSchema
->
name
,
pField
->
name
);
strcpy
(
pSchema
->
name
,
pField
->
name
);
...
@@ -1384,9 +1363,9 @@ static int tscSetResultPointer(SQueryInfo *pQueryInfo, SSqlRes *pRes) {
...
@@ -1384,9 +1363,9 @@ static int tscSetResultPointer(SQueryInfo *pQueryInfo, SSqlRes *pRes) {
return
pRes
->
code
;
return
pRes
->
code
;
}
}
for
(
int
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
;
++
i
)
{
for
(
int
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
i
)
{
int16_t
offset
=
tscFieldInfoGetOffset
(
pQueryInfo
,
i
);
int16_t
offset
=
tscFieldInfoGetOffset
(
pQueryInfo
,
i
);
pRes
->
tsrow
[
i
]
=
(
pRes
->
data
+
offset
*
pRes
->
numOfRows
);
pRes
->
tsrow
[
i
]
=
(
(
char
*
)
pRes
->
data
+
offset
*
pRes
->
numOfRows
);
}
}
return
0
;
return
0
;
...
@@ -2190,28 +2169,35 @@ int tscProcessShowRsp(SSqlObj *pSql) {
...
@@ -2190,28 +2169,35 @@ int tscProcessShowRsp(SSqlObj *pSql) {
strcpy
(
key
+
1
,
"showlist"
);
strcpy
(
key
+
1
,
"showlist"
);
taosCacheRelease
(
tscCacheHandle
,
(
void
*
)
&
(
pTableMetaInfo
->
pTableMeta
),
false
);
taosCacheRelease
(
tscCacheHandle
,
(
void
*
)
&
(
pTableMetaInfo
->
pTableMeta
),
false
);
size_t
size
=
0
;
size_t
size
=
0
;
STableMeta
*
pTableMeta
=
tscCreateTableMetaFromMsg
(
pMetaMsg
,
&
size
);
STableMeta
*
pTableMeta
=
tscCreateTableMetaFromMsg
(
pMetaMsg
,
&
size
);
pTableMetaInfo
->
pTableMeta
=
pTableMetaInfo
->
pTableMeta
=
taosCachePut
(
tscCacheHandle
,
key
,
(
char
*
)
pTableMeta
,
size
,
tsMeterMetaKeepTimer
);
(
STableMeta
*
)
taosCachePut
(
tscCacheHandle
,
key
,
(
char
*
)
pTableMeta
,
size
,
tsMeterMetaKeepTimer
);
pCmd
->
numOfCols
=
pQueryInfo
->
fieldsInfo
.
numOfOutputCols
;
SSchema
*
pTableSchema
=
tscGetTableSchema
(
pTableMetaInfo
->
pTableMeta
);
SSchema
*
pTableSchema
=
tscGetTableSchema
(
pTableMetaInfo
->
pTableMeta
);
tscColumnBaseInfoReserve
(
&
pQueryInfo
->
colList
,
pMetaMsg
->
numOfColumns
);
if
(
pQueryInfo
->
colList
==
NULL
)
{
pQueryInfo
->
colList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
}
SFieldInfo
*
pFieldInfo
=
&
pQueryInfo
->
fieldsInfo
;
SColumnIndex
index
=
{
0
};
SColumnIndex
index
=
{
0
};
pSchema
=
pMetaMsg
->
schema
;
for
(
int16_t
i
=
0
;
i
<
pMetaMsg
->
numOfColumns
;
++
i
)
{
for
(
int16_t
i
=
0
;
i
<
pMetaMsg
->
numOfColumns
;
++
i
,
++
pSchema
)
{
index
.
columnIndex
=
i
;
index
.
columnIndex
=
i
;
tscColumnBaseInfoInsert
(
pQueryInfo
,
&
index
);
tscColumnListInsert
(
pQueryInfo
->
colList
,
&
index
);
tscFieldInfoSetValFromSchema
(
&
pQueryInfo
->
fieldsInfo
,
i
,
&
pTableSchema
[
i
]);
TAOS_FIELD
f
=
tscCreateField
(
pSchema
->
type
,
pSchema
->
name
,
pSchema
->
bytes
);
SFieldSupInfo
*
pInfo
=
tscFieldInfoAppend
(
pFieldInfo
,
&
f
);
p
QueryInfo
->
fieldsInfo
.
pSqlExpr
[
i
]
=
tscSqlExprInsert
(
pQueryInfo
,
i
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
p
Info
->
pSqlExpr
=
tscSqlExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
pTableSchema
[
i
].
type
,
pTableSchema
[
i
].
bytes
,
pTableSchema
[
i
].
bytes
);
pTableSchema
[
i
].
type
,
pTableSchema
[
i
].
bytes
,
pTableSchema
[
i
].
bytes
);
}
}
tscFieldInfoCalOffset
(
pQueryInfo
);
pCmd
->
numOfCols
=
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
tscFieldInfoUpdateOffset
(
pQueryInfo
);
tfree
(
pTableMeta
);
tfree
(
pTableMeta
);
return
0
;
return
0
;
...
@@ -2322,7 +2308,7 @@ int tscProcessQueryRsp(SSqlObj *pSql) {
...
@@ -2322,7 +2308,7 @@ int tscProcessQueryRsp(SSqlObj *pSql) {
return
0
;
return
0
;
}
}
int
tscProcessRetrieveRspFrom
Vn
ode
(
SSqlObj
*
pSql
)
{
int
tscProcessRetrieveRspFrom
N
ode
(
SSqlObj
*
pSql
)
{
SSqlRes
*
pRes
=
&
pSql
->
res
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
...
@@ -2339,9 +2325,9 @@ int tscProcessRetrieveRspFromVnode(SSqlObj *pSql) {
...
@@ -2339,9 +2325,9 @@ int tscProcessRetrieveRspFromVnode(SSqlObj *pSql) {
tscSetResultPointer
(
pQueryInfo
,
pRes
);
tscSetResultPointer
(
pQueryInfo
,
pRes
);
if
(
pSql
->
pSubscription
!=
NULL
)
{
if
(
pSql
->
pSubscription
!=
NULL
)
{
int32_t
numOfCols
=
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
;
int32_t
numOfCols
=
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
pQuery
Info
,
numOfCols
-
1
);
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fields
Info
,
numOfCols
-
1
);
int16_t
offset
=
tscFieldInfoGetOffset
(
pQueryInfo
,
numOfCols
-
1
);
int16_t
offset
=
tscFieldInfoGetOffset
(
pQueryInfo
,
numOfCols
-
1
);
char
*
p
=
pRes
->
data
+
(
pField
->
bytes
+
offset
)
*
pRes
->
numOfRows
;
char
*
p
=
pRes
->
data
+
(
pField
->
bytes
+
offset
)
*
pRes
->
numOfRows
;
...
@@ -2479,7 +2465,7 @@ int tscRenewMeterMeta(SSqlObj *pSql, char *tableId) {
...
@@ -2479,7 +2465,7 @@ int tscRenewMeterMeta(SSqlObj *pSql, char *tableId) {
* 1. only update the metermeta in force model metricmeta is not updated
* 1. only update the metermeta in force model metricmeta is not updated
* 2. if get metermeta failed, still get the metermeta
* 2. if get metermeta failed, still get the metermeta
*/
*/
if
(
pTableMetaInfo
->
pTableMeta
==
NULL
||
!
tscQueryOn
Metric
(
pCmd
))
{
if
(
pTableMetaInfo
->
pTableMeta
==
NULL
||
!
tscQueryOn
STable
(
pCmd
))
{
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
if
(
pTableMetaInfo
->
pTableMeta
)
{
if
(
pTableMetaInfo
->
pTableMeta
)
{
tscTrace
(
"%p update table meta, old: numOfTags:%d, numOfCols:%d, uid:%"
PRId64
", addr:%p"
,
pSql
,
tscTrace
(
"%p update table meta, old: numOfTags:%d, numOfCols:%d, uid:%"
PRId64
", addr:%p"
,
pSql
,
...
@@ -2624,7 +2610,7 @@ void tscInitMsgsFp() {
...
@@ -2624,7 +2610,7 @@ void tscInitMsgsFp() {
tscBuildMsg
[
TSDB_SQL_KILL_CONNECTION
]
=
tscBuildKillMsg
;
tscBuildMsg
[
TSDB_SQL_KILL_CONNECTION
]
=
tscBuildKillMsg
;
tscProcessMsgRsp
[
TSDB_SQL_SELECT
]
=
tscProcessQueryRsp
;
tscProcessMsgRsp
[
TSDB_SQL_SELECT
]
=
tscProcessQueryRsp
;
tscProcessMsgRsp
[
TSDB_SQL_FETCH
]
=
tscProcessRetrieveRspFrom
Vn
ode
;
tscProcessMsgRsp
[
TSDB_SQL_FETCH
]
=
tscProcessRetrieveRspFrom
N
ode
;
tscProcessMsgRsp
[
TSDB_SQL_DROP_DB
]
=
tscProcessDropDbRsp
;
tscProcessMsgRsp
[
TSDB_SQL_DROP_DB
]
=
tscProcessDropDbRsp
;
tscProcessMsgRsp
[
TSDB_SQL_DROP_TABLE
]
=
tscProcessDropTableRsp
;
tscProcessMsgRsp
[
TSDB_SQL_DROP_TABLE
]
=
tscProcessDropTableRsp
;
...
@@ -2635,7 +2621,7 @@ void tscInitMsgsFp() {
...
@@ -2635,7 +2621,7 @@ void tscInitMsgsFp() {
tscProcessMsgRsp
[
TSDB_SQL_MULTI_META
]
=
tscProcessMultiMeterMetaRsp
;
tscProcessMsgRsp
[
TSDB_SQL_MULTI_META
]
=
tscProcessMultiMeterMetaRsp
;
tscProcessMsgRsp
[
TSDB_SQL_SHOW
]
=
tscProcessShowRsp
;
tscProcessMsgRsp
[
TSDB_SQL_SHOW
]
=
tscProcessShowRsp
;
tscProcessMsgRsp
[
TSDB_SQL_RETRIEVE
]
=
tscProcessRetrieveRspFrom
Vn
ode
;
// rsp handled by same function.
tscProcessMsgRsp
[
TSDB_SQL_RETRIEVE
]
=
tscProcessRetrieveRspFrom
N
ode
;
// rsp handled by same function.
tscProcessMsgRsp
[
TSDB_SQL_DESCRIBE_TABLE
]
=
tscProcessDescribeTableRsp
;
tscProcessMsgRsp
[
TSDB_SQL_DESCRIBE_TABLE
]
=
tscProcessDescribeTableRsp
;
tscProcessMsgRsp
[
TSDB_SQL_RETRIEVE_TAGS
]
=
tscProcessTagRetrieveRsp
;
tscProcessMsgRsp
[
TSDB_SQL_RETRIEVE_TAGS
]
=
tscProcessTagRetrieveRsp
;
...
...
src/client/src/tscSql.c
浏览文件 @
6dbca070
...
@@ -326,16 +326,21 @@ int taos_num_fields(TAOS_RES *res) {
...
@@ -326,16 +326,21 @@ int taos_num_fields(TAOS_RES *res) {
SSqlObj
*
pSql
=
(
SSqlObj
*
)
res
;
SSqlObj
*
pSql
=
(
SSqlObj
*
)
res
;
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
return
0
;
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
return
0
;
int32_t
num
=
0
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
if
(
pQueryInfo
==
NULL
)
{
if
(
pQueryInfo
==
NULL
)
{
return
0
;
return
num
;
}
}
SFieldInfo
*
pFieldsInfo
=
&
pQueryInfo
->
fieldsInfo
;
size_t
numOfCols
=
tscNumOfFields
(
pQueryInfo
);
if
(
pFieldsInfo
)
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
return
(
pFieldsInfo
->
numOfOutputCols
-
pFieldsInfo
->
numOfHiddenCols
);
SFieldSupInfo
*
pInfo
=
taosArrayGet
(
pQueryInfo
->
fieldsInfo
.
pSupportInfo
,
i
);
else
if
(
pInfo
->
visible
)
{
return
0
;
num
++
;
}
}
return
num
;
}
}
int
taos_field_count
(
TAOS
*
taos
)
{
int
taos_field_count
(
TAOS
*
taos
)
{
...
@@ -357,11 +362,16 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
...
@@ -357,11 +362,16 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
return
0
;
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
return
0
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
if
(
pQueryInfo
==
NULL
)
{
if
(
pQueryInfo
)
return
pQueryInfo
->
fieldsInfo
.
pFields
;
else
return
NULL
;
return
NULL
;
}
size_t
numOfCols
=
tscNumOfFields
(
pQueryInfo
);
if
(
numOfCols
==
0
)
{
return
NULL
;
}
return
pQueryInfo
->
fieldsInfo
.
pFields
->
pData
;
}
}
int
taos_retrieve
(
TAOS_RES
*
res
)
{
int
taos_retrieve
(
TAOS_RES
*
res
)
{
...
@@ -414,8 +424,8 @@ int taos_fetch_block_impl(TAOS_RES *res, TAOS_ROW *rows) {
...
@@ -414,8 +424,8 @@ int taos_fetch_block_impl(TAOS_RES *res, TAOS_ROW *rows) {
if
(
pQueryInfo
==
NULL
)
if
(
pQueryInfo
==
NULL
)
return
0
;
return
0
;
for
(
int
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
;
++
i
)
{
for
(
int
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
i
)
{
pRes
->
tsrow
[
i
]
=
TSC_GET_RESPTR_BASE
(
pRes
,
pQueryInfo
,
i
);
pRes
->
tsrow
[
i
]
=
tscGetResultColumnChr
(
pRes
,
pQueryInfo
,
i
);
}
}
*
rows
=
pRes
->
tsrow
;
*
rows
=
pRes
->
tsrow
;
...
@@ -448,7 +458,7 @@ static void transferNcharData(SSqlObj *pSql, int32_t columnIndex, TAOS_FIELD *pF
...
@@ -448,7 +458,7 @@ static void transferNcharData(SSqlObj *pSql, int32_t columnIndex, TAOS_FIELD *pF
static
char
*
getArithemicInputSrc
(
void
*
param
,
char
*
name
,
int32_t
colId
)
{
static
char
*
getArithemicInputSrc
(
void
*
param
,
char
*
name
,
int32_t
colId
)
{
SArithmeticSupport
*
pSupport
=
(
SArithmeticSupport
*
)
param
;
SArithmeticSupport
*
pSupport
=
(
SArithmeticSupport
*
)
param
;
S
SqlFunctionExpr
*
pExpr
=
pSupport
->
p
Expr
;
S
ArithExprInfo
*
pExpr
=
pSupport
->
pArith
Expr
;
int32_t
index
=
-
1
;
int32_t
index
=
-
1
;
for
(
int32_t
i
=
0
;
i
<
pExpr
->
binExprInfo
.
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pExpr
->
binExprInfo
.
numOfCols
;
++
i
)
{
...
@@ -476,7 +486,8 @@ static void **doSetResultRowData(SSqlObj *pSql) {
...
@@ -476,7 +486,8 @@ static void **doSetResultRowData(SSqlObj *pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
//todo refactor move away
//todo refactor move away
for
(
int32_t
k
=
0
;
k
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
k
)
{
size_t
numOfExprs
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
for
(
int32_t
k
=
0
;
k
<
numOfExprs
;
++
k
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
k
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
k
);
if
(
k
>
0
)
{
if
(
k
>
0
)
{
...
@@ -487,9 +498,9 @@ static void **doSetResultRowData(SSqlObj *pSql) {
...
@@ -487,9 +498,9 @@ static void **doSetResultRowData(SSqlObj *pSql) {
int32_t
num
=
0
;
int32_t
num
=
0
;
for
(
int
i
=
0
;
i
<
tscNumOfFields
(
pQueryInfo
);
++
i
)
{
for
(
int
i
=
0
;
i
<
tscNumOfFields
(
pQueryInfo
);
++
i
)
{
if
(
pQueryInfo
->
fieldsInfo
.
pSqlExpr
[
i
]
!=
NULL
)
{
SFieldSupInfo
*
pInfo
=
tscFieldInfoGetSupp
(
&
pQueryInfo
->
fieldsInfo
,
i
);
SSqlExpr
*
pExpr
=
pQueryInfo
->
fieldsInfo
.
pSqlExpr
[
i
];
if
(
pInfo
->
pSqlExpr
!=
NULL
)
{
pRes
->
tsrow
[
i
]
=
TSC_GET_RESPTR_BASE
(
pRes
,
pQueryInfo
,
i
)
+
p
Expr
->
resBytes
*
pRes
->
row
;
pRes
->
tsrow
[
i
]
=
tscGetResultColumnChr
(
pRes
,
pQueryInfo
,
i
)
+
pInfo
->
pSql
Expr
->
resBytes
*
pRes
->
row
;
}
else
{
}
else
{
assert
(
0
);
assert
(
0
);
}
}
...
@@ -499,37 +510,37 @@ static void **doSetResultRowData(SSqlObj *pSql) {
...
@@ -499,37 +510,37 @@ static void **doSetResultRowData(SSqlObj *pSql) {
continue
;
continue
;
}
}
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
pQuery
Info
,
i
);
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fields
Info
,
i
);
transferNcharData
(
pSql
,
i
,
pField
);
transferNcharData
(
pSql
,
i
,
pField
);
// calculate the result from se
r
veral other columns
// calculate the result from several other columns
if
(
p
QueryInfo
->
fieldsInfo
.
pExpr
!=
NULL
&&
pQueryInfo
->
fieldsInfo
.
pExpr
[
i
]
!=
NULL
)
{
if
(
p
Info
->
pArithExprInfo
!=
NULL
)
{
SArithmeticSupport
*
sas
=
(
SArithmeticSupport
*
)
calloc
(
1
,
sizeof
(
SArithmeticSupport
));
SArithmeticSupport
*
sas
=
(
SArithmeticSupport
*
)
calloc
(
1
,
sizeof
(
SArithmeticSupport
));
sas
->
offset
=
0
;
sas
->
offset
=
0
;
sas
->
p
Expr
=
pQueryInfo
->
fieldsInfo
.
pExpr
[
i
]
;
sas
->
p
ArithExpr
=
pInfo
->
pArithExprInfo
;
sas
->
numOfCols
=
sas
->
pExpr
->
binExprInfo
.
numOfCols
;
sas
->
numOfCols
=
sas
->
p
Arith
Expr
->
binExprInfo
.
numOfCols
;
if
(
pRes
->
buffer
[
i
]
==
NULL
)
{
if
(
pRes
->
buffer
[
i
]
==
NULL
)
{
pRes
->
buffer
[
i
]
=
malloc
(
tscFieldInfoGetField
(
pQuery
Info
,
i
)
->
bytes
);
pRes
->
buffer
[
i
]
=
malloc
(
tscFieldInfoGetField
(
&
pQueryInfo
->
fields
Info
,
i
)
->
bytes
);
}
}
for
(
int32_t
k
=
0
;
k
<
sas
->
numOfCols
;
++
k
)
{
for
(
int32_t
k
=
0
;
k
<
sas
->
numOfCols
;
++
k
)
{
int32_t
columnIndex
=
sas
->
pExpr
->
binExprInfo
.
pReqColumns
[
k
].
colIndex
;
int32_t
columnIndex
=
sas
->
p
Arith
Expr
->
binExprInfo
.
pReqColumns
[
k
].
colIndex
;
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
columnIndex
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
columnIndex
);
sas
->
elemSize
[
k
]
=
pExpr
->
resBytes
;
sas
->
elemSize
[
k
]
=
pExpr
->
resBytes
;
sas
->
data
[
k
]
=
(
pRes
->
data
+
pRes
->
numOfRows
*
pExpr
->
offset
)
+
pRes
->
row
*
pExpr
->
resBytes
;
sas
->
data
[
k
]
=
(
pRes
->
data
+
pRes
->
numOfRows
*
pExpr
->
offset
)
+
pRes
->
row
*
pExpr
->
resBytes
;
}
}
tSQLBinaryExprCalcTraverse
(
sas
->
pExpr
->
binExprInfo
.
pBinExpr
,
1
,
pRes
->
buffer
[
i
],
sas
,
TSDB_ORDER_ASC
,
getArithemicInputSrc
);
tSQLBinaryExprCalcTraverse
(
sas
->
p
Arith
Expr
->
binExprInfo
.
pBinExpr
,
1
,
pRes
->
buffer
[
i
],
sas
,
TSDB_ORDER_ASC
,
getArithemicInputSrc
);
pRes
->
tsrow
[
i
]
=
pRes
->
buffer
[
i
];
pRes
->
tsrow
[
i
]
=
pRes
->
buffer
[
i
];
free
(
sas
);
//todo optimization
free
(
sas
);
//todo optimization
}
}
}
}
assert
(
num
<=
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
);
assert
(
num
<=
pQueryInfo
->
fieldsInfo
.
numOfOutput
);
pRes
->
row
++
;
// index increase one-step
pRes
->
row
++
;
// index increase one-step
return
pRes
->
tsrow
;
return
pRes
->
tsrow
;
...
@@ -591,11 +602,13 @@ static bool tscHashRemainDataInSubqueryResultSet(SSqlObj *pSql) {
...
@@ -591,11 +602,13 @@ static bool tscHashRemainDataInSubqueryResultSet(SSqlObj *pSql) {
static
UNUSED_FUNC
void
**
tscBuildResFromSubqueries
(
SSqlObj
*
pSql
)
{
static
UNUSED_FUNC
void
**
tscBuildResFromSubqueries
(
SSqlObj
*
pSql
)
{
SSqlRes
*
pRes
=
&
pSql
->
res
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
while
(
1
)
{
while
(
1
)
{
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
pSql
->
cmd
.
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
pSql
->
cmd
.
clauseIndex
);
size_t
numOfExprs
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
if
(
pRes
->
tsrow
==
NULL
)
{
if
(
pRes
->
tsrow
==
NULL
)
{
pRes
->
tsrow
=
calloc
(
pQueryInfo
->
exprsInfo
.
numOfExprs
,
POINTER_BYTES
);
pRes
->
tsrow
=
calloc
(
numOfExprs
,
POINTER_BYTES
);
}
}
bool
success
=
false
;
bool
success
=
false
;
...
@@ -619,7 +632,9 @@ static UNUSED_FUNC void **tscBuildResFromSubqueries(SSqlObj *pSql) {
...
@@ -619,7 +632,9 @@ static UNUSED_FUNC void **tscBuildResFromSubqueries(SSqlObj *pSql) {
}
}
if
(
success
)
{
// current row of final output has been built, return to app
if
(
success
)
{
// current row of final output has been built, return to app
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
i
)
{
size_t
numOfExprs
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
for
(
int32_t
i
=
0
;
i
<
numOfExprs
;
++
i
)
{
int32_t
tableIndex
=
pRes
->
pColumnIndex
[
i
].
tableIndex
;
int32_t
tableIndex
=
pRes
->
pColumnIndex
[
i
].
tableIndex
;
int32_t
columnIndex
=
pRes
->
pColumnIndex
[
i
].
columnIndex
;
int32_t
columnIndex
=
pRes
->
pColumnIndex
[
i
].
columnIndex
;
...
@@ -949,7 +964,7 @@ void taos_stop_query(TAOS_RES *res) {
...
@@ -949,7 +964,7 @@ void taos_stop_query(TAOS_RES *res) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
if
(
tscIsTwoStageSTableQuery
(
pQueryInfo
,
0
))
{
if
(
tscIsTwoStageSTableQuery
(
pQueryInfo
,
0
))
{
tscKill
Metric
Query
(
pSql
);
tscKill
STable
Query
(
pSql
);
return
;
return
;
}
}
...
@@ -1126,7 +1141,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
...
@@ -1126,7 +1141,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
return
code
;
return
code
;
}
}
if
((
code
=
setMeterID
(
pTableMetaInfo
,
&
sToken
,
pSql
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
tscSetTableId
(
pTableMetaInfo
,
&
sToken
,
pSql
))
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
...
...
src/client/src/tscStream.c
浏览文件 @
6dbca070
...
@@ -36,7 +36,7 @@ static int64_t getDelayValueAfterTimewindowClosed(SSqlStream* pStream, int64_t l
...
@@ -36,7 +36,7 @@ static int64_t getDelayValueAfterTimewindowClosed(SSqlStream* pStream, int64_t l
}
}
static
bool
isProjectStream
(
SQueryInfo
*
pQueryInfo
)
{
static
bool
isProjectStream
(
SQueryInfo
*
pQueryInfo
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
if
(
pExpr
->
functionId
!=
TSDB_FUNC_PRJ
)
{
if
(
pExpr
->
functionId
!=
TSDB_FUNC_PRJ
)
{
return
false
;
return
false
;
...
@@ -86,7 +86,7 @@ static void tscProcessStreamLaunchQuery(SSchedMsg *pMsg) {
...
@@ -86,7 +86,7 @@ static void tscProcessStreamLaunchQuery(SSchedMsg *pMsg) {
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
return
;
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
return
;
}
}
tscTansformSQLFunc
tion
ForSTableQuery
(
pQueryInfo
);
tscTansformSQLFuncForSTableQuery
(
pQueryInfo
);
// failed to get meter/metric meta, retry in 10sec.
// failed to get meter/metric meta, retry in 10sec.
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -116,18 +116,18 @@ static void tscProcessStreamTimer(void *handle, void *tmrId) {
...
@@ -116,18 +116,18 @@ static void tscProcessStreamTimer(void *handle, void *tmrId) {
if
(
isProjectStream
(
pQueryInfo
))
{
if
(
isProjectStream
(
pQueryInfo
))
{
/*
/*
* pQueryInfo->
etime
, which is the start time, does not change in case of
* pQueryInfo->
window.ekey
, which is the start time, does not change in case of
* repeat first execution, once the first execution failed.
* repeat first execution, once the first execution failed.
*/
*/
pQueryInfo
->
stime
=
pStream
->
stime
;
// start time
pQueryInfo
->
window
.
skey
=
pStream
->
stime
;
// start time
pQueryInfo
->
etime
=
taosGetTimestamp
(
pStream
->
precision
);
// end time
pQueryInfo
->
window
.
ekey
=
taosGetTimestamp
(
pStream
->
precision
);
// end time
if
(
pQueryInfo
->
etime
>
pStream
->
etime
)
{
if
(
pQueryInfo
->
window
.
ekey
>
pStream
->
etime
)
{
pQueryInfo
->
etime
=
pStream
->
etime
;
pQueryInfo
->
window
.
ekey
=
pStream
->
etime
;
}
}
}
else
{
}
else
{
pQueryInfo
->
stime
=
pStream
->
stime
-
pStream
->
interval
;
pQueryInfo
->
window
.
skey
=
pStream
->
stime
-
pStream
->
interval
;
pQueryInfo
->
etime
=
pStream
->
stime
-
1
;
pQueryInfo
->
window
.
ekey
=
pStream
->
stime
-
1
;
}
}
// launch stream computing in a new thread
// launch stream computing in a new thread
...
@@ -219,9 +219,9 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
...
@@ -219,9 +219,9 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
void
*
oldPtr
=
pSql
->
res
.
data
;
void
*
oldPtr
=
pSql
->
res
.
data
;
pSql
->
res
.
data
=
tmpRes
;
pSql
->
res
.
data
=
tmpRes
;
for
(
int32_t
i
=
1
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
;
++
i
)
{
for
(
int32_t
i
=
1
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
i
)
{
int16_t
offset
=
tscFieldInfoGetOffset
(
pQueryInfo
,
i
);
int16_t
offset
=
tscFieldInfoGetOffset
(
pQueryInfo
,
i
);
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
pQuery
Info
,
i
);
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fields
Info
,
i
);
assignVal
(
pSql
->
res
.
data
+
offset
,
(
char
*
)(
&
pQueryInfo
->
defaultVal
[
i
]),
pField
->
bytes
,
pField
->
type
);
assignVal
(
pSql
->
res
.
data
+
offset
,
(
char
*
)(
&
pQueryInfo
->
defaultVal
[
i
]),
pField
->
bytes
,
pField
->
type
);
row
[
i
]
=
pSql
->
res
.
data
+
offset
;
row
[
i
]
=
pSql
->
res
.
data
+
offset
;
...
@@ -231,7 +231,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
...
@@ -231,7 +231,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
row
[
0
]
=
pRes
->
data
;
row
[
0
]
=
pRes
->
data
;
// char result[512] = {0};
// char result[512] = {0};
// taos_print_row(result, row, pQueryInfo->fieldsInfo.pFields, pQueryInfo->fieldsInfo.numOfOutput
Cols
);
// taos_print_row(result, row, pQueryInfo->fieldsInfo.pFields, pQueryInfo->fieldsInfo.numOfOutput);
// tscPrint("%p stream:%p query result: %s", pSql, pStream, result);
// tscPrint("%p stream:%p query result: %s", pSql, pStream, result);
tscTrace
(
"%p stream:%p fetch result"
,
pSql
,
pStream
);
tscTrace
(
"%p stream:%p fetch result"
,
pSql
,
pStream
);
...
@@ -425,10 +425,10 @@ static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, in
...
@@ -425,10 +425,10 @@ static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, in
pStream
->
slidingTime
=
tsProjectExecInterval
;
pStream
->
slidingTime
=
tsProjectExecInterval
;
if
(
stime
!=
0
)
{
// first projection start from the latest event timestamp
if
(
stime
!=
0
)
{
// first projection start from the latest event timestamp
assert
(
stime
>=
pQueryInfo
->
stime
);
assert
(
stime
>=
pQueryInfo
->
window
.
skey
);
stime
+=
1
;
// exclude the last records from table
stime
+=
1
;
// exclude the last records from table
}
else
{
}
else
{
stime
=
pQueryInfo
->
stime
;
stime
=
pQueryInfo
->
window
.
skey
;
}
}
}
else
{
// timewindow based aggregation stream
}
else
{
// timewindow based aggregation stream
if
(
stime
==
0
)
{
// no data in meter till now
if
(
stime
==
0
)
{
// no data in meter till now
...
@@ -548,7 +548,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
...
@@ -548,7 +548,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
pStream
->
precision
=
tinfo
.
precision
;
pStream
->
precision
=
tinfo
.
precision
;
pStream
->
ctime
=
taosGetTimestamp
(
pStream
->
precision
);
pStream
->
ctime
=
taosGetTimestamp
(
pStream
->
precision
);
pStream
->
etime
=
pQueryInfo
->
etime
;
pStream
->
etime
=
pQueryInfo
->
window
.
ekey
;
pSql
->
pStream
=
pStream
;
pSql
->
pStream
=
pStream
;
tscAddIntoStreamList
(
pStream
);
tscAddIntoStreamList
(
pStream
);
...
...
src/client/src/tscSubquery.c
浏览文件 @
6dbca070
...
@@ -190,10 +190,10 @@ void tscDestroyJoinSupporter(SJoinSubquerySupporter* pSupporter) {
...
@@ -190,10 +190,10 @@ void tscDestroyJoinSupporter(SJoinSubquerySupporter* pSupporter) {
return
;
return
;
}
}
tscSqlExprInfoDestroy
(
&
pSupporter
->
exprsInfo
);
tscSqlExprInfoDestroy
(
pSupporter
->
exprsInfo
);
tscColumn
BaseInfoDestroy
(
&
pSupporter
->
colList
);
tscColumn
ListDestroy
(
pSupporter
->
colList
);
tsc
ClearFieldInfo
(
&
pSupporter
->
fieldsInfo
);
tsc
FieldInfoClear
(
&
pSupporter
->
fieldsInfo
);
if
(
pSupporter
->
f
!=
NULL
)
{
if
(
pSupporter
->
f
!=
NULL
)
{
fclose
(
pSupporter
->
f
);
fclose
(
pSupporter
->
f
);
...
@@ -211,8 +211,10 @@ void tscDestroyJoinSupporter(SJoinSubquerySupporter* pSupporter) {
...
@@ -211,8 +211,10 @@ void tscDestroyJoinSupporter(SJoinSubquerySupporter* pSupporter) {
*
*
*/
*/
bool
needSecondaryQuery
(
SQueryInfo
*
pQueryInfo
)
{
bool
needSecondaryQuery
(
SQueryInfo
*
pQueryInfo
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
colList
.
numOfCols
;
++
i
)
{
size_t
numOfCols
=
taosArrayGetSize
(
pQueryInfo
->
colList
);
SColumnBase
*
pBase
=
tscColumnBaseInfoGet
(
&
pQueryInfo
->
colList
,
i
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumn
*
pBase
=
taosArrayGet
(
pQueryInfo
->
colList
,
i
);
if
(
pBase
->
colIndex
.
columnIndex
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
if
(
pBase
->
colIndex
.
columnIndex
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
return
true
;
return
true
;
}
}
...
@@ -236,7 +238,7 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
...
@@ -236,7 +238,7 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
for
(
int32_t
i
=
0
;
i
<
pSql
->
numOfSubs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pSql
->
numOfSubs
;
++
i
)
{
pSupporter
=
pSql
->
pSubs
[
i
]
->
param
;
pSupporter
=
pSql
->
pSubs
[
i
]
->
param
;
if
(
pSupporter
->
exprsInfo
.
numOfExprs
>
0
)
{
if
(
taosArrayGetSize
(
pSupporter
->
exprsInfo
)
>
0
)
{
++
numOfSub
;
++
numOfSub
;
}
}
}
}
...
@@ -262,7 +264,7 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
...
@@ -262,7 +264,7 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
pSupporter
=
pPrevSub
->
param
;
pSupporter
=
pPrevSub
->
param
;
if
(
pSupporter
->
exprsInfo
.
numOfExprs
==
0
)
{
if
(
taosArrayGetSize
(
pSupporter
->
exprsInfo
)
==
0
)
{
tscTrace
(
"%p subIndex: %d, not need to launch query, ignore it"
,
pSql
,
i
);
tscTrace
(
"%p subIndex: %d, not need to launch query, ignore it"
,
pSql
,
i
);
tscDestroyJoinSupporter
(
pSupporter
);
tscDestroyJoinSupporter
(
pSupporter
);
...
@@ -277,7 +279,7 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
...
@@ -277,7 +279,7 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
pSubQueryInfo
->
tsBuf
=
NULL
;
pSubQueryInfo
->
tsBuf
=
NULL
;
// free result for async object will also free sqlObj
// free result for async object will also free sqlObj
assert
(
pSubQueryInfo
->
exprsInfo
.
numOfExprs
==
1
);
// ts_comp query only requires one resutl columns
assert
(
tscSqlExprNumOfExprs
(
pSubQueryInfo
)
==
1
);
// ts_comp query only requires one resutl columns
taos_free_result
(
pPrevSub
);
taos_free_result
(
pPrevSub
);
SSqlObj
*
pNew
=
createSubqueryObj
(
pSql
,
(
int16_t
)
i
,
tscJoinQueryCallback
,
pSupporter
,
TSDB_SQL_SELECT
,
NULL
);
SSqlObj
*
pNew
=
createSubqueryObj
(
pSql
,
(
int16_t
)
i
,
tscJoinQueryCallback
,
pSupporter
,
TSDB_SQL_SELECT
,
NULL
);
...
@@ -299,27 +301,27 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
...
@@ -299,27 +301,27 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
pQueryInfo
->
intervalTime
=
pSupporter
->
interval
;
pQueryInfo
->
intervalTime
=
pSupporter
->
interval
;
pQueryInfo
->
groupbyExpr
=
pSupporter
->
groupbyExpr
;
pQueryInfo
->
groupbyExpr
=
pSupporter
->
groupbyExpr
;
tscColumn
BaseInfoCopy
(
&
pQueryInfo
->
colList
,
&
pSupporter
->
colList
,
0
);
tscColumn
ListCopy
(
pQueryInfo
->
colList
,
pSupporter
->
colList
,
0
);
tscTagCondCopy
(
&
pQueryInfo
->
tagCond
,
&
pSupporter
->
tagCond
);
tscTagCondCopy
(
&
pQueryInfo
->
tagCond
,
&
pSupporter
->
tagCond
);
tscSqlExprCopy
(
&
pQueryInfo
->
exprsInfo
,
&
pSupporter
->
exprsInfo
,
pSupporter
->
uid
,
false
);
pQueryInfo
->
exprsInfo
=
tscSqlExprCopy
(
pSupporter
->
exprsInfo
,
pSupporter
->
uid
,
false
);
tscFieldInfoCopy
All
(
&
pQueryInfo
->
fieldsInfo
,
&
pSupporter
->
fieldsInfo
);
tscFieldInfoCopy
(
&
pQueryInfo
->
fieldsInfo
,
&
pSupporter
->
fieldsInfo
);
pSupporter
->
exprsInfo
.
numOfExprs
=
0
;
pSupporter
->
fieldsInfo
.
numOfOutput
=
0
;
pSupporter
->
fieldsInfo
.
numOfOutputCols
=
0
;
/*
/*
* if the first column of the secondary query is not ts function, add this function.
* 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.
* Because this column is required to filter with timestamp after intersecting.
*/
*/
if
(
pSupporter
->
exprsInfo
.
pExprs
[
0
]
->
functionId
!=
TSDB_FUNC_TS
)
{
SSqlExpr
*
pExpr
=
taosArrayGet
(
pSupporter
->
exprsInfo
,
0
);
if
(
pExpr
->
functionId
!=
TSDB_FUNC_TS
)
{
tscAddTimestampColumn
(
pQueryInfo
,
TSDB_FUNC_TS
,
0
);
tscAddTimestampColumn
(
pQueryInfo
,
TSDB_FUNC_TS
,
0
);
}
}
SQueryInfo
*
pNewQueryInfo
=
tscGetQueryInfoDetail
(
&
pNew
->
cmd
,
0
);
SQueryInfo
*
pNewQueryInfo
=
tscGetQueryInfoDetail
(
&
pNew
->
cmd
,
0
);
assert
(
pNew
->
numOfSubs
==
0
&&
pNew
->
cmd
.
numOfClause
==
1
&&
pNewQueryInfo
->
numOfTables
==
1
);
assert
(
pNew
->
numOfSubs
==
0
&&
pNew
->
cmd
.
numOfClause
==
1
&&
pNewQueryInfo
->
numOfTables
==
1
);
tscFieldInfo
Cal
Offset
(
pNewQueryInfo
);
tscFieldInfo
Update
Offset
(
pNewQueryInfo
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pNewQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pNewQueryInfo
,
0
);
...
@@ -342,10 +344,11 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
...
@@ -342,10 +344,11 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
tscPrintSelectClause
(
pNew
,
0
);
tscPrintSelectClause
(
pNew
,
0
);
size_t
numOfCols
=
taosArrayGetSize
(
pNewQueryInfo
->
colList
);
tscTrace
(
"%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%d, colList:%d, fieldsInfo:%d, name:%s"
,
tscTrace
(
"%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%d, colList:%d, fieldsInfo:%d, name:%s"
,
pSql
,
pNew
,
0
,
pTableMetaInfo
->
vgroupIndex
,
pNewQueryInfo
->
type
,
pSql
,
pNew
,
0
,
pTableMetaInfo
->
vgroupIndex
,
pNewQueryInfo
->
type
,
pNewQueryInfo
->
exprsInfo
.
numOfExprs
,
pNewQueryInfo
->
colList
.
numOfCols
,
taosArrayGetSize
(
pNewQueryInfo
->
exprsInfo
),
numOfCols
,
pNewQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
,
pNewQueryInfo
->
pTableMetaInfo
[
0
]
->
name
);
pNewQueryInfo
->
fieldsInfo
.
numOfOutput
,
pNewQueryInfo
->
pTableMetaInfo
[
0
]
->
name
);
}
}
//prepare the subqueries object failed, abort
//prepare the subqueries object failed, abort
...
@@ -413,10 +416,10 @@ static void quitAllSubquery(SSqlObj* pSqlObj, SJoinSubquerySupporter* pSupporter
...
@@ -413,10 +416,10 @@ static void quitAllSubquery(SSqlObj* pSqlObj, SJoinSubquerySupporter* pSupporter
// update the query time range according to the join results on timestamp
// update the query time range according to the join results on timestamp
static
void
updateQueryTimeRange
(
SQueryInfo
*
pQueryInfo
,
int64_t
st
,
int64_t
et
)
{
static
void
updateQueryTimeRange
(
SQueryInfo
*
pQueryInfo
,
int64_t
st
,
int64_t
et
)
{
assert
(
pQueryInfo
->
stime
<=
st
&&
pQueryInfo
->
etime
>=
et
);
assert
(
pQueryInfo
->
window
.
skey
<=
st
&&
pQueryInfo
->
window
.
ekey
>=
et
);
pQueryInfo
->
stime
=
st
;
pQueryInfo
->
window
.
skey
=
st
;
pQueryInfo
->
etime
=
et
;
pQueryInfo
->
window
.
ekey
=
et
;
}
}
static
void
joinRetrieveCallback
(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
)
{
static
void
joinRetrieveCallback
(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
)
{
...
@@ -688,9 +691,9 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
...
@@ -688,9 +691,9 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
}
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
pRes
->
pColumnIndex
=
calloc
(
1
,
sizeof
(
SColumnIndex
)
*
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
);
pRes
->
pColumnIndex
=
calloc
(
1
,
sizeof
(
SColumnIndex
)
*
pQueryInfo
->
fieldsInfo
.
numOfOutput
);
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
int32_t
tableIndexOfSub
=
-
1
;
int32_t
tableIndexOfSub
=
-
1
;
...
@@ -707,7 +710,8 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
...
@@ -707,7 +710,8 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
SSqlCmd
*
pSubCmd
=
&
pSql
->
pSubs
[
tableIndexOfSub
]
->
cmd
;
SSqlCmd
*
pSubCmd
=
&
pSql
->
pSubs
[
tableIndexOfSub
]
->
cmd
;
SQueryInfo
*
pSubQueryInfo
=
tscGetQueryInfoDetail
(
pSubCmd
,
0
);
SQueryInfo
*
pSubQueryInfo
=
tscGetQueryInfoDetail
(
pSubCmd
,
0
);
for
(
int32_t
k
=
0
;
k
<
pSubQueryInfo
->
exprsInfo
.
numOfExprs
;
++
k
)
{
size_t
numOfExprs
=
taosArrayGetSize
(
pSubQueryInfo
->
exprsInfo
);
for
(
int32_t
k
=
0
;
k
<
numOfExprs
;
++
k
)
{
SSqlExpr
*
pSubExpr
=
tscSqlExprGet
(
pSubQueryInfo
,
k
);
SSqlExpr
*
pSubExpr
=
tscSqlExprGet
(
pSubQueryInfo
,
k
);
if
(
pExpr
->
functionId
==
pSubExpr
->
functionId
&&
pExpr
->
colInfo
.
colId
==
pSubExpr
->
colInfo
.
colId
)
{
if
(
pExpr
->
functionId
==
pSubExpr
->
functionId
&&
pExpr
->
colInfo
.
colId
==
pSubExpr
->
colInfo
.
colId
)
{
pRes
->
pColumnIndex
[
i
]
=
(
SColumnIndex
){.
tableIndex
=
tableIndexOfSub
,
.
columnIndex
=
k
};
pRes
->
pColumnIndex
[
i
]
=
(
SColumnIndex
){.
tableIndex
=
tableIndexOfSub
,
.
columnIndex
=
k
};
...
@@ -723,11 +727,6 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) {
...
@@ -723,11 +727,6 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) {
// int32_t idx = pSql->cmd.vnodeIdx;
// int32_t idx = pSql->cmd.vnodeIdx;
// SVnodeSidList *vnodeInfo = NULL;
// if (pTableMetaInfo->pMetricMeta != NULL) {
// vnodeInfo = tscGetVnodeSidList(pTableMetaInfo->pMetricMeta, idx - 1);
// }
SJoinSubquerySupporter
*
pSupporter
=
(
SJoinSubquerySupporter
*
)
param
;
SJoinSubquerySupporter
*
pSupporter
=
(
SJoinSubquerySupporter
*
)
param
;
// if (atomic_add_fetch_32(pSupporter->numOfComplete, 1) >=
// if (atomic_add_fetch_32(pSupporter->numOfComplete, 1) >=
...
@@ -850,11 +849,17 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSubquerySu
...
@@ -850,11 +849,17 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSubquerySu
SQueryInfo
*
pNewQueryInfo
=
tscGetQueryInfoDetail
(
&
pNew
->
cmd
,
0
);
SQueryInfo
*
pNewQueryInfo
=
tscGetQueryInfoDetail
(
&
pNew
->
cmd
,
0
);
assert
(
pNewQueryInfo
!=
NULL
);
assert
(
pNewQueryInfo
!=
NULL
);
tscColumnBaseInfoUpdateTableIndex
(
&
pNewQueryInfo
->
colList
,
0
);
// update the table index
tscColumnBaseInfoCopy
(
&
pSupporter
->
colList
,
&
pNewQueryInfo
->
colList
,
0
);
size_t
num
=
taosArrayGetSize
(
pNewQueryInfo
->
colList
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SColumn
*
pCol
=
taosArrayGetP
(
pNewQueryInfo
->
colList
,
i
);
pCol
->
colIndex
.
tableIndex
=
0
;
}
tscSqlExprCopy
(
&
pSupporter
->
exprsInfo
,
&
pNewQueryInfo
->
exprsInfo
,
pSupporter
->
uid
,
false
);
tscColumnListCopy
(
pSupporter
->
colList
,
pNewQueryInfo
->
colList
,
0
);
tscFieldInfoCopyAll
(
&
pSupporter
->
fieldsInfo
,
&
pNewQueryInfo
->
fieldsInfo
);
pSupporter
->
exprsInfo
=
tscSqlExprCopy
(
pNewQueryInfo
->
exprsInfo
,
pSupporter
->
uid
,
false
);
tscFieldInfoCopy
(
&
pSupporter
->
fieldsInfo
,
&
pNewQueryInfo
->
fieldsInfo
);
tscTagCondCopy
(
&
pSupporter
->
tagCond
,
&
pNewQueryInfo
->
tagCond
);
tscTagCondCopy
(
&
pSupporter
->
tagCond
,
&
pNewQueryInfo
->
tagCond
);
...
@@ -867,8 +872,7 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSubquerySu
...
@@ -867,8 +872,7 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSubquerySu
memset
(
&
pNewQueryInfo
->
groupbyExpr
,
0
,
sizeof
(
SSqlGroupbyExpr
));
memset
(
&
pNewQueryInfo
->
groupbyExpr
,
0
,
sizeof
(
SSqlGroupbyExpr
));
// this data needs to be transfer to support struct
// this data needs to be transfer to support struct
pNewQueryInfo
->
fieldsInfo
.
numOfOutputCols
=
0
;
pNewQueryInfo
->
fieldsInfo
.
numOfOutput
=
0
;
pNewQueryInfo
->
exprsInfo
.
numOfExprs
=
0
;
// set the ts,tags that involved in join, as the output column of intermediate result
// set the ts,tags that involved in join, as the output column of intermediate result
tscClearSubqueryInfo
(
&
pNew
->
cmd
);
tscClearSubqueryInfo
(
&
pNew
->
cmd
);
...
@@ -888,27 +892,26 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSubquerySu
...
@@ -888,27 +892,26 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSubquerySu
pExpr
->
numOfParams
=
1
;
pExpr
->
numOfParams
=
1
;
// add the filter tag column
// add the filter tag column
for
(
int32_t
i
=
0
;
i
<
pSupporter
->
colList
.
numOfCols
;
++
i
)
{
size_t
s
=
taosArrayGetSize
(
pSupporter
->
colList
);
SColumnBase
*
pColBase
=
&
pSupporter
->
colList
.
pColList
[
i
];
if
(
pColBase
->
numOfFilters
>
0
)
{
// copy to the pNew->cmd.colList if it is filtered.
for
(
int32_t
i
=
0
;
i
<
s
;
++
i
)
{
tscColumnBaseCopy
(
&
pNewQueryInfo
->
colList
.
pColList
[
pNewQueryInfo
->
colList
.
numOfCols
],
pColBase
);
SColumn
*
pCol
=
taosArrayGetP
(
pSupporter
->
colList
,
i
);
pNewQueryInfo
->
colList
.
numOfCols
++
;
if
(
pCol
->
numOfFilters
>
0
)
{
// copy to the pNew->cmd.colList if it is filtered.
SColumn
*
p
=
tscColumnClone
(
pCol
);
taosArrayPush
(
pNewQueryInfo
->
colList
,
&
p
);
}
}
}
}
tscTrace
(
"%p subquery:%p tableIndex:%d, vnodeIdx:%d, type:%d, transfer to ts_comp query to retrieve timestamps, "
size_t
numOfCols
=
taosArrayGetSize
(
pNewQueryInfo
->
colList
);
"exprInfo:%d, colList:%d, fieldsInfo:%d, name:%s"
,
pSql
,
pNew
,
tableIndex
,
pTableMetaInfo
->
vgroupIndex
,
pNewQueryInfo
->
type
,
pNewQueryInfo
->
exprsInfo
.
numOfExprs
,
pNewQueryInfo
->
colList
.
numOfCols
,
pNewQueryInfo
->
fieldsInfo
.
numOfOutputCols
,
pNewQueryInfo
->
pTableMetaInfo
[
0
]
->
name
);
tscPrintSelectClause
(
pNew
,
0
);
tscTrace
(
"%p subquery:%p tableIndex:%d, vnodeIdx:%d, type:%d, transfer to ts_comp query to retrieve timestamps, "
tscTrace
(
"%p subquery:%p tableIndex:%d, vnodeIdx:%d, type:%d, transfer to ts_comp query to retrieve timestamps, "
"exprInfo:%d, colList:%d, fieldsInfo:%d, name:%s"
,
"exprInfo:%d, colList:%d, fieldsInfo:%d, name:%s"
,
pSql
,
pNew
,
tableIndex
,
pTableMetaInfo
->
vgroupIndex
,
pNewQueryInfo
->
type
,
pSql
,
pNew
,
tableIndex
,
pTableMetaInfo
->
vgroupIndex
,
pNewQueryInfo
->
type
,
pNewQueryInfo
->
exprsInfo
.
numOfExprs
,
pNewQueryInfo
->
colList
.
numOfCols
,
tscSqlExprNumOfExprs
(
pNewQueryInfo
),
numOfCols
,
pNewQueryInfo
->
fieldsInfo
.
numOfOutput
Cols
,
pNewQueryInfo
->
pTableMetaInfo
[
0
]
->
name
);
pNewQueryInfo
->
fieldsInfo
.
numOfOutput
,
pNewQueryInfo
->
pTableMetaInfo
[
0
]
->
name
);
tscPrintSelectClause
(
pNew
,
0
);
tscPrintSelectClause
(
pNew
,
0
);
}
else
{
}
else
{
SQueryInfo
*
pNewQueryInfo
=
tscGetQueryInfoDetail
(
&
pNew
->
cmd
,
0
);
SQueryInfo
*
pNewQueryInfo
=
tscGetQueryInfoDetail
(
&
pNew
->
cmd
,
0
);
pNewQueryInfo
->
type
|=
TSDB_QUERY_TYPE_SUBQUERY
;
pNewQueryInfo
->
type
|=
TSDB_QUERY_TYPE_SUBQUERY
;
...
@@ -1352,7 +1355,7 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
...
@@ -1352,7 +1355,7 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
}
}
#ifdef _DEBUG_VIEW
#ifdef _DEBUG_VIEW
printf
(
"received data from vnode: %
d
rows
\n
"
,
pRes
->
numOfRows
);
printf
(
"received data from vnode: %
"
PRIu64
"
rows
\n
"
,
pRes
->
numOfRows
);
SSrcColumnInfo
colInfo
[
256
]
=
{
0
};
SSrcColumnInfo
colInfo
[
256
]
=
{
0
};
tscGetSrcColumnInfo
(
colInfo
,
pQueryInfo
);
tscGetSrcColumnInfo
(
colInfo
,
pQueryInfo
);
...
...
src/client/src/tscUtil.c
浏览文件 @
6dbca070
此差异已折叠。
点击以展开。
src/inc/taos.h
浏览文件 @
6dbca070
...
@@ -29,6 +29,19 @@ typedef void TAOS_SUB;
...
@@ -29,6 +29,19 @@ typedef void TAOS_SUB;
typedef
void
TAOS_STREAM
;
typedef
void
TAOS_STREAM
;
typedef
void
TAOS_STMT
;
typedef
void
TAOS_STMT
;
// Data type definition
#define TSDB_DATA_TYPE_NULL 0 // 1 bytes
#define TSDB_DATA_TYPE_BOOL 1 // 1 bytes
#define TSDB_DATA_TYPE_TINYINT 2 // 1 byte
#define TSDB_DATA_TYPE_SMALLINT 3 // 2 bytes
#define TSDB_DATA_TYPE_INT 4 // 4 bytes
#define TSDB_DATA_TYPE_BIGINT 5 // 8 bytes
#define TSDB_DATA_TYPE_FLOAT 6 // 4 bytes
#define TSDB_DATA_TYPE_DOUBLE 7 // 8 bytes
#define TSDB_DATA_TYPE_BINARY 8 // string
#define TSDB_DATA_TYPE_TIMESTAMP 9 // 8 bytes
#define TSDB_DATA_TYPE_NCHAR 10 // unicode string
typedef
enum
{
typedef
enum
{
TSDB_OPTION_LOCALE
,
TSDB_OPTION_LOCALE
,
TSDB_OPTION_CHARSET
,
TSDB_OPTION_CHARSET
,
...
...
src/inc/taosdef.h
浏览文件 @
6dbca070
...
@@ -22,6 +22,7 @@ extern "C" {
...
@@ -22,6 +22,7 @@ extern "C" {
#include <stdint.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdbool.h>
#include "taos.h"
#define TSDB__packed
#define TSDB__packed
...
@@ -31,19 +32,6 @@ extern "C" {
...
@@ -31,19 +32,6 @@ extern "C" {
#define TSKEY int64_t
#define TSKEY int64_t
#endif
#endif
// Data type definition
#define TSDB_DATA_TYPE_NULL 0 // 1 bytes
#define TSDB_DATA_TYPE_BOOL 1 // 1 bytes
#define TSDB_DATA_TYPE_TINYINT 2 // 1 byte
#define TSDB_DATA_TYPE_SMALLINT 3 // 2 bytes
#define TSDB_DATA_TYPE_INT 4 // 4 bytes
#define TSDB_DATA_TYPE_BIGINT 5 // 8 bytes
#define TSDB_DATA_TYPE_FLOAT 6 // 4 bytes
#define TSDB_DATA_TYPE_DOUBLE 7 // 8 bytes
#define TSDB_DATA_TYPE_BINARY 8 // string
#define TSDB_DATA_TYPE_TIMESTAMP 9 // 8 bytes
#define TSDB_DATA_TYPE_NCHAR 10 // unicode string
// Bytes for each type.
// Bytes for each type.
extern
const
int32_t
TYPE_BYTES
[
11
];
extern
const
int32_t
TYPE_BYTES
[
11
];
// TODO: replace and remove code below
// TODO: replace and remove code below
...
...
src/inc/taosmsg.h
浏览文件 @
6dbca070
...
@@ -372,7 +372,7 @@ typedef struct SColIndex {
...
@@ -372,7 +372,7 @@ typedef struct SColIndex {
/* sql function msg, to describe the message to vnode about sql function
/* sql function msg, to describe the message to vnode about sql function
* operations in select clause */
* operations in select clause */
typedef
struct
SSqlFunc
Expr
Msg
{
typedef
struct
SSqlFuncMsg
{
int16_t
functionId
;
int16_t
functionId
;
int16_t
numOfParams
;
int16_t
numOfParams
;
...
@@ -386,26 +386,26 @@ typedef struct SSqlFuncExprMsg {
...
@@ -386,26 +386,26 @@ typedef struct SSqlFuncExprMsg {
char
*
pz
;
char
*
pz
;
}
argValue
;
}
argValue
;
}
arg
[
3
];
}
arg
[
3
];
}
SSqlFunc
Expr
Msg
;
}
SSqlFuncMsg
;
typedef
struct
S
SqlBinary
ExprInfo
{
typedef
struct
SExprInfo
{
struct
tExprNode
*
pBinExpr
;
/* for binary expression */
struct
tExprNode
*
pBinExpr
;
/* for binary expression */
int32_t
numOfCols
;
/* binary expression involves the readed number of columns*/
int32_t
numOfCols
;
/* binary expression involves the readed number of columns*/
SColIndex
*
pReqColumns
;
/* source column list */
SColIndex
*
pReqColumns
;
/* source column list */
}
S
SqlBinary
ExprInfo
;
}
SExprInfo
;
typedef
struct
S
SqlFunctionExpr
{
typedef
struct
S
ArithExprInfo
{
SSqlFunc
ExprMsg
pBase
;
SSqlFunc
Msg
pBase
;
S
SqlBinaryExprInfo
binExprInfo
;
S
ExprInfo
binExprInfo
;
int16_t
resB
ytes
;
int16_t
b
ytes
;
int16_t
resT
ype
;
int16_t
t
ype
;
int16_t
interResBytes
;
int16_t
interResBytes
;
}
S
SqlFunctionExpr
;
}
S
ArithExprInfo
;
typedef
struct
SColumnFilterInfo
{
typedef
struct
SColumnFilterInfo
{
int16_t
lowerRelOptr
;
int16_t
lowerRelOptr
;
int16_t
upperRelOptr
;
int16_t
upperRelOptr
;
int16_t
filter
OnBinary
;
/* denote if current column is binary */
int16_t
filter
str
;
// denote if current column is char(binary/nchar)
union
{
union
{
struct
{
struct
{
...
@@ -469,7 +469,7 @@ typedef struct {
...
@@ -469,7 +469,7 @@ typedef struct {
int64_t
limit
;
int64_t
limit
;
int64_t
offset
;
int64_t
offset
;
uint16_t
queryType
;
// denote another query process
uint16_t
queryType
;
// denote another query process
int16_t
numOfOutput
Cols
;
// final output columns numbers
int16_t
numOfOutput
;
// final output columns numbers
int16_t
interpoType
;
// interpolate type
int16_t
interpoType
;
// interpolate type
uint64_t
defaultVal
;
// default value array list
uint64_t
defaultVal
;
// default value array list
...
...
src/inc/tsdb.h
浏览文件 @
6dbca070
...
@@ -146,7 +146,7 @@ typedef struct STsdbQueryCond {
...
@@ -146,7 +146,7 @@ typedef struct STsdbQueryCond {
STimeWindow
twindow
;
STimeWindow
twindow
;
int32_t
order
;
// desc/asc order to iterate the data block
int32_t
order
;
// desc/asc order to iterate the data block
int32_t
numOfCols
;
int32_t
numOfCols
;
SColumnInfo
Data
*
colList
;
SColumnInfo
*
colList
;
}
STsdbQueryCond
;
}
STsdbQueryCond
;
typedef
struct
SBlockInfo
{
typedef
struct
SBlockInfo
{
...
...
src/kit/CMakeLists.txt
浏览文件 @
6dbca070
...
@@ -2,5 +2,5 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
...
@@ -2,5 +2,5 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT
(
TDengine
)
PROJECT
(
TDengine
)
ADD_SUBDIRECTORY
(
shell
)
ADD_SUBDIRECTORY
(
shell
)
#
ADD_SUBDIRECTORY(taosdemo)
ADD_SUBDIRECTORY
(
taosdemo
)
#
ADD_SUBDIRECTORY(taosdump)
ADD_SUBDIRECTORY
(
taosdump
)
src/kit/taosdump/CMakeLists.txt
浏览文件 @
6dbca070
...
@@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
...
@@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT
(
TDengine
)
PROJECT
(
TDengine
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/common/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/client/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/client/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/util/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/util/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/query/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/query/inc
)
...
...
src/kit/taosdump/taosdump.c
浏览文件 @
6dbca070
...
@@ -30,7 +30,6 @@
...
@@ -30,7 +30,6 @@
#include "taos.h"
#include "taos.h"
#include "taosmsg.h"
#include "taosmsg.h"
#include "tglobal.h"
#include "tsclient.h"
#include "tsclient.h"
#include "taosdef.h"
#include "taosdef.h"
#include "tutil.h"
#include "tutil.h"
...
@@ -360,7 +359,7 @@ int main(int argc, char *argv[]) {
...
@@ -360,7 +359,7 @@ int main(int argc, char *argv[]) {
void
taosFreeDbInfos
()
{
void
taosFreeDbInfos
()
{
if
(
dbInfos
==
NULL
)
return
;
if
(
dbInfos
==
NULL
)
return
;
for
(
int
i
=
0
;
i
<
tsMaxDbs
;
i
++
)
tfree
(
dbInfos
[
i
]);
for
(
int
i
=
0
;
i
<
TSDB_MAX_DBS
;
i
++
)
tfree
(
dbInfos
[
i
]);
tfree
(
dbInfos
);
tfree
(
dbInfos
);
}
}
...
@@ -440,7 +439,7 @@ int taosDumpOut(struct arguments *arguments) {
...
@@ -440,7 +439,7 @@ int taosDumpOut(struct arguments *arguments) {
return
-
1
;
return
-
1
;
}
}
dbInfos
=
(
SDbInfo
**
)
calloc
(
tsMaxDbs
,
sizeof
(
SDbInfo
*
));
dbInfos
=
(
SDbInfo
**
)
calloc
(
TSDB_MAX_DBS
,
sizeof
(
SDbInfo
*
));
if
(
dbInfos
==
NULL
)
{
if
(
dbInfos
==
NULL
)
{
fprintf
(
stderr
,
"failed to allocate memory
\n
"
);
fprintf
(
stderr
,
"failed to allocate memory
\n
"
);
goto
_exit_failure
;
goto
_exit_failure
;
...
@@ -1330,4 +1329,4 @@ _exit_no_charset:
...
@@ -1330,4 +1329,4 @@ _exit_no_charset:
*
fcharset
=
'\0'
;
*
fcharset
=
'\0'
;
tfree
(
line
);
tfree
(
line
);
return
;
return
;
}
}
\ No newline at end of file
src/mnode/src/mgmtTable.c
浏览文件 @
6dbca070
...
@@ -364,7 +364,7 @@ static void mgmtAddTableIntoStable(SSuperTableObj *pStable, SChildTableObj *pCta
...
@@ -364,7 +364,7 @@ static void mgmtAddTableIntoStable(SSuperTableObj *pStable, SChildTableObj *pCta
bool
find
=
false
;
bool
find
=
false
;
int32_t
pos
=
0
;
int32_t
pos
=
0
;
for
(
int
pos
=
0
;
pos
<
pStable
->
vgLen
;
++
pos
)
{
for
(
pos
=
0
;
pos
<
pStable
->
vgLen
;
++
pos
)
{
if
(
pStable
->
vgList
[
pos
]
==
0
)
break
;
if
(
pStable
->
vgList
[
pos
]
==
0
)
break
;
if
(
pStable
->
vgList
[
pos
]
==
pCtable
->
vgId
)
{
if
(
pStable
->
vgList
[
pos
]
==
pCtable
->
vgId
)
{
find
=
true
;
find
=
true
;
...
@@ -730,6 +730,9 @@ static void mgmtProcessCreateSuperTableMsg(SQueuedMsg *pMsg) {
...
@@ -730,6 +730,9 @@ static void mgmtProcessCreateSuperTableMsg(SQueuedMsg *pMsg) {
SSchema
*
tschema
=
pStable
->
schema
;
SSchema
*
tschema
=
pStable
->
schema
;
tschema
[
col
].
colId
=
pStable
->
nextColId
++
;
tschema
[
col
].
colId
=
pStable
->
nextColId
++
;
tschema
[
col
].
bytes
=
htons
(
tschema
[
col
].
bytes
);
tschema
[
col
].
bytes
=
htons
(
tschema
[
col
].
bytes
);
// todo 1. check the length of each column; 2. check the total length of all columns
assert
(
tschema
[
col
].
type
>=
TSDB_DATA_TYPE_BOOL
&&
tschema
[
col
].
type
<=
TSDB_DATA_TYPE_NCHAR
);
}
}
SSdbOper
oper
=
{
SSdbOper
oper
=
{
...
@@ -1135,7 +1138,7 @@ void mgmtDropAllSuperTables(SDbObj *pDropDb) {
...
@@ -1135,7 +1138,7 @@ void mgmtDropAllSuperTables(SDbObj *pDropDb) {
static
int32_t
mgmtSetSchemaFromSuperTable
(
SSchema
*
pSchema
,
SSuperTableObj
*
pTable
)
{
static
int32_t
mgmtSetSchemaFromSuperTable
(
SSchema
*
pSchema
,
SSuperTableObj
*
pTable
)
{
int32_t
numOfCols
=
pTable
->
numOfColumns
+
pTable
->
numOfTags
;
int32_t
numOfCols
=
pTable
->
numOfColumns
+
pTable
->
numOfTags
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
str
cpy
(
pSchema
->
name
,
pTable
->
schema
[
i
].
name
);
str
ncpy
(
pSchema
->
name
,
pTable
->
schema
[
i
].
name
,
TSDB_TABLE_ID_LEN
);
pSchema
->
type
=
pTable
->
schema
[
i
].
type
;
pSchema
->
type
=
pTable
->
schema
[
i
].
type
;
pSchema
->
bytes
=
htons
(
pTable
->
schema
[
i
].
bytes
);
pSchema
->
bytes
=
htons
(
pTable
->
schema
[
i
].
bytes
);
pSchema
->
colId
=
htons
(
pTable
->
schema
[
i
].
colId
);
pSchema
->
colId
=
htons
(
pTable
->
schema
[
i
].
colId
);
...
@@ -1155,7 +1158,7 @@ static void mgmtGetSuperTableMeta(SQueuedMsg *pMsg) {
...
@@ -1155,7 +1158,7 @@ static void mgmtGetSuperTableMeta(SQueuedMsg *pMsg) {
pMeta
->
numOfColumns
=
htons
((
int16_t
)
pTable
->
numOfColumns
);
pMeta
->
numOfColumns
=
htons
((
int16_t
)
pTable
->
numOfColumns
);
pMeta
->
tableType
=
pTable
->
info
.
type
;
pMeta
->
tableType
=
pTable
->
info
.
type
;
pMeta
->
contLen
=
sizeof
(
STableMetaMsg
)
+
mgmtSetSchemaFromSuperTable
(
pMeta
->
schema
,
pTable
);
pMeta
->
contLen
=
sizeof
(
STableMetaMsg
)
+
mgmtSetSchemaFromSuperTable
(
pMeta
->
schema
,
pTable
);
str
cpy
(
pMeta
->
tableId
,
pTable
->
info
.
tableId
);
str
ncpy
(
pMeta
->
tableId
,
pTable
->
info
.
tableId
,
TSDB_TABLE_ID_LEN
);
SRpcMsg
rpcRsp
=
{
SRpcMsg
rpcRsp
=
{
.
handle
=
pMsg
->
thandle
,
.
handle
=
pMsg
->
thandle
,
...
...
src/query/inc/queryExecutor.h
浏览文件 @
6dbca070
...
@@ -90,7 +90,7 @@ typedef struct SColumnFilterElem {
...
@@ -90,7 +90,7 @@ typedef struct SColumnFilterElem {
}
SColumnFilterElem
;
}
SColumnFilterElem
;
typedef
struct
SSingleColumnFilterInfo
{
typedef
struct
SSingleColumnFilterInfo
{
SColumnInfo
Data
info
;
SColumnInfo
info
;
int32_t
numOfFilters
;
int32_t
numOfFilters
;
SColumnFilterElem
*
pFilters
;
SColumnFilterElem
*
pFilters
;
void
*
pData
;
void
*
pData
;
...
@@ -122,21 +122,20 @@ typedef struct SQuery {
...
@@ -122,21 +122,20 @@ typedef struct SQuery {
int64_t
slidingTime
;
// sliding time for sliding window query
int64_t
slidingTime
;
// sliding time for sliding window query
char
slidingTimeUnit
;
// interval data type, used for daytime revise
char
slidingTimeUnit
;
// interval data type, used for daytime revise
int8_t
precision
;
int8_t
precision
;
int16_t
numOfOutput
Cols
;
int16_t
numOfOutput
;
int16_t
interpoType
;
int16_t
interpoType
;
int16_t
checkBuffer
;
// check if the buffer is full during scan each block
int16_t
checkBuffer
;
// check if the buffer is full during scan each block
SLimitVal
limit
;
SLimitVal
limit
;
int32_t
rowSize
;
int32_t
rowSize
;
SSqlGroupbyExpr
*
pGroupbyExpr
;
SSqlGroupbyExpr
*
pGroupbyExpr
;
S
SqlFunctionExpr
*
pSelectExpr
;
S
ArithExprInfo
*
pSelectExpr
;
SColumnInfo
Data
*
colList
;
SColumnInfo
*
colList
;
int32_t
numOfFilterCols
;
int32_t
numOfFilterCols
;
int64_t
*
defaultVal
;
int64_t
*
defaultVal
;
TSKEY
lastKey
;
TSKEY
lastKey
;
uint32_t
status
;
// query status
uint32_t
status
;
// query status
SResultRec
rec
;
SResultRec
rec
;
int32_t
pos
;
int32_t
pos
;
int64_t
pointsOffset
;
// the number of points offset to save read data
SData
**
sdata
;
SData
**
sdata
;
SSingleColumnFilterInfo
*
pFilterInfo
;
SSingleColumnFilterInfo
*
pFilterInfo
;
}
SQuery
;
}
SQuery
;
...
...
src/query/inc/queryUtil.h
浏览文件 @
6dbca070
...
@@ -38,4 +38,9 @@ void createQueryResultInfo(SQuery *pQuery, SWindowResult *pResultRow, bool isSTa
...
@@ -38,4 +38,9 @@ void createQueryResultInfo(SQuery *pQuery, SWindowResult *pResultRow, bool isSTa
char
*
getPosInResultPage
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
int32_t
columnIndex
,
SWindowResult
*
pResult
);
char
*
getPosInResultPage
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
int32_t
columnIndex
,
SWindowResult
*
pResult
);
__filter_func_t
*
getRangeFilterFuncArray
(
int32_t
type
);
__filter_func_t
*
getValueFilterFuncArray
(
int32_t
type
);
bool
supportPrefilter
(
int32_t
type
);
#endif // TDENGINE_QUERYUTIL_H
#endif // TDENGINE_QUERYUTIL_H
src/query/inc/tsqlfunction.h
浏览文件 @
6dbca070
...
@@ -114,7 +114,7 @@ enum {
...
@@ -114,7 +114,7 @@ enum {
#define QUERY_IS_FREE_RESOURCE(type) (((type)&TSDB_QUERY_TYPE_FREE_RESOURCE) != 0)
#define QUERY_IS_FREE_RESOURCE(type) (((type)&TSDB_QUERY_TYPE_FREE_RESOURCE) != 0)
typedef
struct
SArithmeticSupport
{
typedef
struct
SArithmeticSupport
{
S
SqlFunctionExpr
*
p
Expr
;
S
ArithExprInfo
*
pArith
Expr
;
int32_t
elemSize
[
TSDB_MAX_COLUMNS
];
int32_t
elemSize
[
TSDB_MAX_COLUMNS
];
int32_t
numOfCols
;
int32_t
numOfCols
;
int32_t
offset
;
int32_t
offset
;
...
...
src/query/src/queryExecutor.c
浏览文件 @
6dbca070
此差异已折叠。
点击以展开。
src/query/src/queryFilterFunc.c
0 → 100644
浏览文件 @
6dbca070
此差异已折叠。
点击以展开。
src/query/src/queryUtil.c
浏览文件 @
6dbca070
...
@@ -217,11 +217,11 @@ void clearTimeWindowResBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *pWindow
...
@@ -217,11 +217,11 @@ void clearTimeWindowResBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *pWindow
return
;
return
;
}
}
for
(
int32_t
i
=
0
;
i
<
pRuntimeEnv
->
pQuery
->
numOfOutput
Cols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pRuntimeEnv
->
pQuery
->
numOfOutput
;
++
i
)
{
SResultInfo
*
pResultInfo
=
&
pWindowRes
->
resultInfo
[
i
];
SResultInfo
*
pResultInfo
=
&
pWindowRes
->
resultInfo
[
i
];
char
*
s
=
getPosInResultPage
(
pRuntimeEnv
,
i
,
pWindowRes
);
char
*
s
=
getPosInResultPage
(
pRuntimeEnv
,
i
,
pWindowRes
);
size_t
size
=
pRuntimeEnv
->
pQuery
->
pSelectExpr
[
i
].
resB
ytes
;
size_t
size
=
pRuntimeEnv
->
pQuery
->
pSelectExpr
[
i
].
b
ytes
;
memset
(
s
,
0
,
size
);
memset
(
s
,
0
,
size
);
resetResultInfo
(
pResultInfo
);
resetResultInfo
(
pResultInfo
);
...
@@ -245,7 +245,7 @@ void copyTimeWindowResBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *dst, con
...
@@ -245,7 +245,7 @@ void copyTimeWindowResBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *dst, con
dst
->
window
=
src
->
window
;
dst
->
window
=
src
->
window
;
dst
->
status
=
src
->
status
;
dst
->
status
=
src
->
status
;
int32_t
nOutputCols
=
pRuntimeEnv
->
pQuery
->
numOfOutput
Cols
;
int32_t
nOutputCols
=
pRuntimeEnv
->
pQuery
->
numOfOutput
;
for
(
int32_t
i
=
0
;
i
<
nOutputCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
nOutputCols
;
++
i
)
{
SResultInfo
*
pDst
=
&
dst
->
resultInfo
[
i
];
SResultInfo
*
pDst
=
&
dst
->
resultInfo
[
i
];
...
@@ -261,7 +261,7 @@ void copyTimeWindowResBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *dst, con
...
@@ -261,7 +261,7 @@ void copyTimeWindowResBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *dst, con
// copy the output buffer data from src to dst, the position info keep unchanged
// copy the output buffer data from src to dst, the position info keep unchanged
char
*
dstBuf
=
getPosInResultPage
(
pRuntimeEnv
,
i
,
dst
);
char
*
dstBuf
=
getPosInResultPage
(
pRuntimeEnv
,
i
,
dst
);
char
*
srcBuf
=
getPosInResultPage
(
pRuntimeEnv
,
i
,
(
SWindowResult
*
)
src
);
char
*
srcBuf
=
getPosInResultPage
(
pRuntimeEnv
,
i
,
(
SWindowResult
*
)
src
);
size_t
s
=
pRuntimeEnv
->
pQuery
->
pSelectExpr
[
i
].
resB
ytes
;
size_t
s
=
pRuntimeEnv
->
pQuery
->
pSelectExpr
[
i
].
b
ytes
;
memcpy
(
dstBuf
,
srcBuf
,
s
);
memcpy
(
dstBuf
,
srcBuf
,
s
);
}
}
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
6dbca070
...
@@ -189,8 +189,8 @@ TsdbQueryHandleT* tsdbQueryTables(TsdbRepoT* tsdb, STsdbQueryCond* pCond, STable
...
@@ -189,8 +189,8 @@ TsdbQueryHandleT* tsdbQueryTables(TsdbRepoT* tsdb, STsdbQueryCond* pCond, STable
for
(
int32_t
i
=
0
;
i
<
pCond
->
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pCond
->
numOfCols
;
++
i
)
{
SColumnInfoData
pDest
=
{{
0
},
0
};
SColumnInfoData
pDest
=
{{
0
},
0
};
pDest
.
info
=
pCond
->
colList
[
i
]
.
info
;
pDest
.
info
=
pCond
->
colList
[
i
];
pDest
.
pData
=
calloc
(
1
,
EXTRA_BYTES
+
bufferCapacity
*
pCond
->
colList
[
i
].
info
.
bytes
);
pDest
.
pData
=
calloc
(
1
,
EXTRA_BYTES
+
bufferCapacity
*
pCond
->
colList
[
i
].
bytes
);
taosArrayPush
(
pQueryHandle
->
pColumns
,
&
pDest
);
taosArrayPush
(
pQueryHandle
->
pColumns
,
&
pDest
);
}
}
...
@@ -442,11 +442,13 @@ static bool loadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock
...
@@ -442,11 +442,13 @@ static bool loadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock
if
(
!
doLoadFileDataBlock
(
pQueryHandle
,
pBlock
,
pCheckInfo
))
{
if
(
!
doLoadFileDataBlock
(
pQueryHandle
,
pBlock
,
pCheckInfo
))
{
return
false
;
return
false
;
}
}
SDataCols
*
pDataCols
=
pCheckInfo
->
pDataCols
;
SDataCols
*
pCols
=
pQueryHandle
->
rhelper
.
pDataCols
[
0
];
assert
(
pCols
->
numOfPoints
==
pBlock
->
numOfPoints
);
if
(
pCheckInfo
->
lastKey
>
pBlock
->
keyFirst
)
{
if
(
pCheckInfo
->
lastKey
>
pBlock
->
keyFirst
)
{
cur
->
pos
=
cur
->
pos
=
binarySearchForKey
(
p
Data
Cols
->
cols
[
0
].
pData
,
pBlock
->
numOfPoints
,
pCheckInfo
->
lastKey
,
pQueryHandle
->
order
);
binarySearchForKey
(
pCols
->
cols
[
0
].
pData
,
pBlock
->
numOfPoints
,
pCheckInfo
->
lastKey
,
pQueryHandle
->
order
);
}
else
{
}
else
{
cur
->
pos
=
0
;
cur
->
pos
=
0
;
}
}
...
@@ -548,8 +550,9 @@ static void filterDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInf
...
@@ -548,8 +550,9 @@ static void filterDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInf
SArray
*
sa
)
{
SArray
*
sa
)
{
SQueryFilePos
*
cur
=
&
pQueryHandle
->
cur
;
SQueryFilePos
*
cur
=
&
pQueryHandle
->
cur
;
SDataBlockInfo
blockInfo
=
getTrueDataBlockInfo
(
pCheckInfo
,
pBlock
);
SDataBlockInfo
blockInfo
=
getTrueDataBlockInfo
(
pCheckInfo
,
pBlock
);
SDataCols
*
pCols
=
pCheckInfo
->
pDataCols
;
// pQueryHandle->rhelper.pDataCols[0]->cols[0];
SDataCols
*
pCols
=
pQueryHandle
->
rhelper
.
pDataCols
[
0
];
int32_t
endPos
=
cur
->
pos
;
int32_t
endPos
=
cur
->
pos
;
if
(
ASCENDING_ORDER_TRAVERSE
(
pQueryHandle
->
order
)
&&
pQueryHandle
->
window
.
ekey
>
blockInfo
.
window
.
ekey
)
{
if
(
ASCENDING_ORDER_TRAVERSE
(
pQueryHandle
->
order
)
&&
pQueryHandle
->
window
.
ekey
>
blockInfo
.
window
.
ekey
)
{
...
@@ -595,10 +598,8 @@ static void filterDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInf
...
@@ -595,10 +598,8 @@ static void filterDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInf
SColumnInfoData
*
pCol
=
taosArrayGet
(
pQueryHandle
->
pColumns
,
j
);
SColumnInfoData
*
pCol
=
taosArrayGet
(
pQueryHandle
->
pColumns
,
j
);
if
(
pCol
->
info
.
colId
==
colId
)
{
if
(
pCol
->
info
.
colId
==
colId
)
{
// SDataCol* pDataCol = &pCols->cols[i];
memmove
(
pCol
->
pData
,
pQueryHandle
->
rhelper
.
pDataCols
[
0
]
->
cols
[
i
].
pData
+
pCol
->
info
.
bytes
*
start
,
// pCol->pData = pQueryHandle->rhelper.pDataCols[0]->cols[i].pData + pCol->info.bytes * start;
pQueryHandle
->
realNumOfRows
*
pCol
->
info
.
bytes
);
memmove
(
pCol
->
pData
,
pQueryHandle
->
rhelper
.
pDataCols
[
0
]
->
cols
[
i
].
pData
+
pCol
->
info
.
bytes
*
start
,
pQueryHandle
->
realNumOfRows
*
pCol
->
info
.
bytes
);
break
;
break
;
}
}
}
}
...
@@ -1082,7 +1083,7 @@ SArray* tsdbRetrieveDataBlock(TsdbQueryHandleT* pQueryHandle, SArray* pIdList) {
...
@@ -1082,7 +1083,7 @@ SArray* tsdbRetrieveDataBlock(TsdbQueryHandleT* pQueryHandle, SArray* pIdList) {
return
pHandle
->
pColumns
;
return
pHandle
->
pColumns
;
}
else
{
}
else
{
STableBlockInfo
*
pBlockInfoEx
=
&
pHandle
->
pDataBlockInfo
[
pHandle
->
cur
.
slot
];
STableBlockInfo
*
pBlockInfoEx
=
&
pHandle
->
pDataBlockInfo
[
pHandle
->
cur
.
slot
];
STableCheckInfo
*
pCheckInfo
=
pBlockInfoEx
->
pTableCheckInfo
;
STableCheckInfo
*
pCheckInfo
=
pBlockInfoEx
->
pTableCheckInfo
;
SDataBlockInfo
binfo
=
getTrueDataBlockInfo
(
pCheckInfo
,
pBlockInfoEx
->
pBlock
.
compBlock
);
SDataBlockInfo
binfo
=
getTrueDataBlockInfo
(
pCheckInfo
,
pBlockInfoEx
->
pBlock
.
compBlock
);
assert
(
pHandle
->
realNumOfRows
<=
binfo
.
rows
);
assert
(
pHandle
->
realNumOfRows
<=
binfo
.
rows
);
...
@@ -1337,10 +1338,6 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC
...
@@ -1337,10 +1338,6 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC
taosArrayPush
(
pTableGroup
,
&
sa
);
taosArrayPush
(
pTableGroup
,
&
sa
);
uTrace
(
"all %d tables belong to one group"
,
size
);
uTrace
(
"all %d tables belong to one group"
,
size
);
#ifdef _DEBUG_VIEW
tSidSetDisplay
(
pTableGroup
);
#endif
}
else
{
}
else
{
STableGroupSupporter
*
pSupp
=
(
STableGroupSupporter
*
)
calloc
(
1
,
sizeof
(
STableGroupSupporter
));
STableGroupSupporter
*
pSupp
=
(
STableGroupSupporter
*
)
calloc
(
1
,
sizeof
(
STableGroupSupporter
));
pSupp
->
numOfCols
=
numOfOrderCols
;
pSupp
->
numOfCols
=
numOfOrderCols
;
...
@@ -1349,10 +1346,6 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC
...
@@ -1349,10 +1346,6 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC
taosqsort
(
pTableList
->
pData
,
size
,
POINTER_BYTES
,
pSupp
,
tableGroupComparFn
);
taosqsort
(
pTableList
->
pData
,
size
,
POINTER_BYTES
,
pSupp
,
tableGroupComparFn
);
createTableGroupImpl
(
pTableGroup
,
pTableList
->
pData
,
size
,
pSupp
,
tableGroupComparFn
);
createTableGroupImpl
(
pTableGroup
,
pTableList
->
pData
,
size
,
pSupp
,
tableGroupComparFn
);
#ifdef _DEBUG_VIEW
tSidSetDisplay
(
pTableGroup
);
#endif
tfree
(
pSupp
);
tfree
(
pSupp
);
}
}
...
...
src/util/inc/tarray.h
浏览文件 @
6dbca070
...
@@ -61,7 +61,7 @@ void taosArrayPop(SArray* pArray);
...
@@ -61,7 +61,7 @@ void taosArrayPop(SArray* pArray);
* @param index
* @param index
* @return
* @return
*/
*/
void
*
taosArrayGet
(
SArray
*
pArray
,
size_t
index
);
void
*
taosArrayGet
(
const
SArray
*
pArray
,
size_t
index
);
/**
/**
* get the pointer data from the array
* get the pointer data from the array
...
@@ -69,7 +69,7 @@ void* taosArrayGet(SArray* pArray, size_t index);
...
@@ -69,7 +69,7 @@ void* taosArrayGet(SArray* pArray, size_t index);
* @param index
* @param index
* @return
* @return
*/
*/
void
*
taosArrayGetP
(
SArray
*
pArray
,
size_t
index
);
void
*
taosArrayGetP
(
const
SArray
*
pArray
,
size_t
index
);
/**
/**
* return the size of array
* return the size of array
...
...
src/util/src/talgo.c
浏览文件 @
6dbca070
...
@@ -42,9 +42,9 @@ static void median(void *src, size_t size, size_t s, size_t e, const void *param
...
@@ -42,9 +42,9 @@ static void median(void *src, size_t size, size_t s, size_t e, const void *param
assert
(
comparFn
(
elePtrAt
(
src
,
size
,
mid
),
elePtrAt
(
src
,
size
,
s
),
param
)
<=
0
&&
comparFn
(
elePtrAt
(
src
,
size
,
s
),
elePtrAt
(
src
,
size
,
e
),
param
)
<=
0
);
assert
(
comparFn
(
elePtrAt
(
src
,
size
,
mid
),
elePtrAt
(
src
,
size
,
s
),
param
)
<=
0
&&
comparFn
(
elePtrAt
(
src
,
size
,
s
),
elePtrAt
(
src
,
size
,
e
),
param
)
<=
0
);
#ifdef _DEBUG_VIEW
#ifdef _DEBUG_VIEW
tTagsPrints
(
src
[
s
],
pOrderDesc
->
pColumnModel
,
&
pOrderDesc
->
orderIdx
);
//
tTagsPrints(src[s], pOrderDesc->pColumnModel, &pOrderDesc->orderIdx);
tTagsPrints
(
src
[
mid
],
pOrderDesc
->
pColumnModel
,
&
pOrderDesc
->
orderIdx
);
//
tTagsPrints(src[mid], pOrderDesc->pColumnModel, &pOrderDesc->orderIdx);
tTagsPrints
(
src
[
e
],
pOrderDesc
->
pColumnModel
,
&
pOrderDesc
->
orderIdx
);
//
tTagsPrints(src[e], pOrderDesc->pColumnModel, &pOrderDesc->orderIdx);
#endif
#endif
}
}
...
...
src/util/src/tarray.c
浏览文件 @
6dbca070
...
@@ -84,12 +84,12 @@ void taosArrayPop(SArray* pArray) {
...
@@ -84,12 +84,12 @@ void taosArrayPop(SArray* pArray) {
pArray
->
size
-=
1
;
pArray
->
size
-=
1
;
}
}
void
*
taosArrayGet
(
SArray
*
pArray
,
size_t
index
)
{
void
*
taosArrayGet
(
const
SArray
*
pArray
,
size_t
index
)
{
assert
(
index
<
pArray
->
size
);
assert
(
index
<
pArray
->
size
);
return
TARRAY_GET_ELEM
(
pArray
,
index
);
return
TARRAY_GET_ELEM
(
pArray
,
index
);
}
}
void
*
taosArrayGetP
(
SArray
*
pArray
,
size_t
index
)
{
void
*
taosArrayGetP
(
const
SArray
*
pArray
,
size_t
index
)
{
void
*
ret
=
taosArrayGet
(
pArray
,
index
);
void
*
ret
=
taosArrayGet
(
pArray
,
index
);
if
(
ret
==
NULL
)
{
if
(
ret
==
NULL
)
{
return
NULL
;
return
NULL
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录