Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
03346d0c
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
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" {
#include "tsclient.h"
#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_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)
...
...
@@ -67,7 +67,7 @@ typedef struct SJoinSubquerySupporter {
}
SJoinSubquerySupporter
;
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
tscDestroyDataBlock
(
STableDataBlocks
*
pDataBlock
);
...
...
@@ -81,7 +81,7 @@ int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock);
void
tscFreeUnusedDataBlocks
(
SDataBlockList
*
pList
);
int32_t
tscMergeTableDataBlocks
(
SSqlObj
*
pSql
,
SDataBlockList
*
pDataList
);
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
);
SVnodeSidList
*
tscGetVnodeSidList
(
SSuperTableMeta
*
pMetricmeta
,
int32_t
vnodeIdx
);
...
...
@@ -114,7 +114,7 @@ void tscAddSpecialColumnForSelect(SQueryInfo* pQueryInfo, int32_t outputColIndex
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
);
bool
tscIsInsertOrImportData
(
char
*
sqlstr
);
...
...
@@ -173,7 +173,7 @@ int32_t tscValidateName(SSQLToken* pToken);
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
SCond
*
tsGetMetricQueryCondPos
(
STagCond
*
pCond
,
uint64_t
tableIndex
);
...
...
@@ -190,26 +190,26 @@ void tscCleanSqlCmd(SSqlCmd* pCmd);
bool
tscShouldFreeAsyncSqlObj
(
SSqlObj
*
pSql
);
void
tscRemoveAllMeterMetaInfo
(
SQueryInfo
*
pQueryInfo
,
const
char
*
address
,
bool
removeFromCache
);
S
Meter
MetaInfo
*
tscGetMeterMetaInfo
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
,
int32_t
tableIndex
);
S
Meter
MetaInfo
*
tscGetMeterMetaInfoFromQueryInfo
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
S
Table
MetaInfo
*
tscGetMeterMetaInfo
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
,
int32_t
tableIndex
);
S
Table
MetaInfo
*
tscGetMeterMetaInfoFromQueryInfo
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
SQueryInfo
*
tscGetQueryInfoDetail
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
);
int32_t
tscGetQueryInfoDetailSafely
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
,
SQueryInfo
**
pQueryInfo
);
S
Meter
MetaInfo
*
tscGetMeterMetaInfoByUid
(
SQueryInfo
*
pQueryInfo
,
uint64_t
uid
,
int32_t
*
index
);
void
tscClearMeterMetaInfo
(
S
MeterMetaInfo
*
pMeter
MetaInfo
,
bool
removeFromCache
);
S
Table
MetaInfo
*
tscGetMeterMetaInfoByUid
(
SQueryInfo
*
pQueryInfo
,
uint64_t
uid
,
int32_t
*
index
);
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
);
S
Meter
MetaInfo
*
tscAddEmptyMeterMetaInfo
(
SQueryInfo
*
pQueryInfo
);
S
Table
MetaInfo
*
tscAddEmptyMeterMetaInfo
(
SQueryInfo
*
pQueryInfo
);
int32_t
tscAddSubqueryInfo
(
SSqlCmd
*
pCmd
);
void
tscFreeSubqueryInfo
(
SSqlCmd
*
pCmd
);
void
tscClearSubqueryInfo
(
SSqlCmd
*
pCmd
);
void
tscGetMetricMetaCacheKey
(
SQueryInfo
*
pQueryInfo
,
char
*
keyStr
,
uint64_t
uid
);
int
tscGetMetricMeta
(
SSqlObj
*
pSql
,
int32_t
clauseIndex
);
int
tscGetMeterMeta
(
SSqlObj
*
pSql
,
S
MeterMetaInfo
*
pMeter
MetaInfo
);
int
tscGetMeterMetaEx
(
SSqlObj
*
pSql
,
S
MeterMetaInfo
*
pMeter
MetaInfo
,
bool
createIfNotExists
);
int
tscGetMeterMeta
(
SSqlObj
*
pSql
,
S
TableMetaInfo
*
pTable
MetaInfo
);
int
tscGetMeterMetaEx
(
SSqlObj
*
pSql
,
S
TableMetaInfo
*
pTable
MetaInfo
,
bool
createIfNotExists
);
void
tscResetForNextRetrieve
(
SSqlRes
*
pRes
);
...
...
src/
util
/inc/tschemautil.h
→
src/
client
/inc/tschemautil.h
浏览文件 @
03346d0c
...
...
@@ -20,13 +20,56 @@
extern
"C"
{
#endif
#include <stdint.h>
#include "taosmsg.h"
#include "tstoken.h"
#include "tsclient.h"
#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:
...
...
@@ -42,13 +85,13 @@ struct SSchema;
*/
bool
isValidSchema
(
struct
SSchema
*
pSchema
,
int32_t
numOfCols
);
struct
SSchema
*
tsGetSchema
(
STableMeta
*
pMeta
);
struct
SSchema
*
tsGetTagSchema
(
STableMeta
*
pMeta
);
struct
SSchema
*
tsGetColumnSchema
(
STableMeta
*
pMeta
,
int32_t
startCol
);
struct
SSchema
tsGetTbnameColumnSchema
();
/**
* get the schema for the "tbname" column. it is a built column
* @return
*/
SSchema
tsGetTbnameColumnSchema
();
//todo tags value as well as the table id structure needs refactor
char
*
tsGetTagsValue
(
STableMeta
*
pMeta
);
bool
tsMeterMetaIdentical
(
STableMeta
*
p1
,
STableMeta
*
p2
);
...
...
src/client/inc/tsclient.h
浏览文件 @
03346d0c
...
...
@@ -46,8 +46,47 @@ typedef struct SSqlGroupbyExpr {
int16_t
orderType
;
// order by type: asc/desc
}
SSqlGroupbyExpr
;
typedef
struct
SMeterMetaInfo
{
STableMeta
*
pMeterMeta
;
// metermeta
typedef
struct
STableInfo
{
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
/*
...
...
@@ -55,10 +94,10 @@ typedef struct SMeterMetaInfo {
* 2. keep the vnode index for multi-vnode insertion
*/
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
tagColumnIndex
[
TSDB_MAX_TAGS
];
// clause + tag projection
}
S
Meter
MetaInfo
;
}
S
Table
MetaInfo
;
/* the structure for sql function in select clause */
typedef
struct
SSqlExpr
{
...
...
@@ -174,7 +213,7 @@ typedef struct STableDataBlocks {
* the metermeta for current table, the metermeta will be used during submit stage, keep a ref
* to avoid it to be removed from cache
*/
STableMeta
*
p
Meter
Meta
;
STableMeta
*
p
Table
Meta
;
union
{
char
*
filename
;
...
...
@@ -215,7 +254,7 @@ typedef struct SQueryInfo {
SOrderVal
order
;
int16_t
interpoType
;
// interpolate type
int16_t
numOfTables
;
S
Meter
MetaInfo
**
pMeterInfo
;
S
Table
MetaInfo
**
pMeterInfo
;
struct
STSBuf
*
tsBuf
;
int64_t
*
defaultVal
;
// default value for interpolation
char
*
msg
;
// pointer to the pCmd->payload to keep error message temporarily
...
...
src/client/src/tscAsync.c
浏览文件 @
03346d0c
...
...
@@ -406,11 +406,11 @@ void tscAsyncInsertMultiVnodesProxy(void *param, TAOS_RES *tres, int numOfRows)
int32_t
index
=
0
;
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
);
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
pSql
->
fp
=
pSql
->
fetchFp
;
tscTrace
(
"%p Async insertion completed, destroy data block list"
,
pSql
);
...
...
@@ -422,17 +422,17 @@ void tscAsyncInsertMultiVnodesProxy(void *param, TAOS_RES *tres, int numOfRows)
(
*
pSql
->
fp
)(
pSql
->
param
,
tres
,
numOfRows
);
}
else
{
do
{
code
=
tscCopyDataBlockToPayload
(
pSql
,
pDataBlocks
->
pData
[
p
Meter
MetaInfo
->
vnodeIndex
++
]);
code
=
tscCopyDataBlockToPayload
(
pSql
,
pDataBlocks
->
pData
[
p
Table
MetaInfo
->
vnodeIndex
++
]);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
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
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
);
}
}
...
...
@@ -464,10 +464,10 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
tscTrace
(
"%p renew tableMeta successfully, command:%d, code:%d, retry:%d"
,
pSql
,
pSql
->
cmd
.
command
,
pSql
->
res
.
code
,
pSql
->
retry
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
);
assert
(
p
MeterMetaInfo
->
pMeter
Meta
==
NULL
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
);
assert
(
p
TableMetaInfo
->
pTable
Meta
==
NULL
);
tscGetMeterMeta
(
pSql
,
p
Meter
MetaInfo
);
tscGetMeterMeta
(
pSql
,
p
Table
MetaInfo
);
code
=
tscSendMsgToServer
(
pSql
);
if
(
code
!=
0
)
{
pRes
->
code
=
code
;
...
...
@@ -489,18 +489,18 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
if
((
pQueryInfo
->
type
&
TSDB_QUERY_TYPE_STABLE_SUBQUERY
)
==
TSDB_QUERY_TYPE_STABLE_SUBQUERY
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
assert
(
pMeterMetaInfo
->
pMeterMeta
->
numOfTags
!=
0
&&
pMeter
MetaInfo
->
vnodeIndex
>=
0
&&
pSql
->
param
!=
NULL
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
// assert(pTableMetaInfo->pTableMeta->numOfTags != 0 && pTable
MetaInfo->vnodeIndex >= 0 && pSql->param != NULL);
SRetrieveSupport
*
trs
=
(
SRetrieveSupport
*
)
pSql
->
param
;
SSqlObj
*
pParObj
=
trs
->
pParentSqlObj
;
assert
(
pParObj
->
signature
==
pParObj
&&
trs
->
subqueryIndex
==
pMeter
MetaInfo
->
vnodeIndex
&&
pMeterMetaInfo
->
pMeter
Meta
->
numOfTags
!=
0
);
// assert(pParObj->signature == pParObj && trs->subqueryIndex == pTable
MetaInfo->vnodeIndex &&
// pTableMetaInfo->pTable
Meta->numOfTags != 0);
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
;
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
return
;
...
...
@@ -513,11 +513,11 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
if
(
pCmd
->
isParseFinish
)
{
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
);
code
=
tscGetMeterMeta
(
pSql
,
p
Meter
MetaInfo
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
code
=
tscGetMeterMeta
(
pSql
,
p
Table
MetaInfo
);
assert
(
code
==
TSDB_CODE_SUCCESS
);
if
(
p
MeterMetaInfo
->
pMeter
Meta
)
{
if
(
p
TableMetaInfo
->
pTable
Meta
)
{
code
=
tscSendMsgToServer
(
pSql
);
if
(
code
==
TSDB_CODE_SUCCESS
)
return
;
}
...
...
@@ -528,13 +528,13 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
}
}
else
{
// stream computing
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
code
=
tscGetMeterMeta
(
pSql
,
p
Meter
MetaInfo
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
code
=
tscGetMeterMeta
(
pSql
,
p
Table
MetaInfo
);
pRes
->
code
=
code
;
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
);
pRes
->
code
=
code
;
...
...
src/client/src/tscJoinProcess.c
浏览文件 @
03346d0c
...
...
@@ -164,8 +164,8 @@ SJoinSubquerySupporter* tscCreateJoinSupporter(SSqlObj* pSql, SSubqueryState* pS
pSupporter
->
interval
=
pQueryInfo
->
intervalTime
;
pSupporter
->
limit
=
pQueryInfo
->
limit
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
pSql
->
cmd
.
clauseIndex
,
index
);
pSupporter
->
uid
=
p
MeterMetaInfo
->
pMeter
Meta
->
uid
;
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
pSql
->
cmd
.
clauseIndex
,
index
);
pSupporter
->
uid
=
p
TableMetaInfo
->
pTable
Meta
->
uid
;
assert
(
pSupporter
->
uid
!=
0
);
...
...
@@ -315,7 +315,7 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
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
...
...
@@ -325,11 +325,11 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
pNewQueryInfo
->
limit
=
pSupporter
->
limit
;
// 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
);
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
->
numOfParams
=
1
;
}
...
...
@@ -337,7 +337,7 @@ int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) {
tscPrintSelectClause
(
pNew
,
0
);
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
->
fieldsInfo
.
numOfOutputCols
,
pNewQueryInfo
->
pMeterInfo
[
0
]
->
name
);
}
...
...
@@ -450,9 +450,9 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
pSupporter
->
pTSBuf
=
pBuf
;
}
else
{
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
);
}
...
...
@@ -467,14 +467,14 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
//todo refactor
if
(
tscNonOrderedProjectionQueryOnSTable
(
pParentQueryInfo
,
0
))
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
assert
(
pQueryInfo
->
numOfTables
==
1
);
// for projection query, need to try next vnode
int32_t
totalVnode
=
p
Meter
MetaInfo
->
pMetricMeta
->
numOfVnodes
;
if
((
++
p
Meter
MetaInfo
->
vnodeIndex
)
<
totalVnode
)
{
int32_t
totalVnode
=
p
Table
MetaInfo
->
pMetricMeta
->
numOfVnodes
;
if
((
++
p
Table
MetaInfo
->
vnodeIndex
)
<
totalVnode
)
{
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
->
fp
=
tscJoinQueryCallback
;
...
...
@@ -532,11 +532,11 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
}
if
(
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
)
&&
numOfRows
==
0
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
assert
(
pQueryInfo
->
numOfTables
==
1
);
// 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
->
numOfTotal
=
1
;
...
...
@@ -600,10 +600,10 @@ void tscFetchDatablockFromSubquery(SSqlObj* pSql) {
SSqlRes
*
pRes
=
&
pSql
->
pSubs
[
i
]
->
res
;
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
(
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
)))
{
numOfFetch
++
;
}
...
...
@@ -638,11 +638,11 @@ void tscFetchDatablockFromSubquery(SSqlObj* pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd1
,
0
);
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
)
{
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
);
pSql1
->
fp
=
joinRetrieveCallback
;
...
...
@@ -688,8 +688,8 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
int32_t
tableIndexOfSub
=
-
1
;
for
(
int32_t
j
=
0
;
j
<
pQueryInfo
->
numOfTables
;
++
j
)
{
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
j
);
if
(
p
MeterMetaInfo
->
pMeter
Meta
->
uid
==
pExpr
->
uid
)
{
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
j
);
if
(
p
TableMetaInfo
->
pTable
Meta
->
uid
==
pExpr
->
uid
)
{
tableIndexOfSub
=
j
;
break
;
}
...
...
@@ -712,13 +712,13 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
void
tscJoinQueryCallback
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
{
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;
// SVnodeSidList *vnodeInfo = NULL;
// if (p
Meter
MetaInfo->pMetricMeta != NULL) {
// vnodeInfo = tscGetVnodeSidList(p
Meter
MetaInfo->pMetricMeta, idx - 1);
// if (p
Table
MetaInfo->pMetricMeta != NULL) {
// vnodeInfo = tscGetVnodeSidList(p
Table
MetaInfo->pMetricMeta, idx - 1);
// }
SJoinSubquerySupporter
*
pSupporter
=
(
SJoinSubquerySupporter
*
)
param
;
...
...
@@ -776,14 +776,14 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) {
assert
(
finished
==
numOfTotal
);
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
* data instead of returning to its invoker
*/
if
(
p
Meter
MetaInfo
->
vnodeIndex
>
0
&&
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
))
{
assert
(
p
MeterMetaInfo
->
vnodeIndex
<
pMeter
MetaInfo
->
pMetricMeta
->
numOfVnodes
);
if
(
p
Table
MetaInfo
->
vnodeIndex
>
0
&&
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
))
{
assert
(
p
TableMetaInfo
->
vnodeIndex
<
pTable
MetaInfo
->
pMetricMeta
->
numOfVnodes
);
pSupporter
->
pState
->
numOfCompleted
=
0
;
// reset the record value
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
* length((uint64_t) 123456789011) > 12, greater than sizsof(uint64_t)
*/
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
||
pMeta
->
tableType
==
TSDB_STREAM_TABLE
)
{
...
...
@@ -85,12 +85,14 @@ static int32_t tscMaxLengthOfTagsFields(SSqlObj *pSql) {
}
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
);
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
);
if
(
len
<
tLen
)
{
len
=
tLen
;
...
...
@@ -108,8 +110,8 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
// one column for each row
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
STableMeta
*
pMeta
=
p
MeterMetaInfo
->
pMeter
Meta
;
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
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.
...
...
@@ -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
*/
int32_t
numOfRows
=
pMeta
->
numOfColumns
;
int32_t
totalNumOfRows
=
numOfRows
+
pMeta
->
numOfTags
;
int32_t
numOfRows
=
tscGetNumOfColumns
(
pMeta
)
;
int32_t
totalNumOfRows
=
numOfRows
+
tscGetNumOfTags
(
pMeta
)
;
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
))
{
numOfRows
=
pMeta
->
numOfColumns
+
pMeta
->
numOfTags
;
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
))
{
numOfRows
=
numOfRows
+
tscGetNumOfTags
(
pMeta
)
;
}
tscInitResObjForLocalQuery
(
pSql
,
totalNumOfRows
,
rowLen
);
SSchema
*
pSchema
=
ts
Get
Schema
(
pMeta
);
SSchema
*
pSchema
=
ts
cGetTable
Schema
(
pMeta
);
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
pQueryInfo
,
0
);
...
...
@@ -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
;
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"
,
strlen
(
"tag"
)
+
1
);
}
}
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Meter
MetaInfo
))
{
if
(
UTIL_METER_IS_SUPERTABLE
(
p
Table
MetaInfo
))
{
return
0
;
}
...
...
@@ -265,7 +267,7 @@ static int32_t tscBuildMeterSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
static
int32_t
tscProcessDescribeTable
(
SSqlObj
*
pSql
)
{
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
assert
(
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
TYPE_COLUMN_LENGTH
=
16
;
...
...
@@ -290,15 +292,15 @@ static int tscBuildMetricTagProjectionResult(SSqlObj *pSql) {
SSqlRes
*
pRes
=
&
pSql
->
res
;
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
;
SSchema
*
pSchema
=
ts
GetTagSchema
(
pMeterMetaInfo
->
pMeter
Meta
);
SSuperTableMeta
*
pMetricMeta
=
p
Table
MetaInfo
->
pMetricMeta
;
SSchema
*
pSchema
=
ts
cGetTableTagSchema
(
pTableMetaInfo
->
pTable
Meta
);
int32_t
vOffset
[
TSDB_MAX_COLUMNS
]
=
{
0
};
for
(
int32_t
f
=
1
;
f
<
p
Meter
MetaInfo
->
numOfTags
;
++
f
)
{
int16_t
tagColumnIndex
=
p
Meter
MetaInfo
->
tagColumnIndex
[
f
-
1
];
for
(
int32_t
f
=
1
;
f
<
p
Table
MetaInfo
->
numOfTags
;
++
f
)
{
int16_t
tagColumnIndex
=
p
Table
MetaInfo
->
tagColumnIndex
[
f
-
1
];
if
(
tagColumnIndex
==
-
1
)
{
vOffset
[
f
]
=
vOffset
[
f
-
1
]
+
TSDB_TABLE_NAME_LEN
;
}
else
{
...
...
@@ -375,8 +377,8 @@ static int tscProcessQueryTags(SSqlObj *pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
STableMeta
*
p
MeterMeta
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
)
->
pMeter
Meta
;
if
(
p
MeterMeta
==
NULL
||
pMeterMeta
->
numOfTags
==
0
||
pMeterMeta
->
numOfColumns
==
0
)
{
STableMeta
*
p
TableMeta
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
)
->
pTable
Meta
;
if
(
p
TableMeta
==
NULL
||
tscGetNumOfTags
(
pTableMeta
)
==
0
||
tscGetNumOfColumns
(
pTableMeta
)
==
0
)
{
strcpy
(
pCmd
->
payload
,
"invalid table"
);
pSql
->
res
.
code
=
TSDB_CODE_INVALID_TABLE
;
return
pSql
->
res
.
code
;
...
...
src/client/src/tscParseInsert.c
浏览文件 @
03346d0c
...
...
@@ -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
)
{
int32_t
index
=
0
;
SSQLToken
sToken
;
int16_t
numOfRows
=
0
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
int32_t
precision
=
pMeterMeta
->
precision
;
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMeta
);
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMeta
);
int32_t
precision
=
tinfo
.
precision
;
if
(
spd
->
hasVal
[
0
]
==
false
)
{
strcpy
(
error
,
"primary timestamp column can not be null"
);
...
...
@@ -518,9 +520,9 @@ int tsParseValues(char **str, STableDataBlocks *pDataBlock, STableMeta *pMeterMe
if
(
sToken
.
n
==
0
||
sToken
.
type
!=
TK_LP
)
break
;
*
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
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
strcpy
(
error
,
"client out of memory"
);
*
code
=
retcode
;
...
...
@@ -601,10 +603,10 @@ int32_t tscAllocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int3
return
TSDB_CODE_SUCCESS
;
}
static
void
tsSetBlockInfo
(
SShellSubmitBlock
*
pBlocks
,
const
STableMeta
*
p
Meter
Meta
,
int32_t
numOfRows
)
{
pBlocks
->
sid
=
p
Meter
Meta
->
sid
;
pBlocks
->
uid
=
p
Meter
Meta
->
uid
;
pBlocks
->
sversion
=
p
Meter
Meta
->
sversion
;
static
void
tsSetBlockInfo
(
SShellSubmitBlock
*
pBlocks
,
const
STableMeta
*
p
Table
Meta
,
int32_t
numOfRows
)
{
pBlocks
->
sid
=
p
Table
Meta
->
sid
;
pBlocks
->
uid
=
p
Table
Meta
->
uid
;
pBlocks
->
sversion
=
p
Table
Meta
->
sversion
;
pBlocks
->
numOfRows
+=
numOfRows
;
}
...
...
@@ -654,19 +656,20 @@ void sortRemoveDuplicates(STableDataBlocks *dataBuf) {
static
int32_t
doParseInsertStatement
(
SSqlObj
*
pSql
,
void
*
pTableHashList
,
char
**
str
,
SParsedDataColInfo
*
spd
,
int32_t
*
totalNum
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
STableMeta
*
pMeterMeta
=
pMeterMetaInfo
->
pMeterMeta
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMeta
);
STableDataBlocks
*
dataBuf
=
NULL
;
int32_t
ret
=
tscGetDataBlockFromList
(
pTableHashList
,
pCmd
->
pDataBlocks
,
p
Meter
Meta
->
uid
,
TSDB_DEFAULT_PAYLOAD_SIZE
,
sizeof
(
SShellSubmitBlock
),
pMeterMeta
->
rowSize
,
pMeter
MetaInfo
->
name
,
p
Meter
Meta
,
&
dataBuf
);
int32_t
ret
=
tscGetDataBlockFromList
(
pTableHashList
,
pCmd
->
pDataBlocks
,
p
Table
Meta
->
uid
,
TSDB_DEFAULT_PAYLOAD_SIZE
,
sizeof
(
SShellSubmitBlock
),
tinfo
.
rowSize
,
pTable
MetaInfo
->
name
,
p
Table
Meta
,
&
dataBuf
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
}
int32_t
maxNumOfRows
;
ret
=
tscAllocateMemIfNeed
(
dataBuf
,
pMeterMeta
->
rowSize
,
&
maxNumOfRows
);
ret
=
tscAllocateMemIfNeed
(
dataBuf
,
tinfo
.
rowSize
,
&
maxNumOfRows
);
if
(
TSDB_CODE_SUCCESS
!=
ret
)
{
return
TSDB_CODE_CLI_OUT_OF_MEMORY
;
}
...
...
@@ -677,7 +680,7 @@ static int32_t doParseInsertStatement(SSqlObj *pSql, void *pTableHashList, char
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
);
if
(
numOfRows
<=
0
)
{
return
code
;
...
...
@@ -692,9 +695,9 @@ static int32_t doParseInsertStatement(SSqlObj *pSql, void *pTableHashList, char
}
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
;
/*
...
...
@@ -756,7 +759,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
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
index
=
0
;
...
...
@@ -767,13 +770,13 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
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
)
{
tscAddEmptyMeterMetaInfo
(
pQueryInfo
);
}
S
Meter
MetaInfo
*
pSTableMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
STABLE_INDEX
);
S
Table
MetaInfo
*
pSTableMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
STABLE_INDEX
);
setMeterID
(
pSTableMeterMetaInfo
,
&
sToken
,
pSql
);
strncpy
(
pTag
->
name
,
pSTableMeterMetaInfo
->
name
,
TSDB_TABLE_ID_LEN
);
...
...
@@ -786,15 +789,16 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
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
;
sToken
=
tStrGetToken
(
sql
,
&
index
,
false
,
0
,
NULL
);
sql
+=
index
;
SParsedDataColInfo
spd
=
{
0
};
uint8_t
numOfTags
=
pSTableMeterMetaInfo
->
pMeterMeta
->
numOfTags
;
uint8_t
numOfTags
=
tscGetNumOfTags
(
pSTableMeterMetaInfo
->
pTableMeta
)
;
spd
.
numOfCols
=
numOfTags
;
// if specify some tags column
...
...
@@ -881,8 +885,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
sToken
.
n
-=
2
;
}
code
=
tsParseOneColumnData
(
&
pTagSchema
[
colIndex
],
&
sToken
,
tagVal
,
pCmd
->
payload
,
&
sql
,
false
,
pSTableMeterMetaInfo
->
pMeterMeta
->
precision
);
code
=
tsParseOneColumnData
(
&
pTagSchema
[
colIndex
],
&
sToken
,
tagVal
,
pCmd
->
payload
,
&
sql
,
false
,
tinfo
.
precision
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -917,13 +920,13 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
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
)
{
return
ret
;
}
createTable
=
true
;
code
=
tscGetMeterMetaEx
(
pSql
,
p
Meter
MetaInfo
,
true
);
code
=
tscGetMeterMetaEx
(
pSql
,
p
Table
MetaInfo
,
true
);
if
(
TSDB_CODE_ACTION_IN_PROGRESS
==
code
)
{
return
code
;
}
...
...
@@ -934,7 +937,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
}
else
{
sql
=
sToken
.
z
;
}
code
=
tscGetMeterMeta
(
pSql
,
p
Meter
MetaInfo
);
code
=
tscGetMeterMeta
(
pSql
,
p
Table
MetaInfo
);
}
int32_t
len
=
cend
-
cstart
+
1
;
...
...
@@ -983,15 +986,15 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
int32_t
totalNum
=
0
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
NULL
;
S
TableMetaInfo
*
pTable
MetaInfo
=
NULL
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
assert
(
pQueryInfo
!=
NULL
);
if
(
pQueryInfo
->
numOfTables
==
0
)
{
p
Meter
MetaInfo
=
tscAddEmptyMeterMetaInfo
(
pQueryInfo
);
p
Table
MetaInfo
=
tscAddEmptyMeterMetaInfo
(
pQueryInfo
);
}
else
{
p
Meter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
p
Table
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
}
if
((
code
=
tscAllocPayload
(
pCmd
,
TSDB_PAYLOAD_SIZE
))
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -1050,7 +1053,7 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
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
;
}
...
...
@@ -1078,7 +1081,7 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
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
);
goto
_error_clean
;
}
...
...
@@ -1091,12 +1094,16 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
code
=
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
"keyword VALUES or FILE required"
,
sToken
.
z
);
goto
_error_clean
;
}
int32_t
numOfCols
=
tscGetNumOfTags
(
pTableMetaInfo
->
pTableMeta
);
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
if
(
sToken
.
type
==
TK_VALUES
)
{
SParsedDataColInfo
spd
=
{.
numOfCols
=
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
};
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
SParsedDataColInfo
spd
=
{.
numOfCols
=
numOfCols
};
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMetaInfo
->
pTableMeta
);
tscSetAssignedColumnInfo
(
&
spd
,
pSchema
,
pMeterMetaInfo
->
pMeterMeta
->
numOfColumn
s
);
tscSetAssignedColumnInfo
(
&
spd
,
pSchema
,
numOfCol
s
);
if
(
validateDataSource
(
pCmd
,
DATA_FROM_SQL_STRING
,
sToken
.
z
)
!=
TSDB_CODE_SUCCESS
)
{
goto
_error_clean
;
...
...
@@ -1136,10 +1143,10 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
wordfree
(
&
full_path
);
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
,
p
Meter
Meta
,
&
pDataBlock
);
int32_t
ret
=
tscCreateDataBlock
(
PATH_MAX
,
tinfo
.
rowSize
,
sizeof
(
SShellSubmitBlock
),
pTable
MetaInfo
->
name
,
p
Table
Meta
,
&
pDataBlock
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
goto
_error_clean
;
}
...
...
@@ -1148,18 +1155,18 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
strcpy
(
pDataBlock
->
filename
,
fname
);
}
else
if
(
sToken
.
type
==
TK_LP
)
{
/* insert into tablename(col1, col2,..., coln) values(v1, v2,... vn); */
STableMeta
*
p
MeterMeta
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
)
->
pMeter
Meta
;
SSchema
*
pSchema
=
ts
GetSchema
(
pMeter
Meta
);
STableMeta
*
p
TableMeta
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
)
->
pTable
Meta
;
SSchema
*
pSchema
=
ts
cGetTableSchema
(
pTable
Meta
);
if
(
validateDataSource
(
pCmd
,
DATA_FROM_SQL_STRING
,
sToken
.
z
)
!=
TSDB_CODE_SUCCESS
)
{
goto
_error_clean
;
}
SParsedDataColInfo
spd
=
{
0
};
spd
.
numOfCols
=
pMeterMeta
->
numOfColumns
;
spd
.
numOfCols
=
tinfo
.
numOfColumns
;
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
;
}
...
...
@@ -1181,7 +1188,7 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
bool
findColumnIndex
=
false
;
// 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
)
{
SParsedColElem
*
pElem
=
&
spd
.
elems
[
spd
.
numOfAssignedCols
++
];
pElem
->
offset
=
offset
[
t
];
...
...
@@ -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
);
goto
_error_clean
;
}
...
...
@@ -1245,10 +1252,10 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
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
p
Meter
MetaInfo
->
vnodeIndex
=
1
;
p
Table
MetaInfo
->
vnodeIndex
=
1
;
}
else
{
pCmd
->
pDataBlocks
=
tscDestroyBlockArrayList
(
pCmd
->
pDataBlocks
);
}
...
...
@@ -1348,10 +1355,10 @@ static int doPackSendDataBlock(SSqlObj *pSql, int32_t numOfRows, STableDataBlock
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
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
);
tsSetBlockInfo
(
pBlocks
,
p
Meter
Meta
,
numOfRows
);
tsSetBlockInfo
(
pBlocks
,
p
Table
Meta
,
numOfRows
);
if
((
code
=
tscMergeTableDataBlocks
(
pSql
,
pCmd
->
pDataBlocks
))
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
...
...
@@ -1381,16 +1388,18 @@ static int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp, char *tmpTokenBuf) {
int32_t
code
=
0
;
int
nrows
=
0
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
STableMeta
*
pMeterMeta
=
pMeterMetaInfo
->
pMeterMeta
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMeta
);
assert
(
pCmd
->
numOfClause
==
1
);
int32_t
rowSize
=
pMeterMeta
->
rowSize
;
int32_t
rowSize
=
tinfo
.
rowSize
;
pCmd
->
pDataBlocks
=
tscCreateBlockArrayList
();
STableDataBlocks
*
pTableDataBlock
=
NULL
;
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
)
{
return
-
1
;
}
...
...
@@ -1401,10 +1410,10 @@ static int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp, char *tmpTokenBuf) {
if
(
TSDB_CODE_SUCCESS
!=
code
)
return
-
1
;
int
count
=
0
;
SParsedDataColInfo
spd
=
{.
numOfCols
=
pMeterMeta
->
numOfColumns
};
SSchema
*
pSchema
=
ts
GetSchema
(
pMeter
Meta
);
SParsedDataColInfo
spd
=
{.
numOfCols
=
tinfo
.
numOfColumns
};
SSchema
*
pSchema
=
ts
cGetTableSchema
(
pTable
Meta
);
tscSetAssignedColumnInfo
(
&
spd
,
pSchema
,
pMeterMeta
->
numOfColumns
);
tscSetAssignedColumnInfo
(
&
spd
,
pSchema
,
tinfo
.
numOfColumns
);
while
((
readLen
=
getline
(
&
line
,
&
n
,
fp
))
!=
-
1
)
{
// line[--readLen] = '\0';
...
...
@@ -1414,7 +1423,7 @@ static int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp, char *tmpTokenBuf) {
char
*
lineptr
=
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
)
{
pSql
->
res
.
code
=
code
;
return
(
-
code
);
...
...
@@ -1431,7 +1440,7 @@ static int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp, char *tmpTokenBuf) {
pTableDataBlock
=
pCmd
->
pDataBlocks
->
pData
[
0
];
pTableDataBlock
->
size
=
sizeof
(
SShellSubmitBlock
);
pTableDataBlock
->
rowSize
=
pMeterMeta
->
rowSize
;
pTableDataBlock
->
rowSize
=
tinfo
.
rowSize
;
numOfRows
+=
pSql
->
res
.
numOfRows
;
pSql
->
res
.
numOfRows
=
0
;
...
...
@@ -1473,25 +1482,25 @@ void tscProcessMultiVnodesInsert(SSqlObj *pSql) {
}
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
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
/* 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
;
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
];
if
(
pDataBlock
==
NULL
)
{
continue
;
}
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
);
continue
;
}
...
...
@@ -1512,7 +1521,7 @@ void tscProcessMultiVnodesInsertFromFile(SSqlObj *pSql) {
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
STableDataBlocks
*
pDataBlock
=
NULL
;
int32_t
affected_rows
=
0
;
...
...
@@ -1543,10 +1552,10 @@ void tscProcessMultiVnodesInsertFromFile(SSqlObj *pSql) {
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
);
int32_t
ret
=
tscGetMeterMeta
(
pSql
,
p
Meter
MetaInfo
);
int32_t
ret
=
tscGetMeterMeta
(
pSql
,
p
Table
MetaInfo
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"%p get meter meta failed, abort"
,
pSql
);
continue
;
...
...
src/client/src/tscPrepare.c
浏览文件 @
03346d0c
...
...
@@ -407,8 +407,8 @@ static int insertStmtReset(STscStmt* pStmt) {
}
pCmd
->
batchSize
=
0
;
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
p
Meter
MetaInfo
->
vnodeIndex
=
0
;
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
p
Table
MetaInfo
->
vnodeIndex
=
0
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -421,7 +421,7 @@ static int insertStmtExecute(STscStmt* stmt) {
++
pCmd
->
batchSize
;
}
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
assert
(
pCmd
->
numOfClause
==
1
);
if
(
pCmd
->
pDataBlocks
->
nSize
>
0
)
{
...
...
@@ -438,7 +438,7 @@ static int insertStmtExecute(STscStmt* stmt) {
}
// set the next sent data vnode index in data block arraylist
p
Meter
MetaInfo
->
vnodeIndex
=
1
;
p
Table
MetaInfo
->
vnodeIndex
=
1
;
}
else
{
pCmd
->
pDataBlocks
=
tscDestroyBlockArrayList
(
pCmd
->
pDataBlocks
);
}
...
...
src/client/src/tscSQLParser.c
浏览文件 @
03346d0c
此差异已折叠。
点击以展开。
src/client/src/tscSchemaUtil.c
浏览文件 @
03346d0c
...
...
@@ -19,6 +19,70 @@
#include "ttokendef.h"
#include "taosdef.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
)
{
if
(
!
VALIDNUMOFCOLS
(
numOfCols
))
{
...
...
@@ -64,34 +128,32 @@ bool isValidSchema(struct SSchema* pSchema, int32_t numOfCols) {
return
(
rowLen
<=
TSDB_MAX_BYTES_PER_ROW
);
}
struct
SSchema
*
tsGetSchema
(
STableMeta
*
pMeta
)
{
if
(
pMeta
==
NULL
)
{
return
NULL
;
}
return
tsGetColumnSchema
(
pMeta
,
0
);
}
struct
SSchema
*
tsGetTagSchema
(
STableMeta
*
pMeta
)
{
if
(
pMeta
==
NULL
||
pMeta
->
numOfTags
==
0
)
{
return
NULL
;
SSchema
*
tscGetTableColumnSchema
(
const
STableMeta
*
pTableMeta
,
int32_t
startCol
)
{
assert
(
pTableMeta
!=
NULL
);
SSchema
*
pSchema
=
pTableMeta
->
schema
;
if
(
pTableMeta
->
tableType
==
TSDB_CHILD_TABLE
)
{
assert
(
pTableMeta
->
pSTable
!=
NULL
);
pSchema
=
pTableMeta
->
pSTable
->
schema
;
}
return
tsGetColumnSchema
(
pMeta
,
pMeta
->
numOfColumns
);
}
struct
SSchema
*
tsGetColumnSchema
(
STableMeta
*
pMeta
,
int32_t
startCol
)
{
return
(
SSchema
*
)(((
char
*
)
pMeta
+
sizeof
(
STableMeta
))
+
startCol
*
sizeof
(
SSchema
));
return
&
pSchema
[
startCol
];
}
struct
SSchema
tsGetTbnameColumnSchema
()
{
struct
SSchema
s
=
{.
colId
=
TSDB_TBNAME_COLUMN_INDEX
,
.
type
=
TSDB_DATA_TYPE_BINARY
,
.
bytes
=
TSDB_TABLE_NAME_LEN
};
strcpy
(
s
.
name
,
TSQL_TBNAME_L
);
struct
SSchema
s
=
{
.
colId
=
TSDB_TBNAME_COLUMN_INDEX
,
.
type
=
TSDB_DATA_TYPE_BINARY
,
.
bytes
=
TSDB_TABLE_NAME_LEN
};
strcpy
(
s
.
name
,
TSQL_TBNAME_L
);
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)
...
...
@@ -101,33 +163,35 @@ struct SSchema tsGetTbnameColumnSchema() {
* |Tags data | tag_col_1.bytes + tag_col_2.bytes + ....
* +--------------------+
*
* @param pMeta
* @param p
Table
Meta
* @return
*/
char
*
tsGetTagsValue
(
STableMeta
*
pMeta
)
{
int32_t
numOfTotalCols
=
pMeta
->
numOfColumns
+
pMeta
->
numOfTags
;
uint32_t
offset
=
sizeof
(
STableMeta
)
+
numOfTotalCols
*
sizeof
(
SSchema
);
char
*
tsGetTagsValue
(
STableMeta
*
pTableMeta
)
{
int32_t
offset
=
0
;
// 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
)
{
if
(
p1
==
NULL
||
p2
==
NULL
||
p1
->
uid
!=
p2
->
uid
||
p1
->
sversion
!=
p2
->
sversion
)
{
return
false
;
}
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
=
tsGetColumnSchema
(
p1
,
i
+
p1
->
numOfColumns
);
size
+=
pColSchema
->
bytes
;
}
return
memcmp
(
p1
,
p2
,
size
)
==
0
;
//
// 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
;
}
// todo refactor
...
...
src/client/src/tscSecondaryMerge.c
浏览文件 @
03346d0c
...
...
@@ -319,9 +319,10 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
pRes
->
pLocalReducer
=
pReducer
;
pRes
->
numOfGroups
=
0
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
int16_t
prec
=
pMeterMetaInfo
->
pMeterMeta
->
precision
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
int16_t
prec
=
tinfo
.
precision
;
int64_t
stime
=
(
pQueryInfo
->
stime
<
pQueryInfo
->
etime
)
?
pQueryInfo
->
stime
:
pQueryInfo
->
etime
;
int64_t
revisedSTime
=
taosGetIntervalStartTimestamp
(
stime
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
intervalTimeUnit
,
prec
);
...
...
@@ -602,9 +603,9 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
*
pFinalModel
=
NULL
;
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
)
{
tscError
(
"%p failed to allocate memory"
,
pSql
);
pRes
->
code
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
...
...
@@ -635,7 +636,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
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
]
->
flushModel
=
MULTIPLE_APPEND_MODEL
;
}
...
...
@@ -650,7 +651,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
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
type
=
-
1
;
...
...
@@ -774,9 +775,11 @@ void adjustLoserTreeFromNewData(SLocalReducer *pLocalReducer, SLocalDataSource *
void
savePrevRecordAndSetupInterpoInfo
(
SLocalReducer
*
pLocalReducer
,
SQueryInfo
*
pQueryInfo
,
SInterpolationInfo
*
pInterpoInfo
)
{
// discard following dataset in the same group and reset the interpolation information
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
int16_t
prec
=
pMeterMetaInfo
->
pMeterMeta
->
precision
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
int16_t
prec
=
tinfo
.
precision
;
int64_t
stime
=
(
pQueryInfo
->
stime
<
pQueryInfo
->
etime
)
?
pQueryInfo
->
stime
:
pQueryInfo
->
etime
;
int64_t
revisedSTime
=
taosGetIntervalStartTimestamp
(
stime
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
intervalTimeUnit
,
prec
);
...
...
@@ -917,8 +920,10 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
functions
[
i
]
=
tscSqlExprGet
(
pQueryInfo
,
i
)
->
functionId
;
}
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
int8_t
precision
=
pMeterMetaInfo
->
pMeterMeta
->
precision
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
int8_t
precision
=
tinfo
.
precision
;
while
(
1
)
{
int32_t
remains
=
taosNumOfRemainPoints
(
pInterpoInfo
);
...
...
@@ -1268,8 +1273,10 @@ static void resetEnvForNewResultset(SSqlRes *pRes, SSqlCmd *pCmd, SLocalReducer
pQueryInfo
->
limit
.
offset
=
pLocalReducer
->
offset
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
int16_t
precision
=
pMeterMetaInfo
->
pMeterMeta
->
precision
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
int8_t
precision
=
tinfo
.
precision
;
// for group result interpolation, do not return if not data is generated
if
(
pQueryInfo
->
interpoType
!=
TSDB_INTERPO_NONE
)
{
...
...
@@ -1294,8 +1301,10 @@ static bool doInterpolationForCurrentGroup(SSqlObj *pSql) {
SLocalReducer
*
pLocalReducer
=
pRes
->
pLocalReducer
;
SInterpolationInfo
*
pInterpoInfo
=
&
pLocalReducer
->
interpolationInfo
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
int8_t
p
=
pMeterMetaInfo
->
pMeterMeta
->
precision
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
int8_t
p
=
tinfo
.
precision
;
if
(
taosHasRemainsDataForInterpolation
(
pInterpoInfo
))
{
assert
(
pQueryInfo
->
interpoType
!=
TSDB_INTERPO_NONE
);
...
...
@@ -1328,8 +1337,10 @@ static bool doHandleLastRemainData(SSqlObj *pSql) {
bool
prevGroupCompleted
=
(
!
pLocalReducer
->
discard
)
&&
pLocalReducer
->
hasUnprocessedRow
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
int8_t
precision
=
pMeterMetaInfo
->
pMeterMeta
->
precision
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
int8_t
precision
=
tinfo
.
precision
;
if
((
isAllSourcesCompleted
(
pLocalReducer
)
&&
!
pLocalReducer
->
hasPrevRow
)
||
pLocalReducer
->
pLocalDataSrc
[
0
]
==
NULL
||
prevGroupCompleted
)
{
...
...
src/client/src/tscServer.c
浏览文件 @
03346d0c
此差异已折叠。
点击以展开。
src/client/src/tscSql.c
浏览文件 @
03346d0c
...
...
@@ -509,7 +509,7 @@ static bool tscHashRemainDataInSubqueryResultSet(SSqlObj *pSql) {
SSqlCmd
*
pCmd1
=
&
pSql
->
pSubs
[
i
]
->
cmd
;
SQueryInfo
*
pQueryInfo1
=
tscGetQueryInfoDetail
(
pCmd1
,
pCmd1
->
clauseIndex
);
S
Meter
MetaInfo
*
pMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo1
,
0
);
S
Table
MetaInfo
*
pMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo1
,
0
);
assert
(
pQueryInfo1
->
numOfTables
==
1
);
...
...
@@ -810,7 +810,7 @@ void taos_free_result_imp(TAOS_RES *res, int keepCmd) {
pQueryInfo
->
type
=
TSDB_QUERY_TYPE_FREE_RESOURCE
;
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.
...
...
@@ -825,7 +825,7 @@ void taos_free_result_imp(TAOS_RES *res, int keepCmd) {
if
(
pRes
->
code
!=
TSDB_CODE_QUERY_CANCELLED
&&
((
pRes
->
numOfRows
>
0
&&
pCmd
->
command
<
TSDB_SQL_LOCAL
)
||
(
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
;
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
SQueryInfo
*
pQueryInfo
=
NULL
;
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
)
{
return
code
;
...
...
@@ -1144,7 +1144,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
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
;
}
...
...
@@ -1154,7 +1154,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
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
);
if
(
pNewMem
==
NULL
)
{
code
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
...
...
@@ -1167,7 +1167,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
pMsg
=
pCmd
->
payload
;
}
payloadLen
+=
sprintf
(
pMsg
+
payloadLen
,
"%s,"
,
p
Meter
MetaInfo
->
name
);
payloadLen
+=
sprintf
(
pMsg
+
payloadLen
,
"%s,"
,
p
Table
MetaInfo
->
name
);
}
*
(
pMsg
+
payloadLen
)
=
'\0'
;
...
...
src/client/src/tscStream.c
浏览文件 @
03346d0c
...
...
@@ -13,15 +13,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <tschemautil.h>
#include "os.h"
#include "taosmsg.h"
#include "tlog.h"
#include "tscUtil.h"
#include "tsched.h"
#include "tsclient.h"
#include "ttime.h"
#include "ttimer.h"
#include "tutil.h"
#include "tsched.h"
#include "taosmsg.h"
#include "tscUtil.h"
#include "tsclient.h"
#include "tscProfile.h"
...
...
@@ -71,14 +72,14 @@ static void tscProcessStreamLaunchQuery(SSchedMsg *pMsg) {
pSql
->
param
=
pStream
;
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
;
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
);
pSql
->
res
.
code
=
code
;
...
...
@@ -96,7 +97,7 @@ static void tscProcessStreamLaunchQuery(SSchedMsg *pMsg) {
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
);
tscIncStreamExecutionCount
(
pStream
);
...
...
@@ -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
,
retryDelay
);
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
&
pStream
->
pSql
->
cmd
,
0
,
0
);
tscClearMeterMetaInfo
(
p
Meter
MetaInfo
,
true
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
&
pStream
->
pSql
->
cmd
,
0
,
0
);
tscClearMeterMetaInfo
(
p
Table
MetaInfo
,
true
);
tscSetRetryTimer
(
pStream
,
pStream
->
pSql
,
retryDelay
);
return
;
...
...
@@ -171,12 +172,12 @@ static void tscSetTimestampForRes(SSqlStream *pStream, SSqlObj *pSql) {
static
void
tscProcessStreamRetrieveResult
(
void
*
param
,
TAOS_RES
*
res
,
int
numOfRows
)
{
SSqlStream
*
pStream
=
(
SSqlStream
*
)
param
;
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
)
{
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
);
tscClearMeterMetaInfo
(
p
Meter
MetaInfo
,
true
);
tscClearMeterMetaInfo
(
p
Table
MetaInfo
,
true
);
tscSetRetryTimer
(
pStream
,
pStream
->
pSql
,
retryDelayTime
);
return
;
...
...
@@ -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
);
// 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
);
}
}
...
...
@@ -539,13 +540,14 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
STableInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
pStream
->
fp
=
fp
;
pStream
->
callback
=
callback
;
pStream
->
param
=
param
;
pStream
->
pSql
=
pSql
;
pStream
->
precision
=
pMeterMetaInfo
->
pMeterMeta
->
precision
;
pStream
->
precision
=
tinfo
.
precision
;
pStream
->
ctime
=
taosGetTimestamp
(
pStream
->
precision
);
pStream
->
etime
=
pQueryInfo
->
etime
;
...
...
@@ -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
);
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
;
}
...
...
src/client/src/tscSub.c
浏览文件 @
03346d0c
...
...
@@ -175,10 +175,10 @@ int tscUpdateSubscription(STscObj* pObj, SSub* pSub) {
return
0
;
}
S
MeterMetaInfo
*
pMeter
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
0
,
0
);
S
TableMetaInfo
*
pTable
MetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
0
,
0
);
int
numOfTables
=
0
;
if
(
!
UTIL_METER_IS_NOMRAL_METER
(
p
Meter
MetaInfo
))
{
SSuperTableMeta
*
pMetricMeta
=
p
Meter
MetaInfo
->
pMetricMeta
;
if
(
!
UTIL_METER_IS_NOMRAL_METER
(
p
Table
MetaInfo
))
{
SSuperTableMeta
*
pMetricMeta
=
p
Table
MetaInfo
->
pMetricMeta
;
for
(
int32_t
i
=
0
;
i
<
pMetricMeta
->
numOfVnodes
;
i
++
)
{
SVnodeSidList
*
pVnodeSidList
=
tscGetVnodeSidList
(
pMetricMeta
,
i
);
numOfTables
+=
pVnodeSidList
->
numOfSids
;
...
...
@@ -191,13 +191,13 @@ int tscUpdateSubscription(STscObj* pObj, SSub* pSub) {
return
0
;
}
if
(
UTIL_METER_IS_NOMRAL_METER
(
p
Meter
MetaInfo
))
{
if
(
UTIL_METER_IS_NOMRAL_METER
(
p
Table
MetaInfo
))
{
numOfTables
=
1
;
int64_t
uid
=
p
MeterMetaInfo
->
pMeter
Meta
->
uid
;
int64_t
uid
=
p
TableMetaInfo
->
pTable
Meta
->
uid
;
progress
[
0
].
uid
=
uid
;
progress
[
0
].
key
=
tscGetSubscriptionProgress
(
pSub
,
uid
);
}
else
{
SSuperTableMeta
*
pMetricMeta
=
p
Meter
MetaInfo
->
pMetricMeta
;
SSuperTableMeta
*
pMetricMeta
=
p
Table
MetaInfo
->
pMetricMeta
;
numOfTables
=
0
;
for
(
int32_t
i
=
0
;
i
<
pMetricMeta
->
numOfVnodes
;
i
++
)
{
SVnodeSidList
*
pVnodeSidList
=
tscGetVnodeSidList
(
pMetricMeta
,
i
);
...
...
src/client/src/tscUtil.c
浏览文件 @
03346d0c
此差异已折叠。
点击以展开。
src/inc/taosdef.h
浏览文件 @
03346d0c
...
...
@@ -165,7 +165,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
#define TSDB_MAX_COLUMNS 256
#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_COL_NAME_LEN 64
#define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 16
...
...
src/inc/taosmsg.h
浏览文件 @
03346d0c
...
...
@@ -678,15 +678,15 @@ typedef struct {
int32_t
list
[];
/* offset of SVnodeSidList, compared to the SSuperTableMeta struct */
}
SSuperTableMeta
;
typedef
struct
STableMeta
{
char
tableId
[
TSDB_TABLE_ID_LEN
+
1
];
// note: This field must be at the front
typedef
struct
STableMeta
Msg
{
char
tableId
[
TSDB_TABLE_ID_LEN
];
// note: This field must be at the front
int32_t
contLen
;
uint8_t
numOfTags
:
6
;
uint8_t
precision
:
2
;
uint8_t
tableType
:
4
;
uint8_t
index
:
4
;
// used locally
uint8_t
numOfTags
;
uint8_t
precision
;
uint8_t
tableType
;
//
uint8_t index : 4; // used locally
int16_t
numOfColumns
;
int16_t
rowSize
;
// used locally, calculated in client
//
int16_t rowSize; // used locally, calculated in client
int16_t
sversion
;
int8_t
numOfVpeers
;
SVnodeDesc
vpeerDesc
[
TSDB_VNODES_SUPPORT
];
...
...
@@ -694,12 +694,12 @@ typedef struct STableMeta {
int32_t
vgid
;
uint64_t
uid
;
SSchema
schema
[];
}
STableMeta
;
}
STableMeta
Msg
;
typedef
struct
SMultiTableMeta
{
int32_t
numOfTables
;
int32_t
contLen
;
STableMeta
metas
[];
STableMeta
Msg
metas
[];
}
SMultiTableMeta
;
typedef
struct
{
...
...
@@ -719,9 +719,9 @@ typedef struct {
char
payload
[];
}
SCMShowMsg
;
typedef
struct
{
uint64_t
qhandle
;
STableMeta
tableMeta
;
typedef
struct
SCMShowRsp
{
uint64_t
qhandle
;
STableMeta
Msg
tableMeta
;
}
SCMShowRsp
;
typedef
struct
{
...
...
src/mnode/inc/mgmtChildTable.h
浏览文件 @
03346d0c
...
...
@@ -36,7 +36,7 @@ void *mgmtBuildCreateChildTableMsg(SCMCreateTableMsg *pCreate, SChildTableObj *p
int32_t
mgmtDropChildTable
(
SQueuedMsg
*
newMsg
,
SChildTableObj
*
pTable
);
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
);
...
...
src/mnode/inc/mgmtNormalTable.h
浏览文件 @
03346d0c
...
...
@@ -35,7 +35,7 @@ int32_t mgmtDropNormalTable(SQueuedMsg *newMsg, SNormalTableObj *pTable);
int32_t
mgmtAddNormalTableColumn
(
SNormalTableObj
*
pTable
,
SSchema
schema
[],
int32_t
ncols
);
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
);
...
...
src/mnode/inc/mgmtShell.h
浏览文件 @
03346d0c
...
...
@@ -25,7 +25,7 @@ int32_t mgmtInitShell();
void
mgmtCleanUpShell
();
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
);
void
mgmtAddShellShowMetaHandle
(
uint8_t
showType
,
SShowMetaFp
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
int32_t
mgmtAddSuperTableColumn
(
SSuperTableObj
*
pTable
,
SSchema
schema
[],
int32_t
ncols
);
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
);
int32_t
mgmtFindSuperTableTagIndex
(
SSuperTableObj
*
pTable
,
const
char
*
tagName
);
...
...
src/mnode/inc/mgmtTable.h
浏览文件 @
03346d0c
...
...
@@ -30,7 +30,7 @@ void mgmtCleanUpTables();
STableInfo
*
mgmtGetTable
(
char
*
tableId
);
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
mgmtRemoveTableFromSuperTable
(
SSuperTableObj
*
pStable
);
...
...
src/mnode/src/mgmtChildTable.c
浏览文件 @
03346d0c
...
...
@@ -16,7 +16,6 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosmsg.h"
#include "tschemautil.h"
#include "tscompression.h"
#include "tskiplist.h"
#include "ttime.h"
...
...
@@ -442,7 +441,7 @@ int32_t mgmtModifyChildTableTagValueByName(SChildTableObj *pTable, char *tagName
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
->
sid
=
htonl
(
pTable
->
sid
);
pMeta
->
vgid
=
htonl
(
pTable
->
vgId
);
...
...
@@ -451,7 +450,7 @@ int32_t mgmtGetChildTableMeta(SDbObj *pDb, SChildTableObj *pTable, STableMeta *p
pMeta
->
numOfTags
=
pTable
->
superTable
->
numOfTags
;
pMeta
->
numOfColumns
=
htons
(
pTable
->
superTable
->
numOfColumns
);
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
);
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pTable
->
vgId
);
...
...
src/mnode/src/mgmtDb.c
浏览文件 @
03346d0c
...
...
@@ -16,7 +16,6 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "taoserror.h"
#include "tschemautil.h"
#include "tstatus.h"
#include "tutil.h"
#include "mnode.h"
...
...
@@ -41,7 +40,7 @@ static int32_t mgmtCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate);
static
void
mgmtDropDb
(
void
*
handle
,
void
*
tmrId
);
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
void
mgmtProcessCreateDbMsg
(
SQueuedMsg
*
pMsg
);
static
void
mgmtProcessAlterDbMsg
(
SQueuedMsg
*
pMsg
);
...
...
@@ -295,7 +294,8 @@ static int32_t mgmtCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate) {
bool
mgmtCheckIsMonitorDB
(
char
*
db
,
char
*
monitordb
)
{
char
dbName
[
TSDB_DB_NAME_LEN
+
1
]
=
{
0
};
extractDBName
(
db
,
dbName
);
assert
(
0
);
// extractDBName(db, dbName);
size_t
len
=
strlen
(
dbName
);
return
(
strncasecmp
(
dbName
,
monitordb
,
len
)
==
0
&&
len
==
strlen
(
monitordb
));
...
...
@@ -421,10 +421,10 @@ void mgmtCleanUpDbs() {
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
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
)
;
SSchema
*
pSchema
=
pMeta
->
schema
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
if
(
pUser
==
NULL
)
return
0
;
...
...
src/mnode/src/mgmtDnode.c
浏览文件 @
03346d0c
...
...
@@ -16,7 +16,6 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "tmodule.h"
#include "tschemautil.h"
#include "tstatus.h"
#include "mgmtBalance.h"
#include "mgmtDnode.h"
...
...
@@ -37,11 +36,11 @@ void (*mgmtSetDnodeUnRemoveFp)(SDnodeObj *pDnode) = NULL;
static
SDnodeObj
tsDnodeObj
=
{
0
};
static
void
*
mgmtGetNextDnode
(
SShowObj
*
pShow
,
SDnodeObj
**
pDnode
);
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
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
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
void
mgmtProcessCfgDnodeMsg
(
SQueuedMsg
*
pMsg
);
...
...
@@ -123,7 +122,7 @@ bool mgmtCheckModuleInDnode(SDnodeObj *pDnode, int32_t moduleType) {
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
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
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
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
)
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
16
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
...
...
@@ -216,7 +215,7 @@ int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pCo
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
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
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
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
)
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
TSDB_CFG_OPTION_LEN
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
...
...
@@ -304,13 +303,13 @@ static int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, vo
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
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
if
(
pUser
==
NULL
)
return
0
;
if
(
strcmp
(
pUser
->
user
,
"root"
)
!=
0
)
return
TSDB_CODE_NO_RIGHTS
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
)
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
4
;
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
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
->
sid
=
htonl
(
pTable
->
sid
);
pMeta
->
vgid
=
htonl
(
pTable
->
vgId
);
...
...
@@ -530,7 +530,7 @@ int32_t mgmtGetNormalTableMeta(SDbObj *pDb, SNormalTableObj *pTable, STableMeta
pMeta
->
numOfTags
=
0
;
pMeta
->
numOfColumns
=
htons
(
pTable
->
numOfColumns
);
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
);
if
(
pVgroup
==
NULL
)
{
...
...
src/mnode/src/mgmtProfile.c
浏览文件 @
03346d0c
...
...
@@ -16,7 +16,6 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosmsg.h"
#include "tschemautil.h"
#include "mgmtMnode.h"
#include "mgmtProfile.h"
#include "mgmtShell.h"
...
...
@@ -137,10 +136,10 @@ int32_t mgmtGetQueries(SShowObj *pShow, void *pConn) {
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
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
)
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
TSDB_USER_LEN
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
...
...
@@ -336,9 +335,9 @@ int32_t mgmtGetStreams(SShowObj *pShow, void *pConn) {
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
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
)
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
TSDB_USER_LEN
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
...
...
@@ -600,11 +599,11 @@ int mgmtGetConns(SShowObj *pShow, void *pConn) {
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
;
pShow
->
bytes
[
cols
]
=
TSDB_TABLE_NAME_LEN
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
)
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"user"
);
...
...
src/mnode/src/mgmtShell.c
浏览文件 @
03346d0c
...
...
@@ -38,7 +38,7 @@
#include "mgmtUser.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
);
static
int
mgmtShellRetriveAuth
(
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
);
...
...
src/mnode/src/mgmtSuperTable.c
浏览文件 @
03346d0c
...
...
@@ -16,7 +16,6 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosmsg.h"
#include "tschemautil.h"
#include "tscompression.h"
#include "tskiplist.h"
#include "tsqlfunction.h"
...
...
@@ -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
*
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
mgmtGetShowSuperTableMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtGetShowSuperTableMeta
(
STableMeta
Msg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
void
mgmtDestroySuperTable
(
SSuperTableObj
*
pTable
)
{
free
(
pTable
->
schema
);
...
...
@@ -492,14 +491,14 @@ int32_t mgmtDropSuperTableColumnByName(SSuperTableObj *pStable, char *colName) {
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
);
if
(
pDb
==
NULL
)
{
return
TSDB_CODE_DB_NOT_SELECTED
;
}
int32_t
cols
=
0
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
)
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
TSDB_TABLE_NAME_LEN
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
...
...
@@ -657,7 +656,7 @@ int32_t mgmtSetSchemaFromSuperTable(SSchema *pSchema, SSuperTableObj *pTable) {
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
->
sid
=
htonl
(
pTable
->
sid
);
pMeta
->
vgid
=
htonl
(
pTable
->
vgId
);
...
...
@@ -666,7 +665,7 @@ int32_t mgmtGetSuperTableMeta(SDbObj *pDb, SSuperTableObj *pTable, STableMeta *p
pMeta
->
numOfTags
=
pTable
->
numOfTags
;
pMeta
->
numOfColumns
=
htons
(
pTable
->
numOfColumns
);
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
);
return
TSDB_CODE_SUCCESS
;
...
...
src/mnode/src/mgmtTable.c
浏览文件 @
03346d0c
...
...
@@ -15,6 +15,7 @@
#define _DEFAULT_SOURCE
#include "mgmtTable.h"
//#include "../../client/inc/tsclient.h"
#include "mgmtAcct.h"
#include "mgmtChildTable.h"
#include "mgmtDClient.h"
...
...
@@ -34,7 +35,6 @@
#include "qextbuffer.h"
#include "taoserror.h"
#include "taosmsg.h"
#include "tschemautil.h"
#include "tscompression.h"
#include "tskiplist.h"
#include "tsqlfunction.h"
...
...
@@ -52,7 +52,7 @@ static void mgmtProcessMultiTableMetaMsg(SQueuedMsg *queueMsg);
static
void
mgmtProcessSuperTableMetaMsg
(
SQueuedMsg
*
queueMsg
);
static
void
mgmtProcessCreateTableRsp
(
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
void
mgmtProcessGetTableMeta
(
STableInfo
*
pTable
,
void
*
thandle
);
...
...
@@ -122,7 +122,7 @@ STableInfo* mgmtGetTableByPos(uint32_t dnodeIp, int32_t vnode, int32_t sid) {
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
)
{
mgmtGetChildTableMeta
(
pDb
,
(
SChildTableObj
*
)
pTable
,
pMeta
,
usePublicIp
);
}
else
if
(
pTable
->
type
==
TSDB_NORMAL_TABLE
)
{
...
...
@@ -187,14 +187,14 @@ void mgmtCleanUpTables() {
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
);
if
(
pDb
==
NULL
)
{
return
TSDB_CODE_DB_NOT_SELECTED
;
}
int32_t
cols
=
0
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
)
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
TSDB_TABLE_NAME_LEN
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
...
...
@@ -601,8 +601,8 @@ void mgmtProcessGetTableMeta(STableInfo *pTable, void *thandle) {
}
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
);
if
(
rpcRsp
.
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -695,7 +695,7 @@ void mgmtProcessMultiTableMetaMsg(SQueuedMsg *pMsg) {
if
(
pDb
==
NULL
)
continue
;
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
//totalMallocLen *= 2;
//pMultiMeta = rpcReMalloc(pMultiMeta, totalMallocLen);
...
...
@@ -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
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
pMultiMeta
->
numOfTables
++
;
...
...
src/mnode/src/mgmtUser.c
浏览文件 @
03346d0c
...
...
@@ -16,7 +16,6 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "trpc.h"
#include "tschemautil.h"
#include "ttime.h"
#include "mgmtAcct.h"
#include "mgmtGrant.h"
...
...
@@ -30,7 +29,7 @@ static int32_t tsUserUpdateSize = 0;
static
int32_t
mgmtCreateUser
(
SAcctObj
*
pAcct
,
char
*
name
,
char
*
pass
);
static
int32_t
mgmtDropUser
(
SAcctObj
*
pAcct
,
char
*
name
);
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
void
mgmtProcessCreateUserMsg
(
SQueuedMsg
*
pMsg
);
...
...
@@ -171,14 +170,14 @@ static int32_t mgmtDropUser(SAcctObj *pAcct, char *name) {
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
);
if
(
pUser
==
NULL
)
{
return
TSDB_CODE_INVALID_USER
;
}
int32_t
cols
=
0
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
)
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
TSDB_USER_LEN
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
...
...
src/mnode/src/mgmtVgroup.c
浏览文件 @
03346d0c
...
...
@@ -17,7 +17,6 @@
#include "os.h"
#include "taoserror.h"
#include "tlog.h"
#include "tschemautil.h"
#include "tstatus.h"
#include "mnode.h"
#include "mgmtBalance.h"
...
...
@@ -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
*
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
void
mgmtProcessCreateVnodeRsp
(
SRpcMsg
*
rpcMsg
);
static
void
mgmtProcessDropVnodeRsp
(
SRpcMsg
*
rpcMsg
);
...
...
@@ -211,14 +210,14 @@ void mgmtCleanUpVgroups() {
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
);
if
(
pDb
==
NULL
)
{
return
TSDB_CODE_DB_NOT_SELECTED
;
}
int32_t
cols
=
0
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
)
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
...
...
src/inc/qpercentile.h
→
src/
query/
inc/qpercentile.h
浏览文件 @
03346d0c
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_
T
PERCENTILE_H
#define TDENGINE_
T
PERCENTILE_H
#ifndef TDENGINE_
Q
PERCENTILE_H
#define TDENGINE_
Q
PERCENTILE_H
#include "qextbuffer.h"
...
...
@@ -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
);
#endif // TDENGINE_
T
PERCENTILE_H
#endif // TDENGINE_
Q
PERCENTILE_H
src/query/src/qast.c
浏览文件 @
03346d0c
...
...
@@ -20,7 +20,7 @@
#include "taosdef.h"
#include "taosmsg.h"
#include "tlog.h"
#include "tschemautil.h"
//
#include "tschemautil.h"
#include "tsqlfunction.h"
#include "tstoken.h"
#include "ttokendef.h"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录