Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
03346d0c
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看板
提交
03346d0c
编写于
3月 18, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-32] refactor the tablemeta
上级
04e0fa80
变更
35
显示空白变更内容
内联
并排
Showing
35 changed file
with
1089 addition
and
920 deletion
+1089
-920
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+14
-14
src/client/inc/tschemautil.h
src/client/inc/tschemautil.h
+51
-8
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+45
-6
src/client/src/tscAsync.c
src/client/src/tscAsync.c
+20
-20
src/client/src/tscJoinProcess.c
src/client/src/tscJoinProcess.c
+26
-26
src/client/src/tscLocal.c
src/client/src/tscLocal.c
+22
-20
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+79
-70
src/client/src/tscPrepare.c
src/client/src/tscPrepare.c
+4
-4
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+237
-226
src/client/src/tscSchemaUtil.c
src/client/src/tscSchemaUtil.c
+101
-37
src/client/src/tscSecondaryMerge.c
src/client/src/tscSecondaryMerge.c
+29
-18
src/client/src/tscServer.c
src/client/src/tscServer.c
+266
-274
src/client/src/tscSql.c
src/client/src/tscSql.c
+7
-7
src/client/src/tscStream.c
src/client/src/tscStream.c
+20
-18
src/client/src/tscSub.c
src/client/src/tscSub.c
+6
-6
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+95
-93
src/inc/taosdef.h
src/inc/taosdef.h
+1
-1
src/inc/taosmsg.h
src/inc/taosmsg.h
+12
-12
src/mnode/inc/mgmtChildTable.h
src/mnode/inc/mgmtChildTable.h
+1
-1
src/mnode/inc/mgmtNormalTable.h
src/mnode/inc/mgmtNormalTable.h
+1
-1
src/mnode/inc/mgmtShell.h
src/mnode/inc/mgmtShell.h
+1
-1
src/mnode/inc/mgmtSuperTable.h
src/mnode/inc/mgmtSuperTable.h
+1
-1
src/mnode/inc/mgmtTable.h
src/mnode/inc/mgmtTable.h
+1
-1
src/mnode/src/mgmtChildTable.c
src/mnode/src/mgmtChildTable.c
+2
-3
src/mnode/src/mgmtDb.c
src/mnode/src/mgmtDb.c
+5
-5
src/mnode/src/mgmtDnode.c
src/mnode/src/mgmtDnode.c
+9
-10
src/mnode/src/mgmtNormalTable.c
src/mnode/src/mgmtNormalTable.c
+2
-2
src/mnode/src/mgmtProfile.c
src/mnode/src/mgmtProfile.c
+6
-7
src/mnode/src/mgmtShell.c
src/mnode/src/mgmtShell.c
+1
-1
src/mnode/src/mgmtSuperTable.c
src/mnode/src/mgmtSuperTable.c
+5
-6
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+9
-9
src/mnode/src/mgmtUser.c
src/mnode/src/mgmtUser.c
+3
-4
src/mnode/src/mgmtVgroup.c
src/mnode/src/mgmtVgroup.c
+3
-4
src/query/inc/qpercentile.h
src/query/inc/qpercentile.h
+3
-3
src/query/src/qast.c
src/query/src/qast.c
+1
-1
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
03346d0c
...
@@ -30,10 +30,10 @@ extern "C" {
...
@@ -30,10 +30,10 @@ extern "C" {
#include "tsclient.h"
#include "tsclient.h"
#define UTIL_METER_IS_SUPERTABLE(metaInfo) \
#define UTIL_METER_IS_SUPERTABLE(metaInfo) \
(((metaInfo)->p
MeterMeta != NULL) && ((metaInfo)->pMeter
Meta->tableType == TSDB_SUPER_TABLE))
(((metaInfo)->p
TableMeta != NULL) && ((metaInfo)->pTable
Meta->tableType == TSDB_SUPER_TABLE))
#define UTIL_METER_IS_NOMRAL_METER(metaInfo) (!(UTIL_METER_IS_SUPERTABLE(metaInfo)))
#define UTIL_METER_IS_NOMRAL_METER(metaInfo) (!(UTIL_METER_IS_SUPERTABLE(metaInfo)))
#define UTIL_METER_IS_CREATE_FROM_METRIC(metaInfo) \
#define UTIL_METER_IS_CREATE_FROM_METRIC(metaInfo) \
(((metaInfo)->p
MeterMeta != NULL) && ((metaInfo)->pMeter
Meta->tableType == TSDB_CHILD_TABLE))
(((metaInfo)->p
TableMeta != NULL) && ((metaInfo)->pTable
Meta->tableType == TSDB_CHILD_TABLE))
#define TSDB_COL_IS_TAG(f) (((f)&TSDB_COL_TAG) != 0)
#define TSDB_COL_IS_TAG(f) (((f)&TSDB_COL_TAG) != 0)
...
@@ -67,7 +67,7 @@ typedef struct SJoinSubquerySupporter {
...
@@ -67,7 +67,7 @@ typedef struct SJoinSubquerySupporter {
}
SJoinSubquerySupporter
;
}
SJoinSubquerySupporter
;
int32_t
tscCreateDataBlock
(
size_t
initialSize
,
int32_t
rowSize
,
int32_t
startOffset
,
const
char
*
name
,
int32_t
tscCreateDataBlock
(
size_t
initialSize
,
int32_t
rowSize
,
int32_t
startOffset
,
const
char
*
name
,
STableMeta
*
p
Meter
Meta
,
STableDataBlocks
**
dataBlocks
);
STableMeta
*
p
Table
Meta
,
STableDataBlocks
**
dataBlocks
);
void
tscAppendDataBlock
(
SDataBlockList
*
pList
,
STableDataBlocks
*
pBlocks
);
void
tscAppendDataBlock
(
SDataBlockList
*
pList
,
STableDataBlocks
*
pBlocks
);
void
tscDestroyDataBlock
(
STableDataBlocks
*
pDataBlock
);
void
tscDestroyDataBlock
(
STableDataBlocks
*
pDataBlock
);
...
@@ -81,7 +81,7 @@ int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock);
...
@@ -81,7 +81,7 @@ int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock);
void
tscFreeUnusedDataBlocks
(
SDataBlockList
*
pList
);
void
tscFreeUnusedDataBlocks
(
SDataBlockList
*
pList
);
int32_t
tscMergeTableDataBlocks
(
SSqlObj
*
pSql
,
SDataBlockList
*
pDataList
);
int32_t
tscMergeTableDataBlocks
(
SSqlObj
*
pSql
,
SDataBlockList
*
pDataList
);
int32_t
tscGetDataBlockFromList
(
void
*
pHashList
,
SDataBlockList
*
pDataBlockList
,
int64_t
id
,
int32_t
size
,
int32_t
tscGetDataBlockFromList
(
void
*
pHashList
,
SDataBlockList
*
pDataBlockList
,
int64_t
id
,
int32_t
size
,
int32_t
startOffset
,
int32_t
rowSize
,
const
char
*
tableId
,
STableMeta
*
p
Meter
Meta
,
int32_t
startOffset
,
int32_t
rowSize
,
const
char
*
tableId
,
STableMeta
*
p
Table
Meta
,
STableDataBlocks
**
dataBlocks
);
STableDataBlocks
**
dataBlocks
);
SVnodeSidList
*
tscGetVnodeSidList
(
SSuperTableMeta
*
pMetricmeta
,
int32_t
vnodeIdx
);
SVnodeSidList
*
tscGetVnodeSidList
(
SSuperTableMeta
*
pMetricmeta
,
int32_t
vnodeIdx
);
...
@@ -114,7 +114,7 @@ void tscAddSpecialColumnForSelect(SQueryInfo* pQueryInfo, int32_t outputColIndex
...
@@ -114,7 +114,7 @@ void tscAddSpecialColumnForSelect(SQueryInfo* pQueryInfo, int32_t outputColIndex
void
addRequiredTagColumn
(
SQueryInfo
*
pQueryInfo
,
int32_t
tagColIndex
,
int32_t
tableIndex
);
void
addRequiredTagColumn
(
SQueryInfo
*
pQueryInfo
,
int32_t
tagColIndex
,
int32_t
tableIndex
);
int32_t
setMeterID
(
S
MeterMetaInfo
*
pMeter
MetaInfo
,
SSQLToken
*
pzTableName
,
SSqlObj
*
pSql
);
int32_t
setMeterID
(
S
TableMetaInfo
*
pTable
MetaInfo
,
SSQLToken
*
pzTableName
,
SSqlObj
*
pSql
);
void
tscClearInterpInfo
(
SQueryInfo
*
pQueryInfo
);
void
tscClearInterpInfo
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsInsertOrImportData
(
char
*
sqlstr
);
bool
tscIsInsertOrImportData
(
char
*
sqlstr
);
...
@@ -173,7 +173,7 @@ int32_t tscValidateName(SSQLToken* pToken);
...
@@ -173,7 +173,7 @@ int32_t tscValidateName(SSQLToken* pToken);
void
tscIncStreamExecutionCount
(
void
*
pStream
);
void
tscIncStreamExecutionCount
(
void
*
pStream
);
bool
tscValidateColumnId
(
S
MeterMetaInfo
*
pMeter
MetaInfo
,
int32_t
colId
);
bool
tscValidateColumnId
(
S
TableMetaInfo
*
pTable
MetaInfo
,
int32_t
colId
);
// get starter position of metric query condition (query on tags) in SSqlCmd.payload
// get starter position of metric query condition (query on tags) in SSqlCmd.payload
SCond
*
tsGetMetricQueryCondPos
(
STagCond
*
pCond
,
uint64_t
tableIndex
);
SCond
*
tsGetMetricQueryCondPos
(
STagCond
*
pCond
,
uint64_t
tableIndex
);
...
@@ -190,26 +190,26 @@ void tscCleanSqlCmd(SSqlCmd* pCmd);
...
@@ -190,26 +190,26 @@ void tscCleanSqlCmd(SSqlCmd* pCmd);
bool
tscShouldFreeAsyncSqlObj
(
SSqlObj
*
pSql
);
bool
tscShouldFreeAsyncSqlObj
(
SSqlObj
*
pSql
);
void
tscRemoveAllMeterMetaInfo
(
SQueryInfo
*
pQueryInfo
,
const
char
*
address
,
bool
removeFromCache
);
void
tscRemoveAllMeterMetaInfo
(
SQueryInfo
*
pQueryInfo
,
const
char
*
address
,
bool
removeFromCache
);
S
Meter
MetaInfo
*
tscGetMeterMetaInfo
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
,
int32_t
tableIndex
);
S
Table
MetaInfo
*
tscGetMeterMetaInfo
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
,
int32_t
tableIndex
);
S
Meter
MetaInfo
*
tscGetMeterMetaInfoFromQueryInfo
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
S
Table
MetaInfo
*
tscGetMeterMetaInfoFromQueryInfo
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
SQueryInfo
*
tscGetQueryInfoDetail
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
);
SQueryInfo
*
tscGetQueryInfoDetail
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
);
int32_t
tscGetQueryInfoDetailSafely
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
,
SQueryInfo
**
pQueryInfo
);
int32_t
tscGetQueryInfoDetailSafely
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
,
SQueryInfo
**
pQueryInfo
);
S
Meter
MetaInfo
*
tscGetMeterMetaInfoByUid
(
SQueryInfo
*
pQueryInfo
,
uint64_t
uid
,
int32_t
*
index
);
S
Table
MetaInfo
*
tscGetMeterMetaInfoByUid
(
SQueryInfo
*
pQueryInfo
,
uint64_t
uid
,
int32_t
*
index
);
void
tscClearMeterMetaInfo
(
S
MeterMetaInfo
*
pMeter
MetaInfo
,
bool
removeFromCache
);
void
tscClearMeterMetaInfo
(
S
TableMetaInfo
*
pTable
MetaInfo
,
bool
removeFromCache
);
S
MeterMetaInfo
*
tscAddMeterMetaInfo
(
SQueryInfo
*
pQueryInfo
,
const
char
*
name
,
STableMeta
*
pMeter
Meta
,
SSuperTableMeta
*
pMetricMeta
,
S
TableMetaInfo
*
tscAddMeterMetaInfo
(
SQueryInfo
*
pQueryInfo
,
const
char
*
name
,
STableMeta
*
pTable
Meta
,
SSuperTableMeta
*
pMetricMeta
,
int16_t
numOfTags
,
int16_t
*
tags
);
int16_t
numOfTags
,
int16_t
*
tags
);
S
Meter
MetaInfo
*
tscAddEmptyMeterMetaInfo
(
SQueryInfo
*
pQueryInfo
);
S
Table
MetaInfo
*
tscAddEmptyMeterMetaInfo
(
SQueryInfo
*
pQueryInfo
);
int32_t
tscAddSubqueryInfo
(
SSqlCmd
*
pCmd
);
int32_t
tscAddSubqueryInfo
(
SSqlCmd
*
pCmd
);
void
tscFreeSubqueryInfo
(
SSqlCmd
*
pCmd
);
void
tscFreeSubqueryInfo
(
SSqlCmd
*
pCmd
);
void
tscClearSubqueryInfo
(
SSqlCmd
*
pCmd
);
void
tscClearSubqueryInfo
(
SSqlCmd
*
pCmd
);
void
tscGetMetricMetaCacheKey
(
SQueryInfo
*
pQueryInfo
,
char
*
keyStr
,
uint64_t
uid
);
void
tscGetMetricMetaCacheKey
(
SQueryInfo
*
pQueryInfo
,
char
*
keyStr
,
uint64_t
uid
);
int
tscGetMetricMeta
(
SSqlObj
*
pSql
,
int32_t
clauseIndex
);
int
tscGetMetricMeta
(
SSqlObj
*
pSql
,
int32_t
clauseIndex
);
int
tscGetMeterMeta
(
SSqlObj
*
pSql
,
S
MeterMetaInfo
*
pMeter
MetaInfo
);
int
tscGetMeterMeta
(
SSqlObj
*
pSql
,
S
TableMetaInfo
*
pTable
MetaInfo
);
int
tscGetMeterMetaEx
(
SSqlObj
*
pSql
,
S
MeterMetaInfo
*
pMeter
MetaInfo
,
bool
createIfNotExists
);
int
tscGetMeterMetaEx
(
SSqlObj
*
pSql
,
S
TableMetaInfo
*
pTable
MetaInfo
,
bool
createIfNotExists
);
void
tscResetForNextRetrieve
(
SSqlRes
*
pRes
);
void
tscResetForNextRetrieve
(
SSqlRes
*
pRes
);
...
...
src/
util
/inc/tschemautil.h
→
src/
client
/inc/tschemautil.h
浏览文件 @
03346d0c
...
@@ -20,13 +20,56 @@
...
@@ -20,13 +20,56 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#include <stdint.h>
#include "taosmsg.h"
#include "taosmsg.h"
#include "tstoken.h"
#include "tstoken.h"
#include "tsclient.h"
#define VALIDNUMOFCOLS(x) ((x) >= TSDB_MIN_COLUMNS && (x) <= TSDB_MAX_COLUMNS)
#define VALIDNUMOFCOLS(x) ((x) >= TSDB_MIN_COLUMNS && (x) <= TSDB_MAX_COLUMNS)
struct
SSchema
;
//struct SSchema;
/**
* get the number of tags of this table
* @param pTableMeta
* @return
*/
int32_t
tscGetNumOfTags
(
const
STableMeta
*
pTableMeta
);
/**
* get the number of columns of this table
* @param pTableMeta
* @return
*/
int32_t
tscGetNumOfColumns
(
const
STableMeta
*
pTableMeta
);
/**
* get the basic info of this table
* @param pTableMeta
* @return
*/
STableInfo
tscGetTableInfo
(
const
STableMeta
*
pTableMeta
);
/**
* get the schema
* @param pTableMeta
* @return
*/
SSchema
*
tscGetTableSchema
(
const
STableMeta
*
pTableMeta
);
/**
* get the tag schema
* @param pMeta
* @return
*/
SSchema
*
tscGetTableTagSchema
(
const
STableMeta
*
pMeta
);
/**
*
* @param pMeta
* @param startCol
* @return
*/
SSchema
*
tscGetTableColumnSchema
(
const
STableMeta
*
pMeta
,
int32_t
startCol
);
/**
/**
* check if the schema is valid or not, including following aspects:
* check if the schema is valid or not, including following aspects:
...
@@ -42,13 +85,13 @@ struct SSchema;
...
@@ -42,13 +85,13 @@ struct SSchema;
*/
*/
bool
isValidSchema
(
struct
SSchema
*
pSchema
,
int32_t
numOfCols
);
bool
isValidSchema
(
struct
SSchema
*
pSchema
,
int32_t
numOfCols
);
struct
SSchema
*
tsGetSchema
(
STableMeta
*
pMeta
);
/**
* get the schema for the "tbname" column. it is a built column
struct
SSchema
*
tsGetTagSchema
(
STableMeta
*
pMeta
);
* @return
*/
struct
SSchema
*
tsGetColumnSchema
(
STableMeta
*
pMeta
,
int32_t
startCol
);
SSchema
tsGetTbnameColumnSchema
();
struct
SSchema
tsGetTbnameColumnSchema
();
//todo tags value as well as the table id structure needs refactor
char
*
tsGetTagsValue
(
STableMeta
*
pMeta
);
char
*
tsGetTagsValue
(
STableMeta
*
pMeta
);
bool
tsMeterMetaIdentical
(
STableMeta
*
p1
,
STableMeta
*
p2
);
bool
tsMeterMetaIdentical
(
STableMeta
*
p1
,
STableMeta
*
p2
);
...
...
src/client/inc/tsclient.h
浏览文件 @
03346d0c
...
@@ -46,8 +46,47 @@ typedef struct SSqlGroupbyExpr {
...
@@ -46,8 +46,47 @@ typedef struct SSqlGroupbyExpr {
int16_t
orderType
;
// order by type: asc/desc
int16_t
orderType
;
// order by type: asc/desc
}
SSqlGroupbyExpr
;
}
SSqlGroupbyExpr
;
typedef
struct
SMeterMetaInfo
{
typedef
struct
STableInfo
{
STableMeta
*
pMeterMeta
;
// metermeta
uint8_t
numOfTags
;
uint8_t
precision
;
int16_t
numOfColumns
;
int16_t
rowSize
;
}
STableInfo
;
typedef
struct
STableMeta
{
char
*
tableId
;
// null-terminated string
union
{
// pointer to super table if it is created according to super table
struct
STableMeta
*
pSTable
;
// otherwise, the following information is required.
STableInfo
tableInfo
;
};
uint8_t
tableType
;
int16_t
sversion
;
int8_t
numOfVpeers
;
SVnodeDesc
vpeerDesc
[
TSDB_VNODES_SUPPORT
];
int32_t
sid
;
int32_t
vgid
;
uint64_t
uid
;
// if the table is TSDB_CHILD_TABLE, schema is acquired by super table meta info
SSchema
schema
[];
}
STableMeta
;
typedef
struct
SSTableMeta
{
char
*
tableId
;
STableInfo
tableInfo
;
int32_t
sid
;
int32_t
vgid
;
uint64_t
uid
;
SSchema
schema
[];
}
SSTableMeta
;
typedef
struct
STableMetaInfo
{
STableMeta
*
pTableMeta
;
// table meta info
SSuperTableMeta
*
pMetricMeta
;
// metricmeta
SSuperTableMeta
*
pMetricMeta
;
// metricmeta
/*
/*
...
@@ -55,10 +94,10 @@ typedef struct SMeterMetaInfo {
...
@@ -55,10 +94,10 @@ typedef struct SMeterMetaInfo {
* 2. keep the vnode index for multi-vnode insertion
* 2. keep the vnode index for multi-vnode insertion
*/
*/
int32_t
vnodeIndex
;
int32_t
vnodeIndex
;
char
name
[
TSDB_TABLE_ID_LEN
+
1
];
//
table(super table)
name
char
name
[
TSDB_TABLE_ID_LEN
+
1
];
//
(super) table
name
int16_t
numOfTags
;
// total required tags in query, including groupby tags
int16_t
numOfTags
;
// total required tags in query, including groupby tags
int16_t
tagColumnIndex
[
TSDB_MAX_TAGS
];
// clause + tag projection
int16_t
tagColumnIndex
[
TSDB_MAX_TAGS
];
// clause + tag projection
}
S
Meter
MetaInfo
;
}
S
Table
MetaInfo
;
/* the structure for sql function in select clause */
/* the structure for sql function in select clause */
typedef
struct
SSqlExpr
{
typedef
struct
SSqlExpr
{
...
@@ -174,7 +213,7 @@ typedef struct STableDataBlocks {
...
@@ -174,7 +213,7 @@ typedef struct STableDataBlocks {
* the metermeta for current table, the metermeta will be used during submit stage, keep a ref
* the metermeta for current table, the metermeta will be used during submit stage, keep a ref
* to avoid it to be removed from cache
* to avoid it to be removed from cache
*/
*/
STableMeta
*
p
Meter
Meta
;
STableMeta
*
p
Table
Meta
;
union
{
union
{
char
*
filename
;
char
*
filename
;
...
@@ -215,7 +254,7 @@ typedef struct SQueryInfo {
...
@@ -215,7 +254,7 @@ typedef struct SQueryInfo {
SOrderVal
order
;
SOrderVal
order
;
int16_t
interpoType
;
// interpolate type
int16_t
interpoType
;
// interpolate type
int16_t
numOfTables
;
int16_t
numOfTables
;
S
Meter
MetaInfo
**
pMeterInfo
;
S
Table
MetaInfo
**
pMeterInfo
;
struct
STSBuf
*
tsBuf
;
struct
STSBuf
*
tsBuf
;
int64_t
*
defaultVal
;
// default value for interpolation
int64_t
*
defaultVal
;
// default value for interpolation
char
*
msg
;
// pointer to the pCmd->payload to keep error message temporarily
char
*
msg
;
// pointer to the pCmd->payload to keep error message temporarily
...
...
src/client/src/tscAsync.c
浏览文件 @
03346d0c
...
@@ -406,11 +406,11 @@ void tscAsyncInsertMultiVnodesProxy(void *param, TAOS_RES *tres, int numOfRows)
...
@@ -406,11 +406,11 @@ void tscAsyncInsertMultiVnodesProxy(void *param, TAOS_RES *tres, int numOfRows)
int32_t
index
=
0
;
int32_t
index
=
0
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
index
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
index
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
assert
(
pQueryInfo
->
numOfTables
==
1
||
pQueryInfo
->
numOfTables
==
2
);
assert
(
pQueryInfo
->
numOfTables
==
1
||
pQueryInfo
->
numOfTables
==
2
);
SDataBlockList
*
pDataBlocks
=
pCmd
->
pDataBlocks
;
SDataBlockList
*
pDataBlocks
=
pCmd
->
pDataBlocks
;
if
(
pDataBlocks
==
NULL
||
p
Meter
MetaInfo
->
vnodeIndex
>=
pDataBlocks
->
nSize
)
{
if
(
pDataBlocks
==
NULL
||
p
Table
MetaInfo
->
vnodeIndex
>=
pDataBlocks
->
nSize
)
{
// restore user defined fp
// restore user defined fp
pSql
->
fp
=
pSql
->
fetchFp
;
pSql
->
fp
=
pSql
->
fetchFp
;
tscTrace
(
"%p Async insertion completed, destroy data block list"
,
pSql
);
tscTrace
(
"%p Async insertion completed, destroy data block list"
,
pSql
);
...
@@ -422,17 +422,17 @@ void tscAsyncInsertMultiVnodesProxy(void *param, TAOS_RES *tres, int numOfRows)
...
@@ -422,17 +422,17 @@ void tscAsyncInsertMultiVnodesProxy(void *param, TAOS_RES *tres, int numOfRows)
(
*
pSql
->
fp
)(
pSql
->
param
,
tres
,
numOfRows
);
(
*
pSql
->
fp
)(
pSql
->
param
,
tres
,
numOfRows
);
}
else
{
}
else
{
do
{
do
{
code
=
tscCopyDataBlockToPayload
(
pSql
,
pDataBlocks
->
pData
[
p
Meter
MetaInfo
->
vnodeIndex
++
]);
code
=
tscCopyDataBlockToPayload
(
pSql
,
pDataBlocks
->
pData
[
p
Table
MetaInfo
->
vnodeIndex
++
]);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tscTrace
(
"%p prepare submit data block failed in async insertion, vnodeIdx:%d, total:%d, code:%d"
,
tscTrace
(
"%p prepare submit data block failed in async insertion, vnodeIdx:%d, total:%d, code:%d"
,
pSql
,
p
Meter
MetaInfo
->
vnodeIndex
-
1
,
pDataBlocks
->
nSize
,
code
);
pSql
,
p
Table
MetaInfo
->
vnodeIndex
-
1
,
pDataBlocks
->
nSize
,
code
);
}
}
}
while
(
code
!=
TSDB_CODE_SUCCESS
&&
p
Meter
MetaInfo
->
vnodeIndex
<
pDataBlocks
->
nSize
);
}
while
(
code
!=
TSDB_CODE_SUCCESS
&&
p
Table
MetaInfo
->
vnodeIndex
<
pDataBlocks
->
nSize
);
// build submit msg may fail
// build submit msg may fail
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
tscTrace
(
"%p async insertion, vnodeIdx:%d, total:%d"
,
pSql
,
p
Meter
MetaInfo
->
vnodeIndex
-
1
,
pDataBlocks
->
nSize
);
tscTrace
(
"%p async insertion, vnodeIdx:%d, total:%d"
,
pSql
,
p
Table
MetaInfo
->
vnodeIndex
-
1
,
pDataBlocks
->
nSize
);
tscProcessSql
(
pSql
);
tscProcessSql
(
pSql
);
}
}
}
}
...
@@ -464,10 +464,10 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
...
@@ -464,10 +464,10 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
tscTrace
(
"%p renew tableMeta successfully, command:%d, code:%d, retry:%d"
,
tscTrace
(
"%p renew tableMeta successfully, command:%d, code:%d, retry:%d"
,
pSql
,
pSql
->
cmd
.
command
,
pSql
->
res
.
code
,
pSql
->
retry
);
pSql
,
pSql
->
cmd
.
command
,
pSql
->
res
.
code
,
pSql
->
retry
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
);
assert
(
p
MeterMetaInfo
->
pMeter
Meta
==
NULL
);
assert
(
p
TableMetaInfo
->
pTable
Meta
==
NULL
);
tscGetMeterMeta
(
pSql
,
p
Meter
MetaInfo
);
tscGetMeterMeta
(
pSql
,
p
Table
MetaInfo
);
code
=
tscSendMsgToServer
(
pSql
);
code
=
tscSendMsgToServer
(
pSql
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
pRes
->
code
=
code
;
pRes
->
code
=
code
;
...
@@ -489,18 +489,18 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
...
@@ -489,18 +489,18 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
if
((
pQueryInfo
->
type
&
TSDB_QUERY_TYPE_STABLE_SUBQUERY
)
==
TSDB_QUERY_TYPE_STABLE_SUBQUERY
)
{
if
((
pQueryInfo
->
type
&
TSDB_QUERY_TYPE_STABLE_SUBQUERY
)
==
TSDB_QUERY_TYPE_STABLE_SUBQUERY
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
assert
(
pMeterMetaInfo
->
pMeterMeta
->
numOfTags
!=
0
&&
pMeter
MetaInfo
->
vnodeIndex
>=
0
&&
pSql
->
param
!=
NULL
);
// assert(pTableMetaInfo->pTableMeta->numOfTags != 0 && pTable
MetaInfo->vnodeIndex >= 0 && pSql->param != NULL);
SRetrieveSupport
*
trs
=
(
SRetrieveSupport
*
)
pSql
->
param
;
SRetrieveSupport
*
trs
=
(
SRetrieveSupport
*
)
pSql
->
param
;
SSqlObj
*
pParObj
=
trs
->
pParentSqlObj
;
SSqlObj
*
pParObj
=
trs
->
pParentSqlObj
;
assert
(
pParObj
->
signature
==
pParObj
&&
trs
->
subqueryIndex
==
pMeter
MetaInfo
->
vnodeIndex
&&
// assert(pParObj->signature == pParObj && trs->subqueryIndex == pTable
MetaInfo->vnodeIndex &&
pMeterMetaInfo
->
pMeter
Meta
->
numOfTags
!=
0
);
// pTableMetaInfo->pTable
Meta->numOfTags != 0);
tscTrace
(
"%p get metricMeta during super table query successfully"
,
pSql
);
tscTrace
(
"%p get metricMeta during super table query successfully"
,
pSql
);
code
=
tscGetMeterMeta
(
pSql
,
p
Meter
MetaInfo
);
code
=
tscGetMeterMeta
(
pSql
,
p
Table
MetaInfo
);
pRes
->
code
=
code
;
pRes
->
code
=
code
;
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
return
;
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
return
;
...
@@ -513,11 +513,11 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
...
@@ -513,11 +513,11 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
if
(
pCmd
->
isParseFinish
)
{
if
(
pCmd
->
isParseFinish
)
{
tscTrace
(
"%p resend data to vnode in metermeta callback since sql has been parsed completed"
,
pSql
);
tscTrace
(
"%p resend data to vnode in metermeta callback since sql has been parsed completed"
,
pSql
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
code
=
tscGetMeterMeta
(
pSql
,
p
Meter
MetaInfo
);
code
=
tscGetMeterMeta
(
pSql
,
p
Table
MetaInfo
);
assert
(
code
==
TSDB_CODE_SUCCESS
);
assert
(
code
==
TSDB_CODE_SUCCESS
);
if
(
p
MeterMetaInfo
->
pMeter
Meta
)
{
if
(
p
TableMetaInfo
->
pTable
Meta
)
{
code
=
tscSendMsgToServer
(
pSql
);
code
=
tscSendMsgToServer
(
pSql
);
if
(
code
==
TSDB_CODE_SUCCESS
)
return
;
if
(
code
==
TSDB_CODE_SUCCESS
)
return
;
}
}
...
@@ -528,13 +528,13 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
...
@@ -528,13 +528,13 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
}
}
}
else
{
// stream computing
}
else
{
// stream computing
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
code
=
tscGetMeterMeta
(
pSql
,
p
Meter
MetaInfo
);
code
=
tscGetMeterMeta
(
pSql
,
p
Table
MetaInfo
);
pRes
->
code
=
code
;
pRes
->
code
=
code
;
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
return
;
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
return
;
if
(
code
==
TSDB_CODE_SUCCESS
&&
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
))
{
if
(
code
==
TSDB_CODE_SUCCESS
&&
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
))
{
code
=
tscGetMetricMeta
(
pSql
,
pCmd
->
clauseIndex
);
code
=
tscGetMetricMeta
(
pSql
,
pCmd
->
clauseIndex
);
pRes
->
code
=
code
;
pRes
->
code
=
code
;
...
...
src/client/src/tscJoinProcess.c
浏览文件 @
03346d0c
...
@@ -164,8 +164,8 @@ SJoinSubquerySupporter* tscCreateJoinSupporter(SSqlObj* pSql, SSubqueryState* pS
...
@@ -164,8 +164,8 @@ SJoinSubquerySupporter* tscCreateJoinSupporter(SSqlObj* pSql, SSubqueryState* pS
pSupporter
->
interval
=
pQueryInfo
->
intervalTime
;
pSupporter
->
interval
=
pQueryInfo
->
intervalTime
;
pSupporter
->
limit
=
pQueryInfo
->
limit
;
pSupporter
->
limit
=
pQueryInfo
->
limit
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
pSql
->
cmd
.
clauseIndex
,
index
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
pSql
->
cmd
.
clauseIndex
,
index
);
pSupporter
->
uid
=
p
MeterMetaInfo
->
pMeter
Meta
->
uid
;
pSupporter
->
uid
=
p
TableMetaInfo
->
pTable
Meta
->
uid
;
assert
(
pSupporter
->
uid
!=
0
);
assert
(
pSupporter
->
uid
!=
0
);
...
@@ -315,7 +315,7 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
...
@@ -315,7 +315,7 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
tscFieldInfoCalOffset
(
pNewQueryInfo
);
tscFieldInfoCalOffset
(
pNewQueryInfo
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pNewQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pNewQueryInfo
,
0
);
/*
/*
* When handling the projection query, the offset value will be modified for table-table join, which is changed
* When handling the projection query, the offset value will be modified for table-table join, which is changed
...
@@ -325,11 +325,11 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
...
@@ -325,11 +325,11 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
pNewQueryInfo
->
limit
=
pSupporter
->
limit
;
pNewQueryInfo
->
limit
=
pSupporter
->
limit
;
// fetch the join tag column
// fetch the join tag column
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
))
{
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
))
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pNewQueryInfo
,
0
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pNewQueryInfo
,
0
);
assert
(
pQueryInfo
->
tagCond
.
joinInfo
.
hasJoin
);
assert
(
pQueryInfo
->
tagCond
.
joinInfo
.
hasJoin
);
int16_t
tagColIndex
=
tscGetJoinTagColIndexByUid
(
&
pQueryInfo
->
tagCond
,
p
MeterMetaInfo
->
pMeter
Meta
->
uid
);
int16_t
tagColIndex
=
tscGetJoinTagColIndexByUid
(
&
pQueryInfo
->
tagCond
,
p
TableMetaInfo
->
pTable
Meta
->
uid
);
pExpr
->
param
[
0
].
i64Key
=
tagColIndex
;
pExpr
->
param
[
0
].
i64Key
=
tagColIndex
;
pExpr
->
numOfParams
=
1
;
pExpr
->
numOfParams
=
1
;
}
}
...
@@ -337,7 +337,7 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
...
@@ -337,7 +337,7 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
tscPrintSelectClause
(
pNew
,
0
);
tscPrintSelectClause
(
pNew
,
0
);
tscTrace
(
"%p subquery:%p tableIndex:%d, vnodeIdx:%d, type:%d, exprInfo:%d, colList:%d, fieldsInfo:%d, name:%s"
,
tscTrace
(
"%p subquery:%p tableIndex:%d, vnodeIdx:%d, type:%d, exprInfo:%d, colList:%d, fieldsInfo:%d, name:%s"
,
pSql
,
pNew
,
0
,
p
Meter
MetaInfo
->
vnodeIndex
,
pNewQueryInfo
->
type
,
pSql
,
pNew
,
0
,
p
Table
MetaInfo
->
vnodeIndex
,
pNewQueryInfo
->
type
,
pNewQueryInfo
->
exprsInfo
.
numOfExprs
,
pNewQueryInfo
->
colList
.
numOfCols
,
pNewQueryInfo
->
exprsInfo
.
numOfExprs
,
pNewQueryInfo
->
colList
.
numOfCols
,
pNewQueryInfo
->
fieldsInfo
.
numOfOutputCols
,
pNewQueryInfo
->
pMeterInfo
[
0
]
->
name
);
pNewQueryInfo
->
fieldsInfo
.
numOfOutputCols
,
pNewQueryInfo
->
pMeterInfo
[
0
]
->
name
);
}
}
...
@@ -450,9 +450,9 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
...
@@ -450,9 +450,9 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
pSupporter
->
pTSBuf
=
pBuf
;
pSupporter
->
pTSBuf
=
pBuf
;
}
else
{
}
else
{
assert
(
pQueryInfo
->
numOfTables
==
1
);
// for subquery, only one metermetaInfo
assert
(
pQueryInfo
->
numOfTables
==
1
);
// for subquery, only one metermetaInfo
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
tsBufMerge
(
pSupporter
->
pTSBuf
,
pBuf
,
p
Meter
MetaInfo
->
vnodeIndex
);
tsBufMerge
(
pSupporter
->
pTSBuf
,
pBuf
,
p
Table
MetaInfo
->
vnodeIndex
);
tsBufDestory
(
pBuf
);
tsBufDestory
(
pBuf
);
}
}
...
@@ -467,14 +467,14 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
...
@@ -467,14 +467,14 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
//todo refactor
//todo refactor
if
(
tscNonOrderedProjectionQueryOnSTable
(
pParentQueryInfo
,
0
))
{
if
(
tscNonOrderedProjectionQueryOnSTable
(
pParentQueryInfo
,
0
))
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
assert
(
pQueryInfo
->
numOfTables
==
1
);
assert
(
pQueryInfo
->
numOfTables
==
1
);
// for projection query, need to try next vnode
// for projection query, need to try next vnode
int32_t
totalVnode
=
p
Meter
MetaInfo
->
pMetricMeta
->
numOfVnodes
;
int32_t
totalVnode
=
p
Table
MetaInfo
->
pMetricMeta
->
numOfVnodes
;
if
((
++
p
Meter
MetaInfo
->
vnodeIndex
)
<
totalVnode
)
{
if
((
++
p
Table
MetaInfo
->
vnodeIndex
)
<
totalVnode
)
{
tscTrace
(
"%p current vnode:%d exhausted, try next:%d. total vnode:%d. current numOfRes:%d"
,
pSql
,
tscTrace
(
"%p current vnode:%d exhausted, try next:%d. total vnode:%d. current numOfRes:%d"
,
pSql
,
p
MeterMetaInfo
->
vnodeIndex
-
1
,
pMeter
MetaInfo
->
vnodeIndex
,
totalVnode
,
pRes
->
numOfTotal
);
p
TableMetaInfo
->
vnodeIndex
-
1
,
pTable
MetaInfo
->
vnodeIndex
,
totalVnode
,
pRes
->
numOfTotal
);
pSql
->
cmd
.
command
=
TSDB_SQL_SELECT
;
pSql
->
cmd
.
command
=
TSDB_SQL_SELECT
;
pSql
->
fp
=
tscJoinQueryCallback
;
pSql
->
fp
=
tscJoinQueryCallback
;
...
@@ -532,11 +532,11 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
...
@@ -532,11 +532,11 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
}
}
if
(
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
)
&&
numOfRows
==
0
)
{
if
(
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
)
&&
numOfRows
==
0
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
assert
(
pQueryInfo
->
numOfTables
==
1
);
assert
(
pQueryInfo
->
numOfTables
==
1
);
// for projection query, need to try next vnode if current vnode is exhausted
// for projection query, need to try next vnode if current vnode is exhausted
if
((
++
p
MeterMetaInfo
->
vnodeIndex
)
<
pMeter
MetaInfo
->
pMetricMeta
->
numOfVnodes
)
{
if
((
++
p
TableMetaInfo
->
vnodeIndex
)
<
pTable
MetaInfo
->
pMetricMeta
->
numOfVnodes
)
{
pSupporter
->
pState
->
numOfCompleted
=
0
;
pSupporter
->
pState
->
numOfCompleted
=
0
;
pSupporter
->
pState
->
numOfTotal
=
1
;
pSupporter
->
pState
->
numOfTotal
=
1
;
...
@@ -600,10 +600,10 @@ void tscFetchDatablockFromSubquery(SSqlObj* pSql) {
...
@@ -600,10 +600,10 @@ void tscFetchDatablockFromSubquery(SSqlObj* pSql) {
SSqlRes
*
pRes
=
&
pSql
->
pSubs
[
i
]
->
res
;
SSqlRes
*
pRes
=
&
pSql
->
pSubs
[
i
]
->
res
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
pSubs
[
i
]
->
cmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
pSubs
[
i
]
->
cmd
,
0
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
if
(
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
))
{
if
(
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
))
{
if
(
pRes
->
row
>=
pRes
->
numOfRows
&&
p
MeterMetaInfo
->
vnodeIndex
<
pMeter
MetaInfo
->
pMetricMeta
->
numOfVnodes
&&
if
(
pRes
->
row
>=
pRes
->
numOfRows
&&
p
TableMetaInfo
->
vnodeIndex
<
pTable
MetaInfo
->
pMetricMeta
->
numOfVnodes
&&
(
!
tscHasReachLimitation
(
pQueryInfo
,
pRes
)))
{
(
!
tscHasReachLimitation
(
pQueryInfo
,
pRes
)))
{
numOfFetch
++
;
numOfFetch
++
;
}
}
...
@@ -638,11 +638,11 @@ void tscFetchDatablockFromSubquery(SSqlObj* pSql) {
...
@@ -638,11 +638,11 @@ void tscFetchDatablockFromSubquery(SSqlObj* pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd1
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd1
,
0
);
assert
(
pRes1
->
numOfRows
>=
0
&&
pQueryInfo
->
numOfTables
==
1
);
assert
(
pRes1
->
numOfRows
>=
0
&&
pQueryInfo
->
numOfTables
==
1
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
if
(
pRes1
->
row
>=
pRes1
->
numOfRows
)
{
if
(
pRes1
->
row
>=
pRes1
->
numOfRows
)
{
tscTrace
(
"%p subquery:%p retrieve data from vnode, subquery:%d, vnodeIndex:%d"
,
pSql
,
pSql1
,
tscTrace
(
"%p subquery:%p retrieve data from vnode, subquery:%d, vnodeIndex:%d"
,
pSql
,
pSql1
,
pSupporter
->
subqueryIndex
,
p
Meter
MetaInfo
->
vnodeIndex
);
pSupporter
->
subqueryIndex
,
p
Table
MetaInfo
->
vnodeIndex
);
tscResetForNextRetrieve
(
pRes1
);
tscResetForNextRetrieve
(
pRes1
);
pSql1
->
fp
=
joinRetrieveCallback
;
pSql1
->
fp
=
joinRetrieveCallback
;
...
@@ -688,8 +688,8 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
...
@@ -688,8 +688,8 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
int32_t
tableIndexOfSub
=
-
1
;
int32_t
tableIndexOfSub
=
-
1
;
for
(
int32_t
j
=
0
;
j
<
pQueryInfo
->
numOfTables
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
pQueryInfo
->
numOfTables
;
++
j
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
j
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
j
);
if
(
p
MeterMetaInfo
->
pMeter
Meta
->
uid
==
pExpr
->
uid
)
{
if
(
p
TableMetaInfo
->
pTable
Meta
->
uid
==
pExpr
->
uid
)
{
tableIndexOfSub
=
j
;
tableIndexOfSub
=
j
;
break
;
break
;
}
}
...
@@ -712,13 +712,13 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
...
@@ -712,13 +712,13 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
void
tscJoinQueryCallback
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
{
void
tscJoinQueryCallback
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
{
SSqlObj
*
pSql
=
(
SSqlObj
*
)
tres
;
SSqlObj
*
pSql
=
(
SSqlObj
*
)
tres
;
// S
MeterMetaInfo *pMeter
MetaInfo = tscGetMeterMetaInfo(&pSql->cmd, 0, 0);
// S
TableMetaInfo *pTable
MetaInfo = tscGetMeterMetaInfo(&pSql->cmd, 0, 0);
// int32_t idx = pSql->cmd.vnodeIdx;
// int32_t idx = pSql->cmd.vnodeIdx;
// SVnodeSidList *vnodeInfo = NULL;
// SVnodeSidList *vnodeInfo = NULL;
// if (p
Meter
MetaInfo->pMetricMeta != NULL) {
// if (p
Table
MetaInfo->pMetricMeta != NULL) {
// vnodeInfo = tscGetVnodeSidList(p
Meter
MetaInfo->pMetricMeta, idx - 1);
// vnodeInfo = tscGetVnodeSidList(p
Table
MetaInfo->pMetricMeta, idx - 1);
// }
// }
SJoinSubquerySupporter
*
pSupporter
=
(
SJoinSubquerySupporter
*
)
param
;
SJoinSubquerySupporter
*
pSupporter
=
(
SJoinSubquerySupporter
*
)
param
;
...
@@ -776,14 +776,14 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) {
...
@@ -776,14 +776,14 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) {
assert
(
finished
==
numOfTotal
);
assert
(
finished
==
numOfTotal
);
tscSetupOutputColumnIndex
(
pParentSql
);
tscSetupOutputColumnIndex
(
pParentSql
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
/**
/**
* if the query is a continue query (vnodeIndex > 0 for projection query) for next vnode, do the retrieval of
* if the query is a continue query (vnodeIndex > 0 for projection query) for next vnode, do the retrieval of
* data instead of returning to its invoker
* data instead of returning to its invoker
*/
*/
if
(
p
Meter
MetaInfo
->
vnodeIndex
>
0
&&
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
))
{
if
(
p
Table
MetaInfo
->
vnodeIndex
>
0
&&
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
))
{
assert
(
p
MeterMetaInfo
->
vnodeIndex
<
pMeter
MetaInfo
->
pMetricMeta
->
numOfVnodes
);
assert
(
p
TableMetaInfo
->
vnodeIndex
<
pTable
MetaInfo
->
pMetricMeta
->
numOfVnodes
);
pSupporter
->
pState
->
numOfCompleted
=
0
;
// reset the record value
pSupporter
->
pState
->
numOfCompleted
=
0
;
// reset the record value
pSql
->
fp
=
joinRetrieveCallback
;
// continue retrieve data
pSql
->
fp
=
joinRetrieveCallback
;
// continue retrieve data
...
...
src/client/src/tscLocal.c
浏览文件 @
03346d0c
...
@@ -77,7 +77,7 @@ static int32_t getToStringLength(const char *pData, int32_t length, int32_t type
...
@@ -77,7 +77,7 @@ static int32_t getToStringLength(const char *pData, int32_t length, int32_t type
* length((uint64_t) 123456789011) > 12, greater than sizsof(uint64_t)
* length((uint64_t) 123456789011) > 12, greater than sizsof(uint64_t)
*/
*/
static
int32_t
tscMaxLengthOfTagsFields
(
SSqlObj
*
pSql
)
{
static
int32_t
tscMaxLengthOfTagsFields
(
SSqlObj
*
pSql
)
{
STableMeta
*
pMeta
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
)
->
p
Meter
Meta
;
STableMeta
*
pMeta
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
)
->
p
Table
Meta
;
if
(
pMeta
->
tableType
==
TSDB_SUPER_TABLE
||
pMeta
->
tableType
==
TSDB_NORMAL_TABLE
||
if
(
pMeta
->
tableType
==
TSDB_SUPER_TABLE
||
pMeta
->
tableType
==
TSDB_NORMAL_TABLE
||
pMeta
->
tableType
==
TSDB_STREAM_TABLE
)
{
pMeta
->
tableType
==
TSDB_STREAM_TABLE
)
{
...
@@ -85,12 +85,14 @@ static int32_t tscMaxLengthOfTagsFields(SSqlObj *pSql) {
...
@@ -85,12 +85,14 @@ static int32_t tscMaxLengthOfTagsFields(SSqlObj *pSql) {
}
}
char
*
pTagValue
=
tsGetTagsValue
(
pMeta
);
char
*
pTagValue
=
tsGetTagsValue
(
pMeta
);
SSchema
*
pTagsSchema
=
ts
Get
TagSchema
(
pMeta
);
SSchema
*
pTagsSchema
=
ts
cGetTable
TagSchema
(
pMeta
);
int32_t
len
=
getToStringLength
(
pTagValue
,
pTagsSchema
[
0
].
bytes
,
pTagsSchema
[
0
].
type
);
int32_t
len
=
getToStringLength
(
pTagValue
,
pTagsSchema
[
0
].
bytes
,
pTagsSchema
[
0
].
type
);
pTagValue
+=
pTagsSchema
[
0
].
bytes
;
pTagValue
+=
pTagsSchema
[
0
].
bytes
;
for
(
int32_t
i
=
1
;
i
<
pMeta
->
numOfTags
;
++
i
)
{
int32_t
numOfTags
=
tscGetNumOfTags
(
pMeta
);
for
(
int32_t
i
=
1
;
i
<
numOfTags
;
++
i
)
{
int32_t
tLen
=
getToStringLength
(
pTagValue
,
pTagsSchema
[
i
].
bytes
,
pTagsSchema
[
i
].
type
);
int32_t
tLen
=
getToStringLength
(
pTagValue
,
pTagsSchema
[
i
].
bytes
,
pTagsSchema
[
i
].
type
);
if
(
len
<
tLen
)
{
if
(
len
<
tLen
)
{
len
=
tLen
;
len
=
tLen
;
...
@@ -108,8 +110,8 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
...
@@ -108,8 +110,8 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
// one column for each row
// one column for each row
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
STableMeta
*
pMeta
=
p
MeterMetaInfo
->
pMeter
Meta
;
STableMeta
*
pMeta
=
p
TableMetaInfo
->
pTable
Meta
;
/*
/*
* tagValueCnt is to denote the number of tags columns for meter, not metric. and is to show the column data.
* tagValueCnt is to denote the number of tags columns for meter, not metric. and is to show the column data.
...
@@ -117,15 +119,15 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
...
@@ -117,15 +119,15 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
* for metric, the value of tagValueCnt must be 0, but the numOfTags is not 0
* for metric, the value of tagValueCnt must be 0, but the numOfTags is not 0
*/
*/
int32_t
numOfRows
=
pMeta
->
numOfColumns
;
int32_t
numOfRows
=
tscGetNumOfColumns
(
pMeta
)
;
int32_t
totalNumOfRows
=
numOfRows
+
pMeta
->
numOfTags
;
int32_t
totalNumOfRows
=
numOfRows
+
tscGetNumOfTags
(
pMeta
)
;
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
))
{
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
))
{
numOfRows
=
pMeta
->
numOfColumns
+
pMeta
->
numOfTags
;
numOfRows
=
numOfRows
+
tscGetNumOfTags
(
pMeta
)
;
}
}
tscInitResObjForLocalQuery
(
pSql
,
totalNumOfRows
,
rowLen
);
tscInitResObjForLocalQuery
(
pSql
,
totalNumOfRows
,
rowLen
);
SSchema
*
pSchema
=
ts
Get
Schema
(
pMeta
);
SSchema
*
pSchema
=
ts
cGetTable
Schema
(
pMeta
);
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
pQueryInfo
,
0
);
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
pQueryInfo
,
0
);
...
@@ -146,13 +148,13 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
...
@@ -146,13 +148,13 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
*
(
int32_t
*
)(
pRes
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
2
)
*
totalNumOfRows
+
pField
->
bytes
*
i
)
=
bytes
;
*
(
int32_t
*
)(
pRes
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
2
)
*
totalNumOfRows
+
pField
->
bytes
*
i
)
=
bytes
;
pField
=
tscFieldInfoGetField
(
pQueryInfo
,
3
);
pField
=
tscFieldInfoGetField
(
pQueryInfo
,
3
);
if
(
i
>=
pMeta
->
numOfColumns
&&
pMeta
->
numOfTags
!=
0
)
{
if
(
i
>=
tscGetNumOfColumns
(
pMeta
)
&&
tscGetNumOfTags
(
pMeta
)
!=
0
)
{
strncpy
(
pRes
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
3
)
*
totalNumOfRows
+
pField
->
bytes
*
i
,
"tag"
,
strncpy
(
pRes
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
3
)
*
totalNumOfRows
+
pField
->
bytes
*
i
,
"tag"
,
strlen
(
"tag"
)
+
1
);
strlen
(
"tag"
)
+
1
);
}
}
}
}
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
))
{
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
))
{
return
0
;
return
0
;
}
}
...
@@ -265,7 +267,7 @@ static int32_t tscBuildMeterSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
...
@@ -265,7 +267,7 @@ static int32_t tscBuildMeterSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
static
int32_t
tscProcessDescribeTable
(
SSqlObj
*
pSql
)
{
static
int32_t
tscProcessDescribeTable
(
SSqlObj
*
pSql
)
{
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
assert
(
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
)
->
p
Meter
Meta
!=
NULL
);
assert
(
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
)
->
p
Table
Meta
!=
NULL
);
const
int32_t
NUM_OF_DESCRIBE_TABLE_COLUMNS
=
4
;
const
int32_t
NUM_OF_DESCRIBE_TABLE_COLUMNS
=
4
;
const
int32_t
TYPE_COLUMN_LENGTH
=
16
;
const
int32_t
TYPE_COLUMN_LENGTH
=
16
;
...
@@ -290,15 +292,15 @@ static int tscBuildMetricTagProjectionResult(SSqlObj *pSql) {
...
@@ -290,15 +292,15 @@ static int tscBuildMetricTagProjectionResult(SSqlObj *pSql) {
SSqlRes
*
pRes
=
&
pSql
->
res
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
SSuperTableMeta
*
pMetricMeta
=
p
Meter
MetaInfo
->
pMetricMeta
;
SSuperTableMeta
*
pMetricMeta
=
p
Table
MetaInfo
->
pMetricMeta
;
SSchema
*
pSchema
=
ts
GetTagSchema
(
pMeterMetaInfo
->
pMeter
Meta
);
SSchema
*
pSchema
=
ts
cGetTableTagSchema
(
pTableMetaInfo
->
pTable
Meta
);
int32_t
vOffset
[
TSDB_MAX_COLUMNS
]
=
{
0
};
int32_t
vOffset
[
TSDB_MAX_COLUMNS
]
=
{
0
};
for
(
int32_t
f
=
1
;
f
<
p
Meter
MetaInfo
->
numOfTags
;
++
f
)
{
for
(
int32_t
f
=
1
;
f
<
p
Table
MetaInfo
->
numOfTags
;
++
f
)
{
int16_t
tagColumnIndex
=
p
Meter
MetaInfo
->
tagColumnIndex
[
f
-
1
];
int16_t
tagColumnIndex
=
p
Table
MetaInfo
->
tagColumnIndex
[
f
-
1
];
if
(
tagColumnIndex
==
-
1
)
{
if
(
tagColumnIndex
==
-
1
)
{
vOffset
[
f
]
=
vOffset
[
f
-
1
]
+
TSDB_TABLE_NAME_LEN
;
vOffset
[
f
]
=
vOffset
[
f
-
1
]
+
TSDB_TABLE_NAME_LEN
;
}
else
{
}
else
{
...
@@ -375,8 +377,8 @@ static int tscProcessQueryTags(SSqlObj *pSql) {
...
@@ -375,8 +377,8 @@ static int tscProcessQueryTags(SSqlObj *pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
STableMeta
*
p
MeterMeta
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
)
->
pMeter
Meta
;
STableMeta
*
p
TableMeta
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
)
->
pTable
Meta
;
if
(
p
MeterMeta
==
NULL
||
pMeterMeta
->
numOfTags
==
0
||
pMeterMeta
->
numOfColumns
==
0
)
{
if
(
p
TableMeta
==
NULL
||
tscGetNumOfTags
(
pTableMeta
)
==
0
||
tscGetNumOfColumns
(
pTableMeta
)
==
0
)
{
strcpy
(
pCmd
->
payload
,
"invalid table"
);
strcpy
(
pCmd
->
payload
,
"invalid table"
);
pSql
->
res
.
code
=
TSDB_CODE_INVALID_TABLE
;
pSql
->
res
.
code
=
TSDB_CODE_INVALID_TABLE
;
return
pSql
->
res
.
code
;
return
pSql
->
res
.
code
;
...
...
src/client/src/tscParseInsert.c
浏览文件 @
03346d0c
...
@@ -496,15 +496,17 @@ static int32_t rowDataCompar(const void *lhs, const void *rhs) {
...
@@ -496,15 +496,17 @@ static int32_t rowDataCompar(const void *lhs, const void *rhs) {
}
}
}
}
int
tsParseValues
(
char
**
str
,
STableDataBlocks
*
pDataBlock
,
STableMeta
*
p
Meter
Meta
,
int
maxRows
,
int
tsParseValues
(
char
**
str
,
STableDataBlocks
*
pDataBlock
,
STableMeta
*
p
Table
Meta
,
int
maxRows
,
SParsedDataColInfo
*
spd
,
char
*
error
,
int32_t
*
code
,
char
*
tmpTokenBuf
)
{
SParsedDataColInfo
*
spd
,
char
*
error
,
int32_t
*
code
,
char
*
tmpTokenBuf
)
{
int32_t
index
=
0
;
int32_t
index
=
0
;
SSQLToken
sToken
;
SSQLToken
sToken
;
int16_t
numOfRows
=
0
;
int16_t
numOfRows
=
0
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMeta
);
int32_t
precision
=
pMeterMeta
->
precision
;
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMeta
);
int32_t
precision
=
tinfo
.
precision
;
if
(
spd
->
hasVal
[
0
]
==
false
)
{
if
(
spd
->
hasVal
[
0
]
==
false
)
{
strcpy
(
error
,
"primary timestamp column can not be null"
);
strcpy
(
error
,
"primary timestamp column can not be null"
);
...
@@ -518,9 +520,9 @@ int tsParseValues(char **str, STableDataBlocks *pDataBlock, STableMeta *pMeterMe
...
@@ -518,9 +520,9 @@ int tsParseValues(char **str, STableDataBlocks *pDataBlock, STableMeta *pMeterMe
if
(
sToken
.
n
==
0
||
sToken
.
type
!=
TK_LP
)
break
;
if
(
sToken
.
n
==
0
||
sToken
.
type
!=
TK_LP
)
break
;
*
str
+=
index
;
*
str
+=
index
;
if
(
numOfRows
>=
maxRows
||
pDataBlock
->
size
+
pMeterMeta
->
rowSize
>=
pDataBlock
->
nAllocSize
)
{
if
(
numOfRows
>=
maxRows
||
pDataBlock
->
size
+
tinfo
.
rowSize
>=
pDataBlock
->
nAllocSize
)
{
int32_t
tSize
;
int32_t
tSize
;
int32_t
retcode
=
tscAllocateMemIfNeed
(
pDataBlock
,
pMeterMeta
->
rowSize
,
&
tSize
);
int32_t
retcode
=
tscAllocateMemIfNeed
(
pDataBlock
,
tinfo
.
rowSize
,
&
tSize
);
if
(
retcode
!=
TSDB_CODE_SUCCESS
)
{
//TODO pass the correct error code to client
if
(
retcode
!=
TSDB_CODE_SUCCESS
)
{
//TODO pass the correct error code to client
strcpy
(
error
,
"client out of memory"
);
strcpy
(
error
,
"client out of memory"
);
*
code
=
retcode
;
*
code
=
retcode
;
...
@@ -601,10 +603,10 @@ int32_t tscAllocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int3
...
@@ -601,10 +603,10 @@ int32_t tscAllocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int3
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
void
tsSetBlockInfo
(
SShellSubmitBlock
*
pBlocks
,
const
STableMeta
*
p
Meter
Meta
,
int32_t
numOfRows
)
{
static
void
tsSetBlockInfo
(
SShellSubmitBlock
*
pBlocks
,
const
STableMeta
*
p
Table
Meta
,
int32_t
numOfRows
)
{
pBlocks
->
sid
=
p
Meter
Meta
->
sid
;
pBlocks
->
sid
=
p
Table
Meta
->
sid
;
pBlocks
->
uid
=
p
Meter
Meta
->
uid
;
pBlocks
->
uid
=
p
Table
Meta
->
uid
;
pBlocks
->
sversion
=
p
Meter
Meta
->
sversion
;
pBlocks
->
sversion
=
p
Table
Meta
->
sversion
;
pBlocks
->
numOfRows
+=
numOfRows
;
pBlocks
->
numOfRows
+=
numOfRows
;
}
}
...
@@ -654,19 +656,20 @@ void sortRemoveDuplicates(STableDataBlocks *dataBuf) {
...
@@ -654,19 +656,20 @@ void sortRemoveDuplicates(STableDataBlocks *dataBuf) {
static
int32_t
doParseInsertStatement
(
SSqlObj
*
pSql
,
void
*
pTableHashList
,
char
**
str
,
SParsedDataColInfo
*
spd
,
static
int32_t
doParseInsertStatement
(
SSqlObj
*
pSql
,
void
*
pTableHashList
,
char
**
str
,
SParsedDataColInfo
*
spd
,
int32_t
*
totalNum
)
{
int32_t
*
totalNum
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
STableMeta
*
pMeterMeta
=
pMeterMetaInfo
->
pMeterMeta
;
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMeta
);
STableDataBlocks
*
dataBuf
=
NULL
;
STableDataBlocks
*
dataBuf
=
NULL
;
int32_t
ret
=
tscGetDataBlockFromList
(
pTableHashList
,
pCmd
->
pDataBlocks
,
p
Meter
Meta
->
uid
,
TSDB_DEFAULT_PAYLOAD_SIZE
,
int32_t
ret
=
tscGetDataBlockFromList
(
pTableHashList
,
pCmd
->
pDataBlocks
,
p
Table
Meta
->
uid
,
TSDB_DEFAULT_PAYLOAD_SIZE
,
sizeof
(
SShellSubmitBlock
),
pMeterMeta
->
rowSize
,
pMeter
MetaInfo
->
name
,
sizeof
(
SShellSubmitBlock
),
tinfo
.
rowSize
,
pTable
MetaInfo
->
name
,
p
Meter
Meta
,
&
dataBuf
);
p
Table
Meta
,
&
dataBuf
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
return
ret
;
}
}
int32_t
maxNumOfRows
;
int32_t
maxNumOfRows
;
ret
=
tscAllocateMemIfNeed
(
dataBuf
,
pMeterMeta
->
rowSize
,
&
maxNumOfRows
);
ret
=
tscAllocateMemIfNeed
(
dataBuf
,
tinfo
.
rowSize
,
&
maxNumOfRows
);
if
(
TSDB_CODE_SUCCESS
!=
ret
)
{
if
(
TSDB_CODE_SUCCESS
!=
ret
)
{
return
TSDB_CODE_CLI_OUT_OF_MEMORY
;
return
TSDB_CODE_CLI_OUT_OF_MEMORY
;
}
}
...
@@ -677,7 +680,7 @@ static int32_t doParseInsertStatement(SSqlObj *pSql, void *pTableHashList, char
...
@@ -677,7 +680,7 @@ static int32_t doParseInsertStatement(SSqlObj *pSql, void *pTableHashList, char
return
TSDB_CODE_CLI_OUT_OF_MEMORY
;
return
TSDB_CODE_CLI_OUT_OF_MEMORY
;
}
}
int32_t
numOfRows
=
tsParseValues
(
str
,
dataBuf
,
p
Meter
Meta
,
maxNumOfRows
,
spd
,
pCmd
->
payload
,
&
code
,
tmpTokenBuf
);
int32_t
numOfRows
=
tsParseValues
(
str
,
dataBuf
,
p
Table
Meta
,
maxNumOfRows
,
spd
,
pCmd
->
payload
,
&
code
,
tmpTokenBuf
);
free
(
tmpTokenBuf
);
free
(
tmpTokenBuf
);
if
(
numOfRows
<=
0
)
{
if
(
numOfRows
<=
0
)
{
return
code
;
return
code
;
...
@@ -692,9 +695,9 @@ static int32_t doParseInsertStatement(SSqlObj *pSql, void *pTableHashList, char
...
@@ -692,9 +695,9 @@ static int32_t doParseInsertStatement(SSqlObj *pSql, void *pTableHashList, char
}
}
SShellSubmitBlock
*
pBlocks
=
(
SShellSubmitBlock
*
)(
dataBuf
->
pData
);
SShellSubmitBlock
*
pBlocks
=
(
SShellSubmitBlock
*
)(
dataBuf
->
pData
);
tsSetBlockInfo
(
pBlocks
,
p
Meter
Meta
,
numOfRows
);
tsSetBlockInfo
(
pBlocks
,
p
Table
Meta
,
numOfRows
);
dataBuf
->
vgid
=
p
Meter
Meta
->
vgid
;
dataBuf
->
vgid
=
p
Table
Meta
->
vgid
;
dataBuf
->
numOfTables
=
1
;
dataBuf
->
numOfTables
=
1
;
/*
/*
...
@@ -756,7 +759,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
...
@@ -756,7 +759,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
return
TSDB_CODE_INVALID_SQL
;
return
TSDB_CODE_INVALID_SQL
;
}
}
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
TABLE_INDEX
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
TABLE_INDEX
);
if
(
sToken
.
type
==
TK_USING
)
{
// create table if not exists according to the super table
if
(
sToken
.
type
==
TK_USING
)
{
// create table if not exists according to the super table
index
=
0
;
index
=
0
;
...
@@ -767,13 +770,13 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
...
@@ -767,13 +770,13 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
memset
(
pTag
,
0
,
sizeof
(
STagData
));
memset
(
pTag
,
0
,
sizeof
(
STagData
));
/*
/*
* the source super table is moved to the secondary position of the p
Meter
MetaInfo list
* the source super table is moved to the secondary position of the p
Table
MetaInfo list
*/
*/
if
(
pQueryInfo
->
numOfTables
<
2
)
{
if
(
pQueryInfo
->
numOfTables
<
2
)
{
tscAddEmptyMeterMetaInfo
(
pQueryInfo
);
tscAddEmptyMeterMetaInfo
(
pQueryInfo
);
}
}
S
Meter
MetaInfo
*
pSTableMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
STABLE_INDEX
);
S
Table
MetaInfo
*
pSTableMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
STABLE_INDEX
);
setMeterID
(
pSTableMeterMetaInfo
,
&
sToken
,
pSql
);
setMeterID
(
pSTableMeterMetaInfo
,
&
sToken
,
pSql
);
strncpy
(
pTag
->
name
,
pSTableMeterMetaInfo
->
name
,
TSDB_TABLE_ID_LEN
);
strncpy
(
pTag
->
name
,
pSTableMeterMetaInfo
->
name
,
TSDB_TABLE_ID_LEN
);
...
@@ -786,7 +789,8 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
...
@@ -786,7 +789,8 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
return
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
"create table only from super table is allowed"
,
sToken
.
z
);
return
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
"create table only from super table is allowed"
,
sToken
.
z
);
}
}
SSchema
*
pTagSchema
=
tsGetTagSchema
(
pSTableMeterMetaInfo
->
pMeterMeta
);
SSchema
*
pTagSchema
=
tscGetTableTagSchema
(
pSTableMeterMetaInfo
->
pTableMeta
);
STableInfo
tinfo
=
tscGetTableInfo
(
pSTableMeterMetaInfo
->
pTableMeta
);
index
=
0
;
index
=
0
;
sToken
=
tStrGetToken
(
sql
,
&
index
,
false
,
0
,
NULL
);
sToken
=
tStrGetToken
(
sql
,
&
index
,
false
,
0
,
NULL
);
...
@@ -794,7 +798,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
...
@@ -794,7 +798,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
SParsedDataColInfo
spd
=
{
0
};
SParsedDataColInfo
spd
=
{
0
};
uint8_t
numOfTags
=
pSTableMeterMetaInfo
->
pMeterMeta
->
numOfTags
;
uint8_t
numOfTags
=
tscGetNumOfTags
(
pSTableMeterMetaInfo
->
pTableMeta
)
;
spd
.
numOfCols
=
numOfTags
;
spd
.
numOfCols
=
numOfTags
;
// if specify some tags column
// if specify some tags column
...
@@ -881,8 +885,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
...
@@ -881,8 +885,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
sToken
.
n
-=
2
;
sToken
.
n
-=
2
;
}
}
code
=
tsParseOneColumnData
(
&
pTagSchema
[
colIndex
],
&
sToken
,
tagVal
,
pCmd
->
payload
,
&
sql
,
false
,
code
=
tsParseOneColumnData
(
&
pTagSchema
[
colIndex
],
&
sToken
,
tagVal
,
pCmd
->
payload
,
&
sql
,
false
,
tinfo
.
precision
);
pSTableMeterMetaInfo
->
pMeterMeta
->
precision
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
...
@@ -917,13 +920,13 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
...
@@ -917,13 +920,13 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
return
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
"invalid table name"
,
*
sqlstr
);
return
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
"invalid table name"
,
*
sqlstr
);
}
}
int32_t
ret
=
setMeterID
(
p
Meter
MetaInfo
,
&
tableToken
,
pSql
);
int32_t
ret
=
setMeterID
(
p
Table
MetaInfo
,
&
tableToken
,
pSql
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
return
ret
;
}
}
createTable
=
true
;
createTable
=
true
;
code
=
tscGetMeterMetaEx
(
pSql
,
p
Meter
MetaInfo
,
true
);
code
=
tscGetMeterMetaEx
(
pSql
,
p
Table
MetaInfo
,
true
);
if
(
TSDB_CODE_ACTION_IN_PROGRESS
==
code
)
{
if
(
TSDB_CODE_ACTION_IN_PROGRESS
==
code
)
{
return
code
;
return
code
;
}
}
...
@@ -934,7 +937,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
...
@@ -934,7 +937,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
}
else
{
}
else
{
sql
=
sToken
.
z
;
sql
=
sToken
.
z
;
}
}
code
=
tscGetMeterMeta
(
pSql
,
p
Meter
MetaInfo
);
code
=
tscGetMeterMeta
(
pSql
,
p
Table
MetaInfo
);
}
}
int32_t
len
=
cend
-
cstart
+
1
;
int32_t
len
=
cend
-
cstart
+
1
;
...
@@ -983,15 +986,15 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
...
@@ -983,15 +986,15 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
int32_t
totalNum
=
0
;
int32_t
totalNum
=
0
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
NULL
;
S
TableMetaInfo
*
pTable
MetaInfo
=
NULL
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
assert
(
pQueryInfo
!=
NULL
);
assert
(
pQueryInfo
!=
NULL
);
if
(
pQueryInfo
->
numOfTables
==
0
)
{
if
(
pQueryInfo
->
numOfTables
==
0
)
{
p
Meter
MetaInfo
=
tscAddEmptyMeterMetaInfo
(
pQueryInfo
);
p
Table
MetaInfo
=
tscAddEmptyMeterMetaInfo
(
pQueryInfo
);
}
else
{
}
else
{
p
Meter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
p
Table
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
}
}
if
((
code
=
tscAllocPayload
(
pCmd
,
TSDB_PAYLOAD_SIZE
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
tscAllocPayload
(
pCmd
,
TSDB_PAYLOAD_SIZE
))
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -1050,7 +1053,7 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
...
@@ -1050,7 +1053,7 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
goto
_error_clean
;
goto
_error_clean
;
}
}
if
((
code
=
setMeterID
(
p
Meter
MetaInfo
,
&
sToken
,
pSql
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
setMeterID
(
p
Table
MetaInfo
,
&
sToken
,
pSql
))
!=
TSDB_CODE_SUCCESS
)
{
goto
_error_clean
;
goto
_error_clean
;
}
}
...
@@ -1078,7 +1081,7 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
...
@@ -1078,7 +1081,7 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
goto
_error_clean
;
// TODO: should _clean or _error_clean to async flow ????
goto
_error_clean
;
// TODO: should _clean or _error_clean to async flow ????
}
}
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
))
{
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
))
{
code
=
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
"insert data into super table is not supported"
,
NULL
);
code
=
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
"insert data into super table is not supported"
,
NULL
);
goto
_error_clean
;
goto
_error_clean
;
}
}
...
@@ -1092,11 +1095,15 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
...
@@ -1092,11 +1095,15 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
goto
_error_clean
;
goto
_error_clean
;
}
}
int32_t
numOfCols
=
tscGetNumOfTags
(
pTableMetaInfo
->
pTableMeta
);
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
if
(
sToken
.
type
==
TK_VALUES
)
{
if
(
sToken
.
type
==
TK_VALUES
)
{
SParsedDataColInfo
spd
=
{.
numOfCols
=
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
};
SParsedDataColInfo
spd
=
{.
numOfCols
=
numOfCols
};
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
tscSetAssignedColumnInfo
(
&
spd
,
pSchema
,
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
);
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMetaInfo
->
pTableMeta
);
tscSetAssignedColumnInfo
(
&
spd
,
pSchema
,
numOfCols
);
if
(
validateDataSource
(
pCmd
,
DATA_FROM_SQL_STRING
,
sToken
.
z
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
validateDataSource
(
pCmd
,
DATA_FROM_SQL_STRING
,
sToken
.
z
)
!=
TSDB_CODE_SUCCESS
)
{
goto
_error_clean
;
goto
_error_clean
;
...
@@ -1136,10 +1143,10 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
...
@@ -1136,10 +1143,10 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
wordfree
(
&
full_path
);
wordfree
(
&
full_path
);
STableDataBlocks
*
pDataBlock
=
NULL
;
STableDataBlocks
*
pDataBlock
=
NULL
;
STableMeta
*
p
MeterMeta
=
pMeterMetaInfo
->
pMeter
Meta
;
STableMeta
*
p
TableMeta
=
pTableMetaInfo
->
pTable
Meta
;
int32_t
ret
=
tscCreateDataBlock
(
PATH_MAX
,
pMeterMeta
->
rowSize
,
sizeof
(
SShellSubmitBlock
),
pMeter
MetaInfo
->
name
,
int32_t
ret
=
tscCreateDataBlock
(
PATH_MAX
,
tinfo
.
rowSize
,
sizeof
(
SShellSubmitBlock
),
pTable
MetaInfo
->
name
,
p
Meter
Meta
,
&
pDataBlock
);
p
Table
Meta
,
&
pDataBlock
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
goto
_error_clean
;
goto
_error_clean
;
}
}
...
@@ -1148,18 +1155,18 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
...
@@ -1148,18 +1155,18 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
strcpy
(
pDataBlock
->
filename
,
fname
);
strcpy
(
pDataBlock
->
filename
,
fname
);
}
else
if
(
sToken
.
type
==
TK_LP
)
{
}
else
if
(
sToken
.
type
==
TK_LP
)
{
/* insert into tablename(col1, col2,..., coln) values(v1, v2,... vn); */
/* insert into tablename(col1, col2,..., coln) values(v1, v2,... vn); */
STableMeta
*
p
MeterMeta
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
)
->
pMeter
Meta
;
STableMeta
*
p
TableMeta
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
)
->
pTable
Meta
;
SSchema
*
pSchema
=
ts
GetSchema
(
pMeter
Meta
);
SSchema
*
pSchema
=
ts
cGetTableSchema
(
pTable
Meta
);
if
(
validateDataSource
(
pCmd
,
DATA_FROM_SQL_STRING
,
sToken
.
z
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
validateDataSource
(
pCmd
,
DATA_FROM_SQL_STRING
,
sToken
.
z
)
!=
TSDB_CODE_SUCCESS
)
{
goto
_error_clean
;
goto
_error_clean
;
}
}
SParsedDataColInfo
spd
=
{
0
};
SParsedDataColInfo
spd
=
{
0
};
spd
.
numOfCols
=
pMeterMeta
->
numOfColumns
;
spd
.
numOfCols
=
tinfo
.
numOfColumns
;
int16_t
offset
[
TSDB_MAX_COLUMNS
]
=
{
0
};
int16_t
offset
[
TSDB_MAX_COLUMNS
]
=
{
0
};
for
(
int32_t
t
=
1
;
t
<
pMeterMeta
->
numOfColumns
;
++
t
)
{
for
(
int32_t
t
=
1
;
t
<
tinfo
.
numOfColumns
;
++
t
)
{
offset
[
t
]
=
offset
[
t
-
1
]
+
pSchema
[
t
-
1
].
bytes
;
offset
[
t
]
=
offset
[
t
-
1
]
+
pSchema
[
t
-
1
].
bytes
;
}
}
...
@@ -1181,7 +1188,7 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
...
@@ -1181,7 +1188,7 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
bool
findColumnIndex
=
false
;
bool
findColumnIndex
=
false
;
// todo speedup by using hash list
// todo speedup by using hash list
for
(
int32_t
t
=
0
;
t
<
pMeterMeta
->
numOfColumns
;
++
t
)
{
for
(
int32_t
t
=
0
;
t
<
tinfo
.
numOfColumns
;
++
t
)
{
if
(
strncmp
(
sToken
.
z
,
pSchema
[
t
].
name
,
sToken
.
n
)
==
0
&&
strlen
(
pSchema
[
t
].
name
)
==
sToken
.
n
)
{
if
(
strncmp
(
sToken
.
z
,
pSchema
[
t
].
name
,
sToken
.
n
)
==
0
&&
strlen
(
pSchema
[
t
].
name
)
==
sToken
.
n
)
{
SParsedColElem
*
pElem
=
&
spd
.
elems
[
spd
.
numOfAssignedCols
++
];
SParsedColElem
*
pElem
=
&
spd
.
elems
[
spd
.
numOfAssignedCols
++
];
pElem
->
offset
=
offset
[
t
];
pElem
->
offset
=
offset
[
t
];
...
@@ -1204,7 +1211,7 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
...
@@ -1204,7 +1211,7 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
}
}
}
}
if
(
spd
.
numOfAssignedCols
==
0
||
spd
.
numOfAssignedCols
>
pMeterMeta
->
numOfColumns
)
{
if
(
spd
.
numOfAssignedCols
==
0
||
spd
.
numOfAssignedCols
>
tinfo
.
numOfColumns
)
{
code
=
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
"column name expected"
,
sToken
.
z
);
code
=
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
"column name expected"
,
sToken
.
z
);
goto
_error_clean
;
goto
_error_clean
;
}
}
...
@@ -1245,10 +1252,10 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
...
@@ -1245,10 +1252,10 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
goto
_error_clean
;
goto
_error_clean
;
}
}
p
Meter
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
);
p
Table
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
);
// set the next sent data vnode index in data block arraylist
// set the next sent data vnode index in data block arraylist
p
Meter
MetaInfo
->
vnodeIndex
=
1
;
p
Table
MetaInfo
->
vnodeIndex
=
1
;
}
else
{
}
else
{
pCmd
->
pDataBlocks
=
tscDestroyBlockArrayList
(
pCmd
->
pDataBlocks
);
pCmd
->
pDataBlocks
=
tscDestroyBlockArrayList
(
pCmd
->
pDataBlocks
);
}
}
...
@@ -1348,10 +1355,10 @@ static int doPackSendDataBlock(SSqlObj *pSql, int32_t numOfRows, STableDataBlock
...
@@ -1348,10 +1355,10 @@ static int doPackSendDataBlock(SSqlObj *pSql, int32_t numOfRows, STableDataBlock
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
assert
(
pCmd
->
numOfClause
==
1
);
assert
(
pCmd
->
numOfClause
==
1
);
STableMeta
*
p
MeterMeta
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
)
->
pMeter
Meta
;
STableMeta
*
p
TableMeta
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
)
->
pTable
Meta
;
SShellSubmitBlock
*
pBlocks
=
(
SShellSubmitBlock
*
)(
pTableDataBlocks
->
pData
);
SShellSubmitBlock
*
pBlocks
=
(
SShellSubmitBlock
*
)(
pTableDataBlocks
->
pData
);
tsSetBlockInfo
(
pBlocks
,
p
Meter
Meta
,
numOfRows
);
tsSetBlockInfo
(
pBlocks
,
p
Table
Meta
,
numOfRows
);
if
((
code
=
tscMergeTableDataBlocks
(
pSql
,
pCmd
->
pDataBlocks
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
tscMergeTableDataBlocks
(
pSql
,
pCmd
->
pDataBlocks
))
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
...
@@ -1381,16 +1388,18 @@ static int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp, char *tmpTokenBuf) {
...
@@ -1381,16 +1388,18 @@ static int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp, char *tmpTokenBuf) {
int32_t
code
=
0
;
int32_t
code
=
0
;
int
nrows
=
0
;
int
nrows
=
0
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
STableMeta
*
pMeterMeta
=
pMeterMetaInfo
->
pMeterMeta
;
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMeta
);
assert
(
pCmd
->
numOfClause
==
1
);
assert
(
pCmd
->
numOfClause
==
1
);
int32_t
rowSize
=
pMeterMeta
->
rowSize
;
int32_t
rowSize
=
tinfo
.
rowSize
;
pCmd
->
pDataBlocks
=
tscCreateBlockArrayList
();
pCmd
->
pDataBlocks
=
tscCreateBlockArrayList
();
STableDataBlocks
*
pTableDataBlock
=
NULL
;
STableDataBlocks
*
pTableDataBlock
=
NULL
;
int32_t
ret
=
tscCreateDataBlock
(
TSDB_PAYLOAD_SIZE
,
rowSize
,
sizeof
(
SShellSubmitBlock
),
int32_t
ret
=
tscCreateDataBlock
(
TSDB_PAYLOAD_SIZE
,
rowSize
,
sizeof
(
SShellSubmitBlock
),
p
MeterMetaInfo
->
name
,
pMeter
Meta
,
&
pTableDataBlock
);
p
TableMetaInfo
->
name
,
pTable
Meta
,
&
pTableDataBlock
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -1401,10 +1410,10 @@ static int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp, char *tmpTokenBuf) {
...
@@ -1401,10 +1410,10 @@ static int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp, char *tmpTokenBuf) {
if
(
TSDB_CODE_SUCCESS
!=
code
)
return
-
1
;
if
(
TSDB_CODE_SUCCESS
!=
code
)
return
-
1
;
int
count
=
0
;
int
count
=
0
;
SParsedDataColInfo
spd
=
{.
numOfCols
=
pMeterMeta
->
numOfColumns
};
SParsedDataColInfo
spd
=
{.
numOfCols
=
tinfo
.
numOfColumns
};
SSchema
*
pSchema
=
ts
GetSchema
(
pMeter
Meta
);
SSchema
*
pSchema
=
ts
cGetTableSchema
(
pTable
Meta
);
tscSetAssignedColumnInfo
(
&
spd
,
pSchema
,
pMeterMeta
->
numOfColumns
);
tscSetAssignedColumnInfo
(
&
spd
,
pSchema
,
tinfo
.
numOfColumns
);
while
((
readLen
=
getline
(
&
line
,
&
n
,
fp
))
!=
-
1
)
{
while
((
readLen
=
getline
(
&
line
,
&
n
,
fp
))
!=
-
1
)
{
// line[--readLen] = '\0';
// line[--readLen] = '\0';
...
@@ -1414,7 +1423,7 @@ static int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp, char *tmpTokenBuf) {
...
@@ -1414,7 +1423,7 @@ static int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp, char *tmpTokenBuf) {
char
*
lineptr
=
line
;
char
*
lineptr
=
line
;
strtolower
(
line
,
line
);
strtolower
(
line
,
line
);
len
=
tsParseOneRowData
(
&
lineptr
,
pTableDataBlock
,
pSchema
,
&
spd
,
pCmd
->
payload
,
pMeterMeta
->
precision
,
&
code
,
tmpTokenBuf
);
len
=
tsParseOneRowData
(
&
lineptr
,
pTableDataBlock
,
pSchema
,
&
spd
,
pCmd
->
payload
,
tinfo
.
precision
,
&
code
,
tmpTokenBuf
);
if
(
len
<=
0
||
pTableDataBlock
->
numOfParams
>
0
)
{
if
(
len
<=
0
||
pTableDataBlock
->
numOfParams
>
0
)
{
pSql
->
res
.
code
=
code
;
pSql
->
res
.
code
=
code
;
return
(
-
code
);
return
(
-
code
);
...
@@ -1431,7 +1440,7 @@ static int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp, char *tmpTokenBuf) {
...
@@ -1431,7 +1440,7 @@ static int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp, char *tmpTokenBuf) {
pTableDataBlock
=
pCmd
->
pDataBlocks
->
pData
[
0
];
pTableDataBlock
=
pCmd
->
pDataBlocks
->
pData
[
0
];
pTableDataBlock
->
size
=
sizeof
(
SShellSubmitBlock
);
pTableDataBlock
->
size
=
sizeof
(
SShellSubmitBlock
);
pTableDataBlock
->
rowSize
=
pMeterMeta
->
rowSize
;
pTableDataBlock
->
rowSize
=
tinfo
.
rowSize
;
numOfRows
+=
pSql
->
res
.
numOfRows
;
numOfRows
+=
pSql
->
res
.
numOfRows
;
pSql
->
res
.
numOfRows
=
0
;
pSql
->
res
.
numOfRows
=
0
;
...
@@ -1473,25 +1482,25 @@ void tscProcessMultiVnodesInsert(SSqlObj *pSql) {
...
@@ -1473,25 +1482,25 @@ void tscProcessMultiVnodesInsert(SSqlObj *pSql) {
}
}
STableDataBlocks
*
pDataBlock
=
NULL
;
STableDataBlocks
*
pDataBlock
=
NULL
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
assert
(
pCmd
->
numOfClause
==
1
);
assert
(
pCmd
->
numOfClause
==
1
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
/* the first block has been sent to server in processSQL function */
/* the first block has been sent to server in processSQL function */
assert
(
p
Meter
MetaInfo
->
vnodeIndex
>=
1
&&
pCmd
->
pDataBlocks
!=
NULL
);
assert
(
p
Table
MetaInfo
->
vnodeIndex
>=
1
&&
pCmd
->
pDataBlocks
!=
NULL
);
if
(
p
Meter
MetaInfo
->
vnodeIndex
<
pCmd
->
pDataBlocks
->
nSize
)
{
if
(
p
Table
MetaInfo
->
vnodeIndex
<
pCmd
->
pDataBlocks
->
nSize
)
{
SDataBlockList
*
pDataBlocks
=
pCmd
->
pDataBlocks
;
SDataBlockList
*
pDataBlocks
=
pCmd
->
pDataBlocks
;
for
(
int32_t
i
=
p
Meter
MetaInfo
->
vnodeIndex
;
i
<
pDataBlocks
->
nSize
;
++
i
)
{
for
(
int32_t
i
=
p
Table
MetaInfo
->
vnodeIndex
;
i
<
pDataBlocks
->
nSize
;
++
i
)
{
pDataBlock
=
pDataBlocks
->
pData
[
i
];
pDataBlock
=
pDataBlocks
->
pData
[
i
];
if
(
pDataBlock
==
NULL
)
{
if
(
pDataBlock
==
NULL
)
{
continue
;
continue
;
}
}
if
((
code
=
tscCopyDataBlockToPayload
(
pSql
,
pDataBlock
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
tscCopyDataBlockToPayload
(
pSql
,
pDataBlock
))
!=
TSDB_CODE_SUCCESS
)
{
tscTrace
(
"%p build submit data block failed, vnodeIdx:%d, total:%d"
,
pSql
,
p
Meter
MetaInfo
->
vnodeIndex
,
tscTrace
(
"%p build submit data block failed, vnodeIdx:%d, total:%d"
,
pSql
,
p
Table
MetaInfo
->
vnodeIndex
,
pDataBlocks
->
nSize
);
pDataBlocks
->
nSize
);
continue
;
continue
;
}
}
...
@@ -1512,7 +1521,7 @@ void tscProcessMultiVnodesInsertFromFile(SSqlObj *pSql) {
...
@@ -1512,7 +1521,7 @@ void tscProcessMultiVnodesInsertFromFile(SSqlObj *pSql) {
}
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
STableDataBlocks
*
pDataBlock
=
NULL
;
STableDataBlocks
*
pDataBlock
=
NULL
;
int32_t
affected_rows
=
0
;
int32_t
affected_rows
=
0
;
...
@@ -1543,10 +1552,10 @@ void tscProcessMultiVnodesInsertFromFile(SSqlObj *pSql) {
...
@@ -1543,10 +1552,10 @@ void tscProcessMultiVnodesInsertFromFile(SSqlObj *pSql) {
continue
;
continue
;
}
}
strncpy
(
p
Meter
MetaInfo
->
name
,
pDataBlock
->
tableId
,
TSDB_TABLE_ID_LEN
);
strncpy
(
p
Table
MetaInfo
->
name
,
pDataBlock
->
tableId
,
TSDB_TABLE_ID_LEN
);
memset
(
pDataBlock
->
pData
,
0
,
pDataBlock
->
nAllocSize
);
memset
(
pDataBlock
->
pData
,
0
,
pDataBlock
->
nAllocSize
);
int32_t
ret
=
tscGetMeterMeta
(
pSql
,
p
Meter
MetaInfo
);
int32_t
ret
=
tscGetMeterMeta
(
pSql
,
p
Table
MetaInfo
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"%p get meter meta failed, abort"
,
pSql
);
tscError
(
"%p get meter meta failed, abort"
,
pSql
);
continue
;
continue
;
...
...
src/client/src/tscPrepare.c
浏览文件 @
03346d0c
...
@@ -407,8 +407,8 @@ static int insertStmtReset(STscStmt* pStmt) {
...
@@ -407,8 +407,8 @@ static int insertStmtReset(STscStmt* pStmt) {
}
}
pCmd
->
batchSize
=
0
;
pCmd
->
batchSize
=
0
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
p
Meter
MetaInfo
->
vnodeIndex
=
0
;
p
Table
MetaInfo
->
vnodeIndex
=
0
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -421,7 +421,7 @@ static int insertStmtExecute(STscStmt* stmt) {
...
@@ -421,7 +421,7 @@ static int insertStmtExecute(STscStmt* stmt) {
++
pCmd
->
batchSize
;
++
pCmd
->
batchSize
;
}
}
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
assert
(
pCmd
->
numOfClause
==
1
);
assert
(
pCmd
->
numOfClause
==
1
);
if
(
pCmd
->
pDataBlocks
->
nSize
>
0
)
{
if
(
pCmd
->
pDataBlocks
->
nSize
>
0
)
{
...
@@ -438,7 +438,7 @@ static int insertStmtExecute(STscStmt* stmt) {
...
@@ -438,7 +438,7 @@ static int insertStmtExecute(STscStmt* stmt) {
}
}
// set the next sent data vnode index in data block arraylist
// set the next sent data vnode index in data block arraylist
p
Meter
MetaInfo
->
vnodeIndex
=
1
;
p
Table
MetaInfo
->
vnodeIndex
=
1
;
}
else
{
}
else
{
pCmd
->
pDataBlocks
=
tscDestroyBlockArrayList
(
pCmd
->
pDataBlocks
);
pCmd
->
pDataBlocks
=
tscDestroyBlockArrayList
(
pCmd
->
pDataBlocks
);
}
}
...
...
src/client/src/tscSQLParser.c
浏览文件 @
03346d0c
...
@@ -149,10 +149,12 @@ static int setColumnFilterInfoForTimestamp(SQueryInfo* pQueryInfo, tVariant* pVa
...
@@ -149,10 +149,12 @@ static int setColumnFilterInfoForTimestamp(SQueryInfo* pQueryInfo, tVariant* pVa
strdequote
(
pVar
->
pz
);
strdequote
(
pVar
->
pz
);
char
*
seg
=
strnchr
(
pVar
->
pz
,
'-'
,
pVar
->
nLen
,
false
);
char
*
seg
=
strnchr
(
pVar
->
pz
,
'-'
,
pVar
->
nLen
,
false
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
if
(
seg
!=
NULL
)
{
if
(
seg
!=
NULL
)
{
if
(
taosParseTime
(
pVar
->
pz
,
&
time
,
pVar
->
nLen
,
pMeterMetaInfo
->
pMeterMeta
->
precision
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
taosParseTime
(
pVar
->
pz
,
&
time
,
pVar
->
nLen
,
tinfo
.
precision
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg
);
}
}
}
else
{
}
else
{
...
@@ -207,7 +209,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -207,7 +209,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
int32_t
code
=
tscGetQueryInfoDetailSafely
(
pCmd
,
pCmd
->
clauseIndex
,
&
pQueryInfo
);
int32_t
code
=
tscGetQueryInfoDetailSafely
(
pCmd
,
pCmd
->
clauseIndex
,
&
pQueryInfo
);
assert
(
pQueryInfo
->
numOfTables
==
0
);
assert
(
pQueryInfo
->
numOfTables
==
0
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscAddEmptyMeterMetaInfo
(
pQueryInfo
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscAddEmptyMeterMetaInfo
(
pQueryInfo
);
pCmd
->
command
=
pInfo
->
type
;
pCmd
->
command
=
pInfo
->
type
;
...
@@ -229,7 +231,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -229,7 +231,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if
(
pInfo
->
type
==
TSDB_SQL_DROP_DB
)
{
if
(
pInfo
->
type
==
TSDB_SQL_DROP_DB
)
{
assert
(
pInfo
->
pDCLInfo
->
nTokens
==
1
);
assert
(
pInfo
->
pDCLInfo
->
nTokens
==
1
);
code
=
setObjFullName
(
p
Meter
MetaInfo
->
name
,
getAccountId
(
pSql
),
pzName
,
NULL
,
NULL
);
code
=
setObjFullName
(
p
Table
MetaInfo
->
name
,
getAccountId
(
pSql
),
pzName
,
NULL
,
NULL
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
}
...
@@ -237,7 +239,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -237,7 +239,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
else
if
(
pInfo
->
type
==
TSDB_SQL_DROP_TABLE
)
{
}
else
if
(
pInfo
->
type
==
TSDB_SQL_DROP_TABLE
)
{
assert
(
pInfo
->
pDCLInfo
->
nTokens
==
1
);
assert
(
pInfo
->
pDCLInfo
->
nTokens
==
1
);
if
(
setMeterID
(
p
Meter
MetaInfo
,
pzName
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
setMeterID
(
p
Table
MetaInfo
,
pzName
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
}
}
}
else
if
(
pInfo
->
type
==
TSDB_SQL_DROP_DNODE
)
{
}
else
if
(
pInfo
->
type
==
TSDB_SQL_DROP_DNODE
)
{
...
@@ -245,13 +247,13 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -245,13 +247,13 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
}
strncpy
(
p
Meter
MetaInfo
->
name
,
pzName
->
z
,
pzName
->
n
);
strncpy
(
p
Table
MetaInfo
->
name
,
pzName
->
z
,
pzName
->
n
);
}
else
{
// drop user
}
else
{
// drop user
if
(
pzName
->
n
>
TSDB_USER_LEN
)
{
if
(
pzName
->
n
>
TSDB_USER_LEN
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
}
}
strncpy
(
p
Meter
MetaInfo
->
name
,
pzName
->
z
,
pzName
->
n
);
strncpy
(
p
Table
MetaInfo
->
name
,
pzName
->
z
,
pzName
->
n
);
}
}
break
;
break
;
...
@@ -265,7 +267,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -265,7 +267,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
);
}
}
int32_t
ret
=
setObjFullName
(
p
Meter
MetaInfo
->
name
,
getAccountId
(
pSql
),
pToken
,
NULL
,
NULL
);
int32_t
ret
=
setObjFullName
(
p
Table
MetaInfo
->
name
,
getAccountId
(
pSql
),
pToken
,
NULL
,
NULL
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
);
}
}
...
@@ -295,7 +297,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -295,7 +297,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
}
int32_t
ret
=
setObjFullName
(
p
Meter
MetaInfo
->
name
,
getAccountId
(
pSql
),
&
(
pCreateDB
->
dbname
),
NULL
,
NULL
);
int32_t
ret
=
setObjFullName
(
p
Table
MetaInfo
->
name
,
getAccountId
(
pSql
),
&
(
pCreateDB
->
dbname
),
NULL
,
NULL
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
}
...
@@ -370,11 +372,11 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -370,11 +372,11 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
}
if
(
setMeterID
(
p
Meter
MetaInfo
,
pToken
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
setMeterID
(
p
Table
MetaInfo
,
pToken
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
}
return
tscGetMeterMeta
(
pSql
,
p
Meter
MetaInfo
);
return
tscGetMeterMeta
(
pSql
,
p
Table
MetaInfo
);
}
}
case
TSDB_SQL_CFG_DNODE
:
{
case
TSDB_SQL_CFG_DNODE
:
{
...
@@ -585,7 +587,8 @@ int32_t parseIntervalClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
...
@@ -585,7 +587,8 @@ int32_t parseIntervalClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
const
char
*
msg1
=
"invalid query expression"
;
const
char
*
msg1
=
"invalid query expression"
;
const
char
*
msg2
=
"interval cannot be less than 10 ms"
;
const
char
*
msg2
=
"interval cannot be less than 10 ms"
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
if
(
pQuerySql
->
interval
.
type
==
0
||
pQuerySql
->
interval
.
n
==
0
)
{
if
(
pQuerySql
->
interval
.
type
==
0
||
pQuerySql
->
interval
.
n
==
0
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -598,7 +601,7 @@ int32_t parseIntervalClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
...
@@ -598,7 +601,7 @@ int32_t parseIntervalClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
}
}
// if the unit of time window value is millisecond, change the value from microsecond
// if the unit of time window value is millisecond, change the value from microsecond
if
(
pMeterMetaInfo
->
pMeterMeta
->
precision
==
TSDB_TIME_PRECISION_MILLI
)
{
if
(
tinfo
.
precision
==
TSDB_TIME_PRECISION_MILLI
)
{
pQueryInfo
->
intervalTime
=
pQueryInfo
->
intervalTime
/
1000
;
pQueryInfo
->
intervalTime
=
pQueryInfo
->
intervalTime
/
1000
;
}
}
...
@@ -643,8 +646,8 @@ int32_t parseIntervalClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
...
@@ -643,8 +646,8 @@ int32_t parseIntervalClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
int32_t
tableIndex
=
COLUMN_INDEX_INITIAL_VAL
;
int32_t
tableIndex
=
COLUMN_INDEX_INITIAL_VAL
;
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
p
Meter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
i
);
p
Table
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
i
);
if
(
p
MeterMetaInfo
->
pMeter
Meta
->
uid
==
uid
)
{
if
(
p
TableMetaInfo
->
pTable
Meta
->
uid
==
uid
)
{
tableIndex
=
i
;
tableIndex
=
i
;
break
;
break
;
}
}
...
@@ -676,12 +679,13 @@ int32_t parseSlidingClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
...
@@ -676,12 +679,13 @@ int32_t parseSlidingClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
const
char
*
msg0
=
"sliding value too small"
;
const
char
*
msg0
=
"sliding value too small"
;
const
char
*
msg1
=
"sliding value no larger than the interval value"
;
const
char
*
msg1
=
"sliding value no larger than the interval value"
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
SSQLToken
*
pSliding
=
&
pQuerySql
->
sliding
;
SSQLToken
*
pSliding
=
&
pQuerySql
->
sliding
;
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
if
(
pSliding
->
n
!=
0
)
{
if
(
pSliding
->
n
!=
0
)
{
getTimestampInUsFromStr
(
pSliding
->
z
,
pSliding
->
n
,
&
pQueryInfo
->
slidingTime
);
getTimestampInUsFromStr
(
pSliding
->
z
,
pSliding
->
n
,
&
pQueryInfo
->
slidingTime
);
if
(
pMeterMetaInfo
->
pMeterMeta
->
precision
==
TSDB_TIME_PRECISION_MILLI
)
{
if
(
tinfo
.
precision
==
TSDB_TIME_PRECISION_MILLI
)
{
pQueryInfo
->
slidingTime
/=
1000
;
pQueryInfo
->
slidingTime
/=
1000
;
}
}
...
@@ -699,27 +703,27 @@ int32_t parseSlidingClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
...
@@ -699,27 +703,27 @@ int32_t parseSlidingClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
setMeterID
(
S
MeterMetaInfo
*
pMeter
MetaInfo
,
SSQLToken
*
pzTableName
,
SSqlObj
*
pSql
)
{
int32_t
setMeterID
(
S
TableMetaInfo
*
pTable
MetaInfo
,
SSQLToken
*
pzTableName
,
SSqlObj
*
pSql
)
{
const
char
*
msg
=
"name too long"
;
const
char
*
msg
=
"name too long"
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
// backup the old name in p
Meter
MetaInfo
// backup the old name in p
Table
MetaInfo
size_t
size
=
strlen
(
p
Meter
MetaInfo
->
name
);
size_t
size
=
strlen
(
p
Table
MetaInfo
->
name
);
char
*
oldName
=
NULL
;
char
*
oldName
=
NULL
;
if
(
size
>
0
)
{
if
(
size
>
0
)
{
oldName
=
strdup
(
p
Meter
MetaInfo
->
name
);
oldName
=
strdup
(
p
Table
MetaInfo
->
name
);
}
}
if
(
hasSpecifyDB
(
pzTableName
))
{
if
(
hasSpecifyDB
(
pzTableName
))
{
// db has been specified in sql string so we ignore current db path
// db has been specified in sql string so we ignore current db path
code
=
setObjFullName
(
p
Meter
MetaInfo
->
name
,
getAccountId
(
pSql
),
NULL
,
pzTableName
,
NULL
);
code
=
setObjFullName
(
p
Table
MetaInfo
->
name
,
getAccountId
(
pSql
),
NULL
,
pzTableName
,
NULL
);
}
else
{
// get current DB name first, then set it into path
}
else
{
// get current DB name first, then set it into path
SSQLToken
t
=
{
0
};
SSQLToken
t
=
{
0
};
getCurrentDBName
(
pSql
,
&
t
);
getCurrentDBName
(
pSql
,
&
t
);
code
=
setObjFullName
(
p
Meter
MetaInfo
->
name
,
NULL
,
&
t
,
pzTableName
,
NULL
);
code
=
setObjFullName
(
p
Table
MetaInfo
->
name
,
NULL
,
&
t
,
pzTableName
,
NULL
);
}
}
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -736,11 +740,11 @@ int32_t setMeterID(SMeterMetaInfo* pMeterMetaInfo, SSQLToken* pzTableName, SSqlO
...
@@ -736,11 +740,11 @@ int32_t setMeterID(SMeterMetaInfo* pMeterMetaInfo, SSQLToken* pzTableName, SSqlO
* that are corresponding to the old name for the new table name.
* that are corresponding to the old name for the new table name.
*/
*/
if
(
size
>
0
)
{
if
(
size
>
0
)
{
if
(
strncasecmp
(
oldName
,
p
MeterMetaInfo
->
name
,
tListLen
(
pMeter
MetaInfo
->
name
))
!=
0
)
{
if
(
strncasecmp
(
oldName
,
p
TableMetaInfo
->
name
,
tListLen
(
pTable
MetaInfo
->
name
))
!=
0
)
{
tscClearMeterMetaInfo
(
p
Meter
MetaInfo
,
false
);
tscClearMeterMetaInfo
(
p
Table
MetaInfo
,
false
);
}
}
}
else
{
}
else
{
assert
(
p
MeterMetaInfo
->
pMeterMeta
==
NULL
&&
pMeter
MetaInfo
->
pMetricMeta
==
NULL
);
assert
(
p
TableMetaInfo
->
pTableMeta
==
NULL
&&
pTable
MetaInfo
->
pMetricMeta
==
NULL
);
}
}
tfree
(
oldName
);
tfree
(
oldName
);
...
@@ -890,11 +894,14 @@ bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) {
...
@@ -890,11 +894,14 @@ bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) {
assert
(
pCmd
->
numOfClause
==
1
);
assert
(
pCmd
->
numOfClause
==
1
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
STableMeta
*
pMeterMeta
=
pMeterMetaInfo
->
pMeterMeta
;
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
int32_t
numOfTags
=
tscGetNumOfTags
(
pTableMeta
);
int32_t
numOfCols
=
tscGetNumOfColumns
(
pTableMeta
);
// no more than 6 tags
// no more than 6 tags
if
(
pMeterMeta
->
numOfTags
==
TSDB_MAX_TAGS
)
{
if
(
numOfTags
==
TSDB_MAX_TAGS
)
{
char
msg
[
128
]
=
{
0
};
char
msg
[
128
]
=
{
0
};
sprintf
(
msg
,
"tags no more than %d"
,
TSDB_MAX_TAGS
);
sprintf
(
msg
,
"tags no more than %d"
,
TSDB_MAX_TAGS
);
...
@@ -913,10 +920,10 @@ bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) {
...
@@ -913,10 +920,10 @@ bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) {
return
false
;
return
false
;
}
}
SSchema
*
pTagSchema
=
ts
GetTagSchema
(
pMeterMetaInfo
->
pMeter
Meta
);
SSchema
*
pTagSchema
=
ts
cGetTableTagSchema
(
pTableMetaInfo
->
pTable
Meta
);
int32_t
nLen
=
0
;
int32_t
nLen
=
0
;
for
(
int32_t
i
=
0
;
i
<
pMeterMeta
->
numOfTags
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfTags
;
++
i
)
{
nLen
+=
pTagSchema
[
i
].
bytes
;
nLen
+=
pTagSchema
[
i
].
bytes
;
}
}
...
@@ -939,9 +946,9 @@ bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) {
...
@@ -939,9 +946,9 @@ bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) {
}
}
// field name must be unique
// field name must be unique
SSchema
*
pSchema
=
ts
GetSchema
(
pMeter
Meta
);
SSchema
*
pSchema
=
ts
cGetTableSchema
(
pTable
Meta
);
for
(
int32_t
i
=
0
;
i
<
pMeterMeta
->
numOfTags
+
pMeterMeta
->
numOfColumn
s
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfTags
+
numOfCol
s
;
++
i
)
{
if
(
strncasecmp
(
pTagField
->
name
,
pSchema
[
i
].
name
,
TSDB_COL_NAME_LEN
)
==
0
)
{
if
(
strncasecmp
(
pTagField
->
name
,
pSchema
[
i
].
name
,
TSDB_COL_NAME_LEN
)
==
0
)
{
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
return
false
;
return
false
;
...
@@ -960,12 +967,14 @@ bool validateOneColumn(SSqlCmd* pCmd, TAOS_FIELD* pColField) {
...
@@ -960,12 +967,14 @@ bool validateOneColumn(SSqlCmd* pCmd, TAOS_FIELD* pColField) {
const
char
*
msg6
=
"invalid column length"
;
const
char
*
msg6
=
"invalid column length"
;
assert
(
pCmd
->
numOfClause
==
1
);
assert
(
pCmd
->
numOfClause
==
1
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
STableMeta
*
pMeterMeta
=
pMeterMetaInfo
->
pMeterMeta
;
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
int32_t
numOfTags
=
tscGetNumOfTags
(
pTableMeta
);
int32_t
numOfCols
=
tscGetNumOfColumns
(
pTableMeta
);
// no more max columns
// no more max columns
if
(
pMeterMeta
->
numOfColumns
>=
TSDB_MAX_COLUMNS
||
if
(
numOfCols
>=
TSDB_MAX_COLUMNS
||
numOfTags
+
numOfCols
>=
TSDB_MAX_COLUMNS
)
{
pMeterMeta
->
numOfTags
+
pMeterMeta
->
numOfColumns
>=
TSDB_MAX_COLUMNS
)
{
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
return
false
;
return
false
;
}
}
...
@@ -980,10 +989,10 @@ bool validateOneColumn(SSqlCmd* pCmd, TAOS_FIELD* pColField) {
...
@@ -980,10 +989,10 @@ bool validateOneColumn(SSqlCmd* pCmd, TAOS_FIELD* pColField) {
return
false
;
return
false
;
}
}
SSchema
*
pSchema
=
ts
GetSchema
(
pMeter
Meta
);
SSchema
*
pSchema
=
ts
cGetTableSchema
(
pTable
Meta
);
int32_t
nLen
=
0
;
int32_t
nLen
=
0
;
for
(
int32_t
i
=
0
;
i
<
pMeterMeta
->
numOfColumn
s
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCol
s
;
++
i
)
{
nLen
+=
pSchema
[
i
].
bytes
;
nLen
+=
pSchema
[
i
].
bytes
;
}
}
...
@@ -999,7 +1008,7 @@ bool validateOneColumn(SSqlCmd* pCmd, TAOS_FIELD* pColField) {
...
@@ -999,7 +1008,7 @@ bool validateOneColumn(SSqlCmd* pCmd, TAOS_FIELD* pColField) {
}
}
// field name must be unique
// field name must be unique
for
(
int32_t
i
=
0
;
i
<
pMeterMeta
->
numOfTags
+
pMeterMeta
->
numOfColumn
s
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfTags
+
numOfCol
s
;
++
i
)
{
if
(
strncasecmp
(
pColField
->
name
,
pSchema
[
i
].
name
,
TSDB_COL_NAME_LEN
)
==
0
)
{
if
(
strncasecmp
(
pColField
->
name
,
pSchema
[
i
].
name
,
TSDB_COL_NAME_LEN
)
==
0
)
{
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
return
false
;
return
false
;
...
@@ -1238,10 +1247,11 @@ int32_t parseSelectClause(SSqlCmd* pCmd, int32_t clauseIndex, tSQLExprList* pSel
...
@@ -1238,10 +1247,11 @@ int32_t parseSelectClause(SSqlCmd* pCmd, int32_t clauseIndex, tSQLExprList* pSel
if
(
isSTable
)
{
if
(
isSTable
)
{
pQueryInfo
->
type
|=
TSDB_QUERY_TYPE_STABLE_QUERY
;
pQueryInfo
->
type
|=
TSDB_QUERY_TYPE_STABLE_QUERY
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
int32_t
numOfCols
=
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
if
(
tscQueryMetricTags
(
pQueryInfo
))
{
// local handle the metric tag query
if
(
tscQueryMetricTags
(
pQueryInfo
))
{
// local handle the metric tag query
pCmd
->
count
=
pMeterMetaInfo
->
pMeterMeta
->
numOfColumn
s
;
// the number of meter schema, tricky.
pCmd
->
count
=
numOfCol
s
;
// the number of meter schema, tricky.
pQueryInfo
->
command
=
TSDB_SQL_RETRIEVE_TAGS
;
pQueryInfo
->
command
=
TSDB_SQL_RETRIEVE_TAGS
;
}
}
...
@@ -1272,11 +1282,11 @@ int32_t insertResultField(SQueryInfo* pQueryInfo, int32_t outputIndex, SColumnLi
...
@@ -1272,11 +1282,11 @@ int32_t insertResultField(SQueryInfo* pQueryInfo, int32_t outputIndex, SColumnLi
}
}
SSqlExpr
*
doAddProjectCol
(
SQueryInfo
*
pQueryInfo
,
int32_t
outputIndex
,
int32_t
colIdx
,
int32_t
tableIndex
)
{
SSqlExpr
*
doAddProjectCol
(
SQueryInfo
*
pQueryInfo
,
int32_t
outputIndex
,
int32_t
colIdx
,
int32_t
tableIndex
)
{
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
tableIndex
);
STableMeta
*
pMeterMeta
=
pMeterMetaInfo
->
pMeterMeta
;
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
int32_t
numOfCols
=
tscGetNumOfColumns
(
pTableMeta
);
SSchema
*
pSchema
=
tsGetColumnSchema
(
pMeterMeta
,
colIdx
);
SSchema
*
pSchema
=
tscGetTableColumnSchema
(
pTableMeta
,
colIdx
);
int32_t
numOfCols
=
pMeterMeta
->
numOfColumns
;
int16_t
functionId
=
(
int16_t
)((
colIdx
>=
numOfCols
)
?
TSDB_FUNC_TAGPRJ
:
TSDB_FUNC_PRJ
);
int16_t
functionId
=
(
int16_t
)((
colIdx
>=
numOfCols
)
?
TSDB_FUNC_TAGPRJ
:
TSDB_FUNC_PRJ
);
...
@@ -1295,39 +1305,39 @@ SSqlExpr* doAddProjectCol(SQueryInfo* pQueryInfo, int32_t outputIndex, int32_t c
...
@@ -1295,39 +1305,39 @@ SSqlExpr* doAddProjectCol(SQueryInfo* pQueryInfo, int32_t outputIndex, int32_t c
}
}
void
addRequiredTagColumn
(
SQueryInfo
*
pQueryInfo
,
int32_t
tagColIndex
,
int32_t
tableIndex
)
{
void
addRequiredTagColumn
(
SQueryInfo
*
pQueryInfo
,
int32_t
tagColIndex
,
int32_t
tableIndex
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
tableIndex
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
tableIndex
);
if
(
p
MeterMetaInfo
->
numOfTags
==
0
||
pMeterMetaInfo
->
tagColumnIndex
[
pMeter
MetaInfo
->
numOfTags
-
1
]
<
tagColIndex
)
{
if
(
p
TableMetaInfo
->
numOfTags
==
0
||
pTableMetaInfo
->
tagColumnIndex
[
pTable
MetaInfo
->
numOfTags
-
1
]
<
tagColIndex
)
{
p
MeterMetaInfo
->
tagColumnIndex
[
pMeter
MetaInfo
->
numOfTags
++
]
=
tagColIndex
;
p
TableMetaInfo
->
tagColumnIndex
[
pTable
MetaInfo
->
numOfTags
++
]
=
tagColIndex
;
}
else
{
// find the appropriate position
}
else
{
// find the appropriate position
for
(
int32_t
i
=
0
;
i
<
p
Meter
MetaInfo
->
numOfTags
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
p
Table
MetaInfo
->
numOfTags
;
++
i
)
{
if
(
tagColIndex
>
p
Meter
MetaInfo
->
tagColumnIndex
[
i
])
{
if
(
tagColIndex
>
p
Table
MetaInfo
->
tagColumnIndex
[
i
])
{
continue
;
continue
;
}
else
if
(
tagColIndex
==
p
Meter
MetaInfo
->
tagColumnIndex
[
i
])
{
}
else
if
(
tagColIndex
==
p
Table
MetaInfo
->
tagColumnIndex
[
i
])
{
break
;
break
;
}
else
{
}
else
{
memmove
(
&
p
MeterMetaInfo
->
tagColumnIndex
[
i
+
1
],
&
pMeter
MetaInfo
->
tagColumnIndex
[
i
],
memmove
(
&
p
TableMetaInfo
->
tagColumnIndex
[
i
+
1
],
&
pTable
MetaInfo
->
tagColumnIndex
[
i
],
sizeof
(
p
MeterMetaInfo
->
tagColumnIndex
[
0
])
*
(
pMeter
MetaInfo
->
numOfTags
-
i
));
sizeof
(
p
TableMetaInfo
->
tagColumnIndex
[
0
])
*
(
pTable
MetaInfo
->
numOfTags
-
i
));
p
Meter
MetaInfo
->
tagColumnIndex
[
i
]
=
tagColIndex
;
p
Table
MetaInfo
->
tagColumnIndex
[
i
]
=
tagColIndex
;
p
Meter
MetaInfo
->
numOfTags
++
;
p
Table
MetaInfo
->
numOfTags
++
;
break
;
break
;
}
}
}
}
}
}
// plus one means tbname
// plus one means tbname
assert
(
tagColIndex
>=
-
1
&&
tagColIndex
<
TSDB_MAX_TAGS
&&
p
Meter
MetaInfo
->
numOfTags
<=
TSDB_MAX_TAGS
+
1
);
assert
(
tagColIndex
>=
-
1
&&
tagColIndex
<
TSDB_MAX_TAGS
&&
p
Table
MetaInfo
->
numOfTags
<=
TSDB_MAX_TAGS
+
1
);
}
}
static
void
addProjectQueryCol
(
SQueryInfo
*
pQueryInfo
,
int32_t
startPos
,
SColumnIndex
*
pIndex
,
tSQLExprItem
*
pItem
)
{
static
void
addProjectQueryCol
(
SQueryInfo
*
pQueryInfo
,
int32_t
startPos
,
SColumnIndex
*
pIndex
,
tSQLExprItem
*
pItem
)
{
SSqlExpr
*
pExpr
=
doAddProjectCol
(
pQueryInfo
,
startPos
,
pIndex
->
columnIndex
,
pIndex
->
tableIndex
);
SSqlExpr
*
pExpr
=
doAddProjectCol
(
pQueryInfo
,
startPos
,
pIndex
->
columnIndex
,
pIndex
->
tableIndex
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
pIndex
->
tableIndex
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
pIndex
->
tableIndex
);
STableMeta
*
p
MeterMeta
=
pMeterMetaInfo
->
pMeter
Meta
;
STableMeta
*
p
TableMeta
=
pTableMetaInfo
->
pTable
Meta
;
SSchema
*
pSchema
=
ts
GetColumnSchema
(
pMeter
Meta
,
pIndex
->
columnIndex
);
SSchema
*
pSchema
=
ts
cGetTableColumnSchema
(
pTable
Meta
,
pIndex
->
columnIndex
);
char
*
colName
=
(
pItem
->
aliasName
==
NULL
)
?
pSchema
->
name
:
pItem
->
aliasName
;
char
*
colName
=
(
pItem
->
aliasName
==
NULL
)
?
pSchema
->
name
:
pItem
->
aliasName
;
strncpy
(
pExpr
->
aliasName
,
colName
,
tListLen
(
pExpr
->
aliasName
));
strncpy
(
pExpr
->
aliasName
,
colName
,
tListLen
(
pExpr
->
aliasName
));
...
@@ -1336,7 +1346,7 @@ static void addProjectQueryCol(SQueryInfo* pQueryInfo, int32_t startPos, SColumn
...
@@ -1336,7 +1346,7 @@ static void addProjectQueryCol(SQueryInfo* pQueryInfo, int32_t startPos, SColumn
ids
.
num
=
1
;
ids
.
num
=
1
;
ids
.
ids
[
0
]
=
*
pIndex
;
ids
.
ids
[
0
]
=
*
pIndex
;
if
(
pIndex
->
columnIndex
>=
pMeterMeta
->
numOfColumns
||
pIndex
->
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
if
(
pIndex
->
columnIndex
>=
tscGetNumOfColumns
(
pTableMeta
)
||
pIndex
->
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
ids
.
num
=
0
;
ids
.
num
=
0
;
}
}
...
@@ -1362,16 +1372,16 @@ void tscAddSpecialColumnForSelect(SQueryInfo* pQueryInfo, int32_t outputColIndex
...
@@ -1362,16 +1372,16 @@ void tscAddSpecialColumnForSelect(SQueryInfo* pQueryInfo, int32_t outputColIndex
}
}
static
int32_t
doAddProjectionExprAndResultFields
(
SQueryInfo
*
pQueryInfo
,
SColumnIndex
*
pIndex
,
int32_t
startPos
)
{
static
int32_t
doAddProjectionExprAndResultFields
(
SQueryInfo
*
pQueryInfo
,
SColumnIndex
*
pIndex
,
int32_t
startPos
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
pIndex
->
tableIndex
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
pIndex
->
tableIndex
);
int32_t
numOfTotalColumns
=
0
;
int32_t
numOfTotalColumns
=
0
;
STableMeta
*
p
MeterMeta
=
pMeterMetaInfo
->
pMeter
Meta
;
STableMeta
*
p
TableMeta
=
pTableMetaInfo
->
pTable
Meta
;
SSchema
*
pSchema
=
ts
GetSchema
(
pMeter
Meta
);
SSchema
*
pSchema
=
ts
cGetTableSchema
(
pTable
Meta
);
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
))
{
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
))
{
numOfTotalColumns
=
pMeterMeta
->
numOfColumns
+
pMeterMeta
->
numOfTags
;
numOfTotalColumns
=
tscGetNumOfColumns
(
pTableMeta
)
+
tscGetNumOfTags
(
pTableMeta
)
;
}
else
{
}
else
{
numOfTotalColumns
=
pMeterMeta
->
numOfColumns
;
numOfTotalColumns
=
tscGetNumOfColumns
(
pTableMeta
)
;
}
}
for
(
int32_t
j
=
0
;
j
<
numOfTotalColumns
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
numOfTotalColumns
;
++
j
)
{
...
@@ -1383,7 +1393,7 @@ static int32_t doAddProjectionExprAndResultFields(SQueryInfo* pQueryInfo, SColum
...
@@ -1383,7 +1393,7 @@ static int32_t doAddProjectionExprAndResultFields(SQueryInfo* pQueryInfo, SColum
ids
.
ids
[
0
]
=
*
pIndex
;
ids
.
ids
[
0
]
=
*
pIndex
;
// tag columns do not add to source list
// tag columns do not add to source list
ids
.
num
=
(
j
>=
pMeterMeta
->
numOfColumns
)
?
0
:
1
;
ids
.
num
=
(
j
>=
tscGetNumOfColumns
(
pTableMeta
)
)
?
0
:
1
;
insertResultField
(
pQueryInfo
,
startPos
+
j
,
&
ids
,
pSchema
[
j
].
bytes
,
pSchema
[
j
].
type
,
pSchema
[
j
].
name
,
pExpr
);
insertResultField
(
pQueryInfo
,
startPos
+
j
,
&
ids
,
pSchema
[
j
].
bytes
,
pSchema
[
j
].
type
,
pSchema
[
j
].
name
,
pExpr
);
}
}
...
@@ -1427,10 +1437,10 @@ int32_t addProjectionExprAndResultField(SQueryInfo* pQueryInfo, tSQLExprItem* pI
...
@@ -1427,10 +1437,10 @@ int32_t addProjectionExprAndResultField(SQueryInfo* pQueryInfo, tSQLExprItem* pI
pQueryInfo
->
type
=
TSDB_QUERY_TYPE_STABLE_QUERY
;
pQueryInfo
->
type
=
TSDB_QUERY_TYPE_STABLE_QUERY
;
tscAddSpecialColumnForSelect
(
pQueryInfo
,
startPos
,
TSDB_FUNC_TAGPRJ
,
&
index
,
&
colSchema
,
true
);
tscAddSpecialColumnForSelect
(
pQueryInfo
,
startPos
,
TSDB_FUNC_TAGPRJ
,
&
index
,
&
colSchema
,
true
);
}
else
{
}
else
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
STableMeta
*
p
MeterMeta
=
pMeterMetaInfo
->
pMeter
Meta
;
STableMeta
*
p
TableMeta
=
pTableMetaInfo
->
pTable
Meta
;
if
(
index
.
columnIndex
>=
pMeterMeta
->
numOfColumns
&&
UTIL_METER_IS_NOMRAL_METER
(
pMeter
MetaInfo
))
{
if
(
index
.
columnIndex
>=
tscGetNumOfColumns
(
pTableMeta
)
&&
UTIL_METER_IS_NOMRAL_METER
(
pTable
MetaInfo
))
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
}
}
...
@@ -1488,7 +1498,7 @@ static int32_t setExprInfoForFunctions(SQueryInfo* pQueryInfo, SSchema* pSchema,
...
@@ -1488,7 +1498,7 @@ static int32_t setExprInfoForFunctions(SQueryInfo* pQueryInfo, SSchema* pSchema,
}
}
int32_t
addExprAndResultField
(
SQueryInfo
*
pQueryInfo
,
int32_t
colIdx
,
tSQLExprItem
*
pItem
,
bool
finalResult
)
{
int32_t
addExprAndResultField
(
SQueryInfo
*
pQueryInfo
,
int32_t
colIdx
,
tSQLExprItem
*
pItem
,
bool
finalResult
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
NULL
;
S
TableMetaInfo
*
pTable
MetaInfo
=
NULL
;
int32_t
optr
=
pItem
->
pNode
->
nSQLOptr
;
int32_t
optr
=
pItem
->
pNode
->
nSQLOptr
;
const
char
*
msg1
=
"not support column types"
;
const
char
*
msg1
=
"not support column types"
;
...
@@ -1538,10 +1548,10 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
...
@@ -1538,10 +1548,10 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg3
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg3
);
}
}
p
Meter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
p
Table
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
// count tag is equalled to count(tbname)
// count tag is equalled to count(tbname)
if
(
index
.
columnIndex
>=
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
)
{
if
(
index
.
columnIndex
>=
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
)
)
{
index
.
columnIndex
=
TSDB_TBNAME_COLUMN_INDEX
;
index
.
columnIndex
=
TSDB_TBNAME_COLUMN_INDEX
;
}
}
...
@@ -1603,8 +1613,8 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
...
@@ -1603,8 +1613,8 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
}
}
// 2. check if sql function can be applied on this column data type
// 2. check if sql function can be applied on this column data type
p
Meter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
p
Table
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
SSchema
*
pSchema
=
ts
GetColumnSchema
(
pMeterMetaInfo
->
pMeter
Meta
,
index
.
columnIndex
);
SSchema
*
pSchema
=
ts
cGetTableColumnSchema
(
pTableMetaInfo
->
pTable
Meta
,
index
.
columnIndex
);
int16_t
colType
=
pSchema
->
type
;
int16_t
colType
=
pSchema
->
type
;
if
(
colType
<=
TSDB_DATA_TYPE_BOOL
||
colType
>=
TSDB_DATA_TYPE_BINARY
)
{
if
(
colType
<=
TSDB_DATA_TYPE_BOOL
||
colType
>=
TSDB_DATA_TYPE_BINARY
)
{
...
@@ -1637,7 +1647,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
...
@@ -1637,7 +1647,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
}
}
// functions can not be applied to tags
// functions can not be applied to tags
if
(
index
.
columnIndex
>=
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
)
{
if
(
index
.
columnIndex
>=
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
)
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg6
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg6
);
}
}
...
@@ -1711,10 +1721,10 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
...
@@ -1711,10 +1721,10 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg4
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg4
);
}
}
p
Meter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
p
Table
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
SSchema
*
pSchema
=
ts
GetSchema
(
pMeterMetaInfo
->
pMeter
Meta
);
SSchema
*
pSchema
=
ts
cGetTableSchema
(
pTableMetaInfo
->
pTable
Meta
);
for
(
int32_t
j
=
0
;
j
<
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
)
;
++
j
)
{
index
.
columnIndex
=
j
;
index
.
columnIndex
=
j
;
if
(
setExprInfoForFunctions
(
pQueryInfo
,
pSchema
,
functionID
,
pItem
->
aliasName
,
colIdx
++
,
&
index
)
!=
0
)
{
if
(
setExprInfoForFunctions
(
pQueryInfo
,
pSchema
,
functionID
,
pItem
->
aliasName
,
colIdx
++
,
&
index
)
!=
0
)
{
return
TSDB_CODE_INVALID_SQL
;
return
TSDB_CODE_INVALID_SQL
;
...
@@ -1726,11 +1736,11 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
...
@@ -1726,11 +1736,11 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg3
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg3
);
}
}
p
Meter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
p
Table
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
SSchema
*
pSchema
=
ts
GetSchema
(
pMeterMetaInfo
->
pMeter
Meta
);
SSchema
*
pSchema
=
ts
cGetTableSchema
(
pTableMetaInfo
->
pTable
Meta
);
// functions can not be applied to tags
// functions can not be applied to tags
if
((
index
.
columnIndex
>=
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
)
||
(
index
.
columnIndex
<
0
))
{
if
((
index
.
columnIndex
>=
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
)
)
||
(
index
.
columnIndex
<
0
))
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg6
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg6
);
}
}
...
@@ -1745,10 +1755,10 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
...
@@ -1745,10 +1755,10 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
int32_t
numOfFields
=
0
;
int32_t
numOfFields
=
0
;
for
(
int32_t
j
=
0
;
j
<
pQueryInfo
->
numOfTables
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
pQueryInfo
->
numOfTables
;
++
j
)
{
p
Meter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
j
);
p
Table
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
j
);
SSchema
*
pSchema
=
ts
GetSchema
(
pMeterMetaInfo
->
pMeter
Meta
);
SSchema
*
pSchema
=
ts
cGetTableSchema
(
pTableMetaInfo
->
pTable
Meta
);
for
(
int32_t
i
=
0
;
i
<
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
)
;
++
i
)
{
SColumnIndex
index
=
{.
tableIndex
=
j
,
.
columnIndex
=
i
};
SColumnIndex
index
=
{.
tableIndex
=
j
,
.
columnIndex
=
i
};
if
(
setExprInfoForFunctions
(
pQueryInfo
,
pSchema
,
functionID
,
pItem
->
aliasName
,
colIdx
+
i
+
j
,
&
index
)
!=
if
(
setExprInfoForFunctions
(
pQueryInfo
,
pSchema
,
functionID
,
pItem
->
aliasName
,
colIdx
+
i
+
j
,
&
index
)
!=
0
)
{
0
)
{
...
@@ -1756,7 +1766,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
...
@@ -1756,7 +1766,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
}
}
}
}
numOfFields
+=
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
;
numOfFields
+=
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
)
;
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -1782,11 +1792,11 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
...
@@ -1782,11 +1792,11 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg3
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg3
);
}
}
p
Meter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
p
Table
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
SSchema
*
pSchema
=
ts
GetSchema
(
pMeterMetaInfo
->
pMeter
Meta
);
SSchema
*
pSchema
=
ts
cGetTableSchema
(
pTableMetaInfo
->
pTable
Meta
);
// functions can not be applied to tags
// functions can not be applied to tags
if
(
index
.
columnIndex
>=
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
)
{
if
(
index
.
columnIndex
>=
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
)
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg6
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg6
);
}
}
...
@@ -1916,10 +1926,10 @@ static bool isTablenameToken(SSQLToken* token) {
...
@@ -1916,10 +1926,10 @@ static bool isTablenameToken(SSQLToken* token) {
}
}
static
int16_t
doGetColumnIndex
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
,
SSQLToken
*
pToken
)
{
static
int16_t
doGetColumnIndex
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
,
SSQLToken
*
pToken
)
{
STableMeta
*
p
MeterMeta
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
)
->
pMeter
Meta
;
STableMeta
*
p
TableMeta
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
)
->
pTable
Meta
;
int32_t
numOfCols
=
pMeterMeta
->
numOfColumns
+
pMeterMeta
->
numOfTags
;
int32_t
numOfCols
=
tscGetNumOfColumns
(
pTableMeta
)
+
tscGetNumOfTags
(
pTableMeta
)
;
SSchema
*
pSchema
=
ts
GetSchema
(
pMeter
Meta
);
SSchema
*
pSchema
=
ts
cGetTableSchema
(
pTable
Meta
);
int16_t
columnIndex
=
COLUMN_INDEX_INITIAL_VAL
;
int16_t
columnIndex
=
COLUMN_INDEX_INITIAL_VAL
;
...
@@ -1991,8 +2001,8 @@ int32_t getMeterIndex(SSQLToken* pTableToken, SQueryInfo* pQueryInfo, SColumnInd
...
@@ -1991,8 +2001,8 @@ int32_t getMeterIndex(SSQLToken* pTableToken, SQueryInfo* pQueryInfo, SColumnInd
char
tableName
[
TSDB_TABLE_ID_LEN
+
1
]
=
{
0
};
char
tableName
[
TSDB_TABLE_ID_LEN
+
1
]
=
{
0
};
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
i
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
i
);
extractTableName
(
p
Meter
MetaInfo
->
name
,
tableName
);
extractTableName
(
p
Table
MetaInfo
->
name
,
tableName
);
if
(
strncasecmp
(
tableName
,
pTableToken
->
z
,
pTableToken
->
n
)
==
0
&&
strlen
(
tableName
)
==
pTableToken
->
n
)
{
if
(
strncasecmp
(
tableName
,
pTableToken
->
z
,
pTableToken
->
n
)
==
0
&&
strlen
(
tableName
)
==
pTableToken
->
n
)
{
pIndex
->
tableIndex
=
i
;
pIndex
->
tableIndex
=
i
;
...
@@ -2115,7 +2125,7 @@ int32_t changeFunctionID(int32_t optr, int16_t* functionId) {
...
@@ -2115,7 +2125,7 @@ int32_t changeFunctionID(int32_t optr, int16_t* functionId) {
int32_t
setShowInfo
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
)
{
int32_t
setShowInfo
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
assert
(
pCmd
->
numOfClause
==
1
);
assert
(
pCmd
->
numOfClause
==
1
);
pCmd
->
command
=
TSDB_SQL_SHOW
;
pCmd
->
command
=
TSDB_SQL_SHOW
;
...
@@ -2151,7 +2161,7 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -2151,7 +2161,7 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
}
int32_t
ret
=
setObjFullName
(
p
Meter
MetaInfo
->
name
,
getAccountId
(
pSql
),
pDbPrefixToken
,
NULL
,
NULL
);
int32_t
ret
=
setObjFullName
(
p
Table
MetaInfo
->
name
,
getAccountId
(
pSql
),
pDbPrefixToken
,
NULL
,
NULL
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
}
...
@@ -2235,13 +2245,13 @@ bool validateIpAddress(const char* ip, size_t size) {
...
@@ -2235,13 +2245,13 @@ bool validateIpAddress(const char* ip, size_t size) {
}
}
int32_t
tscTansformSQLFunctionForSTableQuery
(
SQueryInfo
*
pQueryInfo
)
{
int32_t
tscTansformSQLFunctionForSTableQuery
(
SQueryInfo
*
pQueryInfo
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
if
(
p
MeterMetaInfo
->
pMeterMeta
==
NULL
||
!
UTIL_METER_IS_SUPERTABLE
(
pMeter
MetaInfo
))
{
if
(
p
TableMetaInfo
->
pTableMeta
==
NULL
||
!
UTIL_METER_IS_SUPERTABLE
(
pTable
MetaInfo
))
{
return
TSDB_CODE_INVALID_SQL
;
return
TSDB_CODE_INVALID_SQL
;
}
}
assert
(
pMeterMetaInfo
->
pMeterMeta
->
numOfTags
>=
0
);
assert
(
tscGetNumOfTags
(
pTableMetaInfo
->
pTableMeta
)
>=
0
);
int16_t
bytes
=
0
;
int16_t
bytes
=
0
;
int16_t
type
=
0
;
int16_t
type
=
0
;
...
@@ -2252,7 +2262,7 @@ int32_t tscTansformSQLFunctionForSTableQuery(SQueryInfo* pQueryInfo) {
...
@@ -2252,7 +2262,7 @@ int32_t tscTansformSQLFunctionForSTableQuery(SQueryInfo* pQueryInfo) {
int16_t
functionId
=
aAggs
[
pExpr
->
functionId
].
stableFuncId
;
int16_t
functionId
=
aAggs
[
pExpr
->
functionId
].
stableFuncId
;
int32_t
colIndex
=
pExpr
->
colInfo
.
colIdx
;
int32_t
colIndex
=
pExpr
->
colInfo
.
colIdx
;
SSchema
*
pSrcSchema
=
ts
GetColumnSchema
(
pMeterMetaInfo
->
pMeter
Meta
,
colIndex
);
SSchema
*
pSrcSchema
=
ts
cGetTableColumnSchema
(
pTableMetaInfo
->
pTable
Meta
,
colIndex
);
if
((
functionId
>=
TSDB_FUNC_SUM
&&
functionId
<=
TSDB_FUNC_TWA
)
||
if
((
functionId
>=
TSDB_FUNC_SUM
&&
functionId
<=
TSDB_FUNC_TWA
)
||
(
functionId
>=
TSDB_FUNC_FIRST_DST
&&
functionId
<=
TSDB_FUNC_LAST_DST
)
||
(
functionId
>=
TSDB_FUNC_FIRST_DST
&&
functionId
<=
TSDB_FUNC_LAST_DST
)
||
...
@@ -2274,14 +2284,14 @@ int32_t tscTansformSQLFunctionForSTableQuery(SQueryInfo* pQueryInfo) {
...
@@ -2274,14 +2284,14 @@ int32_t tscTansformSQLFunctionForSTableQuery(SQueryInfo* pQueryInfo) {
/* transfer the field-info back to original input format */
/* transfer the field-info back to original input format */
void
tscRestoreSQLFunctionForMetricQuery
(
SQueryInfo
*
pQueryInfo
)
{
void
tscRestoreSQLFunctionForMetricQuery
(
SQueryInfo
*
pQueryInfo
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
if
(
!
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
))
{
if
(
!
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
))
{
return
;
return
;
}
}
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
SSchema
*
pSchema
=
ts
GetColumnSchema
(
pMeterMetaInfo
->
pMeter
Meta
,
pExpr
->
colInfo
.
colIdx
);
SSchema
*
pSchema
=
ts
cGetTableColumnSchema
(
pTableMetaInfo
->
pTable
Meta
,
pExpr
->
colInfo
.
colIdx
);
// if (/*(pExpr->functionId >= TSDB_FUNC_FIRST_DST && pExpr->functionId <= TSDB_FUNC_LAST_DST) ||
// if (/*(pExpr->functionId >= TSDB_FUNC_FIRST_DST && pExpr->functionId <= TSDB_FUNC_LAST_DST) ||
// (pExpr->functionId >= TSDB_FUNC_SUM && pExpr->functionId <= TSDB_FUNC_MAX) ||
// (pExpr->functionId >= TSDB_FUNC_SUM && pExpr->functionId <= TSDB_FUNC_MAX) ||
...
@@ -2371,7 +2381,7 @@ static bool functionCompatibleCheck(SQueryInfo* pQueryInfo) {
...
@@ -2371,7 +2381,7 @@ static bool functionCompatibleCheck(SQueryInfo* pQueryInfo) {
}
}
void
updateTagColumnIndex
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
)
{
void
updateTagColumnIndex
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
tableIndex
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
tableIndex
);
/*
/*
* update tags column index for group by tags
* update tags column index for group by tags
...
@@ -2381,8 +2391,8 @@ void updateTagColumnIndex(SQueryInfo* pQueryInfo, int32_t tableIndex) {
...
@@ -2381,8 +2391,8 @@ void updateTagColumnIndex(SQueryInfo* pQueryInfo, int32_t tableIndex) {
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
;
++
i
)
{
int32_t
index
=
pQueryInfo
->
groupbyExpr
.
columnInfo
[
i
].
colIdx
;
int32_t
index
=
pQueryInfo
->
groupbyExpr
.
columnInfo
[
i
].
colIdx
;
for
(
int32_t
j
=
0
;
j
<
p
Meter
MetaInfo
->
numOfTags
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
p
Table
MetaInfo
->
numOfTags
;
++
j
)
{
int32_t
tagColIndex
=
p
Meter
MetaInfo
->
tagColumnIndex
[
j
];
int32_t
tagColIndex
=
p
Table
MetaInfo
->
tagColumnIndex
[
j
];
if
(
tagColIndex
==
index
)
{
if
(
tagColIndex
==
index
)
{
pQueryInfo
->
groupbyExpr
.
columnInfo
[
i
].
colIdx
=
j
;
pQueryInfo
->
groupbyExpr
.
columnInfo
[
i
].
colIdx
=
j
;
break
;
break
;
...
@@ -2400,12 +2410,12 @@ void updateTagColumnIndex(SQueryInfo* pQueryInfo, int32_t tableIndex) {
...
@@ -2400,12 +2410,12 @@ void updateTagColumnIndex(SQueryInfo* pQueryInfo, int32_t tableIndex) {
}
}
// not belongs to this table
// not belongs to this table
if
(
pExpr
->
uid
!=
p
MeterMetaInfo
->
pMeter
Meta
->
uid
)
{
if
(
pExpr
->
uid
!=
p
TableMetaInfo
->
pTable
Meta
->
uid
)
{
continue
;
continue
;
}
}
for
(
int32_t
j
=
0
;
j
<
p
Meter
MetaInfo
->
numOfTags
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
p
Table
MetaInfo
->
numOfTags
;
++
j
)
{
if
(
pExpr
->
colInfo
.
colIdx
==
p
Meter
MetaInfo
->
tagColumnIndex
[
j
])
{
if
(
pExpr
->
colInfo
.
colIdx
==
p
Table
MetaInfo
->
tagColumnIndex
[
j
])
{
pExpr
->
colInfo
.
colIdx
=
j
;
pExpr
->
colInfo
.
colIdx
=
j
;
break
;
break
;
}
}
...
@@ -2421,17 +2431,17 @@ void updateTagColumnIndex(SQueryInfo* pQueryInfo, int32_t tableIndex) {
...
@@ -2421,17 +2431,17 @@ void updateTagColumnIndex(SQueryInfo* pQueryInfo, int32_t tableIndex) {
assert
(
pJoinInfo
->
left
.
uid
!=
pJoinInfo
->
right
.
uid
);
assert
(
pJoinInfo
->
left
.
uid
!=
pJoinInfo
->
right
.
uid
);
// the join condition expression node belongs to this table(super table)
// the join condition expression node belongs to this table(super table)
if
(
p
MeterMetaInfo
->
pMeter
Meta
->
uid
==
pJoinInfo
->
left
.
uid
)
{
if
(
p
TableMetaInfo
->
pTable
Meta
->
uid
==
pJoinInfo
->
left
.
uid
)
{
for
(
int32_t
i
=
0
;
i
<
p
Meter
MetaInfo
->
numOfTags
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
p
Table
MetaInfo
->
numOfTags
;
++
i
)
{
if
(
pJoinInfo
->
left
.
tagCol
==
p
Meter
MetaInfo
->
tagColumnIndex
[
i
])
{
if
(
pJoinInfo
->
left
.
tagCol
==
p
Table
MetaInfo
->
tagColumnIndex
[
i
])
{
pJoinInfo
->
left
.
tagCol
=
i
;
pJoinInfo
->
left
.
tagCol
=
i
;
}
}
}
}
}
}
if
(
p
MeterMetaInfo
->
pMeter
Meta
->
uid
==
pJoinInfo
->
right
.
uid
)
{
if
(
p
TableMetaInfo
->
pTable
Meta
->
uid
==
pJoinInfo
->
right
.
uid
)
{
for
(
int32_t
i
=
0
;
i
<
p
Meter
MetaInfo
->
numOfTags
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
p
Table
MetaInfo
->
numOfTags
;
++
i
)
{
if
(
pJoinInfo
->
right
.
tagCol
==
p
Meter
MetaInfo
->
tagColumnIndex
[
i
])
{
if
(
pJoinInfo
->
right
.
tagCol
==
p
Table
MetaInfo
->
tagColumnIndex
[
i
])
{
pJoinInfo
->
right
.
tagCol
=
i
;
pJoinInfo
->
right
.
tagCol
=
i
;
}
}
}
}
...
@@ -2447,7 +2457,7 @@ int32_t parseGroupbyClause(SQueryInfo* pQueryInfo, tVariantList* pList, SSqlCmd*
...
@@ -2447,7 +2457,7 @@ int32_t parseGroupbyClause(SQueryInfo* pQueryInfo, tVariantList* pList, SSqlCmd*
const
char
*
msg9
=
"tags not allowed for table query"
;
const
char
*
msg9
=
"tags not allowed for table query"
;
// todo : handle two meter situation
// todo : handle two meter situation
S
MeterMetaInfo
*
pMeter
MetaInfo
=
NULL
;
S
TableMetaInfo
*
pTable
MetaInfo
=
NULL
;
if
(
pList
==
NULL
)
{
if
(
pList
==
NULL
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -2458,7 +2468,7 @@ int32_t parseGroupbyClause(SQueryInfo* pQueryInfo, tVariantList* pList, SSqlCmd*
...
@@ -2458,7 +2468,7 @@ int32_t parseGroupbyClause(SQueryInfo* pQueryInfo, tVariantList* pList, SSqlCmd*
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
}
}
STableMeta
*
p
Meter
Meta
=
NULL
;
STableMeta
*
p
Table
Meta
=
NULL
;
SSchema
*
pSchema
=
NULL
;
SSchema
*
pSchema
=
NULL
;
SSchema
s
=
tsGetTbnameColumnSchema
();
SSchema
s
=
tsGetTbnameColumnSchema
();
...
@@ -2480,28 +2490,28 @@ int32_t parseGroupbyClause(SQueryInfo* pQueryInfo, tVariantList* pList, SSqlCmd*
...
@@ -2480,28 +2490,28 @@ int32_t parseGroupbyClause(SQueryInfo* pQueryInfo, tVariantList* pList, SSqlCmd*
tableIndex
=
index
.
tableIndex
;
tableIndex
=
index
.
tableIndex
;
p
Meter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
p
Table
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
p
MeterMeta
=
pMeterMetaInfo
->
pMeter
Meta
;
p
TableMeta
=
pTableMetaInfo
->
pTable
Meta
;
if
(
index
.
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
if
(
index
.
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
pSchema
=
&
s
;
pSchema
=
&
s
;
}
else
{
}
else
{
pSchema
=
ts
GetColumnSchema
(
pMeter
Meta
,
index
.
columnIndex
);
pSchema
=
ts
cGetTableColumnSchema
(
pTable
Meta
,
index
.
columnIndex
);
}
}
bool
groupTag
=
false
;
bool
groupTag
=
false
;
if
(
index
.
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
||
index
.
columnIndex
>=
pMeterMeta
->
numOfColumns
)
{
if
(
index
.
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
||
index
.
columnIndex
>=
tscGetNumOfColumns
(
pTableMeta
)
)
{
groupTag
=
true
;
groupTag
=
true
;
}
}
if
(
groupTag
)
{
if
(
groupTag
)
{
if
(
!
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
))
{
if
(
!
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
))
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg9
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg9
);
}
}
int32_t
relIndex
=
index
.
columnIndex
;
int32_t
relIndex
=
index
.
columnIndex
;
if
(
index
.
columnIndex
!=
TSDB_TBNAME_COLUMN_INDEX
)
{
if
(
index
.
columnIndex
!=
TSDB_TBNAME_COLUMN_INDEX
)
{
relIndex
-=
pMeterMeta
->
numOfColumns
;
relIndex
-=
tscGetNumOfColumns
(
pTableMeta
)
;
}
}
pQueryInfo
->
groupbyExpr
.
columnInfo
[
i
]
=
pQueryInfo
->
groupbyExpr
.
columnInfo
[
i
]
=
...
@@ -2561,9 +2571,9 @@ static int32_t doExtractColumnFilterInfo(SQueryInfo* pQueryInfo, SColumnFilterIn
...
@@ -2561,9 +2571,9 @@ static int32_t doExtractColumnFilterInfo(SQueryInfo* pQueryInfo, SColumnFilterIn
const
char
*
msg
=
"not supported filter condition"
;
const
char
*
msg
=
"not supported filter condition"
;
tSQLExpr
*
pRight
=
pExpr
->
pRight
;
tSQLExpr
*
pRight
=
pExpr
->
pRight
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
columnIndex
->
tableIndex
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
columnIndex
->
tableIndex
);
SSchema
*
pSchema
=
ts
GetColumnSchema
(
pMeterMetaInfo
->
pMeter
Meta
,
columnIndex
->
columnIndex
);
SSchema
*
pSchema
=
ts
cGetTableColumnSchema
(
pTableMetaInfo
->
pTable
Meta
,
columnIndex
->
columnIndex
);
int16_t
colType
=
pSchema
->
type
;
int16_t
colType
=
pSchema
->
type
;
if
(
colType
>=
TSDB_DATA_TYPE_TINYINT
&&
colType
<=
TSDB_DATA_TYPE_BIGINT
)
{
if
(
colType
>=
TSDB_DATA_TYPE_TINYINT
&&
colType
<=
TSDB_DATA_TYPE_BIGINT
)
{
...
@@ -2806,10 +2816,10 @@ enum {
...
@@ -2806,10 +2816,10 @@ enum {
};
};
static
int32_t
extractColumnFilterInfo
(
SQueryInfo
*
pQueryInfo
,
SColumnIndex
*
pIndex
,
tSQLExpr
*
pExpr
,
int32_t
sqlOptr
)
{
static
int32_t
extractColumnFilterInfo
(
SQueryInfo
*
pQueryInfo
,
SColumnIndex
*
pIndex
,
tSQLExpr
*
pExpr
,
int32_t
sqlOptr
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
pIndex
->
tableIndex
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
pIndex
->
tableIndex
);
STableMeta
*
p
MeterMeta
=
pMeterMetaInfo
->
pMeter
Meta
;
STableMeta
*
p
TableMeta
=
pTableMetaInfo
->
pTable
Meta
;
SSchema
*
pSchema
=
ts
GetColumnSchema
(
pMeter
Meta
,
pIndex
->
columnIndex
);
SSchema
*
pSchema
=
ts
cGetTableColumnSchema
(
pTable
Meta
,
pIndex
->
columnIndex
);
const
char
*
msg1
=
"non binary column not support like operator"
;
const
char
*
msg1
=
"non binary column not support like operator"
;
const
char
*
msg2
=
"binary column not support this operator"
;
const
char
*
msg2
=
"binary column not support this operator"
;
...
@@ -2966,24 +2976,24 @@ static int32_t getJoinCondInfo(SQueryInfo* pQueryInfo, tSQLExpr* pExpr) {
...
@@ -2966,24 +2976,24 @@ static int32_t getJoinCondInfo(SQueryInfo* pQueryInfo, tSQLExpr* pExpr) {
return
TSDB_CODE_INVALID_SQL
;
return
TSDB_CODE_INVALID_SQL
;
}
}
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
int16_t
tagColIndex
=
index
.
columnIndex
-
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
;
int16_t
tagColIndex
=
index
.
columnIndex
-
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
)
;
pLeft
->
uid
=
p
MeterMetaInfo
->
pMeter
Meta
->
uid
;
pLeft
->
uid
=
p
TableMetaInfo
->
pTable
Meta
->
uid
;
pLeft
->
tagCol
=
tagColIndex
;
pLeft
->
tagCol
=
tagColIndex
;
strcpy
(
pLeft
->
tableId
,
p
Meter
MetaInfo
->
name
);
strcpy
(
pLeft
->
tableId
,
p
Table
MetaInfo
->
name
);
index
=
(
SColumnIndex
)
COLUMN_INDEX_INITIALIZER
;
index
=
(
SColumnIndex
)
COLUMN_INDEX_INITIALIZER
;
if
(
getColumnIndexByName
(
&
pExpr
->
pRight
->
colInfo
,
pQueryInfo
,
&
index
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
getColumnIndexByName
(
&
pExpr
->
pRight
->
colInfo
,
pQueryInfo
,
&
index
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_INVALID_SQL
;
return
TSDB_CODE_INVALID_SQL
;
}
}
p
Meter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
p
Table
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
tagColIndex
=
index
.
columnIndex
-
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
;
tagColIndex
=
index
.
columnIndex
-
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
)
;
pRight
->
uid
=
p
MeterMetaInfo
->
pMeter
Meta
->
uid
;
pRight
->
uid
=
p
TableMetaInfo
->
pTable
Meta
->
uid
;
pRight
->
tagCol
=
tagColIndex
;
pRight
->
tagCol
=
tagColIndex
;
strcpy
(
pRight
->
tableId
,
p
Meter
MetaInfo
->
name
);
strcpy
(
pRight
->
tableId
,
p
Table
MetaInfo
->
name
);
pTagCond
->
joinInfo
.
hasJoin
=
true
;
pTagCond
->
joinInfo
.
hasJoin
=
true
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -3035,8 +3045,9 @@ static int32_t validateSQLExpr(tSQLExpr* pExpr, SQueryInfo* pQueryInfo, SColumnL
...
@@ -3035,8 +3045,9 @@ static int32_t validateSQLExpr(tSQLExpr* pExpr, SQueryInfo* pQueryInfo, SColumnL
}
}
// if column is timestamp, bool, binary, nchar, not support arithmetic, so return invalid sql
// if column is timestamp, bool, binary, nchar, not support arithmetic, so return invalid sql
STableMeta
*
pMeterMeta
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
)
->
pMeterMeta
;
STableMeta
*
pTableMeta
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
)
->
pTableMeta
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMeta
)
+
index
.
columnIndex
;
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMeta
)
+
index
.
columnIndex
;
if
((
pSchema
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
||
(
pSchema
->
type
==
TSDB_DATA_TYPE_BOOL
)
||
if
((
pSchema
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
||
(
pSchema
->
type
==
TSDB_DATA_TYPE_BOOL
)
||
(
pSchema
->
type
==
TSDB_DATA_TYPE_BINARY
)
||
(
pSchema
->
type
==
TSDB_DATA_TYPE_NCHAR
))
{
(
pSchema
->
type
==
TSDB_DATA_TYPE_BINARY
)
||
(
pSchema
->
type
==
TSDB_DATA_TYPE_NCHAR
))
{
return
TSDB_CODE_INVALID_SQL
;
return
TSDB_CODE_INVALID_SQL
;
...
@@ -3183,12 +3194,12 @@ static bool validateJoinExprNode(SQueryInfo* pQueryInfo, tSQLExpr* pExpr, SColum
...
@@ -3183,12 +3194,12 @@ static bool validateJoinExprNode(SQueryInfo* pQueryInfo, tSQLExpr* pExpr, SColum
}
}
// todo extract function
// todo extract function
S
Meter
MetaInfo
*
pLeftMeterMeta
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
pLeftIndex
->
tableIndex
);
S
Table
MetaInfo
*
pLeftMeterMeta
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
pLeftIndex
->
tableIndex
);
SSchema
*
pLeftSchema
=
ts
GetSchema
(
pLeftMeterMeta
->
pMeter
Meta
);
SSchema
*
pLeftSchema
=
ts
cGetTableSchema
(
pLeftMeterMeta
->
pTable
Meta
);
int16_t
leftType
=
pLeftSchema
[
pLeftIndex
->
columnIndex
].
type
;
int16_t
leftType
=
pLeftSchema
[
pLeftIndex
->
columnIndex
].
type
;
S
Meter
MetaInfo
*
pRightMeterMeta
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
rightIndex
.
tableIndex
);
S
Table
MetaInfo
*
pRightMeterMeta
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
rightIndex
.
tableIndex
);
SSchema
*
pRightSchema
=
ts
GetSchema
(
pRightMeterMeta
->
pMeter
Meta
);
SSchema
*
pRightSchema
=
ts
cGetTableSchema
(
pRightMeterMeta
->
pTable
Meta
);
int16_t
rightType
=
pRightSchema
[
rightIndex
.
columnIndex
].
type
;
int16_t
rightType
=
pRightSchema
[
rightIndex
.
columnIndex
].
type
;
if
(
leftType
!=
rightType
)
{
if
(
leftType
!=
rightType
)
{
...
@@ -3259,8 +3270,8 @@ static int32_t handleExprInQueryCond(SQueryInfo* pQueryInfo, tSQLExpr** pExpr, S
...
@@ -3259,8 +3270,8 @@ static int32_t handleExprInQueryCond(SQueryInfo* pQueryInfo, tSQLExpr** pExpr, S
assert
(
isExprDirectParentOfLeaftNode
(
*
pExpr
));
assert
(
isExprDirectParentOfLeaftNode
(
*
pExpr
));
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
STableMeta
*
p
MeterMeta
=
pMeterMetaInfo
->
pMeter
Meta
;
STableMeta
*
p
TableMeta
=
pTableMetaInfo
->
pTable
Meta
;
if
(
index
.
columnIndex
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
// query on time range
if
(
index
.
columnIndex
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
// query on time range
if
(
!
validateJoinExprNode
(
pQueryInfo
,
*
pExpr
,
&
index
))
{
if
(
!
validateJoinExprNode
(
pQueryInfo
,
*
pExpr
,
&
index
))
{
...
@@ -3283,10 +3294,10 @@ static int32_t handleExprInQueryCond(SQueryInfo* pQueryInfo, tSQLExpr** pExpr, S
...
@@ -3283,10 +3294,10 @@ static int32_t handleExprInQueryCond(SQueryInfo* pQueryInfo, tSQLExpr** pExpr, S
*
pExpr
=
NULL
;
// remove this expression
*
pExpr
=
NULL
;
// remove this expression
*
type
=
TSQL_EXPR_TS
;
*
type
=
TSQL_EXPR_TS
;
}
else
if
(
index
.
columnIndex
>=
pMeterMeta
->
numOfColumns
||
}
else
if
(
index
.
columnIndex
>=
tscGetNumOfColumns
(
pTableMeta
)
||
index
.
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
// query on tags
index
.
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
// query on tags
// check for tag query condition
// check for tag query condition
if
(
UTIL_METER_IS_NOMRAL_METER
(
p
Meter
MetaInfo
))
{
if
(
UTIL_METER_IS_NOMRAL_METER
(
p
Table
MetaInfo
))
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
}
}
...
@@ -3296,7 +3307,7 @@ static int32_t handleExprInQueryCond(SQueryInfo* pQueryInfo, tSQLExpr** pExpr, S
...
@@ -3296,7 +3307,7 @@ static int32_t handleExprInQueryCond(SQueryInfo* pQueryInfo, tSQLExpr** pExpr, S
return
TSDB_CODE_INVALID_SQL
;
return
TSDB_CODE_INVALID_SQL
;
}
}
SSchema
*
pSchema
=
ts
GetSchema
(
pMeterMetaInfo
->
pMeter
Meta
);
SSchema
*
pSchema
=
ts
cGetTableSchema
(
pTableMetaInfo
->
pTable
Meta
);
if
((
!
isTablenameToken
(
&
pLeft
->
colInfo
))
&&
pSchema
[
index
.
columnIndex
].
type
!=
TSDB_DATA_TYPE_BINARY
&&
if
((
!
isTablenameToken
(
&
pLeft
->
colInfo
))
&&
pSchema
[
index
.
columnIndex
].
type
!=
TSDB_DATA_TYPE_BINARY
&&
pSchema
[
index
.
columnIndex
].
type
!=
TSDB_DATA_TYPE_NCHAR
)
{
pSchema
[
index
.
columnIndex
].
type
!=
TSDB_DATA_TYPE_NCHAR
)
{
...
@@ -3494,10 +3505,10 @@ static int32_t setTableCondForMetricQuery(SQueryInfo* pQueryInfo, const char* ac
...
@@ -3494,10 +3505,10 @@ static int32_t setTableCondForMetricQuery(SQueryInfo* pQueryInfo, const char* ac
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
tableCondIndex
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
tableCondIndex
);
STagCond
*
pTagCond
=
&
pQueryInfo
->
tagCond
;
STagCond
*
pTagCond
=
&
pQueryInfo
->
tagCond
;
pTagCond
->
tbnameCond
.
uid
=
p
MeterMetaInfo
->
pMeter
Meta
->
uid
;
pTagCond
->
tbnameCond
.
uid
=
p
TableMetaInfo
->
pTable
Meta
->
uid
;
assert
(
pExpr
->
nSQLOptr
==
TK_LIKE
||
pExpr
->
nSQLOptr
==
TK_IN
);
assert
(
pExpr
->
nSQLOptr
==
TK_LIKE
||
pExpr
->
nSQLOptr
==
TK_IN
);
...
@@ -3527,7 +3538,7 @@ static int32_t setTableCondForMetricQuery(SQueryInfo* pQueryInfo, const char* ac
...
@@ -3527,7 +3538,7 @@ static int32_t setTableCondForMetricQuery(SQueryInfo* pQueryInfo, const char* ac
}
}
num
=
j
;
num
=
j
;
SSQLToken
dbToken
=
extractDBName
(
p
Meter
MetaInfo
->
name
,
db
);
SSQLToken
dbToken
=
extractDBName
(
p
Table
MetaInfo
->
name
,
db
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
if
(
i
>=
1
)
{
if
(
i
>=
1
)
{
...
@@ -3604,15 +3615,15 @@ static int32_t getTimeRangeFromExpr(SQueryInfo* pQueryInfo, tSQLExpr* pExpr) {
...
@@ -3604,15 +3615,15 @@ static int32_t getTimeRangeFromExpr(SQueryInfo* pQueryInfo, tSQLExpr* pExpr) {
return
TSDB_CODE_INVALID_SQL
;
return
TSDB_CODE_INVALID_SQL
;
}
}
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
STable
Meta
*
pMeterMeta
=
pMeterMetaInfo
->
pMeterMeta
;
STable
Info
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
)
;
tSQLExpr
*
pRight
=
pExpr
->
pRight
;
tSQLExpr
*
pRight
=
pExpr
->
pRight
;
TSKEY
stime
=
0
;
TSKEY
stime
=
0
;
TSKEY
etime
=
INT64_MAX
;
TSKEY
etime
=
INT64_MAX
;
if
(
getTimeRange
(
&
stime
,
&
etime
,
pRight
,
pExpr
->
nSQLOptr
,
pMeterMeta
->
precision
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
getTimeRange
(
&
stime
,
&
etime
,
pRight
,
pExpr
->
nSQLOptr
,
tinfo
.
precision
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg0
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg0
);
}
}
...
@@ -3642,8 +3653,8 @@ static int32_t validateJoinExpr(SQueryInfo* pQueryInfo, SCondExpr* pCondExpr) {
...
@@ -3642,8 +3653,8 @@ static int32_t validateJoinExpr(SQueryInfo* pQueryInfo, SCondExpr* pCondExpr) {
}
}
}
}
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
))
{
// for stable join, tag columns
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
))
{
// for stable join, tag columns
// must be present for join
// must be present for join
if
(
pCondExpr
->
pJoinExpr
==
NULL
)
{
if
(
pCondExpr
->
pJoinExpr
==
NULL
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
...
@@ -3680,20 +3691,20 @@ static void cleanQueryExpr(SCondExpr* pCondExpr) {
...
@@ -3680,20 +3691,20 @@ static void cleanQueryExpr(SCondExpr* pCondExpr) {
}
}
static
void
doAddJoinTagsColumnsIntoTagList
(
SQueryInfo
*
pQueryInfo
,
SCondExpr
*
pCondExpr
)
{
static
void
doAddJoinTagsColumnsIntoTagList
(
SQueryInfo
*
pQueryInfo
,
SCondExpr
*
pCondExpr
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
if
(
QUERY_IS_JOIN_QUERY
(
pQueryInfo
->
type
)
&&
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
))
{
if
(
QUERY_IS_JOIN_QUERY
(
pQueryInfo
->
type
)
&&
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
))
{
SColumnIndex
index
=
{
0
};
SColumnIndex
index
=
{
0
};
getColumnIndexByName
(
&
pCondExpr
->
pJoinExpr
->
pLeft
->
colInfo
,
pQueryInfo
,
&
index
);
getColumnIndexByName
(
&
pCondExpr
->
pJoinExpr
->
pLeft
->
colInfo
,
pQueryInfo
,
&
index
);
p
Meter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
p
Table
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
int32_t
columnInfo
=
index
.
columnIndex
-
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
;
int32_t
columnInfo
=
index
.
columnIndex
-
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
)
;
addRequiredTagColumn
(
pQueryInfo
,
columnInfo
,
index
.
tableIndex
);
addRequiredTagColumn
(
pQueryInfo
,
columnInfo
,
index
.
tableIndex
);
getColumnIndexByName
(
&
pCondExpr
->
pJoinExpr
->
pRight
->
colInfo
,
pQueryInfo
,
&
index
);
getColumnIndexByName
(
&
pCondExpr
->
pJoinExpr
->
pRight
->
colInfo
,
pQueryInfo
,
&
index
);
p
Meter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
p
Table
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
columnInfo
=
index
.
columnIndex
-
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
;
columnInfo
=
index
.
columnIndex
-
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
)
;
addRequiredTagColumn
(
pQueryInfo
,
columnInfo
,
index
.
tableIndex
);
addRequiredTagColumn
(
pQueryInfo
,
columnInfo
,
index
.
tableIndex
);
}
}
}
}
...
@@ -3705,7 +3716,7 @@ static int32_t getTagQueryCondExpr(SQueryInfo* pQueryInfo, SCondExpr* pCondExpr,
...
@@ -3705,7 +3716,7 @@ static int32_t getTagQueryCondExpr(SQueryInfo* pQueryInfo, SCondExpr* pCondExpr,
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
tSQLExpr
*
p1
=
extractExprForSTable
(
pExpr
,
pQueryInfo
,
i
);
tSQLExpr
*
p1
=
extractExprForSTable
(
pExpr
,
pQueryInfo
,
i
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
i
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
i
);
char
c
[
TSDB_MAX_TAGS_LEN
]
=
{
0
};
char
c
[
TSDB_MAX_TAGS_LEN
]
=
{
0
};
char
*
str
=
c
;
char
*
str
=
c
;
...
@@ -3714,7 +3725,7 @@ static int32_t getTagQueryCondExpr(SQueryInfo* pQueryInfo, SCondExpr* pCondExpr,
...
@@ -3714,7 +3725,7 @@ static int32_t getTagQueryCondExpr(SQueryInfo* pQueryInfo, SCondExpr* pCondExpr,
return
ret
;
return
ret
;
}
}
tsSetMetricQueryCond
(
&
pQueryInfo
->
tagCond
,
p
MeterMetaInfo
->
pMeter
Meta
->
uid
,
c
);
tsSetMetricQueryCond
(
&
pQueryInfo
->
tagCond
,
p
TableMetaInfo
->
pTable
Meta
->
uid
,
c
);
doCompactQueryExpr
(
pExpr
);
doCompactQueryExpr
(
pExpr
);
tSQLExprDestroy
(
p1
);
tSQLExprDestroy
(
p1
);
...
@@ -4019,7 +4030,7 @@ int32_t parseFillClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySQL) {
...
@@ -4019,7 +4030,7 @@ int32_t parseFillClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySQL) {
static
void
setDefaultOrderInfo
(
SQueryInfo
*
pQueryInfo
)
{
static
void
setDefaultOrderInfo
(
SQueryInfo
*
pQueryInfo
)
{
/* set default timestamp order information for all queries */
/* set default timestamp order information for all queries */
pQueryInfo
->
order
.
order
=
TSQL_SO_ASC
;
pQueryInfo
->
order
.
order
=
TSQL_SO_ASC
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
if
(
isTopBottomQuery
(
pQueryInfo
))
{
if
(
isTopBottomQuery
(
pQueryInfo
))
{
pQueryInfo
->
order
.
order
=
TSQL_SO_ASC
;
pQueryInfo
->
order
.
order
=
TSQL_SO_ASC
;
...
@@ -4029,7 +4040,7 @@ static void setDefaultOrderInfo(SQueryInfo* pQueryInfo) {
...
@@ -4029,7 +4040,7 @@ static void setDefaultOrderInfo(SQueryInfo* pQueryInfo) {
}
}
/* for metric query, set default ascending order for group output */
/* for metric query, set default ascending order for group output */
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
))
{
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
))
{
pQueryInfo
->
groupbyExpr
.
orderType
=
TSQL_SO_ASC
;
pQueryInfo
->
groupbyExpr
.
orderType
=
TSQL_SO_ASC
;
}
}
}
}
...
@@ -4041,7 +4052,7 @@ int32_t parseOrderbyClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql, SSchema
...
@@ -4041,7 +4052,7 @@ int32_t parseOrderbyClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql, SSchema
const
char
*
msg3
=
"only support order by primary timestamp and first tag in groupby clause"
;
const
char
*
msg3
=
"only support order by primary timestamp and first tag in groupby clause"
;
setDefaultOrderInfo
(
pQueryInfo
);
setDefaultOrderInfo
(
pQueryInfo
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
if
(
pQuerySql
->
pSortOrder
==
NULL
)
{
if
(
pQuerySql
->
pSortOrder
==
NULL
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -4055,7 +4066,7 @@ int32_t parseOrderbyClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql, SSchema
...
@@ -4055,7 +4066,7 @@ int32_t parseOrderbyClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql, SSchema
*
*
* for super table query, the order option must be less than 3.
* for super table query, the order option must be less than 3.
*/
*/
if
(
UTIL_METER_IS_NOMRAL_METER
(
p
Meter
MetaInfo
))
{
if
(
UTIL_METER_IS_NOMRAL_METER
(
p
Table
MetaInfo
))
{
if
(
pSortorder
->
nExpr
>
1
)
{
if
(
pSortorder
->
nExpr
>
1
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg0
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg0
);
}
}
...
@@ -4076,7 +4087,7 @@ int32_t parseOrderbyClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql, SSchema
...
@@ -4076,7 +4087,7 @@ int32_t parseOrderbyClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql, SSchema
SSQLToken
columnName
=
{
pVar
->
nLen
,
pVar
->
nType
,
pVar
->
pz
};
SSQLToken
columnName
=
{
pVar
->
nLen
,
pVar
->
nType
,
pVar
->
pz
};
SColumnIndex
index
=
{
0
};
SColumnIndex
index
=
{
0
};
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
))
{
// metric query
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
))
{
// metric query
if
(
getColumnIndexByName
(
&
columnName
,
pQueryInfo
,
&
index
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
getColumnIndexByName
(
&
columnName
,
pQueryInfo
,
&
index
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
}
}
...
@@ -4084,8 +4095,8 @@ int32_t parseOrderbyClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql, SSchema
...
@@ -4084,8 +4095,8 @@ int32_t parseOrderbyClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql, SSchema
bool
orderByTags
=
false
;
bool
orderByTags
=
false
;
bool
orderByTS
=
false
;
bool
orderByTS
=
false
;
if
(
index
.
columnIndex
>=
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
)
{
if
(
index
.
columnIndex
>=
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
)
)
{
int32_t
relTagIndex
=
index
.
columnIndex
-
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
;
int32_t
relTagIndex
=
index
.
columnIndex
-
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
)
;
if
(
relTagIndex
==
pQueryInfo
->
groupbyExpr
.
columnInfo
[
0
].
colIdx
)
{
if
(
relTagIndex
==
pQueryInfo
->
groupbyExpr
.
columnInfo
[
0
].
colIdx
)
{
orderByTags
=
true
;
orderByTags
=
true
;
}
}
...
@@ -4105,7 +4116,7 @@ int32_t parseOrderbyClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql, SSchema
...
@@ -4105,7 +4116,7 @@ int32_t parseOrderbyClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql, SSchema
if
(
pSortorder
->
nExpr
==
1
)
{
if
(
pSortorder
->
nExpr
==
1
)
{
if
(
orderByTags
)
{
if
(
orderByTags
)
{
pQueryInfo
->
groupbyExpr
.
orderIndex
=
index
.
columnIndex
-
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
;
pQueryInfo
->
groupbyExpr
.
orderIndex
=
index
.
columnIndex
-
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
)
;
pQueryInfo
->
groupbyExpr
.
orderType
=
pQuerySql
->
pSortOrder
->
a
[
0
].
sortOrder
;
pQueryInfo
->
groupbyExpr
.
orderType
=
pQuerySql
->
pSortOrder
->
a
[
0
].
sortOrder
;
}
else
if
(
isTopBottomQuery
(
pQueryInfo
))
{
}
else
if
(
isTopBottomQuery
(
pQueryInfo
))
{
/* order of top/bottom query in interval is not valid */
/* order of top/bottom query in interval is not valid */
...
@@ -4128,7 +4139,7 @@ int32_t parseOrderbyClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql, SSchema
...
@@ -4128,7 +4139,7 @@ int32_t parseOrderbyClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql, SSchema
if
(
pSortorder
->
nExpr
==
2
)
{
if
(
pSortorder
->
nExpr
==
2
)
{
if
(
orderByTags
)
{
if
(
orderByTags
)
{
pQueryInfo
->
groupbyExpr
.
orderIndex
=
index
.
columnIndex
-
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
;
pQueryInfo
->
groupbyExpr
.
orderIndex
=
index
.
columnIndex
-
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
)
;
pQueryInfo
->
groupbyExpr
.
orderType
=
pQuerySql
->
pSortOrder
->
a
[
0
].
sortOrder
;
pQueryInfo
->
groupbyExpr
.
orderType
=
pQuerySql
->
pSortOrder
->
a
[
0
].
sortOrder
;
}
else
{
}
else
{
pQueryInfo
->
order
.
order
=
pSortorder
->
a
[
0
].
sortOrder
;
pQueryInfo
->
order
.
order
=
pSortorder
->
a
[
0
].
sortOrder
;
...
@@ -4193,32 +4204,32 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -4193,32 +4204,32 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
SAlterTableSQL
*
pAlterSQL
=
pInfo
->
pAlterInfo
;
SAlterTableSQL
*
pAlterSQL
=
pInfo
->
pAlterInfo
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
DEFAULT_TABLE_INDEX
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
DEFAULT_TABLE_INDEX
);
if
(
tscValidateName
(
&
(
pAlterSQL
->
name
))
!=
TSDB_CODE_SUCCESS
)
{
if
(
tscValidateName
(
&
(
pAlterSQL
->
name
))
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
}
}
if
(
setMeterID
(
p
Meter
MetaInfo
,
&
(
pAlterSQL
->
name
),
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
setMeterID
(
p
Table
MetaInfo
,
&
(
pAlterSQL
->
name
),
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg2
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg2
);
}
}
int32_t
ret
=
tscGetMeterMeta
(
pSql
,
p
Meter
MetaInfo
);
int32_t
ret
=
tscGetMeterMeta
(
pSql
,
p
Table
MetaInfo
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
return
ret
;
}
}
STableMeta
*
p
MeterMeta
=
pMeterMetaInfo
->
pMeter
Meta
;
STableMeta
*
p
TableMeta
=
pTableMetaInfo
->
pTable
Meta
;
if
(
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_ADD_TAG_COLUMN
||
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_DROP_TAG_COLUMN
||
if
(
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_ADD_TAG_COLUMN
||
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_DROP_TAG_COLUMN
||
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN
)
{
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN
)
{
if
(
UTIL_METER_IS_NOMRAL_METER
(
p
Meter
MetaInfo
))
{
if
(
UTIL_METER_IS_NOMRAL_METER
(
p
Table
MetaInfo
))
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg3
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg3
);
}
}
}
else
if
((
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_UPDATE_TAG_VAL
)
&&
(
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
)))
{
}
else
if
((
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_UPDATE_TAG_VAL
)
&&
(
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
)))
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg4
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg4
);
}
else
if
((
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_ADD_COLUMN
||
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_DROP_COLUMN
)
&&
}
else
if
((
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_ADD_COLUMN
||
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_DROP_COLUMN
)
&&
UTIL_METER_IS_CREATE_FROM_METRIC
(
p
Meter
MetaInfo
))
{
UTIL_METER_IS_CREATE_FROM_METRIC
(
p
Table
MetaInfo
))
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg6
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg6
);
}
}
...
@@ -4240,7 +4251,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -4240,7 +4251,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
const
char
*
msg4
=
"illegal tag name"
;
const
char
*
msg4
=
"illegal tag name"
;
const
char
*
msg5
=
"primary tag cannot be dropped"
;
const
char
*
msg5
=
"primary tag cannot be dropped"
;
if
(
pMeterMeta
->
numOfTags
==
1
)
{
if
(
tscGetNumOfTags
(
pTableMeta
)
==
1
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
}
}
...
@@ -4261,7 +4272,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -4261,7 +4272,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return
TSDB_CODE_INVALID_SQL
;
return
TSDB_CODE_INVALID_SQL
;
}
}
if
(
index
.
columnIndex
<
pMeterMeta
->
numOfColumns
)
{
if
(
index
.
columnIndex
<
tscGetNumOfColumns
(
pTableMeta
)
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg4
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg4
);
}
else
if
(
index
.
columnIndex
==
0
)
{
}
else
if
(
index
.
columnIndex
==
0
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg5
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg5
);
...
@@ -4327,11 +4338,11 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -4327,11 +4338,11 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return
TSDB_CODE_INVALID_SQL
;
return
TSDB_CODE_INVALID_SQL
;
}
}
if
(
columnIndex
.
columnIndex
<
pMeterMeta
->
numOfColumns
)
{
if
(
columnIndex
.
columnIndex
<
tscGetNumOfColumns
(
pTableMeta
)
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg2
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg2
);
}
}
SSchema
*
pTagsSchema
=
ts
GetColumnSchema
(
pMeterMetaInfo
->
pMeter
Meta
,
columnIndex
.
columnIndex
);
SSchema
*
pTagsSchema
=
ts
cGetTableColumnSchema
(
pTableMetaInfo
->
pTable
Meta
,
columnIndex
.
columnIndex
);
if
(
tVariantDump
(
&
pVarList
->
a
[
1
].
pVar
,
pAlterSQL
->
tagData
.
data
/*pCmd->payload*/
,
pTagsSchema
->
type
)
!=
if
(
tVariantDump
(
&
pVarList
->
a
[
1
].
pVar
,
pAlterSQL
->
tagData
.
data
/*pCmd->payload*/
,
pTagsSchema
->
type
)
!=
TSDB_CODE_SUCCESS
)
{
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
...
@@ -4366,7 +4377,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -4366,7 +4377,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
const
char
*
msg4
=
"illegal column name"
;
const
char
*
msg4
=
"illegal column name"
;
const
char
*
msg3
=
"primary timestamp column cannot be dropped"
;
const
char
*
msg3
=
"primary timestamp column cannot be dropped"
;
if
(
pMeterMeta
->
numOfColumns
==
TSDB_MIN_COLUMNS
)
{
//
if
(
tscGetNumOfColumns
(
pTableMeta
)
==
TSDB_MIN_COLUMNS
)
{
//
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
}
...
@@ -4586,7 +4597,7 @@ bool hasTimestampForPointInterpQuery(SQueryInfo* pQueryInfo) {
...
@@ -4586,7 +4597,7 @@ bool hasTimestampForPointInterpQuery(SQueryInfo* pQueryInfo) {
}
}
int32_t
parseLimitClause
(
SQueryInfo
*
pQueryInfo
,
int32_t
clauseIndex
,
SQuerySQL
*
pQuerySql
,
SSqlObj
*
pSql
)
{
int32_t
parseLimitClause
(
SQueryInfo
*
pQueryInfo
,
int32_t
clauseIndex
,
SQuerySQL
*
pQuerySql
,
SSqlObj
*
pSql
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
const
char
*
msg0
=
"soffset/offset can not be less than 0"
;
const
char
*
msg0
=
"soffset/offset can not be less than 0"
;
const
char
*
msg1
=
"slimit/soffset only available for STable query"
;
const
char
*
msg1
=
"slimit/soffset only available for STable query"
;
...
@@ -4611,7 +4622,7 @@ int32_t parseLimitClause(SQueryInfo* pQueryInfo, int32_t clauseIndex, SQuerySQL*
...
@@ -4611,7 +4622,7 @@ int32_t parseLimitClause(SQueryInfo* pQueryInfo, int32_t clauseIndex, SQuerySQL*
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
))
{
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
))
{
bool
queryOnTags
=
false
;
bool
queryOnTags
=
false
;
if
(
tscQueryOnlyMetricTags
(
pQueryInfo
,
&
queryOnTags
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tscQueryOnlyMetricTags
(
pQueryInfo
,
&
queryOnTags
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_INVALID_SQL
;
return
TSDB_CODE_INVALID_SQL
;
...
@@ -4650,8 +4661,8 @@ int32_t parseLimitClause(SQueryInfo* pQueryInfo, int32_t clauseIndex, SQuerySQL*
...
@@ -4650,8 +4661,8 @@ int32_t parseLimitClause(SQueryInfo* pQueryInfo, int32_t clauseIndex, SQuerySQL*
}
}
// No tables included. No results generated. Query results are empty.
// No tables included. No results generated. Query results are empty.
SSuperTableMeta
*
pMetricMeta
=
p
Meter
MetaInfo
->
pMetricMeta
;
SSuperTableMeta
*
pMetricMeta
=
p
Table
MetaInfo
->
pMetricMeta
;
if
(
p
MeterMetaInfo
->
pMeter
Meta
==
NULL
||
pMetricMeta
==
NULL
||
pMetricMeta
->
numOfTables
==
0
)
{
if
(
p
TableMetaInfo
->
pTable
Meta
==
NULL
||
pMetricMeta
==
NULL
||
pMetricMeta
->
numOfTables
==
0
)
{
tscTrace
(
"%p no table in metricmeta, no output result"
,
pSql
);
tscTrace
(
"%p no table in metricmeta, no output result"
,
pSql
);
pQueryInfo
->
command
=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
;
pQueryInfo
->
command
=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
;
}
}
...
@@ -4807,10 +4818,10 @@ void addGroupInfoForSubquery(SSqlObj* pParentObj, SSqlObj* pSql, int32_t subClau
...
@@ -4807,10 +4818,10 @@ void addGroupInfoForSubquery(SSqlObj* pParentObj, SSqlObj* pSql, int32_t subClau
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
num
-
1
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
num
-
1
);
if
(
pExpr
->
functionId
!=
TSDB_FUNC_TAG
)
{
if
(
pExpr
->
functionId
!=
TSDB_FUNC_TAG
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
tableIndex
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
tableIndex
);
int16_t
columnInfo
=
tscGetJoinTagColIndexByUid
(
&
pQueryInfo
->
tagCond
,
p
MeterMetaInfo
->
pMeter
Meta
->
uid
);
int16_t
columnInfo
=
tscGetJoinTagColIndexByUid
(
&
pQueryInfo
->
tagCond
,
p
TableMetaInfo
->
pTable
Meta
->
uid
);
SColumnIndex
index
=
{.
tableIndex
=
0
,
.
columnIndex
=
columnInfo
};
SColumnIndex
index
=
{.
tableIndex
=
0
,
.
columnIndex
=
columnInfo
};
SSchema
*
pSchema
=
ts
GetTagSchema
(
pMeterMetaInfo
->
pMeter
Meta
);
SSchema
*
pSchema
=
ts
cGetTableTagSchema
(
pTableMetaInfo
->
pTable
Meta
);
int16_t
type
=
pSchema
[
index
.
columnIndex
].
type
;
int16_t
type
=
pSchema
[
index
.
columnIndex
].
type
;
int16_t
bytes
=
pSchema
[
index
.
columnIndex
].
bytes
;
int16_t
bytes
=
pSchema
[
index
.
columnIndex
].
bytes
;
...
@@ -4844,9 +4855,9 @@ static void doLimitOutputNormalColOfGroupby(SSqlExpr* pExpr) {
...
@@ -4844,9 +4855,9 @@ static void doLimitOutputNormalColOfGroupby(SSqlExpr* pExpr) {
void
doAddGroupColumnForSubquery
(
SQueryInfo
*
pQueryInfo
,
int32_t
tagIndex
)
{
void
doAddGroupColumnForSubquery
(
SQueryInfo
*
pQueryInfo
,
int32_t
tagIndex
)
{
int32_t
index
=
pQueryInfo
->
groupbyExpr
.
columnInfo
[
tagIndex
].
colIdx
;
int32_t
index
=
pQueryInfo
->
groupbyExpr
.
columnInfo
[
tagIndex
].
colIdx
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
SSchema
*
pSchema
=
ts
GetColumnSchema
(
pMeterMetaInfo
->
pMeter
Meta
,
index
);
SSchema
*
pSchema
=
ts
cGetTableColumnSchema
(
pTableMetaInfo
->
pTable
Meta
,
index
);
SColumnIndex
colIndex
=
{.
tableIndex
=
0
,
.
columnIndex
=
index
};
SColumnIndex
colIndex
=
{.
tableIndex
=
0
,
.
columnIndex
=
index
};
SSqlExpr
*
pExpr
=
tscSqlExprInsert
(
pQueryInfo
,
pQueryInfo
->
exprsInfo
.
numOfExprs
,
TSDB_FUNC_PRJ
,
&
colIndex
,
SSqlExpr
*
pExpr
=
tscSqlExprInsert
(
pQueryInfo
,
pQueryInfo
->
exprsInfo
.
numOfExprs
,
TSDB_FUNC_PRJ
,
&
colIndex
,
...
@@ -4878,8 +4889,8 @@ static void doUpdateSqlFunctionForTagPrj(SQueryInfo* pQueryInfo) {
...
@@ -4878,8 +4889,8 @@ static void doUpdateSqlFunctionForTagPrj(SQueryInfo* pQueryInfo) {
}
}
}
}
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
SSchema
*
pSchema
=
ts
GetSchema
(
pMeterMetaInfo
->
pMeter
Meta
);
SSchema
*
pSchema
=
ts
cGetTableSchema
(
pTableMetaInfo
->
pTable
Meta
);
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
...
@@ -5054,9 +5065,9 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo) {
...
@@ -5054,9 +5065,9 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo) {
static
int32_t
doAddGroupbyColumnsOnDemand
(
SQueryInfo
*
pQueryInfo
)
{
static
int32_t
doAddGroupbyColumnsOnDemand
(
SQueryInfo
*
pQueryInfo
)
{
const
char
*
msg2
=
"interval not allowed in group by normal column"
;
const
char
*
msg2
=
"interval not allowed in group by normal column"
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
SSchema
*
pSchema
=
ts
GetSchema
(
pMeterMetaInfo
->
pMeter
Meta
);
SSchema
*
pSchema
=
ts
cGetTableSchema
(
pTableMetaInfo
->
pTable
Meta
);
int16_t
bytes
=
0
;
int16_t
bytes
=
0
;
int16_t
type
=
0
;
int16_t
type
=
0
;
char
*
name
=
NULL
;
char
*
name
=
NULL
;
...
@@ -5070,7 +5081,7 @@ static int32_t doAddGroupbyColumnsOnDemand(SQueryInfo* pQueryInfo) {
...
@@ -5070,7 +5081,7 @@ static int32_t doAddGroupbyColumnsOnDemand(SQueryInfo* pQueryInfo) {
bytes
=
TSDB_TABLE_NAME_LEN
;
bytes
=
TSDB_TABLE_NAME_LEN
;
name
=
TSQL_TBNAME_L
;
name
=
TSQL_TBNAME_L
;
}
else
{
}
else
{
colIndex
=
(
TSDB_COL_IS_TAG
(
pColIndex
->
flag
))
?
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
+
pColIndex
->
colIdx
colIndex
=
(
TSDB_COL_IS_TAG
(
pColIndex
->
flag
))
?
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
)
+
pColIndex
->
colIdx
:
pColIndex
->
colIdx
;
:
pColIndex
->
colIdx
;
type
=
pSchema
[
colIndex
].
type
;
type
=
pSchema
[
colIndex
].
type
;
...
@@ -5364,7 +5375,7 @@ int32_t doCheckForCreateTable(SSqlObj* pSql, int32_t subClauseIndex, SSqlInfo* p
...
@@ -5364,7 +5375,7 @@ int32_t doCheckForCreateTable(SSqlObj* pSql, int32_t subClauseIndex, SSqlInfo* p
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
subClauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
subClauseIndex
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
SCreateTableSQL
*
pCreateTable
=
pInfo
->
pCreateTableInfo
;
SCreateTableSQL
*
pCreateTable
=
pInfo
->
pCreateTableInfo
;
...
@@ -5380,7 +5391,7 @@ int32_t doCheckForCreateTable(SSqlObj* pSql, int32_t subClauseIndex, SSqlInfo* p
...
@@ -5380,7 +5391,7 @@ int32_t doCheckForCreateTable(SSqlObj* pSql, int32_t subClauseIndex, SSqlInfo* p
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
}
if
(
setMeterID
(
p
Meter
MetaInfo
,
pzTableName
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
setMeterID
(
p
Table
MetaInfo
,
pzTableName
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
}
...
@@ -5425,7 +5436,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
...
@@ -5425,7 +5436,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
const
int32_t
TABLE_INDEX
=
0
;
const
int32_t
TABLE_INDEX
=
0
;
const
int32_t
STABLE_INDEX
=
1
;
const
int32_t
STABLE_INDEX
=
1
;
S
Meter
MetaInfo
*
pStableMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
STABLE_INDEX
);
S
Table
MetaInfo
*
pStableMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
STABLE_INDEX
);
// super table name, create table by using dst
// super table name, create table by using dst
SSQLToken
*
pToken
=
&
(
pCreateTable
->
usingInfo
.
stableName
);
SSQLToken
*
pToken
=
&
(
pCreateTable
->
usingInfo
.
stableName
);
...
@@ -5447,12 +5458,12 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
...
@@ -5447,12 +5458,12 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
return
code
;
return
code
;
}
}
if
(
pStableMeterMetaInfo
->
pMeterMeta
->
numOfTags
!=
pList
->
nExpr
)
{
if
(
tscGetNumOfTags
(
pStableMeterMetaInfo
->
pTableMeta
)
!=
pList
->
nExpr
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg5
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg5
);
}
}
// too long tag values will return invalid sql, not be truncated automatically
// too long tag values will return invalid sql, not be truncated automatically
SSchema
*
pTagSchema
=
ts
GetTagSchema
(
pStableMeterMetaInfo
->
pMeter
Meta
);
SSchema
*
pTagSchema
=
ts
cGetTableTagSchema
(
pStableMeterMetaInfo
->
pTable
Meta
);
char
*
tagVal
=
pCreateTable
->
usingInfo
.
tagdata
.
data
;
char
*
tagVal
=
pCreateTable
->
usingInfo
.
tagdata
.
data
;
for
(
int32_t
i
=
0
;
i
<
pList
->
nExpr
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pList
->
nExpr
;
++
i
)
{
...
@@ -5475,7 +5486,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
...
@@ -5475,7 +5486,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
}
S
Meter
MetaInfo
*
pTableMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
TABLE_INDEX
);
S
Table
MetaInfo
*
pTableMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
TABLE_INDEX
);
int32_t
ret
=
setMeterID
(
pTableMeterMetaInfo
,
&
pInfo
->
pCreateTableInfo
->
name
,
pSql
);
int32_t
ret
=
setMeterID
(
pTableMeterMetaInfo
,
&
pInfo
->
pCreateTableInfo
->
name
,
pSql
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
return
ret
;
...
@@ -5496,7 +5507,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
...
@@ -5496,7 +5507,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
assert
(
pQueryInfo
->
numOfTables
==
1
);
assert
(
pQueryInfo
->
numOfTables
==
1
);
SCreateTableSQL
*
pCreateTable
=
pInfo
->
pCreateTableInfo
;
SCreateTableSQL
*
pCreateTable
=
pInfo
->
pCreateTableInfo
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
// if sql specifies db, use it, otherwise use default db
// if sql specifies db, use it, otherwise use default db
SSQLToken
*
pzTableName
=
&
(
pCreateTable
->
name
);
SSQLToken
*
pzTableName
=
&
(
pCreateTable
->
name
);
...
@@ -5514,16 +5525,16 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
...
@@ -5514,16 +5525,16 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
}
}
if
(
setMeterID
(
p
Meter
MetaInfo
,
&
srcToken
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
setMeterID
(
p
Table
MetaInfo
,
&
srcToken
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg2
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg2
);
}
}
int32_t
code
=
tscGetMeterMeta
(
pSql
,
p
Meter
MetaInfo
);
int32_t
code
=
tscGetMeterMeta
(
pSql
,
p
Table
MetaInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
bool
isSTable
=
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
);
bool
isSTable
=
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
);
if
(
parseSelectClause
(
&
pSql
->
cmd
,
0
,
pQuerySql
->
pSelection
,
isSTable
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
parseSelectClause
(
&
pSql
->
cmd
,
0
,
pQuerySql
->
pSelection
,
isSTable
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_INVALID_SQL
;
return
TSDB_CODE_INVALID_SQL
;
}
}
...
@@ -5545,7 +5556,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
...
@@ -5545,7 +5556,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
}
}
// set the created table[stream] name
// set the created table[stream] name
if
(
setMeterID
(
p
Meter
MetaInfo
,
pzTableName
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
setMeterID
(
p
Table
MetaInfo
,
pzTableName
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
}
}
...
@@ -5603,9 +5614,9 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
...
@@ -5603,9 +5614,9 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
index
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
index
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
if
(
p
Meter
MetaInfo
==
NULL
)
{
if
(
p
Table
MetaInfo
==
NULL
)
{
p
Meter
MetaInfo
=
tscAddEmptyMeterMetaInfo
(
pQueryInfo
);
p
Table
MetaInfo
=
tscAddEmptyMeterMetaInfo
(
pQueryInfo
);
}
}
// too many result columns not support order by in query
// too many result columns not support order by in query
...
@@ -5651,7 +5662,7 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
...
@@ -5651,7 +5662,7 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
tscAddEmptyMeterMetaInfo
(
pQueryInfo
);
tscAddEmptyMeterMetaInfo
(
pQueryInfo
);
}
}
S
Meter
MetaInfo
*
pMeterInfo1
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
i
);
S
Table
MetaInfo
*
pMeterInfo1
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
i
);
SSQLToken
t
=
{.
type
=
TSDB_DATA_TYPE_BINARY
,
.
n
=
pTableItem
->
nLen
,
.
z
=
pTableItem
->
pz
};
SSQLToken
t
=
{.
type
=
TSDB_DATA_TYPE_BINARY
,
.
n
=
pTableItem
->
nLen
,
.
z
=
pTableItem
->
pz
};
if
(
setMeterID
(
pMeterInfo1
,
&
t
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
setMeterID
(
pMeterInfo1
,
&
t
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -5671,7 +5682,7 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
...
@@ -5671,7 +5682,7 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
return
TSDB_CODE_INVALID_SQL
;
return
TSDB_CODE_INVALID_SQL
;
}
}
bool
isSTable
=
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
);
bool
isSTable
=
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
);
if
(
parseSelectClause
(
pCmd
,
index
,
pQuerySql
->
pSelection
,
isSTable
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
parseSelectClause
(
pCmd
,
index
,
pQuerySql
->
pSelection
,
isSTable
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_INVALID_SQL
;
return
TSDB_CODE_INVALID_SQL
;
}
}
...
@@ -5687,19 +5698,20 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
...
@@ -5687,19 +5698,20 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
}
}
// set order by info
// set order by info
if
(
parseOrderbyClause
(
pQueryInfo
,
pQuerySql
,
ts
GetSchema
(
pMeterMetaInfo
->
pMeter
Meta
))
!=
TSDB_CODE_SUCCESS
)
{
if
(
parseOrderbyClause
(
pQueryInfo
,
pQuerySql
,
ts
cGetTableSchema
(
pTableMetaInfo
->
pTable
Meta
))
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_INVALID_SQL
;
return
TSDB_CODE_INVALID_SQL
;
}
}
// set where info
// set where info
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
if
(
pQuerySql
->
pWhere
!=
NULL
)
{
if
(
pQuerySql
->
pWhere
!=
NULL
)
{
if
(
parseWhereClause
(
pQueryInfo
,
&
pQuerySql
->
pWhere
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
parseWhereClause
(
pQueryInfo
,
&
pQuerySql
->
pWhere
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_INVALID_SQL
;
return
TSDB_CODE_INVALID_SQL
;
}
}
pQuerySql
->
pWhere
=
NULL
;
pQuerySql
->
pWhere
=
NULL
;
if
(
tinfo
.
precision
==
TSDB_TIME_PRECISION_MILLI
)
{
if
(
pMeterMetaInfo
->
pMeterMeta
->
precision
==
TSDB_TIME_PRECISION_MILLI
)
{
pQueryInfo
->
stime
=
pQueryInfo
->
stime
/
1000
;
pQueryInfo
->
stime
=
pQueryInfo
->
stime
/
1000
;
pQueryInfo
->
etime
=
pQueryInfo
->
etime
/
1000
;
pQueryInfo
->
etime
=
pQueryInfo
->
etime
/
1000
;
}
}
...
@@ -5710,8 +5722,7 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
...
@@ -5710,8 +5722,7 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
// user does not specified the query time window, twa is not allowed in such case.
// user does not specified the query time window, twa is not allowed in such case.
if
((
pQueryInfo
->
stime
==
0
||
pQueryInfo
->
etime
==
INT64_MAX
||
if
((
pQueryInfo
->
stime
==
0
||
pQueryInfo
->
etime
==
INT64_MAX
||
(
pQueryInfo
->
etime
==
INT64_MAX
/
1000
&&
pMeterMetaInfo
->
pMeterMeta
->
precision
==
TSDB_TIME_PRECISION_MILLI
))
&&
(
pQueryInfo
->
etime
==
INT64_MAX
/
1000
&&
tinfo
.
precision
==
TSDB_TIME_PRECISION_MILLI
))
&&
tscIsTWAQuery
(
pQueryInfo
))
{
tscIsTWAQuery
(
pQueryInfo
))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg9
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg9
);
}
}
...
...
src/client/src/tscSchemaUtil.c
浏览文件 @
03346d0c
...
@@ -19,6 +19,70 @@
...
@@ -19,6 +19,70 @@
#include "ttokendef.h"
#include "ttokendef.h"
#include "taosdef.h"
#include "taosdef.h"
#include "tutil.h"
#include "tutil.h"
#include "tsclient.h"
int32_t
tscGetNumOfTags
(
const
STableMeta
*
pTableMeta
)
{
assert
(
pTableMeta
!=
NULL
);
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMeta
);
if
(
pTableMeta
->
tableType
==
TSDB_NORMAL_TABLE
)
{
assert
(
tinfo
.
numOfTags
==
0
);
return
0
;
}
if
(
pTableMeta
->
tableType
==
TSDB_SUPER_TABLE
||
pTableMeta
->
tableType
==
TSDB_CHILD_TABLE
)
{
assert
(
tinfo
.
numOfTags
>
0
);
return
tinfo
.
numOfTags
;
}
assert
(
tinfo
.
numOfTags
==
0
);
return
0
;
}
int32_t
tscGetNumOfColumns
(
const
STableMeta
*
pTableMeta
)
{
assert
(
pTableMeta
!=
NULL
);
// table created according to super table, use data from super table
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMeta
);
assert
(
tinfo
.
numOfColumns
>=
2
);
return
tinfo
.
numOfColumns
;
}
SSchema
*
tscGetTableSchema
(
const
STableMeta
*
pTableMeta
)
{
assert
(
pTableMeta
!=
NULL
);
if
(
pTableMeta
->
tableType
==
TSDB_CHILD_TABLE
)
{
STableMeta
*
pSTableMeta
=
pTableMeta
->
pSTable
;
assert
(
pSTableMeta
!=
NULL
);
return
pSTableMeta
->
schema
;
}
return
pTableMeta
->
schema
;
}
SSchema
*
tscGetTableTagSchema
(
const
STableMeta
*
pTableMeta
)
{
assert
(
pTableMeta
!=
NULL
&&
(
pTableMeta
->
tableType
==
TSDB_SUPER_TABLE
||
pTableMeta
->
tableType
==
TSDB_CHILD_TABLE
));
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMeta
);
assert
(
tinfo
.
numOfTags
>
0
);
return
tscGetTableColumnSchema
(
pTableMeta
,
tinfo
.
numOfColumns
);
}
STableInfo
tscGetTableInfo
(
const
STableMeta
*
pTableMeta
)
{
assert
(
pTableMeta
!=
NULL
);
if
(
pTableMeta
->
tableType
==
TSDB_CHILD_TABLE
)
{
assert
(
pTableMeta
->
pSTable
!=
NULL
);
return
pTableMeta
->
pSTable
->
tableInfo
;
}
return
pTableMeta
->
tableInfo
;
}
bool
isValidSchema
(
struct
SSchema
*
pSchema
,
int32_t
numOfCols
)
{
bool
isValidSchema
(
struct
SSchema
*
pSchema
,
int32_t
numOfCols
)
{
if
(
!
VALIDNUMOFCOLS
(
numOfCols
))
{
if
(
!
VALIDNUMOFCOLS
(
numOfCols
))
{
...
@@ -64,34 +128,32 @@ bool isValidSchema(struct SSchema* pSchema, int32_t numOfCols) {
...
@@ -64,34 +128,32 @@ bool isValidSchema(struct SSchema* pSchema, int32_t numOfCols) {
return
(
rowLen
<=
TSDB_MAX_BYTES_PER_ROW
);
return
(
rowLen
<=
TSDB_MAX_BYTES_PER_ROW
);
}
}
struct
SSchema
*
tsGetSchema
(
STableMeta
*
pMeta
)
{
SSchema
*
tscGetTableColumnSchema
(
const
STableMeta
*
pTableMeta
,
int32_t
startCol
)
{
if
(
pMeta
==
NULL
)
{
assert
(
pTableMeta
!=
NULL
);
return
NULL
;
}
return
tsGetColumnSchema
(
pMeta
,
0
);
}
struct
SSchema
*
tsGetTagSchema
(
STableMeta
*
pMeta
)
{
SSchema
*
pSchema
=
pTableMeta
->
schema
;
if
(
pMeta
==
NULL
||
pMeta
->
numOfTags
==
0
)
{
return
NULL
;
}
return
tsGetColumnSchema
(
pMeta
,
pMeta
->
numOfColumns
);
if
(
pTableMeta
->
tableType
==
TSDB_CHILD_TABLE
)
{
}
assert
(
pTableMeta
->
pSTable
!=
NULL
);
pSchema
=
pTableMeta
->
pSTable
->
schema
;
}
struct
SSchema
*
tsGetColumnSchema
(
STableMeta
*
pMeta
,
int32_t
startCol
)
{
return
&
pSchema
[
startCol
];
return
(
SSchema
*
)(((
char
*
)
pMeta
+
sizeof
(
STableMeta
))
+
startCol
*
sizeof
(
SSchema
));
}
}
struct
SSchema
tsGetTbnameColumnSchema
()
{
struct
SSchema
tsGetTbnameColumnSchema
()
{
struct
SSchema
s
=
{.
colId
=
TSDB_TBNAME_COLUMN_INDEX
,
.
type
=
TSDB_DATA_TYPE_BINARY
,
.
bytes
=
TSDB_TABLE_NAME_LEN
};
struct
SSchema
s
=
{
strcpy
(
s
.
name
,
TSQL_TBNAME_L
);
.
colId
=
TSDB_TBNAME_COLUMN_INDEX
,
.
type
=
TSDB_DATA_TYPE_BINARY
,
.
bytes
=
TSDB_TABLE_NAME_LEN
};
strcpy
(
s
.
name
,
TSQL_TBNAME_L
);
return
s
;
return
s
;
}
}
/**
/**
* the
Meter
Meta data format in memory is as follows:
* the
Table
Meta data format in memory is as follows:
*
*
* +--------------------+
* +--------------------+
* |STableMeta Body data| sizeof(STableMeta)
* |STableMeta Body data| sizeof(STableMeta)
...
@@ -101,33 +163,35 @@ struct SSchema tsGetTbnameColumnSchema() {
...
@@ -101,33 +163,35 @@ struct SSchema tsGetTbnameColumnSchema() {
* |Tags data | tag_col_1.bytes + tag_col_2.bytes + ....
* |Tags data | tag_col_1.bytes + tag_col_2.bytes + ....
* +--------------------+
* +--------------------+
*
*
* @param pMeta
* @param p
Table
Meta
* @return
* @return
*/
*/
char
*
tsGetTagsValue
(
STableMeta
*
pMeta
)
{
char
*
tsGetTagsValue
(
STableMeta
*
pTableMeta
)
{
int32_t
numOfTotalCols
=
pMeta
->
numOfColumns
+
pMeta
->
numOfTags
;
int32_t
offset
=
0
;
uint32_t
offset
=
sizeof
(
STableMeta
)
+
numOfTotalCols
*
sizeof
(
SSchema
);
// int32_t numOfTotalCols = pTableMeta->numOfColumns + pTableMeta->numOfTags;
// uint32_t offset = sizeof(STableMeta) + numOfTotalCols * sizeof(SSchema);
return
((
char
*
)
pMeta
+
offset
);
return
((
char
*
)
p
Table
Meta
+
offset
);
}
}
bool
tsMeterMetaIdentical
(
STableMeta
*
p1
,
STableMeta
*
p2
)
{
bool
tsMeterMetaIdentical
(
STableMeta
*
p1
,
STableMeta
*
p2
)
{
if
(
p1
==
NULL
||
p2
==
NULL
||
p1
->
uid
!=
p2
->
uid
||
p1
->
sversion
!=
p2
->
sversion
)
{
if
(
p1
==
NULL
||
p2
==
NULL
||
p1
->
uid
!=
p2
->
uid
||
p1
->
sversion
!=
p2
->
sversion
)
{
return
false
;
return
false
;
}
}
//
if
(
p1
==
p2
)
{
// if (p1 == p2) {
// return true;
// }
//
// size_t size = sizeof(STableMeta) + p1->numOfColumns * sizeof(SSchema);
//
// for (int32_t i = 0; i < p1->numOfTags; ++i) {
// SSchema* pColSchema = tscGetTableColumnSchema(p1, i + p1->numOfColumns);
// size += pColSchema->bytes;
// }
// return memcmp(p1, p2, size) == 0;
return
true
;
return
true
;
}
size_t
size
=
sizeof
(
STableMeta
)
+
p1
->
numOfColumns
*
sizeof
(
SSchema
);
for
(
int32_t
i
=
0
;
i
<
p1
->
numOfTags
;
++
i
)
{
SSchema
*
pColSchema
=
tsGetColumnSchema
(
p1
,
i
+
p1
->
numOfColumns
);
size
+=
pColSchema
->
bytes
;
}
return
memcmp
(
p1
,
p2
,
size
)
==
0
;
}
}
// todo refactor
// todo refactor
...
...
src/client/src/tscSecondaryMerge.c
浏览文件 @
03346d0c
...
@@ -319,9 +319,10 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
...
@@ -319,9 +319,10 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
pRes
->
pLocalReducer
=
pReducer
;
pRes
->
pLocalReducer
=
pReducer
;
pRes
->
numOfGroups
=
0
;
pRes
->
numOfGroups
=
0
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
int16_t
prec
=
pMeterMetaInfo
->
pMeterMeta
->
precision
;
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
)
;
int16_t
prec
=
tinfo
.
precision
;
int64_t
stime
=
(
pQueryInfo
->
stime
<
pQueryInfo
->
etime
)
?
pQueryInfo
->
stime
:
pQueryInfo
->
etime
;
int64_t
stime
=
(
pQueryInfo
->
stime
<
pQueryInfo
->
etime
)
?
pQueryInfo
->
stime
:
pQueryInfo
->
etime
;
int64_t
revisedSTime
=
int64_t
revisedSTime
=
taosGetIntervalStartTimestamp
(
stime
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
intervalTimeUnit
,
prec
);
taosGetIntervalStartTimestamp
(
stime
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
intervalTimeUnit
,
prec
);
...
@@ -602,9 +603,9 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
...
@@ -602,9 +603,9 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
*
pFinalModel
=
NULL
;
*
pFinalModel
=
NULL
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
(
*
pMemBuffer
)
=
(
tExtMemBuffer
**
)
malloc
(
POINTER_BYTES
*
p
Meter
MetaInfo
->
pMetricMeta
->
numOfVnodes
);
(
*
pMemBuffer
)
=
(
tExtMemBuffer
**
)
malloc
(
POINTER_BYTES
*
p
Table
MetaInfo
->
pMetricMeta
->
numOfVnodes
);
if
(
*
pMemBuffer
==
NULL
)
{
if
(
*
pMemBuffer
==
NULL
)
{
tscError
(
"%p failed to allocate memory"
,
pSql
);
tscError
(
"%p failed to allocate memory"
,
pSql
);
pRes
->
code
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
pRes
->
code
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
...
@@ -635,7 +636,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
...
@@ -635,7 +636,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
pModel
=
createColumnModel
(
pSchema
,
pQueryInfo
->
exprsInfo
.
numOfExprs
,
capacity
);
pModel
=
createColumnModel
(
pSchema
,
pQueryInfo
->
exprsInfo
.
numOfExprs
,
capacity
);
for
(
int32_t
i
=
0
;
i
<
p
Meter
MetaInfo
->
pMetricMeta
->
numOfVnodes
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
p
Table
MetaInfo
->
pMetricMeta
->
numOfVnodes
;
++
i
)
{
(
*
pMemBuffer
)[
i
]
=
createExtMemBuffer
(
nBufferSizes
,
rlen
,
pModel
);
(
*
pMemBuffer
)[
i
]
=
createExtMemBuffer
(
nBufferSizes
,
rlen
,
pModel
);
(
*
pMemBuffer
)[
i
]
->
flushModel
=
MULTIPLE_APPEND_MODEL
;
(
*
pMemBuffer
)[
i
]
->
flushModel
=
MULTIPLE_APPEND_MODEL
;
}
}
...
@@ -650,7 +651,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
...
@@ -650,7 +651,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
SSchema
*
p1
=
ts
GetColumnSchema
(
pMeterMetaInfo
->
pMeter
Meta
,
pExpr
->
colInfo
.
colIdx
);
SSchema
*
p1
=
ts
cGetTableColumnSchema
(
pTableMetaInfo
->
pTable
Meta
,
pExpr
->
colInfo
.
colIdx
);
int16_t
inter
=
0
;
int16_t
inter
=
0
;
int16_t
type
=
-
1
;
int16_t
type
=
-
1
;
...
@@ -774,9 +775,11 @@ void adjustLoserTreeFromNewData(SLocalReducer *pLocalReducer, SLocalDataSource *
...
@@ -774,9 +775,11 @@ void adjustLoserTreeFromNewData(SLocalReducer *pLocalReducer, SLocalDataSource *
void
savePrevRecordAndSetupInterpoInfo
(
SLocalReducer
*
pLocalReducer
,
SQueryInfo
*
pQueryInfo
,
void
savePrevRecordAndSetupInterpoInfo
(
SLocalReducer
*
pLocalReducer
,
SQueryInfo
*
pQueryInfo
,
SInterpolationInfo
*
pInterpoInfo
)
{
SInterpolationInfo
*
pInterpoInfo
)
{
// discard following dataset in the same group and reset the interpolation information
// discard following dataset in the same group and reset the interpolation information
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
int16_t
prec
=
pMeterMetaInfo
->
pMeterMeta
->
precision
;
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
int16_t
prec
=
tinfo
.
precision
;
int64_t
stime
=
(
pQueryInfo
->
stime
<
pQueryInfo
->
etime
)
?
pQueryInfo
->
stime
:
pQueryInfo
->
etime
;
int64_t
stime
=
(
pQueryInfo
->
stime
<
pQueryInfo
->
etime
)
?
pQueryInfo
->
stime
:
pQueryInfo
->
etime
;
int64_t
revisedSTime
=
int64_t
revisedSTime
=
taosGetIntervalStartTimestamp
(
stime
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
intervalTimeUnit
,
prec
);
taosGetIntervalStartTimestamp
(
stime
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
intervalTimeUnit
,
prec
);
...
@@ -917,8 +920,10 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
...
@@ -917,8 +920,10 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
functions
[
i
]
=
tscSqlExprGet
(
pQueryInfo
,
i
)
->
functionId
;
functions
[
i
]
=
tscSqlExprGet
(
pQueryInfo
,
i
)
->
functionId
;
}
}
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
int8_t
precision
=
pMeterMetaInfo
->
pMeterMeta
->
precision
;
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
int8_t
precision
=
tinfo
.
precision
;
while
(
1
)
{
while
(
1
)
{
int32_t
remains
=
taosNumOfRemainPoints
(
pInterpoInfo
);
int32_t
remains
=
taosNumOfRemainPoints
(
pInterpoInfo
);
...
@@ -1268,8 +1273,10 @@ static void resetEnvForNewResultset(SSqlRes *pRes, SSqlCmd *pCmd, SLocalReducer
...
@@ -1268,8 +1273,10 @@ static void resetEnvForNewResultset(SSqlRes *pRes, SSqlCmd *pCmd, SLocalReducer
pQueryInfo
->
limit
.
offset
=
pLocalReducer
->
offset
;
pQueryInfo
->
limit
.
offset
=
pLocalReducer
->
offset
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
int16_t
precision
=
pMeterMetaInfo
->
pMeterMeta
->
precision
;
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
int8_t
precision
=
tinfo
.
precision
;
// for group result interpolation, do not return if not data is generated
// for group result interpolation, do not return if not data is generated
if
(
pQueryInfo
->
interpoType
!=
TSDB_INTERPO_NONE
)
{
if
(
pQueryInfo
->
interpoType
!=
TSDB_INTERPO_NONE
)
{
...
@@ -1294,8 +1301,10 @@ static bool doInterpolationForCurrentGroup(SSqlObj *pSql) {
...
@@ -1294,8 +1301,10 @@ static bool doInterpolationForCurrentGroup(SSqlObj *pSql) {
SLocalReducer
*
pLocalReducer
=
pRes
->
pLocalReducer
;
SLocalReducer
*
pLocalReducer
=
pRes
->
pLocalReducer
;
SInterpolationInfo
*
pInterpoInfo
=
&
pLocalReducer
->
interpolationInfo
;
SInterpolationInfo
*
pInterpoInfo
=
&
pLocalReducer
->
interpolationInfo
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
int8_t
p
=
pMeterMetaInfo
->
pMeterMeta
->
precision
;
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
int8_t
p
=
tinfo
.
precision
;
if
(
taosHasRemainsDataForInterpolation
(
pInterpoInfo
))
{
if
(
taosHasRemainsDataForInterpolation
(
pInterpoInfo
))
{
assert
(
pQueryInfo
->
interpoType
!=
TSDB_INTERPO_NONE
);
assert
(
pQueryInfo
->
interpoType
!=
TSDB_INTERPO_NONE
);
...
@@ -1328,8 +1337,10 @@ static bool doHandleLastRemainData(SSqlObj *pSql) {
...
@@ -1328,8 +1337,10 @@ static bool doHandleLastRemainData(SSqlObj *pSql) {
bool
prevGroupCompleted
=
(
!
pLocalReducer
->
discard
)
&&
pLocalReducer
->
hasUnprocessedRow
;
bool
prevGroupCompleted
=
(
!
pLocalReducer
->
discard
)
&&
pLocalReducer
->
hasUnprocessedRow
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
int8_t
precision
=
pMeterMetaInfo
->
pMeterMeta
->
precision
;
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
int8_t
precision
=
tinfo
.
precision
;
if
((
isAllSourcesCompleted
(
pLocalReducer
)
&&
!
pLocalReducer
->
hasPrevRow
)
||
pLocalReducer
->
pLocalDataSrc
[
0
]
==
NULL
||
if
((
isAllSourcesCompleted
(
pLocalReducer
)
&&
!
pLocalReducer
->
hasPrevRow
)
||
pLocalReducer
->
pLocalDataSrc
[
0
]
==
NULL
||
prevGroupCompleted
)
{
prevGroupCompleted
)
{
...
...
src/client/src/tscServer.c
浏览文件 @
03346d0c
...
@@ -236,7 +236,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg) {
...
@@ -236,7 +236,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg) {
if
(
rpcMsg
->
pCont
==
NULL
)
{
if
(
rpcMsg
->
pCont
==
NULL
)
{
rpcMsg
->
code
=
TSDB_CODE_NETWORK_UNAVAIL
;
rpcMsg
->
code
=
TSDB_CODE_NETWORK_UNAVAIL
;
}
else
{
}
else
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
if
(
rpcMsg
->
code
==
TSDB_CODE_NOT_ACTIVE_TABLE
||
rpcMsg
->
code
==
TSDB_CODE_INVALID_TABLE_ID
||
if
(
rpcMsg
->
code
==
TSDB_CODE_NOT_ACTIVE_TABLE
||
rpcMsg
->
code
==
TSDB_CODE_INVALID_TABLE_ID
||
rpcMsg
->
code
==
TSDB_CODE_INVALID_VNODE_ID
||
rpcMsg
->
code
==
TSDB_CODE_NOT_ACTIVE_VNODE
||
rpcMsg
->
code
==
TSDB_CODE_INVALID_VNODE_ID
||
rpcMsg
->
code
==
TSDB_CODE_NOT_ACTIVE_VNODE
||
rpcMsg
->
code
==
TSDB_CODE_NETWORK_UNAVAIL
||
rpcMsg
->
code
==
TSDB_CODE_NOT_ACTIVE_SESSION
||
rpcMsg
->
code
==
TSDB_CODE_NETWORK_UNAVAIL
||
rpcMsg
->
code
==
TSDB_CODE_NOT_ACTIVE_SESSION
||
...
@@ -265,9 +265,9 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg) {
...
@@ -265,9 +265,9 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg) {
pSql
->
maxRetry
=
TSDB_VNODES_SUPPORT
*
2
;
pSql
->
maxRetry
=
TSDB_VNODES_SUPPORT
*
2
;
pSql
->
res
.
code
=
rpcMsg
->
code
;
// keep the previous error code
pSql
->
res
.
code
=
rpcMsg
->
code
;
// keep the previous error code
rpcMsg
->
code
=
tscRenewMeterMeta
(
pSql
,
p
Meter
MetaInfo
->
name
);
rpcMsg
->
code
=
tscRenewMeterMeta
(
pSql
,
p
Table
MetaInfo
->
name
);
if
(
p
MeterMetaInfo
->
pMeter
Meta
)
{
if
(
p
TableMetaInfo
->
pTable
Meta
)
{
tscSendMsgToServer
(
pSql
);
tscSendMsgToServer
(
pSql
);
rpcFreeCont
(
rpcMsg
->
pCont
);
rpcFreeCont
(
rpcMsg
->
pCont
);
return
;
return
;
...
@@ -436,8 +436,8 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSubquerySu
...
@@ -436,8 +436,8 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSubquerySu
// set the tags value for ts_comp function
// set the tags value for ts_comp function
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pNewQueryInfo
,
0
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pNewQueryInfo
,
0
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pNewQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pNewQueryInfo
,
0
);
int16_t
tagColIndex
=
tscGetJoinTagColIndexByUid
(
&
pSupporter
->
tagCond
,
p
MeterMetaInfo
->
pMeter
Meta
->
uid
);
int16_t
tagColIndex
=
tscGetJoinTagColIndexByUid
(
&
pSupporter
->
tagCond
,
p
TableMetaInfo
->
pTable
Meta
->
uid
);
pExpr
->
param
->
i64Key
=
tagColIndex
;
pExpr
->
param
->
i64Key
=
tagColIndex
;
pExpr
->
numOfParams
=
1
;
pExpr
->
numOfParams
=
1
;
...
@@ -453,14 +453,14 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSubquerySu
...
@@ -453,14 +453,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, "
tscTrace
(
"%p subquery:%p tableIndex:%d, vnodeIdx:%d, type:%d, transfer to ts_comp query to retrieve timestamps, "
"exprInfo:%d, colList:%d, fieldsInfo:%d, name:%s"
,
"exprInfo:%d, colList:%d, fieldsInfo:%d, name:%s"
,
pSql
,
pNew
,
tableIndex
,
p
Meter
MetaInfo
->
vnodeIndex
,
pNewQueryInfo
->
type
,
pSql
,
pNew
,
tableIndex
,
p
Table
MetaInfo
->
vnodeIndex
,
pNewQueryInfo
->
type
,
pNewQueryInfo
->
exprsInfo
.
numOfExprs
,
pNewQueryInfo
->
colList
.
numOfCols
,
pNewQueryInfo
->
exprsInfo
.
numOfExprs
,
pNewQueryInfo
->
colList
.
numOfCols
,
pNewQueryInfo
->
fieldsInfo
.
numOfOutputCols
,
pNewQueryInfo
->
pMeterInfo
[
0
]
->
name
);
pNewQueryInfo
->
fieldsInfo
.
numOfOutputCols
,
pNewQueryInfo
->
pMeterInfo
[
0
]
->
name
);
tscPrintSelectClause
(
pNew
,
0
);
tscPrintSelectClause
(
pNew
,
0
);
tscTrace
(
"%p subquery:%p tableIndex:%d, vnodeIdx:%d, type:%d, transfer to ts_comp query to retrieve timestamps, "
tscTrace
(
"%p subquery:%p tableIndex:%d, vnodeIdx:%d, type:%d, transfer to ts_comp query to retrieve timestamps, "
"exprInfo:%d, colList:%d, fieldsInfo:%d, name:%s"
,
"exprInfo:%d, colList:%d, fieldsInfo:%d, name:%s"
,
pSql
,
pNew
,
tableIndex
,
p
Meter
MetaInfo
->
vnodeIndex
,
pNewQueryInfo
->
type
,
pSql
,
pNew
,
tableIndex
,
p
Table
MetaInfo
->
vnodeIndex
,
pNewQueryInfo
->
type
,
pNewQueryInfo
->
exprsInfo
.
numOfExprs
,
pNewQueryInfo
->
colList
.
numOfCols
,
pNewQueryInfo
->
exprsInfo
.
numOfExprs
,
pNewQueryInfo
->
colList
.
numOfCols
,
pNewQueryInfo
->
fieldsInfo
.
numOfOutputCols
,
pNewQueryInfo
->
pMeterInfo
[
0
]
->
name
);
pNewQueryInfo
->
fieldsInfo
.
numOfOutputCols
,
pNewQueryInfo
->
pMeterInfo
[
0
]
->
name
);
tscPrintSelectClause
(
pNew
,
0
);
tscPrintSelectClause
(
pNew
,
0
);
...
@@ -517,13 +517,13 @@ int tscProcessSql(SSqlObj *pSql) {
...
@@ -517,13 +517,13 @@ int tscProcessSql(SSqlObj *pSql) {
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
NULL
;
S
TableMetaInfo
*
pTable
MetaInfo
=
NULL
;
int16_t
type
=
0
;
int16_t
type
=
0
;
if
(
pQueryInfo
!=
NULL
)
{
if
(
pQueryInfo
!=
NULL
)
{
p
Meter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
p
Table
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
if
(
p
Meter
MetaInfo
!=
NULL
)
{
if
(
p
Table
MetaInfo
!=
NULL
)
{
name
=
p
Meter
MetaInfo
->
name
;
name
=
p
Table
MetaInfo
->
name
;
}
}
type
=
pQueryInfo
->
type
;
type
=
pQueryInfo
->
type
;
...
@@ -534,21 +534,21 @@ int tscProcessSql(SSqlObj *pSql) {
...
@@ -534,21 +534,21 @@ int tscProcessSql(SSqlObj *pSql) {
tscTrace
(
"%p SQL cmd:%d will be processed, name:%s, type:%d"
,
pSql
,
pCmd
->
command
,
name
,
type
);
tscTrace
(
"%p SQL cmd:%d will be processed, name:%s, type:%d"
,
pSql
,
pCmd
->
command
,
name
,
type
);
if
(
pSql
->
cmd
.
command
<
TSDB_SQL_MGMT
)
{
if
(
pSql
->
cmd
.
command
<
TSDB_SQL_MGMT
)
{
// the p
Meter
MetaInfo cannot be NULL
// the p
Table
MetaInfo cannot be NULL
if
(
p
Meter
MetaInfo
==
NULL
)
{
if
(
p
Table
MetaInfo
==
NULL
)
{
pSql
->
res
.
code
=
TSDB_CODE_OTHERS
;
pSql
->
res
.
code
=
TSDB_CODE_OTHERS
;
return
pSql
->
res
.
code
;
return
pSql
->
res
.
code
;
}
}
// temp
// temp
pSql
->
ipList
=
&
tscMgmtIpList
;
pSql
->
ipList
=
&
tscMgmtIpList
;
// if (UTIL_METER_IS_NOMRAL_METER(p
Meter
MetaInfo)) {
// if (UTIL_METER_IS_NOMRAL_METER(p
Table
MetaInfo)) {
// pSql->index = p
MeterMetaInfo->pMeter
Meta->index;
// pSql->index = p
TableMetaInfo->pTable
Meta->index;
// } else { // it must be the parent SSqlObj for super table query
// } else { // it must be the parent SSqlObj for super table query
// if ((pQueryInfo->type & TSDB_QUERY_TYPE_SUBQUERY) != 0) {
// if ((pQueryInfo->type & TSDB_QUERY_TYPE_SUBQUERY) != 0) {
// int32_t idx = p
Meter
MetaInfo->vnodeIndex;
// int32_t idx = p
Table
MetaInfo->vnodeIndex;
//
//
// SVnodeSidList *pSidList = tscGetVnodeSidList(p
Meter
MetaInfo->pMetricMeta, idx);
// SVnodeSidList *pSidList = tscGetVnodeSidList(p
Table
MetaInfo->pMetricMeta, idx);
// pSql->index = pSidList->index;
// pSql->index = pSidList->index;
// }
// }
// }
// }
...
@@ -668,8 +668,8 @@ int tscLaunchSTableSubqueries(SSqlObj *pSql) {
...
@@ -668,8 +668,8 @@ int tscLaunchSTableSubqueries(SSqlObj *pSql) {
const
uint32_t
nBufferSize
=
(
1
<<
16
);
// 64KB
const
uint32_t
nBufferSize
=
(
1
<<
16
);
// 64KB
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
int32_t
numOfSubQueries
=
p
Meter
MetaInfo
->
pMetricMeta
->
numOfVnodes
;
int32_t
numOfSubQueries
=
p
Table
MetaInfo
->
pMetricMeta
->
numOfVnodes
;
assert
(
numOfSubQueries
>
0
);
assert
(
numOfSubQueries
>
0
);
int32_t
ret
=
tscLocalReducerEnvCreate
(
pSql
,
&
pMemoryBuf
,
&
pDesc
,
&
pModel
,
nBufferSize
);
int32_t
ret
=
tscLocalReducerEnvCreate
(
pSql
,
&
pMemoryBuf
,
&
pDesc
,
&
pModel
,
nBufferSize
);
...
@@ -929,9 +929,9 @@ void tscRetrieveFromVnodeCallBack(void *param, TAOS_RES *tres, int numOfRows) {
...
@@ -929,9 +929,9 @@ void tscRetrieveFromVnodeCallBack(void *param, TAOS_RES *tres, int numOfRows) {
SSqlRes
*
pRes
=
&
pSql
->
res
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
SVnodeSidList
*
vnodeInfo
=
tscGetVnodeSidList
(
p
Meter
MetaInfo
->
pMetricMeta
,
idx
);
SVnodeSidList
*
vnodeInfo
=
tscGetVnodeSidList
(
p
Table
MetaInfo
->
pMetricMeta
,
idx
);
SVnodeDesc
*
pSvd
=
&
vnodeInfo
->
vpeerDesc
[
vnodeInfo
->
index
];
SVnodeDesc
*
pSvd
=
&
vnodeInfo
->
vpeerDesc
[
vnodeInfo
->
index
];
if
(
numOfRows
>
0
)
{
if
(
numOfRows
>
0
)
{
...
@@ -1110,8 +1110,8 @@ static SSqlObj *tscCreateSqlObjForSubquery(SSqlObj *pSql, SRetrieveSupport *trsu
...
@@ -1110,8 +1110,8 @@ static SSqlObj *tscCreateSqlObjForSubquery(SSqlObj *pSql, SRetrieveSupport *trsu
assert
(
pQueryInfo
->
numOfTables
==
1
&&
pNew
->
cmd
.
numOfClause
==
1
);
assert
(
pQueryInfo
->
numOfTables
==
1
&&
pNew
->
cmd
.
numOfClause
==
1
);
// launch subquery for each vnode, so the subquery index equals to the vnodeIndex.
// launch subquery for each vnode, so the subquery index equals to the vnodeIndex.
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
table_index
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
table_index
);
p
Meter
MetaInfo
->
vnodeIndex
=
trsupport
->
subqueryIndex
;
p
Table
MetaInfo
->
vnodeIndex
=
trsupport
->
subqueryIndex
;
pSql
->
pSubs
[
trsupport
->
subqueryIndex
]
=
pNew
;
pSql
->
pSubs
[
trsupport
->
subqueryIndex
]
=
pNew
;
}
}
...
@@ -1125,15 +1125,15 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
...
@@ -1125,15 +1125,15 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
SSqlObj
*
pParentSql
=
trsupport
->
pParentSqlObj
;
SSqlObj
*
pParentSql
=
trsupport
->
pParentSqlObj
;
SSqlObj
*
pSql
=
(
SSqlObj
*
)
tres
;
SSqlObj
*
pSql
=
(
SSqlObj
*
)
tres
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
);
assert
(
pSql
->
cmd
.
numOfClause
==
1
&&
pSql
->
cmd
.
pQueryInfo
[
0
]
->
numOfTables
==
1
);
assert
(
pSql
->
cmd
.
numOfClause
==
1
&&
pSql
->
cmd
.
pQueryInfo
[
0
]
->
numOfTables
==
1
);
int32_t
idx
=
p
Meter
MetaInfo
->
vnodeIndex
;
int32_t
idx
=
p
Table
MetaInfo
->
vnodeIndex
;
SVnodeSidList
*
vnodeInfo
=
NULL
;
SVnodeSidList
*
vnodeInfo
=
NULL
;
SVnodeDesc
*
pSvd
=
NULL
;
SVnodeDesc
*
pSvd
=
NULL
;
if
(
p
Meter
MetaInfo
->
pMetricMeta
!=
NULL
)
{
if
(
p
Table
MetaInfo
->
pMetricMeta
!=
NULL
)
{
vnodeInfo
=
tscGetVnodeSidList
(
p
Meter
MetaInfo
->
pMetricMeta
,
idx
);
vnodeInfo
=
tscGetVnodeSidList
(
p
Table
MetaInfo
->
pMetricMeta
,
idx
);
pSvd
=
&
vnodeInfo
->
vpeerDesc
[
vnodeInfo
->
index
];
pSvd
=
&
vnodeInfo
->
vpeerDesc
[
vnodeInfo
->
index
];
}
}
...
@@ -1176,7 +1176,7 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
...
@@ -1176,7 +1176,7 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
trsupport
->
numOfRetry
=
MAX_NUM_OF_SUBQUERY_RETRY
;
trsupport
->
numOfRetry
=
MAX_NUM_OF_SUBQUERY_RETRY
;
}
else
{
}
else
{
SQueryInfo
*
pNewQueryInfo
=
tscGetQueryInfoDetail
(
&
pNew
->
cmd
,
0
);
SQueryInfo
*
pNewQueryInfo
=
tscGetQueryInfoDetail
(
&
pNew
->
cmd
,
0
);
assert
(
pNewQueryInfo
->
pMeterInfo
[
0
]
->
p
Meter
Meta
!=
NULL
&&
pNewQueryInfo
->
pMeterInfo
[
0
]
->
pMetricMeta
!=
NULL
);
assert
(
pNewQueryInfo
->
pMeterInfo
[
0
]
->
p
Table
Meta
!=
NULL
&&
pNewQueryInfo
->
pMeterInfo
[
0
]
->
pMetricMeta
!=
NULL
);
tscProcessSql
(
pNew
);
tscProcessSql
(
pNew
);
return
;
return
;
}
}
...
@@ -1231,16 +1231,16 @@ int tscBuildRetrieveMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1231,16 +1231,16 @@ int tscBuildRetrieveMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
void
tscUpdateVnodeInSubmitMsg
(
SSqlObj
*
pSql
,
char
*
buf
)
{
void
tscUpdateVnodeInSubmitMsg
(
SSqlObj
*
pSql
,
char
*
buf
)
{
//SShellSubmitMsg *pShellMsg;
//SShellSubmitMsg *pShellMsg;
//char * pMsg;
//char * pMsg;
//S
MeterMetaInfo * pMeter
MetaInfo = tscGetMeterMetaInfo(&pSql->cmd, pSql->cmd.clauseIndex, 0);
//S
TableMetaInfo * pTable
MetaInfo = tscGetMeterMetaInfo(&pSql->cmd, pSql->cmd.clauseIndex, 0);
//STableMeta *p
MeterMeta = pMeterMetaInfo->pMeter
Meta;
//STableMeta *p
TableMeta = pTableMetaInfo->pTable
Meta;
//pMsg = buf + tsRpcHeadSize;
//pMsg = buf + tsRpcHeadSize;
//TODO set iplist
//TODO set iplist
//pShellMsg = (SShellSubmitMsg *)pMsg;
//pShellMsg = (SShellSubmitMsg *)pMsg;
//pShellMsg->vnode = htons(p
Meter
Meta->vpeerDesc[pSql->index].vnode);
//pShellMsg->vnode = htons(p
Table
Meta->vpeerDesc[pSql->index].vnode);
//tscTrace("%p update submit msg vnode:%s:%d", pSql, taosIpStr(p
Meter
Meta->vpeerDesc[pSql->index].ip),
//tscTrace("%p update submit msg vnode:%s:%d", pSql, taosIpStr(p
Table
Meta->vpeerDesc[pSql->index].ip),
// htons(pShellMsg->vnode));
// htons(pShellMsg->vnode));
}
}
...
@@ -1248,10 +1248,7 @@ int tscBuildSubmitMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1248,10 +1248,7 @@ int tscBuildSubmitMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SShellSubmitMsg
*
pShellMsg
;
SShellSubmitMsg
*
pShellMsg
;
char
*
pMsg
,
*
pStart
;
char
*
pMsg
,
*
pStart
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
STableMeta
*
pMeterMeta
=
pMeterMetaInfo
->
pMeterMeta
;
pStart
=
pSql
->
cmd
.
payload
+
tsRpcHeadSize
;
pStart
=
pSql
->
cmd
.
payload
+
tsRpcHeadSize
;
pMsg
=
pStart
;
pMsg
=
pStart
;
...
@@ -1259,13 +1256,13 @@ int tscBuildSubmitMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1259,13 +1256,13 @@ int tscBuildSubmitMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pShellMsg
=
(
SShellSubmitMsg
*
)
pMsg
;
pShellMsg
=
(
SShellSubmitMsg
*
)
pMsg
;
pShellMsg
->
import
=
htons
(
TSDB_QUERY_HAS_TYPE
(
pQueryInfo
->
type
,
TSDB_QUERY_TYPE_INSERT
)
?
0
:
1
);
pShellMsg
->
import
=
htons
(
TSDB_QUERY_HAS_TYPE
(
pQueryInfo
->
type
,
TSDB_QUERY_TYPE_INSERT
)
?
0
:
1
);
pShellMsg
->
vnode
=
0
;
//htons(p
MeterMeta->vpeerDesc[pMeter
Meta->index].vnode);
pShellMsg
->
vnode
=
0
;
//htons(p
TableMeta->vpeerDesc[pTable
Meta->index].vnode);
pShellMsg
->
numOfSid
=
htonl
(
pSql
->
cmd
.
numOfTablesInSubmit
);
// number of meters to be inserted
pShellMsg
->
numOfSid
=
htonl
(
pSql
->
cmd
.
numOfTablesInSubmit
);
// number of meters to be inserted
// pSql->cmd.payloadLen is set during parse sql routine, so we do not use it here
// pSql->cmd.payloadLen is set during parse sql routine, so we do not use it here
pSql
->
cmd
.
msgType
=
TSDB_MSG_TYPE_SUBMIT
;
pSql
->
cmd
.
msgType
=
TSDB_MSG_TYPE_SUBMIT
;
tscTrace
(
"%p update submit msg vnode:%s:%d"
,
pSql
,
taosIpStr
(
pMeterMeta
->
vpeerDesc
[
pMeter
Meta
->
index
].
ip
),
// tscTrace("%p update submit msg vnode:%s:%d", pSql, taosIpStr(pTableMeta->vpeerDesc[pTable
Meta->index].ip),
htons
(
pShellMsg
->
vnode
));
//
htons(pShellMsg->vnode));
pSql
->
cmd
.
payloadLen
=
sizeof
(
SShellSubmitMsg
);
pSql
->
cmd
.
payloadLen
=
sizeof
(
SShellSubmitMsg
);
...
@@ -1275,17 +1272,17 @@ int tscBuildSubmitMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1275,17 +1272,17 @@ int tscBuildSubmitMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
void
tscUpdateVnodeInQueryMsg
(
SSqlObj
*
pSql
,
char
*
buf
)
{
void
tscUpdateVnodeInQueryMsg
(
SSqlObj
*
pSql
,
char
*
buf
)
{
//TODO
//TODO
// SSqlCmd * pCmd = &pSql->cmd;
// SSqlCmd * pCmd = &pSql->cmd;
// S
MeterMetaInfo *pMeter
MetaInfo = tscGetMeterMetaInfo(pCmd, pCmd->clauseIndex, 0);
// S
TableMetaInfo *pTable
MetaInfo = tscGetMeterMetaInfo(pCmd, pCmd->clauseIndex, 0);
//
//
// char * pStart = buf + tsRpcHeadSize;
// char * pStart = buf + tsRpcHeadSize;
// SQueryTableMsg *pQueryMsg = (SQueryTableMsg *)pStart;
// SQueryTableMsg *pQueryMsg = (SQueryTableMsg *)pStart;
//
//
// if (UTIL_METER_IS_NOMRAL_METER(p
Meter
MetaInfo)) { // pColumnModel == NULL, query on meter
// if (UTIL_METER_IS_NOMRAL_METER(p
Table
MetaInfo)) { // pColumnModel == NULL, query on meter
// STableMeta *p
MeterMeta = pMeterMetaInfo->pMeter
Meta;
// STableMeta *p
TableMeta = pTableMetaInfo->pTable
Meta;
// pQueryMsg->vnode = htons(p
Meter
Meta->vpeerDesc[pSql->index].vnode);
// pQueryMsg->vnode = htons(p
Table
Meta->vpeerDesc[pSql->index].vnode);
// } else { // query on metric
// } else { // query on metric
// SSuperTableMeta * pMetricMeta = p
Meter
MetaInfo->pMetricMeta;
// SSuperTableMeta * pMetricMeta = p
Table
MetaInfo->pMetricMeta;
// SVnodeSidList *pVnodeSidList = tscGetVnodeSidList(pMetricMeta, p
Meter
MetaInfo->vnodeIndex);
// SVnodeSidList *pVnodeSidList = tscGetVnodeSidList(pMetricMeta, p
Table
MetaInfo->vnodeIndex);
// pQueryMsg->vnode = htons(pVnodeSidList->vpeerDesc[pSql->index].vnode);
// pQueryMsg->vnode = htons(pVnodeSidList->vpeerDesc[pSql->index].vnode);
// }
// }
}
}
...
@@ -1301,15 +1298,15 @@ static int32_t tscEstimateQueryMsgSize(SSqlCmd *pCmd, int32_t clauseIndex) {
...
@@ -1301,15 +1298,15 @@ static int32_t tscEstimateQueryMsgSize(SSqlCmd *pCmd, int32_t clauseIndex) {
int32_t
srcColListSize
=
pQueryInfo
->
colList
.
numOfCols
*
sizeof
(
SColumnInfo
);
int32_t
srcColListSize
=
pQueryInfo
->
colList
.
numOfCols
*
sizeof
(
SColumnInfo
);
int32_t
exprSize
=
sizeof
(
SSqlFuncExprMsg
)
*
pQueryInfo
->
exprsInfo
.
numOfExprs
;
int32_t
exprSize
=
sizeof
(
SSqlFuncExprMsg
)
*
pQueryInfo
->
exprsInfo
.
numOfExprs
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
// meter query without tags values
// meter query without tags values
if
(
!
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
))
{
if
(
!
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
))
{
return
MIN_QUERY_MSG_PKT_SIZE
+
minMsgSize
()
+
sizeof
(
SQueryTableMsg
)
+
srcColListSize
+
exprSize
;
return
MIN_QUERY_MSG_PKT_SIZE
+
minMsgSize
()
+
sizeof
(
SQueryTableMsg
)
+
srcColListSize
+
exprSize
;
}
}
SSuperTableMeta
*
pMetricMeta
=
p
Meter
MetaInfo
->
pMetricMeta
;
SSuperTableMeta
*
pMetricMeta
=
p
Table
MetaInfo
->
pMetricMeta
;
SVnodeSidList
*
pVnodeSidList
=
tscGetVnodeSidList
(
pMetricMeta
,
p
Meter
MetaInfo
->
vnodeIndex
);
SVnodeSidList
*
pVnodeSidList
=
tscGetVnodeSidList
(
pMetricMeta
,
p
Table
MetaInfo
->
vnodeIndex
);
int32_t
meterInfoSize
=
(
pMetricMeta
->
tagLen
+
sizeof
(
STableSidExtInfo
))
*
pVnodeSidList
->
numOfSids
;
int32_t
meterInfoSize
=
(
pMetricMeta
->
tagLen
+
sizeof
(
STableSidExtInfo
))
*
pVnodeSidList
->
numOfSids
;
int32_t
outputColumnSize
=
pQueryInfo
->
exprsInfo
.
numOfExprs
*
sizeof
(
SSqlFuncExprMsg
);
int32_t
outputColumnSize
=
pQueryInfo
->
exprsInfo
.
numOfExprs
*
sizeof
(
SSqlFuncExprMsg
);
...
@@ -1323,23 +1320,23 @@ static int32_t tscEstimateQueryMsgSize(SSqlCmd *pCmd, int32_t clauseIndex) {
...
@@ -1323,23 +1320,23 @@ static int32_t tscEstimateQueryMsgSize(SSqlCmd *pCmd, int32_t clauseIndex) {
}
}
static
char
*
doSerializeTableInfo
(
SSqlObj
*
pSql
,
int32_t
numOfTables
,
int32_t
vnodeId
,
char
*
pMsg
)
{
static
char
*
doSerializeTableInfo
(
SSqlObj
*
pSql
,
int32_t
numOfTables
,
int32_t
vnodeId
,
char
*
pMsg
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
pSql
->
cmd
.
clauseIndex
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
pSql
->
cmd
.
clauseIndex
,
0
);
STableMeta
*
p
MeterMeta
=
pMeterMetaInfo
->
pMeter
Meta
;
STableMeta
*
p
TableMeta
=
pTableMetaInfo
->
pTable
Meta
;
SSuperTableMeta
*
pMetricMeta
=
p
Meter
MetaInfo
->
pMetricMeta
;
SSuperTableMeta
*
pMetricMeta
=
p
Table
MetaInfo
->
pMetricMeta
;
tscTrace
(
"%p vid:%d, query on %d meters"
,
pSql
,
vnodeId
,
numOfTables
);
tscTrace
(
"%p vid:%d, query on %d meters"
,
pSql
,
vnodeId
,
numOfTables
);
if
(
UTIL_METER_IS_NOMRAL_METER
(
p
Meter
MetaInfo
))
{
if
(
UTIL_METER_IS_NOMRAL_METER
(
p
Table
MetaInfo
))
{
#ifdef _DEBUG_VIEW
#ifdef _DEBUG_VIEW
tscTrace
(
"%p sid:%d, uid:%"
PRIu64
,
pSql
,
p
MeterMetaInfo
->
pMeterMeta
->
sid
,
pMeterMetaInfo
->
pMeter
Meta
->
uid
);
tscTrace
(
"%p sid:%d, uid:%"
PRIu64
,
pSql
,
p
TableMetaInfo
->
pTableMeta
->
sid
,
pTableMetaInfo
->
pTable
Meta
->
uid
);
#endif
#endif
STableSidExtInfo
*
pMeterInfo
=
(
STableSidExtInfo
*
)
pMsg
;
STableSidExtInfo
*
pMeterInfo
=
(
STableSidExtInfo
*
)
pMsg
;
pMeterInfo
->
sid
=
htonl
(
p
Meter
Meta
->
sid
);
pMeterInfo
->
sid
=
htonl
(
p
Table
Meta
->
sid
);
pMeterInfo
->
uid
=
htobe64
(
p
Meter
Meta
->
uid
);
pMeterInfo
->
uid
=
htobe64
(
p
Table
Meta
->
uid
);
pMeterInfo
->
key
=
htobe64
(
tscGetSubscriptionProgress
(
pSql
->
pSubscription
,
p
Meter
Meta
->
uid
));
pMeterInfo
->
key
=
htobe64
(
tscGetSubscriptionProgress
(
pSql
->
pSubscription
,
p
Table
Meta
->
uid
));
pMsg
+=
sizeof
(
STableSidExtInfo
);
pMsg
+=
sizeof
(
STableSidExtInfo
);
}
else
{
}
else
{
SVnodeSidList
*
pVnodeSidList
=
tscGetVnodeSidList
(
pMetricMeta
,
p
Meter
MetaInfo
->
vnodeIndex
);
SVnodeSidList
*
pVnodeSidList
=
tscGetVnodeSidList
(
pMetricMeta
,
p
Table
MetaInfo
->
vnodeIndex
);
for
(
int32_t
i
=
0
;
i
<
numOfTables
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfTables
;
++
i
)
{
STableSidExtInfo
*
pMeterInfo
=
(
STableSidExtInfo
*
)
pMsg
;
STableSidExtInfo
*
pMeterInfo
=
(
STableSidExtInfo
*
)
pMsg
;
...
@@ -1374,34 +1371,34 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1374,34 +1371,34 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
char
*
pStart
=
pCmd
->
payload
+
tsRpcHeadSize
;
char
*
pStart
=
pCmd
->
payload
+
tsRpcHeadSize
;
STableMeta
*
p
MeterMeta
=
pMeterMetaInfo
->
pMeter
Meta
;
STableMeta
*
p
TableMeta
=
pTableMetaInfo
->
pTable
Meta
;
SSuperTableMeta
*
pMetricMeta
=
p
Meter
MetaInfo
->
pMetricMeta
;
SSuperTableMeta
*
pMetricMeta
=
p
Table
MetaInfo
->
pMetricMeta
;
SQueryTableMsg
*
pQueryMsg
=
(
SQueryTableMsg
*
)
pStart
;
SQueryTableMsg
*
pQueryMsg
=
(
SQueryTableMsg
*
)
pStart
;
int32_t
msgLen
=
0
;
int32_t
msgLen
=
0
;
int32_t
numOfTables
=
0
;
int32_t
numOfTables
=
0
;
if
(
UTIL_METER_IS_NOMRAL_METER
(
p
Meter
MetaInfo
))
{
if
(
UTIL_METER_IS_NOMRAL_METER
(
p
Table
MetaInfo
))
{
numOfTables
=
1
;
numOfTables
=
1
;
tscTrace
(
"%p query on vnode: %d, number of sid:%d, meter id: %s"
,
pSql
,
//
tscTrace("%p query on vnode: %d, number of sid:%d, meter id: %s", pSql,
pMeterMeta
->
vpeerDesc
[
pMeterMeta
->
index
].
vnode
,
1
,
pMeter
MetaInfo
->
name
);
// pTableMeta->vpeerDesc[pTableMeta->index].vnode, 1, pTable
MetaInfo->name);
pQueryMsg
->
vnode
=
htons
(
pMeterMeta
->
vpeerDesc
[
pMeter
Meta
->
index
].
vnode
);
// pQueryMsg->vnode = htons(pTableMeta->vpeerDesc[pTable
Meta->index].vnode);
pQueryMsg
->
uid
=
p
Meter
Meta
->
uid
;
pQueryMsg
->
uid
=
p
Table
Meta
->
uid
;
pQueryMsg
->
numOfTagsCols
=
0
;
pQueryMsg
->
numOfTagsCols
=
0
;
}
else
{
// query on super table
}
else
{
// query on super table
if
(
p
Meter
MetaInfo
->
vnodeIndex
<
0
)
{
if
(
p
Table
MetaInfo
->
vnodeIndex
<
0
)
{
tscError
(
"%p error vnodeIdx:%d"
,
pSql
,
p
Meter
MetaInfo
->
vnodeIndex
);
tscError
(
"%p error vnodeIdx:%d"
,
pSql
,
p
Table
MetaInfo
->
vnodeIndex
);
return
-
1
;
return
-
1
;
}
}
SVnodeSidList
*
pVnodeSidList
=
tscGetVnodeSidList
(
pMetricMeta
,
p
Meter
MetaInfo
->
vnodeIndex
);
SVnodeSidList
*
pVnodeSidList
=
tscGetVnodeSidList
(
pMetricMeta
,
p
Table
MetaInfo
->
vnodeIndex
);
uint32_t
vnodeId
=
pVnodeSidList
->
vpeerDesc
[
pVnodeSidList
->
index
].
vnode
;
uint32_t
vnodeId
=
pVnodeSidList
->
vpeerDesc
[
pVnodeSidList
->
index
].
vnode
;
numOfTables
=
pVnodeSidList
->
numOfSids
;
numOfTables
=
pVnodeSidList
->
numOfSids
;
...
@@ -1415,7 +1412,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1415,7 +1412,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
}
pQueryMsg
->
numOfSids
=
htonl
(
numOfTables
);
pQueryMsg
->
numOfSids
=
htonl
(
numOfTables
);
pQueryMsg
->
numOfTagsCols
=
htons
(
p
Meter
MetaInfo
->
numOfTags
);
pQueryMsg
->
numOfTagsCols
=
htons
(
p
Table
MetaInfo
->
numOfTags
);
if
(
pQueryInfo
->
order
.
order
==
TSQL_SO_ASC
)
{
if
(
pQueryInfo
->
order
.
order
==
TSQL_SO_ASC
)
{
pQueryMsg
->
skey
=
htobe64
(
pQueryInfo
->
stime
);
pQueryMsg
->
skey
=
htobe64
(
pQueryInfo
->
stime
);
...
@@ -1436,12 +1433,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1436,12 +1433,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pQueryMsg
->
numOfCols
=
htons
(
pQueryInfo
->
colList
.
numOfCols
);
pQueryMsg
->
numOfCols
=
htons
(
pQueryInfo
->
colList
.
numOfCols
);
if
(
pQueryInfo
->
colList
.
numOfCols
<=
0
)
{
if
(
pQueryInfo
->
colList
.
numOfCols
<=
0
)
{
tscError
(
"%p illegal value of numOfCols in query msg: %d"
,
pSql
,
pMeterMeta
->
numOfColumns
);
tscError
(
"%p illegal value of numOfCols in query msg: %d"
,
pSql
,
tscGetNumOfColumns
(
pTableMeta
));
return
-
1
;
}
if
(
pMeterMeta
->
numOfTags
<
0
)
{
tscError
(
"%p illegal value of numOfTagsCols in query msg: %d"
,
pSql
,
pMeterMeta
->
numOfTags
);
return
-
1
;
return
-
1
;
}
}
...
@@ -1461,7 +1453,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1461,7 +1453,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pQueryMsg
->
numOfGroupCols
=
htons
(
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
);
pQueryMsg
->
numOfGroupCols
=
htons
(
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
);
if
(
UTIL_METER_IS_NOMRAL_METER
(
p
Meter
MetaInfo
))
{
// query on meter
if
(
UTIL_METER_IS_NOMRAL_METER
(
p
Table
MetaInfo
))
{
// query on meter
pQueryMsg
->
tagLength
=
0
;
pQueryMsg
->
tagLength
=
0
;
}
else
{
// query on metric
}
else
{
// query on metric
pQueryMsg
->
tagLength
=
htons
(
pMetricMeta
->
tagLen
);
pQueryMsg
->
tagLength
=
htons
(
pMetricMeta
->
tagLen
);
...
@@ -1478,16 +1470,16 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1478,16 +1470,16 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
// set column list ids
// set column list ids
char
*
pMsg
=
(
char
*
)(
pQueryMsg
->
colList
)
+
pQueryInfo
->
colList
.
numOfCols
*
sizeof
(
SColumnInfo
);
char
*
pMsg
=
(
char
*
)(
pQueryMsg
->
colList
)
+
pQueryInfo
->
colList
.
numOfCols
*
sizeof
(
SColumnInfo
);
SSchema
*
pSchema
=
ts
GetSchema
(
pMeter
Meta
);
SSchema
*
pSchema
=
ts
cGetTableSchema
(
pTable
Meta
);
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
colList
.
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
colList
.
numOfCols
;
++
i
)
{
SColumnBase
*
pCol
=
tscColumnBaseInfoGet
(
&
pQueryInfo
->
colList
,
i
);
SColumnBase
*
pCol
=
tscColumnBaseInfoGet
(
&
pQueryInfo
->
colList
,
i
);
SSchema
*
pColSchema
=
&
pSchema
[
pCol
->
colIndex
.
columnIndex
];
SSchema
*
pColSchema
=
&
pSchema
[
pCol
->
colIndex
.
columnIndex
];
if
(
pCol
->
colIndex
.
columnIndex
>=
pMeterMeta
->
numOfColumns
||
pColSchema
->
type
<
TSDB_DATA_TYPE_BOOL
||
if
(
pCol
->
colIndex
.
columnIndex
>=
tscGetNumOfColumns
(
pTableMeta
)
||
pColSchema
->
type
<
TSDB_DATA_TYPE_BOOL
||
pColSchema
->
type
>
TSDB_DATA_TYPE_NCHAR
)
{
pColSchema
->
type
>
TSDB_DATA_TYPE_NCHAR
)
{
tscError
(
"%p vid:%d sid:%d id:%s, column index out of range, numOfColumns:%d, index:%d, column name:%s"
,
pSql
,
tscError
(
"%p vid:%d sid:%d id:%s, column index out of range, numOfColumns:%d, index:%d, column name:%s"
,
pSql
,
htons
(
pQueryMsg
->
vnode
),
p
MeterMeta
->
sid
,
pMeterMetaInfo
->
name
,
pMeterMeta
->
numOfColumns
,
pCol
->
colIndex
,
htons
(
pQueryMsg
->
vnode
),
p
TableMeta
->
sid
,
pTableMetaInfo
->
name
,
tscGetNumOfColumns
(
pTableMeta
)
,
pCol
->
colIndex
,
pColSchema
->
name
);
pColSchema
->
name
);
return
-
1
;
// 0 means build msg failed
return
-
1
;
// 0 means build msg failed
...
@@ -1537,7 +1529,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1537,7 +1529,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
hasArithmeticFunction
=
true
;
hasArithmeticFunction
=
true
;
}
}
if
(
!
tscValidateColumnId
(
p
Meter
MetaInfo
,
pExpr
->
colInfo
.
colId
))
{
if
(
!
tscValidateColumnId
(
p
Table
MetaInfo
,
pExpr
->
colInfo
.
colId
))
{
/* column id is not valid according to the cached metermeta, the meter meta is expired */
/* column id is not valid according to the cached metermeta, the meter meta is expired */
tscError
(
"%p table schema is not matched with parsed sql"
,
pSql
);
tscError
(
"%p table schema is not matched with parsed sql"
,
pSql
);
return
-
1
;
return
-
1
;
...
@@ -1588,17 +1580,17 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1588,17 +1580,17 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pMsg
=
doSerializeTableInfo
(
pSql
,
numOfTables
,
htons
(
pQueryMsg
->
vnode
),
pMsg
);
pMsg
=
doSerializeTableInfo
(
pSql
,
numOfTables
,
htons
(
pQueryMsg
->
vnode
),
pMsg
);
// only include the required tag column schema. If a tag is not required, it won't be sent to vnode
// only include the required tag column schema. If a tag is not required, it won't be sent to vnode
if
(
p
Meter
MetaInfo
->
numOfTags
>
0
)
{
if
(
p
Table
MetaInfo
->
numOfTags
>
0
)
{
// always transfer tag schema to vnode if exists
// always transfer tag schema to vnode if exists
SSchema
*
pTagSchema
=
ts
GetTagSchema
(
pMeter
Meta
);
SSchema
*
pTagSchema
=
ts
cGetTableTagSchema
(
pTable
Meta
);
for
(
int32_t
j
=
0
;
j
<
p
Meter
MetaInfo
->
numOfTags
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
p
Table
MetaInfo
->
numOfTags
;
++
j
)
{
if
(
p
Meter
MetaInfo
->
tagColumnIndex
[
j
]
==
TSDB_TBNAME_COLUMN_INDEX
)
{
if
(
p
Table
MetaInfo
->
tagColumnIndex
[
j
]
==
TSDB_TBNAME_COLUMN_INDEX
)
{
SSchema
tbSchema
=
{
SSchema
tbSchema
=
{
.
bytes
=
TSDB_TABLE_NAME_LEN
,
.
colId
=
TSDB_TBNAME_COLUMN_INDEX
,
.
type
=
TSDB_DATA_TYPE_BINARY
};
.
bytes
=
TSDB_TABLE_NAME_LEN
,
.
colId
=
TSDB_TBNAME_COLUMN_INDEX
,
.
type
=
TSDB_DATA_TYPE_BINARY
};
memcpy
(
pMsg
,
&
tbSchema
,
sizeof
(
SSchema
));
memcpy
(
pMsg
,
&
tbSchema
,
sizeof
(
SSchema
));
}
else
{
}
else
{
memcpy
(
pMsg
,
&
pTagSchema
[
p
Meter
MetaInfo
->
tagColumnIndex
[
j
]],
sizeof
(
SSchema
));
memcpy
(
pMsg
,
&
pTagSchema
[
p
Table
MetaInfo
->
tagColumnIndex
[
j
]],
sizeof
(
SSchema
));
}
}
pMsg
+=
sizeof
(
SSchema
);
pMsg
+=
sizeof
(
SSchema
);
...
@@ -1643,7 +1635,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1643,7 +1635,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int32_t
numOfBlocks
=
0
;
int32_t
numOfBlocks
=
0
;
if
(
pQueryInfo
->
tsBuf
!=
NULL
)
{
if
(
pQueryInfo
->
tsBuf
!=
NULL
)
{
STSVnodeBlockInfo
*
pBlockInfo
=
tsBufGetVnodeBlockInfo
(
pQueryInfo
->
tsBuf
,
p
Meter
MetaInfo
->
vnodeIndex
);
STSVnodeBlockInfo
*
pBlockInfo
=
tsBufGetVnodeBlockInfo
(
pQueryInfo
->
tsBuf
,
p
Table
MetaInfo
->
vnodeIndex
);
assert
(
QUERY_IS_JOIN_QUERY
(
pQueryInfo
->
type
)
&&
pBlockInfo
!=
NULL
);
// this query should not be sent
assert
(
QUERY_IS_JOIN_QUERY
(
pQueryInfo
->
type
)
&&
pBlockInfo
!=
NULL
);
// this query should not be sent
// todo refactor
// todo refactor
...
@@ -1685,8 +1677,8 @@ int32_t tscBuildCreateDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1685,8 +1677,8 @@ int32_t tscBuildCreateDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SCMCreateDbMsg
*
pCreateDbMsg
=
(
SCMCreateDbMsg
*
)
pCmd
->
payload
;
SCMCreateDbMsg
*
pCreateDbMsg
=
(
SCMCreateDbMsg
*
)
pCmd
->
payload
;
assert
(
pCmd
->
numOfClause
==
1
);
assert
(
pCmd
->
numOfClause
==
1
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
strncpy
(
pCreateDbMsg
->
db
,
p
Meter
MetaInfo
->
name
,
tListLen
(
pCreateDbMsg
->
db
));
strncpy
(
pCreateDbMsg
->
db
,
p
Table
MetaInfo
->
name
,
tListLen
(
pCreateDbMsg
->
db
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1807,8 +1799,8 @@ int32_t tscBuildDropDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1807,8 +1799,8 @@ int32_t tscBuildDropDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SCMDropDbMsg
*
pDropDbMsg
=
(
SCMDropDbMsg
*
)
pCmd
->
payload
;
SCMDropDbMsg
*
pDropDbMsg
=
(
SCMDropDbMsg
*
)
pCmd
->
payload
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
strncpy
(
pDropDbMsg
->
db
,
p
Meter
MetaInfo
->
name
,
tListLen
(
pDropDbMsg
->
db
));
strncpy
(
pDropDbMsg
->
db
,
p
Table
MetaInfo
->
name
,
tListLen
(
pDropDbMsg
->
db
));
pDropDbMsg
->
ignoreNotExists
=
pInfo
->
pDCLInfo
->
existsCheck
?
1
:
0
;
pDropDbMsg
->
ignoreNotExists
=
pInfo
->
pDCLInfo
->
existsCheck
?
1
:
0
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_CM_DROP_DB
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_CM_DROP_DB
;
...
@@ -1825,8 +1817,8 @@ int32_t tscBuildDropTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1825,8 +1817,8 @@ int32_t tscBuildDropTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
}
SCMDropTableMsg
*
pDropTableMsg
=
(
SCMDropTableMsg
*
)
pCmd
->
payload
;
SCMDropTableMsg
*
pDropTableMsg
=
(
SCMDropTableMsg
*
)
pCmd
->
payload
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
strcpy
(
pDropTableMsg
->
tableId
,
p
Meter
MetaInfo
->
name
);
strcpy
(
pDropTableMsg
->
tableId
,
p
Table
MetaInfo
->
name
);
pDropTableMsg
->
igNotExists
=
pInfo
->
pDCLInfo
->
existsCheck
?
1
:
0
;
pDropTableMsg
->
igNotExists
=
pInfo
->
pDCLInfo
->
existsCheck
?
1
:
0
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_CM_DROP_TABLE
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_CM_DROP_TABLE
;
...
@@ -1842,8 +1834,8 @@ int32_t tscBuildDropDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1842,8 +1834,8 @@ int32_t tscBuildDropDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
}
SCMDropDnodeMsg
*
pDrop
=
(
SCMDropDnodeMsg
*
)
pCmd
->
payload
;
SCMDropDnodeMsg
*
pDrop
=
(
SCMDropDnodeMsg
*
)
pCmd
->
payload
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
strcpy
(
pDrop
->
ip
,
p
Meter
MetaInfo
->
name
);
strcpy
(
pDrop
->
ip
,
p
Table
MetaInfo
->
name
);
pCmd
->
msgType
=
TSDB_MSG_TYPE_CM_DROP_DNODE
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_CM_DROP_DNODE
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -1860,8 +1852,8 @@ int32_t tscBuildDropAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1860,8 +1852,8 @@ int32_t tscBuildDropAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
}
SCMDropUserMsg
*
pDropMsg
=
(
SCMDropUserMsg
*
)
pCmd
->
payload
;
SCMDropUserMsg
*
pDropMsg
=
(
SCMDropUserMsg
*
)
pCmd
->
payload
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
strcpy
(
pDropMsg
->
user
,
p
Meter
MetaInfo
->
name
);
strcpy
(
pDropMsg
->
user
,
p
Table
MetaInfo
->
name
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1876,8 +1868,8 @@ int32_t tscBuildUseDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1876,8 +1868,8 @@ int32_t tscBuildUseDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
}
SCMUseDbMsg
*
pUseDbMsg
=
(
SCMUseDbMsg
*
)
pCmd
->
payload
;
SCMUseDbMsg
*
pUseDbMsg
=
(
SCMUseDbMsg
*
)
pCmd
->
payload
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
strcpy
(
pUseDbMsg
->
db
,
p
Meter
MetaInfo
->
name
);
strcpy
(
pUseDbMsg
->
db
,
p
Table
MetaInfo
->
name
);
pCmd
->
msgType
=
TSDB_MSG_TYPE_CM_USE_DB
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_CM_USE_DB
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -1896,10 +1888,10 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1896,10 +1888,10 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SCMShowMsg
*
pShowMsg
=
(
SCMShowMsg
*
)
pCmd
->
payload
;
SCMShowMsg
*
pShowMsg
=
(
SCMShowMsg
*
)
pCmd
->
payload
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
size_t
nameLen
=
strlen
(
p
Meter
MetaInfo
->
name
);
size_t
nameLen
=
strlen
(
p
Table
MetaInfo
->
name
);
if
(
nameLen
>
0
)
{
if
(
nameLen
>
0
)
{
strcpy
(
pShowMsg
->
db
,
p
Meter
MetaInfo
->
name
);
// prefix is set here
strcpy
(
pShowMsg
->
db
,
p
Table
MetaInfo
->
name
);
// prefix is set here
}
else
{
}
else
{
strcpy
(
pShowMsg
->
db
,
pObj
->
db
);
strcpy
(
pShowMsg
->
db
,
pObj
->
db
);
}
}
...
@@ -1976,7 +1968,7 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1976,7 +1968,7 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
// Reallocate the payload size
// Reallocate the payload size
size
=
tscEstimateCreateTableMsgLength
(
pSql
,
pInfo
);
size
=
tscEstimateCreateTableMsgLength
(
pSql
,
pInfo
);
...
@@ -1987,10 +1979,10 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1987,10 +1979,10 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SCMCreateTableMsg
*
pCreateTableMsg
=
(
SCMCreateTableMsg
*
)
pCmd
->
payload
;
SCMCreateTableMsg
*
pCreateTableMsg
=
(
SCMCreateTableMsg
*
)
pCmd
->
payload
;
strcpy
(
pCreateTableMsg
->
tableId
,
p
Meter
MetaInfo
->
name
);
strcpy
(
pCreateTableMsg
->
tableId
,
p
Table
MetaInfo
->
name
);
// use dbinfo from table id without modifying current db info
// use dbinfo from table id without modifying current db info
tscGetDBInfoFromMeterId
(
p
Meter
MetaInfo
->
name
,
pCreateTableMsg
->
db
);
tscGetDBInfoFromMeterId
(
p
Table
MetaInfo
->
name
,
pCreateTableMsg
->
db
);
SCreateTableSQL
*
pCreateTable
=
pInfo
->
pCreateTableInfo
;
SCreateTableSQL
*
pCreateTable
=
pInfo
->
pCreateTableInfo
;
...
@@ -2055,7 +2047,7 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -2055,7 +2047,7 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
size
=
tscEstimateAlterTableMsgLength
(
pCmd
);
size
=
tscEstimateAlterTableMsgLength
(
pCmd
);
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
size
))
{
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
size
))
{
...
@@ -2065,11 +2057,11 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -2065,11 +2057,11 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pAlterTableMsg
=
(
SCMAlterTableMsg
*
)
pCmd
->
payload
;
pAlterTableMsg
=
(
SCMAlterTableMsg
*
)
pCmd
->
payload
;
tscGetDBInfoFromMeterId
(
p
Meter
MetaInfo
->
name
,
pAlterTableMsg
->
db
);
tscGetDBInfoFromMeterId
(
p
Table
MetaInfo
->
name
,
pAlterTableMsg
->
db
);
SAlterTableSQL
*
pAlterInfo
=
pInfo
->
pAlterInfo
;
SAlterTableSQL
*
pAlterInfo
=
pInfo
->
pAlterInfo
;
strcpy
(
pAlterTableMsg
->
tableId
,
p
Meter
MetaInfo
->
name
);
strcpy
(
pAlterTableMsg
->
tableId
,
p
Table
MetaInfo
->
name
);
pAlterTableMsg
->
type
=
htons
(
pAlterInfo
->
type
);
pAlterTableMsg
->
type
=
htons
(
pAlterInfo
->
type
);
pAlterTableMsg
->
numOfCols
=
htons
(
tscNumOfFields
(
pQueryInfo
));
pAlterTableMsg
->
numOfCols
=
htons
(
tscNumOfFields
(
pQueryInfo
));
...
@@ -2107,8 +2099,8 @@ int tscAlterDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -2107,8 +2099,8 @@ int tscAlterDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
}
SCMAlterDbMsg
*
pAlterDbMsg
=
(
SCMAlterDbMsg
*
)
pCmd
->
payload
;
SCMAlterDbMsg
*
pAlterDbMsg
=
(
SCMAlterDbMsg
*
)
pCmd
->
payload
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
strcpy
(
pAlterDbMsg
->
db
,
p
Meter
MetaInfo
->
name
);
strcpy
(
pAlterDbMsg
->
db
,
p
Table
MetaInfo
->
name
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -2182,10 +2174,11 @@ static int tscLocalResultCommonBuilder(SSqlObj *pSql, int32_t numOfRes) {
...
@@ -2182,10 +2174,11 @@ static int tscLocalResultCommonBuilder(SSqlObj *pSql, int32_t numOfRes) {
int
tscProcessDescribeTableRsp
(
SSqlObj
*
pSql
)
{
int
tscProcessDescribeTableRsp
(
SSqlObj
*
pSql
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
int32_t
numOfRes
=
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
+
pMeterMetaInfo
->
pMeterMeta
->
numOfTags
;
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
)
;
int32_t
numOfRes
=
tinfo
.
numOfColumns
+
tinfo
.
numOfTags
;
return
tscLocalResultCommonBuilder
(
pSql
,
numOfRes
);
return
tscLocalResultCommonBuilder
(
pSql
,
numOfRes
);
}
}
...
@@ -2193,11 +2186,11 @@ int tscProcessTagRetrieveRsp(SSqlObj *pSql) {
...
@@ -2193,11 +2186,11 @@ int tscProcessTagRetrieveRsp(SSqlObj *pSql) {
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
int32_t
numOfRes
=
0
;
int32_t
numOfRes
=
0
;
if
(
tscSqlExprGet
(
pQueryInfo
,
0
)
->
functionId
==
TSDB_FUNC_TAGPRJ
)
{
if
(
tscSqlExprGet
(
pQueryInfo
,
0
)
->
functionId
==
TSDB_FUNC_TAGPRJ
)
{
numOfRes
=
p
Meter
MetaInfo
->
pMetricMeta
->
numOfTables
;
numOfRes
=
p
Table
MetaInfo
->
pMetricMeta
->
numOfTables
;
}
else
{
}
else
{
numOfRes
=
1
;
// for count function, there is only one output.
numOfRes
=
1
;
// for count function, there is only one output.
}
}
...
@@ -2273,10 +2266,10 @@ int tscBuildMeterMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -2273,10 +2266,10 @@ int tscBuildMeterMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
pInfoMsg
=
(
SCMTableInfoMsg
*
)
pCmd
->
payload
;
pInfoMsg
=
(
SCMTableInfoMsg
*
)
pCmd
->
payload
;
strcpy
(
pInfoMsg
->
tableId
,
p
Meter
MetaInfo
->
name
);
strcpy
(
pInfoMsg
->
tableId
,
p
Table
MetaInfo
->
name
);
pInfoMsg
->
createFlag
=
htons
(
pSql
->
cmd
.
createOnDemand
?
1
:
0
);
pInfoMsg
->
createFlag
=
htons
(
pSql
->
cmd
.
createOnDemand
?
1
:
0
);
pMsg
=
(
char
*
)
pInfoMsg
+
sizeof
(
SCMTableInfoMsg
);
pMsg
=
(
char
*
)
pInfoMsg
+
sizeof
(
SCMTableInfoMsg
);
...
@@ -2372,7 +2365,7 @@ int tscBuildMetricMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -2372,7 +2365,7 @@ int tscBuildMetricMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
STagCond
*
pTagCond
=
&
pQueryInfo
->
tagCond
;
STagCond
*
pTagCond
=
&
pQueryInfo
->
tagCond
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
tableIndex
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
tableIndex
);
int32_t
size
=
tscEstimateMetricMetaMsgSize
(
pCmd
);
int32_t
size
=
tscEstimateMetricMetaMsgSize
(
pCmd
);
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
size
))
{
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
size
))
{
...
@@ -2384,7 +2377,7 @@ int tscBuildMetricMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -2384,7 +2377,7 @@ int tscBuildMetricMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pMsg
=
pStart
;
pMsg
=
pStart
;
SMgmtHead
*
pMgmt
=
(
SMgmtHead
*
)
pMsg
;
SMgmtHead
*
pMgmt
=
(
SMgmtHead
*
)
pMsg
;
tscGetDBInfoFromMeterId
(
p
Meter
MetaInfo
->
name
,
pMgmt
->
db
);
tscGetDBInfoFromMeterId
(
p
Table
MetaInfo
->
name
,
pMgmt
->
db
);
pMsg
+=
sizeof
(
SMgmtHead
);
pMsg
+=
sizeof
(
SMgmtHead
);
...
@@ -2412,8 +2405,8 @@ int tscBuildMetricMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -2412,8 +2405,8 @@ int tscBuildMetricMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pMsg
+=
sizeof
(
int16_t
);
pMsg
+=
sizeof
(
int16_t
);
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
p
Meter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
i
);
p
Table
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
i
);
uint64_t
uid
=
p
MeterMetaInfo
->
pMeter
Meta
->
uid
;
uint64_t
uid
=
p
TableMetaInfo
->
pTable
Meta
->
uid
;
offset
=
pMsg
-
(
char
*
)
pMetaMsg
;
offset
=
pMsg
-
(
char
*
)
pMetaMsg
;
pMetaMsg
->
metaElem
[
i
]
=
htonl
(
offset
);
pMetaMsg
->
metaElem
[
i
]
=
htonl
(
offset
);
...
@@ -2466,8 +2459,8 @@ int tscBuildMetricMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -2466,8 +2459,8 @@ int tscBuildMetricMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pElem
->
numOfGroupCols
=
0
;
pElem
->
numOfGroupCols
=
0
;
}
else
{
}
else
{
pElem
->
numOfGroupCols
=
htons
(
pGroupby
->
numOfGroupCols
);
pElem
->
numOfGroupCols
=
htons
(
pGroupby
->
numOfGroupCols
);
for
(
int32_t
j
=
0
;
j
<
p
Meter
MetaInfo
->
numOfTags
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
p
Table
MetaInfo
->
numOfTags
;
++
j
)
{
pElem
->
tagCols
[
j
]
=
htons
(
p
Meter
MetaInfo
->
tagColumnIndex
[
j
]);
pElem
->
tagCols
[
j
]
=
htons
(
p
Table
MetaInfo
->
tagColumnIndex
[
j
]);
}
}
if
(
pGroupby
->
numOfGroupCols
!=
0
)
{
if
(
pGroupby
->
numOfGroupCols
!=
0
)
{
...
@@ -2491,8 +2484,8 @@ int tscBuildMetricMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -2491,8 +2484,8 @@ int tscBuildMetricMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
}
}
}
strcpy
(
pElem
->
tableId
,
p
Meter
MetaInfo
->
name
);
strcpy
(
pElem
->
tableId
,
p
Table
MetaInfo
->
name
);
pElem
->
numOfTags
=
htons
(
p
Meter
MetaInfo
->
numOfTags
);
pElem
->
numOfTags
=
htons
(
p
Table
MetaInfo
->
numOfTags
);
int16_t
len
=
pMsg
-
(
char
*
)
pElem
;
int16_t
len
=
pMsg
-
(
char
*
)
pElem
;
pElem
->
elemLen
=
htons
(
len
);
// redundant data for integrate check
pElem
->
elemLen
=
htons
(
len
);
// redundant data for integrate check
...
@@ -2564,10 +2557,10 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -2564,10 +2557,10 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
}
int
tscProcessMeterMetaRsp
(
SSqlObj
*
pSql
)
{
int
tscProcessMeterMetaRsp
(
SSqlObj
*
pSql
)
{
STableMeta
*
pMeta
;
STableMeta
Msg
*
pMeta
;
SSchema
*
pSchema
;
SSchema
*
pSchema
;
pMeta
=
(
STableMeta
*
)
pSql
->
res
.
pRsp
;
pMeta
=
(
STableMeta
Msg
*
)
pSql
->
res
.
pRsp
;
pMeta
->
sid
=
htonl
(
pMeta
->
sid
);
pMeta
->
sid
=
htonl
(
pMeta
->
sid
);
pMeta
->
sversion
=
htons
(
pMeta
->
sversion
);
pMeta
->
sversion
=
htons
(
pMeta
->
sversion
);
...
@@ -2596,7 +2589,7 @@ int tscProcessMeterMetaRsp(SSqlObj *pSql) {
...
@@ -2596,7 +2589,7 @@ int tscProcessMeterMetaRsp(SSqlObj *pSql) {
pMeta
->
vpeerDesc
[
i
].
vnode
=
htonl
(
pMeta
->
vpeerDesc
[
i
].
vnode
);
pMeta
->
vpeerDesc
[
i
].
vnode
=
htonl
(
pMeta
->
vpeerDesc
[
i
].
vnode
);
}
}
pMeta
->
rowSize
=
0
;
int32_t
rowSize
=
0
;
pSchema
=
(
SSchema
*
)(
pSql
->
res
.
pRsp
+
sizeof
(
STableMeta
));
pSchema
=
(
SSchema
*
)(
pSql
->
res
.
pRsp
+
sizeof
(
STableMeta
));
int32_t
numOfTotalCols
=
pMeta
->
numOfColumns
+
pMeta
->
numOfTags
;
int32_t
numOfTotalCols
=
pMeta
->
numOfColumns
+
pMeta
->
numOfTags
;
...
@@ -2606,7 +2599,7 @@ int tscProcessMeterMetaRsp(SSqlObj *pSql) {
...
@@ -2606,7 +2599,7 @@ int tscProcessMeterMetaRsp(SSqlObj *pSql) {
// ignore the tags length
// ignore the tags length
if
(
i
<
pMeta
->
numOfColumns
)
{
if
(
i
<
pMeta
->
numOfColumns
)
{
pMeta
->
rowSize
+=
pSchema
->
bytes
;
rowSize
+=
pSchema
->
bytes
;
}
}
pSchema
++
;
pSchema
++
;
}
}
...
@@ -2614,7 +2607,7 @@ int tscProcessMeterMetaRsp(SSqlObj *pSql) {
...
@@ -2614,7 +2607,7 @@ int tscProcessMeterMetaRsp(SSqlObj *pSql) {
// rsp += numOfTotalCols * sizeof(SSchema);
// rsp += numOfTotalCols * sizeof(SSchema);
//
//
// int32_t tagLen = 0;
// int32_t tagLen = 0;
// SSchema *pTagsSchema = ts
Get
TagSchema(pMeta);
// SSchema *pTagsSchema = ts
cGetTable
TagSchema(pMeta);
//
//
// if (pMeta->tableType == TSDB_CHILD_TABLE) {
// if (pMeta->tableType == TSDB_CHILD_TABLE) {
// for (int32_t i = 0; i < pMeta->numOfTags; ++i) {
// for (int32_t i = 0; i < pMeta->numOfTags; ++i) {
...
@@ -2629,13 +2622,13 @@ int tscProcessMeterMetaRsp(SSqlObj *pSql) {
...
@@ -2629,13 +2622,13 @@ int tscProcessMeterMetaRsp(SSqlObj *pSql) {
// pMeta->index = 0;
// pMeta->index = 0;
// todo add one more function: taosAddDataIfNotExists();
// todo add one more function: taosAddDataIfNotExists();
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
);
assert
(
p
MeterMetaInfo
->
pMeter
Meta
==
NULL
);
assert
(
p
TableMetaInfo
->
pTable
Meta
==
NULL
);
p
MeterMetaInfo
->
pMeterMeta
=
(
STableMeta
*
)
taosCachePut
(
tscCacheHandle
,
pMeter
MetaInfo
->
name
,
(
char
*
)
pMeta
,
p
TableMetaInfo
->
pTableMeta
=
(
STableMeta
*
)
taosCachePut
(
tscCacheHandle
,
pTable
MetaInfo
->
name
,
(
char
*
)
pMeta
,
pMeta
->
contLen
,
tsMeterMetaKeepTimer
);
pMeta
->
contLen
,
tsMeterMetaKeepTimer
);
// todo handle out of memory case
// todo handle out of memory case
if
(
p
MeterMetaInfo
->
pMeter
Meta
==
NULL
)
return
0
;
if
(
p
TableMetaInfo
->
pTable
Meta
==
NULL
)
return
0
;
return
TSDB_CODE_OTHERS
;
return
TSDB_CODE_OTHERS
;
}
}
...
@@ -2646,7 +2639,6 @@ int tscProcessMeterMetaRsp(SSqlObj *pSql) {
...
@@ -2646,7 +2639,6 @@ int tscProcessMeterMetaRsp(SSqlObj *pSql) {
* |...... 1B 1B 4B
* |...... 1B 1B 4B
**/
**/
int
tscProcessMultiMeterMetaRsp
(
SSqlObj
*
pSql
)
{
int
tscProcessMultiMeterMetaRsp
(
SSqlObj
*
pSql
)
{
SSchema
*
pSchema
;
uint8_t
ieType
;
uint8_t
ieType
;
int32_t
totalNum
;
int32_t
totalNum
;
int32_t
i
;
int32_t
i
;
...
@@ -2683,65 +2675,66 @@ int tscProcessMultiMeterMetaRsp(SSqlObj *pSql) {
...
@@ -2683,65 +2675,66 @@ int tscProcessMultiMeterMetaRsp(SSqlObj *pSql) {
return
TSDB_CODE_OTHERS
;
return
TSDB_CODE_OTHERS
;
}
}
pMeta
->
numOfColumns
=
htons
(
pMeta
->
numOfColumns
);
// pMeta->numOfColumns = htons(pMeta->numOfColumns);
//
if
(
pMeta
->
numOfTags
>
TSDB_MAX_TAGS
||
pMeta
->
numOfTags
<
0
)
{
// if (pMeta->numOfTags > TSDB_MAX_TAGS || pMeta->numOfTags < 0) {
tscError
(
"invalid tag value count:%d"
,
pMeta
->
numOfTags
);
// tscError("invalid tag value count:%d", pMeta->numOfTags);
pSql
->
res
.
code
=
TSDB_CODE_INVALID_VALUE
;
// pSql->res.code = TSDB_CODE_INVALID_VALUE;
pSql
->
res
.
numOfTotal
=
i
;
// pSql->res.numOfTotal = i;
return
TSDB_CODE_OTHERS
;
// return TSDB_CODE_OTHERS;
}
// }
//
if
(
pMeta
->
numOfTags
>
TSDB_MAX_TAGS
||
pMeta
->
numOfTags
<
0
)
{
// if (pMeta->numOfTags > TSDB_MAX_TAGS || pMeta->numOfTags < 0) {
tscError
(
"invalid numOfTags:%d"
,
pMeta
->
numOfTags
);
// tscError("invalid numOfTags:%d", pMeta->numOfTags);
pSql
->
res
.
code
=
TSDB_CODE_INVALID_VALUE
;
// pSql->res.code = TSDB_CODE_INVALID_VALUE;
pSql
->
res
.
numOfTotal
=
i
;
// pSql->res.numOfTotal = i;
return
TSDB_CODE_OTHERS
;
// return TSDB_CODE_OTHERS;
}
// }
//
if
(
pMeta
->
numOfColumns
>
TSDB_MAX_COLUMNS
||
pMeta
->
numOfColumns
<
0
)
{
// if (pMeta->numOfColumns > TSDB_MAX_COLUMNS || pMeta->numOfColumns < 0) {
tscError
(
"invalid numOfColumns:%d"
,
pMeta
->
numOfColumns
);
// tscError("invalid numOfColumns:%d", pMeta->numOfColumns);
pSql
->
res
.
code
=
TSDB_CODE_INVALID_VALUE
;
// pSql->res.code = TSDB_CODE_INVALID_VALUE;
pSql
->
res
.
numOfTotal
=
i
;
// pSql->res.numOfTotal = i;
return
TSDB_CODE_OTHERS
;
// return TSDB_CODE_OTHERS;
}
// }
//
for
(
int
j
=
0
;
j
<
TSDB_VNODES_SUPPORT
;
++
j
)
{
// for (int j = 0; j < TSDB_VNODES_SUPPORT; ++j) {
pMeta
->
vpeerDesc
[
j
].
vnode
=
htonl
(
pMeta
->
vpeerDesc
[
j
].
vnode
);
// pMeta->vpeerDesc[j].vnode = htonl(pMeta->vpeerDesc[j].vnode);
}
// }
//
pMeta
->
rowSize
=
0
;
// pMeta->rowSize = 0;
rsp
+=
sizeof
(
SMultiTableMeta
);
// rsp += sizeof(SMultiTableMeta);
pSchema
=
(
SSchema
*
)
rsp
;
// pSchema = (SSchema *)rsp;
//
int32_t
numOfTotalCols
=
pMeta
->
numOfColumns
+
pMeta
->
numOfTags
;
// int32_t numOfTotalCols = pMeta->numOfColumns + pMeta->numOfTags;
for
(
int
j
=
0
;
j
<
numOfTotalCols
;
++
j
)
{
// for (int j = 0; j < numOfTotalCols; ++j) {
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
// pSchema->bytes = htons(pSchema->bytes);
pSchema
->
colId
=
htons
(
pSchema
->
colId
);
// pSchema->colId = htons(pSchema->colId);
//
// ignore the tags length
// // ignore the tags length
if
(
j
<
pMeta
->
numOfColumns
)
{
// if (j < pMeta->numOfColumns) {
pMeta
->
rowSize
+=
pSchema
->
bytes
;
// pMeta->rowSize += pSchema->bytes;
}
// }
pSchema
++
;
// pSchema++;
}
// }
//
rsp
+=
numOfTotalCols
*
sizeof
(
SSchema
);
// rsp += numOfTotalCols * sizeof(SSchema);
//
int32_t
tagLen
=
0
;
// int32_t tagLen = 0;
SSchema
*
pTagsSchema
=
tsGetTagSchema
(
pMeta
);
// SSchema *pTagsSchema = tscGetTableTagSchema(pMeta);
//
if
(
pMeta
->
tableType
==
TSDB_CHILD_TABLE
)
{
// if (pMeta->tableType == TSDB_CHILD_TABLE) {
for
(
int32_t
j
=
0
;
j
<
pMeta
->
numOfTags
;
++
j
)
{
// for (int32_t j = 0; j < pMeta->numOfTags; ++j) {
tagLen
+=
pTagsSchema
[
j
].
bytes
;
// tagLen += pTagsSchema[j].bytes;
}
// }
}
// }
//
rsp
+=
tagLen
;
// rsp += tagLen;
int32_t
size
=
(
int32_t
)(
rsp
-
((
char
*
)
pMeta
));
// Consistent with STableMeta in cache
// int32_t size = (int32_t)(rsp - ((char *)pMeta)); // Consistent with STableMeta in cache
//
pMeta
->
index
=
0
;
// pMeta->index = 0;
(
void
)
taosCachePut
(
tscCacheHandle
,
pMeta
->
tableId
,
(
char
*
)
pMeta
,
size
,
tsMeterMetaKeepTimer
);
// (void)taosCachePut(tscCacheHandle, pMeta->tableId, (char *)pMeta, size, tsMeterMetaKeepTimer);
// }
}
}
pSql
->
res
.
code
=
TSDB_CODE_SUCCESS
;
pSql
->
res
.
code
=
TSDB_CODE_SUCCESS
;
...
@@ -2840,22 +2833,22 @@ int tscProcessMetricMetaRsp(SSqlObj *pSql) {
...
@@ -2840,22 +2833,22 @@ int tscProcessMetricMetaRsp(SSqlObj *pSql) {
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
char
name
[
TSDB_MAX_TAGS_LEN
+
1
]
=
{
0
};
char
name
[
TSDB_MAX_TAGS_LEN
+
1
]
=
{
0
};
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
i
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
i
);
tscGetMetricMetaCacheKey
(
pQueryInfo
,
name
,
p
MeterMetaInfo
->
pMeter
Meta
->
uid
);
tscGetMetricMetaCacheKey
(
pQueryInfo
,
name
,
p
TableMetaInfo
->
pTable
Meta
->
uid
);
#ifdef _DEBUG_VIEW
#ifdef _DEBUG_VIEW
printf
(
"generate the metric key:%s, index:%d
\n
"
,
name
,
i
);
printf
(
"generate the metric key:%s, index:%d
\n
"
,
name
,
i
);
#endif
#endif
// release the used metricmeta
// release the used metricmeta
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
Meter
MetaInfo
->
pMetricMeta
),
false
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
Table
MetaInfo
->
pMetricMeta
),
false
);
p
Meter
MetaInfo
->
pMetricMeta
=
(
SSuperTableMeta
*
)
taosCachePut
(
tscCacheHandle
,
name
,
(
char
*
)
metricMetaList
[
i
],
p
Table
MetaInfo
->
pMetricMeta
=
(
SSuperTableMeta
*
)
taosCachePut
(
tscCacheHandle
,
name
,
(
char
*
)
metricMetaList
[
i
],
sizes
[
i
],
tsMetricMetaKeepTimer
);
sizes
[
i
],
tsMetricMetaKeepTimer
);
tfree
(
metricMetaList
[
i
]);
tfree
(
metricMetaList
[
i
]);
// failed to put into cache
// failed to put into cache
if
(
p
Meter
MetaInfo
->
pMetricMeta
==
NULL
)
{
if
(
p
Table
MetaInfo
->
pMetricMeta
==
NULL
)
{
pSql
->
res
.
code
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
pSql
->
res
.
code
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
goto
_error_clean
;
goto
_error_clean
;
}
}
...
@@ -2877,7 +2870,7 @@ _error_clean:
...
@@ -2877,7 +2870,7 @@ _error_clean:
* current process do not use the cache at all
* current process do not use the cache at all
*/
*/
int
tscProcessShowRsp
(
SSqlObj
*
pSql
)
{
int
tscProcessShowRsp
(
SSqlObj
*
pSql
)
{
STableMeta
*
pMeta
;
STableMeta
Msg
*
pMetaMsg
;
SCMShowRsp
*
pShow
;
SCMShowRsp
*
pShow
;
SSchema
*
pSchema
;
SSchema
*
pSchema
;
char
key
[
20
];
char
key
[
20
];
...
@@ -2887,20 +2880,20 @@ int tscProcessShowRsp(SSqlObj *pSql) {
...
@@ -2887,20 +2880,20 @@ int tscProcessShowRsp(SSqlObj *pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
//?
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
//?
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
pShow
=
(
SCMShowRsp
*
)
pRes
->
pRsp
;
pShow
=
(
SCMShowRsp
*
)
pRes
->
pRsp
;
pShow
->
qhandle
=
htobe64
(
pShow
->
qhandle
);
pShow
->
qhandle
=
htobe64
(
pShow
->
qhandle
);
pRes
->
qhandle
=
pShow
->
qhandle
;
pRes
->
qhandle
=
pShow
->
qhandle
;
tscResetForNextRetrieve
(
pRes
);
tscResetForNextRetrieve
(
pRes
);
pMeta
=
&
(
pShow
->
tableMeta
);
pMeta
Msg
=
&
(
pShow
->
tableMeta
);
pMeta
->
numOfColumns
=
ntohs
(
pMeta
->
numOfColumns
);
pMeta
Msg
->
numOfColumns
=
ntohs
(
pMetaMsg
->
numOfColumns
);
pSchema
=
(
SSchema
*
)((
char
*
)
pMeta
+
sizeof
(
STableMeta
));
pSchema
=
(
SSchema
*
)((
char
*
)
pMeta
Msg
+
sizeof
(
STableMeta
));
pMeta
->
sid
=
ntohs
(
pMeta
->
sid
);
pMeta
Msg
->
sid
=
ntohs
(
pMetaMsg
->
sid
);
for
(
int
i
=
0
;
i
<
pMeta
->
numOfColumns
;
++
i
)
{
for
(
int
i
=
0
;
i
<
pMeta
Msg
->
numOfColumns
;
++
i
)
{
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
pSchema
++
;
pSchema
++
;
}
}
...
@@ -2908,18 +2901,18 @@ int tscProcessShowRsp(SSqlObj *pSql) {
...
@@ -2908,18 +2901,18 @@ int tscProcessShowRsp(SSqlObj *pSql) {
key
[
0
]
=
pCmd
->
msgType
+
'a'
;
key
[
0
]
=
pCmd
->
msgType
+
'a'
;
strcpy
(
key
+
1
,
"showlist"
);
strcpy
(
key
+
1
,
"showlist"
);
taosCacheRelease
(
tscCacheHandle
,
(
void
*
)
&
(
p
MeterMetaInfo
->
pMeter
Meta
),
false
);
taosCacheRelease
(
tscCacheHandle
,
(
void
*
)
&
(
p
TableMetaInfo
->
pTable
Meta
),
false
);
int32_t
size
=
pMeta
->
numOfColumns
*
sizeof
(
SSchema
)
+
sizeof
(
STableMeta
);
int32_t
size
=
pMeta
Msg
->
numOfColumns
*
sizeof
(
SSchema
)
+
sizeof
(
STableMeta
);
p
MeterMetaInfo
->
pMeter
Meta
=
p
TableMetaInfo
->
pTable
Meta
=
(
STableMeta
*
)
taosCachePut
(
tscCacheHandle
,
key
,
(
char
*
)
pMeta
,
size
,
tsMeterMetaKeepTimer
);
(
STableMeta
*
)
taosCachePut
(
tscCacheHandle
,
key
,
(
char
*
)
pMeta
Msg
,
size
,
tsMeterMetaKeepTimer
);
pCmd
->
numOfCols
=
pQueryInfo
->
fieldsInfo
.
numOfOutputCols
;
pCmd
->
numOfCols
=
pQueryInfo
->
fieldsInfo
.
numOfOutputCols
;
SSchema
*
pMeterSchema
=
ts
GetSchema
(
pMeterMetaInfo
->
pMeter
Meta
);
SSchema
*
pMeterSchema
=
ts
cGetTableSchema
(
pTableMetaInfo
->
pTable
Meta
);
tscColumnBaseInfoReserve
(
&
pQueryInfo
->
colList
,
pMeta
->
numOfColumns
);
tscColumnBaseInfoReserve
(
&
pQueryInfo
->
colList
,
pMeta
Msg
->
numOfColumns
);
SColumnIndex
index
=
{
0
};
SColumnIndex
index
=
{
0
};
for
(
int16_t
i
=
0
;
i
<
pMeta
->
numOfColumns
;
++
i
)
{
for
(
int16_t
i
=
0
;
i
<
pMeta
Msg
->
numOfColumns
;
++
i
)
{
index
.
columnIndex
=
i
;
index
.
columnIndex
=
i
;
tscColumnBaseInfoInsert
(
pQueryInfo
,
&
index
);
tscColumnBaseInfoInsert
(
pQueryInfo
,
&
index
);
tscFieldInfoSetValFromSchema
(
&
pQueryInfo
->
fieldsInfo
,
i
,
&
pMeterSchema
[
i
]);
tscFieldInfoSetValFromSchema
(
&
pQueryInfo
->
fieldsInfo
,
i
,
&
pMeterSchema
[
i
]);
...
@@ -2959,9 +2952,9 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
...
@@ -2959,9 +2952,9 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
int
tscProcessUseDbRsp
(
SSqlObj
*
pSql
)
{
int
tscProcessUseDbRsp
(
SSqlObj
*
pSql
)
{
STscObj
*
pObj
=
pSql
->
pTscObj
;
STscObj
*
pObj
=
pSql
->
pTscObj
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
);
strcpy
(
pObj
->
db
,
p
Meter
MetaInfo
->
name
);
strcpy
(
pObj
->
db
,
p
Table
MetaInfo
->
name
);
return
0
;
return
0
;
}
}
...
@@ -2971,10 +2964,10 @@ int tscProcessDropDbRsp(SSqlObj *UNUSED_PARAM(pSql)) {
...
@@ -2971,10 +2964,10 @@ int tscProcessDropDbRsp(SSqlObj *UNUSED_PARAM(pSql)) {
}
}
int
tscProcessDropTableRsp
(
SSqlObj
*
pSql
)
{
int
tscProcessDropTableRsp
(
SSqlObj
*
pSql
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
);
STableMeta
*
p
MeterMeta
=
taosCacheAcquireByName
(
tscCacheHandle
,
pMeter
MetaInfo
->
name
);
STableMeta
*
p
TableMeta
=
taosCacheAcquireByName
(
tscCacheHandle
,
pTable
MetaInfo
->
name
);
if
(
p
Meter
Meta
==
NULL
)
{
if
(
p
Table
Meta
==
NULL
)
{
/* not in cache, abort */
/* not in cache, abort */
return
0
;
return
0
;
}
}
...
@@ -2986,36 +2979,36 @@ int tscProcessDropTableRsp(SSqlObj *pSql) {
...
@@ -2986,36 +2979,36 @@ int tscProcessDropTableRsp(SSqlObj *pSql) {
* The cached information is expired, however, we may have lost the ref of original meter. So, clear whole cache
* The cached information is expired, however, we may have lost the ref of original meter. So, clear whole cache
* instead.
* instead.
*/
*/
tscTrace
(
"%p force release metermeta after drop table:%s"
,
pSql
,
p
Meter
MetaInfo
->
name
);
tscTrace
(
"%p force release metermeta after drop table:%s"
,
pSql
,
p
Table
MetaInfo
->
name
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
p
Meter
Meta
,
true
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
p
Table
Meta
,
true
);
if
(
p
MeterMetaInfo
->
pMeter
Meta
)
{
if
(
p
TableMetaInfo
->
pTable
Meta
)
{
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
MeterMetaInfo
->
pMeter
Meta
),
true
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
TableMetaInfo
->
pTable
Meta
),
true
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
Meter
MetaInfo
->
pMetricMeta
),
true
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
Table
MetaInfo
->
pMetricMeta
),
true
);
}
}
return
0
;
return
0
;
}
}
int
tscProcessAlterTableMsgRsp
(
SSqlObj
*
pSql
)
{
int
tscProcessAlterTableMsgRsp
(
SSqlObj
*
pSql
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
);
STableMeta
*
p
MeterMeta
=
taosCacheAcquireByName
(
tscCacheHandle
,
pMeter
MetaInfo
->
name
);
STableMeta
*
p
TableMeta
=
taosCacheAcquireByName
(
tscCacheHandle
,
pTable
MetaInfo
->
name
);
if
(
p
Meter
Meta
==
NULL
)
{
/* not in cache, abort */
if
(
p
Table
Meta
==
NULL
)
{
/* not in cache, abort */
return
0
;
return
0
;
}
}
tscTrace
(
"%p force release metermeta in cache after alter-table: %s"
,
pSql
,
p
Meter
MetaInfo
->
name
);
tscTrace
(
"%p force release metermeta in cache after alter-table: %s"
,
pSql
,
p
Table
MetaInfo
->
name
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
p
Meter
Meta
,
true
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
p
Table
Meta
,
true
);
if
(
p
MeterMetaInfo
->
pMeter
Meta
)
{
if
(
p
TableMetaInfo
->
pTable
Meta
)
{
bool
isSuperTable
=
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
);
bool
isSuperTable
=
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
MeterMetaInfo
->
pMeter
Meta
),
true
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
TableMetaInfo
->
pTable
Meta
),
true
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
Meter
MetaInfo
->
pMetricMeta
),
true
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
Table
MetaInfo
->
pMetricMeta
),
true
);
if
(
isSuperTable
)
{
// if it is a super table, reset whole query cache
if
(
isSuperTable
)
{
// if it is a super table, reset whole query cache
tscTrace
(
"%p reset query cache since table:%s is stable"
,
pSql
,
p
Meter
MetaInfo
->
name
);
tscTrace
(
"%p reset query cache since table:%s is stable"
,
pSql
,
p
Table
MetaInfo
->
name
);
taosCacheEmpty
(
tscCacheHandle
);
taosCacheEmpty
(
tscCacheHandle
);
}
}
}
}
...
@@ -3098,7 +3091,7 @@ int tscProcessRetrieveRspFromLocal(SSqlObj *pSql) {
...
@@ -3098,7 +3091,7 @@ int tscProcessRetrieveRspFromLocal(SSqlObj *pSql) {
void
tscMeterMetaCallBack
(
void
*
param
,
TAOS_RES
*
res
,
int
code
);
void
tscMeterMetaCallBack
(
void
*
param
,
TAOS_RES
*
res
,
int
code
);
static
int32_t
doGetMeterMetaFromServer
(
SSqlObj
*
pSql
,
S
MeterMetaInfo
*
pMeter
MetaInfo
)
{
static
int32_t
doGetMeterMetaFromServer
(
SSqlObj
*
pSql
,
S
TableMetaInfo
*
pTable
MetaInfo
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SSqlObj
*
pNew
=
calloc
(
1
,
sizeof
(
SSqlObj
));
SSqlObj
*
pNew
=
calloc
(
1
,
sizeof
(
SSqlObj
));
...
@@ -3124,10 +3117,10 @@ static int32_t doGetMeterMetaFromServer(SSqlObj *pSql, SMeterMetaInfo *pMeterMet
...
@@ -3124,10 +3117,10 @@ static int32_t doGetMeterMetaFromServer(SSqlObj *pSql, SMeterMetaInfo *pMeterMet
return
TSDB_CODE_CLI_OUT_OF_MEMORY
;
return
TSDB_CODE_CLI_OUT_OF_MEMORY
;
}
}
S
Meter
MetaInfo
*
pNewMeterMetaInfo
=
tscAddEmptyMeterMetaInfo
(
pNewQueryInfo
);
S
Table
MetaInfo
*
pNewMeterMetaInfo
=
tscAddEmptyMeterMetaInfo
(
pNewQueryInfo
);
assert
(
pNew
->
cmd
.
numOfClause
==
1
&&
pNewQueryInfo
->
numOfTables
==
1
);
assert
(
pNew
->
cmd
.
numOfClause
==
1
&&
pNewQueryInfo
->
numOfTables
==
1
);
strcpy
(
pNewMeterMetaInfo
->
name
,
p
Meter
MetaInfo
->
name
);
strcpy
(
pNewMeterMetaInfo
->
name
,
p
Table
MetaInfo
->
name
);
memcpy
(
pNew
->
cmd
.
payload
,
pSql
->
cmd
.
payload
,
TSDB_DEFAULT_PAYLOAD_SIZE
);
// tag information if table does not exists.
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
);
tscTrace
(
"%p new pSqlObj:%p to get tableMeta"
,
pSql
,
pNew
);
...
@@ -3142,11 +3135,11 @@ static int32_t doGetMeterMetaFromServer(SSqlObj *pSql, SMeterMetaInfo *pMeterMet
...
@@ -3142,11 +3135,11 @@ static int32_t doGetMeterMetaFromServer(SSqlObj *pSql, SMeterMetaInfo *pMeterMet
* Transfer the ownership of metermeta to the new object, instead of invoking the release/acquire routine
* Transfer the ownership of metermeta to the new object, instead of invoking the release/acquire routine
*/
*/
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
p
MeterMetaInfo
->
pMeterMeta
=
taosCacheTransfer
(
tscCacheHandle
,
(
void
**
)
&
pNewMeterMetaInfo
->
pMeter
Meta
);
p
TableMetaInfo
->
pTableMeta
=
taosCacheTransfer
(
tscCacheHandle
,
(
void
**
)
&
pNewMeterMetaInfo
->
pTable
Meta
);
assert
(
p
MeterMetaInfo
->
pMeter
Meta
!=
NULL
);
assert
(
p
TableMetaInfo
->
pTable
Meta
!=
NULL
);
}
}
tscTrace
(
"%p get meter meta complete, code:%d, p
MeterMeta:%p"
,
pSql
,
code
,
pMeterMetaInfo
->
pMeter
Meta
);
tscTrace
(
"%p get meter meta complete, code:%d, p
TableMeta:%p"
,
pSql
,
code
,
pTableMetaInfo
->
pTable
Meta
);
tscFreeSqlObj
(
pNew
);
tscFreeSqlObj
(
pNew
);
}
else
{
}
else
{
...
@@ -3163,20 +3156,19 @@ static int32_t doGetMeterMetaFromServer(SSqlObj *pSql, SMeterMetaInfo *pMeterMet
...
@@ -3163,20 +3156,19 @@ static int32_t doGetMeterMetaFromServer(SSqlObj *pSql, SMeterMetaInfo *pMeterMet
return
code
;
return
code
;
}
}
int
tscGetMeterMeta
(
SSqlObj
*
pSql
,
S
MeterMetaInfo
*
pMeter
MetaInfo
)
{
int
tscGetMeterMeta
(
SSqlObj
*
pSql
,
S
TableMetaInfo
*
pTable
MetaInfo
)
{
assert
(
strlen
(
p
Meter
MetaInfo
->
name
)
!=
0
);
assert
(
strlen
(
p
Table
MetaInfo
->
name
)
!=
0
);
// If this S
Meter
MetaInfo owns a metermeta, release it first
// If this S
Table
MetaInfo owns a metermeta, release it first
if
(
p
MeterMetaInfo
->
pMeter
Meta
!=
NULL
)
{
if
(
p
TableMetaInfo
->
pTable
Meta
!=
NULL
)
{
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
MeterMetaInfo
->
pMeter
Meta
),
false
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
TableMetaInfo
->
pTable
Meta
),
false
);
}
}
pMeterMetaInfo
->
pMeterMeta
=
(
STableMeta
*
)
taosCacheAcquireByName
(
tscCacheHandle
,
pMeterMetaInfo
->
name
);
pTableMetaInfo
->
pTableMeta
=
(
STableMeta
*
)
taosCacheAcquireByName
(
tscCacheHandle
,
pTableMetaInfo
->
name
);
if
(
pMeterMetaInfo
->
pMeterMeta
!=
NULL
)
{
if
(
pTableMetaInfo
->
pTableMeta
!=
NULL
)
{
STableMeta
*
pMeterMeta
=
pMeterMetaInfo
->
pMeterMeta
;
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
tscTrace
(
"%p retrieve tableMeta from cache, the number of columns:%d, numOfTags:%d"
,
pSql
,
tinfo
.
numOfColumns
,
tscTrace
(
"%p retrieve tableMeta from cache, the number of columns:%d, numOfTags:%d"
,
pSql
,
pMeterMeta
->
numOfColumns
,
tinfo
.
numOfTags
);
pMeterMeta
->
numOfTags
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -3185,12 +3177,12 @@ int tscGetMeterMeta(SSqlObj *pSql, SMeterMetaInfo *pMeterMetaInfo) {
...
@@ -3185,12 +3177,12 @@ int tscGetMeterMeta(SSqlObj *pSql, SMeterMetaInfo *pMeterMetaInfo) {
* for async insert operation, release data block buffer before issue new object to get metermeta
* for async insert operation, release data block buffer before issue new object to get metermeta
* because in metermeta callback function, the tscParse function will generate the submit data blocks
* because in metermeta callback function, the tscParse function will generate the submit data blocks
*/
*/
return
doGetMeterMetaFromServer
(
pSql
,
p
Meter
MetaInfo
);
return
doGetMeterMetaFromServer
(
pSql
,
p
Table
MetaInfo
);
}
}
int
tscGetMeterMetaEx
(
SSqlObj
*
pSql
,
S
MeterMetaInfo
*
pMeter
MetaInfo
,
bool
createIfNotExists
)
{
int
tscGetMeterMetaEx
(
SSqlObj
*
pSql
,
S
TableMetaInfo
*
pTable
MetaInfo
,
bool
createIfNotExists
)
{
pSql
->
cmd
.
createOnDemand
=
createIfNotExists
;
pSql
->
cmd
.
createOnDemand
=
createIfNotExists
;
return
tscGetMeterMeta
(
pSql
,
p
Meter
MetaInfo
);
return
tscGetMeterMeta
(
pSql
,
p
Table
MetaInfo
);
}
}
/*
/*
...
@@ -3219,7 +3211,7 @@ int tscRenewMeterMeta(SSqlObj *pSql, char *tableId) {
...
@@ -3219,7 +3211,7 @@ int tscRenewMeterMeta(SSqlObj *pSql, char *tableId) {
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
// enforce the renew metermeta operation in async model
// enforce the renew metermeta operation in async model
if
(
pSql
->
fp
==
NULL
)
pSql
->
fp
=
(
void
*
)
0x1
;
if
(
pSql
->
fp
==
NULL
)
pSql
->
fp
=
(
void
*
)
0x1
;
...
@@ -3228,20 +3220,20 @@ int tscRenewMeterMeta(SSqlObj *pSql, char *tableId) {
...
@@ -3228,20 +3220,20 @@ int tscRenewMeterMeta(SSqlObj *pSql, char *tableId) {
* 1. only update the metermeta in force model metricmeta is not updated
* 1. only update the metermeta in force model metricmeta is not updated
* 2. if get metermeta failed, still get the metermeta
* 2. if get metermeta failed, still get the metermeta
*/
*/
if
(
p
MeterMetaInfo
->
pMeter
Meta
==
NULL
||
!
tscQueryOnMetric
(
pCmd
))
{
if
(
p
TableMetaInfo
->
pTable
Meta
==
NULL
||
!
tscQueryOnMetric
(
pCmd
))
{
if
(
p
MeterMetaInfo
->
pMeter
Meta
)
{
if
(
p
TableMetaInfo
->
pTable
Meta
)
{
tscTrace
(
"%p update meter meta, old: numOfTags:%d, numOfCols:%d, uid:%"
PRId64
", addr:%p"
,
pSql
,
tscTrace
(
"%p update meter meta, old: numOfTags:%d, numOfCols:%d, uid:%"
PRId64
", addr:%p"
,
pSql
,
p
MeterMetaInfo
->
numOfTags
,
pCmd
->
numOfCols
,
pMeterMetaInfo
->
pMeterMeta
->
uid
,
pMeterMetaInfo
->
pMeter
Meta
);
p
TableMetaInfo
->
numOfTags
,
pCmd
->
numOfCols
,
pTableMetaInfo
->
pTableMeta
->
uid
,
pTableMetaInfo
->
pTable
Meta
);
}
}
tscWaitingForCreateTable
(
pCmd
);
tscWaitingForCreateTable
(
pCmd
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
MeterMetaInfo
->
pMeter
Meta
),
true
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
TableMetaInfo
->
pTable
Meta
),
true
);
code
=
doGetMeterMetaFromServer
(
pSql
,
p
Meter
MetaInfo
);
// todo ??
code
=
doGetMeterMetaFromServer
(
pSql
,
p
Table
MetaInfo
);
// todo ??
}
else
{
}
else
{
tscTrace
(
"%p metric query not update metric meta, numOfTags:%d, numOfCols:%d, uid:%"
PRId64
", addr:%p"
,
pSql
,
tscTrace
(
"%p metric query not update metric meta, numOfTags:%d, numOfCols:%d, uid:%"
PRId64
", addr:%p"
,
pSql
,
pMeterMetaInfo
->
pMeterMeta
->
numOfTags
,
pCmd
->
numOfCols
,
pMeterMetaInfo
->
pMeter
Meta
->
uid
,
tscGetNumOfTags
(
pTableMetaInfo
->
pTableMeta
),
pCmd
->
numOfCols
,
pTableMetaInfo
->
pTable
Meta
->
uid
,
p
MeterMetaInfo
->
pMeter
Meta
);
p
TableMetaInfo
->
pTable
Meta
);
}
}
if
(
code
!=
TSDB_CODE_ACTION_IN_PROGRESS
)
{
if
(
code
!=
TSDB_CODE_ACTION_IN_PROGRESS
)
{
...
@@ -3266,17 +3258,17 @@ int tscGetMetricMeta(SSqlObj *pSql, int32_t clauseIndex) {
...
@@ -3266,17 +3258,17 @@ int tscGetMetricMeta(SSqlObj *pSql, int32_t clauseIndex) {
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
char
tagstr
[
TSDB_MAX_TAGS_LEN
+
1
]
=
{
0
};
char
tagstr
[
TSDB_MAX_TAGS_LEN
+
1
]
=
{
0
};
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
i
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
i
);
tscGetMetricMetaCacheKey
(
pQueryInfo
,
tagstr
,
p
MeterMetaInfo
->
pMeter
Meta
->
uid
);
tscGetMetricMetaCacheKey
(
pQueryInfo
,
tagstr
,
p
TableMetaInfo
->
pTable
Meta
->
uid
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
Meter
MetaInfo
->
pMetricMeta
),
false
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
Table
MetaInfo
->
pMetricMeta
),
false
);
SSuperTableMeta
*
ppMeta
=
(
SSuperTableMeta
*
)
taosCacheAcquireByName
(
tscCacheHandle
,
tagstr
);
SSuperTableMeta
*
ppMeta
=
(
SSuperTableMeta
*
)
taosCacheAcquireByName
(
tscCacheHandle
,
tagstr
);
if
(
ppMeta
==
NULL
)
{
if
(
ppMeta
==
NULL
)
{
required
=
true
;
required
=
true
;
break
;
break
;
}
else
{
}
else
{
p
Meter
MetaInfo
->
pMetricMeta
=
ppMeta
;
p
Table
MetaInfo
->
pMetricMeta
=
ppMeta
;
}
}
}
}
...
@@ -3297,10 +3289,10 @@ int tscGetMetricMeta(SSqlObj *pSql, int32_t clauseIndex) {
...
@@ -3297,10 +3289,10 @@ int tscGetMetricMeta(SSqlObj *pSql, int32_t clauseIndex) {
}
}
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
S
Meter
MetaInfo
*
pMMInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
i
);
S
Table
MetaInfo
*
pMMInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
i
);
STableMeta
*
p
Meter
Meta
=
taosCacheAcquireByName
(
tscCacheHandle
,
pMMInfo
->
name
);
STableMeta
*
p
Table
Meta
=
taosCacheAcquireByName
(
tscCacheHandle
,
pMMInfo
->
name
);
tscAddMeterMetaInfo
(
pNewQueryInfo
,
pMMInfo
->
name
,
p
Meter
Meta
,
NULL
,
pMMInfo
->
numOfTags
,
pMMInfo
->
tagColumnIndex
);
tscAddMeterMetaInfo
(
pNewQueryInfo
,
pMMInfo
->
name
,
p
Table
Meta
,
NULL
,
pMMInfo
->
numOfTags
,
pMMInfo
->
tagColumnIndex
);
}
}
if
((
code
=
tscAllocPayload
(
&
pNew
->
cmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
tscAllocPayload
(
&
pNew
->
cmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
))
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -3337,15 +3329,15 @@ int tscGetMetricMeta(SSqlObj *pSql, int32_t clauseIndex) {
...
@@ -3337,15 +3329,15 @@ int tscGetMetricMeta(SSqlObj *pSql, int32_t clauseIndex) {
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
char
tagstr
[
TSDB_MAX_TAGS_LEN
]
=
{
0
};
char
tagstr
[
TSDB_MAX_TAGS_LEN
]
=
{
0
};
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
i
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
i
);
tscGetMetricMetaCacheKey
(
pQueryInfo
,
tagstr
,
p
MeterMetaInfo
->
pMeter
Meta
->
uid
);
tscGetMetricMetaCacheKey
(
pQueryInfo
,
tagstr
,
p
TableMetaInfo
->
pTable
Meta
->
uid
);
#ifdef _DEBUG_VIEW
#ifdef _DEBUG_VIEW
printf
(
"create metric key:%s, index:%d
\n
"
,
tagstr
,
i
);
printf
(
"create metric key:%s, index:%d
\n
"
,
tagstr
,
i
);
#endif
#endif
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
Meter
MetaInfo
->
pMetricMeta
),
false
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
Table
MetaInfo
->
pMetricMeta
),
false
);
p
Meter
MetaInfo
->
pMetricMeta
=
(
SSuperTableMeta
*
)
taosCacheAcquireByName
(
tscCacheHandle
,
tagstr
);
p
Table
MetaInfo
->
pMetricMeta
=
(
SSuperTableMeta
*
)
taosCacheAcquireByName
(
tscCacheHandle
,
tagstr
);
}
}
}
}
...
...
src/client/src/tscSql.c
浏览文件 @
03346d0c
...
@@ -509,7 +509,7 @@ static bool tscHashRemainDataInSubqueryResultSet(SSqlObj *pSql) {
...
@@ -509,7 +509,7 @@ static bool tscHashRemainDataInSubqueryResultSet(SSqlObj *pSql) {
SSqlCmd
*
pCmd1
=
&
pSql
->
pSubs
[
i
]
->
cmd
;
SSqlCmd
*
pCmd1
=
&
pSql
->
pSubs
[
i
]
->
cmd
;
SQueryInfo
*
pQueryInfo1
=
tscGetQueryInfoDetail
(
pCmd1
,
pCmd1
->
clauseIndex
);
SQueryInfo
*
pQueryInfo1
=
tscGetQueryInfoDetail
(
pCmd1
,
pCmd1
->
clauseIndex
);
S
Meter
MetaInfo
*
pMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo1
,
0
);
S
Table
MetaInfo
*
pMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo1
,
0
);
assert
(
pQueryInfo1
->
numOfTables
==
1
);
assert
(
pQueryInfo1
->
numOfTables
==
1
);
...
@@ -810,7 +810,7 @@ void taos_free_result_imp(TAOS_RES *res, int keepCmd) {
...
@@ -810,7 +810,7 @@ void taos_free_result_imp(TAOS_RES *res, int keepCmd) {
pQueryInfo
->
type
=
TSDB_QUERY_TYPE_FREE_RESOURCE
;
pQueryInfo
->
type
=
TSDB_QUERY_TYPE_FREE_RESOURCE
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
/*
/*
* case 1. Partial data have been retrieved from vnodes, but not all data has been retrieved yet.
* case 1. Partial data have been retrieved from vnodes, but not all data has been retrieved yet.
...
@@ -825,7 +825,7 @@ void taos_free_result_imp(TAOS_RES *res, int keepCmd) {
...
@@ -825,7 +825,7 @@ void taos_free_result_imp(TAOS_RES *res, int keepCmd) {
if
(
pRes
->
code
!=
TSDB_CODE_QUERY_CANCELLED
&&
if
(
pRes
->
code
!=
TSDB_CODE_QUERY_CANCELLED
&&
((
pRes
->
numOfRows
>
0
&&
pCmd
->
command
<
TSDB_SQL_LOCAL
)
||
((
pRes
->
numOfRows
>
0
&&
pCmd
->
command
<
TSDB_SQL_LOCAL
)
||
(
pRes
->
code
==
TSDB_CODE_SUCCESS
&&
pRes
->
numOfRows
==
0
&&
pCmd
->
command
==
TSDB_SQL_SELECT
&&
(
pRes
->
code
==
TSDB_CODE_SUCCESS
&&
pRes
->
numOfRows
==
0
&&
pCmd
->
command
==
TSDB_SQL_SELECT
&&
pSql
->
pStream
==
NULL
&&
p
MeterMetaInfo
->
pMeter
Meta
!=
NULL
)))
{
pSql
->
pStream
==
NULL
&&
p
TableMetaInfo
->
pTable
Meta
!=
NULL
)))
{
pCmd
->
command
=
(
pCmd
->
command
>
TSDB_SQL_MGMT
)
?
TSDB_SQL_RETRIEVE
:
TSDB_SQL_FETCH
;
pCmd
->
command
=
(
pCmd
->
command
>
TSDB_SQL_MGMT
)
?
TSDB_SQL_RETRIEVE
:
TSDB_SQL_FETCH
;
tscTrace
(
"%p code:%d, numOfRows:%d, command:%d"
,
pSql
,
pRes
->
code
,
pRes
->
numOfRows
,
pCmd
->
command
);
tscTrace
(
"%p code:%d, numOfRows:%d, command:%d"
,
pSql
,
pRes
->
code
,
pRes
->
numOfRows
,
pCmd
->
command
);
...
@@ -1109,7 +1109,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
...
@@ -1109,7 +1109,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
SQueryInfo
*
pQueryInfo
=
NULL
;
SQueryInfo
*
pQueryInfo
=
NULL
;
tscGetQueryInfoDetailSafely
(
pCmd
,
pCmd
->
clauseIndex
,
&
pQueryInfo
);
tscGetQueryInfoDetailSafely
(
pCmd
,
pCmd
->
clauseIndex
,
&
pQueryInfo
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscAddEmptyMeterMetaInfo
(
pQueryInfo
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscAddEmptyMeterMetaInfo
(
pQueryInfo
);
if
((
code
=
tscAllocPayload
(
pCmd
,
tblListLen
+
16
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
tscAllocPayload
(
pCmd
,
tblListLen
+
16
))
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
...
@@ -1144,7 +1144,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
...
@@ -1144,7 +1144,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
return
code
;
return
code
;
}
}
if
((
code
=
setMeterID
(
p
Meter
MetaInfo
,
&
sToken
,
pSql
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
setMeterID
(
p
Table
MetaInfo
,
&
sToken
,
pSql
))
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
...
@@ -1154,7 +1154,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
...
@@ -1154,7 +1154,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
return
code
;
return
code
;
}
}
if
(
payloadLen
+
strlen
(
p
Meter
MetaInfo
->
name
)
+
128
>=
pCmd
->
allocSize
)
{
if
(
payloadLen
+
strlen
(
p
Table
MetaInfo
->
name
)
+
128
>=
pCmd
->
allocSize
)
{
char
*
pNewMem
=
realloc
(
pCmd
->
payload
,
pCmd
->
allocSize
+
tblListLen
);
char
*
pNewMem
=
realloc
(
pCmd
->
payload
,
pCmd
->
allocSize
+
tblListLen
);
if
(
pNewMem
==
NULL
)
{
if
(
pNewMem
==
NULL
)
{
code
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
code
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
...
@@ -1167,7 +1167,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
...
@@ -1167,7 +1167,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
pMsg
=
pCmd
->
payload
;
pMsg
=
pCmd
->
payload
;
}
}
payloadLen
+=
sprintf
(
pMsg
+
payloadLen
,
"%s,"
,
p
Meter
MetaInfo
->
name
);
payloadLen
+=
sprintf
(
pMsg
+
payloadLen
,
"%s,"
,
p
Table
MetaInfo
->
name
);
}
}
*
(
pMsg
+
payloadLen
)
=
'\0'
;
*
(
pMsg
+
payloadLen
)
=
'\0'
;
...
...
src/client/src/tscStream.c
浏览文件 @
03346d0c
...
@@ -13,15 +13,16 @@
...
@@ -13,15 +13,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include <tschemautil.h>
#include "os.h"
#include "os.h"
#include "taosmsg.h"
#include "tlog.h"
#include "tlog.h"
#include "tscUtil.h"
#include "tsched.h"
#include "tsclient.h"
#include "ttime.h"
#include "ttime.h"
#include "ttimer.h"
#include "ttimer.h"
#include "tutil.h"
#include "tutil.h"
#include "tsched.h"
#include "taosmsg.h"
#include "tscUtil.h"
#include "tsclient.h"
#include "tscProfile.h"
#include "tscProfile.h"
...
@@ -71,14 +72,14 @@ static void tscProcessStreamLaunchQuery(SSchedMsg *pMsg) {
...
@@ -71,14 +72,14 @@ static void tscProcessStreamLaunchQuery(SSchedMsg *pMsg) {
pSql
->
param
=
pStream
;
pSql
->
param
=
pStream
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
int
code
=
tscGetMeterMeta
(
pSql
,
p
Meter
MetaInfo
);
int
code
=
tscGetMeterMeta
(
pSql
,
p
Table
MetaInfo
);
pSql
->
res
.
code
=
code
;
pSql
->
res
.
code
=
code
;
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
return
;
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
return
;
if
(
code
==
0
&&
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
))
{
if
(
code
==
0
&&
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
))
{
code
=
tscGetMetricMeta
(
pSql
,
0
);
code
=
tscGetMetricMeta
(
pSql
,
0
);
pSql
->
res
.
code
=
code
;
pSql
->
res
.
code
=
code
;
...
@@ -96,7 +97,7 @@ static void tscProcessStreamLaunchQuery(SSchedMsg *pMsg) {
...
@@ -96,7 +97,7 @@ static void tscProcessStreamLaunchQuery(SSchedMsg *pMsg) {
return
;
return
;
}
}
tscTrace
(
"%p stream:%p start stream query on:%s"
,
pSql
,
pStream
,
p
Meter
MetaInfo
->
name
);
tscTrace
(
"%p stream:%p start stream query on:%s"
,
pSql
,
pStream
,
p
Table
MetaInfo
->
name
);
tscProcessSql
(
pStream
->
pSql
);
tscProcessSql
(
pStream
->
pSql
);
tscIncStreamExecutionCount
(
pStream
);
tscIncStreamExecutionCount
(
pStream
);
...
@@ -145,8 +146,8 @@ static void tscProcessStreamQueryCallback(void *param, TAOS_RES *tres, int numOf
...
@@ -145,8 +146,8 @@ static void tscProcessStreamQueryCallback(void *param, TAOS_RES *tres, int numOf
tscError
(
"%p stream:%p, query data failed, code:%d, retry in %"
PRId64
"ms"
,
pStream
->
pSql
,
pStream
,
numOfRows
,
tscError
(
"%p stream:%p, query data failed, code:%d, retry in %"
PRId64
"ms"
,
pStream
->
pSql
,
pStream
,
numOfRows
,
retryDelay
);
retryDelay
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
&
pStream
->
pSql
->
cmd
,
0
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
&
pStream
->
pSql
->
cmd
,
0
,
0
);
tscClearMeterMetaInfo
(
p
Meter
MetaInfo
,
true
);
tscClearMeterMetaInfo
(
p
Table
MetaInfo
,
true
);
tscSetRetryTimer
(
pStream
,
pStream
->
pSql
,
retryDelay
);
tscSetRetryTimer
(
pStream
,
pStream
->
pSql
,
retryDelay
);
return
;
return
;
...
@@ -171,12 +172,12 @@ static void tscSetTimestampForRes(SSqlStream *pStream, SSqlObj *pSql) {
...
@@ -171,12 +172,12 @@ static void tscSetTimestampForRes(SSqlStream *pStream, SSqlObj *pSql) {
static
void
tscProcessStreamRetrieveResult
(
void
*
param
,
TAOS_RES
*
res
,
int
numOfRows
)
{
static
void
tscProcessStreamRetrieveResult
(
void
*
param
,
TAOS_RES
*
res
,
int
numOfRows
)
{
SSqlStream
*
pStream
=
(
SSqlStream
*
)
param
;
SSqlStream
*
pStream
=
(
SSqlStream
*
)
param
;
SSqlObj
*
pSql
=
(
SSqlObj
*
)
res
;
SSqlObj
*
pSql
=
(
SSqlObj
*
)
res
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
);
if
(
pSql
==
NULL
||
numOfRows
<
0
)
{
if
(
pSql
==
NULL
||
numOfRows
<
0
)
{
int64_t
retryDelayTime
=
tscGetRetryDelayTime
(
pStream
->
slidingTime
,
pStream
->
precision
);
int64_t
retryDelayTime
=
tscGetRetryDelayTime
(
pStream
->
slidingTime
,
pStream
->
precision
);
tscError
(
"%p stream:%p, retrieve data failed, code:%d, retry in %"
PRId64
"ms"
,
pSql
,
pStream
,
numOfRows
,
retryDelayTime
);
tscError
(
"%p stream:%p, retrieve data failed, code:%d, retry in %"
PRId64
"ms"
,
pSql
,
pStream
,
numOfRows
,
retryDelayTime
);
tscClearMeterMetaInfo
(
p
Meter
MetaInfo
,
true
);
tscClearMeterMetaInfo
(
p
Table
MetaInfo
,
true
);
tscSetRetryTimer
(
pStream
,
pStream
->
pSql
,
retryDelayTime
);
tscSetRetryTimer
(
pStream
,
pStream
->
pSql
,
retryDelayTime
);
return
;
return
;
...
@@ -254,11 +255,11 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
...
@@ -254,11 +255,11 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
}
}
}
}
tscTrace
(
"%p stream:%p, query on:%s, fetch result completed, fetched rows:%d"
,
pSql
,
pStream
,
p
Meter
MetaInfo
->
name
,
tscTrace
(
"%p stream:%p, query on:%s, fetch result completed, fetched rows:%d"
,
pSql
,
pStream
,
p
Table
MetaInfo
->
name
,
pStream
->
numOfRes
);
pStream
->
numOfRes
);
// release the metric/meter meta information reference, so data in cache can be updated
// release the metric/meter meta information reference, so data in cache can be updated
tscClearMeterMetaInfo
(
p
Meter
MetaInfo
,
false
);
tscClearMeterMetaInfo
(
p
Table
MetaInfo
,
false
);
tscSetNextLaunchTimer
(
pStream
,
pSql
);
tscSetNextLaunchTimer
(
pStream
,
pSql
);
}
}
}
}
...
@@ -539,13 +540,14 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
...
@@ -539,13 +540,14 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
}
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
pStream
->
fp
=
fp
;
pStream
->
fp
=
fp
;
pStream
->
callback
=
callback
;
pStream
->
callback
=
callback
;
pStream
->
param
=
param
;
pStream
->
param
=
param
;
pStream
->
pSql
=
pSql
;
pStream
->
pSql
=
pSql
;
pStream
->
precision
=
pMeterMetaInfo
->
pMeterMeta
->
precision
;
pStream
->
precision
=
tinfo
.
precision
;
pStream
->
ctime
=
taosGetTimestamp
(
pStream
->
precision
);
pStream
->
ctime
=
taosGetTimestamp
(
pStream
->
precision
);
pStream
->
etime
=
pQueryInfo
->
etime
;
pStream
->
etime
=
pQueryInfo
->
etime
;
...
@@ -560,7 +562,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
...
@@ -560,7 +562,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
taosTmrReset
(
tscProcessStreamTimer
,
starttime
,
pStream
,
tscTmr
,
&
pStream
->
pTimer
);
taosTmrReset
(
tscProcessStreamTimer
,
starttime
,
pStream
,
tscTmr
,
&
pStream
->
pTimer
);
tscTrace
(
"%p stream:%p is opened, query on:%s, interval:%"
PRId64
", sliding:%"
PRId64
", first launched in:%"
PRId64
", sql:%s"
,
pSql
,
tscTrace
(
"%p stream:%p is opened, query on:%s, interval:%"
PRId64
", sliding:%"
PRId64
", first launched in:%"
PRId64
", sql:%s"
,
pSql
,
pStream
,
p
Meter
MetaInfo
->
name
,
pStream
->
interval
,
pStream
->
slidingTime
,
starttime
,
sqlstr
);
pStream
,
p
Table
MetaInfo
->
name
,
pStream
->
interval
,
pStream
->
slidingTime
,
starttime
,
sqlstr
);
return
pStream
;
return
pStream
;
}
}
...
...
src/client/src/tscSub.c
浏览文件 @
03346d0c
...
@@ -175,10 +175,10 @@ int tscUpdateSubscription(STscObj* pObj, SSub* pSub) {
...
@@ -175,10 +175,10 @@ int tscUpdateSubscription(STscObj* pObj, SSub* pSub) {
return
0
;
return
0
;
}
}
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
0
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
0
,
0
);
int
numOfTables
=
0
;
int
numOfTables
=
0
;
if
(
!
UTIL_METER_IS_NOMRAL_METER
(
p
Meter
MetaInfo
))
{
if
(
!
UTIL_METER_IS_NOMRAL_METER
(
p
Table
MetaInfo
))
{
SSuperTableMeta
*
pMetricMeta
=
p
Meter
MetaInfo
->
pMetricMeta
;
SSuperTableMeta
*
pMetricMeta
=
p
Table
MetaInfo
->
pMetricMeta
;
for
(
int32_t
i
=
0
;
i
<
pMetricMeta
->
numOfVnodes
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
pMetricMeta
->
numOfVnodes
;
i
++
)
{
SVnodeSidList
*
pVnodeSidList
=
tscGetVnodeSidList
(
pMetricMeta
,
i
);
SVnodeSidList
*
pVnodeSidList
=
tscGetVnodeSidList
(
pMetricMeta
,
i
);
numOfTables
+=
pVnodeSidList
->
numOfSids
;
numOfTables
+=
pVnodeSidList
->
numOfSids
;
...
@@ -191,13 +191,13 @@ int tscUpdateSubscription(STscObj* pObj, SSub* pSub) {
...
@@ -191,13 +191,13 @@ int tscUpdateSubscription(STscObj* pObj, SSub* pSub) {
return
0
;
return
0
;
}
}
if
(
UTIL_METER_IS_NOMRAL_METER
(
p
Meter
MetaInfo
))
{
if
(
UTIL_METER_IS_NOMRAL_METER
(
p
Table
MetaInfo
))
{
numOfTables
=
1
;
numOfTables
=
1
;
int64_t
uid
=
p
MeterMetaInfo
->
pMeter
Meta
->
uid
;
int64_t
uid
=
p
TableMetaInfo
->
pTable
Meta
->
uid
;
progress
[
0
].
uid
=
uid
;
progress
[
0
].
uid
=
uid
;
progress
[
0
].
key
=
tscGetSubscriptionProgress
(
pSub
,
uid
);
progress
[
0
].
key
=
tscGetSubscriptionProgress
(
pSub
,
uid
);
}
else
{
}
else
{
SSuperTableMeta
*
pMetricMeta
=
p
Meter
MetaInfo
->
pMetricMeta
;
SSuperTableMeta
*
pMetricMeta
=
p
Table
MetaInfo
->
pMetricMeta
;
numOfTables
=
0
;
numOfTables
=
0
;
for
(
int32_t
i
=
0
;
i
<
pMetricMeta
->
numOfVnodes
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
pMetricMeta
->
numOfVnodes
;
i
++
)
{
SVnodeSidList
*
pVnodeSidList
=
tscGetVnodeSidList
(
pMetricMeta
,
i
);
SVnodeSidList
*
pVnodeSidList
=
tscGetVnodeSidList
(
pMetricMeta
,
i
);
...
...
src/client/src/tscUtil.c
浏览文件 @
03346d0c
...
@@ -40,12 +40,12 @@
...
@@ -40,12 +40,12 @@
*/
*/
void
tscGetMetricMetaCacheKey
(
SQueryInfo
*
pQueryInfo
,
char
*
str
,
uint64_t
uid
)
{
void
tscGetMetricMetaCacheKey
(
SQueryInfo
*
pQueryInfo
,
char
*
str
,
uint64_t
uid
)
{
int32_t
index
=
-
1
;
int32_t
index
=
-
1
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoByUid
(
pQueryInfo
,
uid
,
&
index
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoByUid
(
pQueryInfo
,
uid
,
&
index
);
int32_t
len
=
0
;
int32_t
len
=
0
;
char
tagIdBuf
[
128
]
=
{
0
};
char
tagIdBuf
[
128
]
=
{
0
};
for
(
int32_t
i
=
0
;
i
<
p
Meter
MetaInfo
->
numOfTags
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
p
Table
MetaInfo
->
numOfTags
;
++
i
)
{
len
+=
sprintf
(
&
tagIdBuf
[
len
],
"%d,"
,
p
Meter
MetaInfo
->
tagColumnIndex
[
i
]);
len
+=
sprintf
(
&
tagIdBuf
[
len
],
"%d,"
,
p
Table
MetaInfo
->
tagColumnIndex
[
i
]);
}
}
STagCond
*
pTagCond
=
&
pQueryInfo
->
tagCond
;
STagCond
*
pTagCond
=
&
pQueryInfo
->
tagCond
;
...
@@ -64,7 +64,7 @@ void tscGetMetricMetaCacheKey(SQueryInfo* pQueryInfo, char* str, uint64_t uid) {
...
@@ -64,7 +64,7 @@ void tscGetMetricMetaCacheKey(SQueryInfo* pQueryInfo, char* str, uint64_t uid) {
size_t
tbnameCondLen
=
pTagCond
->
tbnameCond
.
cond
!=
NULL
?
strlen
(
pTagCond
->
tbnameCond
.
cond
)
:
0
;
size_t
tbnameCondLen
=
pTagCond
->
tbnameCond
.
cond
!=
NULL
?
strlen
(
pTagCond
->
tbnameCond
.
cond
)
:
0
;
size_t
redundantLen
=
20
;
size_t
redundantLen
=
20
;
size_t
bufSize
=
strlen
(
p
Meter
MetaInfo
->
name
)
+
tbnameCondLen
+
strlen
(
join
)
+
strlen
(
tagIdBuf
);
size_t
bufSize
=
strlen
(
p
Table
MetaInfo
->
name
)
+
tbnameCondLen
+
strlen
(
join
)
+
strlen
(
tagIdBuf
);
if
(
cond
!=
NULL
&&
cond
->
cond
!=
NULL
)
{
if
(
cond
!=
NULL
&&
cond
->
cond
!=
NULL
)
{
bufSize
+=
strlen
(
cond
->
cond
);
bufSize
+=
strlen
(
cond
->
cond
);
}
}
...
@@ -72,7 +72,7 @@ void tscGetMetricMetaCacheKey(SQueryInfo* pQueryInfo, char* str, uint64_t uid) {
...
@@ -72,7 +72,7 @@ void tscGetMetricMetaCacheKey(SQueryInfo* pQueryInfo, char* str, uint64_t uid) {
bufSize
=
(
size_t
)((
bufSize
+
redundantLen
)
*
1
.
5
);
bufSize
=
(
size_t
)((
bufSize
+
redundantLen
)
*
1
.
5
);
char
*
tmp
=
calloc
(
1
,
bufSize
);
char
*
tmp
=
calloc
(
1
,
bufSize
);
int32_t
keyLen
=
snprintf
(
tmp
,
bufSize
,
"%s,%s,%s,%d,%s,[%s],%d"
,
p
Meter
MetaInfo
->
name
,
int32_t
keyLen
=
snprintf
(
tmp
,
bufSize
,
"%s,%s,%s,%d,%s,[%s],%d"
,
p
Table
MetaInfo
->
name
,
((
cond
!=
NULL
&&
cond
->
cond
!=
NULL
)
?
cond
->
cond
:
NULL
),
(
tbnameCondLen
>
0
?
pTagCond
->
tbnameCond
.
cond
:
NULL
),
((
cond
!=
NULL
&&
cond
->
cond
!=
NULL
)
?
cond
->
cond
:
NULL
),
(
tbnameCondLen
>
0
?
pTagCond
->
tbnameCond
.
cond
:
NULL
),
pTagCond
->
relType
,
join
,
tagIdBuf
,
pQueryInfo
->
groupbyExpr
.
orderType
);
pTagCond
->
relType
,
join
,
tagIdBuf
,
pQueryInfo
->
groupbyExpr
.
orderType
);
...
@@ -214,17 +214,17 @@ bool tscIsTwoStageMergeMetricQuery(SQueryInfo* pQueryInfo, int32_t tableIndex) {
...
@@ -214,17 +214,17 @@ bool tscIsTwoStageMergeMetricQuery(SQueryInfo* pQueryInfo, int32_t tableIndex) {
return
false
;
return
false
;
}
}
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
tableIndex
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
tableIndex
);
if
(
p
Meter
MetaInfo
==
NULL
)
{
if
(
p
Table
MetaInfo
==
NULL
)
{
return
false
;
return
false
;
}
}
// for select query super table, the metricmeta can not be null in any cases.
// for select query super table, the metricmeta can not be null in any cases.
if
(
pQueryInfo
->
command
==
TSDB_SQL_SELECT
&&
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
))
{
if
(
pQueryInfo
->
command
==
TSDB_SQL_SELECT
&&
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
))
{
assert
(
p
Meter
MetaInfo
->
pMetricMeta
!=
NULL
);
assert
(
p
Table
MetaInfo
->
pMetricMeta
!=
NULL
);
}
}
if
(
p
Meter
MetaInfo
->
pMetricMeta
==
NULL
)
{
if
(
p
Table
MetaInfo
->
pMetricMeta
==
NULL
)
{
return
false
;
return
false
;
}
}
...
@@ -239,21 +239,21 @@ bool tscIsTwoStageMergeMetricQuery(SQueryInfo* pQueryInfo, int32_t tableIndex) {
...
@@ -239,21 +239,21 @@ bool tscIsTwoStageMergeMetricQuery(SQueryInfo* pQueryInfo, int32_t tableIndex) {
if
(((
pQueryInfo
->
type
&
TSDB_QUERY_TYPE_STABLE_SUBQUERY
)
!=
TSDB_QUERY_TYPE_STABLE_SUBQUERY
)
&&
if
(((
pQueryInfo
->
type
&
TSDB_QUERY_TYPE_STABLE_SUBQUERY
)
!=
TSDB_QUERY_TYPE_STABLE_SUBQUERY
)
&&
pQueryInfo
->
command
==
TSDB_SQL_SELECT
)
{
pQueryInfo
->
command
==
TSDB_SQL_SELECT
)
{
return
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
);
return
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
);
}
}
return
false
;
return
false
;
}
}
bool
tscIsProjectionQueryOnSTable
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
)
{
bool
tscIsProjectionQueryOnSTable
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
tableIndex
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
tableIndex
);
/*
/*
* In following cases, return false for non ordered project query on super table
* In following cases, return false for non ordered project query on super table
* 1. failed to get metermeta from server; 2. not a super table; 3. limitation is 0;
* 1. failed to get metermeta from server; 2. not a super table; 3. limitation is 0;
* 4. show queries, instead of a select query
* 4. show queries, instead of a select query
*/
*/
if
(
p
MeterMetaInfo
==
NULL
||
!
UTIL_METER_IS_SUPERTABLE
(
pMeter
MetaInfo
)
||
if
(
p
TableMetaInfo
==
NULL
||
!
UTIL_METER_IS_SUPERTABLE
(
pTable
MetaInfo
)
||
pQueryInfo
->
command
==
TSDB_SQL_RETRIEVE_EMPTY_RESULT
||
pQueryInfo
->
exprsInfo
.
numOfExprs
==
0
)
{
pQueryInfo
->
command
==
TSDB_SQL_RETRIEVE_EMPTY_RESULT
||
pQueryInfo
->
exprsInfo
.
numOfExprs
==
0
)
{
return
false
;
return
false
;
}
}
...
@@ -505,7 +505,7 @@ void tscDestroyDataBlock(STableDataBlocks* pDataBlock) {
...
@@ -505,7 +505,7 @@ void tscDestroyDataBlock(STableDataBlocks* pDataBlock) {
tfree
(
pDataBlock
->
params
);
tfree
(
pDataBlock
->
params
);
// free the refcount for metermeta
// free the refcount for metermeta
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
pDataBlock
->
p
Meter
Meta
),
false
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
pDataBlock
->
p
Table
Meta
),
false
);
tfree
(
pDataBlock
);
tfree
(
pDataBlock
);
}
}
...
@@ -579,21 +579,21 @@ void* tscDestroyBlockArrayList(SDataBlockList* pList) {
...
@@ -579,21 +579,21 @@ void* tscDestroyBlockArrayList(SDataBlockList* pList) {
int32_t
tscCopyDataBlockToPayload
(
SSqlObj
*
pSql
,
STableDataBlocks
*
pDataBlock
)
{
int32_t
tscCopyDataBlockToPayload
(
SSqlObj
*
pSql
,
STableDataBlocks
*
pDataBlock
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
assert
(
pDataBlock
->
p
Meter
Meta
!=
NULL
);
assert
(
pDataBlock
->
p
Table
Meta
!=
NULL
);
pCmd
->
numOfTablesInSubmit
=
pDataBlock
->
numOfTables
;
pCmd
->
numOfTablesInSubmit
=
pDataBlock
->
numOfTables
;
assert
(
pCmd
->
numOfClause
==
1
);
assert
(
pCmd
->
numOfClause
==
1
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
// set the correct metermeta object, the metermeta has been locked in pDataBlocks, so it must be in the cache
// set the correct metermeta object, the metermeta has been locked in pDataBlocks, so it must be in the cache
if
(
p
MeterMetaInfo
->
pMeterMeta
!=
pDataBlock
->
pMeter
Meta
)
{
if
(
p
TableMetaInfo
->
pTableMeta
!=
pDataBlock
->
pTable
Meta
)
{
strcpy
(
p
Meter
MetaInfo
->
name
,
pDataBlock
->
tableId
);
strcpy
(
p
Table
MetaInfo
->
name
,
pDataBlock
->
tableId
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
MeterMetaInfo
->
pMeter
Meta
),
false
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
TableMetaInfo
->
pTable
Meta
),
false
);
p
MeterMetaInfo
->
pMeterMeta
=
taosCacheTransfer
(
tscCacheHandle
,
(
void
**
)
&
pDataBlock
->
pMeter
Meta
);
p
TableMetaInfo
->
pTableMeta
=
taosCacheTransfer
(
tscCacheHandle
,
(
void
**
)
&
pDataBlock
->
pTable
Meta
);
}
else
{
}
else
{
assert
(
strncmp
(
p
Meter
MetaInfo
->
name
,
pDataBlock
->
tableId
,
tListLen
(
pDataBlock
->
tableId
))
==
0
);
assert
(
strncmp
(
p
Table
MetaInfo
->
name
,
pDataBlock
->
tableId
,
tListLen
(
pDataBlock
->
tableId
))
==
0
);
}
}
/*
/*
...
@@ -637,7 +637,7 @@ void tscFreeUnusedDataBlocks(SDataBlockList* pList) {
...
@@ -637,7 +637,7 @@ void tscFreeUnusedDataBlocks(SDataBlockList* pList) {
* @return
* @return
*/
*/
int32_t
tscCreateDataBlock
(
size_t
initialSize
,
int32_t
rowSize
,
int32_t
startOffset
,
const
char
*
name
,
int32_t
tscCreateDataBlock
(
size_t
initialSize
,
int32_t
rowSize
,
int32_t
startOffset
,
const
char
*
name
,
STableMeta
*
p
Meter
Meta
,
STableDataBlocks
**
dataBlocks
)
{
STableMeta
*
p
Table
Meta
,
STableDataBlocks
**
dataBlocks
)
{
STableDataBlocks
*
dataBuf
=
(
STableDataBlocks
*
)
calloc
(
1
,
sizeof
(
STableDataBlocks
));
STableDataBlocks
*
dataBuf
=
(
STableDataBlocks
*
)
calloc
(
1
,
sizeof
(
STableDataBlocks
));
if
(
dataBuf
==
NULL
)
{
if
(
dataBuf
==
NULL
)
{
tscError
(
"failed to allocated memory, reason:%s"
,
strerror
(
errno
));
tscError
(
"failed to allocated memory, reason:%s"
,
strerror
(
errno
));
...
@@ -665,15 +665,15 @@ int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOff
...
@@ -665,15 +665,15 @@ int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOff
* due to operation such as drop database. So here we add the reference count directly instead of invoke
* due to operation such as drop database. So here we add the reference count directly instead of invoke
* taosGetDataFromCache, which may return NULL value.
* taosGetDataFromCache, which may return NULL value.
*/
*/
dataBuf
->
p
MeterMeta
=
taosCacheAcquireByData
(
tscCacheHandle
,
pMeter
Meta
);
dataBuf
->
p
TableMeta
=
taosCacheAcquireByData
(
tscCacheHandle
,
pTable
Meta
);
assert
(
initialSize
>
0
&&
p
MeterMeta
!=
NULL
&&
dataBuf
->
pMeter
Meta
!=
NULL
);
assert
(
initialSize
>
0
&&
p
TableMeta
!=
NULL
&&
dataBuf
->
pTable
Meta
!=
NULL
);
*
dataBlocks
=
dataBuf
;
*
dataBlocks
=
dataBuf
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
tscGetDataBlockFromList
(
void
*
pHashList
,
SDataBlockList
*
pDataBlockList
,
int64_t
id
,
int32_t
size
,
int32_t
tscGetDataBlockFromList
(
void
*
pHashList
,
SDataBlockList
*
pDataBlockList
,
int64_t
id
,
int32_t
size
,
int32_t
startOffset
,
int32_t
rowSize
,
const
char
*
tableId
,
STableMeta
*
p
Meter
Meta
,
int32_t
startOffset
,
int32_t
rowSize
,
const
char
*
tableId
,
STableMeta
*
p
Table
Meta
,
STableDataBlocks
**
dataBlocks
)
{
STableDataBlocks
**
dataBlocks
)
{
*
dataBlocks
=
NULL
;
*
dataBlocks
=
NULL
;
...
@@ -683,7 +683,7 @@ int32_t tscGetDataBlockFromList(void* pHashList, SDataBlockList* pDataBlockList,
...
@@ -683,7 +683,7 @@ int32_t tscGetDataBlockFromList(void* pHashList, SDataBlockList* pDataBlockList,
}
}
if
(
*
dataBlocks
==
NULL
)
{
if
(
*
dataBlocks
==
NULL
)
{
int32_t
ret
=
tscCreateDataBlock
((
size_t
)
size
,
rowSize
,
startOffset
,
tableId
,
p
Meter
Meta
,
dataBlocks
);
int32_t
ret
=
tscCreateDataBlock
((
size_t
)
size
,
rowSize
,
startOffset
,
tableId
,
p
Table
Meta
,
dataBlocks
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
return
ret
;
}
}
...
@@ -707,7 +707,7 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, SDataBlockList* pTableDataBlockLi
...
@@ -707,7 +707,7 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, SDataBlockList* pTableDataBlockLi
STableDataBlocks
*
dataBuf
=
NULL
;
STableDataBlocks
*
dataBuf
=
NULL
;
int32_t
ret
=
int32_t
ret
=
tscGetDataBlockFromList
(
pVnodeDataBlockHashList
,
pVnodeDataBlockList
,
pOneTableBlock
->
vgid
,
TSDB_PAYLOAD_SIZE
,
tscGetDataBlockFromList
(
pVnodeDataBlockHashList
,
pVnodeDataBlockList
,
pOneTableBlock
->
vgid
,
TSDB_PAYLOAD_SIZE
,
tsInsertHeadSize
,
0
,
pOneTableBlock
->
tableId
,
pOneTableBlock
->
p
Meter
Meta
,
&
dataBuf
);
tsInsertHeadSize
,
0
,
pOneTableBlock
->
tableId
,
pOneTableBlock
->
p
Table
Meta
,
&
dataBuf
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"%p failed to prepare the data block buffer for merging table data, code:%d"
,
pSql
,
ret
);
tscError
(
"%p failed to prepare the data block buffer for merging table data, code:%d"
,
pSql
,
ret
);
taosHashCleanup
(
pVnodeDataBlockHashList
);
taosHashCleanup
(
pVnodeDataBlockHashList
);
...
@@ -1116,7 +1116,7 @@ SSqlExpr* tscSqlExprInsertEmpty(SQueryInfo* pQueryInfo, int32_t index, int16_t f
...
@@ -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
,
SSqlExpr
*
tscSqlExprInsert
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
,
int16_t
functionId
,
SColumnIndex
*
pColIndex
,
int16_t
type
,
int16_t
size
,
int16_t
interSize
)
{
int16_t
type
,
int16_t
size
,
int16_t
interSize
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
pColIndex
->
tableIndex
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
pColIndex
->
tableIndex
);
SSqlExprInfo
*
pExprInfo
=
&
pQueryInfo
->
exprsInfo
;
SSqlExprInfo
*
pExprInfo
=
&
pQueryInfo
->
exprsInfo
;
...
@@ -1127,13 +1127,13 @@ SSqlExpr* tscSqlExprInsert(SQueryInfo* pQueryInfo, int32_t index, int16_t functi
...
@@ -1127,13 +1127,13 @@ SSqlExpr* tscSqlExprInsert(SQueryInfo* pQueryInfo, int32_t index, int16_t functi
pExprInfo
->
pExprs
[
index
]
=
pExpr
;
pExprInfo
->
pExprs
[
index
]
=
pExpr
;
pExpr
->
functionId
=
functionId
;
pExpr
->
functionId
=
functionId
;
int16_t
numOfCols
=
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
;
int16_t
numOfCols
=
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
)
;
// set the correct column index
// set the correct column index
if
(
pColIndex
->
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
if
(
pColIndex
->
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
pExpr
->
colInfo
.
colId
=
TSDB_TBNAME_COLUMN_INDEX
;
pExpr
->
colInfo
.
colId
=
TSDB_TBNAME_COLUMN_INDEX
;
}
else
{
}
else
{
SSchema
*
pSchema
=
ts
GetColumnSchema
(
pMeterMetaInfo
->
pMeter
Meta
,
pColIndex
->
columnIndex
);
SSchema
*
pSchema
=
ts
cGetTableColumnSchema
(
pTableMetaInfo
->
pTable
Meta
,
pColIndex
->
columnIndex
);
pExpr
->
colInfo
.
colId
=
pSchema
->
colId
;
pExpr
->
colInfo
.
colId
=
pSchema
->
colId
;
}
}
...
@@ -1153,7 +1153,7 @@ SSqlExpr* tscSqlExprInsert(SQueryInfo* pQueryInfo, int32_t index, int16_t functi
...
@@ -1153,7 +1153,7 @@ SSqlExpr* tscSqlExprInsert(SQueryInfo* pQueryInfo, int32_t index, int16_t functi
pExpr
->
resType
=
type
;
pExpr
->
resType
=
type
;
pExpr
->
resBytes
=
size
;
pExpr
->
resBytes
=
size
;
pExpr
->
interResBytes
=
interSize
;
pExpr
->
interResBytes
=
interSize
;
pExpr
->
uid
=
p
MeterMetaInfo
->
pMeter
Meta
->
uid
;
pExpr
->
uid
=
p
TableMetaInfo
->
pTable
Meta
->
uid
;
pExprInfo
->
numOfExprs
++
;
pExprInfo
->
numOfExprs
++
;
return
pExpr
;
return
pExpr
;
...
@@ -1161,7 +1161,7 @@ SSqlExpr* tscSqlExprInsert(SQueryInfo* pQueryInfo, int32_t index, int16_t functi
...
@@ -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
,
SSqlExpr
*
tscSqlExprUpdate
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
,
int16_t
functionId
,
int16_t
srcColumnIndex
,
int16_t
type
,
int16_t
size
)
{
int16_t
type
,
int16_t
size
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
SSqlExprInfo
*
pExprInfo
=
&
pQueryInfo
->
exprsInfo
;
SSqlExprInfo
*
pExprInfo
=
&
pQueryInfo
->
exprsInfo
;
if
(
index
>
pExprInfo
->
numOfExprs
)
{
if
(
index
>
pExprInfo
->
numOfExprs
)
{
return
NULL
;
return
NULL
;
...
@@ -1172,7 +1172,7 @@ SSqlExpr* tscSqlExprUpdate(SQueryInfo* pQueryInfo, int32_t index, int16_t functi
...
@@ -1172,7 +1172,7 @@ SSqlExpr* tscSqlExprUpdate(SQueryInfo* pQueryInfo, int32_t index, int16_t functi
pExpr
->
functionId
=
functionId
;
pExpr
->
functionId
=
functionId
;
pExpr
->
colInfo
.
colIdx
=
srcColumnIndex
;
pExpr
->
colInfo
.
colIdx
=
srcColumnIndex
;
pExpr
->
colInfo
.
colId
=
ts
GetColumnSchema
(
pMeterMetaInfo
->
pMeter
Meta
,
srcColumnIndex
)
->
colId
;
pExpr
->
colInfo
.
colId
=
ts
cGetTableColumnSchema
(
pTableMetaInfo
->
pTable
Meta
,
srcColumnIndex
)
->
colId
;
pExpr
->
resType
=
type
;
pExpr
->
resType
=
type
;
pExpr
->
resBytes
=
size
;
pExpr
->
resBytes
=
size
;
...
@@ -1573,17 +1573,19 @@ void tscIncStreamExecutionCount(void* pStream) {
...
@@ -1573,17 +1573,19 @@ void tscIncStreamExecutionCount(void* pStream) {
ps
->
num
+=
1
;
ps
->
num
+=
1
;
}
}
bool
tscValidateColumnId
(
S
MeterMetaInfo
*
pMeter
MetaInfo
,
int32_t
colId
)
{
bool
tscValidateColumnId
(
S
TableMetaInfo
*
pTable
MetaInfo
,
int32_t
colId
)
{
if
(
p
MeterMetaInfo
->
pMeter
Meta
==
NULL
)
{
if
(
p
TableMetaInfo
->
pTable
Meta
==
NULL
)
{
return
false
;
return
false
;
}
}
if
(
colId
==
-
1
&&
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
))
{
if
(
colId
==
-
1
&&
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
))
{
return
true
;
return
true
;
}
}
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMetaInfo
->
pTableMeta
);
int32_t
numOfTotal
=
pMeterMetaInfo
->
pMeterMeta
->
numOfTags
+
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
;
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
int32_t
numOfTotal
=
tinfo
.
numOfTags
+
tinfo
.
numOfColumns
;
for
(
int32_t
i
=
0
;
i
<
numOfTotal
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfTotal
;
++
i
)
{
if
(
pSchema
[
i
].
colId
==
colId
)
{
if
(
pSchema
[
i
].
colId
==
colId
)
{
...
@@ -1627,16 +1629,16 @@ void tscTagCondRelease(STagCond* pCond) {
...
@@ -1627,16 +1629,16 @@ void tscTagCondRelease(STagCond* pCond) {
}
}
void
tscGetSrcColumnInfo
(
SSrcColumnInfo
*
pColInfo
,
SQueryInfo
*
pQueryInfo
)
{
void
tscGetSrcColumnInfo
(
SSrcColumnInfo
*
pColInfo
,
SQueryInfo
*
pQueryInfo
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
SSchema
*
pSchema
=
ts
GetSchema
(
pMeterMetaInfo
->
pMeter
Meta
);
SSchema
*
pSchema
=
ts
cGetTableSchema
(
pTableMetaInfo
->
pTable
Meta
);
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
pColInfo
[
i
].
functionId
=
pExpr
->
functionId
;
pColInfo
[
i
].
functionId
=
pExpr
->
functionId
;
if
(
TSDB_COL_IS_TAG
(
pExpr
->
colInfo
.
flag
))
{
if
(
TSDB_COL_IS_TAG
(
pExpr
->
colInfo
.
flag
))
{
SSchema
*
pTagSchema
=
ts
GetTagSchema
(
pMeterMetaInfo
->
pMeter
Meta
);
SSchema
*
pTagSchema
=
ts
cGetTableTagSchema
(
pTableMetaInfo
->
pTable
Meta
);
int16_t
actualTagIndex
=
p
Meter
MetaInfo
->
tagColumnIndex
[
pExpr
->
colInfo
.
colIdx
];
int16_t
actualTagIndex
=
p
Table
MetaInfo
->
tagColumnIndex
[
pExpr
->
colInfo
.
colIdx
];
pColInfo
[
i
].
type
=
(
actualTagIndex
!=
-
1
)
?
pTagSchema
[
actualTagIndex
].
type
:
TSDB_DATA_TYPE_BINARY
;
pColInfo
[
i
].
type
=
(
actualTagIndex
!=
-
1
)
?
pTagSchema
[
actualTagIndex
].
type
:
TSDB_DATA_TYPE_BINARY
;
}
else
{
}
else
{
...
@@ -1723,10 +1725,10 @@ bool tscShouldFreeAsyncSqlObj(SSqlObj* pSql) {
...
@@ -1723,10 +1725,10 @@ bool tscShouldFreeAsyncSqlObj(SSqlObj* pSql) {
SDataBlockList
*
pDataBlocks
=
pCmd
->
pDataBlocks
;
SDataBlockList
*
pDataBlocks
=
pCmd
->
pDataBlocks
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
assert
(
pQueryInfo
->
numOfTables
==
1
||
pQueryInfo
->
numOfTables
==
2
);
assert
(
pQueryInfo
->
numOfTables
==
1
||
pQueryInfo
->
numOfTables
==
2
);
if
(
pDataBlocks
==
NULL
||
p
Meter
MetaInfo
->
vnodeIndex
>=
pDataBlocks
->
nSize
)
{
if
(
pDataBlocks
==
NULL
||
p
Table
MetaInfo
->
vnodeIndex
>=
pDataBlocks
->
nSize
)
{
tscTrace
(
"%p object should be release since all data blocks have been submit"
,
pSql
);
tscTrace
(
"%p object should be release since all data blocks have been submit"
,
pSql
);
return
true
;
return
true
;
}
else
{
}
else
{
...
@@ -1745,7 +1747,7 @@ bool tscShouldFreeAsyncSqlObj(SSqlObj* pSql) {
...
@@ -1745,7 +1747,7 @@ bool tscShouldFreeAsyncSqlObj(SSqlObj* pSql) {
* @param tableIndex denote the table index for join query, where more than one table exists
* @param tableIndex denote the table index for join query, where more than one table exists
* @return
* @return
*/
*/
S
Meter
MetaInfo
*
tscGetMeterMetaInfo
(
SSqlCmd
*
pCmd
,
int32_t
clauseIndex
,
int32_t
tableIndex
)
{
S
Table
MetaInfo
*
tscGetMeterMetaInfo
(
SSqlCmd
*
pCmd
,
int32_t
clauseIndex
,
int32_t
tableIndex
)
{
if
(
pCmd
==
NULL
||
pCmd
->
numOfClause
==
0
)
{
if
(
pCmd
==
NULL
||
pCmd
->
numOfClause
==
0
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -1756,7 +1758,7 @@ SMeterMetaInfo* tscGetMeterMetaInfo(SSqlCmd* pCmd, int32_t clauseIndex, int32_t
...
@@ -1756,7 +1758,7 @@ SMeterMetaInfo* tscGetMeterMetaInfo(SSqlCmd* pCmd, int32_t clauseIndex, int32_t
return
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
tableIndex
);
return
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
tableIndex
);
}
}
S
Meter
MetaInfo
*
tscGetMeterMetaInfoFromQueryInfo
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
)
{
S
Table
MetaInfo
*
tscGetMeterMetaInfoFromQueryInfo
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
)
{
assert
(
pQueryInfo
!=
NULL
);
assert
(
pQueryInfo
!=
NULL
);
if
(
pQueryInfo
->
pMeterInfo
==
NULL
)
{
if
(
pQueryInfo
->
pMeterInfo
==
NULL
)
{
...
@@ -1795,11 +1797,11 @@ int32_t tscGetQueryInfoDetailSafely(SSqlCmd* pCmd, int32_t subClauseIndex, SQuer
...
@@ -1795,11 +1797,11 @@ int32_t tscGetQueryInfoDetailSafely(SSqlCmd* pCmd, int32_t subClauseIndex, SQuer
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
S
Meter
MetaInfo
*
tscGetMeterMetaInfoByUid
(
SQueryInfo
*
pQueryInfo
,
uint64_t
uid
,
int32_t
*
index
)
{
S
Table
MetaInfo
*
tscGetMeterMetaInfoByUid
(
SQueryInfo
*
pQueryInfo
,
uint64_t
uid
,
int32_t
*
index
)
{
int32_t
k
=
-
1
;
int32_t
k
=
-
1
;
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
if
(
pQueryInfo
->
pMeterInfo
[
i
]
->
p
Meter
Meta
->
uid
==
uid
)
{
if
(
pQueryInfo
->
pMeterInfo
[
i
]
->
p
Table
Meta
->
uid
==
uid
)
{
k
=
i
;
k
=
i
;
break
;
break
;
}
}
...
@@ -1872,7 +1874,7 @@ void tscFreeSubqueryInfo(SSqlCmd* pCmd) {
...
@@ -1872,7 +1874,7 @@ void tscFreeSubqueryInfo(SSqlCmd* pCmd) {
tfree
(
pCmd
->
pQueryInfo
);
tfree
(
pCmd
->
pQueryInfo
);
}
}
S
MeterMetaInfo
*
tscAddMeterMetaInfo
(
SQueryInfo
*
pQueryInfo
,
const
char
*
name
,
STableMeta
*
pMeter
Meta
,
S
TableMetaInfo
*
tscAddMeterMetaInfo
(
SQueryInfo
*
pQueryInfo
,
const
char
*
name
,
STableMeta
*
pTable
Meta
,
SSuperTableMeta
*
pMetricMeta
,
int16_t
numOfTags
,
int16_t
*
tags
)
{
SSuperTableMeta
*
pMetricMeta
,
int16_t
numOfTags
,
int16_t
*
tags
)
{
void
*
pAlloc
=
realloc
(
pQueryInfo
->
pMeterInfo
,
(
pQueryInfo
->
numOfTables
+
1
)
*
POINTER_BYTES
);
void
*
pAlloc
=
realloc
(
pQueryInfo
->
pMeterInfo
,
(
pQueryInfo
->
numOfTables
+
1
)
*
POINTER_BYTES
);
if
(
pAlloc
==
NULL
)
{
if
(
pAlloc
==
NULL
)
{
...
@@ -1880,29 +1882,29 @@ SMeterMetaInfo* tscAddMeterMetaInfo(SQueryInfo* pQueryInfo, const char* name, ST
...
@@ -1880,29 +1882,29 @@ SMeterMetaInfo* tscAddMeterMetaInfo(SQueryInfo* pQueryInfo, const char* name, ST
}
}
pQueryInfo
->
pMeterInfo
=
pAlloc
;
pQueryInfo
->
pMeterInfo
=
pAlloc
;
pQueryInfo
->
pMeterInfo
[
pQueryInfo
->
numOfTables
]
=
calloc
(
1
,
sizeof
(
S
Meter
MetaInfo
));
pQueryInfo
->
pMeterInfo
[
pQueryInfo
->
numOfTables
]
=
calloc
(
1
,
sizeof
(
S
Table
MetaInfo
));
S
MeterMetaInfo
*
pMeter
MetaInfo
=
pQueryInfo
->
pMeterInfo
[
pQueryInfo
->
numOfTables
];
S
TableMetaInfo
*
pTable
MetaInfo
=
pQueryInfo
->
pMeterInfo
[
pQueryInfo
->
numOfTables
];
assert
(
p
Meter
MetaInfo
!=
NULL
);
assert
(
p
Table
MetaInfo
!=
NULL
);
if
(
name
!=
NULL
)
{
if
(
name
!=
NULL
)
{
assert
(
strlen
(
name
)
<=
TSDB_TABLE_ID_LEN
);
assert
(
strlen
(
name
)
<=
TSDB_TABLE_ID_LEN
);
strcpy
(
p
Meter
MetaInfo
->
name
,
name
);
strcpy
(
p
Table
MetaInfo
->
name
,
name
);
}
}
p
MeterMetaInfo
->
pMeterMeta
=
pMeter
Meta
;
p
TableMetaInfo
->
pTableMeta
=
pTable
Meta
;
p
Meter
MetaInfo
->
pMetricMeta
=
pMetricMeta
;
p
Table
MetaInfo
->
pMetricMeta
=
pMetricMeta
;
p
Meter
MetaInfo
->
numOfTags
=
numOfTags
;
p
Table
MetaInfo
->
numOfTags
=
numOfTags
;
if
(
tags
!=
NULL
)
{
if
(
tags
!=
NULL
)
{
memcpy
(
p
MeterMetaInfo
->
tagColumnIndex
,
tags
,
sizeof
(
pMeter
MetaInfo
->
tagColumnIndex
[
0
])
*
numOfTags
);
memcpy
(
p
TableMetaInfo
->
tagColumnIndex
,
tags
,
sizeof
(
pTable
MetaInfo
->
tagColumnIndex
[
0
])
*
numOfTags
);
}
}
pQueryInfo
->
numOfTables
+=
1
;
pQueryInfo
->
numOfTables
+=
1
;
return
p
Meter
MetaInfo
;
return
p
Table
MetaInfo
;
}
}
S
Meter
MetaInfo
*
tscAddEmptyMeterMetaInfo
(
SQueryInfo
*
pQueryInfo
)
{
S
Table
MetaInfo
*
tscAddEmptyMeterMetaInfo
(
SQueryInfo
*
pQueryInfo
)
{
return
tscAddMeterMetaInfo
(
pQueryInfo
,
NULL
,
NULL
,
NULL
,
0
,
NULL
);
return
tscAddMeterMetaInfo
(
pQueryInfo
,
NULL
,
NULL
,
NULL
,
0
,
NULL
);
}
}
...
@@ -1911,10 +1913,10 @@ void doRemoveMeterMetaInfo(SQueryInfo* pQueryInfo, int32_t index, bool removeFro
...
@@ -1911,10 +1913,10 @@ void doRemoveMeterMetaInfo(SQueryInfo* pQueryInfo, int32_t index, bool removeFro
return
;
return
;
}
}
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
);
tscClearMeterMetaInfo
(
p
Meter
MetaInfo
,
removeFromCache
);
tscClearMeterMetaInfo
(
p
Table
MetaInfo
,
removeFromCache
);
free
(
p
Meter
MetaInfo
);
free
(
p
Table
MetaInfo
);
int32_t
after
=
pQueryInfo
->
numOfTables
-
index
-
1
;
int32_t
after
=
pQueryInfo
->
numOfTables
-
index
-
1
;
if
(
after
>
0
)
{
if
(
after
>
0
)
{
...
@@ -1935,13 +1937,13 @@ void tscRemoveAllMeterMetaInfo(SQueryInfo* pQueryInfo, const char* address, bool
...
@@ -1935,13 +1937,13 @@ void tscRemoveAllMeterMetaInfo(SQueryInfo* pQueryInfo, const char* address, bool
tfree
(
pQueryInfo
->
pMeterInfo
);
tfree
(
pQueryInfo
->
pMeterInfo
);
}
}
void
tscClearMeterMetaInfo
(
S
MeterMetaInfo
*
pMeter
MetaInfo
,
bool
removeFromCache
)
{
void
tscClearMeterMetaInfo
(
S
TableMetaInfo
*
pTable
MetaInfo
,
bool
removeFromCache
)
{
if
(
p
Meter
MetaInfo
==
NULL
)
{
if
(
p
Table
MetaInfo
==
NULL
)
{
return
;
return
;
}
}
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
MeterMetaInfo
->
pMeter
Meta
),
removeFromCache
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
TableMetaInfo
->
pTable
Meta
),
removeFromCache
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
Meter
MetaInfo
->
pMetricMeta
),
removeFromCache
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
p
Table
MetaInfo
->
pMetricMeta
),
removeFromCache
);
}
}
void
tscResetForNextRetrieve
(
SSqlRes
*
pRes
)
{
void
tscResetForNextRetrieve
(
SSqlRes
*
pRes
)
{
...
@@ -1955,11 +1957,11 @@ void tscResetForNextRetrieve(SSqlRes* pRes) {
...
@@ -1955,11 +1957,11 @@ void tscResetForNextRetrieve(SSqlRes* pRes) {
SSqlObj
*
createSubqueryObj
(
SSqlObj
*
pSql
,
int16_t
tableIndex
,
void
(
*
fp
)(),
void
*
param
,
SSqlObj
*
pPrevSql
)
{
SSqlObj
*
createSubqueryObj
(
SSqlObj
*
pSql
,
int16_t
tableIndex
,
void
(
*
fp
)(),
void
*
param
,
SSqlObj
*
pPrevSql
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
tableIndex
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
tableIndex
);
SSqlObj
*
pNew
=
(
SSqlObj
*
)
calloc
(
1
,
sizeof
(
SSqlObj
));
SSqlObj
*
pNew
=
(
SSqlObj
*
)
calloc
(
1
,
sizeof
(
SSqlObj
));
if
(
pNew
==
NULL
)
{
if
(
pNew
==
NULL
)
{
tscError
(
"%p new subquery failed, tableIndex:%d, vnodeIndex:%d"
,
pSql
,
tableIndex
,
p
Meter
MetaInfo
->
vnodeIndex
);
tscError
(
"%p new subquery failed, tableIndex:%d, vnodeIndex:%d"
,
pSql
,
tableIndex
,
p
Table
MetaInfo
->
vnodeIndex
);
return
NULL
;
return
NULL
;
}
}
...
@@ -1968,7 +1970,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
...
@@ -1968,7 +1970,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
pNew
->
sqlstr
=
strdup
(
pSql
->
sqlstr
);
pNew
->
sqlstr
=
strdup
(
pSql
->
sqlstr
);
if
(
pNew
->
sqlstr
==
NULL
)
{
if
(
pNew
->
sqlstr
==
NULL
)
{
tscError
(
"%p new subquery failed, tableIndex:%d, vnodeIndex:%d"
,
pSql
,
tableIndex
,
p
Meter
MetaInfo
->
vnodeIndex
);
tscError
(
"%p new subquery failed, tableIndex:%d, vnodeIndex:%d"
,
pSql
,
tableIndex
,
p
Table
MetaInfo
->
vnodeIndex
);
free
(
pNew
);
free
(
pNew
);
return
NULL
;
return
NULL
;
...
@@ -2010,7 +2012,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
...
@@ -2010,7 +2012,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
}
}
if
(
tscAllocPayload
(
&
pNew
->
cmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tscAllocPayload
(
&
pNew
->
cmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
)
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"%p new subquery failed, tableIndex:%d, vnodeIndex:%d"
,
pSql
,
tableIndex
,
p
Meter
MetaInfo
->
vnodeIndex
);
tscError
(
"%p new subquery failed, tableIndex:%d, vnodeIndex:%d"
,
pSql
,
tableIndex
,
p
Table
MetaInfo
->
vnodeIndex
);
tscFreeSqlObj
(
pNew
);
tscFreeSqlObj
(
pNew
);
return
NULL
;
return
NULL
;
}
}
...
@@ -2025,7 +2027,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
...
@@ -2025,7 +2027,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
pNewQueryInfo
->
type
|=
TSDB_QUERY_TYPE_SUBQUERY
;
// it must be the subquery
pNewQueryInfo
->
type
|=
TSDB_QUERY_TYPE_SUBQUERY
;
// it must be the subquery
}
}
uint64_t
uid
=
p
MeterMetaInfo
->
pMeter
Meta
->
uid
;
uint64_t
uid
=
p
TableMetaInfo
->
pTable
Meta
->
uid
;
tscSqlExprCopy
(
&
pNewQueryInfo
->
exprsInfo
,
&
pQueryInfo
->
exprsInfo
,
uid
,
true
);
tscSqlExprCopy
(
&
pNewQueryInfo
->
exprsInfo
,
&
pQueryInfo
->
exprsInfo
,
uid
,
true
);
int32_t
numOfOutputCols
=
pNewQueryInfo
->
exprsInfo
.
numOfExprs
;
int32_t
numOfOutputCols
=
pNewQueryInfo
->
exprsInfo
.
numOfExprs
;
...
@@ -2067,34 +2069,34 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
...
@@ -2067,34 +2069,34 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
printf
(
"the metricmeta key is:%s
\n
"
,
key
);
printf
(
"the metricmeta key is:%s
\n
"
,
key
);
#endif
#endif
char
*
name
=
p
Meter
MetaInfo
->
name
;
char
*
name
=
p
Table
MetaInfo
->
name
;
S
Meter
MetaInfo
*
pFinalInfo
=
NULL
;
S
Table
MetaInfo
*
pFinalInfo
=
NULL
;
if
(
pPrevSql
==
NULL
)
{
if
(
pPrevSql
==
NULL
)
{
STableMeta
*
p
Meter
Meta
=
taosCacheAcquireByName
(
tscCacheHandle
,
name
);
STableMeta
*
p
Table
Meta
=
taosCacheAcquireByName
(
tscCacheHandle
,
name
);
SSuperTableMeta
*
pMetricMeta
=
taosCacheAcquireByName
(
tscCacheHandle
,
key
);
SSuperTableMeta
*
pMetricMeta
=
taosCacheAcquireByName
(
tscCacheHandle
,
key
);
pFinalInfo
=
tscAddMeterMetaInfo
(
pNewQueryInfo
,
name
,
p
MeterMeta
,
pMetricMeta
,
pMeter
MetaInfo
->
numOfTags
,
pFinalInfo
=
tscAddMeterMetaInfo
(
pNewQueryInfo
,
name
,
p
TableMeta
,
pMetricMeta
,
pTable
MetaInfo
->
numOfTags
,
p
Meter
MetaInfo
->
tagColumnIndex
);
p
Table
MetaInfo
->
tagColumnIndex
);
}
else
{
// transfer the ownership of p
Meter
Meta/pMetricMeta to the newly create sql object.
}
else
{
// transfer the ownership of p
Table
Meta/pMetricMeta to the newly create sql object.
S
Meter
MetaInfo
*
pPrevInfo
=
tscGetMeterMetaInfo
(
&
pPrevSql
->
cmd
,
pPrevSql
->
cmd
.
clauseIndex
,
0
);
S
Table
MetaInfo
*
pPrevInfo
=
tscGetMeterMetaInfo
(
&
pPrevSql
->
cmd
,
pPrevSql
->
cmd
.
clauseIndex
,
0
);
STableMeta
*
pPrevMeterMeta
=
taosCacheTransfer
(
tscCacheHandle
,
(
void
**
)
&
pPrevInfo
->
p
Meter
Meta
);
STableMeta
*
pPrevMeterMeta
=
taosCacheTransfer
(
tscCacheHandle
,
(
void
**
)
&
pPrevInfo
->
p
Table
Meta
);
SSuperTableMeta
*
pPrevMetricMeta
=
taosCacheTransfer
(
tscCacheHandle
,
(
void
**
)
&
pPrevInfo
->
pMetricMeta
);
SSuperTableMeta
*
pPrevMetricMeta
=
taosCacheTransfer
(
tscCacheHandle
,
(
void
**
)
&
pPrevInfo
->
pMetricMeta
);
pFinalInfo
=
tscAddMeterMetaInfo
(
pNewQueryInfo
,
name
,
pPrevMeterMeta
,
pPrevMetricMeta
,
p
Meter
MetaInfo
->
numOfTags
,
pFinalInfo
=
tscAddMeterMetaInfo
(
pNewQueryInfo
,
name
,
pPrevMeterMeta
,
pPrevMetricMeta
,
p
Table
MetaInfo
->
numOfTags
,
p
Meter
MetaInfo
->
tagColumnIndex
);
p
Table
MetaInfo
->
tagColumnIndex
);
}
}
assert
(
pFinalInfo
->
p
Meter
Meta
!=
NULL
&&
pNewQueryInfo
->
numOfTables
==
1
);
assert
(
pFinalInfo
->
p
Table
Meta
!=
NULL
&&
pNewQueryInfo
->
numOfTables
==
1
);
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
))
{
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
))
{
assert
(
pFinalInfo
->
pMetricMeta
!=
NULL
);
assert
(
pFinalInfo
->
pMetricMeta
!=
NULL
);
}
}
tscTrace
(
tscTrace
(
"%p new subquery: %p, tableIndex:%d, vnodeIdx:%d, type:%d, exprInfo:%d, colList:%d,"
"%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
,
"fieldInfo:%d, name:%s, qrang:%"
PRId64
" - %"
PRId64
" order:%d, limit:%"
PRId64
,
pSql
,
pNew
,
tableIndex
,
p
Meter
MetaInfo
->
vnodeIndex
,
pNewQueryInfo
->
type
,
pNewQueryInfo
->
exprsInfo
.
numOfExprs
,
pSql
,
pNew
,
tableIndex
,
p
Table
MetaInfo
->
vnodeIndex
,
pNewQueryInfo
->
type
,
pNewQueryInfo
->
exprsInfo
.
numOfExprs
,
pNewQueryInfo
->
colList
.
numOfCols
,
pNewQueryInfo
->
fieldsInfo
.
numOfOutputCols
,
pFinalInfo
->
name
,
pNewQueryInfo
->
stime
,
pNewQueryInfo
->
colList
.
numOfCols
,
pNewQueryInfo
->
fieldsInfo
.
numOfOutputCols
,
pFinalInfo
->
name
,
pNewQueryInfo
->
stime
,
pNewQueryInfo
->
etime
,
pNewQueryInfo
->
order
.
order
,
pNewQueryInfo
->
limit
.
limit
);
pNewQueryInfo
->
etime
,
pNewQueryInfo
->
order
.
order
,
pNewQueryInfo
->
limit
.
limit
);
...
@@ -2187,14 +2189,14 @@ bool hasMoreVnodesToTry(SSqlObj* pSql) {
...
@@ -2187,14 +2189,14 @@ bool hasMoreVnodesToTry(SSqlObj* pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
if
(
!
UTIL_METER_IS_SUPERTABLE
(
p
MeterMetaInfo
)
||
(
pMeter
MetaInfo
->
pMetricMeta
==
NULL
))
{
if
(
!
UTIL_METER_IS_SUPERTABLE
(
p
TableMetaInfo
)
||
(
pTable
MetaInfo
->
pMetricMeta
==
NULL
))
{
return
false
;
return
false
;
}
}
int32_t
totalVnode
=
p
Meter
MetaInfo
->
pMetricMeta
->
numOfVnodes
;
int32_t
totalVnode
=
p
Table
MetaInfo
->
pMetricMeta
->
numOfVnodes
;
return
pRes
->
numOfRows
==
0
&&
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
)
&&
return
pRes
->
numOfRows
==
0
&&
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
)
&&
(
!
tscHasReachLimitation
(
pQueryInfo
,
pRes
))
&&
(
p
Meter
MetaInfo
->
vnodeIndex
<
totalVnode
-
1
);
(
!
tscHasReachLimitation
(
pQueryInfo
,
pRes
))
&&
(
p
Table
MetaInfo
->
vnodeIndex
<
totalVnode
-
1
);
}
}
void
tscTryQueryNextVnode
(
SSqlObj
*
pSql
,
__async_cb_func_t
fp
)
{
void
tscTryQueryNextVnode
(
SSqlObj
*
pSql
,
__async_cb_func_t
fp
)
{
...
@@ -2209,12 +2211,12 @@ void tscTryQueryNextVnode(SSqlObj* pSql, __async_cb_func_t fp) {
...
@@ -2209,12 +2211,12 @@ void tscTryQueryNextVnode(SSqlObj* pSql, __async_cb_func_t fp) {
*/
*/
assert
(
pRes
->
numOfRows
==
0
&&
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
)
&&
!
tscHasReachLimitation
(
pQueryInfo
,
pRes
));
assert
(
pRes
->
numOfRows
==
0
&&
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
)
&&
!
tscHasReachLimitation
(
pQueryInfo
,
pRes
));
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
int32_t
totalVnode
=
p
Meter
MetaInfo
->
pMetricMeta
->
numOfVnodes
;
int32_t
totalVnode
=
p
Table
MetaInfo
->
pMetricMeta
->
numOfVnodes
;
while
(
++
p
Meter
MetaInfo
->
vnodeIndex
<
totalVnode
)
{
while
(
++
p
Table
MetaInfo
->
vnodeIndex
<
totalVnode
)
{
tscTrace
(
"%p current vnode:%d exhausted, try next:%d. total vnode:%d. current numOfRes:%d"
,
pSql
,
tscTrace
(
"%p current vnode:%d exhausted, try next:%d. total vnode:%d. current numOfRes:%d"
,
pSql
,
p
MeterMetaInfo
->
vnodeIndex
-
1
,
pMeter
MetaInfo
->
vnodeIndex
,
totalVnode
,
pRes
->
numOfTotalInCurrentClause
);
p
TableMetaInfo
->
vnodeIndex
-
1
,
pTable
MetaInfo
->
vnodeIndex
,
totalVnode
,
pRes
->
numOfTotalInCurrentClause
);
/*
/*
* update the limit and offset value for the query on the next vnode,
* update the limit and offset value for the query on the next vnode,
...
@@ -2233,7 +2235,7 @@ void tscTryQueryNextVnode(SSqlObj* pSql, __async_cb_func_t fp) {
...
@@ -2233,7 +2235,7 @@ void tscTryQueryNextVnode(SSqlObj* pSql, __async_cb_func_t fp) {
assert
((
pRes
->
offset
>=
0
&&
pRes
->
numOfRows
==
0
)
||
(
pRes
->
offset
==
0
&&
pRes
->
numOfRows
>=
0
));
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
,
tscTrace
(
"%p new query to next vnode, vnode index:%d, limit:%"
PRId64
", offset:%"
PRId64
", glimit:%"
PRId64
,
pSql
,
p
Meter
MetaInfo
->
vnodeIndex
,
pQueryInfo
->
limit
.
limit
,
pQueryInfo
->
limit
.
offset
,
pQueryInfo
->
clauseLimit
);
p
Table
MetaInfo
->
vnodeIndex
,
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.
* For project query with super table join, the numOfSub is equalled to the number of all subqueries.
...
...
src/inc/taosdef.h
浏览文件 @
03346d0c
...
@@ -165,7 +165,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
...
@@ -165,7 +165,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
#define TSDB_MAX_COLUMNS 256
#define TSDB_MAX_COLUMNS 256
#define TSDB_MIN_COLUMNS 2 //PRIMARY COLUMN(timestamp) + other columns
#define TSDB_MIN_COLUMNS 2 //PRIMARY COLUMN(timestamp) + other columns
#define TSDB_TABLE_NAME_LEN
64
#define TSDB_TABLE_NAME_LEN
192
#define TSDB_DB_NAME_LEN 32
#define TSDB_DB_NAME_LEN 32
#define TSDB_COL_NAME_LEN 64
#define TSDB_COL_NAME_LEN 64
#define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 16
#define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 16
...
...
src/inc/taosmsg.h
浏览文件 @
03346d0c
...
@@ -678,15 +678,15 @@ typedef struct {
...
@@ -678,15 +678,15 @@ typedef struct {
int32_t
list
[];
/* offset of SVnodeSidList, compared to the SSuperTableMeta struct */
int32_t
list
[];
/* offset of SVnodeSidList, compared to the SSuperTableMeta struct */
}
SSuperTableMeta
;
}
SSuperTableMeta
;
typedef
struct
STableMeta
{
typedef
struct
STableMeta
Msg
{
char
tableId
[
TSDB_TABLE_ID_LEN
+
1
];
// note: This field must be at the front
char
tableId
[
TSDB_TABLE_ID_LEN
];
// note: This field must be at the front
int32_t
contLen
;
int32_t
contLen
;
uint8_t
numOfTags
:
6
;
uint8_t
numOfTags
;
uint8_t
precision
:
2
;
uint8_t
precision
;
uint8_t
tableType
:
4
;
uint8_t
tableType
;
uint8_t
index
:
4
;
// used locally
//
uint8_t index : 4; // used locally
int16_t
numOfColumns
;
int16_t
numOfColumns
;
int16_t
rowSize
;
// used locally, calculated in client
//
int16_t rowSize; // used locally, calculated in client
int16_t
sversion
;
int16_t
sversion
;
int8_t
numOfVpeers
;
int8_t
numOfVpeers
;
SVnodeDesc
vpeerDesc
[
TSDB_VNODES_SUPPORT
];
SVnodeDesc
vpeerDesc
[
TSDB_VNODES_SUPPORT
];
...
@@ -694,12 +694,12 @@ typedef struct STableMeta {
...
@@ -694,12 +694,12 @@ typedef struct STableMeta {
int32_t
vgid
;
int32_t
vgid
;
uint64_t
uid
;
uint64_t
uid
;
SSchema
schema
[];
SSchema
schema
[];
}
STableMeta
;
}
STableMeta
Msg
;
typedef
struct
SMultiTableMeta
{
typedef
struct
SMultiTableMeta
{
int32_t
numOfTables
;
int32_t
numOfTables
;
int32_t
contLen
;
int32_t
contLen
;
STableMeta
metas
[];
STableMeta
Msg
metas
[];
}
SMultiTableMeta
;
}
SMultiTableMeta
;
typedef
struct
{
typedef
struct
{
...
@@ -719,9 +719,9 @@ typedef struct {
...
@@ -719,9 +719,9 @@ typedef struct {
char
payload
[];
char
payload
[];
}
SCMShowMsg
;
}
SCMShowMsg
;
typedef
struct
{
typedef
struct
SCMShowRsp
{
uint64_t
qhandle
;
uint64_t
qhandle
;
STableMeta
tableMeta
;
STableMeta
Msg
tableMeta
;
}
SCMShowRsp
;
}
SCMShowRsp
;
typedef
struct
{
typedef
struct
{
...
...
src/mnode/inc/mgmtChildTable.h
浏览文件 @
03346d0c
...
@@ -36,7 +36,7 @@ void *mgmtBuildCreateChildTableMsg(SCMCreateTableMsg *pCreate, SChildTableObj *p
...
@@ -36,7 +36,7 @@ void *mgmtBuildCreateChildTableMsg(SCMCreateTableMsg *pCreate, SChildTableObj *p
int32_t
mgmtDropChildTable
(
SQueuedMsg
*
newMsg
,
SChildTableObj
*
pTable
);
int32_t
mgmtDropChildTable
(
SQueuedMsg
*
newMsg
,
SChildTableObj
*
pTable
);
int32_t
mgmtModifyChildTableTagValueByName
(
SChildTableObj
*
pTable
,
char
*
tagName
,
char
*
nContent
);
int32_t
mgmtModifyChildTableTagValueByName
(
SChildTableObj
*
pTable
,
char
*
tagName
,
char
*
nContent
);
int32_t
mgmtGetChildTableMeta
(
SDbObj
*
pDb
,
SChildTableObj
*
pTable
,
STableMeta
*
pMeta
,
bool
usePublicIp
);
int32_t
mgmtGetChildTableMeta
(
SDbObj
*
pDb
,
SChildTableObj
*
pTable
,
STableMeta
Msg
*
pMeta
,
bool
usePublicIp
);
void
mgmtDropAllChildTables
(
SDbObj
*
pDropDb
);
void
mgmtDropAllChildTables
(
SDbObj
*
pDropDb
);
...
...
src/mnode/inc/mgmtNormalTable.h
浏览文件 @
03346d0c
...
@@ -35,7 +35,7 @@ int32_t mgmtDropNormalTable(SQueuedMsg *newMsg, SNormalTableObj *pTable);
...
@@ -35,7 +35,7 @@ int32_t mgmtDropNormalTable(SQueuedMsg *newMsg, SNormalTableObj *pTable);
int32_t
mgmtAddNormalTableColumn
(
SNormalTableObj
*
pTable
,
SSchema
schema
[],
int32_t
ncols
);
int32_t
mgmtAddNormalTableColumn
(
SNormalTableObj
*
pTable
,
SSchema
schema
[],
int32_t
ncols
);
int32_t
mgmtDropNormalTableColumnByName
(
SNormalTableObj
*
pTable
,
char
*
colName
);
int32_t
mgmtDropNormalTableColumnByName
(
SNormalTableObj
*
pTable
,
char
*
colName
);
int32_t
mgmtGetNormalTableMeta
(
SDbObj
*
pDb
,
SNormalTableObj
*
pTable
,
STableMeta
*
pMeta
,
bool
usePublicIp
);
int32_t
mgmtGetNormalTableMeta
(
SDbObj
*
pDb
,
SNormalTableObj
*
pTable
,
STableMeta
Msg
*
pMeta
,
bool
usePublicIp
);
void
mgmtDropAllNormalTables
(
SDbObj
*
pDropDb
);
void
mgmtDropAllNormalTables
(
SDbObj
*
pDropDb
);
...
...
src/mnode/inc/mgmtShell.h
浏览文件 @
03346d0c
...
@@ -25,7 +25,7 @@ int32_t mgmtInitShell();
...
@@ -25,7 +25,7 @@ int32_t mgmtInitShell();
void
mgmtCleanUpShell
();
void
mgmtCleanUpShell
();
void
mgmtAddShellMsgHandle
(
uint8_t
msgType
,
void
(
*
fp
)(
SQueuedMsg
*
queuedMsg
));
void
mgmtAddShellMsgHandle
(
uint8_t
msgType
,
void
(
*
fp
)(
SQueuedMsg
*
queuedMsg
));
typedef
int32_t
(
*
SShowMetaFp
)(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
typedef
int32_t
(
*
SShowMetaFp
)(
STableMeta
Msg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
typedef
int32_t
(
*
SShowRetrieveFp
)(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
typedef
int32_t
(
*
SShowRetrieveFp
)(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
void
mgmtAddShellShowMetaHandle
(
uint8_t
showType
,
SShowMetaFp
fp
);
void
mgmtAddShellShowMetaHandle
(
uint8_t
showType
,
SShowMetaFp
fp
);
void
mgmtAddShellShowRetrieveHandle
(
uint8_t
showType
,
SShowRetrieveFp
fp
);
void
mgmtAddShellShowRetrieveHandle
(
uint8_t
showType
,
SShowRetrieveFp
fp
);
...
...
src/mnode/inc/mgmtSuperTable.h
浏览文件 @
03346d0c
...
@@ -39,7 +39,7 @@ int32_t mgmtModifySuperTableTagNameByName(SSuperTableObj *pTable, char *oldTagNa
...
@@ -39,7 +39,7 @@ int32_t mgmtModifySuperTableTagNameByName(SSuperTableObj *pTable, char *oldTagNa
int32_t
mgmtAddSuperTableColumn
(
SSuperTableObj
*
pTable
,
SSchema
schema
[],
int32_t
ncols
);
int32_t
mgmtAddSuperTableColumn
(
SSuperTableObj
*
pTable
,
SSchema
schema
[],
int32_t
ncols
);
int32_t
mgmtDropSuperTableColumnByName
(
SSuperTableObj
*
pTable
,
char
*
colName
);
int32_t
mgmtDropSuperTableColumnByName
(
SSuperTableObj
*
pTable
,
char
*
colName
);
int32_t
mgmtGetSuperTableMeta
(
SDbObj
*
pDb
,
SSuperTableObj
*
pTable
,
STableMeta
*
pMeta
,
bool
usePublicIp
);
int32_t
mgmtGetSuperTableMeta
(
SDbObj
*
pDb
,
SSuperTableObj
*
pTable
,
STableMeta
Msg
*
pMeta
,
bool
usePublicIp
);
void
*
mgmtGetSuperTableVgroup
(
SSuperTableObj
*
pStable
);
void
*
mgmtGetSuperTableVgroup
(
SSuperTableObj
*
pStable
);
int32_t
mgmtFindSuperTableTagIndex
(
SSuperTableObj
*
pTable
,
const
char
*
tagName
);
int32_t
mgmtFindSuperTableTagIndex
(
SSuperTableObj
*
pTable
,
const
char
*
tagName
);
...
...
src/mnode/inc/mgmtTable.h
浏览文件 @
03346d0c
...
@@ -30,7 +30,7 @@ void mgmtCleanUpTables();
...
@@ -30,7 +30,7 @@ void mgmtCleanUpTables();
STableInfo
*
mgmtGetTable
(
char
*
tableId
);
STableInfo
*
mgmtGetTable
(
char
*
tableId
);
STableInfo
*
mgmtGetTableByPos
(
uint32_t
dnodeIp
,
int32_t
vnode
,
int32_t
sid
);
STableInfo
*
mgmtGetTableByPos
(
uint32_t
dnodeIp
,
int32_t
vnode
,
int32_t
sid
);
int32_t
mgmtGetTableMeta
(
SDbObj
*
pDb
,
STableInfo
*
pTable
,
STableMeta
*
pMeta
,
bool
usePublicIp
);
int32_t
mgmtGetTableMeta
(
SDbObj
*
pDb
,
STableInfo
*
pTable
,
STableMeta
Msg
*
pMeta
,
bool
usePublicIp
);
void
mgmtAddTableIntoSuperTable
(
SSuperTableObj
*
pStable
);
void
mgmtAddTableIntoSuperTable
(
SSuperTableObj
*
pStable
);
void
mgmtRemoveTableFromSuperTable
(
SSuperTableObj
*
pStable
);
void
mgmtRemoveTableFromSuperTable
(
SSuperTableObj
*
pStable
);
...
...
src/mnode/src/mgmtChildTable.c
浏览文件 @
03346d0c
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "os.h"
#include "os.h"
#include "taosmsg.h"
#include "taosmsg.h"
#include "tschemautil.h"
#include "tscompression.h"
#include "tscompression.h"
#include "tskiplist.h"
#include "tskiplist.h"
#include "ttime.h"
#include "ttime.h"
...
@@ -442,7 +441,7 @@ int32_t mgmtModifyChildTableTagValueByName(SChildTableObj *pTable, char *tagName
...
@@ -442,7 +441,7 @@ int32_t mgmtModifyChildTableTagValueByName(SChildTableObj *pTable, char *tagName
return
0
;
return
0
;
}
}
int32_t
mgmtGetChildTableMeta
(
SDbObj
*
pDb
,
SChildTableObj
*
pTable
,
STableMeta
*
pMeta
,
bool
usePublicIp
)
{
int32_t
mgmtGetChildTableMeta
(
SDbObj
*
pDb
,
SChildTableObj
*
pTable
,
STableMeta
Msg
*
pMeta
,
bool
usePublicIp
)
{
pMeta
->
uid
=
htobe64
(
pTable
->
uid
);
pMeta
->
uid
=
htobe64
(
pTable
->
uid
);
pMeta
->
sid
=
htonl
(
pTable
->
sid
);
pMeta
->
sid
=
htonl
(
pTable
->
sid
);
pMeta
->
vgid
=
htonl
(
pTable
->
vgId
);
pMeta
->
vgid
=
htonl
(
pTable
->
vgId
);
...
@@ -451,7 +450,7 @@ int32_t mgmtGetChildTableMeta(SDbObj *pDb, SChildTableObj *pTable, STableMeta *p
...
@@ -451,7 +450,7 @@ int32_t mgmtGetChildTableMeta(SDbObj *pDb, SChildTableObj *pTable, STableMeta *p
pMeta
->
numOfTags
=
pTable
->
superTable
->
numOfTags
;
pMeta
->
numOfTags
=
pTable
->
superTable
->
numOfTags
;
pMeta
->
numOfColumns
=
htons
(
pTable
->
superTable
->
numOfColumns
);
pMeta
->
numOfColumns
=
htons
(
pTable
->
superTable
->
numOfColumns
);
pMeta
->
tableType
=
pTable
->
type
;
pMeta
->
tableType
=
pTable
->
type
;
pMeta
->
contLen
=
sizeof
(
STableMeta
)
+
mgmtSetSchemaFromSuperTable
(
pMeta
->
schema
,
pTable
->
superTable
);
pMeta
->
contLen
=
sizeof
(
STableMeta
Msg
)
+
mgmtSetSchemaFromSuperTable
(
pMeta
->
schema
,
pTable
->
superTable
);
strcpy
(
pMeta
->
tableId
,
pTable
->
tableId
);
strcpy
(
pMeta
->
tableId
,
pTable
->
tableId
);
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pTable
->
vgId
);
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pTable
->
vgId
);
...
...
src/mnode/src/mgmtDb.c
浏览文件 @
03346d0c
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "os.h"
#include "os.h"
#include "taoserror.h"
#include "taoserror.h"
#include "tschemautil.h"
#include "tstatus.h"
#include "tstatus.h"
#include "tutil.h"
#include "tutil.h"
#include "mnode.h"
#include "mnode.h"
...
@@ -41,7 +40,7 @@ static int32_t mgmtCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate);
...
@@ -41,7 +40,7 @@ static int32_t mgmtCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate);
static
void
mgmtDropDb
(
void
*
handle
,
void
*
tmrId
);
static
void
mgmtDropDb
(
void
*
handle
,
void
*
tmrId
);
static
void
mgmtSetDbDirty
(
SDbObj
*
pDb
);
static
void
mgmtSetDbDirty
(
SDbObj
*
pDb
);
static
int32_t
mgmtGetDbMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtGetDbMeta
(
STableMeta
Msg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtRetrieveDbs
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mgmtRetrieveDbs
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
void
mgmtProcessCreateDbMsg
(
SQueuedMsg
*
pMsg
);
static
void
mgmtProcessCreateDbMsg
(
SQueuedMsg
*
pMsg
);
static
void
mgmtProcessAlterDbMsg
(
SQueuedMsg
*
pMsg
);
static
void
mgmtProcessAlterDbMsg
(
SQueuedMsg
*
pMsg
);
...
@@ -295,7 +294,8 @@ static int32_t mgmtCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate) {
...
@@ -295,7 +294,8 @@ static int32_t mgmtCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate) {
bool
mgmtCheckIsMonitorDB
(
char
*
db
,
char
*
monitordb
)
{
bool
mgmtCheckIsMonitorDB
(
char
*
db
,
char
*
monitordb
)
{
char
dbName
[
TSDB_DB_NAME_LEN
+
1
]
=
{
0
};
char
dbName
[
TSDB_DB_NAME_LEN
+
1
]
=
{
0
};
extractDBName
(
db
,
dbName
);
assert
(
0
);
// extractDBName(db, dbName);
size_t
len
=
strlen
(
dbName
);
size_t
len
=
strlen
(
dbName
);
return
(
strncasecmp
(
dbName
,
monitordb
,
len
)
==
0
&&
len
==
strlen
(
monitordb
));
return
(
strncasecmp
(
dbName
,
monitordb
,
len
)
==
0
&&
len
==
strlen
(
monitordb
));
...
@@ -421,10 +421,10 @@ void mgmtCleanUpDbs() {
...
@@ -421,10 +421,10 @@ void mgmtCleanUpDbs() {
sdbCloseTable
(
tsDbSdb
);
sdbCloseTable
(
tsDbSdb
);
}
}
static
int32_t
mgmtGetDbMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
static
int32_t
mgmtGetDbMeta
(
STableMeta
Msg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
cols
=
0
;
int32_t
cols
=
0
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
)
;
SSchema
*
pSchema
=
pMeta
->
schema
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
if
(
pUser
==
NULL
)
return
0
;
if
(
pUser
==
NULL
)
return
0
;
...
...
src/mnode/src/mgmtDnode.c
浏览文件 @
03346d0c
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "os.h"
#include "os.h"
#include "tmodule.h"
#include "tmodule.h"
#include "tschemautil.h"
#include "tstatus.h"
#include "tstatus.h"
#include "mgmtBalance.h"
#include "mgmtBalance.h"
#include "mgmtDnode.h"
#include "mgmtDnode.h"
...
@@ -37,11 +36,11 @@ void (*mgmtSetDnodeUnRemoveFp)(SDnodeObj *pDnode) = NULL;
...
@@ -37,11 +36,11 @@ void (*mgmtSetDnodeUnRemoveFp)(SDnodeObj *pDnode) = NULL;
static
SDnodeObj
tsDnodeObj
=
{
0
};
static
SDnodeObj
tsDnodeObj
=
{
0
};
static
void
*
mgmtGetNextDnode
(
SShowObj
*
pShow
,
SDnodeObj
**
pDnode
);
static
void
*
mgmtGetNextDnode
(
SShowObj
*
pShow
,
SDnodeObj
**
pDnode
);
static
bool
mgmtCheckConfigShow
(
SGlobalConfig
*
cfg
);
static
bool
mgmtCheckConfigShow
(
SGlobalConfig
*
cfg
);
static
int32_t
mgmtGetModuleMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtGetModuleMeta
(
STableMeta
Msg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtRetrieveModules
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mgmtRetrieveModules
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mgmtGetConfigMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtGetConfigMeta
(
STableMeta
Msg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtRetrieveConfigs
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mgmtRetrieveConfigs
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mgmtGetVnodeMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtGetVnodeMeta
(
STableMeta
Msg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtRetrieveVnodes
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mgmtRetrieveVnodes
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
void
mgmtProcessCfgDnodeMsg
(
SQueuedMsg
*
pMsg
);
static
void
mgmtProcessCfgDnodeMsg
(
SQueuedMsg
*
pMsg
);
...
@@ -123,7 +122,7 @@ bool mgmtCheckModuleInDnode(SDnodeObj *pDnode, int32_t moduleType) {
...
@@ -123,7 +122,7 @@ bool mgmtCheckModuleInDnode(SDnodeObj *pDnode, int32_t moduleType) {
return
status
>
0
;
return
status
>
0
;
}
}
int32_t
mgmtGetModuleMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
mgmtGetModuleMeta
(
STableMeta
Msg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
cols
=
0
;
int32_t
cols
=
0
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
...
@@ -131,7 +130,7 @@ int32_t mgmtGetModuleMeta(STableMeta *pMeta, SShowObj *pShow, void *pConn) {
...
@@ -131,7 +130,7 @@ int32_t mgmtGetModuleMeta(STableMeta *pMeta, SShowObj *pShow, void *pConn) {
if
(
strcmp
(
pUser
->
user
,
"root"
)
!=
0
)
return
TSDB_CODE_NO_RIGHTS
;
if
(
strcmp
(
pUser
->
user
,
"root"
)
!=
0
)
return
TSDB_CODE_NO_RIGHTS
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
)
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
16
;
pShow
->
bytes
[
cols
]
=
16
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
...
@@ -216,7 +215,7 @@ int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pCo
...
@@ -216,7 +215,7 @@ int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pCo
return
numOfRows
;
return
numOfRows
;
}
}
static
int32_t
mgmtGetConfigMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
static
int32_t
mgmtGetConfigMeta
(
STableMeta
Msg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
cols
=
0
;
int32_t
cols
=
0
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
...
@@ -224,7 +223,7 @@ static int32_t mgmtGetConfigMeta(STableMeta *pMeta, SShowObj *pShow, void *pConn
...
@@ -224,7 +223,7 @@ static int32_t mgmtGetConfigMeta(STableMeta *pMeta, SShowObj *pShow, void *pConn
if
(
strcmp
(
pUser
->
user
,
"root"
)
!=
0
)
return
TSDB_CODE_NO_RIGHTS
;
if
(
strcmp
(
pUser
->
user
,
"root"
)
!=
0
)
return
TSDB_CODE_NO_RIGHTS
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
)
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
TSDB_CFG_OPTION_LEN
;
pShow
->
bytes
[
cols
]
=
TSDB_CFG_OPTION_LEN
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
...
@@ -304,13 +303,13 @@ static int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, vo
...
@@ -304,13 +303,13 @@ static int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, vo
return
numOfRows
;
return
numOfRows
;
}
}
static
int32_t
mgmtGetVnodeMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
static
int32_t
mgmtGetVnodeMeta
(
STableMeta
Msg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
cols
=
0
;
int32_t
cols
=
0
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
if
(
pUser
==
NULL
)
return
0
;
if
(
pUser
==
NULL
)
return
0
;
if
(
strcmp
(
pUser
->
user
,
"root"
)
!=
0
)
return
TSDB_CODE_NO_RIGHTS
;
if
(
strcmp
(
pUser
->
user
,
"root"
)
!=
0
)
return
TSDB_CODE_NO_RIGHTS
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
)
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
4
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
...
...
src/mnode/src/mgmtNormalTable.c
浏览文件 @
03346d0c
...
@@ -521,7 +521,7 @@ static int32_t mgmtSetSchemaFromNormalTable(SSchema *pSchema, SNormalTableObj *p
...
@@ -521,7 +521,7 @@ static int32_t mgmtSetSchemaFromNormalTable(SSchema *pSchema, SNormalTableObj *p
return
numOfCols
*
sizeof
(
SSchema
);
return
numOfCols
*
sizeof
(
SSchema
);
}
}
int32_t
mgmtGetNormalTableMeta
(
SDbObj
*
pDb
,
SNormalTableObj
*
pTable
,
STableMeta
*
pMeta
,
bool
usePublicIp
)
{
int32_t
mgmtGetNormalTableMeta
(
SDbObj
*
pDb
,
SNormalTableObj
*
pTable
,
STableMeta
Msg
*
pMeta
,
bool
usePublicIp
)
{
pMeta
->
uid
=
htobe64
(
pTable
->
uid
);
pMeta
->
uid
=
htobe64
(
pTable
->
uid
);
pMeta
->
sid
=
htonl
(
pTable
->
sid
);
pMeta
->
sid
=
htonl
(
pTable
->
sid
);
pMeta
->
vgid
=
htonl
(
pTable
->
vgId
);
pMeta
->
vgid
=
htonl
(
pTable
->
vgId
);
...
@@ -530,7 +530,7 @@ int32_t mgmtGetNormalTableMeta(SDbObj *pDb, SNormalTableObj *pTable, STableMeta
...
@@ -530,7 +530,7 @@ int32_t mgmtGetNormalTableMeta(SDbObj *pDb, SNormalTableObj *pTable, STableMeta
pMeta
->
numOfTags
=
0
;
pMeta
->
numOfTags
=
0
;
pMeta
->
numOfColumns
=
htons
(
pTable
->
numOfColumns
);
pMeta
->
numOfColumns
=
htons
(
pTable
->
numOfColumns
);
pMeta
->
tableType
=
pTable
->
type
;
pMeta
->
tableType
=
pTable
->
type
;
pMeta
->
contLen
=
sizeof
(
STableMeta
)
+
mgmtSetSchemaFromNormalTable
(
pMeta
->
schema
,
pTable
);
pMeta
->
contLen
=
sizeof
(
STableMeta
Msg
)
+
mgmtSetSchemaFromNormalTable
(
pMeta
->
schema
,
pTable
);
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pTable
->
vgId
);
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pTable
->
vgId
);
if
(
pVgroup
==
NULL
)
{
if
(
pVgroup
==
NULL
)
{
...
...
src/mnode/src/mgmtProfile.c
浏览文件 @
03346d0c
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "os.h"
#include "os.h"
#include "taosmsg.h"
#include "taosmsg.h"
#include "tschemautil.h"
#include "mgmtMnode.h"
#include "mgmtMnode.h"
#include "mgmtProfile.h"
#include "mgmtProfile.h"
#include "mgmtShell.h"
#include "mgmtShell.h"
...
@@ -137,10 +136,10 @@ int32_t mgmtGetQueries(SShowObj *pShow, void *pConn) {
...
@@ -137,10 +136,10 @@ int32_t mgmtGetQueries(SShowObj *pShow, void *pConn) {
return
0
;
return
0
;
}
}
int32_t
mgmtGetQueryMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
mgmtGetQueryMeta
(
STableMeta
Msg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
cols
=
0
;
int32_t
cols
=
0
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
)
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
TSDB_USER_LEN
;
pShow
->
bytes
[
cols
]
=
TSDB_USER_LEN
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
...
@@ -336,9 +335,9 @@ int32_t mgmtGetStreams(SShowObj *pShow, void *pConn) {
...
@@ -336,9 +335,9 @@ int32_t mgmtGetStreams(SShowObj *pShow, void *pConn) {
return
0
;
return
0
;
}
}
int32_t
mgmtGetStreamMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
mgmtGetStreamMeta
(
STableMeta
Msg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
cols
=
0
;
int32_t
cols
=
0
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
)
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
TSDB_USER_LEN
;
pShow
->
bytes
[
cols
]
=
TSDB_USER_LEN
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
...
@@ -600,11 +599,11 @@ int mgmtGetConns(SShowObj *pShow, void *pConn) {
...
@@ -600,11 +599,11 @@ int mgmtGetConns(SShowObj *pShow, void *pConn) {
return
0
;
return
0
;
}
}
int32_t
mgmtGetConnsMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
mgmtGetConnsMeta
(
STableMeta
Msg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
cols
=
0
;
int32_t
cols
=
0
;
pShow
->
bytes
[
cols
]
=
TSDB_TABLE_NAME_LEN
;
pShow
->
bytes
[
cols
]
=
TSDB_TABLE_NAME_LEN
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
)
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"user"
);
strcpy
(
pSchema
[
cols
].
name
,
"user"
);
...
...
src/mnode/src/mgmtShell.c
浏览文件 @
03346d0c
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
#include "mgmtUser.h"
#include "mgmtUser.h"
#include "mgmtVgroup.h"
#include "mgmtVgroup.h"
typedef
int32_t
(
*
SShowMetaFp
)(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
typedef
int32_t
(
*
SShowMetaFp
)(
STableMeta
Msg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
typedef
int32_t
(
*
SShowRetrieveFp
)(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
typedef
int32_t
(
*
SShowRetrieveFp
)(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int
mgmtShellRetriveAuth
(
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
);
static
int
mgmtShellRetriveAuth
(
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
);
...
...
src/mnode/src/mgmtSuperTable.c
浏览文件 @
03346d0c
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "os.h"
#include "os.h"
#include "taosmsg.h"
#include "taosmsg.h"
#include "tschemautil.h"
#include "tscompression.h"
#include "tscompression.h"
#include "tskiplist.h"
#include "tskiplist.h"
#include "tsqlfunction.h"
#include "tsqlfunction.h"
...
@@ -47,7 +46,7 @@ static void *mgmtSuperTableActionDecode(void *row, char *str, int32_t size, int3
...
@@ -47,7 +46,7 @@ static void *mgmtSuperTableActionDecode(void *row, char *str, int32_t size, int3
static
void
*
mgmtSuperTableActionReset
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
static
void
*
mgmtSuperTableActionReset
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
static
void
*
mgmtSuperTableActionDestroy
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
static
void
*
mgmtSuperTableActionDestroy
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
static
int32_t
mgmtRetrieveShowSuperTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mgmtRetrieveShowSuperTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mgmtGetShowSuperTableMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtGetShowSuperTableMeta
(
STableMeta
Msg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
void
mgmtDestroySuperTable
(
SSuperTableObj
*
pTable
)
{
static
void
mgmtDestroySuperTable
(
SSuperTableObj
*
pTable
)
{
free
(
pTable
->
schema
);
free
(
pTable
->
schema
);
...
@@ -492,14 +491,14 @@ int32_t mgmtDropSuperTableColumnByName(SSuperTableObj *pStable, char *colName) {
...
@@ -492,14 +491,14 @@ int32_t mgmtDropSuperTableColumnByName(SSuperTableObj *pStable, char *colName) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mgmtGetShowSuperTableMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
static
int32_t
mgmtGetShowSuperTableMeta
(
STableMeta
Msg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
SDbObj
*
pDb
=
mgmtGetDb
(
pShow
->
db
);
SDbObj
*
pDb
=
mgmtGetDb
(
pShow
->
db
);
if
(
pDb
==
NULL
)
{
if
(
pDb
==
NULL
)
{
return
TSDB_CODE_DB_NOT_SELECTED
;
return
TSDB_CODE_DB_NOT_SELECTED
;
}
}
int32_t
cols
=
0
;
int32_t
cols
=
0
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
)
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
TSDB_TABLE_NAME_LEN
;
pShow
->
bytes
[
cols
]
=
TSDB_TABLE_NAME_LEN
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
...
@@ -657,7 +656,7 @@ int32_t mgmtSetSchemaFromSuperTable(SSchema *pSchema, SSuperTableObj *pTable) {
...
@@ -657,7 +656,7 @@ int32_t mgmtSetSchemaFromSuperTable(SSchema *pSchema, SSuperTableObj *pTable) {
return
(
pTable
->
numOfColumns
+
pTable
->
numOfTags
)
*
sizeof
(
SSchema
);
return
(
pTable
->
numOfColumns
+
pTable
->
numOfTags
)
*
sizeof
(
SSchema
);
}
}
int32_t
mgmtGetSuperTableMeta
(
SDbObj
*
pDb
,
SSuperTableObj
*
pTable
,
STableMeta
*
pMeta
,
bool
usePublicIp
)
{
int32_t
mgmtGetSuperTableMeta
(
SDbObj
*
pDb
,
SSuperTableObj
*
pTable
,
STableMeta
Msg
*
pMeta
,
bool
usePublicIp
)
{
pMeta
->
uid
=
htobe64
(
pTable
->
uid
);
pMeta
->
uid
=
htobe64
(
pTable
->
uid
);
pMeta
->
sid
=
htonl
(
pTable
->
sid
);
pMeta
->
sid
=
htonl
(
pTable
->
sid
);
pMeta
->
vgid
=
htonl
(
pTable
->
vgId
);
pMeta
->
vgid
=
htonl
(
pTable
->
vgId
);
...
@@ -666,7 +665,7 @@ int32_t mgmtGetSuperTableMeta(SDbObj *pDb, SSuperTableObj *pTable, STableMeta *p
...
@@ -666,7 +665,7 @@ int32_t mgmtGetSuperTableMeta(SDbObj *pDb, SSuperTableObj *pTable, STableMeta *p
pMeta
->
numOfTags
=
pTable
->
numOfTags
;
pMeta
->
numOfTags
=
pTable
->
numOfTags
;
pMeta
->
numOfColumns
=
htons
(
pTable
->
numOfColumns
);
pMeta
->
numOfColumns
=
htons
(
pTable
->
numOfColumns
);
pMeta
->
tableType
=
pTable
->
type
;
pMeta
->
tableType
=
pTable
->
type
;
pMeta
->
contLen
=
sizeof
(
STableMeta
)
+
mgmtSetSchemaFromSuperTable
(
pMeta
->
schema
,
pTable
);
pMeta
->
contLen
=
sizeof
(
STableMeta
Msg
)
+
mgmtSetSchemaFromSuperTable
(
pMeta
->
schema
,
pTable
);
strcpy
(
pMeta
->
tableId
,
pTable
->
tableId
);
strcpy
(
pMeta
->
tableId
,
pTable
->
tableId
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
...
src/mnode/src/mgmtTable.c
浏览文件 @
03346d0c
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "mgmtTable.h"
#include "mgmtTable.h"
//#include "../../client/inc/tsclient.h"
#include "mgmtAcct.h"
#include "mgmtAcct.h"
#include "mgmtChildTable.h"
#include "mgmtChildTable.h"
#include "mgmtDClient.h"
#include "mgmtDClient.h"
...
@@ -34,7 +35,6 @@
...
@@ -34,7 +35,6 @@
#include "qextbuffer.h"
#include "qextbuffer.h"
#include "taoserror.h"
#include "taoserror.h"
#include "taosmsg.h"
#include "taosmsg.h"
#include "tschemautil.h"
#include "tscompression.h"
#include "tscompression.h"
#include "tskiplist.h"
#include "tskiplist.h"
#include "tsqlfunction.h"
#include "tsqlfunction.h"
...
@@ -52,7 +52,7 @@ static void mgmtProcessMultiTableMetaMsg(SQueuedMsg *queueMsg);
...
@@ -52,7 +52,7 @@ static void mgmtProcessMultiTableMetaMsg(SQueuedMsg *queueMsg);
static
void
mgmtProcessSuperTableMetaMsg
(
SQueuedMsg
*
queueMsg
);
static
void
mgmtProcessSuperTableMetaMsg
(
SQueuedMsg
*
queueMsg
);
static
void
mgmtProcessCreateTableRsp
(
SRpcMsg
*
rpcMsg
);
static
void
mgmtProcessCreateTableRsp
(
SRpcMsg
*
rpcMsg
);
static
void
mgmtProcessDropTableRsp
(
SRpcMsg
*
rpcMsg
);
static
void
mgmtProcessDropTableRsp
(
SRpcMsg
*
rpcMsg
);
static
int32_t
mgmtGetShowTableMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtGetShowTableMeta
(
STableMeta
Msg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtRetrieveShowTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mgmtRetrieveShowTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
void
mgmtProcessGetTableMeta
(
STableInfo
*
pTable
,
void
*
thandle
);
static
void
mgmtProcessGetTableMeta
(
STableInfo
*
pTable
,
void
*
thandle
);
...
@@ -122,7 +122,7 @@ STableInfo* mgmtGetTableByPos(uint32_t dnodeIp, int32_t vnode, int32_t sid) {
...
@@ -122,7 +122,7 @@ STableInfo* mgmtGetTableByPos(uint32_t dnodeIp, int32_t vnode, int32_t sid) {
return
NULL
;
return
NULL
;
}
}
int32_t
mgmtGetTableMeta
(
SDbObj
*
pDb
,
STableInfo
*
pTable
,
STableMeta
*
pMeta
,
bool
usePublicIp
)
{
int32_t
mgmtGetTableMeta
(
SDbObj
*
pDb
,
STableInfo
*
pTable
,
STableMeta
Msg
*
pMeta
,
bool
usePublicIp
)
{
if
(
pTable
->
type
==
TSDB_CHILD_TABLE
)
{
if
(
pTable
->
type
==
TSDB_CHILD_TABLE
)
{
mgmtGetChildTableMeta
(
pDb
,
(
SChildTableObj
*
)
pTable
,
pMeta
,
usePublicIp
);
mgmtGetChildTableMeta
(
pDb
,
(
SChildTableObj
*
)
pTable
,
pMeta
,
usePublicIp
);
}
else
if
(
pTable
->
type
==
TSDB_NORMAL_TABLE
)
{
}
else
if
(
pTable
->
type
==
TSDB_NORMAL_TABLE
)
{
...
@@ -187,14 +187,14 @@ void mgmtCleanUpTables() {
...
@@ -187,14 +187,14 @@ void mgmtCleanUpTables() {
mgmtCleanUpSuperTables
();
mgmtCleanUpSuperTables
();
}
}
int32_t
mgmtGetShowTableMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
mgmtGetShowTableMeta
(
STableMeta
Msg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
SDbObj
*
pDb
=
mgmtGetDb
(
pShow
->
db
);
SDbObj
*
pDb
=
mgmtGetDb
(
pShow
->
db
);
if
(
pDb
==
NULL
)
{
if
(
pDb
==
NULL
)
{
return
TSDB_CODE_DB_NOT_SELECTED
;
return
TSDB_CODE_DB_NOT_SELECTED
;
}
}
int32_t
cols
=
0
;
int32_t
cols
=
0
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
)
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
TSDB_TABLE_NAME_LEN
;
pShow
->
bytes
[
cols
]
=
TSDB_TABLE_NAME_LEN
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
...
@@ -602,7 +602,7 @@ void mgmtProcessGetTableMeta(STableInfo *pTable, void *thandle) {
...
@@ -602,7 +602,7 @@ void mgmtProcessGetTableMeta(STableInfo *pTable, void *thandle) {
bool
usePublicIp
=
(
connInfo
.
serverIp
==
tsPublicIpInt
);
bool
usePublicIp
=
(
connInfo
.
serverIp
==
tsPublicIpInt
);
STableMeta
*
pMeta
=
rpcMallocCont
(
sizeof
(
STableMeta
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
);
STableMeta
Msg
*
pMeta
=
rpcMallocCont
(
sizeof
(
STableMetaMsg
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
);
rpcRsp
.
code
=
mgmtGetTableMeta
(
pDb
,
pTable
,
pMeta
,
usePublicIp
);
rpcRsp
.
code
=
mgmtGetTableMeta
(
pDb
,
pTable
,
pMeta
,
usePublicIp
);
if
(
rpcRsp
.
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
rpcRsp
.
code
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -695,7 +695,7 @@ void mgmtProcessMultiTableMetaMsg(SQueuedMsg *pMsg) {
...
@@ -695,7 +695,7 @@ void mgmtProcessMultiTableMetaMsg(SQueuedMsg *pMsg) {
if
(
pDb
==
NULL
)
continue
;
if
(
pDb
==
NULL
)
continue
;
int
availLen
=
totalMallocLen
-
pMultiMeta
->
contLen
;
int
availLen
=
totalMallocLen
-
pMultiMeta
->
contLen
;
if
(
availLen
<=
sizeof
(
STableMeta
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
)
{
if
(
availLen
<=
sizeof
(
STableMeta
Msg
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
)
{
//TODO realloc
//TODO realloc
//totalMallocLen *= 2;
//totalMallocLen *= 2;
//pMultiMeta = rpcReMalloc(pMultiMeta, totalMallocLen);
//pMultiMeta = rpcReMalloc(pMultiMeta, totalMallocLen);
...
@@ -708,7 +708,7 @@ void mgmtProcessMultiTableMetaMsg(SQueuedMsg *pMsg) {
...
@@ -708,7 +708,7 @@ void mgmtProcessMultiTableMetaMsg(SQueuedMsg *pMsg) {
//}
//}
}
}
STableMeta
*
pMeta
=
(
STableMeta
*
)(
pMultiMeta
->
metas
+
pMultiMeta
->
contLen
);
STableMeta
Msg
*
pMeta
=
(
STableMetaMsg
*
)(
pMultiMeta
->
metas
+
pMultiMeta
->
contLen
);
int32_t
code
=
mgmtGetTableMeta
(
pDb
,
pTable
,
pMeta
,
usePublicIp
);
int32_t
code
=
mgmtGetTableMeta
(
pDb
,
pTable
,
pMeta
,
usePublicIp
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
pMultiMeta
->
numOfTables
++
;
pMultiMeta
->
numOfTables
++
;
...
...
src/mnode/src/mgmtUser.c
浏览文件 @
03346d0c
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "os.h"
#include "os.h"
#include "trpc.h"
#include "trpc.h"
#include "tschemautil.h"
#include "ttime.h"
#include "ttime.h"
#include "mgmtAcct.h"
#include "mgmtAcct.h"
#include "mgmtGrant.h"
#include "mgmtGrant.h"
...
@@ -30,7 +29,7 @@ static int32_t tsUserUpdateSize = 0;
...
@@ -30,7 +29,7 @@ static int32_t tsUserUpdateSize = 0;
static
int32_t
mgmtCreateUser
(
SAcctObj
*
pAcct
,
char
*
name
,
char
*
pass
);
static
int32_t
mgmtCreateUser
(
SAcctObj
*
pAcct
,
char
*
name
,
char
*
pass
);
static
int32_t
mgmtDropUser
(
SAcctObj
*
pAcct
,
char
*
name
);
static
int32_t
mgmtDropUser
(
SAcctObj
*
pAcct
,
char
*
name
);
static
int32_t
mgmtUpdateUser
(
SUserObj
*
pUser
);
static
int32_t
mgmtUpdateUser
(
SUserObj
*
pUser
);
static
int32_t
mgmtGetUserMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtGetUserMeta
(
STableMeta
Msg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtRetrieveUsers
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mgmtRetrieveUsers
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
void
mgmtProcessCreateUserMsg
(
SQueuedMsg
*
pMsg
);
static
void
mgmtProcessCreateUserMsg
(
SQueuedMsg
*
pMsg
);
...
@@ -171,14 +170,14 @@ static int32_t mgmtDropUser(SAcctObj *pAcct, char *name) {
...
@@ -171,14 +170,14 @@ static int32_t mgmtDropUser(SAcctObj *pAcct, char *name) {
return
0
;
return
0
;
}
}
static
int32_t
mgmtGetUserMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
static
int32_t
mgmtGetUserMeta
(
STableMeta
Msg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
if
(
pUser
==
NULL
)
{
if
(
pUser
==
NULL
)
{
return
TSDB_CODE_INVALID_USER
;
return
TSDB_CODE_INVALID_USER
;
}
}
int32_t
cols
=
0
;
int32_t
cols
=
0
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
)
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
TSDB_USER_LEN
;
pShow
->
bytes
[
cols
]
=
TSDB_USER_LEN
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
...
...
src/mnode/src/mgmtVgroup.c
浏览文件 @
03346d0c
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
#include "os.h"
#include "os.h"
#include "taoserror.h"
#include "taoserror.h"
#include "tlog.h"
#include "tlog.h"
#include "tschemautil.h"
#include "tstatus.h"
#include "tstatus.h"
#include "mnode.h"
#include "mnode.h"
#include "mgmtBalance.h"
#include "mgmtBalance.h"
...
@@ -41,7 +40,7 @@ static void *mgmtVgroupActionDecode(void *row, char *str, int32_t size, int32_t
...
@@ -41,7 +40,7 @@ static void *mgmtVgroupActionDecode(void *row, char *str, int32_t size, int32_t
static
void
*
mgmtVgroupActionReset
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
static
void
*
mgmtVgroupActionReset
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
static
void
*
mgmtVgroupActionDestroy
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
static
void
*
mgmtVgroupActionDestroy
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
static
int32_t
mgmtGetVgroupMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtGetVgroupMeta
(
STableMeta
Msg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtRetrieveVgroups
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mgmtRetrieveVgroups
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
void
mgmtProcessCreateVnodeRsp
(
SRpcMsg
*
rpcMsg
);
static
void
mgmtProcessCreateVnodeRsp
(
SRpcMsg
*
rpcMsg
);
static
void
mgmtProcessDropVnodeRsp
(
SRpcMsg
*
rpcMsg
);
static
void
mgmtProcessDropVnodeRsp
(
SRpcMsg
*
rpcMsg
);
...
@@ -211,14 +210,14 @@ void mgmtCleanUpVgroups() {
...
@@ -211,14 +210,14 @@ void mgmtCleanUpVgroups() {
sdbCloseTable
(
tsVgroupSdb
);
sdbCloseTable
(
tsVgroupSdb
);
}
}
int32_t
mgmtGetVgroupMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
mgmtGetVgroupMeta
(
STableMeta
Msg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
SDbObj
*
pDb
=
mgmtGetDb
(
pShow
->
db
);
SDbObj
*
pDb
=
mgmtGetDb
(
pShow
->
db
);
if
(
pDb
==
NULL
)
{
if
(
pDb
==
NULL
)
{
return
TSDB_CODE_DB_NOT_SELECTED
;
return
TSDB_CODE_DB_NOT_SELECTED
;
}
}
int32_t
cols
=
0
;
int32_t
cols
=
0
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
)
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
4
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
...
...
src/inc/qpercentile.h
→
src/
query/
inc/qpercentile.h
浏览文件 @
03346d0c
...
@@ -13,8 +13,8 @@
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#ifndef TDENGINE_
T
PERCENTILE_H
#ifndef TDENGINE_
Q
PERCENTILE_H
#define TDENGINE_
T
PERCENTILE_H
#define TDENGINE_
Q
PERCENTILE_H
#include "qextbuffer.h"
#include "qextbuffer.h"
...
@@ -74,4 +74,4 @@ void tBucketIntHash(tMemBucket *pBucket, void *value, int16_t *segIdx, int16_t *
...
@@ -74,4 +74,4 @@ void tBucketIntHash(tMemBucket *pBucket, void *value, int16_t *segIdx, int16_t *
void
tBucketDoubleHash
(
tMemBucket
*
pBucket
,
void
*
value
,
int16_t
*
segIdx
,
int16_t
*
slotIdx
);
void
tBucketDoubleHash
(
tMemBucket
*
pBucket
,
void
*
value
,
int16_t
*
segIdx
,
int16_t
*
slotIdx
);
#endif // TDENGINE_
T
PERCENTILE_H
#endif // TDENGINE_
Q
PERCENTILE_H
src/query/src/qast.c
浏览文件 @
03346d0c
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
#include "taosdef.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "taosmsg.h"
#include "tlog.h"
#include "tlog.h"
#include "tschemautil.h"
//
#include "tschemautil.h"
#include "tsqlfunction.h"
#include "tsqlfunction.h"
#include "tstoken.h"
#include "tstoken.h"
#include "ttokendef.h"
#include "ttokendef.h"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录