Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
9b6c8a30
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看板
未验证
提交
9b6c8a30
编写于
4月 16, 2020
作者:
S
slguan
提交者:
GitHub
4月 16, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1624 from taosdata/feature/query
Feature/query
上级
d255b599
6fc7c108
变更
22
隐藏空白更改
内联
并排
Showing
22 changed file
with
154 addition
and
138 deletion
+154
-138
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+3
-5
src/client/src/tscAsync.c
src/client/src/tscAsync.c
+4
-28
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+1
-1
src/client/src/tscPrepare.c
src/client/src/tscPrepare.c
+2
-2
src/client/src/tscSchemaUtil.c
src/client/src/tscSchemaUtil.c
+1
-3
src/client/src/tscSecondaryMerge.c
src/client/src/tscSecondaryMerge.c
+1
-1
src/client/src/tscServer.c
src/client/src/tscServer.c
+43
-40
src/client/src/tscSql.c
src/client/src/tscSql.c
+2
-0
src/client/src/tscSub.c
src/client/src/tscSub.c
+1
-1
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+22
-22
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+33
-1
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+11
-11
src/inc/taos.h
src/inc/taos.h
+1
-0
src/inc/taosmsg.h
src/inc/taosmsg.h
+1
-1
src/kit/shell/inc/shell.h
src/kit/shell/inc/shell.h
+1
-1
src/kit/shell/src/shellEngine.c
src/kit/shell/src/shellEngine.c
+6
-4
src/kit/shell/src/shellLinux.c
src/kit/shell/src/shellLinux.c
+10
-3
src/kit/shell/src/shellMain.c
src/kit/shell/src/shellMain.c
+1
-1
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+0
-1
src/util/src/hash.c
src/util/src/hash.c
+8
-11
src/util/src/ttimer.c
src/util/src/ttimer.c
+1
-1
tests/examples/c/demo.c
tests/examples/c/demo.c
+1
-0
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
9b6c8a30
...
...
@@ -28,12 +28,12 @@ extern "C" {
#include "taos.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "tarray.h"
#include "tglobalcfg.h"
#include "tlog.h"
#include "trpc.h"
#include "tsqlfunction.h"
#include "tutil.h"
#include "tarray.h"
#define TSC_GET_RESPTR_BASE(res, _queryinfo, col) (res->data + ((_queryinfo)->fieldsInfo.pSqlExpr[col]->offset) * res->numOfRows)
...
...
@@ -61,10 +61,8 @@ 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
;
int8_t
numOfVpeers
;
int16_t
sversion
;
SVnodeDesc
vpeerDesc
[
TSDB_VNODES_SUPPORT
];
int32_t
vgId
;
// virtual group id, which current table belongs to
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
...
...
@@ -77,7 +75,7 @@ typedef struct STableMetaInfo {
* 1. keep the vnode index during the multi-vnode super table projection query
* 2. keep the vnode index for multi-vnode insertion
*/
int32_t
dnode
Index
;
int32_t
vgroup
Index
;
char
name
[
TSDB_TABLE_ID_LEN
];
// (super) table name
int16_t
numOfTags
;
// total required tags in query, including groupby tags
int16_t
tagColumnIndex
[
TSDB_MAX_TAGS
];
// clause + tag projection
...
...
src/client/src/tscAsync.c
浏览文件 @
9b6c8a30
...
...
@@ -45,9 +45,10 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, void (*fp)(), void* param, const
SSqlRes
*
pRes
=
&
pSql
->
res
;
pSql
->
signature
=
pSql
;
pSql
->
param
=
param
;
pSql
->
pTscObj
=
pObj
;
pSql
->
maxRetry
=
TSDB_REPLICA_MAX_NUM
;
pSql
->
fp
=
fp
;
pSql
->
param
=
param
;
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
))
{
tscError
(
"failed to malloc payload"
);
...
...
@@ -406,31 +407,6 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
if
(
pSql
->
fp
==
(
void
*
)
1
)
{
pSql
->
fp
=
NULL
;
if
(
code
!=
0
)
{
pRes
->
code
=
code
;
tscTrace
(
"%p failed to renew tableMeta"
,
pSql
);
// tsem_post(&pSql->rspSem);
}
else
{
tscTrace
(
"%p renew tableMeta successfully, command:%d, code:%d, retry:%d"
,
pSql
,
pSql
->
cmd
.
command
,
pSql
->
res
.
code
,
pSql
->
retry
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pSql
->
cmd
,
0
,
0
);
assert
(
pTableMetaInfo
->
pTableMeta
==
NULL
);
tscGetTableMeta
(
pSql
,
pTableMetaInfo
);
code
=
tscSendMsgToServer
(
pSql
);
if
(
code
!=
0
)
{
pRes
->
code
=
code
;
// tsem_post(&pSql->rspSem);
}
}
return
;
}
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pRes
->
code
=
code
;
tscQueueAsyncRes
(
pSql
);
...
...
@@ -443,12 +419,12 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
if
((
pQueryInfo
->
type
&
TSDB_QUERY_TYPE_STABLE_SUBQUERY
)
==
TSDB_QUERY_TYPE_STABLE_SUBQUERY
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
assert
((
tscGetNumOfTags
(
pTableMetaInfo
->
pTableMeta
)
!=
0
)
&&
pTableMetaInfo
->
dnode
Index
>=
0
&&
pSql
->
param
!=
NULL
);
assert
((
tscGetNumOfTags
(
pTableMetaInfo
->
pTableMeta
)
!=
0
)
&&
pTableMetaInfo
->
vgroup
Index
>=
0
&&
pSql
->
param
!=
NULL
);
SRetrieveSupport
*
trs
=
(
SRetrieveSupport
*
)
pSql
->
param
;
SSqlObj
*
pParObj
=
trs
->
pParentSqlObj
;
assert
(
pParObj
->
signature
==
pParObj
&&
trs
->
subqueryIndex
==
pTableMetaInfo
->
dnode
Index
&&
assert
(
pParObj
->
signature
==
pParObj
&&
trs
->
subqueryIndex
==
pTableMetaInfo
->
vgroup
Index
&&
tscGetNumOfTags
(
pTableMetaInfo
->
pTableMeta
)
!=
0
);
tscTrace
(
"%p get metricMeta during super table query successfully"
,
pSql
);
...
...
src/client/src/tscParseInsert.c
浏览文件 @
9b6c8a30
...
...
@@ -699,7 +699,7 @@ static int32_t doParseInsertStatement(SSqlObj *pSql, void *pTableList, char **st
SSubmitBlk
*
pBlocks
=
(
SSubmitBlk
*
)(
dataBuf
->
pData
);
tsSetBlockInfo
(
pBlocks
,
pTableMeta
,
numOfRows
);
dataBuf
->
vgId
=
pTableMeta
->
vgId
;
dataBuf
->
vgId
=
pTableMeta
->
vg
roupInfo
.
vg
Id
;
dataBuf
->
numOfTables
=
1
;
/*
...
...
src/client/src/tscPrepare.c
浏览文件 @
9b6c8a30
...
...
@@ -408,7 +408,7 @@ static int insertStmtReset(STscStmt* pStmt) {
pCmd
->
batchSize
=
0
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
pTableMetaInfo
->
dnode
Index
=
0
;
pTableMetaInfo
->
vgroup
Index
=
0
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -438,7 +438,7 @@ static int insertStmtExecute(STscStmt* stmt) {
}
// set the next sent data vnode index in data block arraylist
pTableMetaInfo
->
dnode
Index
=
1
;
pTableMetaInfo
->
vgroup
Index
=
1
;
}
else
{
pCmd
->
pDataBlocks
=
tscDestroyBlockArrayList
(
pCmd
->
pDataBlocks
);
}
...
...
src/client/src/tscSchemaUtil.c
浏览文件 @
9b6c8a30
...
...
@@ -168,10 +168,8 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg, size_t* size
pTableMeta
->
sid
=
pTableMetaMsg
->
sid
;
pTableMeta
->
uid
=
pTableMetaMsg
->
uid
;
pTableMeta
->
vg
Id
=
pTableMetaMsg
->
vgId
;
pTableMeta
->
vg
roupInfo
=
pTableMetaMsg
->
vgroup
;
pTableMeta
->
numOfVpeers
=
pTableMetaMsg
->
numOfVpeers
;
memcpy
(
pTableMeta
->
vpeerDesc
,
pTableMetaMsg
->
vpeerDesc
,
sizeof
(
SVnodeDesc
)
*
pTableMeta
->
numOfVpeers
);
memcpy
(
pTableMeta
->
schema
,
pTableMetaMsg
->
schema
,
schemaSize
);
int32_t
numOfTotalCols
=
pTableMeta
->
tableInfo
.
numOfColumns
+
pTableMeta
->
tableInfo
.
numOfTags
;
...
...
src/client/src/tscSecondaryMerge.c
浏览文件 @
9b6c8a30
...
...
@@ -636,7 +636,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
pModel
=
createColumnModel
(
pSchema
,
pQueryInfo
->
exprsInfo
.
numOfExprs
,
capacity
);
size_t
numOfSubs
=
pTableMetaInfo
->
vgroupList
->
numOf
Dnode
s
;
size_t
numOfSubs
=
pTableMetaInfo
->
vgroupList
->
numOf
Vgroup
s
;
for
(
int32_t
i
=
0
;
i
<
numOfSubs
;
++
i
)
{
(
*
pMemBuffer
)[
i
]
=
createExtMemBuffer
(
nBufferSizes
,
rlen
,
pModel
);
(
*
pMemBuffer
)[
i
]
->
flushModel
=
MULTIPLE_APPEND_MODEL
;
...
...
src/client/src/tscServer.c
浏览文件 @
9b6c8a30
...
...
@@ -47,12 +47,12 @@ static int32_t minMsgSize() { return tsRpcHeadSize + 100; }
static
void
tscSetDnodeIpList
(
SSqlObj
*
pSql
,
STableMeta
*
pTableMeta
)
{
SRpcIpSet
*
pIpList
=
&
pSql
->
ipList
;
pIpList
->
numOfIps
=
pTableMeta
->
numOfVpeer
s
;
pIpList
->
numOfIps
=
pTableMeta
->
vgroupInfo
.
numOfIp
s
;
pIpList
->
port
=
tsDnodeShellPort
;
pIpList
->
inUse
=
0
;
for
(
int32_t
i
=
0
;
i
<
pTableMeta
->
numOfVpeer
s
;
++
i
)
{
pIpList
->
ip
[
i
]
=
pTableMeta
->
v
peerDesc
[
i
].
ip
;
for
(
int32_t
i
=
0
;
i
<
pTableMeta
->
vgroupInfo
.
numOfIp
s
;
++
i
)
{
pIpList
->
ip
[
i
]
=
pTableMeta
->
v
groupInfo
.
ipAddr
[
i
].
ip
;
}
}
...
...
@@ -269,8 +269,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg) {
return
;
}
else
{
tscWarn
(
"%p it shall renew table meta, code:%s, retry:%d"
,
pSql
,
tstrerror
(
rpcMsg
->
code
),
++
pSql
->
retry
);
pSql
->
maxRetry
=
TSDB_VNODES_SUPPORT
*
2
;
// todo move away
pSql
->
res
.
code
=
rpcMsg
->
code
;
// keep the previous error code
if
(
pSql
->
retry
>
pSql
->
maxRetry
)
{
tscError
(
"%p max retry %d reached, give up"
,
pSql
,
pSql
->
maxRetry
);
...
...
@@ -327,7 +326,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg) {
* There is not response callback function for submit response.
* The actual inserted number of points is the first number.
*/
if
(
rpcMsg
->
msgType
==
TSDB_MSG_TYPE_SUBMIT_RSP
)
{
if
(
rpcMsg
->
msgType
==
TSDB_MSG_TYPE_SUBMIT_RSP
&&
pRes
->
pRsp
!=
NULL
)
{
SShellSubmitRspMsg
*
pMsg
=
(
SShellSubmitRspMsg
*
)
pRes
->
pRsp
;
pMsg
->
code
=
htonl
(
pMsg
->
code
);
pMsg
->
numOfRows
=
htonl
(
pMsg
->
numOfRows
);
...
...
@@ -512,12 +511,12 @@ int tscBuildRetrieveMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
// todo valid the vgroupId at the client side
if
(
UTIL_TABLE_IS_SUPERTABLE
(
pQueryInfo
->
pTableMetaInfo
[
0
]))
{
SVgroupsInfo
*
pVgroupInfo
=
pQueryInfo
->
pTableMetaInfo
[
0
]
->
vgroupList
;
assert
(
pVgroupInfo
->
dnodeVgroups
->
numOfVgroups
==
1
);
// todo fix me
assert
(
pVgroupInfo
->
numOfVgroups
==
1
);
// todo fix me
pRetrieveMsg
->
header
.
vgId
=
htonl
(
pVgroupInfo
->
dnodeVgroups
[
0
].
vgId
[
0
]
);
pRetrieveMsg
->
header
.
vgId
=
htonl
(
pVgroupInfo
->
vgroups
[
0
].
vgId
);
}
else
{
STableMeta
*
pTableMeta
=
pQueryInfo
->
pTableMetaInfo
[
0
]
->
pTableMeta
;
pRetrieveMsg
->
header
.
vgId
=
htonl
(
pTableMeta
->
vgId
);
pRetrieveMsg
->
header
.
vgId
=
htonl
(
pTableMeta
->
vg
roupInfo
.
vg
Id
);
}
pMsg
+=
sizeof
(
SRetrieveTableMsg
);
...
...
@@ -543,8 +542,9 @@ int tscBuildSubmitMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pMsg
+=
sizeof
(
SMsgDesc
);
SSubmitMsg
*
pShellMsg
=
(
SSubmitMsg
*
)
pMsg
;
int32_t
vgId
=
pTableMeta
->
vgroupInfo
.
vgId
;
pShellMsg
->
header
.
vgId
=
htonl
(
pTableMeta
->
vgId
);
pShellMsg
->
header
.
vgId
=
htonl
(
vgId
);
pShellMsg
->
header
.
contLen
=
htonl
(
size
);
pShellMsg
->
length
=
pShellMsg
->
header
.
contLen
;
...
...
@@ -554,7 +554,7 @@ int tscBuildSubmitMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pSql
->
cmd
.
msgType
=
TSDB_MSG_TYPE_SUBMIT
;
tscSetDnodeIpList
(
pSql
,
pTableMeta
);
tscTrace
(
"%p build submit msg, vgId:%d numOfV
nodes:%d"
,
pSql
,
pTableMeta
->
vgId
,
htonl
(
pMsgDesc
->
numOfVnodes
));
tscTrace
(
"%p build submit msg, vgId:%d numOfV
group:%d"
,
pSql
,
vgId
,
htonl
(
pMsgDesc
->
numOfVnodes
));
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -580,7 +580,7 @@ static int32_t tscEstimateQueryMsgSize(SSqlCmd *pCmd, int32_t clauseIndex) {
#if 0
SSuperTableMeta *pMetricMeta = pTableMetaInfo->pMetricMeta;
SVnodeSidList *pVnodeSidList = tscGetVnodeSidList(pMetricMeta, pTableMetaInfo->
dnode
Index);
SVnodeSidList *pVnodeSidList = tscGetVnodeSidList(pMetricMeta, pTableMetaInfo->
vgroup
Index);
int32_t meterInfoSize = (pMetricMeta->tagLen + sizeof(STableIdInfo)) * pVnodeSidList->numOfSids;
int32_t outputColumnSize = pQueryInfo->exprsInfo.numOfExprs * sizeof(SSqlFuncExprMsg);
...
...
@@ -648,12 +648,12 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
if
(
UTIL_TABLE_IS_NOMRAL_TABLE
(
pTableMetaInfo
))
{
numOfTables
=
1
;
tscSetDnodeIpList
(
pSql
,
pTableMeta
);
pQueryMsg
->
head
.
vgId
=
htonl
(
pTableMeta
->
vgId
);
pQueryMsg
->
head
.
vgId
=
htonl
(
pTableMeta
->
vg
roupInfo
.
vg
Id
);
tscTrace
(
"%p queried tables:%d, table id: %s"
,
pSql
,
1
,
pTableMetaInfo
->
name
);
}
else
{
// query super table
if
(
pTableMetaInfo
->
dnode
Index
<
0
)
{
tscError
(
"%p error vnodeIdx:%d"
,
pSql
,
pTableMetaInfo
->
dnode
Index
);
if
(
pTableMetaInfo
->
vgroup
Index
<
0
)
{
tscError
(
"%p error vnodeIdx:%d"
,
pSql
,
pTableMetaInfo
->
vgroup
Index
);
return
-
1
;
}
...
...
@@ -662,11 +662,11 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pSql
->
ipList
.
inUse
=
0
;
// todo extract method
S
TableDnodeVgroupInfo
*
pVgroupInfo
=
&
pTableMetaInfo
->
vgroupList
->
dnodeVgroups
[
pTableMetaInfo
->
dnode
Index
];
pSql
->
ipList
.
ip
[
0
]
=
pVgroupInfo
->
ipAddr
.
ip
;
S
CMVgroupInfo
*
pVgroupInfo
=
&
pTableMetaInfo
->
vgroupList
->
vgroups
[
pTableMetaInfo
->
vgroup
Index
];
pSql
->
ipList
.
ip
[
0
]
=
pVgroupInfo
->
ipAddr
[
0
]
.
ip
;
#if 0
SVnodeSidList *pVnodeSidList = tscGetVnodeSidList(pMetricMeta, pTableMetaInfo->
dnode
Index);
SVnodeSidList *pVnodeSidList = tscGetVnodeSidList(pMetricMeta, pTableMetaInfo->
vgroup
Index);
uint32_t vnodeId = pVnodeSidList->vpeerDesc[pVnodeSidList->index].vnode;
numOfTables = pVnodeSidList->numOfSids;
...
...
@@ -676,10 +676,10 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
#endif
tscTrace
(
"%p query on super table, numOfVgroup:%d,
dnodeIndex:%d"
,
pSql
,
pVgroupInfo
->
numOfVgroups
,
pTableMetaInfo
->
dnode
Index
);
tscTrace
(
"%p query on super table, numOfVgroup:%d,
vgroupIndex:%d"
,
pSql
,
pTableMetaInfo
->
vgroupList
->
numOfVgroups
,
pTableMetaInfo
->
vgroup
Index
);
pQueryMsg
->
head
.
vgId
=
htonl
(
pVgroupInfo
->
vgId
[
0
]
);
pQueryMsg
->
head
.
vgId
=
htonl
(
pVgroupInfo
->
vgId
);
numOfTables
=
1
;
}
...
...
@@ -857,7 +857,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int32_t
numOfBlocks
=
0
;
if
(
pQueryInfo
->
tsBuf
!=
NULL
)
{
STSVnodeBlockInfo
*
pBlockInfo
=
tsBufGetVnodeBlockInfo
(
pQueryInfo
->
tsBuf
,
pTableMetaInfo
->
dnode
Index
);
STSVnodeBlockInfo
*
pBlockInfo
=
tsBufGetVnodeBlockInfo
(
pQueryInfo
->
tsBuf
,
pTableMetaInfo
->
vgroup
Index
);
assert
(
QUERY_IS_JOIN_QUERY
(
pQueryInfo
->
type
)
&&
pBlockInfo
!=
NULL
);
// this query should not be sent
// todo refactor
...
...
@@ -1828,13 +1828,15 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
pMetaMsg
->
sid
=
htonl
(
pMetaMsg
->
sid
);
pMetaMsg
->
sversion
=
htons
(
pMetaMsg
->
sversion
);
pMetaMsg
->
vgId
=
htonl
(
pMetaMsg
->
vgId
);
pMetaMsg
->
vgroup
.
vgId
=
htonl
(
pMetaMsg
->
vgroup
.
vgId
);
pMetaMsg
->
uid
=
htobe64
(
pMetaMsg
->
uid
);
pMetaMsg
->
contLen
=
htons
(
pMetaMsg
->
contLen
);
pMetaMsg
->
numOfColumns
=
htons
(
pMetaMsg
->
numOfColumns
);
if
(
pMetaMsg
->
sid
<
0
||
pMetaMsg
->
vg
Id
<
0
)
{
tscError
(
"invalid meter vgId:%d, sid%d"
,
pMetaMsg
->
vg
Id
,
pMetaMsg
->
sid
);
if
(
pMetaMsg
->
sid
<
0
||
pMetaMsg
->
vg
roup
.
numOfIps
<
0
)
{
tscError
(
"invalid meter vgId:%d, sid%d"
,
pMetaMsg
->
vg
roup
.
numOfIps
,
pMetaMsg
->
sid
);
return
TSDB_CODE_INVALID_VALUE
;
}
...
...
@@ -1848,9 +1850,11 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
return
TSDB_CODE_INVALID_VALUE
;
}
for
(
int
i
=
0
;
i
<
TSDB_VNODES_SUPPORT
;
++
i
)
{
pMetaMsg
->
vpeerDesc
[
i
].
ip
=
htonl
(
pMetaMsg
->
vpeerDesc
[
i
].
ip
);
pMetaMsg
->
vpeerDesc
[
i
].
dnodeId
=
htonl
(
pMetaMsg
->
vpeerDesc
[
i
].
dnodeId
);
for
(
int
i
=
0
;
i
<
pMetaMsg
->
vgroup
.
numOfIps
;
++
i
)
{
pMetaMsg
->
vgroup
.
ipAddr
[
i
].
ip
=
htonl
(
pMetaMsg
->
vgroup
.
ipAddr
[
i
].
ip
);
pMetaMsg
->
vgroup
.
ipAddr
[
i
].
port
=
htons
(
pMetaMsg
->
vgroup
.
ipAddr
[
i
].
port
);
assert
(
pMetaMsg
->
vgroup
.
ipAddr
[
i
].
ip
!=
0
);
}
SSchema
*
pSchema
=
pMetaMsg
->
schema
;
...
...
@@ -1859,6 +1863,8 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
for
(
int
i
=
0
;
i
<
numOfTotalCols
;
++
i
)
{
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
pSchema
->
colId
=
htons
(
pSchema
->
colId
);
assert
(
pSchema
->
type
>=
TSDB_DATA_TYPE_BOOL
&&
pSchema
->
type
<=
TSDB_DATA_TYPE_NCHAR
);
pSchema
++
;
}
...
...
@@ -1899,9 +1905,6 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
* |...... 1B 1B 4B
**/
int
tscProcessMultiMeterMetaRsp
(
SSqlObj
*
pSql
)
{
// uint8_t ieType;
// int32_t totalNum;
// int32_t i;
#if 0
char *rsp = pSql->res.pRsp;
...
...
@@ -1958,7 +1961,7 @@ int tscProcessMultiMeterMetaRsp(SSqlObj *pSql) {
// return TSDB_CODE_OTHERS;
// }
//
// for (int j = 0; j < TSDB_
VNODES_SUPPORT
; ++j) {
// for (int j = 0; j < TSDB_
REPLICA_MAX_NUM
; ++j) {
// pMeta->vpeerDesc[j].vnode = htonl(pMeta->vpeerDesc[j].vnode);
// }
//
...
...
@@ -2116,7 +2119,7 @@ _error_clean:
SSqlRes
*
pRes
=
&
pSql
->
res
;
SCMSTableVgroupRspMsg
*
pStableVgroup
=
(
SCMSTableVgroupRspMsg
*
)
pRes
->
pRsp
;
pStableVgroup
->
numOf
Dnodes
=
htonl
(
pStableVgroup
->
numOfDnode
s
);
pStableVgroup
->
numOf
Vgroups
=
htonl
(
pStableVgroup
->
numOfVgroup
s
);
// master sqlObj locates in param
SSqlObj
*
parent
=
pSql
->
param
;
...
...
@@ -2128,14 +2131,14 @@ _error_clean:
pInfo
->
vgroupList
=
malloc
(
pRes
->
rspLen
);
memcpy
(
pInfo
->
vgroupList
,
pStableVgroup
,
pRes
->
rspLen
);
for
(
int32_t
i
=
0
;
i
<
pInfo
->
vgroupList
->
numOfDnodes
;
++
i
)
{
STableDnodeVgroupInfo
*
pVgroups
=
&
pInfo
->
vgroupList
->
dnodeVgroups
[
i
];
pVgroups
->
numOfVgroups
=
htonl
(
pVgroups
->
numOfVgroups
);
pVgroups
->
ipAddr
.
ip
=
htonl
(
pVgroups
->
ipAddr
.
ip
);
pVgroups
->
ipAddr
.
port
=
htons
(
pVgroups
->
ipAddr
.
port
);
for
(
int32_t
i
=
0
;
i
<
pInfo
->
vgroupList
->
numOfVgroups
;
++
i
)
{
SCMVgroupInfo
*
pVgroups
=
&
pInfo
->
vgroupList
->
vgroups
[
i
];
pVgroups
->
numOfIps
=
htonl
(
pVgroups
->
numOfIps
);
pVgroups
->
vgId
=
htonl
(
pVgroups
->
vgId
);
for
(
int32_t
j
=
0
;
j
<
pVgroups
->
numOfVgroups
;
++
j
)
{
pVgroups
->
vgId
[
j
]
=
htonl
(
pVgroups
->
vgId
[
j
]);
for
(
int32_t
j
=
0
;
j
<
tListLen
(
pVgroups
->
ipAddr
);
++
j
)
{
pVgroups
->
ipAddr
[
j
].
ip
=
htonl
(
pVgroups
->
ipAddr
[
j
].
ip
);
pVgroups
->
ipAddr
[
j
].
port
=
htons
(
pVgroups
->
ipAddr
[
j
].
port
);
}
}
...
...
src/client/src/tscSql.c
浏览文件 @
9b6c8a30
...
...
@@ -129,6 +129,8 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
pSql
->
pTscObj
=
pObj
;
pSql
->
signature
=
pSql
;
pSql
->
maxRetry
=
TSDB_REPLICA_MAX_NUM
;
tsem_init
(
&
pSql
->
rspSem
,
0
,
0
);
pObj
->
pSql
=
pSql
;
...
...
src/client/src/tscSub.c
浏览文件 @
9b6c8a30
...
...
@@ -382,7 +382,7 @@ TAOS_RES *taos_consume(TAOS_SUB *tsub) {
pSql
->
cmd
.
command
=
TSDB_SQL_SELECT
;
pQueryInfo
->
type
=
type
;
tscGetTableMetaInfoFromCmd
(
&
pSql
->
cmd
,
0
,
0
)
->
dnode
Index
=
0
;
tscGetTableMetaInfoFromCmd
(
&
pSql
->
cmd
,
0
,
0
)
->
vgroup
Index
=
0
;
}
tscDoQuery
(
pSql
);
...
...
src/client/src/tscSubquery.c
浏览文件 @
9b6c8a30
...
...
@@ -341,8 +341,8 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
tscPrintSelectClause
(
pNew
,
0
);
tscTrace
(
"%p subquery:%p tableIndex:%d,
dnode
Index:%d, type:%d, exprInfo:%d, colList:%d, fieldsInfo:%d, name:%s"
,
pSql
,
pNew
,
0
,
pTableMetaInfo
->
dnode
Index
,
pNewQueryInfo
->
type
,
tscTrace
(
"%p subquery:%p tableIndex:%d,
vgroup
Index:%d, type:%d, exprInfo:%d, colList:%d, fieldsInfo:%d, name:%s"
,
pSql
,
pNew
,
0
,
pTableMetaInfo
->
vgroup
Index
,
pNewQueryInfo
->
type
,
pNewQueryInfo
->
exprsInfo
.
numOfExprs
,
pNewQueryInfo
->
colList
.
numOfCols
,
pNewQueryInfo
->
fieldsInfo
.
numOfOutputCols
,
pNewQueryInfo
->
pTableMetaInfo
[
0
]
->
name
);
}
...
...
@@ -457,7 +457,7 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
assert
(
pQueryInfo
->
numOfTables
==
1
);
// for subquery, only one metermetaInfo
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
tsBufMerge
(
pSupporter
->
pTSBuf
,
pBuf
,
pTableMetaInfo
->
dnode
Index
);
tsBufMerge
(
pSupporter
->
pTSBuf
,
pBuf
,
pTableMetaInfo
->
vgroup
Index
);
tsBufDestory
(
pBuf
);
}
...
...
@@ -478,9 +478,9 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
// for projection query, need to try next vnode
// int32_t totalVnode = pTableMetaInfo->pMetricMeta->numOfVnodes;
int32_t
totalVnode
=
0
;
if
((
++
pTableMetaInfo
->
dnode
Index
)
<
totalVnode
)
{
if
((
++
pTableMetaInfo
->
vgroup
Index
)
<
totalVnode
)
{
tscTrace
(
"%p current vnode:%d exhausted, try next:%d. total vnode:%d. current numOfRes:%d"
,
pSql
,
pTableMetaInfo
->
dnodeIndex
-
1
,
pTableMetaInfo
->
dnode
Index
,
totalVnode
,
pRes
->
numOfTotal
);
pTableMetaInfo
->
vgroupIndex
-
1
,
pTableMetaInfo
->
vgroup
Index
,
totalVnode
,
pRes
->
numOfTotal
);
pSql
->
cmd
.
command
=
TSDB_SQL_SELECT
;
pSql
->
fp
=
tscJoinQueryCallback
;
...
...
@@ -542,7 +542,7 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
assert
(
pQueryInfo
->
numOfTables
==
1
);
// for projection query, need to try next vnode if current vnode is exhausted
// if ((++pTableMetaInfo->
dnode
Index) < pTableMetaInfo->pMetricMeta->numOfVnodes) {
// if ((++pTableMetaInfo->
vgroup
Index) < pTableMetaInfo->pMetricMeta->numOfVnodes) {
// pSupporter->pState->numOfCompleted = 0;
// pSupporter->pState->numOfTotal = 1;
//
...
...
@@ -609,7 +609,7 @@ void tscFetchDatablockFromSubquery(SSqlObj* pSql) {
// STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
if
(
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
))
{
// if (pRes->row >= pRes->numOfRows && pTableMetaInfo->
dnode
Index < pTableMetaInfo->pMetricMeta->numOfVnodes &&
// if (pRes->row >= pRes->numOfRows && pTableMetaInfo->
vgroup
Index < pTableMetaInfo->pMetricMeta->numOfVnodes &&
// (!tscHasReachLimitation(pQueryInfo, pRes))) {
// numOfFetch++;
// }
...
...
@@ -647,8 +647,8 @@ void tscFetchDatablockFromSubquery(SSqlObj* pSql) {
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
if
(
pRes1
->
row
>=
pRes1
->
numOfRows
)
{
tscTrace
(
"%p subquery:%p retrieve data from vnode, subquery:%d,
dnode
Index:%d"
,
pSql
,
pSql1
,
pSupporter
->
subqueryIndex
,
pTableMetaInfo
->
dnode
Index
);
tscTrace
(
"%p subquery:%p retrieve data from vnode, subquery:%d,
vgroup
Index:%d"
,
pSql
,
pSql1
,
pSupporter
->
subqueryIndex
,
pTableMetaInfo
->
vgroup
Index
);
tscResetForNextRetrieve
(
pRes1
);
pSql1
->
fp
=
joinRetrieveCallback
;
...
...
@@ -785,11 +785,11 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) {
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
/**
* if the query is a continue query (
dnode
Index > 0 for projection query) for next vnode, do the retrieval of
* if the query is a continue query (
vgroup
Index > 0 for projection query) for next vnode, do the retrieval of
* data instead of returning to its invoker
*/
if
(
pTableMetaInfo
->
dnode
Index
>
0
&&
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
))
{
// assert(pTableMetaInfo->
dnode
Index < pTableMetaInfo->pMetricMeta->numOfVnodes);
if
(
pTableMetaInfo
->
vgroup
Index
>
0
&&
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
))
{
// assert(pTableMetaInfo->
vgroup
Index < pTableMetaInfo->pMetricMeta->numOfVnodes);
pSupporter
->
pState
->
numOfCompleted
=
0
;
// reset the record value
pSql
->
fp
=
joinRetrieveCallback
;
// continue retrieve data
...
...
@@ -897,14 +897,14 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSubquerySu
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"
,
pSql
,
pNew
,
tableIndex
,
pTableMetaInfo
->
dnode
Index
,
pNewQueryInfo
->
type
,
pSql
,
pNew
,
tableIndex
,
pTableMetaInfo
->
vgroup
Index
,
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, "
"exprInfo:%d, colList:%d, fieldsInfo:%d, name:%s"
,
pSql
,
pNew
,
tableIndex
,
pTableMetaInfo
->
dnode
Index
,
pNewQueryInfo
->
type
,
pSql
,
pNew
,
tableIndex
,
pTableMetaInfo
->
vgroup
Index
,
pNewQueryInfo
->
type
,
pNewQueryInfo
->
exprsInfo
.
numOfExprs
,
pNewQueryInfo
->
colList
.
numOfCols
,
pNewQueryInfo
->
fieldsInfo
.
numOfOutputCols
,
pNewQueryInfo
->
pTableMetaInfo
[
0
]
->
name
);
tscPrintSelectClause
(
pNew
,
0
);
...
...
@@ -1005,7 +1005,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
pSql
->
numOfSubs
=
pTableMetaInfo
->
vgroupList
->
numOf
Dnode
s
;
pSql
->
numOfSubs
=
pTableMetaInfo
->
vgroupList
->
numOf
Vgroup
s
;
assert
(
pSql
->
numOfSubs
>
0
);
int32_t
ret
=
tscLocalReducerEnvCreate
(
pSql
,
&
pMemoryBuf
,
&
pDesc
,
&
pModel
,
nBufferSize
);
...
...
@@ -1241,7 +1241,7 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
// data in from current vnode is stored in cache and disk
uint32_t
numOfRowsFromSubquery
=
trsupport
->
pExtMemBuffer
[
idx
]
->
numOfTotalElems
+
trsupport
->
localBuffer
->
numOfElems
;
tscTrace
(
"%p sub:%p all data retrieved from ip:%u,vgId:%d, numOfRows:%d, orderOfSub:%d"
,
pPObj
,
pSql
,
pTableMetaInfo
->
vgroupList
->
dnodeVgroups
[
0
].
ipAddr
.
ip
,
pTableMetaInfo
->
vgroupList
->
dnodeVgroups
[
0
].
vgId
[
0
]
,
pTableMetaInfo
->
vgroupList
->
vgroups
[
0
].
ipAddr
[
0
].
ip
,
pTableMetaInfo
->
vgroupList
->
vgroups
[
0
].
vgId
,
numOfRowsFromSubquery
,
idx
);
tColModelCompact
(
pDesc
->
pColumnModel
,
trsupport
->
localBuffer
,
pDesc
->
pColumnModel
->
capacity
);
...
...
@@ -1401,9 +1401,9 @@ static SSqlObj *tscCreateSqlObjForSubquery(SSqlObj *pSql, SRetrieveSupport *trsu
assert
(
pQueryInfo
->
numOfTables
==
1
&&
pNew
->
cmd
.
numOfClause
==
1
);
// launch subquery for each vnode, so the subquery index equals to the
dnode
Index.
// launch subquery for each vnode, so the subquery index equals to the
vgroup
Index.
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
table_index
);
pTableMetaInfo
->
dnode
Index
=
trsupport
->
subqueryIndex
;
pTableMetaInfo
->
vgroup
Index
=
trsupport
->
subqueryIndex
;
pSql
->
pSubs
[
trsupport
->
subqueryIndex
]
=
pNew
;
}
...
...
@@ -1421,7 +1421,7 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
assert
(
pSql
->
cmd
.
numOfClause
==
1
&&
pQueryInfo
->
numOfTables
==
1
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pSql
->
cmd
,
0
,
0
);
S
TableDnodeVgroupInfo
*
pVgroupInfo
=
&
pTableMetaInfo
->
vgroupList
->
dnodeV
groups
[
0
];
S
CMVgroupInfo
*
pVgroup
=
&
pTableMetaInfo
->
vgroupList
->
v
groups
[
0
];
SSubqueryState
*
pState
=
trsupport
->
pState
;
assert
(
pState
->
numOfCompleted
<
pState
->
numOfTotal
&&
pState
->
numOfCompleted
>=
0
&&
...
...
@@ -1459,7 +1459,7 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
SSqlObj
*
pNew
=
tscCreateSqlObjForSubquery
(
pParentSql
,
trsupport
,
pSql
);
if
(
pNew
==
NULL
)
{
tscError
(
"%p sub:%p failed to create new subquery due to out of memory, abort retry, vgId:%d, orderOfSub:%d"
,
trsupport
->
pParentSqlObj
,
pSql
,
pVgroup
Info
->
vgId
[
0
]
,
trsupport
->
subqueryIndex
);
trsupport
->
pParentSqlObj
,
pSql
,
pVgroup
->
vgId
,
trsupport
->
subqueryIndex
);
pState
->
code
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
trsupport
->
numOfRetry
=
MAX_NUM_OF_SUBQUERY_RETRY
;
...
...
@@ -1475,12 +1475,12 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
if
(
pState
->
code
!=
TSDB_CODE_SUCCESS
)
{
// at least one peer subquery failed, abort current query
tscTrace
(
"%p sub:%p query failed,ip:%u,vgId:%d,orderOfSub:%d,global code:%d"
,
pParentSql
,
pSql
,
pVgroup
Info
->
ipAddr
.
ip
,
pVgroupInfo
->
vgId
[
0
]
,
trsupport
->
subqueryIndex
,
pState
->
code
);
pVgroup
->
ipAddr
[
0
].
ip
,
pVgroup
->
vgId
,
trsupport
->
subqueryIndex
,
pState
->
code
);
tscHandleSubqueryError
(
param
,
tres
,
pState
->
code
);
}
else
{
// success, proceed to retrieve data from dnode
tscTrace
(
"%p sub:%p query complete, ip:%u, vgId:%d, orderOfSub:%d,retrieve data"
,
trsupport
->
pParentSqlObj
,
pSql
,
pVgroup
Info
->
ipAddr
.
ip
,
pVgroupInfo
->
vgId
[
0
]
,
trsupport
->
subqueryIndex
);
pVgroup
->
ipAddr
[
0
].
ip
,
pVgroup
->
vgId
,
trsupport
->
subqueryIndex
);
taos_fetch_rows_a
(
tres
,
tscRetrieveFromDnodeCallBack
,
param
);
}
...
...
src/client/src/tscSystem.c
浏览文件 @
9b6c8a30
...
...
@@ -171,17 +171,49 @@ void taos_init_imp() {
if
(
0
==
tscEmbedded
){
taosTmrReset
(
tscCheckDiskUsage
,
10
,
NULL
,
tscTmr
,
&
tscCheckDiskUsageTmr
);
}
int64_t
refreshTime
=
tsMetricMetaKeepTimer
<
tsMeterMetaKeepTimer
?
tsMetricMetaKeepTimer
:
tsMeterMetaKeepTimer
;
refreshTime
=
refreshTime
>
2
?
2
:
refreshTime
;
refreshTime
=
refreshTime
<
1
?
1
:
refreshTime
;
if
(
tscCacheHandle
==
NULL
)
tscCacheHandle
=
taosCacheInit
(
tscTmr
,
refreshTime
);
if
(
tscCacheHandle
==
NULL
)
{
tscCacheHandle
=
taosCacheInit
(
tscTmr
,
refreshTime
);
}
tscTrace
(
"client is initialized successfully"
);
}
void
taos_init
()
{
pthread_once
(
&
tscinit
,
taos_init_imp
);
}
void
taos_cleanup
()
{
if
(
tscCacheHandle
!=
NULL
)
{
taosCacheCleanup
(
tscCacheHandle
);
}
if
(
tscQhandle
!=
NULL
)
{
taosCleanUpScheduler
(
tscQhandle
);
tscQhandle
=
NULL
;
}
taosCloseLogger
();
if
(
pVnodeConn
!=
NULL
)
{
rpcClose
(
pVnodeConn
);
pVnodeConn
=
NULL
;
}
if
(
pTscMgmtConn
!=
NULL
)
{
rpcClose
(
pTscMgmtConn
);
pTscMgmtConn
=
NULL
;
}
if
(
tsGlobalConfig
!=
NULL
)
{
tfree
(
tsGlobalConfig
);
}
taosTmrCleanUp
(
tscTmr
);
}
static
int
taos_options_imp
(
TSDB_OPTION
option
,
const
char
*
pStr
)
{
SGlobalConfig
*
cfg
=
NULL
;
...
...
src/client/src/tscUtil.c
浏览文件 @
9b6c8a30
...
...
@@ -1937,9 +1937,9 @@ STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, ST
pTableMetaInfo
->
numOfTags
=
numOfTags
;
if
(
vgroupList
!=
NULL
)
{
assert
(
vgroupList
->
numOf
Dnode
s
==
1
);
// todo fix me
size_t
size
=
sizeof
(
SVgroupsInfo
)
+
(
sizeof
(
STableDnodeVgroupInfo
)
+
vgroupList
->
dnodeVgroups
[
0
].
numOfVgroups
*
sizeof
(
int32_t
))
*
vgroupList
->
numOfDnode
s
;
assert
(
vgroupList
->
numOf
Vgroup
s
==
1
);
// todo fix me
size_t
size
=
sizeof
(
SVgroupsInfo
)
+
sizeof
(
SCMVgroupInfo
)
*
vgroupList
->
numOfVgroup
s
;
pTableMetaInfo
->
vgroupList
=
malloc
(
size
);
memcpy
(
pTableMetaInfo
->
vgroupList
,
vgroupList
,
size
);
...
...
@@ -2020,7 +2020,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
pNew
->
sqlstr
=
strdup
(
pSql
->
sqlstr
);
if
(
pNew
->
sqlstr
==
NULL
)
{
tscError
(
"%p new subquery failed, tableIndex:%d,
dnodeIndex:%d"
,
pSql
,
tableIndex
,
pTableMetaInfo
->
dnode
Index
);
tscError
(
"%p new subquery failed, tableIndex:%d,
vgroupIndex:%d"
,
pSql
,
tableIndex
,
pTableMetaInfo
->
vgroup
Index
);
free
(
pNew
);
return
NULL
;
...
...
@@ -2064,7 +2064,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
}
if
(
tscAllocPayload
(
pnCmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
)
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"%p new subquery failed, tableIndex:%d,
dnodeIndex:%d"
,
pSql
,
tableIndex
,
pTableMetaInfo
->
dnode
Index
);
tscError
(
"%p new subquery failed, tableIndex:%d,
vgroupIndex:%d"
,
pSql
,
tableIndex
,
pTableMetaInfo
->
vgroup
Index
);
tscFreeSqlObj
(
pNew
);
return
NULL
;
}
...
...
@@ -2155,13 +2155,13 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
tscTrace
(
"%p new subquery: %p, tableIndex:%d, vnodeIdx:%d, type:%d, exprInfo:%d, colList:%d,"
"fieldInfo:%d, name:%s, qrang:%"
PRId64
" - %"
PRId64
" order:%d, limit:%"
PRId64
,
pSql
,
pNew
,
tableIndex
,
pTableMetaInfo
->
dnode
Index
,
pNewQueryInfo
->
type
,
pNewQueryInfo
->
exprsInfo
.
numOfExprs
,
pSql
,
pNew
,
tableIndex
,
pTableMetaInfo
->
vgroup
Index
,
pNewQueryInfo
->
type
,
pNewQueryInfo
->
exprsInfo
.
numOfExprs
,
pNewQueryInfo
->
colList
.
numOfCols
,
pNewQueryInfo
->
fieldsInfo
.
numOfOutputCols
,
pFinalInfo
->
name
,
pNewQueryInfo
->
stime
,
pNewQueryInfo
->
etime
,
pNewQueryInfo
->
order
.
order
,
pNewQueryInfo
->
limit
.
limit
);
tscPrintSelectClause
(
pNew
,
0
);
}
else
{
tscTrace
(
"%p new sub insertion: %p, vnodeIdx:%d"
,
pSql
,
pNew
,
pTableMetaInfo
->
dnode
Index
);
tscTrace
(
"%p new sub insertion: %p, vnodeIdx:%d"
,
pSql
,
pNew
,
pTableMetaInfo
->
vgroup
Index
);
}
return
pNew
;
...
...
@@ -2258,7 +2258,7 @@ bool hasMoreVnodesToTry(SSqlObj* pSql) {
// int32_t totalVnode = pTableMetaInfo->pMetricMeta->numOfVnodes;
// return pRes->numOfRows == 0 && tscNonOrderedProjectionQueryOnSTable(pQueryInfo, 0) &&
// (!tscHasReachLimitation(pQueryInfo, pRes)) && (pTableMetaInfo->
dnode
Index < totalVnode - 1);
// (!tscHasReachLimitation(pQueryInfo, pRes)) && (pTableMetaInfo->
vgroup
Index < totalVnode - 1);
}
void
tscTryQueryNextVnode
(
SSqlObj
*
pSql
,
__async_cb_func_t
fp
)
{
...
...
@@ -2277,9 +2277,9 @@ void tscTryQueryNextVnode(SSqlObj* pSql, __async_cb_func_t fp) {
int32_t
totalVnode
=
0
;
// int32_t totalVnode = pTableMetaInfo->pMetricMeta->numOfVnodes;
while
(
++
pTableMetaInfo
->
dnode
Index
<
totalVnode
)
{
while
(
++
pTableMetaInfo
->
vgroup
Index
<
totalVnode
)
{
tscTrace
(
"%p current vnode:%d exhausted, try next:%d. total vnode:%d. current numOfRes:%d"
,
pSql
,
pTableMetaInfo
->
dnodeIndex
-
1
,
pTableMetaInfo
->
dnode
Index
,
totalVnode
,
pRes
->
numOfTotalInCurrentClause
);
pTableMetaInfo
->
vgroupIndex
-
1
,
pTableMetaInfo
->
vgroup
Index
,
totalVnode
,
pRes
->
numOfTotalInCurrentClause
);
/*
* update the limit and offset value for the query on the next vnode,
...
...
@@ -2298,7 +2298,7 @@ void tscTryQueryNextVnode(SSqlObj* pSql, __async_cb_func_t fp) {
assert
((
pRes
->
offset
>=
0
&&
pRes
->
numOfRows
==
0
)
||
(
pRes
->
offset
==
0
&&
pRes
->
numOfRows
>=
0
));
tscTrace
(
"%p new query to next vnode, vnode index:%d, limit:%"
PRId64
", offset:%"
PRId64
", glimit:%"
PRId64
,
pSql
,
pTableMetaInfo
->
dnode
Index
,
pQueryInfo
->
limit
.
limit
,
pQueryInfo
->
limit
.
offset
,
pQueryInfo
->
clauseLimit
);
pTableMetaInfo
->
vgroup
Index
,
pQueryInfo
->
limit
.
limit
,
pQueryInfo
->
limit
.
offset
,
pQueryInfo
->
clauseLimit
);
/*
* For project query with super table join, the numOfSub is equalled to the number of all subqueries.
...
...
src/inc/taos.h
浏览文件 @
9b6c8a30
...
...
@@ -52,6 +52,7 @@ typedef struct taosField {
#endif
DLL_EXPORT
void
taos_init
();
DLL_EXPORT
void
taos_cleanup
();
DLL_EXPORT
int
taos_options
(
TSDB_OPTION
option
,
const
void
*
arg
,
...);
DLL_EXPORT
TAOS
*
taos_connect
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
db
,
uint16_t
port
);
DLL_EXPORT
void
taos_close
(
TAOS
*
taos
);
...
...
src/inc/taosmsg.h
浏览文件 @
9b6c8a30
...
...
@@ -674,7 +674,7 @@ typedef struct {
}
SSuperTableMetaMsg
;
typedef
struct
{
SVnodeDesc
vpeerDesc
[
TSDB_
VNODES_SUPPORT
];
SVnodeDesc
vpeerDesc
[
TSDB_
REPLICA_MAX_NUM
];
int16_t
index
;
// used locally
int32_t
numOfSids
;
int32_t
pSidExtInfoList
[];
// offset value of STableIdInfo
...
...
src/kit/shell/inc/shell.h
浏览文件 @
9b6c8a30
...
...
@@ -71,7 +71,7 @@ extern void* shellLoopQuery(void* arg);
extern
void
taos_error
(
TAOS
*
con
);
extern
int
regex_match
(
const
char
*
s
,
const
char
*
reg
,
int
cflags
);
void
shellReadCommand
(
TAOS
*
con
,
char
command
[]);
void
shellRunCommand
(
TAOS
*
con
,
char
*
command
);
int32_t
shellRunCommand
(
TAOS
*
con
,
char
*
command
);
void
shellRunCommandOnServer
(
TAOS
*
con
,
char
command
[]);
void
read_history
();
void
write_history
();
...
...
src/kit/shell/src/shellEngine.c
浏览文件 @
9b6c8a30
...
...
@@ -166,10 +166,10 @@ void shellReplaceCtrlChar(char *str) {
*
pstr
=
'\0'
;
}
void
shellRunCommand
(
TAOS
*
con
,
char
*
command
)
{
int32_t
shellRunCommand
(
TAOS
*
con
,
char
*
command
)
{
/* If command is empty just return */
if
(
regex_match
(
command
,
"^[
\t
;]*$"
,
REG_EXTENDED
))
{
return
;
return
0
;
}
/* Update the history vector. */
...
...
@@ -193,11 +193,11 @@ void shellRunCommand(TAOS *con, char *command) {
if
(
regex_match
(
command
,
"^[
\t
]*(quit|q|exit)[
\t
;]*$"
,
REG_EXTENDED
|
REG_ICASE
))
{
taos_close
(
con
);
write_history
();
exitShell
()
;
return
-
1
;
}
else
if
(
regex_match
(
command
,
"^[
\t
]*clear[
\t
;]*$"
,
REG_EXTENDED
|
REG_ICASE
))
{
// If clear the screen.
system
(
"clear"
);
return
;
return
0
;
}
else
if
(
regex_match
(
command
,
"^[
\t
]*source[
\t
]+[^ ]+[
\t
;]*$"
,
REG_EXTENDED
|
REG_ICASE
))
{
/* If source file. */
char
*
c_ptr
=
strtok
(
command
,
" ;"
);
...
...
@@ -209,6 +209,8 @@ void shellRunCommand(TAOS *con, char *command) {
}
else
{
shellRunCommandOnServer
(
con
,
command
);
}
return
0
;
}
void
shellRunCommandOnServer
(
TAOS
*
con
,
char
command
[])
{
...
...
src/kit/shell/src/shellLinux.c
浏览文件 @
9b6c8a30
...
...
@@ -295,6 +295,7 @@ void *shellLoopQuery(void *arg) {
tscError
(
"failed to malloc command"
);
return
NULL
;
}
while
(
1
)
{
// Read command from shell.
...
...
@@ -304,11 +305,16 @@ void *shellLoopQuery(void *arg) {
reset_terminal_mode
();
// Run the command
shellRunCommand
(
con
,
command
);
if
(
shellRunCommand
(
con
,
command
)
!=
0
)
{
break
;
}
}
tfree
(
command
);
exitShell
();
pthread_cleanup_pop
(
1
);
return
NULL
;
}
...
...
@@ -487,6 +493,7 @@ void showOnScreen(Command *cmd) {
void
cleanup_handler
(
void
*
arg
)
{
tcsetattr
(
0
,
TCSANOW
,
&
oldtio
);
}
void
exitShell
()
{
tcsetattr
(
0
,
TCSANOW
,
&
oldtio
);
/*int32_t ret =*/
tcsetattr
(
STDIN_FILENO
,
TCSANOW
,
&
oldtio
);
taos_cleanup
();
exit
(
EXIT_SUCCESS
);
}
src/kit/shell/src/shellMain.c
浏览文件 @
9b6c8a30
...
...
@@ -95,7 +95,7 @@ int main(int argc, char* argv[]) {
exit
(
EXIT_FAILURE
);
}
/* Interupt handler. */
/* Inter
r
upt handler. */
struct
sigaction
act
;
memset
(
&
act
,
0
,
sizeof
(
struct
sigaction
));
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
9b6c8a30
...
...
@@ -732,7 +732,6 @@ static int32_t tdInsertRowToTable(STsdbRepo *pRepo, SDataRow row, STable *pTable
if
(
key
<
pTable
->
mem
->
keyFirst
)
pTable
->
mem
->
keyFirst
=
key
;
pTable
->
mem
->
numOfPoints
=
tSkipListGetSize
(
pTable
->
mem
->
pData
);
// pTable->mem->numOfPoints++;
return
0
;
}
...
...
src/util/src/hash.c
浏览文件 @
9b6c8a30
...
...
@@ -101,8 +101,6 @@ static void doUpdateHashTable(SHashObj *pHashObj, SHashNode *pNode) {
if
(
pNode
->
next
)
{
(
pNode
->
next
)
->
prev
=
pNode
;
}
pTrace
(
"key:%s %p update hash table"
,
pNode
->
key
,
pNode
);
}
/**
...
...
@@ -153,18 +151,18 @@ static void taosHashTableResize(SHashObj *pHashObj) {
SHashNode
*
pNode
=
NULL
;
SHashNode
*
pNext
=
NULL
;
int32_t
newSize
=
pHashObj
->
capacity
<<
1
U
;
int32_t
newSize
=
pHashObj
->
capacity
<<
1
u
;
if
(
newSize
>
HASH_MAX_CAPACITY
)
{
pTrace
(
"current capacity:%d, maximum capacity:%d, no resize applied due to limitation is reached"
,
pHashObj
->
capacity
,
HASH_MAX_CAPACITY
);
//
pTrace("current capacity:%d, maximum capacity:%d, no resize applied due to limitation is reached",
//
pHashObj->capacity, HASH_MAX_CAPACITY);
return
;
}
int64_t
st
=
taosGetTimestampUs
();
//
int64_t st = taosGetTimestampUs();
SHashEntry
**
pNewEntry
=
realloc
(
pHashObj
->
hashList
,
sizeof
(
SHashEntry
*
)
*
newSize
);
if
(
pNewEntry
==
NULL
)
{
pTrace
(
"cache resize failed due to out of memory, capacity remain:%d"
,
pHashObj
->
capacity
);
//
pTrace("cache resize failed due to out of memory, capacity remain:%d", pHashObj->capacity);
return
;
}
...
...
@@ -230,10 +228,9 @@ static void taosHashTableResize(SHashObj *pHashObj) {
}
}
int64_t
et
=
taosGetTimestampUs
();
pTrace
(
"hash table resize completed, new capacity:%d, load factor:%f, elapsed time:%fms"
,
pHashObj
->
capacity
,
((
double
)
pHashObj
->
size
)
/
pHashObj
->
capacity
,
(
et
-
st
)
/
1000
.
0
);
// int64_t et = taosGetTimestampUs();
// pTrace("hash table resize completed, new capacity:%d, load factor:%f, elapsed time:%fms", pHashObj->capacity,
// ((double)pHashObj->size) / pHashObj->capacity, (et - st) / 1000.0);
}
/**
...
...
src/util/src/ttimer.c
浏览文件 @
9b6c8a30
...
...
@@ -562,7 +562,7 @@ void taosTmrCleanUp(void* handle) {
pthread_mutex_unlock
(
&
tmrCtrlMutex
);
if
(
numOfTmrCtrl
<=
0
)
{
pthread_cancel
(
athread
);
//
pthread_cancel(athread);
for
(
int
i
=
0
;
i
<
tListLen
(
wheels
);
i
++
)
{
time_wheel_t
*
wheel
=
wheels
+
i
;
...
...
tests/examples/c/demo.c
浏览文件 @
9b6c8a30
...
...
@@ -75,6 +75,7 @@ int main(int argc, char *argv[]) {
doQuery
(
taos
,
"create database if not exists test"
);
doQuery
(
taos
,
"use test"
);
doQuery
(
taos
,
"insert into tm99 values('2020-01-01 1:1:1', 99);"
);
// doQuery(taos, "create table if not exists tm0 (ts timestamp, k int);");
// doQuery(taos, "insert into tm0 values('2020-1-1 1:1:1', 1);");
// doQuery(taos, "insert into tm0 values('2020-1-1 1:1:2', 2);");
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录