Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
5e221d72
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5e221d72
编写于
4月 23, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-171] refactor codes
上级
79f3d778
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
169 addition
and
193 deletion
+169
-193
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+5
-10
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+128
-129
src/client/src/tscAsync.c
src/client/src/tscAsync.c
+1
-1
src/client/src/tscLocal.c
src/client/src/tscLocal.c
+1
-1
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+1
-1
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+5
-5
src/client/src/tscSchemaUtil.c
src/client/src/tscSchemaUtil.c
+1
-1
src/client/src/tscSecondaryMerge.c
src/client/src/tscSecondaryMerge.c
+2
-2
src/client/src/tscServer.c
src/client/src/tscServer.c
+2
-2
src/client/src/tscSql.c
src/client/src/tscSql.c
+1
-1
src/client/src/tscStream.c
src/client/src/tscStream.c
+1
-1
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+3
-3
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+15
-33
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+3
-3
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
5e221d72
...
...
@@ -69,8 +69,9 @@ typedef struct SJoinSubquerySupporter {
int32_t
tscCreateDataBlock
(
size_t
initialSize
,
int32_t
rowSize
,
int32_t
startOffset
,
const
char
*
name
,
STableMeta
*
pTableMeta
,
STableDataBlocks
**
dataBlocks
);
void
tscAppendDataBlock
(
SDataBlockList
*
pList
,
STableDataBlocks
*
pBlocks
);
void
tscDestroyDataBlock
(
STableDataBlocks
*
pDataBlock
);
void
tscAppendDataBlock
(
SDataBlockList
*
pList
,
STableDataBlocks
*
pBlocks
);
void
tscDestroyDataBlock
(
STableDataBlocks
*
pDataBlock
);
void
tscSortRemoveDataBlockDupRows
(
STableDataBlocks
*
dataBuf
);
SParamInfo
*
tscAddParamToDataBlock
(
STableDataBlocks
*
pDataBlock
,
char
type
,
uint8_t
timePrec
,
short
bytes
,
uint32_t
offset
);
...
...
@@ -133,9 +134,8 @@ SFieldSupInfo* tscFieldInfoInsert(SFieldInfo* pFieldInfo, int32_t index, TAOS_FI
SFieldSupInfo
*
tscFieldInfoGetSupp
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
);
TAOS_FIELD
*
tscFieldInfoGetField
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
);
void
tscFieldInfoCalOffset
(
SQueryInfo
*
pQueryInfo
);
void
tscFieldInfoCopy
(
SFieldInfo
*
src
,
SFieldInfo
*
dst
,
const
int32_t
*
indexList
,
int32_t
size
);
void
tscFieldInfoCopyAll
(
SFieldInfo
*
dst
,
SFieldInfo
*
src
);
void
tscFieldInfoUpdateOffset
(
SQueryInfo
*
pQueryInfo
);
void
tscFieldInfoCopy
(
SFieldInfo
*
dst
,
const
SFieldInfo
*
src
);
void
tscFieldInfoUpdateOffsetForInterResult
(
SQueryInfo
*
pQueryInfo
);
int16_t
tscFieldInfoGetOffset
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
);
...
...
@@ -235,11 +235,6 @@ void doAddGroupColumnForSubquery(SQueryInfo* pQueryInfo, int32_t tagIndex);
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
);
bool
hasMoreVnodesToTry
(
SSqlObj
*
pSql
);
...
...
src/client/inc/tsclient.h
浏览文件 @
5e221d72
...
...
@@ -22,20 +22,28 @@ extern "C" {
#include "os.h"
#include "qsqlparser.h"
#include "qsqltype.h"
#include "qtsbuf.h"
#include "taos.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "tarray.h"
#include "tglobal.h"
#include "tutil.h"
#include "tsqlfunction.h"
#include "tutil.h"
#include "qsqlparser.h"
#include "qsqltype.h"
#include "qtsbuf.h"
#include "queryExecutor.h"
// forward declaration
struct
SSqlInfo
;
struct
SLocalReducer
;
// data source from sql string or from file
enum
{
DATA_FROM_SQL_STRING
=
1
,
DATA_FROM_DATA_FILE
=
2
,
};
typedef
SCMSTableVgroupRspMsg
SVgroupsInfo
;
...
...
@@ -47,20 +55,23 @@ typedef struct STableComInfo {
}
STableComInfo
;
typedef
struct
STableMeta
{
//super table if it is created according to super table, otherwise, tableInfo is used
union
{
struct
STableMeta
*
pSTable
;
STableComInfo
tableInfo
;
};
uint8_t
tableType
;
int16_t
sversion
;
// super table if it is created according to super table, otherwise, tableInfo is used
union
{
struct
STableMeta
*
pSTable
;
STableComInfo
tableInfo
;
};
uint8_t
tableType
;
int16_t
sversion
;
SCMVgroupInfo
vgroupInfo
;
int32_t
sid
;
// the index of one table in a virtual node
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
int32_t
sid
;
// the index of one table in a virtual node
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
}
STableMeta
;
typedef
struct
STableMetaInfo
{
STableMeta
*
pTableMeta
;
// table meta, cached in client side and acquried by name
SVgroupsInfo
*
vgroupList
;
STableMeta
*
pTableMeta
;
// table meta, cached in client side and acquried by name
SVgroupsInfo
*
vgroupList
;
/*
* 1. keep the vnode index during the multi-vnode super table projection query
* 2. keep the vnode index for multi-vnode insertion
...
...
@@ -73,16 +84,16 @@ typedef struct STableMetaInfo {
/* the structure for sql function in select clause */
typedef
struct
SSqlExpr
{
char
aliasName
[
TSDB_COL_NAME_LEN
];
// as aliasName
SColIndex
colInfo
;
int64_t
uid
;
// refactor use the pointer
int16_t
functionId
;
// function id in aAgg array
int16_t
resType
;
// return value type
int16_t
resBytes
;
// length of return value
int16_t
interResBytes
;
// inter result buffer size
int16_t
numOfParams
;
// argument value of each function
tVariant
param
[
3
];
// parameters are not more than 3
int32_t
offset
;
// sub result column value of arithmetic expression.
char
aliasName
[
TSDB_COL_NAME_LEN
];
// as aliasName
SColIndex
colInfo
;
int64_t
uid
;
// refactor use the pointer
int16_t
functionId
;
// function id in aAgg array
int16_t
resType
;
// return value type
int16_t
resBytes
;
// length of return value
int16_t
interResBytes
;
// inter result buffer size
int16_t
numOfParams
;
// argument value of each function
tVariant
param
[
3
];
// parameters are not more than 3
int32_t
offset
;
// sub result column value of arithmetic expression.
}
SSqlExpr
;
typedef
struct
SColumnIndex
{
...
...
@@ -92,14 +103,14 @@ typedef struct SColumnIndex {
typedef
struct
SFieldSupInfo
{
bool
visible
;
SArithExprInfo
*
pArithExprInfo
;
SSqlExpr
*
pSqlExpr
;
SArithExprInfo
*
pArithExprInfo
;
SSqlExpr
*
pSqlExpr
;
}
SFieldSupInfo
;
typedef
struct
SFieldInfo
{
int16_t
numOfOutput
;
// number of column in result
SArray
*
pFields
;
// SArray<TAOS_FIELD>
SArray
*
pSupportInfo
;
// SArray<SFieldSupInfo>
int16_t
numOfOutput
;
// number of column in result
SArray
*
pFields
;
// SArray<TAOS_FIELD>
SArray
*
pSupportInfo
;
// SArray<SFieldSupInfo>
}
SFieldInfo
;
typedef
struct
SColumn
{
...
...
@@ -108,11 +119,9 @@ typedef struct SColumn {
SColumnFilterInfo
*
filterInfo
;
}
SColumn
;
struct
SLocalReducer
;
typedef
struct
SCond
{
uint64_t
uid
;
int32_t
len
;
// length of tag query condition data
int32_t
len
;
// length of tag query condition data
char
*
cond
;
}
SCond
;
...
...
@@ -139,7 +148,7 @@ typedef struct STagCond {
SJoinInfo
joinInfo
;
// for different table, the query condition must be seperated
SArray
*
pCond
;
SArray
*
pCond
;
}
STagCond
;
typedef
struct
SParamInfo
{
...
...
@@ -180,7 +189,7 @@ typedef struct STableDataBlocks {
SParamInfo
*
params
;
}
STableDataBlocks
;
typedef
struct
SDataBlockList
{
// todo remove
typedef
struct
SDataBlockList
{
// todo remove
uint32_t
nSize
;
uint32_t
nAlloc
;
STableDataBlocks
**
pData
;
...
...
@@ -196,9 +205,9 @@ typedef struct SQueryInfo {
int64_t
slidingTime
;
// sliding window in mseconds
SSqlGroupbyExpr
groupbyExpr
;
// group by tags info
SArray
*
colList
;
// SArray<SColumn*>
SArray
*
colList
;
// SArray<SColumn*>
SFieldInfo
fieldsInfo
;
SArray
*
exprsInfo
;
// SArray<SSqlExpr*>
SArray
*
exprsInfo
;
// SArray<SSqlExpr*>
SLimitVal
limit
;
SLimitVal
slimit
;
STagCond
tagCond
;
...
...
@@ -215,19 +224,13 @@ typedef struct SQueryInfo {
int64_t
prjOffset
;
}
SQueryInfo
;
// data source from sql string or from file
enum
{
DATA_FROM_SQL_STRING
=
1
,
DATA_FROM_DATA_FILE
=
2
,
};
typedef
struct
{
int
command
;
uint8_t
msgType
;
union
{
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
};
...
...
@@ -244,11 +247,11 @@ typedef struct {
int32_t
payloadLen
;
SQueryInfo
**
pQueryInfo
;
int32_t
numOfClause
;
SDataBlockList
*
pDataBlocks
;
// submit data blocks after parsing sql
char
*
curSql
;
// current sql, resume position of sql after parsing paused
void
*
pTableList
;
// referred table involved in sql
SDataBlockList
*
pDataBlocks
;
// submit data blocks after parsing sql
char
*
curSql
;
// current sql, resume position of sql after parsing paused
void
*
pTableList
;
// referred table involved in sql
// for parameter ('?') binding and batch processing
int32_t
batchSize
;
int32_t
numOfParams
;
...
...
@@ -259,50 +262,48 @@ typedef struct SResRec {
int
numOfTotal
;
}
SResRec
;
struct
STSBuf
;
typedef
struct
{
int64_t
numOfRows
;
// num of results in current retrieved
int64_t
numOfTotal
;
// num of total results
int64_t
numOfTotalInCurrentClause
;
// num of total result in current subclause
char
*
pRsp
;
int32_t
rspType
;
int32_t
rspLen
;
uint64_t
qhandle
;
int64_t
uid
;
int64_t
useconds
;
int64_t
offset
;
// offset value from vnode during projection query of stable
int32_t
row
;
int16_t
numOfCols
;
int16_t
precision
;
bool
completed
;
int32_t
code
;
int32_t
numOfGroups
;
SResRec
*
pGroupRec
;
char
*
data
;
void
**
tsrow
;
char
**
buffer
;
// Buffer used to put multibytes encoded using unicode (wchar_t)
SColumnIndex
*
pColumnIndex
;
int64_t
numOfRows
;
// num of results in current retrieved
int64_t
numOfTotal
;
// num of total results
int64_t
numOfTotalInCurrentClause
;
// num of total result in current subclause
char
*
pRsp
;
int32_t
rspType
;
int32_t
rspLen
;
uint64_t
qhandle
;
int64_t
uid
;
int64_t
useconds
;
int64_t
offset
;
// offset value from vnode during projection query of stable
int32_t
row
;
int16_t
numOfCols
;
int16_t
precision
;
bool
completed
;
int32_t
code
;
int32_t
numOfGroups
;
SResRec
*
pGroupRec
;
char
*
data
;
void
**
tsrow
;
char
**
buffer
;
// Buffer used to put multibytes encoded using unicode (wchar_t)
SColumnIndex
*
pColumnIndex
;
struct
SLocalReducer
*
pLocalReducer
;
}
SSqlRes
;
typedef
struct
STscObj
{
void
*
signature
;
void
*
pTimer
;
char
mgmtIp
[
TSDB_USER_LEN
];
uint16_t
mgmtPort
;
char
user
[
TSDB_USER_LEN
];
char
pass
[
TSDB_KEY_LEN
];
char
acctId
[
TSDB_DB_NAME_LEN
];
char
db
[
TSDB_TABLE_ID_LEN
];
char
sversion
[
TSDB_VERSION_LEN
];
char
writeAuth
:
1
;
char
superAuth
:
1
;
struct
SSqlObj
*
pSql
;
struct
SSqlObj
*
pHb
;
struct
SSqlObj
*
sqlList
;
void
*
signature
;
void
*
pTimer
;
char
mgmtIp
[
TSDB_USER_LEN
];
uint16_t
mgmtPort
;
char
user
[
TSDB_USER_LEN
];
char
pass
[
TSDB_KEY_LEN
];
char
acctId
[
TSDB_DB_NAME_LEN
];
char
db
[
TSDB_TABLE_ID_LEN
];
char
sversion
[
TSDB_VERSION_LEN
];
char
writeAuth
:
1
;
char
superAuth
:
1
;
struct
SSqlObj
*
pSql
;
struct
SSqlObj
*
pHb
;
struct
SSqlObj
*
sqlList
;
struct
SSqlStream
*
streamList
;
pthread_mutex_t
mutex
;
pthread_mutex_t
mutex
;
}
STscObj
;
typedef
struct
SSqlObj
{
...
...
@@ -310,23 +311,23 @@ typedef struct SSqlObj {
STscObj
*
pTscObj
;
void
(
*
fp
)();
void
(
*
fetchFp
)();
void
*
param
;
uint32_t
ip
;
short
vnode
;
int64_t
stime
;
uint32_t
queryId
;
void
*
pStream
;
void
*
pSubscription
;
char
*
sqlstr
;
char
retry
;
char
maxRetry
;
SRpcIpSet
ipList
;
char
freed
:
4
;
char
listed
:
4
;
tsem_t
rspSem
;
SSqlCmd
cmd
;
SSqlRes
res
;
uint8_t
numOfSubs
;
void
*
param
;
uint32_t
ip
;
short
vnode
;
int64_t
stime
;
uint32_t
queryId
;
void
*
pStream
;
void
*
pSubscription
;
char
*
sqlstr
;
char
retry
;
char
maxRetry
;
SRpcIpSet
ipList
;
char
freed
:
4
;
char
listed
:
4
;
tsem_t
rspSem
;
SSqlCmd
cmd
;
SSqlRes
res
;
uint8_t
numOfSubs
;
struct
SSqlObj
**
pSubs
;
struct
SSqlObj
*
prev
,
*
next
;
}
SSqlObj
;
...
...
@@ -360,13 +361,10 @@ typedef struct SSqlStream {
}
SSqlStream
;
int32_t
tscInitRpc
(
const
char
*
user
,
const
char
*
secret
);
void
tscInitMsgsFp
();
// tscSql API
int
tsParseSql
(
SSqlObj
*
pSql
,
bool
multiVnodeInsertion
);
void
tscInitMsgsFp
();
extern
int
(
*
tscBuildMsg
[
TSDB_SQL_MAX
])(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
);
void
tscProcessMsgFromServer
(
SRpcMsg
*
rpcMsg
);
int
tscProcessSql
(
SSqlObj
*
pSql
);
...
...
@@ -379,12 +377,8 @@ int tscProcessLocalCmd(SSqlObj *pSql);
int
tscCfgDynamicOptions
(
char
*
msg
);
int
taos_retrieve
(
TAOS_RES
*
res
);
/*
* transfer function for metric query in stream computing, the function need to be change
* before send query message to vnode
*/
int32_t
tscTansformSQLFunctionForSTableQuery
(
SQueryInfo
*
pQueryInfo
);
void
tscRestoreSQLFunctionForMetricQuery
(
SQueryInfo
*
pQueryInfo
);
int32_t
tscTansformSQLFuncForSTableQuery
(
SQueryInfo
*
pQueryInfo
);
void
tscRestoreSQLFuncForSTableQuery
(
SQueryInfo
*
pQueryInfo
);
int32_t
tscCreateResPointerInfo
(
SSqlRes
*
pRes
,
SQueryInfo
*
pQueryInfo
);
void
tscDestroyResPointerInfo
(
SSqlRes
*
pRes
);
...
...
@@ -414,10 +408,13 @@ void tscFreeSqlObj(SSqlObj *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
tscKill
Metric
Query
(
SSqlObj
*
pSql
);
void
tscKill
STable
Query
(
SSqlObj
*
pSql
);
void
tscInitResObjForLocalQuery
(
SSqlObj
*
pObj
,
int32_t
numOfRes
,
int32_t
rowLen
);
bool
tscIsUpdateQuery
(
STscObj
*
pObj
);
bool
tscHasReachLimitation
(
SQueryInfo
*
pQueryInfo
,
SSqlRes
*
pRes
);
...
...
@@ -426,20 +423,22 @@ char *tscGetErrorMsgPayload(SSqlCmd *pCmd);
int32_t
tscInvalidSQLErrMsg
(
char
*
msg
,
const
char
*
additionalInfo
,
const
char
*
sql
);
void
tscQueueAsyncFreeResult
(
SSqlObj
*
pSql
);
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
*
tscCacheHandle
;
extern
int
slaveIndex
;
extern
void
*
tscTmr
;
extern
void
*
tscQhandle
;
extern
int
tscKeepConn
[];
extern
int
tsInsertHeadSize
;
extern
int
tscNumOfThreads
;
extern
SRpcIpSet
tscMgmtIpSet
;
void
tscQueueAsyncFreeResult
(
SSqlObj
*
pSql
);
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
*
tscCacheHandle
;
extern
int
slaveIndex
;
extern
void
*
tscTmr
;
extern
void
*
tscQhandle
;
extern
int
tscKeepConn
[];
extern
int
tsInsertHeadSize
;
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
);
...
...
src/client/src/tscAsync.c
浏览文件 @
5e221d72
...
...
@@ -488,7 +488,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
*/
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
tscTansformSQLFunc
tion
ForSTableQuery
(
pQueryInfo
);
tscTansformSQLFuncForSTableQuery
(
pQueryInfo
);
tscIncStreamExecutionCount
(
pSql
->
pStream
);
}
else
{
tscTrace
(
"%p get tableMeta successfully"
,
pSql
);
...
...
src/client/src/tscLocal.c
浏览文件 @
5e221d72
...
...
@@ -296,7 +296,7 @@ static int32_t tscProcessDescribeTable(SSqlObj *pSql) {
int32_t
rowLen
=
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
);
}
...
...
src/client/src/tscParseInsert.c
浏览文件 @
5e221d72
...
...
@@ -613,7 +613,7 @@ static void tsSetBlockInfo(SSubmitBlk *pBlocks, const STableMeta *pTableMeta, in
}
// data block is disordered, sort it in ascending order
void
sortRemoveDuplicate
s
(
STableDataBlocks
*
dataBuf
)
{
void
tscSortRemoveDataBlockDupRow
s
(
STableDataBlocks
*
dataBuf
)
{
SSubmitBlk
*
pBlocks
=
(
SSubmitBlk
*
)
dataBuf
->
pData
;
// size is less than the total size, since duplicated rows may be removed yet.
...
...
src/client/src/tscSQLParser.c
浏览文件 @
5e221d72
...
...
@@ -1258,7 +1258,7 @@ int32_t parseSelectClause(SSqlCmd* pCmd, int32_t clauseIndex, tSQLExprList* pSel
* transfer sql functions that need secondary merge into another format
* in dealing with metric queries such as: count/first/last
*/
tscTansformSQLFunc
tion
ForSTableQuery
(
pQueryInfo
);
tscTansformSQLFuncForSTableQuery
(
pQueryInfo
);
if
(
hasUnsupportFunctionsForSTableQuery
(
pQueryInfo
))
{
return
TSDB_CODE_INVALID_SQL
;
...
...
@@ -2242,7 +2242,7 @@ bool validateIpAddress(const char* ip, size_t size) {
return
ipAddr
!=
INADDR_NONE
;
}
int32_t
tscTansformSQLFunc
tion
ForSTableQuery
(
SQueryInfo
*
pQueryInfo
)
{
int32_t
tscTansformSQLFuncForSTableQuery
(
SQueryInfo
*
pQueryInfo
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
if
(
pTableMetaInfo
->
pTableMeta
==
NULL
||
!
UTIL_TABLE_IS_SUPERTABLE
(
pTableMetaInfo
))
{
...
...
@@ -2282,7 +2282,7 @@ int32_t tscTansformSQLFunctionForSTableQuery(SQueryInfo* pQueryInfo) {
}
/* transfer the field-info back to original input format */
void
tscRestoreSQLFunc
tionForMetric
Query
(
SQueryInfo
*
pQueryInfo
)
{
void
tscRestoreSQLFunc
ForSTable
Query
(
SQueryInfo
*
pQueryInfo
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
if
(
!
UTIL_TABLE_IS_SUPERTABLE
(
pTableMetaInfo
))
{
return
;
...
...
@@ -2547,7 +2547,7 @@ void setColumnOffsetValueInResultset(SQueryInfo* pQueryInfo) {
if
(
QUERY_IS_STABLE_QUERY
(
pQueryInfo
->
type
))
{
tscFieldInfoUpdateOffsetForInterResult
(
pQueryInfo
);
}
else
{
tscFieldInfo
Cal
Offset
(
pQueryInfo
);
tscFieldInfo
Update
Offset
(
pQueryInfo
);
}
}
...
...
@@ -2828,7 +2828,7 @@ static int32_t extractColumnFilterInfo(SQueryInfo* pQueryInfo, SColumnIndex* pIn
const
char
*
msg1
=
"non binary column not support like operator"
;
const
char
*
msg2
=
"binary column not support this operator"
;
SColumn
*
pColumn
=
tscColumnListInsert
(
pQueryInfo
->
colList
,
pIndex
);
SColumn
*
pColumn
=
tscColumnListInsert
(
pQueryInfo
->
colList
,
pIndex
);
SColumnFilterInfo
*
pColFilter
=
NULL
;
/*
...
...
src/client/src/tscSchemaUtil.c
浏览文件 @
5e221d72
...
...
@@ -168,7 +168,7 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg, size_t* size
pTableMeta
->
sid
=
pTableMetaMsg
->
sid
;
pTableMeta
->
uid
=
pTableMetaMsg
->
uid
;
pTableMeta
->
vgroupInfo
=
pTableMetaMsg
->
vgroup
;
//
pTableMeta->vgroupInfo = pTableMetaMsg->vgroup;
memcpy
(
pTableMeta
->
schema
,
pTableMetaMsg
->
schema
,
schemaSize
);
...
...
src/client/src/tscSecondaryMerge.c
浏览文件 @
5e221d72
...
...
@@ -261,8 +261,8 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
pReducer
->
pCtx
=
(
SQLFunctionCtx
*
)
calloc
(
size
,
sizeof
(
SQLFunctionCtx
));
pReducer
->
rowSize
=
pMemBuffer
[
0
]
->
nElemSize
;
tscRestoreSQLFunc
tionForMetric
Query
(
pQueryInfo
);
tscFieldInfo
Cal
Offset
(
pQueryInfo
);
tscRestoreSQLFunc
ForSTable
Query
(
pQueryInfo
);
tscFieldInfo
Update
Offset
(
pQueryInfo
);
if
(
pReducer
->
rowSize
>
pMemBuffer
[
0
]
->
pageSize
)
{
assert
(
false
);
// todo fixed row size is larger than the minimum page size;
...
...
src/client/src/tscServer.c
浏览文件 @
5e221d72
...
...
@@ -458,7 +458,7 @@ int tscProcessSql(SSqlObj *pSql) {
return
doProcessSql
(
pSql
);
}
void
tscKill
Metric
Query
(
SSqlObj
*
pSql
)
{
void
tscKill
STable
Query
(
SSqlObj
*
pSql
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
...
...
@@ -2202,7 +2202,7 @@ int tscProcessShowRsp(SSqlObj *pSql) {
pTableSchema
[
i
].
type
,
pTableSchema
[
i
].
bytes
,
pTableSchema
[
i
].
bytes
);
}
tscFieldInfo
Cal
Offset
(
pQueryInfo
);
tscFieldInfo
Update
Offset
(
pQueryInfo
);
tfree
(
pTableMeta
);
return
0
;
...
...
src/client/src/tscSql.c
浏览文件 @
5e221d72
...
...
@@ -964,7 +964,7 @@ void taos_stop_query(TAOS_RES *res) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
if
(
tscIsTwoStageSTableQuery
(
pQueryInfo
,
0
))
{
tscKill
Metric
Query
(
pSql
);
tscKill
STable
Query
(
pSql
);
return
;
}
...
...
src/client/src/tscStream.c
浏览文件 @
5e221d72
...
...
@@ -86,7 +86,7 @@ static void tscProcessStreamLaunchQuery(SSchedMsg *pMsg) {
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
return
;
}
tscTansformSQLFunc
tion
ForSTableQuery
(
pQueryInfo
);
tscTansformSQLFuncForSTableQuery
(
pQueryInfo
);
// failed to get meter/metric meta, retry in 10sec.
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
src/client/src/tscSubquery.c
浏览文件 @
5e221d72
...
...
@@ -305,7 +305,7 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
tscTagCondCopy
(
&
pQueryInfo
->
tagCond
,
&
pSupporter
->
tagCond
);
pQueryInfo
->
exprsInfo
=
tscSqlExprCopy
(
pSupporter
->
exprsInfo
,
pSupporter
->
uid
,
false
);
tscFieldInfoCopy
All
(
&
pQueryInfo
->
fieldsInfo
,
&
pSupporter
->
fieldsInfo
);
tscFieldInfoCopy
(
&
pQueryInfo
->
fieldsInfo
,
&
pSupporter
->
fieldsInfo
);
pSupporter
->
fieldsInfo
.
numOfOutput
=
0
;
...
...
@@ -321,7 +321,7 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
SQueryInfo
*
pNewQueryInfo
=
tscGetQueryInfoDetail
(
&
pNew
->
cmd
,
0
);
assert
(
pNew
->
numOfSubs
==
0
&&
pNew
->
cmd
.
numOfClause
==
1
&&
pNewQueryInfo
->
numOfTables
==
1
);
tscFieldInfo
Cal
Offset
(
pNewQueryInfo
);
tscFieldInfo
Update
Offset
(
pNewQueryInfo
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pNewQueryInfo
,
0
);
...
...
@@ -859,7 +859,7 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSubquerySu
tscColumnListAssign
(
pSupporter
->
colList
,
pNewQueryInfo
->
colList
,
0
);
pSupporter
->
exprsInfo
=
tscSqlExprCopy
(
pNewQueryInfo
->
exprsInfo
,
pSupporter
->
uid
,
false
);
tscFieldInfoCopy
All
(
&
pSupporter
->
fieldsInfo
,
&
pNewQueryInfo
->
fieldsInfo
);
tscFieldInfoCopy
(
&
pSupporter
->
fieldsInfo
,
&
pNewQueryInfo
->
fieldsInfo
);
tscTagCondCopy
(
&
pSupporter
->
tagCond
,
&
pNewQueryInfo
->
tagCond
);
...
...
src/client/src/tscUtil.c
浏览文件 @
5e221d72
...
...
@@ -475,6 +475,7 @@ SDataBlockList* tscCreateBlockArrayList() {
if
(
pDataBlockArrayList
==
NULL
)
{
return
NULL
;
}
pDataBlockArrayList
->
nAlloc
=
DEFAULT_INITIAL_NUM_OF_BLOCK
;
pDataBlockArrayList
->
pData
=
calloc
(
1
,
POINTER_BYTES
*
pDataBlockArrayList
->
nAlloc
);
if
(
pDataBlockArrayList
->
pData
==
NULL
)
{
...
...
@@ -716,7 +717,7 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, SDataBlockList* pTableDataBlockLi
}
SSubmitBlk
*
pBlocks
=
(
SSubmitBlk
*
)
pOneTableBlock
->
pData
;
sortRemoveDuplicate
s
(
pOneTableBlock
);
tscSortRemoveDataBlockDupRow
s
(
pOneTableBlock
);
char
*
e
=
(
char
*
)
pBlocks
->
data
+
pOneTableBlock
->
rowSize
*
(
pBlocks
->
numOfRows
-
1
);
...
...
@@ -838,7 +839,7 @@ SFieldSupInfo* tscFieldInfoInsert(SFieldInfo* pFieldInfo, int32_t index, TAOS_FI
return
taosArrayInsert
(
pFieldInfo
->
pSupportInfo
,
index
,
&
info
);
}
void
tscFieldInfo
Cal
Offset
(
SQueryInfo
*
pQueryInfo
)
{
void
tscFieldInfo
Update
Offset
(
SQueryInfo
*
pQueryInfo
)
{
size_t
numOfExprs
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
SSqlExpr
*
pExpr
=
taosArrayGetP
(
pQueryInfo
->
exprsInfo
,
0
);
...
...
@@ -869,26 +870,7 @@ void tscFieldInfoUpdateOffsetForInterResult(SQueryInfo* pQueryInfo) {
}
}
void
tscFieldInfoCopy
(
SFieldInfo
*
src
,
SFieldInfo
*
dst
,
const
int32_t
*
indexList
,
int32_t
size
)
{
if
(
src
==
NULL
)
{
return
;
}
if
(
size
<=
0
)
{
tscFieldInfoCopyAll
(
dst
,
src
);
}
else
{
// only copy the required column
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
assert
(
indexList
[
i
]
>=
0
&&
indexList
[
i
]
<=
src
->
numOfOutput
);
TAOS_FIELD
*
p
=
taosArrayGet
(
src
->
pFields
,
indexList
[
i
]);
SFieldSupInfo
*
pInfo
=
taosArrayGet
(
src
->
pSupportInfo
,
indexList
[
i
]);
SFieldSupInfo
*
pInfo1
=
tscFieldInfoAppend
(
dst
,
p
);
*
pInfo1
=
*
pInfo
;
}
}
}
void
tscFieldInfoCopyAll
(
SFieldInfo
*
dst
,
SFieldInfo
*
src
)
{
void
tscFieldInfoCopy
(
SFieldInfo
*
dst
,
const
SFieldInfo
*
src
)
{
dst
->
numOfOutput
=
src
->
numOfOutput
;
taosArrayCopy
(
dst
->
pFields
,
src
->
pFields
);
...
...
@@ -1818,20 +1800,22 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
int32_t
numOfOutput
=
tscSqlExprNumOfExprs
(
pNewQueryInfo
);
if
(
numOfOutput
>
0
)
{
int32_t
*
indexList
=
calloc
(
1
,
numOfOutput
*
sizeof
(
int32_t
));
if
(
numOfOutput
>
0
)
{
// todo refactor to extract method
size_t
numOfExprs
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
for
(
int32_t
i
=
0
,
j
=
0
;
i
<
numOfExprs
;
++
i
)
{
SFieldInfo
*
pFieldInfo
=
&
pQueryInfo
->
fieldsInfo
;
for
(
int32_t
i
=
0
;
i
<
numOfExprs
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
if
(
pExpr
->
uid
==
uid
)
{
indexList
[
j
++
]
=
i
;
TAOS_FIELD
*
p
=
tscFieldInfoGetField
(
pFieldInfo
,
i
);
SFieldSupInfo
*
pInfo
=
tscFieldInfoGetSupp
(
pFieldInfo
,
i
);
SFieldSupInfo
*
pInfo1
=
tscFieldInfoAppend
(
&
pNewQueryInfo
->
fieldsInfo
,
p
);
*
pInfo1
=
*
pInfo
;
}
}
tscFieldInfoCopy
(
&
pQueryInfo
->
fieldsInfo
,
&
pNewQueryInfo
->
fieldsInfo
,
indexList
,
numOfOutput
);
free
(
indexList
);
// make sure the the sqlExpr for each fields is correct
// todo handle the agg arithmetic expression
for
(
int32_t
f
=
0
;
f
<
pNewQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
f
)
{
...
...
@@ -1930,9 +1914,7 @@ bool tscIsUpdateQuery(STscObj* pObj) {
SSqlCmd
*
pCmd
=
&
pObj
->
pSql
->
cmd
;
return
((
pCmd
->
command
>=
TSDB_SQL_INSERT
&&
pCmd
->
command
<=
TSDB_SQL_DROP_DNODE
)
||
TSDB_SQL_USE_DB
==
pCmd
->
command
)
?
1
:
0
;
TSDB_SQL_USE_DB
==
pCmd
->
command
);
}
int32_t
tscInvalidSQLErrMsg
(
char
*
msg
,
const
char
*
additionalInfo
,
const
char
*
sql
)
{
...
...
src/mnode/src/mgmtTable.c
浏览文件 @
5e221d72
...
...
@@ -364,7 +364,7 @@ static void mgmtAddTableIntoStable(SSuperTableObj *pStable, SChildTableObj *pCta
bool
find
=
false
;
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
]
==
pCtable
->
vgId
)
{
find
=
true
;
...
...
@@ -1134,7 +1134,7 @@ void mgmtDropAllSuperTables(SDbObj *pDropDb) {
static
int32_t
mgmtSetSchemaFromSuperTable
(
SSchema
*
pSchema
,
SSuperTableObj
*
pTable
)
{
int32_t
numOfCols
=
pTable
->
numOfColumns
+
pTable
->
numOfTags
;
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
->
bytes
=
htons
(
pTable
->
schema
[
i
].
bytes
);
pSchema
->
colId
=
htons
(
pTable
->
schema
[
i
].
colId
);
...
...
@@ -1154,7 +1154,7 @@ static void mgmtGetSuperTableMeta(SQueuedMsg *pMsg) {
pMeta
->
numOfColumns
=
htons
((
int16_t
)
pTable
->
numOfColumns
);
pMeta
->
tableType
=
pTable
->
info
.
type
;
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
=
{
.
handle
=
pMsg
->
thandle
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录