Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
d1828544
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看板
提交
d1828544
编写于
3月 19, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-32] refactor the table meta
上级
9f8178d0
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
208 addition
and
209 deletion
+208
-209
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+3
-3
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+2
-2
src/client/src/tscAsync.c
src/client/src/tscAsync.c
+7
-7
src/client/src/tscJoinProcess.c
src/client/src/tscJoinProcess.c
+9
-9
src/client/src/tscLocal.c
src/client/src/tscLocal.c
+5
-5
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+10
-10
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+66
-64
src/client/src/tscSecondaryMerge.c
src/client/src/tscSecondaryMerge.c
+10
-10
src/client/src/tscServer.c
src/client/src/tscServer.c
+41
-64
src/client/src/tscSql.c
src/client/src/tscSql.c
+3
-3
src/client/src/tscStream.c
src/client/src/tscStream.c
+3
-3
src/client/src/tscSub.c
src/client/src/tscSub.c
+2
-2
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+24
-24
src/inc/taosmsg.h
src/inc/taosmsg.h
+1
-1
tests/examples/c/demo.c
tests/examples/c/demo.c
+22
-2
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
d1828544
...
...
@@ -191,7 +191,7 @@ bool tscShouldFreeAsyncSqlObj(SSqlObj* pSql);
void
tscRemoveAllMeterMetaInfo
(
SQueryInfo
*
pQueryInfo
,
const
char
*
address
,
bool
removeFromCache
);
STableMetaInfo
*
tscGetMeterMetaInfo
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
,
int32_t
tableIndex
);
STableMetaInfo
*
tscGetMet
erMetaInfoFromQuery
Info
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
STableMetaInfo
*
tscGetMet
a
Info
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
SQueryInfo
*
tscGetQueryInfoDetail
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
);
int32_t
tscGetQueryInfoDetailSafely
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
,
SQueryInfo
**
pQueryInfo
);
...
...
@@ -201,14 +201,14 @@ void tscClearMeterMetaInfo(STableMetaInfo* pTableMetaInfo, bool remov
STableMetaInfo
*
tscAddMeterMetaInfo
(
SQueryInfo
*
pQueryInfo
,
const
char
*
name
,
STableMeta
*
pTableMeta
,
SSuperTableMeta
*
pMetricMeta
,
int16_t
numOfTags
,
int16_t
*
tags
);
STableMetaInfo
*
tscAddEmptyMet
erMet
aInfo
(
SQueryInfo
*
pQueryInfo
);
STableMetaInfo
*
tscAddEmptyMetaInfo
(
SQueryInfo
*
pQueryInfo
);
int32_t
tscAddSubqueryInfo
(
SSqlCmd
*
pCmd
);
void
tscFreeSubqueryInfo
(
SSqlCmd
*
pCmd
);
void
tscClearSubqueryInfo
(
SSqlCmd
*
pCmd
);
void
tscGetMetricMetaCacheKey
(
SQueryInfo
*
pQueryInfo
,
char
*
keyStr
,
uint64_t
uid
);
int
tscGetMetricMeta
(
SSqlObj
*
pSql
,
int32_t
clauseIndex
);
int
tscGet
Meter
Meta
(
SSqlObj
*
pSql
,
STableMetaInfo
*
pTableMetaInfo
);
int
tscGet
Table
Meta
(
SSqlObj
*
pSql
,
STableMetaInfo
*
pTableMetaInfo
);
int
tscGetMeterMetaEx
(
SSqlObj
*
pSql
,
STableMetaInfo
*
pTableMetaInfo
,
bool
createIfNotExists
);
void
tscResetForNextRetrieve
(
SSqlRes
*
pRes
);
...
...
src/client/inc/tsclient.h
浏览文件 @
d1828544
...
...
@@ -238,7 +238,7 @@ typedef struct SDataBlockList {
typedef
struct
SQueryInfo
{
int16_t
command
;
// the command may be different for each subclause, so keep it seperately.
uint16_t
type
;
// query/insert/import type
char
interval
TimeUnit
;
char
sliding
TimeUnit
;
int64_t
etime
,
stime
;
int64_t
intervalTime
;
// aggregation time interval
...
...
@@ -254,7 +254,7 @@ typedef struct SQueryInfo {
SOrderVal
order
;
int16_t
interpoType
;
// interpolate type
int16_t
numOfTables
;
STableMetaInfo
**
p
Meter
Info
;
STableMetaInfo
**
p
TableMeta
Info
;
struct
STSBuf
*
tsBuf
;
int64_t
*
defaultVal
;
// default value for interpolation
char
*
msg
;
// pointer to the pCmd->payload to keep error message temporarily
...
...
src/client/src/tscAsync.c
浏览文件 @
d1828544
...
...
@@ -407,7 +407,7 @@ void tscAsyncInsertMultiVnodesProxy(void *param, TAOS_RES *tres, int numOfRows)
int32_t
index
=
0
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
index
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
assert
(
pQueryInfo
->
numOfTables
==
1
||
pQueryInfo
->
numOfTables
==
2
);
SDataBlockList
*
pDataBlocks
=
pCmd
->
pDataBlocks
;
...
...
@@ -441,7 +441,7 @@ void tscAsyncInsertMultiVnodesProxy(void *param, TAOS_RES *tres, int numOfRows)
int
tscSendMsgToServer
(
SSqlObj
*
pSql
);
void
tsc
Meter
MetaCallBack
(
void
*
param
,
TAOS_RES
*
res
,
int
code
)
{
void
tsc
Table
MetaCallBack
(
void
*
param
,
TAOS_RES
*
res
,
int
code
)
{
SSqlObj
*
pSql
=
(
SSqlObj
*
)
param
;
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
return
;
...
...
@@ -468,7 +468,7 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
);
assert
(
pTableMetaInfo
->
pTableMeta
==
NULL
);
tscGet
Meter
Meta
(
pSql
,
pTableMetaInfo
);
tscGet
Table
Meta
(
pSql
,
pTableMetaInfo
);
code
=
tscSendMsgToServer
(
pSql
);
if
(
code
!=
0
)
{
pRes
->
code
=
code
;
...
...
@@ -490,7 +490,7 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
if
((
pQueryInfo
->
type
&
TSDB_QUERY_TYPE_STABLE_SUBQUERY
)
==
TSDB_QUERY_TYPE_STABLE_SUBQUERY
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
assert
((
tscGetNumOfTags
(
pTableMetaInfo
->
pTableMeta
)
!=
0
)
&&
pTableMetaInfo
->
vnodeIndex
>=
0
&&
pSql
->
param
!=
NULL
);
SRetrieveSupport
*
trs
=
(
SRetrieveSupport
*
)
pSql
->
param
;
...
...
@@ -501,7 +501,7 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
tscTrace
(
"%p get metricMeta during super table query successfully"
,
pSql
);
code
=
tscGet
Meter
Meta
(
pSql
,
pTableMetaInfo
);
code
=
tscGet
Table
Meta
(
pSql
,
pTableMetaInfo
);
pRes
->
code
=
code
;
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
return
;
...
...
@@ -515,7 +515,7 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
tscTrace
(
"%p resend data to vnode in metermeta callback since sql has been parsed completed"
,
pSql
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
code
=
tscGet
Meter
Meta
(
pSql
,
pTableMetaInfo
);
code
=
tscGet
Table
Meta
(
pSql
,
pTableMetaInfo
);
assert
(
code
==
TSDB_CODE_SUCCESS
);
if
(
pTableMetaInfo
->
pTableMeta
)
{
...
...
@@ -530,7 +530,7 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
}
else
{
// stream computing
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
code
=
tscGet
Meter
Meta
(
pSql
,
pTableMetaInfo
);
code
=
tscGet
Table
Meta
(
pSql
,
pTableMetaInfo
);
pRes
->
code
=
code
;
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
return
;
...
...
src/client/src/tscJoinProcess.c
浏览文件 @
d1828544
...
...
@@ -315,7 +315,7 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
tscFieldInfoCalOffset
(
pNewQueryInfo
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pNewQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pNewQueryInfo
,
0
);
/*
* When handling the projection query, the offset value will be modified for table-table join, which is changed
...
...
@@ -339,7 +339,7 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
tscTrace
(
"%p subquery:%p tableIndex:%d, vnodeIdx:%d, type:%d, exprInfo:%d, colList:%d, fieldsInfo:%d, name:%s"
,
pSql
,
pNew
,
0
,
pTableMetaInfo
->
vnodeIndex
,
pNewQueryInfo
->
type
,
pNewQueryInfo
->
exprsInfo
.
numOfExprs
,
pNewQueryInfo
->
colList
.
numOfCols
,
pNewQueryInfo
->
fieldsInfo
.
numOfOutputCols
,
pNewQueryInfo
->
p
Meter
Info
[
0
]
->
name
);
pNewQueryInfo
->
fieldsInfo
.
numOfOutputCols
,
pNewQueryInfo
->
p
TableMeta
Info
[
0
]
->
name
);
}
//prepare the subqueries object failed, abort
...
...
@@ -450,7 +450,7 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
pSupporter
->
pTSBuf
=
pBuf
;
}
else
{
assert
(
pQueryInfo
->
numOfTables
==
1
);
// for subquery, only one metermetaInfo
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
tsBufMerge
(
pSupporter
->
pTSBuf
,
pBuf
,
pTableMetaInfo
->
vnodeIndex
);
tsBufDestory
(
pBuf
);
...
...
@@ -467,7 +467,7 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
//todo refactor
if
(
tscNonOrderedProjectionQueryOnSTable
(
pParentQueryInfo
,
0
))
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
assert
(
pQueryInfo
->
numOfTables
==
1
);
// for projection query, need to try next vnode
...
...
@@ -532,7 +532,7 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
}
if
(
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
)
&&
numOfRows
==
0
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
assert
(
pQueryInfo
->
numOfTables
==
1
);
// for projection query, need to try next vnode if current vnode is exhausted
...
...
@@ -600,7 +600,7 @@ void tscFetchDatablockFromSubquery(SSqlObj* pSql) {
SSqlRes
*
pRes
=
&
pSql
->
pSubs
[
i
]
->
res
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
pSubs
[
i
]
->
cmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
if
(
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
))
{
if
(
pRes
->
row
>=
pRes
->
numOfRows
&&
pTableMetaInfo
->
vnodeIndex
<
pTableMetaInfo
->
pMetricMeta
->
numOfVnodes
&&
...
...
@@ -638,7 +638,7 @@ void tscFetchDatablockFromSubquery(SSqlObj* pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd1
,
0
);
assert
(
pRes1
->
numOfRows
>=
0
&&
pQueryInfo
->
numOfTables
==
1
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
if
(
pRes1
->
row
>=
pRes1
->
numOfRows
)
{
tscTrace
(
"%p subquery:%p retrieve data from vnode, subquery:%d, vnodeIndex:%d"
,
pSql
,
pSql1
,
...
...
@@ -688,7 +688,7 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
int32_t
tableIndexOfSub
=
-
1
;
for
(
int32_t
j
=
0
;
j
<
pQueryInfo
->
numOfTables
;
++
j
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
j
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
j
);
if
(
pTableMetaInfo
->
pTableMeta
->
uid
==
pExpr
->
uid
)
{
tableIndexOfSub
=
j
;
break
;
...
...
@@ -776,7 +776,7 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) {
assert
(
finished
==
numOfTotal
);
tscSetupOutputColumnIndex
(
pParentSql
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
/**
* if the query is a continue query (vnodeIndex > 0 for projection query) for next vnode, do the retrieval of
...
...
src/client/src/tscLocal.c
浏览文件 @
d1828544
...
...
@@ -110,7 +110,7 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
// one column for each row
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
STableMeta
*
pMeta
=
pTableMetaInfo
->
pTableMeta
;
/*
...
...
@@ -267,7 +267,7 @@ static int32_t tscBuildMeterSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
static
int32_t
tscProcessDescribeTable
(
SSqlObj
*
pSql
)
{
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
assert
(
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
)
->
pTableMeta
!=
NULL
);
assert
(
tscGetMet
a
Info
(
pQueryInfo
,
0
)
->
pTableMeta
!=
NULL
);
const
int32_t
NUM_OF_DESCRIBE_TABLE_COLUMNS
=
4
;
const
int32_t
TYPE_COLUMN_LENGTH
=
16
;
...
...
@@ -292,7 +292,7 @@ static int tscBuildMetricTagProjectionResult(SSqlObj *pSql) {
SSqlRes
*
pRes
=
&
pSql
->
res
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
SSuperTableMeta
*
pMetricMeta
=
pTableMetaInfo
->
pMetricMeta
;
SSchema
*
pSchema
=
tscGetTableTagSchema
(
pTableMetaInfo
->
pTableMeta
);
...
...
@@ -345,7 +345,7 @@ static int tscBuildMetricTagSqlFunctionResult(SSqlObj *pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
SSuperTableMeta
*
pMetricMeta
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
)
->
pMetricMeta
;
SSuperTableMeta
*
pMetricMeta
=
tscGetMet
a
Info
(
pQueryInfo
,
0
)
->
pMetricMeta
;
int32_t
totalNumOfResults
=
1
;
// count function only produce one result
int32_t
rowLen
=
tscGetResRowLength
(
pQueryInfo
);
...
...
@@ -377,7 +377,7 @@ static int tscProcessQueryTags(SSqlObj *pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
STableMeta
*
pTableMeta
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
)
->
pTableMeta
;
STableMeta
*
pTableMeta
=
tscGetMet
a
Info
(
pQueryInfo
,
0
)
->
pTableMeta
;
if
(
pTableMeta
==
NULL
||
tscGetNumOfTags
(
pTableMeta
)
==
0
||
tscGetNumOfColumns
(
pTableMeta
)
==
0
)
{
strcpy
(
pCmd
->
payload
,
"invalid table"
);
pSql
->
res
.
code
=
TSDB_CODE_INVALID_TABLE
;
...
...
src/client/src/tscParseInsert.c
浏览文件 @
d1828544
...
...
@@ -759,7 +759,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
return
TSDB_CODE_INVALID_SQL
;
}
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
TABLE_INDEX
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
TABLE_INDEX
);
if
(
sToken
.
type
==
TK_USING
)
{
// create table if not exists according to the super table
index
=
0
;
...
...
@@ -773,14 +773,14 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
* the source super table is moved to the secondary position of the pTableMetaInfo list
*/
if
(
pQueryInfo
->
numOfTables
<
2
)
{
tscAddEmptyMet
erMet
aInfo
(
pQueryInfo
);
tscAddEmptyMetaInfo
(
pQueryInfo
);
}
STableMetaInfo
*
pSTableMeterMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
STABLE_INDEX
);
STableMetaInfo
*
pSTableMeterMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
STABLE_INDEX
);
setMeterID
(
pSTableMeterMetaInfo
,
&
sToken
,
pSql
);
strncpy
(
pTag
->
name
,
pSTableMeterMetaInfo
->
name
,
TSDB_TABLE_ID_LEN
);
code
=
tscGet
Meter
Meta
(
pSql
,
pSTableMeterMetaInfo
);
code
=
tscGet
Table
Meta
(
pSql
,
pSTableMeterMetaInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -937,7 +937,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
}
else
{
sql
=
sToken
.
z
;
}
code
=
tscGet
Meter
Meta
(
pSql
,
pTableMetaInfo
);
code
=
tscGet
Table
Meta
(
pSql
,
pTableMetaInfo
);
}
int32_t
len
=
cend
-
cstart
+
1
;
...
...
@@ -992,9 +992,9 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
assert
(
pQueryInfo
!=
NULL
);
if
(
pQueryInfo
->
numOfTables
==
0
)
{
pTableMetaInfo
=
tscAddEmptyMet
erMet
aInfo
(
pQueryInfo
);
pTableMetaInfo
=
tscAddEmptyMetaInfo
(
pQueryInfo
);
}
else
{
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
}
if
((
code
=
tscAllocPayload
(
pCmd
,
TSDB_PAYLOAD_SIZE
))
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -1340,7 +1340,7 @@ int tsParseSql(SSqlObj *pSql, bool multiVnodeInsertion) {
}
/*
* the pRes->code may be modified or even released by another thread in tsc
Meter
MetaCallBack
* the pRes->code may be modified or even released by another thread in tsc
Table
MetaCallBack
* function, so do NOT use pRes->code to determine if the getMeterMeta/getMetricMeta function
* invokes new threads to get data from mnode or simply retrieves data from cache.
*
...
...
@@ -1521,7 +1521,7 @@ void tscProcessMultiVnodesInsertFromFile(SSqlObj *pSql) {
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
STableDataBlocks
*
pDataBlock
=
NULL
;
int32_t
affected_rows
=
0
;
...
...
@@ -1555,7 +1555,7 @@ void tscProcessMultiVnodesInsertFromFile(SSqlObj *pSql) {
strncpy
(
pTableMetaInfo
->
name
,
pDataBlock
->
tableId
,
TSDB_TABLE_ID_LEN
);
memset
(
pDataBlock
->
pData
,
0
,
pDataBlock
->
nAllocSize
);
int32_t
ret
=
tscGet
Meter
Meta
(
pSql
,
pTableMetaInfo
);
int32_t
ret
=
tscGet
Table
Meta
(
pSql
,
pTableMetaInfo
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"%p get meter meta failed, abort"
,
pSql
);
continue
;
...
...
src/client/src/tscSQLParser.c
浏览文件 @
d1828544
...
...
@@ -151,7 +151,7 @@ static int setColumnFilterInfoForTimestamp(SQueryInfo* pQueryInfo, tVariant* pVa
strdequote
(
pVar
->
pz
);
char
*
seg
=
strnchr
(
pVar
->
pz
,
'-'
,
pVar
->
nLen
,
false
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
...
...
@@ -211,7 +211,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
int32_t
code
=
tscGetQueryInfoDetailSafely
(
pCmd
,
pCmd
->
clauseIndex
,
&
pQueryInfo
);
assert
(
pQueryInfo
->
numOfTables
==
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscAddEmptyMet
erMet
aInfo
(
pQueryInfo
);
STableMetaInfo
*
pTableMetaInfo
=
tscAddEmptyMetaInfo
(
pQueryInfo
);
pCmd
->
command
=
pInfo
->
type
;
...
...
@@ -378,7 +378,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
return
tscGet
Meter
Meta
(
pSql
,
pTableMetaInfo
);
return
tscGet
Table
Meta
(
pSql
,
pTableMetaInfo
);
}
case
TSDB_SQL_CFG_DNODE
:
{
...
...
@@ -589,7 +589,7 @@ int32_t parseIntervalClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
const
char
*
msg1
=
"invalid query expression"
;
const
char
*
msg2
=
"interval cannot be less than 10 ms"
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
if
(
pQuerySql
->
interval
.
type
==
0
||
pQuerySql
->
interval
.
n
==
0
)
{
...
...
@@ -608,7 +608,7 @@ int32_t parseIntervalClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
}
/* parser has filter the illegal type, no need to check here */
pQueryInfo
->
interval
TimeUnit
=
pQuerySql
->
interval
.
z
[
pQuerySql
->
interval
.
n
-
1
];
pQueryInfo
->
sliding
TimeUnit
=
pQuerySql
->
interval
.
z
[
pQuerySql
->
interval
.
n
-
1
];
// interval cannot be less than 10 milliseconds
if
(
pQueryInfo
->
intervalTime
<
tsMinIntervalTime
)
{
...
...
@@ -648,7 +648,7 @@ int32_t parseIntervalClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
int32_t
tableIndex
=
COLUMN_INDEX_INITIAL_VAL
;
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
i
);
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
i
);
if
(
pTableMetaInfo
->
pTableMeta
->
uid
==
uid
)
{
tableIndex
=
i
;
break
;
...
...
@@ -681,7 +681,7 @@ int32_t parseSlidingClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
const
char
*
msg0
=
"sliding value too small"
;
const
char
*
msg1
=
"sliding value no larger than the interval value"
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
SSQLToken
*
pSliding
=
&
pQuerySql
->
sliding
;
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
...
...
@@ -1249,7 +1249,7 @@ int32_t parseSelectClause(SSqlCmd* pCmd, int32_t clauseIndex, tSQLExprList* pSel
if
(
isSTable
)
{
pQueryInfo
->
type
|=
TSDB_QUERY_TYPE_STABLE_QUERY
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
int32_t
numOfCols
=
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
if
(
tscQueryMetricTags
(
pQueryInfo
))
{
// local handle the metric tag query
...
...
@@ -1284,7 +1284,7 @@ int32_t insertResultField(SQueryInfo* pQueryInfo, int32_t outputIndex, SColumnLi
}
SSqlExpr
*
doAddProjectCol
(
SQueryInfo
*
pQueryInfo
,
int32_t
outputIndex
,
int32_t
colIdx
,
int32_t
tableIndex
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
tableIndex
);
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
int32_t
numOfCols
=
tscGetNumOfColumns
(
pTableMeta
);
...
...
@@ -1307,7 +1307,7 @@ SSqlExpr* doAddProjectCol(SQueryInfo* pQueryInfo, int32_t outputIndex, int32_t c
}
void
addRequiredTagColumn
(
SQueryInfo
*
pQueryInfo
,
int32_t
tagColIndex
,
int32_t
tableIndex
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
tableIndex
);
if
(
pTableMetaInfo
->
numOfTags
==
0
||
pTableMetaInfo
->
tagColumnIndex
[
pTableMetaInfo
->
numOfTags
-
1
]
<
tagColIndex
)
{
pTableMetaInfo
->
tagColumnIndex
[
pTableMetaInfo
->
numOfTags
++
]
=
tagColIndex
;
...
...
@@ -1336,7 +1336,7 @@ void addRequiredTagColumn(SQueryInfo* pQueryInfo, int32_t tagColIndex, int32_t t
static
void
addProjectQueryCol
(
SQueryInfo
*
pQueryInfo
,
int32_t
startPos
,
SColumnIndex
*
pIndex
,
tSQLExprItem
*
pItem
)
{
SSqlExpr
*
pExpr
=
doAddProjectCol
(
pQueryInfo
,
startPos
,
pIndex
->
columnIndex
,
pIndex
->
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
pIndex
->
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
pIndex
->
tableIndex
);
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
SSchema
*
pSchema
=
tscGetTableColumnSchema
(
pTableMeta
,
pIndex
->
columnIndex
);
...
...
@@ -1374,16 +1374,18 @@ void tscAddSpecialColumnForSelect(SQueryInfo* pQueryInfo, int32_t outputColIndex
}
static
int32_t
doAddProjectionExprAndResultFields
(
SQueryInfo
*
pQueryInfo
,
SColumnIndex
*
pIndex
,
int32_t
startPos
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
pIndex
->
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
pIndex
->
tableIndex
);
int32_t
numOfTotalColumns
=
0
;
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMeta
);
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMeta
);
if
(
UTIL_METER_IS_SUPERTABLE
(
pTableMetaInfo
))
{
numOfTotalColumns
=
t
scGetNumOfColumns
(
pTableMeta
)
+
tscGetNumOfTags
(
pTableMeta
)
;
numOfTotalColumns
=
t
info
.
numOfColumns
+
tinfo
.
numOfTags
;
}
else
{
numOfTotalColumns
=
t
scGetNumOfColumns
(
pTableMeta
)
;
numOfTotalColumns
=
t
info
.
numOfColumns
;
}
for
(
int32_t
j
=
0
;
j
<
numOfTotalColumns
;
++
j
)
{
...
...
@@ -1439,7 +1441,7 @@ int32_t addProjectionExprAndResultField(SQueryInfo* pQueryInfo, tSQLExprItem* pI
pQueryInfo
->
type
=
TSDB_QUERY_TYPE_STABLE_QUERY
;
tscAddSpecialColumnForSelect
(
pQueryInfo
,
startPos
,
TSDB_FUNC_TAGPRJ
,
&
index
,
&
colSchema
,
true
);
}
else
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
index
.
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
index
.
tableIndex
);
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
if
(
index
.
columnIndex
>=
tscGetNumOfColumns
(
pTableMeta
)
&&
UTIL_METER_IS_NOMRAL_METER
(
pTableMetaInfo
))
{
...
...
@@ -1550,7 +1552,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg3
);
}
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
index
.
tableIndex
);
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
index
.
tableIndex
);
// count tag is equalled to count(tbname)
if
(
index
.
columnIndex
>=
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
))
{
...
...
@@ -1615,7 +1617,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
}
// 2. check if sql function can be applied on this column data type
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
index
.
tableIndex
);
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
index
.
tableIndex
);
SSchema
*
pSchema
=
tscGetTableColumnSchema
(
pTableMetaInfo
->
pTableMeta
,
index
.
columnIndex
);
int16_t
colType
=
pSchema
->
type
;
...
...
@@ -1723,7 +1725,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg4
);
}
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
index
.
tableIndex
);
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
index
.
tableIndex
);
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMetaInfo
->
pTableMeta
);
for
(
int32_t
j
=
0
;
j
<
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
++
j
)
{
...
...
@@ -1738,7 +1740,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg3
);
}
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
index
.
tableIndex
);
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
index
.
tableIndex
);
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMetaInfo
->
pTableMeta
);
// functions can not be applied to tags
...
...
@@ -1757,7 +1759,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
int32_t
numOfFields
=
0
;
for
(
int32_t
j
=
0
;
j
<
pQueryInfo
->
numOfTables
;
++
j
)
{
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
j
);
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
j
);
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMetaInfo
->
pTableMeta
);
for
(
int32_t
i
=
0
;
i
<
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
++
i
)
{
...
...
@@ -1794,7 +1796,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg3
);
}
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
index
.
tableIndex
);
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
index
.
tableIndex
);
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMetaInfo
->
pTableMeta
);
// functions can not be applied to tags
...
...
@@ -1928,7 +1930,7 @@ static bool isTablenameToken(SSQLToken* token) {
}
static
int16_t
doGetColumnIndex
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
,
SSQLToken
*
pToken
)
{
STableMeta
*
pTableMeta
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
index
)
->
pTableMeta
;
STableMeta
*
pTableMeta
=
tscGetMet
a
Info
(
pQueryInfo
,
index
)
->
pTableMeta
;
int32_t
numOfCols
=
tscGetNumOfColumns
(
pTableMeta
)
+
tscGetNumOfTags
(
pTableMeta
);
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMeta
);
...
...
@@ -2003,7 +2005,7 @@ int32_t getMeterIndex(SSQLToken* pTableToken, SQueryInfo* pQueryInfo, SColumnInd
char
tableName
[
TSDB_TABLE_ID_LEN
+
1
]
=
{
0
};
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
i
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
i
);
extractTableName
(
pTableMetaInfo
->
name
,
tableName
);
if
(
strncasecmp
(
tableName
,
pTableToken
->
z
,
pTableToken
->
n
)
==
0
&&
strlen
(
tableName
)
==
pTableToken
->
n
)
{
...
...
@@ -2031,7 +2033,7 @@ int32_t getTableIndexByName(SSQLToken* pToken, SQueryInfo* pQueryInfo, SColumnIn
}
int32_t
getColumnIndexByName
(
SSQLToken
*
pToken
,
SQueryInfo
*
pQueryInfo
,
SColumnIndex
*
pIndex
)
{
if
(
pQueryInfo
->
p
Meter
Info
==
NULL
||
pQueryInfo
->
numOfTables
==
0
)
{
if
(
pQueryInfo
->
p
TableMeta
Info
==
NULL
||
pQueryInfo
->
numOfTables
==
0
)
{
return
TSDB_CODE_INVALID_SQL
;
}
...
...
@@ -2247,7 +2249,7 @@ bool validateIpAddress(const char* ip, size_t size) {
}
int32_t
tscTansformSQLFunctionForSTableQuery
(
SQueryInfo
*
pQueryInfo
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
if
(
pTableMetaInfo
->
pTableMeta
==
NULL
||
!
UTIL_METER_IS_SUPERTABLE
(
pTableMetaInfo
))
{
return
TSDB_CODE_INVALID_SQL
;
...
...
@@ -2286,7 +2288,7 @@ int32_t tscTansformSQLFunctionForSTableQuery(SQueryInfo* pQueryInfo) {
/* transfer the field-info back to original input format */
void
tscRestoreSQLFunctionForMetricQuery
(
SQueryInfo
*
pQueryInfo
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
if
(
!
UTIL_METER_IS_SUPERTABLE
(
pTableMetaInfo
))
{
return
;
}
...
...
@@ -2383,7 +2385,7 @@ static bool functionCompatibleCheck(SQueryInfo* pQueryInfo) {
}
void
updateTagColumnIndex
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
tableIndex
);
/*
* update tags column index for group by tags
...
...
@@ -2492,7 +2494,7 @@ int32_t parseGroupbyClause(SQueryInfo* pQueryInfo, tVariantList* pList, SSqlCmd*
tableIndex
=
index
.
tableIndex
;
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
index
.
tableIndex
);
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
index
.
tableIndex
);
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
if
(
index
.
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
...
...
@@ -2573,7 +2575,7 @@ static int32_t doExtractColumnFilterInfo(SQueryInfo* pQueryInfo, SColumnFilterIn
const
char
*
msg
=
"not supported filter condition"
;
tSQLExpr
*
pRight
=
pExpr
->
pRight
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
columnIndex
->
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
columnIndex
->
tableIndex
);
SSchema
*
pSchema
=
tscGetTableColumnSchema
(
pTableMetaInfo
->
pTableMeta
,
columnIndex
->
columnIndex
);
...
...
@@ -2818,7 +2820,7 @@ enum {
};
static
int32_t
extractColumnFilterInfo
(
SQueryInfo
*
pQueryInfo
,
SColumnIndex
*
pIndex
,
tSQLExpr
*
pExpr
,
int32_t
sqlOptr
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
pIndex
->
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
pIndex
->
tableIndex
);
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
SSchema
*
pSchema
=
tscGetTableColumnSchema
(
pTableMeta
,
pIndex
->
columnIndex
);
...
...
@@ -2978,7 +2980,7 @@ static int32_t getJoinCondInfo(SQueryInfo* pQueryInfo, tSQLExpr* pExpr) {
return
TSDB_CODE_INVALID_SQL
;
}
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
index
.
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
index
.
tableIndex
);
int16_t
tagColIndex
=
index
.
columnIndex
-
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
pLeft
->
uid
=
pTableMetaInfo
->
pTableMeta
->
uid
;
...
...
@@ -2990,7 +2992,7 @@ static int32_t getJoinCondInfo(SQueryInfo* pQueryInfo, tSQLExpr* pExpr) {
return
TSDB_CODE_INVALID_SQL
;
}
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
index
.
tableIndex
);
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
index
.
tableIndex
);
tagColIndex
=
index
.
columnIndex
-
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
pRight
->
uid
=
pTableMetaInfo
->
pTableMeta
->
uid
;
...
...
@@ -3047,7 +3049,7 @@ static int32_t validateSQLExpr(tSQLExpr* pExpr, SQueryInfo* pQueryInfo, SColumnL
}
// if column is timestamp, bool, binary, nchar, not support arithmetic, so return invalid sql
STableMeta
*
pTableMeta
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
index
.
tableIndex
)
->
pTableMeta
;
STableMeta
*
pTableMeta
=
tscGetMet
a
Info
(
pQueryInfo
,
index
.
tableIndex
)
->
pTableMeta
;
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMeta
)
+
index
.
columnIndex
;
if
((
pSchema
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
||
(
pSchema
->
type
==
TSDB_DATA_TYPE_BOOL
)
||
...
...
@@ -3196,11 +3198,11 @@ static bool validateJoinExprNode(SQueryInfo* pQueryInfo, tSQLExpr* pExpr, SColum
}
// todo extract function
STableMetaInfo
*
pLeftMeterMeta
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
pLeftIndex
->
tableIndex
);
STableMetaInfo
*
pLeftMeterMeta
=
tscGetMet
a
Info
(
pQueryInfo
,
pLeftIndex
->
tableIndex
);
SSchema
*
pLeftSchema
=
tscGetTableSchema
(
pLeftMeterMeta
->
pTableMeta
);
int16_t
leftType
=
pLeftSchema
[
pLeftIndex
->
columnIndex
].
type
;
STableMetaInfo
*
pRightMeterMeta
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
rightIndex
.
tableIndex
);
STableMetaInfo
*
pRightMeterMeta
=
tscGetMet
a
Info
(
pQueryInfo
,
rightIndex
.
tableIndex
);
SSchema
*
pRightSchema
=
tscGetTableSchema
(
pRightMeterMeta
->
pTableMeta
);
int16_t
rightType
=
pRightSchema
[
rightIndex
.
columnIndex
].
type
;
...
...
@@ -3272,7 +3274,7 @@ static int32_t handleExprInQueryCond(SQueryInfo* pQueryInfo, tSQLExpr** pExpr, S
assert
(
isExprDirectParentOfLeaftNode
(
*
pExpr
));
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
index
.
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
index
.
tableIndex
);
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
if
(
index
.
columnIndex
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
// query on time range
...
...
@@ -3507,7 +3509,7 @@ static int32_t setTableCondForMetricQuery(SQueryInfo* pQueryInfo, const char* ac
return
TSDB_CODE_SUCCESS
;
}
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
tableCondIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
tableCondIndex
);
STagCond
*
pTagCond
=
&
pQueryInfo
->
tagCond
;
pTagCond
->
tbnameCond
.
uid
=
pTableMetaInfo
->
pTableMeta
->
uid
;
...
...
@@ -3618,7 +3620,7 @@ static int32_t getTimeRangeFromExpr(SQueryInfo* pQueryInfo, tSQLExpr* pExpr) {
return
TSDB_CODE_INVALID_SQL
;
}
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
index
.
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
index
.
tableIndex
);
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
tSQLExpr
*
pRight
=
pExpr
->
pRight
;
...
...
@@ -3656,7 +3658,7 @@ static int32_t validateJoinExpr(SQueryInfo* pQueryInfo, SCondExpr* pCondExpr) {
}
}
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
if
(
UTIL_METER_IS_SUPERTABLE
(
pTableMetaInfo
))
{
// for stable join, tag columns
// must be present for join
if
(
pCondExpr
->
pJoinExpr
==
NULL
)
{
...
...
@@ -3694,18 +3696,18 @@ static void cleanQueryExpr(SCondExpr* pCondExpr) {
}
static
void
doAddJoinTagsColumnsIntoTagList
(
SQueryInfo
*
pQueryInfo
,
SCondExpr
*
pCondExpr
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
if
(
QUERY_IS_JOIN_QUERY
(
pQueryInfo
->
type
)
&&
UTIL_METER_IS_SUPERTABLE
(
pTableMetaInfo
))
{
SColumnIndex
index
=
{
0
};
getColumnIndexByName
(
&
pCondExpr
->
pJoinExpr
->
pLeft
->
colInfo
,
pQueryInfo
,
&
index
);
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
index
.
tableIndex
);
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
index
.
tableIndex
);
int32_t
columnInfo
=
index
.
columnIndex
-
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
addRequiredTagColumn
(
pQueryInfo
,
columnInfo
,
index
.
tableIndex
);
getColumnIndexByName
(
&
pCondExpr
->
pJoinExpr
->
pRight
->
colInfo
,
pQueryInfo
,
&
index
);
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
index
.
tableIndex
);
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
index
.
tableIndex
);
columnInfo
=
index
.
columnIndex
-
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
addRequiredTagColumn
(
pQueryInfo
,
columnInfo
,
index
.
tableIndex
);
...
...
@@ -3719,7 +3721,7 @@ static int32_t getTagQueryCondExpr(SQueryInfo* pQueryInfo, SCondExpr* pCondExpr,
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
tSQLExpr
*
p1
=
extractExprForSTable
(
pExpr
,
pQueryInfo
,
i
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
i
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
i
);
char
c
[
TSDB_MAX_TAGS_LEN
]
=
{
0
};
char
*
str
=
c
;
...
...
@@ -4033,7 +4035,7 @@ int32_t parseFillClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySQL) {
static
void
setDefaultOrderInfo
(
SQueryInfo
*
pQueryInfo
)
{
/* set default timestamp order information for all queries */
pQueryInfo
->
order
.
order
=
TSQL_SO_ASC
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
if
(
isTopBottomQuery
(
pQueryInfo
))
{
pQueryInfo
->
order
.
order
=
TSQL_SO_ASC
;
...
...
@@ -4055,7 +4057,7 @@ int32_t parseOrderbyClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql, SSchema
const
char
*
msg3
=
"only support order by primary timestamp and first tag in groupby clause"
;
setDefaultOrderInfo
(
pQueryInfo
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
if
(
pQuerySql
->
pSortOrder
==
NULL
)
{
return
TSDB_CODE_SUCCESS
;
...
...
@@ -4207,7 +4209,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
SAlterTableSQL
*
pAlterSQL
=
pInfo
->
pAlterInfo
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
DEFAULT_TABLE_INDEX
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
DEFAULT_TABLE_INDEX
);
if
(
tscValidateName
(
&
(
pAlterSQL
->
name
))
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
...
...
@@ -4217,7 +4219,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg2
);
}
int32_t
ret
=
tscGet
Meter
Meta
(
pSql
,
pTableMetaInfo
);
int32_t
ret
=
tscGet
Table
Meta
(
pSql
,
pTableMetaInfo
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
}
...
...
@@ -4600,7 +4602,7 @@ bool hasTimestampForPointInterpQuery(SQueryInfo* pQueryInfo) {
}
int32_t
parseLimitClause
(
SQueryInfo
*
pQueryInfo
,
int32_t
clauseIndex
,
SQuerySQL
*
pQuerySql
,
SSqlObj
*
pSql
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
const
char
*
msg0
=
"soffset/offset can not be less than 0"
;
const
char
*
msg1
=
"slimit/soffset only available for STable query"
;
...
...
@@ -4821,7 +4823,7 @@ void addGroupInfoForSubquery(SSqlObj* pParentObj, SSqlObj* pSql, int32_t subClau
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
num
-
1
);
if
(
pExpr
->
functionId
!=
TSDB_FUNC_TAG
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
tableIndex
);
int16_t
columnInfo
=
tscGetJoinTagColIndexByUid
(
&
pQueryInfo
->
tagCond
,
pTableMetaInfo
->
pTableMeta
->
uid
);
SColumnIndex
index
=
{.
tableIndex
=
0
,
.
columnIndex
=
columnInfo
};
SSchema
*
pSchema
=
tscGetTableTagSchema
(
pTableMetaInfo
->
pTableMeta
);
...
...
@@ -4858,7 +4860,7 @@ static void doLimitOutputNormalColOfGroupby(SSqlExpr* pExpr) {
void
doAddGroupColumnForSubquery
(
SQueryInfo
*
pQueryInfo
,
int32_t
tagIndex
)
{
int32_t
index
=
pQueryInfo
->
groupbyExpr
.
columnInfo
[
tagIndex
].
colIdx
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
SSchema
*
pSchema
=
tscGetTableColumnSchema
(
pTableMetaInfo
->
pTableMeta
,
index
);
SColumnIndex
colIndex
=
{.
tableIndex
=
0
,
.
columnIndex
=
index
};
...
...
@@ -4892,7 +4894,7 @@ static void doUpdateSqlFunctionForTagPrj(SQueryInfo* pQueryInfo) {
}
}
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMetaInfo
->
pTableMeta
);
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
i
)
{
...
...
@@ -5068,7 +5070,7 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo) {
static
int32_t
doAddGroupbyColumnsOnDemand
(
SQueryInfo
*
pQueryInfo
)
{
const
char
*
msg2
=
"interval not allowed in group by normal column"
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMetaInfo
->
pTableMeta
);
int16_t
bytes
=
0
;
...
...
@@ -5378,7 +5380,7 @@ int32_t doCheckForCreateTable(SSqlObj* pSql, int32_t subClauseIndex, SSqlInfo* p
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
subClauseIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
SCreateTableSQL
*
pCreateTable
=
pInfo
->
pCreateTableInfo
;
...
...
@@ -5433,13 +5435,13 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
// two table: the first one is for current table, and the secondary is for the super table.
tscAddEmptyMet
erMet
aInfo
(
pQueryInfo
);
tscAddEmptyMetaInfo
(
pQueryInfo
);
assert
(
pQueryInfo
->
numOfTables
==
2
);
const
int32_t
TABLE_INDEX
=
0
;
const
int32_t
STABLE_INDEX
=
1
;
STableMetaInfo
*
pStableMeterMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
STABLE_INDEX
);
STableMetaInfo
*
pStableMeterMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
STABLE_INDEX
);
// super table name, create table by using dst
SSQLToken
*
pToken
=
&
(
pCreateTable
->
usingInfo
.
stableName
);
...
...
@@ -5456,7 +5458,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
strncpy
(
pCreateTable
->
usingInfo
.
tagdata
.
name
,
pStableMeterMetaInfo
->
name
,
TSDB_TABLE_ID_LEN
);
tVariantList
*
pList
=
pInfo
->
pCreateTableInfo
->
usingInfo
.
pTagVals
;
int32_t
code
=
tscGet
Meter
Meta
(
pSql
,
pStableMeterMetaInfo
);
int32_t
code
=
tscGet
Table
Meta
(
pSql
,
pStableMeterMetaInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -5489,7 +5491,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
STableMetaInfo
*
pTableMeterMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
TABLE_INDEX
);
STableMetaInfo
*
pTableMeterMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
TABLE_INDEX
);
int32_t
ret
=
setMeterID
(
pTableMeterMetaInfo
,
&
pInfo
->
pCreateTableInfo
->
name
,
pSql
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
...
...
@@ -5510,7 +5512,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
assert
(
pQueryInfo
->
numOfTables
==
1
);
SCreateTableSQL
*
pCreateTable
=
pInfo
->
pCreateTableInfo
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
// if sql specifies db, use it, otherwise use default db
SSQLToken
*
pzTableName
=
&
(
pCreateTable
->
name
);
...
...
@@ -5532,7 +5534,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg2
);
}
int32_t
code
=
tscGet
Meter
Meta
(
pSql
,
pTableMetaInfo
);
int32_t
code
=
tscGet
Table
Meta
(
pSql
,
pTableMetaInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -5617,9 +5619,9 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
index
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
if
(
pTableMetaInfo
==
NULL
)
{
pTableMetaInfo
=
tscAddEmptyMet
erMet
aInfo
(
pQueryInfo
);
pTableMetaInfo
=
tscAddEmptyMetaInfo
(
pQueryInfo
);
}
// too many result columns not support order by in query
...
...
@@ -5662,17 +5664,17 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
}
if
(
pQueryInfo
->
numOfTables
<=
i
)
{
// more than one table
tscAddEmptyMet
erMet
aInfo
(
pQueryInfo
);
tscAddEmptyMetaInfo
(
pQueryInfo
);
}
STableMetaInfo
*
pMeterInfo1
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
i
);
STableMetaInfo
*
pMeterInfo1
=
tscGetMet
a
Info
(
pQueryInfo
,
i
);
SSQLToken
t
=
{.
type
=
TSDB_DATA_TYPE_BINARY
,
.
n
=
pTableItem
->
nLen
,
.
z
=
pTableItem
->
pz
};
if
(
setMeterID
(
pMeterInfo1
,
&
t
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
code
=
tscGet
Meter
Meta
(
pSql
,
pMeterInfo1
);
code
=
tscGet
Table
Meta
(
pSql
,
pMeterInfo1
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
src/client/src/tscSecondaryMerge.c
浏览文件 @
d1828544
...
...
@@ -325,7 +325,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
int16_t
prec
=
tinfo
.
precision
;
int64_t
stime
=
(
pQueryInfo
->
stime
<
pQueryInfo
->
etime
)
?
pQueryInfo
->
stime
:
pQueryInfo
->
etime
;
int64_t
revisedSTime
=
taosGetIntervalStartTimestamp
(
stime
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
interval
TimeUnit
,
prec
);
taosGetIntervalStartTimestamp
(
stime
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
sliding
TimeUnit
,
prec
);
SInterpolationInfo
*
pInterpoInfo
=
&
pReducer
->
interpolationInfo
;
taosInitInterpoInfo
(
pInterpoInfo
,
pQueryInfo
->
order
.
order
,
revisedSTime
,
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
,
...
...
@@ -603,7 +603,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
*
pFinalModel
=
NULL
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
(
*
pMemBuffer
)
=
(
tExtMemBuffer
**
)
malloc
(
POINTER_BYTES
*
pTableMetaInfo
->
pMetricMeta
->
numOfVnodes
);
if
(
*
pMemBuffer
==
NULL
)
{
...
...
@@ -775,14 +775,14 @@ void adjustLoserTreeFromNewData(SLocalReducer *pLocalReducer, SLocalDataSource *
void
savePrevRecordAndSetupInterpoInfo
(
SLocalReducer
*
pLocalReducer
,
SQueryInfo
*
pQueryInfo
,
SInterpolationInfo
*
pInterpoInfo
)
{
// discard following dataset in the same group and reset the interpolation information
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
int16_t
prec
=
tinfo
.
precision
;
int64_t
stime
=
(
pQueryInfo
->
stime
<
pQueryInfo
->
etime
)
?
pQueryInfo
->
stime
:
pQueryInfo
->
etime
;
int64_t
revisedSTime
=
taosGetIntervalStartTimestamp
(
stime
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
interval
TimeUnit
,
prec
);
taosGetIntervalStartTimestamp
(
stime
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
sliding
TimeUnit
,
prec
);
taosInitInterpoInfo
(
pInterpoInfo
,
pQueryInfo
->
order
.
order
,
revisedSTime
,
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
,
pLocalReducer
->
rowSize
);
...
...
@@ -928,7 +928,7 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
while
(
1
)
{
int32_t
remains
=
taosNumOfRemainPoints
(
pInterpoInfo
);
TSKEY
etime
=
taosGetRevisedEndKey
(
actualETime
,
pQueryInfo
->
order
.
order
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
interval
TimeUnit
,
precision
);
pQueryInfo
->
sliding
TimeUnit
,
precision
);
int32_t
nrows
=
taosGetNumOfResultWithInterpo
(
pInterpoInfo
,
pPrimaryKeys
,
remains
,
pQueryInfo
->
intervalTime
,
etime
,
pLocalReducer
->
resColModel
->
capacity
);
...
...
@@ -1282,7 +1282,7 @@ static void resetEnvForNewResultset(SSqlRes *pRes, SSqlCmd *pCmd, SLocalReducer
if
(
pQueryInfo
->
interpoType
!=
TSDB_INTERPO_NONE
)
{
int64_t
stime
=
(
pQueryInfo
->
stime
<
pQueryInfo
->
etime
)
?
pQueryInfo
->
stime
:
pQueryInfo
->
etime
;
int64_t
newTime
=
taosGetIntervalStartTimestamp
(
stime
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
interval
TimeUnit
,
precision
);
taosGetIntervalStartTimestamp
(
stime
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
sliding
TimeUnit
,
precision
);
taosInitInterpoInfo
(
&
pLocalReducer
->
interpolationInfo
,
pQueryInfo
->
order
.
order
,
newTime
,
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
,
pLocalReducer
->
rowSize
);
...
...
@@ -1301,7 +1301,7 @@ static bool doInterpolationForCurrentGroup(SSqlObj *pSql) {
SLocalReducer
*
pLocalReducer
=
pRes
->
pLocalReducer
;
SInterpolationInfo
*
pInterpoInfo
=
&
pLocalReducer
->
interpolationInfo
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
int8_t
p
=
tinfo
.
precision
;
...
...
@@ -1314,7 +1314,7 @@ static bool doInterpolationForCurrentGroup(SSqlObj *pSql) {
int32_t
remain
=
taosNumOfRemainPoints
(
pInterpoInfo
);
TSKEY
ekey
=
taosGetRevisedEndKey
(
etime
,
pQueryInfo
->
order
.
order
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
interval
TimeUnit
,
p
);
taosGetRevisedEndKey
(
etime
,
pQueryInfo
->
order
.
order
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
sliding
TimeUnit
,
p
);
int32_t
rows
=
taosGetNumOfResultWithInterpo
(
pInterpoInfo
,
(
TSKEY
*
)
pLocalReducer
->
pBufForInterpo
,
remain
,
pQueryInfo
->
intervalTime
,
ekey
,
pLocalReducer
->
resColModel
->
capacity
);
if
(
rows
>
0
)
{
// do interpo
...
...
@@ -1337,7 +1337,7 @@ static bool doHandleLastRemainData(SSqlObj *pSql) {
bool
prevGroupCompleted
=
(
!
pLocalReducer
->
discard
)
&&
pLocalReducer
->
hasUnprocessedRow
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
int8_t
precision
=
tinfo
.
precision
;
...
...
@@ -1349,7 +1349,7 @@ static bool doHandleLastRemainData(SSqlObj *pSql) {
int64_t
etime
=
(
pQueryInfo
->
stime
<
pQueryInfo
->
etime
)
?
pQueryInfo
->
etime
:
pQueryInfo
->
stime
;
etime
=
taosGetRevisedEndKey
(
etime
,
pQueryInfo
->
order
.
order
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
interval
TimeUnit
,
precision
);
pQueryInfo
->
sliding
TimeUnit
,
precision
);
int32_t
rows
=
taosGetNumOfResultWithInterpo
(
pInterpoInfo
,
NULL
,
0
,
pQueryInfo
->
intervalTime
,
etime
,
pLocalReducer
->
resColModel
->
capacity
);
if
(
rows
>
0
)
{
// do interpo
...
...
src/client/src/tscServer.c
浏览文件 @
d1828544
...
...
@@ -436,7 +436,7 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSubquerySu
// set the tags value for ts_comp function
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pNewQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pNewQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pNewQueryInfo
,
0
);
int16_t
tagColIndex
=
tscGetJoinTagColIndexByUid
(
&
pSupporter
->
tagCond
,
pTableMetaInfo
->
pTableMeta
->
uid
);
pExpr
->
param
->
i64Key
=
tagColIndex
;
...
...
@@ -455,14 +455,14 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSubquerySu
"exprInfo:%d, colList:%d, fieldsInfo:%d, name:%s"
,
pSql
,
pNew
,
tableIndex
,
pTableMetaInfo
->
vnodeIndex
,
pNewQueryInfo
->
type
,
pNewQueryInfo
->
exprsInfo
.
numOfExprs
,
pNewQueryInfo
->
colList
.
numOfCols
,
pNewQueryInfo
->
fieldsInfo
.
numOfOutputCols
,
pNewQueryInfo
->
p
Meter
Info
[
0
]
->
name
);
pNewQueryInfo
->
fieldsInfo
.
numOfOutputCols
,
pNewQueryInfo
->
p
TableMeta
Info
[
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
->
vnodeIndex
,
pNewQueryInfo
->
type
,
pNewQueryInfo
->
exprsInfo
.
numOfExprs
,
pNewQueryInfo
->
colList
.
numOfCols
,
pNewQueryInfo
->
fieldsInfo
.
numOfOutputCols
,
pNewQueryInfo
->
p
Meter
Info
[
0
]
->
name
);
pNewQueryInfo
->
fieldsInfo
.
numOfOutputCols
,
pNewQueryInfo
->
p
TableMeta
Info
[
0
]
->
name
);
tscPrintSelectClause
(
pNew
,
0
);
}
else
{
SQueryInfo
*
pNewQueryInfo
=
tscGetQueryInfoDetail
(
&
pNew
->
cmd
,
0
);
...
...
@@ -521,7 +521,7 @@ int tscProcessSql(SSqlObj *pSql) {
int16_t
type
=
0
;
if
(
pQueryInfo
!=
NULL
)
{
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
if
(
pTableMetaInfo
!=
NULL
)
{
name
=
pTableMetaInfo
->
name
;
}
...
...
@@ -668,7 +668,7 @@ int tscLaunchSTableSubqueries(SSqlObj *pSql) {
const
uint32_t
nBufferSize
=
(
1
<<
16
);
// 64KB
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
int32_t
numOfSubQueries
=
pTableMetaInfo
->
pMetricMeta
->
numOfVnodes
;
assert
(
numOfSubQueries
>
0
);
...
...
@@ -929,7 +929,7 @@ void tscRetrieveFromVnodeCallBack(void *param, TAOS_RES *tres, int numOfRows) {
SSqlRes
*
pRes
=
&
pSql
->
res
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
SVnodeSidList
*
vnodeInfo
=
tscGetVnodeSidList
(
pTableMetaInfo
->
pMetricMeta
,
idx
);
SVnodeDesc
*
pSvd
=
&
vnodeInfo
->
vpeerDesc
[
vnodeInfo
->
index
];
...
...
@@ -1110,7 +1110,7 @@ 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 vnodeIndex.
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
table_index
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
table_index
);
pTableMetaInfo
->
vnodeIndex
=
trsupport
->
subqueryIndex
;
pSql
->
pSubs
[
trsupport
->
subqueryIndex
]
=
pNew
;
...
...
@@ -1176,7 +1176,7 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
trsupport
->
numOfRetry
=
MAX_NUM_OF_SUBQUERY_RETRY
;
}
else
{
SQueryInfo
*
pNewQueryInfo
=
tscGetQueryInfoDetail
(
&
pNew
->
cmd
,
0
);
assert
(
pNewQueryInfo
->
p
MeterInfo
[
0
]
->
pTableMeta
!=
NULL
&&
pNewQueryInfo
->
pMeter
Info
[
0
]
->
pMetricMeta
!=
NULL
);
assert
(
pNewQueryInfo
->
p
TableMetaInfo
[
0
]
->
pTableMeta
!=
NULL
&&
pNewQueryInfo
->
pTableMeta
Info
[
0
]
->
pMetricMeta
!=
NULL
);
tscProcessSql
(
pNew
);
return
;
}
...
...
@@ -1298,7 +1298,7 @@ static int32_t tscEstimateQueryMsgSize(SSqlCmd *pCmd, int32_t clauseIndex) {
int32_t
srcColListSize
=
pQueryInfo
->
colList
.
numOfCols
*
sizeof
(
SColumnInfo
);
int32_t
exprSize
=
sizeof
(
SSqlFuncExprMsg
)
*
pQueryInfo
->
exprsInfo
.
numOfExprs
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
// meter query without tags values
if
(
!
UTIL_METER_IS_SUPERTABLE
(
pTableMetaInfo
))
{
...
...
@@ -1330,21 +1330,21 @@ static char *doSerializeTableInfo(SSqlObj *pSql, int32_t numOfTables, int32_t vn
#ifdef _DEBUG_VIEW
tscTrace
(
"%p sid:%d, uid:%"
PRIu64
,
pSql
,
pTableMetaInfo
->
pTableMeta
->
sid
,
pTableMetaInfo
->
pTableMeta
->
uid
);
#endif
STableSidExtInfo
*
p
Meter
Info
=
(
STableSidExtInfo
*
)
pMsg
;
p
Meter
Info
->
sid
=
htonl
(
pTableMeta
->
sid
);
p
Meter
Info
->
uid
=
htobe64
(
pTableMeta
->
uid
);
p
Meter
Info
->
key
=
htobe64
(
tscGetSubscriptionProgress
(
pSql
->
pSubscription
,
pTableMeta
->
uid
));
STableSidExtInfo
*
p
TableMeta
Info
=
(
STableSidExtInfo
*
)
pMsg
;
p
TableMeta
Info
->
sid
=
htonl
(
pTableMeta
->
sid
);
p
TableMeta
Info
->
uid
=
htobe64
(
pTableMeta
->
uid
);
p
TableMeta
Info
->
key
=
htobe64
(
tscGetSubscriptionProgress
(
pSql
->
pSubscription
,
pTableMeta
->
uid
));
pMsg
+=
sizeof
(
STableSidExtInfo
);
}
else
{
SVnodeSidList
*
pVnodeSidList
=
tscGetVnodeSidList
(
pMetricMeta
,
pTableMetaInfo
->
vnodeIndex
);
for
(
int32_t
i
=
0
;
i
<
numOfTables
;
++
i
)
{
STableSidExtInfo
*
p
Meter
Info
=
(
STableSidExtInfo
*
)
pMsg
;
STableSidExtInfo
*
p
TableMeta
Info
=
(
STableSidExtInfo
*
)
pMsg
;
STableSidExtInfo
*
pQueryMeterInfo
=
tscGetMeterSidInfo
(
pVnodeSidList
,
i
);
p
Meter
Info
->
sid
=
htonl
(
pQueryMeterInfo
->
sid
);
p
Meter
Info
->
uid
=
htobe64
(
pQueryMeterInfo
->
uid
);
p
Meter
Info
->
key
=
htobe64
(
tscGetSubscriptionProgress
(
pSql
->
pSubscription
,
pQueryMeterInfo
->
uid
));
p
TableMeta
Info
->
sid
=
htonl
(
pQueryMeterInfo
->
sid
);
p
TableMeta
Info
->
uid
=
htobe64
(
pQueryMeterInfo
->
uid
);
p
TableMeta
Info
->
key
=
htobe64
(
tscGetSubscriptionProgress
(
pSql
->
pSubscription
,
pQueryMeterInfo
->
uid
));
pMsg
+=
sizeof
(
STableSidExtInfo
);
...
...
@@ -1371,7 +1371,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
char
*
pStart
=
pCmd
->
payload
+
tsRpcHeadSize
;
...
...
@@ -1438,7 +1438,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
pQueryMsg
->
intervalTime
=
htobe64
(
pQueryInfo
->
intervalTime
);
pQueryMsg
->
intervalTimeUnit
=
pQueryInfo
->
interval
TimeUnit
;
pQueryMsg
->
slidingTimeUnit
=
pQueryInfo
->
sliding
TimeUnit
;
pQueryMsg
->
slidingTime
=
htobe64
(
pQueryInfo
->
slidingTime
);
if
(
pQueryInfo
->
intervalTime
<
0
)
{
...
...
@@ -1968,7 +1968,7 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
// Reallocate the payload size
size
=
tscEstimateCreateTableMsgLength
(
pSql
,
pInfo
);
...
...
@@ -2047,7 +2047,7 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
size
=
tscEstimateAlterTableMsgLength
(
pCmd
);
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
size
))
{
...
...
@@ -2186,7 +2186,7 @@ int tscProcessTagRetrieveRsp(SSqlObj *pSql) {
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
int32_t
numOfRes
=
0
;
if
(
tscSqlExprGet
(
pQueryInfo
,
0
)
->
functionId
==
TSDB_FUNC_TAGPRJ
)
{
...
...
@@ -2266,7 +2266,7 @@ int tscBuildTableMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
pInfoMsg
=
(
SCMTableInfoMsg
*
)
pCmd
->
payload
;
strcpy
(
pInfoMsg
->
tableId
,
pTableMetaInfo
->
name
);
...
...
@@ -2365,7 +2365,7 @@ int tscBuildMetricMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
STagCond
*
pTagCond
=
&
pQueryInfo
->
tagCond
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
tableIndex
);
int32_t
size
=
tscEstimateMetricMetaMsgSize
(
pCmd
);
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
size
))
{
...
...
@@ -2833,7 +2833,7 @@ int tscProcessMetricMetaRsp(SSqlObj *pSql) {
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
char
name
[
TSDB_MAX_TAGS_LEN
+
1
]
=
{
0
};
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
i
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
i
);
tscGetMetricMetaCacheKey
(
pQueryInfo
,
name
,
pTableMetaInfo
->
pTableMeta
->
uid
);
#ifdef _DEBUG_VIEW
...
...
@@ -2880,7 +2880,7 @@ int tscProcessShowRsp(SSqlObj *pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
pShow
=
(
SCMShowRsp
*
)
pRes
->
pRsp
;
pShow
->
qhandle
=
htobe64
(
pShow
->
qhandle
);
...
...
@@ -3093,11 +3093,9 @@ int tscProcessRetrieveRspFromLocal(SSqlObj *pSql) {
return
0
;
}
void
tsc
Meter
MetaCallBack
(
void
*
param
,
TAOS_RES
*
res
,
int
code
);
void
tsc
Table
MetaCallBack
(
void
*
param
,
TAOS_RES
*
res
,
int
code
);
static
int32_t
doGetMeterMetaFromServer
(
SSqlObj
*
pSql
,
STableMetaInfo
*
pTableMetaInfo
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
SSqlObj
*
pNew
=
calloc
(
1
,
sizeof
(
SSqlObj
));
if
(
NULL
==
pNew
)
{
tscError
(
"%p malloc failed for new sqlobj to get meter meta"
,
pSql
);
...
...
@@ -3121,46 +3119,25 @@ static int32_t doGetMeterMetaFromServer(SSqlObj *pSql, STableMetaInfo *pTableMet
return
TSDB_CODE_CLI_OUT_OF_MEMORY
;
}
STableMetaInfo
*
pNewMeterMetaInfo
=
tscAddEmptyMet
erMet
aInfo
(
pNewQueryInfo
);
STableMetaInfo
*
pNewMeterMetaInfo
=
tscAddEmptyMetaInfo
(
pNewQueryInfo
);
assert
(
pNew
->
cmd
.
numOfClause
==
1
&&
pNewQueryInfo
->
numOfTables
==
1
);
strcpy
(
pNewMeterMetaInfo
->
name
,
pTableMetaInfo
->
name
);
memcpy
(
pNew
->
cmd
.
payload
,
pSql
->
cmd
.
payload
,
TSDB_DEFAULT_PAYLOAD_SIZE
);
// tag information if table does not exists.
tscTrace
(
"%p new pSqlObj:%p to get tableMeta"
,
pSql
,
pNew
);
if
(
pSql
->
fp
==
NULL
)
{
tsem_init
(
&
pNew
->
rspSem
,
0
,
0
);
tsem_init
(
&
pNew
->
emptyRspSem
,
0
,
1
);
code
=
tscProcessSql
(
pNew
);
/*
* Update cache only on succeeding in getting metermeta.
* Transfer the ownership of metermeta to the new object, instead of invoking the release/acquire routine
*/
if
(
code
==
TSDB_CODE_SUCCESS
)
{
pTableMetaInfo
->
pTableMeta
=
taosCacheTransfer
(
tscCacheHandle
,
(
void
**
)
&
pNewMeterMetaInfo
->
pTableMeta
);
assert
(
pTableMetaInfo
->
pTableMeta
!=
NULL
);
}
tscTrace
(
"%p get meter meta complete, code:%d, pTableMeta:%p"
,
pSql
,
code
,
pTableMetaInfo
->
pTableMeta
);
tscFreeSqlObj
(
pNew
);
}
else
{
pNew
->
fp
=
tscMeterMetaCallBack
;
pNew
->
param
=
pSql
;
pNew
->
sqlstr
=
strdup
(
pSql
->
sqlstr
);
pNew
->
fp
=
tscTableMetaCallBack
;
pNew
->
param
=
pSql
;
code
=
tscProcessSql
(
pNew
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
}
int32_t
code
=
tscProcessSql
(
pNew
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
}
return
code
;
}
int
tscGetMeter
Meta
(
SSqlObj
*
pSql
,
STableMetaInfo
*
pTableMetaInfo
)
{
int
32_t
tscGetTable
Meta
(
SSqlObj
*
pSql
,
STableMetaInfo
*
pTableMetaInfo
)
{
assert
(
strlen
(
pTableMetaInfo
->
name
)
!=
0
);
// If this STableMetaInfo owns a metermeta, release it first
...
...
@@ -3179,14 +3156,14 @@ int tscGetMeterMeta(SSqlObj *pSql, STableMetaInfo *pTableMetaInfo) {
/*
* for async insert operation, release data block buffer before issue new object to get metermeta
* because in
meter
meta callback function, the tscParse function will generate the submit data blocks
* because in
table
meta callback function, the tscParse function will generate the submit data blocks
*/
return
doGetMeterMetaFromServer
(
pSql
,
pTableMetaInfo
);
}
int
tscGetMeterMetaEx
(
SSqlObj
*
pSql
,
STableMetaInfo
*
pTableMetaInfo
,
bool
createIfNotExists
)
{
pSql
->
cmd
.
createOnDemand
=
createIfNotExists
;
return
tscGet
Meter
Meta
(
pSql
,
pTableMetaInfo
);
return
tscGet
Table
Meta
(
pSql
,
pTableMetaInfo
);
}
/*
...
...
@@ -3215,7 +3192,7 @@ int tscRenewMeterMeta(SSqlObj *pSql, char *tableId) {
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
// enforce the renew metermeta operation in async model
if
(
pSql
->
fp
==
NULL
)
pSql
->
fp
=
(
void
*
)
0x1
;
...
...
@@ -3262,7 +3239,7 @@ int tscGetMetricMeta(SSqlObj *pSql, int32_t clauseIndex) {
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
char
tagstr
[
TSDB_MAX_TAGS_LEN
+
1
]
=
{
0
};
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
i
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
i
);
tscGetMetricMetaCacheKey
(
pQueryInfo
,
tagstr
,
pTableMetaInfo
->
pTableMeta
->
uid
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
pTableMetaInfo
->
pMetricMeta
),
false
);
...
...
@@ -3293,7 +3270,7 @@ int tscGetMetricMeta(SSqlObj *pSql, int32_t clauseIndex) {
}
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
STableMetaInfo
*
pMMInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
i
);
STableMetaInfo
*
pMMInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
i
);
STableMeta
*
pTableMeta
=
taosCacheAcquireByName
(
tscCacheHandle
,
pMMInfo
->
name
);
tscAddMeterMetaInfo
(
pNewQueryInfo
,
pMMInfo
->
name
,
pTableMeta
,
NULL
,
pMMInfo
->
numOfTags
,
pMMInfo
->
tagColumnIndex
);
...
...
@@ -3333,7 +3310,7 @@ int tscGetMetricMeta(SSqlObj *pSql, int32_t clauseIndex) {
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
char
tagstr
[
TSDB_MAX_TAGS_LEN
]
=
{
0
};
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
i
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
i
);
tscGetMetricMetaCacheKey
(
pQueryInfo
,
tagstr
,
pTableMetaInfo
->
pTableMeta
->
uid
);
#ifdef _DEBUG_VIEW
...
...
@@ -3347,7 +3324,7 @@ int tscGetMetricMeta(SSqlObj *pSql, int32_t clauseIndex) {
tscFreeSqlObj
(
pNew
);
}
else
{
pNew
->
fp
=
tsc
Meter
MetaCallBack
;
pNew
->
fp
=
tsc
Table
MetaCallBack
;
pNew
->
param
=
pSql
;
code
=
tscProcessSql
(
pNew
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
...
...
src/client/src/tscSql.c
浏览文件 @
d1828544
...
...
@@ -509,7 +509,7 @@ static bool tscHashRemainDataInSubqueryResultSet(SSqlObj *pSql) {
SSqlCmd
*
pCmd1
=
&
pSql
->
pSubs
[
i
]
->
cmd
;
SQueryInfo
*
pQueryInfo1
=
tscGetQueryInfoDetail
(
pCmd1
,
pCmd1
->
clauseIndex
);
STableMetaInfo
*
pMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo1
,
0
);
STableMetaInfo
*
pMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo1
,
0
);
assert
(
pQueryInfo1
->
numOfTables
==
1
);
...
...
@@ -810,7 +810,7 @@ void taos_free_result_imp(TAOS_RES *res, int keepCmd) {
pQueryInfo
->
type
=
TSDB_QUERY_TYPE_FREE_RESOURCE
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
/*
* case 1. Partial data have been retrieved from vnodes, but not all data has been retrieved yet.
...
...
@@ -1109,7 +1109,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
SQueryInfo
*
pQueryInfo
=
NULL
;
tscGetQueryInfoDetailSafely
(
pCmd
,
pCmd
->
clauseIndex
,
&
pQueryInfo
);
STableMetaInfo
*
pTableMetaInfo
=
tscAddEmptyMet
erMet
aInfo
(
pQueryInfo
);
STableMetaInfo
*
pTableMetaInfo
=
tscAddEmptyMetaInfo
(
pQueryInfo
);
if
((
code
=
tscAllocPayload
(
pCmd
,
tblListLen
+
16
))
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
...
...
src/client/src/tscStream.c
浏览文件 @
d1828544
...
...
@@ -72,9 +72,9 @@ static void tscProcessStreamLaunchQuery(SSchedMsg *pMsg) {
pSql
->
param
=
pStream
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
int
code
=
tscGet
Meter
Meta
(
pSql
,
pTableMetaInfo
);
int
code
=
tscGet
Table
Meta
(
pSql
,
pTableMetaInfo
);
pSql
->
res
.
code
=
code
;
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
return
;
...
...
@@ -540,7 +540,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
pStream
->
fp
=
fp
;
...
...
src/client/src/tscSub.c
浏览文件 @
d1828544
...
...
@@ -202,8 +202,8 @@ int tscUpdateSubscription(STscObj* pObj, SSub* pSub) {
for
(
int32_t
i
=
0
;
i
<
pMetricMeta
->
numOfVnodes
;
i
++
)
{
SVnodeSidList
*
pVnodeSidList
=
tscGetVnodeSidList
(
pMetricMeta
,
i
);
for
(
int32_t
j
=
0
;
j
<
pVnodeSidList
->
numOfSids
;
j
++
)
{
STableSidExtInfo
*
p
Meter
Info
=
tscGetMeterSidInfo
(
pVnodeSidList
,
j
);
int64_t
uid
=
p
Meter
Info
->
uid
;
STableSidExtInfo
*
p
TableMeta
Info
=
tscGetMeterSidInfo
(
pVnodeSidList
,
j
);
int64_t
uid
=
p
TableMeta
Info
->
uid
;
progress
[
numOfTables
].
uid
=
uid
;
progress
[
numOfTables
++
].
key
=
tscGetSubscriptionProgress
(
pSub
,
uid
);
}
...
...
src/client/src/tscUtil.c
浏览文件 @
d1828544
...
...
@@ -214,7 +214,7 @@ bool tscIsTwoStageMergeMetricQuery(SQueryInfo* pQueryInfo, int32_t tableIndex) {
return
false
;
}
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
tableIndex
);
if
(
pTableMetaInfo
==
NULL
)
{
return
false
;
}
...
...
@@ -246,7 +246,7 @@ bool tscIsTwoStageMergeMetricQuery(SQueryInfo* pQueryInfo, int32_t tableIndex) {
}
bool
tscIsProjectionQueryOnSTable
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
tableIndex
);
/*
* In following cases, return false for non ordered project query on super table
...
...
@@ -1116,7 +1116,7 @@ SSqlExpr* tscSqlExprInsertEmpty(SQueryInfo* pQueryInfo, int32_t index, int16_t f
SSqlExpr
*
tscSqlExprInsert
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
,
int16_t
functionId
,
SColumnIndex
*
pColIndex
,
int16_t
type
,
int16_t
size
,
int16_t
interSize
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
pColIndex
->
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
pColIndex
->
tableIndex
);
SSqlExprInfo
*
pExprInfo
=
&
pQueryInfo
->
exprsInfo
;
...
...
@@ -1161,7 +1161,7 @@ SSqlExpr* tscSqlExprInsert(SQueryInfo* pQueryInfo, int32_t index, int16_t functi
SSqlExpr
*
tscSqlExprUpdate
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
,
int16_t
functionId
,
int16_t
srcColumnIndex
,
int16_t
type
,
int16_t
size
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
SSqlExprInfo
*
pExprInfo
=
&
pQueryInfo
->
exprsInfo
;
if
(
index
>
pExprInfo
->
numOfExprs
)
{
return
NULL
;
...
...
@@ -1629,7 +1629,7 @@ void tscTagCondRelease(STagCond* pCond) {
}
void
tscGetSrcColumnInfo
(
SSrcColumnInfo
*
pColInfo
,
SQueryInfo
*
pQueryInfo
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMetaInfo
->
pTableMeta
);
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
i
)
{
...
...
@@ -1725,7 +1725,7 @@ bool tscShouldFreeAsyncSqlObj(SSqlObj* pSql) {
SDataBlockList
*
pDataBlocks
=
pCmd
->
pDataBlocks
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
assert
(
pQueryInfo
->
numOfTables
==
1
||
pQueryInfo
->
numOfTables
==
2
);
if
(
pDataBlocks
==
NULL
||
pTableMetaInfo
->
vnodeIndex
>=
pDataBlocks
->
nSize
)
{
...
...
@@ -1755,20 +1755,20 @@ STableMetaInfo* tscGetMeterMetaInfo(SSqlCmd* pCmd, int32_t clauseIndex, int32_t
assert
(
clauseIndex
>=
0
&&
clauseIndex
<
pCmd
->
numOfClause
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
clauseIndex
);
return
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
tableIndex
);
return
tscGetMet
a
Info
(
pQueryInfo
,
tableIndex
);
}
STableMetaInfo
*
tscGetMet
erMetaInfoFromQuery
Info
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
)
{
STableMetaInfo
*
tscGetMet
a
Info
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
)
{
assert
(
pQueryInfo
!=
NULL
);
if
(
pQueryInfo
->
p
Meter
Info
==
NULL
)
{
if
(
pQueryInfo
->
p
TableMeta
Info
==
NULL
)
{
assert
(
pQueryInfo
->
numOfTables
==
0
);
return
NULL
;
}
assert
(
tableIndex
>=
0
&&
tableIndex
<=
pQueryInfo
->
numOfTables
&&
pQueryInfo
->
p
Meter
Info
!=
NULL
);
assert
(
tableIndex
>=
0
&&
tableIndex
<=
pQueryInfo
->
numOfTables
&&
pQueryInfo
->
p
TableMeta
Info
!=
NULL
);
return
pQueryInfo
->
p
Meter
Info
[
tableIndex
];
return
pQueryInfo
->
p
TableMeta
Info
[
tableIndex
];
}
SQueryInfo
*
tscGetQueryInfoDetail
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
)
{
...
...
@@ -1801,7 +1801,7 @@ STableMetaInfo* tscGetMeterMetaInfoByUid(SQueryInfo* pQueryInfo, uint64_t uid, i
int32_t
k
=
-
1
;
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
if
(
pQueryInfo
->
p
Meter
Info
[
i
]
->
pTableMeta
->
uid
==
uid
)
{
if
(
pQueryInfo
->
p
TableMeta
Info
[
i
]
->
pTableMeta
->
uid
==
uid
)
{
k
=
i
;
break
;
}
...
...
@@ -1812,7 +1812,7 @@ STableMetaInfo* tscGetMeterMetaInfoByUid(SQueryInfo* pQueryInfo, uint64_t uid, i
}
assert
(
k
!=
-
1
);
return
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
k
);
return
tscGetMet
a
Info
(
pQueryInfo
,
k
);
}
int32_t
tscAddSubqueryInfo
(
SSqlCmd
*
pCmd
)
{
...
...
@@ -1876,15 +1876,15 @@ void tscFreeSubqueryInfo(SSqlCmd* pCmd) {
STableMetaInfo
*
tscAddMeterMetaInfo
(
SQueryInfo
*
pQueryInfo
,
const
char
*
name
,
STableMeta
*
pTableMeta
,
SSuperTableMeta
*
pMetricMeta
,
int16_t
numOfTags
,
int16_t
*
tags
)
{
void
*
pAlloc
=
realloc
(
pQueryInfo
->
p
Meter
Info
,
(
pQueryInfo
->
numOfTables
+
1
)
*
POINTER_BYTES
);
void
*
pAlloc
=
realloc
(
pQueryInfo
->
p
TableMeta
Info
,
(
pQueryInfo
->
numOfTables
+
1
)
*
POINTER_BYTES
);
if
(
pAlloc
==
NULL
)
{
return
NULL
;
}
pQueryInfo
->
p
Meter
Info
=
pAlloc
;
pQueryInfo
->
p
Meter
Info
[
pQueryInfo
->
numOfTables
]
=
calloc
(
1
,
sizeof
(
STableMetaInfo
));
pQueryInfo
->
p
TableMeta
Info
=
pAlloc
;
pQueryInfo
->
p
TableMeta
Info
[
pQueryInfo
->
numOfTables
]
=
calloc
(
1
,
sizeof
(
STableMetaInfo
));
STableMetaInfo
*
pTableMetaInfo
=
pQueryInfo
->
p
Meter
Info
[
pQueryInfo
->
numOfTables
];
STableMetaInfo
*
pTableMetaInfo
=
pQueryInfo
->
p
TableMeta
Info
[
pQueryInfo
->
numOfTables
];
assert
(
pTableMetaInfo
!=
NULL
);
if
(
name
!=
NULL
)
{
...
...
@@ -1904,7 +1904,7 @@ STableMetaInfo* tscAddMeterMetaInfo(SQueryInfo* pQueryInfo, const char* name, ST
return
pTableMetaInfo
;
}
STableMetaInfo
*
tscAddEmptyMet
erMet
aInfo
(
SQueryInfo
*
pQueryInfo
)
{
STableMetaInfo
*
tscAddEmptyMetaInfo
(
SQueryInfo
*
pQueryInfo
)
{
return
tscAddMeterMetaInfo
(
pQueryInfo
,
NULL
,
NULL
,
NULL
,
0
,
NULL
);
}
...
...
@@ -1913,14 +1913,14 @@ void doRemoveMeterMetaInfo(SQueryInfo* pQueryInfo, int32_t index, bool removeFro
return
;
}
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
index
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
index
);
tscClearMeterMetaInfo
(
pTableMetaInfo
,
removeFromCache
);
free
(
pTableMetaInfo
);
int32_t
after
=
pQueryInfo
->
numOfTables
-
index
-
1
;
if
(
after
>
0
)
{
memmove
(
&
pQueryInfo
->
p
MeterInfo
[
index
],
&
pQueryInfo
->
pMeter
Info
[
index
+
1
],
after
*
POINTER_BYTES
);
memmove
(
&
pQueryInfo
->
p
TableMetaInfo
[
index
],
&
pQueryInfo
->
pTableMeta
Info
[
index
+
1
],
after
*
POINTER_BYTES
);
}
pQueryInfo
->
numOfTables
-=
1
;
...
...
@@ -1934,7 +1934,7 @@ void tscRemoveAllMeterMetaInfo(SQueryInfo* pQueryInfo, const char* address, bool
doRemoveMeterMetaInfo
(
pQueryInfo
,
--
index
,
removeFromCache
);
}
tfree
(
pQueryInfo
->
p
Meter
Info
);
tfree
(
pQueryInfo
->
p
TableMeta
Info
);
}
void
tscClearMeterMetaInfo
(
STableMetaInfo
*
pTableMetaInfo
,
bool
removeFromCache
)
{
...
...
@@ -1999,7 +1999,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
memset
(
&
pNewQueryInfo
->
colList
,
0
,
sizeof
(
pNewQueryInfo
->
colList
));
memset
(
&
pNewQueryInfo
->
fieldsInfo
,
0
,
sizeof
(
SFieldInfo
));
pNewQueryInfo
->
p
Meter
Info
=
NULL
;
pNewQueryInfo
->
p
TableMeta
Info
=
NULL
;
pNewQueryInfo
->
defaultVal
=
NULL
;
pNewQueryInfo
->
numOfTables
=
0
;
pNewQueryInfo
->
tsBuf
=
NULL
;
...
...
@@ -2189,7 +2189,7 @@ bool hasMoreVnodesToTry(SSqlObj* pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
if
(
!
UTIL_METER_IS_SUPERTABLE
(
pTableMetaInfo
)
||
(
pTableMetaInfo
->
pMetricMeta
==
NULL
))
{
return
false
;
}
...
...
@@ -2211,7 +2211,7 @@ void tscTryQueryNextVnode(SSqlObj* pSql, __async_cb_func_t fp) {
*/
assert
(
pRes
->
numOfRows
==
0
&&
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
)
&&
!
tscHasReachLimitation
(
pQueryInfo
,
pRes
));
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
erMetaInfoFromQuery
Info
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMet
a
Info
(
pQueryInfo
,
0
);
int32_t
totalVnode
=
pTableMetaInfo
->
pMetricMeta
->
numOfVnodes
;
while
(
++
pTableMetaInfo
->
vnodeIndex
<
totalVnode
)
{
...
...
src/inc/taosmsg.h
浏览文件 @
d1828544
...
...
@@ -464,7 +464,7 @@ typedef struct {
int16_t
orderColId
;
int16_t
numOfCols
;
// the number of columns will be load from vnode
char
interval
TimeUnit
;
// time interval type, for revisement of interval(1d)
char
sliding
TimeUnit
;
// time interval type, for revisement of interval(1d)
int64_t
intervalTime
;
// time interval for aggregation, in million second
int64_t
slidingTime
;
// value for sliding window
...
...
tests/examples/c/demo.c
浏览文件 @
d1828544
...
...
@@ -35,6 +35,7 @@ int main(int argc, char *argv[]) {
return
0
;
}
taos_options
(
TSDB_OPTION_CONFIGDIR
,
"~/first/cfg"
);
// init TAOS
taos_init
();
...
...
@@ -44,8 +45,27 @@ int main(int argc, char *argv[]) {
exit
(
1
);
}
printf
(
"success to connect to server
\n
"
);
int32_t
code
=
taos_query
(
taos
,
"select * from test.t1"
);
if
(
code
!=
0
)
{
printf
(
"failed to execute query, reason:%s
\n
"
,
taos_errstr
(
taos
));
}
TAOS_RES
*
res
=
taos_use_result
(
taos
);
TAOS_ROW
row
=
NULL
;
char
buf
[
512
]
=
{
0
};
int32_t
numOfFields
=
taos_num_fields
(
res
);
TAOS_FIELD
*
pFields
=
taos_fetch_fields
(
res
);
while
((
row
=
taos_fetch_row
(
res
))
!=
NULL
)
{
taos_print_row
(
buf
,
row
,
pFields
,
numOfFields
);
printf
(
"%s
\n
"
,
buf
);
memset
(
buf
,
0
,
512
);
}
return
0
;
taos_query
(
taos
,
"drop database demo"
);
if
(
taos_query
(
taos
,
"create database demo"
)
!=
0
)
{
printf
(
"failed to create database, reason:%s
\n
"
,
taos_errstr
(
taos
));
...
...
@@ -90,7 +110,7 @@ int main(int argc, char *argv[]) {
exit
(
1
);
}
TAOS_ROW
row
;
//
TAOS_ROW row;
int
rows
=
0
;
int
num_fields
=
taos_field_count
(
taos
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
result
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录