Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
KASAKI11
TDengine
提交
5b969523
T
TDengine
项目概览
KASAKI11
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5b969523
编写于
2月 23, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename SCM to S
上级
aee99f11
变更
42
隐藏空白更改
内联
并排
Showing
42 changed file
with
456 addition
and
462 deletion
+456
-462
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+2
-2
src/client/src/tscAst.c
src/client/src/tscAst.c
+9
-9
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+1
-1
src/client/src/tscLocal.c
src/client/src/tscLocal.c
+3
-3
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+9
-9
src/client/src/tscProfile.c
src/client/src/tscProfile.c
+8
-8
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+39
-39
src/client/src/tscSchemaUtil.c
src/client/src/tscSchemaUtil.c
+11
-11
src/client/src/tscSecondaryMerge.c
src/client/src/tscSecondaryMerge.c
+7
-7
src/client/src/tscServer.c
src/client/src/tscServer.c
+72
-72
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+5
-5
src/dnode/src/dnodeMgmt.c
src/dnode/src/dnodeMgmt.c
+1
-1
src/inc/mnode.h
src/inc/mnode.h
+7
-7
src/inc/taosmsg.h
src/inc/taosmsg.h
+33
-39
src/mnode/inc/mgmtAcct.h
src/mnode/inc/mgmtAcct.h
+1
-1
src/mnode/inc/mgmtChildTable.h
src/mnode/inc/mgmtChildTable.h
+1
-1
src/mnode/inc/mgmtDb.h
src/mnode/inc/mgmtDb.h
+2
-2
src/mnode/inc/mgmtNormalTable.h
src/mnode/inc/mgmtNormalTable.h
+2
-2
src/mnode/inc/mgmtProfile.h
src/mnode/inc/mgmtProfile.h
+1
-1
src/mnode/inc/mgmtStreamTable.h
src/mnode/inc/mgmtStreamTable.h
+1
-1
src/mnode/inc/mgmtSuperTable.h
src/mnode/inc/mgmtSuperTable.h
+3
-3
src/mnode/inc/mgmtTable.h
src/mnode/inc/mgmtTable.h
+1
-1
src/mnode/src/mgmtAcct.c
src/mnode/src/mgmtAcct.c
+2
-2
src/mnode/src/mgmtChildTable.c
src/mnode/src/mgmtChildTable.c
+5
-5
src/mnode/src/mgmtConn.c
src/mnode/src/mgmtConn.c
+1
-1
src/mnode/src/mgmtDb.c
src/mnode/src/mgmtDb.c
+5
-5
src/mnode/src/mgmtDnode.c
src/mnode/src/mgmtDnode.c
+4
-4
src/mnode/src/mgmtDnodeInt.c
src/mnode/src/mgmtDnodeInt.c
+3
-3
src/mnode/src/mgmtNormalTable.c
src/mnode/src/mgmtNormalTable.c
+18
-18
src/mnode/src/mgmtProfile.c
src/mnode/src/mgmtProfile.c
+16
-16
src/mnode/src/mgmtShell.c
src/mnode/src/mgmtShell.c
+90
-90
src/mnode/src/mgmtStreamTable.c
src/mnode/src/mgmtStreamTable.c
+14
-14
src/mnode/src/mgmtSuperTable.c
src/mnode/src/mgmtSuperTable.c
+34
-34
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+2
-2
src/mnode/src/mgmtUser.c
src/mnode/src/mgmtUser.c
+1
-1
src/mnode/src/mgmtVgroup.c
src/mnode/src/mgmtVgroup.c
+1
-1
src/util/inc/tast.h
src/util/inc/tast.h
+4
-4
src/util/inc/textbuffer.h
src/util/inc/textbuffer.h
+7
-7
src/util/inc/tschemautil.h
src/util/inc/tschemautil.h
+6
-6
src/util/src/textbuffer.c
src/util/src/textbuffer.c
+13
-13
src/util/src/tinterpolation.c
src/util/src/tinterpolation.c
+10
-10
src/util/src/tpercentile.c
src/util/src/tpercentile.c
+1
-1
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
5b969523
...
...
@@ -110,7 +110,7 @@ bool tscQueryMetricTags(SQueryInfo* pQueryInfo);
bool
tscIsSelectivityWithTagQuery
(
SSqlCmd
*
pCmd
);
void
tscAddSpecialColumnForSelect
(
SQueryInfo
*
pQueryInfo
,
int32_t
outputColIndex
,
int16_t
functionId
,
SColumnIndex
*
pIndex
,
S
CM
Schema
*
pColSchema
,
int16_t
isTag
);
SSchema
*
pColSchema
,
int16_t
isTag
);
void
addRequiredTagColumn
(
SQueryInfo
*
pQueryInfo
,
int32_t
tagColIndex
,
int32_t
tableIndex
);
...
...
@@ -124,7 +124,7 @@ void tscGetDBInfoFromMeterId(char* meterId, char* db);
int
tscAllocPayload
(
SSqlCmd
*
pCmd
,
int
size
);
void
tscFieldInfoSetValFromSchema
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
,
S
CM
Schema
*
pSchema
);
void
tscFieldInfoSetValFromSchema
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
,
SSchema
*
pSchema
);
void
tscFieldInfoSetValFromField
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
,
TAOS_FIELD
*
pField
);
void
tscFieldInfoSetValue
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
,
int8_t
type
,
const
char
*
name
,
int16_t
bytes
);
void
tscFieldInfoUpdateVisible
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
,
bool
visible
);
...
...
src/client/src/tscAst.c
浏览文件 @
5b969523
...
...
@@ -40,10 +40,10 @@
*
*/
static
tSQLSyntaxNode
*
tSQLSyntaxNodeCreate
(
S
CM
Schema
*
pSchema
,
int32_t
numOfCols
,
SSQLToken
*
pToken
);
static
tSQLSyntaxNode
*
tSQLSyntaxNodeCreate
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
SSQLToken
*
pToken
);
static
void
tSQLSyntaxNodeDestroy
(
tSQLSyntaxNode
*
pNode
,
void
(
*
fp
)(
void
*
));
static
tSQLSyntaxNode
*
createSyntaxTree
(
S
CM
Schema
*
pSchema
,
int32_t
numOfCols
,
char
*
str
,
int32_t
*
i
);
static
tSQLSyntaxNode
*
createSyntaxTree
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
char
*
str
,
int32_t
*
i
);
static
void
destroySyntaxTree
(
tSQLSyntaxNode
*
);
static
uint8_t
isQueryOnPrimaryKey
(
const
char
*
primaryColumnName
,
const
tSQLSyntaxNode
*
pLeft
,
...
...
@@ -101,7 +101,7 @@ static void reviseBinaryExprIfNecessary(tSQLSyntaxNode **pLeft, tSQLSyntaxNode *
}
}
static
tSQLSyntaxNode
*
tSQLSyntaxNodeCreate
(
S
CM
Schema
*
pSchema
,
int32_t
numOfCols
,
SSQLToken
*
pToken
)
{
static
tSQLSyntaxNode
*
tSQLSyntaxNodeCreate
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
SSQLToken
*
pToken
)
{
/* if the token is not a value, return false */
if
(
pToken
->
type
==
TK_RP
||
(
pToken
->
type
!=
TK_INTEGER
&&
pToken
->
type
!=
TK_FLOAT
&&
pToken
->
type
!=
TK_ID
&&
pToken
->
type
!=
TK_TBNAME
&&
pToken
->
type
!=
TK_STRING
&&
pToken
->
type
!=
TK_BOOL
))
{
...
...
@@ -127,15 +127,15 @@ static tSQLSyntaxNode *tSQLSyntaxNodeCreate(SCMSchema *pSchema, int32_t numOfCol
}
}
nodeSize
+=
sizeof
(
S
CM
Schema
);
nodeSize
+=
sizeof
(
SSchema
);
pNode
=
calloc
(
1
,
nodeSize
);
pNode
->
pSchema
=
(
struct
S
CM
Schema
*
)((
char
*
)
pNode
+
sizeof
(
tSQLSyntaxNode
));
pNode
->
pSchema
=
(
struct
SSchema
*
)((
char
*
)
pNode
+
sizeof
(
tSQLSyntaxNode
));
pNode
->
nodeType
=
TSQL_NODE_COL
;
if
(
pToken
->
type
==
TK_ID
)
{
pNode
->
colId
=
(
int16_t
)
pSchema
[
i
].
colId
;
memcpy
(
pNode
->
pSchema
,
&
pSchema
[
i
],
sizeof
(
S
CM
Schema
));
memcpy
(
pNode
->
pSchema
,
&
pSchema
[
i
],
sizeof
(
SSchema
));
}
else
{
pNode
->
colId
=
-
1
;
pNode
->
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
...
...
@@ -193,7 +193,7 @@ static uint8_t getBinaryExprOptr(SSQLToken *pToken) {
}
// previous generated expr is reduced as the left child
static
tSQLSyntaxNode
*
parseRemainStr
(
char
*
pstr
,
tSQLBinaryExpr
*
pExpr
,
S
CM
Schema
*
pSchema
,
int32_t
optr
,
static
tSQLSyntaxNode
*
parseRemainStr
(
char
*
pstr
,
tSQLBinaryExpr
*
pExpr
,
SSchema
*
pSchema
,
int32_t
optr
,
int32_t
numOfCols
,
int32_t
*
i
)
{
// set the previous generated node as the left child of new root
tSQLSyntaxNode
*
pLeft
=
malloc
(
sizeof
(
tSQLSyntaxNode
));
...
...
@@ -238,7 +238,7 @@ uint8_t isQueryOnPrimaryKey(const char *primaryColumnName, const tSQLSyntaxNode
}
}
static
tSQLSyntaxNode
*
createSyntaxTree
(
S
CM
Schema
*
pSchema
,
int32_t
numOfCols
,
char
*
str
,
int32_t
*
i
)
{
static
tSQLSyntaxNode
*
createSyntaxTree
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
char
*
str
,
int32_t
*
i
)
{
SSQLToken
t0
;
t0
=
tStrGetToken
(
str
,
i
,
false
,
0
,
NULL
);
...
...
@@ -337,7 +337,7 @@ static tSQLSyntaxNode *createSyntaxTree(SCMSchema *pSchema, int32_t numOfCols, c
}
}
void
tSQLBinaryExprFromString
(
tSQLBinaryExpr
**
pExpr
,
S
CM
Schema
*
pSchema
,
int32_t
numOfCols
,
char
*
src
,
int32_t
len
)
{
void
tSQLBinaryExprFromString
(
tSQLBinaryExpr
**
pExpr
,
SSchema
*
pSchema
,
int32_t
numOfCols
,
char
*
src
,
int32_t
len
)
{
*
pExpr
=
NULL
;
if
(
len
<=
0
||
src
==
NULL
||
pSchema
==
NULL
||
numOfCols
<=
0
)
{
return
;
...
...
src/client/src/tscFunctionImpl.c
浏览文件 @
5b969523
...
...
@@ -2437,7 +2437,7 @@ static bool percentile_function_setup(SQLFunctionCtx *pCtx) {
}
SResultInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
S
CM
Schema
field
[
1
]
=
{{
pCtx
->
inputType
,
"dummyCol"
,
0
,
pCtx
->
inputBytes
}};
SSchema
field
[
1
]
=
{{
pCtx
->
inputType
,
"dummyCol"
,
0
,
pCtx
->
inputBytes
}};
SColumnModel
*
pModel
=
createColumnModel
(
field
,
1
,
1000
);
int32_t
orderIdx
=
0
;
...
...
src/client/src/tscLocal.c
浏览文件 @
5b969523
...
...
@@ -85,7 +85,7 @@ static int32_t tscMaxLengthOfTagsFields(SSqlObj *pSql) {
}
char
*
pTagValue
=
tsGetTagsValue
(
pMeta
);
S
CM
Schema
*
pTagsSchema
=
tsGetTagSchema
(
pMeta
);
SSchema
*
pTagsSchema
=
tsGetTagSchema
(
pMeta
);
int32_t
len
=
getToStringLength
(
pTagValue
,
pTagsSchema
[
0
].
bytes
,
pTagsSchema
[
0
].
type
);
...
...
@@ -125,7 +125,7 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
}
tscInitResObjForLocalQuery
(
pSql
,
totalNumOfRows
,
rowLen
);
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
pQueryInfo
,
0
);
...
...
@@ -286,7 +286,7 @@ static int tscBuildMetricTagProjectionResult(SSqlObj *pSql) {
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
SMetricMeta
*
pMetricMeta
=
pMeterMetaInfo
->
pMetricMeta
;
S
CM
Schema
*
pSchema
=
tsGetTagSchema
(
pMeterMetaInfo
->
pMeterMeta
);
SSchema
*
pSchema
=
tsGetTagSchema
(
pMeterMetaInfo
->
pMeterMeta
);
int32_t
vOffset
[
TSDB_MAX_COLUMNS
]
=
{
0
};
...
...
src/client/src/tscParseInsert.c
浏览文件 @
5b969523
...
...
@@ -144,7 +144,7 @@ int tsParseTime(SSQLToken *pToken, int64_t *time, char **next, char *error, int1
return
TSDB_CODE_SUCCESS
;
}
int32_t
tsParseOneColumnData
(
S
CM
Schema
*
pSchema
,
SSQLToken
*
pToken
,
char
*
payload
,
char
*
msg
,
char
**
str
,
bool
primaryKey
,
int32_t
tsParseOneColumnData
(
SSchema
*
pSchema
,
SSQLToken
*
pToken
,
char
*
payload
,
char
*
msg
,
char
**
str
,
bool
primaryKey
,
int16_t
timePrec
)
{
int64_t
iv
;
int32_t
numType
;
...
...
@@ -389,7 +389,7 @@ static int32_t tsCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start
return
TSDB_CODE_SUCCESS
;
}
int
tsParseOneRowData
(
char
**
str
,
STableDataBlocks
*
pDataBlocks
,
S
CM
Schema
schema
[],
SParsedDataColInfo
*
spd
,
char
*
error
,
int
tsParseOneRowData
(
char
**
str
,
STableDataBlocks
*
pDataBlocks
,
SSchema
schema
[],
SParsedDataColInfo
*
spd
,
char
*
error
,
int16_t
timePrec
,
int32_t
*
code
,
char
*
tmpTokenBuf
)
{
int32_t
index
=
0
;
// bool isPrevOptr; //fang, never used
...
...
@@ -402,7 +402,7 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SCMSchema schem
// the start position in data block buffer of current value in sql
char
*
start
=
payload
+
spd
->
elems
[
i
].
offset
;
int16_t
colIndex
=
spd
->
elems
[
i
].
colIndex
;
S
CM
Schema
*
pSchema
=
schema
+
colIndex
;
SSchema
*
pSchema
=
schema
+
colIndex
;
rowSize
+=
pSchema
->
bytes
;
index
=
0
;
...
...
@@ -503,7 +503,7 @@ int tsParseValues(char **str, STableDataBlocks *pDataBlock, SMeterMeta *pMeterMe
int16_t
numOfRows
=
0
;
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
int32_t
precision
=
pMeterMeta
->
precision
;
if
(
spd
->
hasVal
[
0
]
==
false
)
{
...
...
@@ -558,7 +558,7 @@ int tsParseValues(char **str, STableDataBlocks *pDataBlock, SMeterMeta *pMeterMe
}
}
static
void
tscSetAssignedColumnInfo
(
SParsedDataColInfo
*
spd
,
S
CM
Schema
*
pSchema
,
int32_t
numOfCols
)
{
static
void
tscSetAssignedColumnInfo
(
SParsedDataColInfo
*
spd
,
SSchema
*
pSchema
,
int32_t
numOfCols
)
{
spd
->
numOfCols
=
numOfCols
;
spd
->
numOfAssignedCols
=
numOfCols
;
...
...
@@ -786,7 +786,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
return
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
"create table only from super table is allowed"
,
sToken
.
z
);
}
S
CM
Schema
*
pTagSchema
=
tsGetTagSchema
(
pSTableMeterMetaInfo
->
pMeterMeta
);
SSchema
*
pTagSchema
=
tsGetTagSchema
(
pSTableMeterMetaInfo
->
pMeterMeta
);
index
=
0
;
sToken
=
tStrGetToken
(
sql
,
&
index
,
false
,
0
,
NULL
);
...
...
@@ -1094,7 +1094,7 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
if
(
sToken
.
type
==
TK_VALUES
)
{
SParsedDataColInfo
spd
=
{.
numOfCols
=
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
};
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
tscSetAssignedColumnInfo
(
&
spd
,
pSchema
,
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
);
...
...
@@ -1149,7 +1149,7 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
}
else
if
(
sToken
.
type
==
TK_LP
)
{
/* insert into tablename(col1, col2,..., coln) values(v1, v2,... vn); */
SMeterMeta
*
pMeterMeta
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
)
->
pMeterMeta
;
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
if
(
validateDataSource
(
pCmd
,
DATA_FROM_SQL_STRING
,
sToken
.
z
)
!=
TSDB_CODE_SUCCESS
)
{
goto
_error_clean
;
...
...
@@ -1403,7 +1403,7 @@ static int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp, char *tmpTokenBuf) {
int
count
=
0
;
SParsedDataColInfo
spd
=
{.
numOfCols
=
pMeterMeta
->
numOfColumns
};
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
tscSetAssignedColumnInfo
(
&
spd
,
pSchema
,
pMeterMeta
->
numOfColumns
);
...
...
src/client/src/tscProfile.c
浏览文件 @
5b969523
...
...
@@ -209,16 +209,16 @@ void tscKillStream(STscObj *pObj, uint32_t killId) {
}
char
*
tscBuildQueryStreamDesc
(
char
*
pMsg
,
STscObj
*
pObj
)
{
S
CMQqueryList
*
pQList
=
(
SCM
QqueryList
*
)
pMsg
;
S
QqueryList
*
pQList
=
(
S
QqueryList
*
)
pMsg
;
char
*
pMax
=
pMsg
+
TSDB_PAYLOAD_SIZE
-
256
;
S
CM
QueryDesc
*
pQdesc
=
pQList
->
qdesc
;
SQueryDesc
*
pQdesc
=
pQList
->
qdesc
;
pQList
->
numOfQueries
=
0
;
// We extract the lock to tscBuildHeartBeatMsg function.
/* pthread_mutex_lock (&pObj->mutex); */
pMsg
+=
sizeof
(
S
CM
QqueryList
);
pMsg
+=
sizeof
(
SQqueryList
);
SSqlObj
*
pSql
=
pObj
->
sqlList
;
while
(
pSql
)
{
/*
...
...
@@ -239,15 +239,15 @@ char *tscBuildQueryStreamDesc(char *pMsg, STscObj *pObj) {
pQList
->
numOfQueries
++
;
pQdesc
++
;
pSql
=
pSql
->
next
;
pMsg
+=
sizeof
(
S
CM
QueryDesc
);
pMsg
+=
sizeof
(
SQueryDesc
);
if
(
pMsg
>
pMax
)
break
;
}
S
CMStreamList
*
pSList
=
(
SCM
StreamList
*
)
pMsg
;
S
CM
StreamDesc
*
pSdesc
=
pSList
->
sdesc
;
S
StreamList
*
pSList
=
(
S
StreamList
*
)
pMsg
;
SStreamDesc
*
pSdesc
=
pSList
->
sdesc
;
pSList
->
numOfStreams
=
0
;
pMsg
+=
sizeof
(
S
CM
StreamList
);
pMsg
+=
sizeof
(
SStreamList
);
SSqlStream
*
pStream
=
pObj
->
streamList
;
while
(
pStream
)
{
strncpy
(
pSdesc
->
sql
,
pStream
->
pSql
->
sqlstr
,
TSDB_SHOW_SQL_LEN
-
1
);
...
...
@@ -265,7 +265,7 @@ char *tscBuildQueryStreamDesc(char *pMsg, STscObj *pObj) {
pSList
->
numOfStreams
++
;
pSdesc
++
;
pStream
=
pStream
->
next
;
pMsg
+=
sizeof
(
S
CM
StreamDesc
);
pMsg
+=
sizeof
(
SStreamDesc
);
if
(
pMsg
>
pMax
)
break
;
}
...
...
src/client/src/tscSQLParser.c
浏览文件 @
5b969523
...
...
@@ -78,7 +78,7 @@ static int32_t addProjectionExprAndResultField(SQueryInfo* pQueryInfo, tSQLExprI
static
int32_t
parseWhereClause
(
SQueryInfo
*
pQueryInfo
,
tSQLExpr
**
pExpr
,
SSqlObj
*
pSql
);
static
int32_t
parseFillClause
(
SQueryInfo
*
pQueryInfo
,
SQuerySQL
*
pQuerySQL
);
static
int32_t
parseOrderbyClause
(
SQueryInfo
*
pQueryInfo
,
SQuerySQL
*
pQuerySql
,
S
CM
Schema
*
pSchema
);
static
int32_t
parseOrderbyClause
(
SQueryInfo
*
pQueryInfo
,
SQuerySQL
*
pQuerySql
,
SSchema
*
pSchema
);
static
int32_t
tsRewriteFieldNameIfNecessary
(
SQueryInfo
*
pQueryInfo
);
static
int32_t
setAlterTableInfo
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
);
...
...
@@ -106,7 +106,7 @@ static int32_t optrToString(tSQLExpr* pExpr, char** exprString);
static
int32_t
getMeterIndex
(
SSQLToken
*
pTableToken
,
SQueryInfo
*
pQueryInfo
,
SColumnIndex
*
pIndex
);
static
int32_t
doFunctionsCompatibleCheck
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
);
static
int32_t
doLocalQueryProcess
(
SQueryInfo
*
pQueryInfo
,
SQuerySQL
*
pQuerySql
);
static
int32_t
tscCheckCreateDbParams
(
SSqlCmd
*
pCmd
,
SC
MC
reateDbMsg
*
pCreate
);
static
int32_t
tscCheckCreateDbParams
(
SSqlCmd
*
pCmd
,
SCreateDbMsg
*
pCreate
);
static
SColumnList
getColumnList
(
int32_t
num
,
int16_t
tableIndex
,
int32_t
columnIndex
);
...
...
@@ -392,7 +392,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
char
*
pMsg
=
pCmd
->
payload
+
tsRpcHeadSize
;
pMsg
+=
sizeof
(
SMgmtHead
);
SC
MCfgDnodeMsg
*
pCfg
=
(
SCM
CfgDnodeMsg
*
)
pMsg
;
SC
fgDnodeMsg
*
pCfg
=
(
S
CfgDnodeMsg
*
)
pMsg
;
strncpy
(
pCfg
->
ip
,
pDCL
->
a
[
0
].
z
,
pDCL
->
a
[
0
].
n
);
strncpy
(
pCfg
->
config
,
pDCL
->
a
[
1
].
z
,
pDCL
->
a
[
1
].
n
);
...
...
@@ -905,7 +905,7 @@ bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) {
return
false
;
}
S
CM
Schema
*
pTagSchema
=
tsGetTagSchema
(
pMeterMetaInfo
->
pMeterMeta
);
SSchema
*
pTagSchema
=
tsGetTagSchema
(
pMeterMetaInfo
->
pMeterMeta
);
int32_t
nLen
=
0
;
for
(
int32_t
i
=
0
;
i
<
pMeterMeta
->
numOfTags
;
++
i
)
{
...
...
@@ -931,7 +931,7 @@ bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) {
}
// field name must be unique
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
for
(
int32_t
i
=
0
;
i
<
pMeterMeta
->
numOfTags
+
pMeterMeta
->
numOfColumns
;
++
i
)
{
if
(
strncasecmp
(
pTagField
->
name
,
pSchema
[
i
].
name
,
TSDB_COL_NAME_LEN
)
==
0
)
{
...
...
@@ -972,7 +972,7 @@ bool validateOneColumn(SSqlCmd* pCmd, TAOS_FIELD* pColField) {
return
false
;
}
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
int32_t
nLen
=
0
;
for
(
int32_t
i
=
0
;
i
<
pMeterMeta
->
numOfColumns
;
++
i
)
{
...
...
@@ -1217,7 +1217,7 @@ SSqlExpr* doAddProjectCol(SQueryInfo* pQueryInfo, int32_t outputIndex, int32_t c
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
tableIndex
);
SMeterMeta
*
pMeterMeta
=
pMeterMetaInfo
->
pMeterMeta
;
S
CM
Schema
*
pSchema
=
tsGetColumnSchema
(
pMeterMeta
,
colIdx
);
SSchema
*
pSchema
=
tsGetColumnSchema
(
pMeterMeta
,
colIdx
);
int32_t
numOfCols
=
pMeterMeta
->
numOfColumns
;
int16_t
functionId
=
(
int16_t
)((
colIdx
>=
numOfCols
)
?
TSDB_FUNC_TAGPRJ
:
TSDB_FUNC_PRJ
);
...
...
@@ -1269,7 +1269,7 @@ static void addProjectQueryCol(SQueryInfo* pQueryInfo, int32_t startPos, SColumn
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
pIndex
->
tableIndex
);
SMeterMeta
*
pMeterMeta
=
pMeterMetaInfo
->
pMeterMeta
;
S
CM
Schema
*
pSchema
=
tsGetColumnSchema
(
pMeterMeta
,
pIndex
->
columnIndex
);
SSchema
*
pSchema
=
tsGetColumnSchema
(
pMeterMeta
,
pIndex
->
columnIndex
);
char
*
colName
=
(
pItem
->
aliasName
==
NULL
)
?
pSchema
->
name
:
pItem
->
aliasName
;
...
...
@@ -1285,7 +1285,7 @@ static void addProjectQueryCol(SQueryInfo* pQueryInfo, int32_t startPos, SColumn
}
void
tscAddSpecialColumnForSelect
(
SQueryInfo
*
pQueryInfo
,
int32_t
outputColIndex
,
int16_t
functionId
,
SColumnIndex
*
pIndex
,
S
CM
Schema
*
pColSchema
,
int16_t
flag
)
{
SColumnIndex
*
pIndex
,
SSchema
*
pColSchema
,
int16_t
flag
)
{
SSqlExpr
*
pExpr
=
tscSqlExprInsert
(
pQueryInfo
,
outputColIndex
,
functionId
,
pIndex
,
pColSchema
->
type
,
pColSchema
->
bytes
,
pColSchema
->
bytes
);
...
...
@@ -1307,7 +1307,7 @@ static int32_t doAddProjectionExprAndResultFields(SQueryInfo* pQueryInfo, SColum
int32_t
numOfTotalColumns
=
0
;
SMeterMeta
*
pMeterMeta
=
pMeterMetaInfo
->
pMeterMeta
;
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
if
(
UTIL_METER_IS_SUPERTABLE
(
pMeterMetaInfo
))
{
numOfTotalColumns
=
pMeterMeta
->
numOfColumns
+
pMeterMeta
->
numOfTags
;
...
...
@@ -1361,7 +1361,7 @@ int32_t addProjectionExprAndResultField(SQueryInfo* pQueryInfo, tSQLExprItem* pI
}
if
(
index
.
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
S
CM
Schema
colSchema
=
{.
type
=
TSDB_DATA_TYPE_BINARY
,
.
bytes
=
TSDB_METER_NAME_LEN
};
SSchema
colSchema
=
{.
type
=
TSDB_DATA_TYPE_BINARY
,
.
bytes
=
TSDB_METER_NAME_LEN
};
strcpy
(
colSchema
.
name
,
TSQL_TBNAME_L
);
pQueryInfo
->
type
=
TSDB_QUERY_TYPE_STABLE_QUERY
;
...
...
@@ -1383,7 +1383,7 @@ int32_t addProjectionExprAndResultField(SQueryInfo* pQueryInfo, tSQLExprItem* pI
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
setExprInfoForFunctions
(
SQueryInfo
*
pQueryInfo
,
S
CM
Schema
*
pSchema
,
int32_t
functionID
,
char
*
aliasName
,
static
int32_t
setExprInfoForFunctions
(
SQueryInfo
*
pQueryInfo
,
SSchema
*
pSchema
,
int32_t
functionID
,
char
*
aliasName
,
int32_t
resColIdx
,
SColumnIndex
*
pColIndex
)
{
int16_t
type
=
0
;
int16_t
bytes
=
0
;
...
...
@@ -1536,7 +1536,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
// 2. check if sql function can be applied on this column data type
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
S
CM
Schema
*
pSchema
=
tsGetColumnSchema
(
pMeterMetaInfo
->
pMeterMeta
,
index
.
columnIndex
);
SSchema
*
pSchema
=
tsGetColumnSchema
(
pMeterMetaInfo
->
pMeterMeta
,
index
.
columnIndex
);
int16_t
colType
=
pSchema
->
type
;
if
(
colType
<=
TSDB_DATA_TYPE_BOOL
||
colType
>=
TSDB_DATA_TYPE_BINARY
)
{
...
...
@@ -1637,7 +1637,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
}
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
for
(
int32_t
j
=
0
;
j
<
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
;
++
j
)
{
index
.
columnIndex
=
j
;
...
...
@@ -1652,7 +1652,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
}
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
// functions can not be applied to tags
if
((
index
.
columnIndex
>=
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
)
||
(
index
.
columnIndex
<
0
))
{
...
...
@@ -1671,7 +1671,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
for
(
int32_t
j
=
0
;
j
<
pQueryInfo
->
numOfTables
;
++
j
)
{
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
j
);
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
for
(
int32_t
i
=
0
;
i
<
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
;
++
i
)
{
SColumnIndex
index
=
{.
tableIndex
=
j
,
.
columnIndex
=
i
};
...
...
@@ -1711,7 +1711,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
}
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
);
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
// functions can not be applied to tags
if
(
index
.
columnIndex
>=
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
)
{
...
...
@@ -1838,7 +1838,7 @@ static int16_t doGetColumnIndex(SQueryInfo* pQueryInfo, int32_t index, SSQLToken
SMeterMeta
*
pMeterMeta
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
)
->
pMeterMeta
;
int32_t
numOfCols
=
pMeterMeta
->
numOfColumns
+
pMeterMeta
->
numOfTags
;
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
int16_t
columnIndex
=
COLUMN_INDEX_INITIAL_VAL
;
...
...
@@ -2361,8 +2361,8 @@ int32_t parseGroupbyClause(SQueryInfo* pQueryInfo, tVariantList* pList, SSqlCmd*
}
SMeterMeta
*
pMeterMeta
=
NULL
;
S
CM
Schema
*
pSchema
=
NULL
;
S
CM
Schema
s
=
tsGetTbnameColumnSchema
();
SSchema
*
pSchema
=
NULL
;
SSchema
s
=
tsGetTbnameColumnSchema
();
int32_t
tableIndex
=
COLUMN_INDEX_INITIAL_VAL
;
...
...
@@ -2465,7 +2465,7 @@ static int32_t doExtractColumnFilterInfo(SQueryInfo* pQueryInfo, SColumnFilterIn
tSQLExpr
*
pRight
=
pExpr
->
pRight
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
columnIndex
->
tableIndex
);
S
CM
Schema
*
pSchema
=
tsGetColumnSchema
(
pMeterMetaInfo
->
pMeterMeta
,
columnIndex
->
columnIndex
);
SSchema
*
pSchema
=
tsGetColumnSchema
(
pMeterMetaInfo
->
pMeterMeta
,
columnIndex
->
columnIndex
);
int16_t
colType
=
pSchema
->
type
;
if
(
colType
>=
TSDB_DATA_TYPE_TINYINT
&&
colType
<=
TSDB_DATA_TYPE_BIGINT
)
{
...
...
@@ -2705,7 +2705,7 @@ static int32_t extractColumnFilterInfo(SQueryInfo* pQueryInfo, SColumnIndex* pIn
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
pIndex
->
tableIndex
);
SMeterMeta
*
pMeterMeta
=
pMeterMetaInfo
->
pMeterMeta
;
S
CM
Schema
*
pSchema
=
tsGetColumnSchema
(
pMeterMeta
,
pIndex
->
columnIndex
);
SSchema
*
pSchema
=
tsGetColumnSchema
(
pMeterMeta
,
pIndex
->
columnIndex
);
const
char
*
msg1
=
"non binary column not support like operator"
;
const
char
*
msg2
=
"binary column not support this operator"
;
...
...
@@ -2928,7 +2928,7 @@ static int32_t validateSQLExpr(tSQLExpr* pExpr, SQueryInfo* pQueryInfo, SColumnL
// if column is timestamp, bool, binary, nchar, not support arithmetic, so return invalid sql
SMeterMeta
*
pMeterMeta
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
index
.
tableIndex
)
->
pMeterMeta
;
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeterMeta
)
+
index
.
columnIndex
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMeta
)
+
index
.
columnIndex
;
if
((
pSchema
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
||
(
pSchema
->
type
==
TSDB_DATA_TYPE_BOOL
)
||
(
pSchema
->
type
==
TSDB_DATA_TYPE_BINARY
)
||
(
pSchema
->
type
==
TSDB_DATA_TYPE_NCHAR
)){
return
TSDB_CODE_INVALID_SQL
;
...
...
@@ -3064,11 +3064,11 @@ static bool validateJoinExprNode(SQueryInfo* pQueryInfo, tSQLExpr* pExpr, SColum
// todo extract function
SMeterMetaInfo
*
pLeftMeterMeta
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
pLeftIndex
->
tableIndex
);
S
CM
Schema
*
pLeftSchema
=
tsGetSchema
(
pLeftMeterMeta
->
pMeterMeta
);
SSchema
*
pLeftSchema
=
tsGetSchema
(
pLeftMeterMeta
->
pMeterMeta
);
int16_t
leftType
=
pLeftSchema
[
pLeftIndex
->
columnIndex
].
type
;
SMeterMetaInfo
*
pRightMeterMeta
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
rightIndex
.
tableIndex
);
S
CM
Schema
*
pRightSchema
=
tsGetSchema
(
pRightMeterMeta
->
pMeterMeta
);
SSchema
*
pRightSchema
=
tsGetSchema
(
pRightMeterMeta
->
pMeterMeta
);
int16_t
rightType
=
pRightSchema
[
rightIndex
.
columnIndex
].
type
;
if
(
leftType
!=
rightType
)
{
...
...
@@ -3176,7 +3176,7 @@ static int32_t handleExprInQueryCond(SQueryInfo* pQueryInfo, tSQLExpr** pExpr, S
return
TSDB_CODE_INVALID_SQL
;
}
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
if
((
!
isTablenameToken
(
&
pLeft
->
colInfo
))
&&
pSchema
[
index
.
columnIndex
].
type
!=
TSDB_DATA_TYPE_BINARY
&&
pSchema
[
index
.
columnIndex
].
type
!=
TSDB_DATA_TYPE_NCHAR
)
{
...
...
@@ -3912,7 +3912,7 @@ static void setDefaultOrderInfo(SQueryInfo* pQueryInfo) {
}
}
int32_t
parseOrderbyClause
(
SQueryInfo
*
pQueryInfo
,
SQuerySQL
*
pQuerySql
,
S
CM
Schema
*
pSchema
)
{
int32_t
parseOrderbyClause
(
SQueryInfo
*
pQueryInfo
,
SQuerySQL
*
pQuerySql
,
SSchema
*
pSchema
)
{
const
char
*
msg0
=
"only support order by primary timestamp"
;
const
char
*
msg1
=
"invalid column name"
;
const
char
*
msg2
=
"only support order by primary timestamp and queried column"
;
...
...
@@ -4209,7 +4209,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg2
);
}
S
CM
Schema
*
pTagsSchema
=
tsGetColumnSchema
(
pMeterMetaInfo
->
pMeterMeta
,
columnIndex
.
columnIndex
);
SSchema
*
pTagsSchema
=
tsGetColumnSchema
(
pMeterMetaInfo
->
pMeterMeta
,
columnIndex
.
columnIndex
);
if
(
tVariantDump
(
&
pVarList
->
a
[
1
].
pVar
,
pAlterSQL
->
tagData
.
data
/*pCmd->payload*/
,
pTagsSchema
->
type
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
...
...
@@ -4573,7 +4573,7 @@ int32_t parseLimitClause(SQueryInfo* pQueryInfo, int32_t clauseIndex, SQuerySQL*
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
setKeepOption
(
SSqlCmd
*
pCmd
,
SC
MC
reateDbMsg
*
pMsg
,
SCreateDBInfo
*
pCreateDb
)
{
static
int32_t
setKeepOption
(
SSqlCmd
*
pCmd
,
SCreateDbMsg
*
pMsg
,
SCreateDBInfo
*
pCreateDb
)
{
const
char
*
msg
=
"invalid number of options"
;
pMsg
->
daysToKeep
=
htonl
(
-
1
);
...
...
@@ -4604,7 +4604,7 @@ static int32_t setKeepOption(SSqlCmd* pCmd, SCMCreateDbMsg* pMsg, SCreateDBInfo*
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
setTimePrecisionOption
(
SSqlCmd
*
pCmd
,
SC
MC
reateDbMsg
*
pMsg
,
SCreateDBInfo
*
pCreateDbInfo
)
{
static
int32_t
setTimePrecisionOption
(
SSqlCmd
*
pCmd
,
SCreateDbMsg
*
pMsg
,
SCreateDBInfo
*
pCreateDbInfo
)
{
const
char
*
msg
=
"invalid time precision"
;
pMsg
->
precision
=
TSDB_TIME_PRECISION_MILLI
;
// millisecond by default
...
...
@@ -4628,7 +4628,7 @@ static int32_t setTimePrecisionOption(SSqlCmd* pCmd, SCMCreateDbMsg* pMsg, SCrea
return
TSDB_CODE_SUCCESS
;
}
static
void
setCreateDBOption
(
SC
MC
reateDbMsg
*
pMsg
,
SCreateDBInfo
*
pCreateDb
)
{
static
void
setCreateDBOption
(
SCreateDbMsg
*
pMsg
,
SCreateDBInfo
*
pCreateDb
)
{
pMsg
->
blocksPerMeter
=
htons
(
pCreateDb
->
numOfBlocksPerTable
);
pMsg
->
compression
=
pCreateDb
->
compressionLevel
;
...
...
@@ -4643,7 +4643,7 @@ static void setCreateDBOption(SCMCreateDbMsg* pMsg, SCreateDBInfo* pCreateDb) {
}
int32_t
parseCreateDBOptions
(
SSqlCmd
*
pCmd
,
SCreateDBInfo
*
pCreateDbSql
)
{
SC
MCreateDbMsg
*
pMsg
=
(
SCM
CreateDbMsg
*
)(
pCmd
->
payload
+
tsRpcHeadSize
+
sizeof
(
SMgmtHead
));
SC
reateDbMsg
*
pMsg
=
(
S
CreateDbMsg
*
)(
pCmd
->
payload
+
tsRpcHeadSize
+
sizeof
(
SMgmtHead
));
setCreateDBOption
(
pMsg
,
pCreateDbSql
);
if
(
setKeepOption
(
pCmd
,
pMsg
,
pCreateDbSql
)
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -4694,7 +4694,7 @@ void addGroupInfoForSubquery(SSqlObj* pParentObj, SSqlObj* pSql, int32_t subClau
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
tableIndex
);
int16_t
columnInfo
=
tscGetJoinTagColIndexByUid
(
&
pQueryInfo
->
tagCond
,
pMeterMetaInfo
->
pMeterMeta
->
uid
);
SColumnIndex
index
=
{.
tableIndex
=
0
,
.
columnIndex
=
columnInfo
};
S
CM
Schema
*
pSchema
=
tsGetTagSchema
(
pMeterMetaInfo
->
pMeterMeta
);
SSchema
*
pSchema
=
tsGetTagSchema
(
pMeterMetaInfo
->
pMeterMeta
);
int16_t
type
=
pSchema
[
index
.
columnIndex
].
type
;
int16_t
bytes
=
pSchema
[
index
.
columnIndex
].
bytes
;
...
...
@@ -4730,7 +4730,7 @@ void doAddGroupColumnForSubquery(SQueryInfo* pQueryInfo, int32_t tagIndex) {
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
CM
Schema
*
pSchema
=
tsGetColumnSchema
(
pMeterMetaInfo
->
pMeterMeta
,
index
);
SSchema
*
pSchema
=
tsGetColumnSchema
(
pMeterMetaInfo
->
pMeterMeta
,
index
);
SColumnIndex
colIndex
=
{.
tableIndex
=
0
,
.
columnIndex
=
index
};
SSqlExpr
*
pExpr
=
tscSqlExprInsert
(
pQueryInfo
,
pQueryInfo
->
fieldsInfo
.
numOfOutputCols
,
TSDB_FUNC_PRJ
,
&
colIndex
,
...
...
@@ -4763,12 +4763,12 @@ static void doUpdateSqlFunctionForTagPrj(SQueryInfo* pQueryInfo) {
}
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutputCols
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
if
(
pExpr
->
functionId
!=
TSDB_FUNC_TAG_DUMMY
&&
pExpr
->
functionId
!=
TSDB_FUNC_TS_DUMMY
)
{
S
CM
Schema
*
pColSchema
=
&
pSchema
[
pExpr
->
colInfo
.
colIdx
];
SSchema
*
pColSchema
=
&
pSchema
[
pExpr
->
colInfo
.
colIdx
];
getResultDataInfo
(
pColSchema
->
type
,
pColSchema
->
bytes
,
pExpr
->
functionId
,
pExpr
->
param
[
0
].
i64Key
,
&
pExpr
->
resType
,
&
pExpr
->
resBytes
,
&
pExpr
->
interResBytes
,
tagLength
,
true
);
}
...
...
@@ -4940,7 +4940,7 @@ static int32_t doAddGroupbyColumnsOnDemand(SQueryInfo* pQueryInfo) {
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
int16_t
bytes
=
0
;
int16_t
type
=
0
;
char
*
name
=
NULL
;
...
...
@@ -5138,7 +5138,7 @@ int32_t doLocalQueryProcess(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
}
// can only perform the parameters based on the macro definitation
int32_t
tscCheckCreateDbParams
(
SSqlCmd
*
pCmd
,
SC
MC
reateDbMsg
*
pCreate
)
{
int32_t
tscCheckCreateDbParams
(
SSqlCmd
*
pCmd
,
SCreateDbMsg
*
pCreate
)
{
char
msg
[
512
]
=
{
0
};
if
(
pCreate
->
commitLog
!=
-
1
&&
(
pCreate
->
commitLog
<
0
||
pCreate
->
commitLog
>
1
))
{
...
...
@@ -5338,7 +5338,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
}
// too long tag values will return invalid sql, not be truncated automatically
S
CM
Schema
*
pTagSchema
=
tsGetTagSchema
(
pStableMeterMetaInfo
->
pMeterMeta
);
SSchema
*
pTagSchema
=
tsGetTagSchema
(
pStableMeterMetaInfo
->
pMeterMeta
);
char
*
tagVal
=
pCreateTable
->
usingInfo
.
tagdata
.
data
;
for
(
int32_t
i
=
0
;
i
<
pList
->
nExpr
;
++
i
)
{
...
...
src/client/src/tscSchemaUtil.c
浏览文件 @
5b969523
...
...
@@ -20,7 +20,7 @@
#include "ttypes.h"
#include "tutil.h"
bool
isValidSchema
(
struct
S
CM
Schema
*
pSchema
,
int32_t
numOfCols
)
{
bool
isValidSchema
(
struct
SSchema
*
pSchema
,
int32_t
numOfCols
)
{
if
(
!
VALIDNUMOFCOLS
(
numOfCols
))
{
return
false
;
}
...
...
@@ -64,14 +64,14 @@ bool isValidSchema(struct SCMSchema* pSchema, int32_t numOfCols) {
return
(
rowLen
<=
TSDB_MAX_BYTES_PER_ROW
);
}
struct
S
CM
Schema
*
tsGetSchema
(
SMeterMeta
*
pMeta
)
{
struct
SSchema
*
tsGetSchema
(
SMeterMeta
*
pMeta
)
{
if
(
pMeta
==
NULL
)
{
return
NULL
;
}
return
tsGetColumnSchema
(
pMeta
,
0
);
}
struct
S
CM
Schema
*
tsGetTagSchema
(
SMeterMeta
*
pMeta
)
{
struct
SSchema
*
tsGetTagSchema
(
SMeterMeta
*
pMeta
)
{
if
(
pMeta
==
NULL
||
pMeta
->
numOfTags
==
0
)
{
return
NULL
;
}
...
...
@@ -79,12 +79,12 @@ struct SCMSchema* tsGetTagSchema(SMeterMeta* pMeta) {
return
tsGetColumnSchema
(
pMeta
,
pMeta
->
numOfColumns
);
}
struct
S
CM
Schema
*
tsGetColumnSchema
(
SMeterMeta
*
pMeta
,
int32_t
startCol
)
{
return
(
S
CMSchema
*
)(((
char
*
)
pMeta
+
sizeof
(
SMeterMeta
))
+
startCol
*
sizeof
(
SCM
Schema
));
struct
SSchema
*
tsGetColumnSchema
(
SMeterMeta
*
pMeta
,
int32_t
startCol
)
{
return
(
S
Schema
*
)(((
char
*
)
pMeta
+
sizeof
(
SMeterMeta
))
+
startCol
*
sizeof
(
S
Schema
));
}
struct
S
CM
Schema
tsGetTbnameColumnSchema
()
{
struct
S
CM
Schema
s
=
{.
colId
=
TSDB_TBNAME_COLUMN_INDEX
,
.
type
=
TSDB_DATA_TYPE_BINARY
,
.
bytes
=
TSDB_METER_NAME_LEN
};
struct
SSchema
tsGetTbnameColumnSchema
()
{
struct
SSchema
s
=
{.
colId
=
TSDB_TBNAME_COLUMN_INDEX
,
.
type
=
TSDB_DATA_TYPE_BINARY
,
.
bytes
=
TSDB_METER_NAME_LEN
};
strcpy
(
s
.
name
,
TSQL_TBNAME_L
);
return
s
;
...
...
@@ -96,7 +96,7 @@ struct SCMSchema tsGetTbnameColumnSchema() {
* +--------------------+
* |SMeterMeta Body data| sizeof(SMeterMeta)
* +--------------------+
* |Schema data | numOfTotalColumns * sizeof(S
CM
Schema)
* |Schema data | numOfTotalColumns * sizeof(SSchema)
* +--------------------+
* |Tags data | tag_col_1.bytes + tag_col_2.bytes + ....
* +--------------------+
...
...
@@ -106,7 +106,7 @@ struct SCMSchema tsGetTbnameColumnSchema() {
*/
char
*
tsGetTagsValue
(
SMeterMeta
*
pMeta
)
{
int32_t
numOfTotalCols
=
pMeta
->
numOfColumns
+
pMeta
->
numOfTags
;
uint32_t
offset
=
sizeof
(
SMeterMeta
)
+
numOfTotalCols
*
sizeof
(
S
CM
Schema
);
uint32_t
offset
=
sizeof
(
SMeterMeta
)
+
numOfTotalCols
*
sizeof
(
SSchema
);
return
((
char
*
)
pMeta
+
offset
);
}
...
...
@@ -120,10 +120,10 @@ bool tsMeterMetaIdentical(SMeterMeta* p1, SMeterMeta* p2) {
return
true
;
}
size_t
size
=
sizeof
(
SMeterMeta
)
+
p1
->
numOfColumns
*
sizeof
(
S
CM
Schema
);
size_t
size
=
sizeof
(
SMeterMeta
)
+
p1
->
numOfColumns
*
sizeof
(
SSchema
);
for
(
int32_t
i
=
0
;
i
<
p1
->
numOfTags
;
++
i
)
{
S
CM
Schema
*
pColSchema
=
tsGetColumnSchema
(
p1
,
i
+
p1
->
numOfColumns
);
SSchema
*
pColSchema
=
tsGetColumnSchema
(
p1
,
i
+
p1
->
numOfColumns
);
size
+=
pColSchema
->
bytes
;
}
...
...
src/client/src/tscSecondaryMerge.c
浏览文件 @
5b969523
...
...
@@ -68,7 +68,7 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SSqlRes *pRes, SLocalReducer *pRedu
// input buffer hold only one point data
int16_t
offset
=
getColumnModelOffset
(
pDesc
->
pColumnModel
,
i
);
S
CM
Schema
*
pSchema
=
getColumnModelSchema
(
pDesc
->
pColumnModel
,
i
);
SSchema
*
pSchema
=
getColumnModelSchema
(
pDesc
->
pColumnModel
,
i
);
pCtx
->
aInputElemBuf
=
pReducer
->
pTempBuffer
->
data
+
offset
;
...
...
@@ -336,7 +336,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
if
(
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
>
0
)
{
pInterpoInfo
->
pTags
[
0
]
=
(
char
*
)
pInterpoInfo
->
pTags
+
POINTER_BYTES
*
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
;
for
(
int32_t
i
=
1
;
i
<
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
;
++
i
)
{
S
CM
Schema
*
pSchema
=
getColumnModelSchema
(
pReducer
->
resColModel
,
startIndex
+
i
-
1
);
SSchema
*
pSchema
=
getColumnModelSchema
(
pReducer
->
resColModel
,
startIndex
+
i
-
1
);
pInterpoInfo
->
pTags
[
i
]
=
pSchema
->
bytes
+
pInterpoInfo
->
pTags
[
i
-
1
];
}
}
else
{
...
...
@@ -599,7 +599,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
S
CM
Schema
*
pSchema
=
NULL
;
SSchema
*
pSchema
=
NULL
;
SColumnModel
*
pModel
=
NULL
;
*
pFinalModel
=
NULL
;
...
...
@@ -613,7 +613,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
return
pRes
->
code
;
}
pSchema
=
(
S
CMSchema
*
)
calloc
(
1
,
sizeof
(
SCM
Schema
)
*
pQueryInfo
->
fieldsInfo
.
numOfOutputCols
);
pSchema
=
(
S
Schema
*
)
calloc
(
1
,
sizeof
(
S
Schema
)
*
pQueryInfo
->
fieldsInfo
.
numOfOutputCols
);
if
(
pSchema
==
NULL
)
{
tscError
(
"%p failed to allocate memory"
,
pSql
);
pRes
->
code
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
...
...
@@ -647,7 +647,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
return
pRes
->
code
;
}
memset
(
pSchema
,
0
,
sizeof
(
S
CM
Schema
)
*
pQueryInfo
->
fieldsInfo
.
numOfOutputCols
);
memset
(
pSchema
,
0
,
sizeof
(
SSchema
)
*
pQueryInfo
->
fieldsInfo
.
numOfOutputCols
);
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutputCols
;
++
i
)
{
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
pQueryInfo
,
i
);
...
...
@@ -985,7 +985,7 @@ static void savePreviousRow(SLocalReducer *pLocalReducer, tFilePage *tmpBuffer)
// copy to previous temp buffer
for
(
int32_t
i
=
0
;
i
<
pColumnModel
->
numOfCols
;
++
i
)
{
S
CM
Schema
*
pSchema
=
getColumnModelSchema
(
pColumnModel
,
i
);
SSchema
*
pSchema
=
getColumnModelSchema
(
pColumnModel
,
i
);
int16_t
offset
=
getColumnModelOffset
(
pColumnModel
,
i
);
memcpy
(
pLocalReducer
->
prevRowOfInput
+
offset
,
tmpBuffer
->
data
+
offset
,
pSchema
->
bytes
);
...
...
@@ -1208,7 +1208,7 @@ bool doGenerateFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool no
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
;
++
i
)
{
int16_t
offset
=
getColumnModelOffset
(
pModel
,
startIndex
+
i
);
S
CM
Schema
*
pSchema
=
getColumnModelSchema
(
pModel
,
startIndex
+
i
);
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
startIndex
+
i
);
memcpy
(
pInterpoInfo
->
pTags
[
i
],
pLocalReducer
->
pBufForInterpo
+
offset
*
pResBuf
->
numOfElems
,
pSchema
->
bytes
);
...
...
src/client/src/tscServer.c
浏览文件 @
5b969523
...
...
@@ -116,7 +116,7 @@ void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) {
SSqlRes
*
pRes
=
&
pSql
->
res
;
if
(
code
==
0
)
{
S
CMHeartBeatRsp
*
pRsp
=
(
SCM
HeartBeatRsp
*
)
pRes
->
pRsp
;
S
HeartBeatRsp
*
pRsp
=
(
S
HeartBeatRsp
*
)
pRes
->
pRsp
;
SRpcIpSet
*
pIpList
=
&
pRsp
->
ipList
;
tscSetMgmtIpList
(
pIpList
);
...
...
@@ -401,7 +401,7 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSubquerySu
// set the ts,tags that involved in join, as the output column of intermediate result
tscClearSubqueryInfo
(
&
pNew
->
cmd
);
S
CM
Schema
colSchema
=
{.
type
=
TSDB_DATA_TYPE_BINARY
,
.
bytes
=
1
};
SSchema
colSchema
=
{.
type
=
TSDB_DATA_TYPE_BINARY
,
.
bytes
=
1
};
SColumnIndex
index
=
{
0
,
PRIMARYKEY_TIMESTAMP_COL_INDEX
};
tscAddSpecialColumnForSelect
(
pNewQueryInfo
,
0
,
TSDB_FUNC_TS_COMP
,
&
index
,
&
colSchema
,
TSDB_COL_NORMAL
);
...
...
@@ -1459,11 +1459,11 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
// set column list ids
char
*
pMsg
=
(
char
*
)(
pQueryMsg
->
colList
)
+
pQueryInfo
->
colList
.
numOfCols
*
sizeof
(
SColumnInfo
);
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
colList
.
numOfCols
;
++
i
)
{
SColumnBase
*
pCol
=
tscColumnBaseInfoGet
(
&
pQueryInfo
->
colList
,
i
);
S
CM
Schema
*
pColSchema
=
&
pSchema
[
pCol
->
colIndex
.
columnIndex
];
SSchema
*
pColSchema
=
&
pSchema
[
pCol
->
colIndex
.
columnIndex
];
if
(
pCol
->
colIndex
.
columnIndex
>=
pMeterMeta
->
numOfColumns
||
pColSchema
->
type
<
TSDB_DATA_TYPE_BOOL
||
pColSchema
->
type
>
TSDB_DATA_TYPE_NCHAR
)
{
...
...
@@ -1571,18 +1571,18 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
// only include the required tag column schema. If a tag is not required, it won't be sent to vnode
if
(
pMeterMetaInfo
->
numOfTags
>
0
)
{
// always transfer tag schema to vnode if exists
S
CM
Schema
*
pTagSchema
=
tsGetTagSchema
(
pMeterMeta
);
SSchema
*
pTagSchema
=
tsGetTagSchema
(
pMeterMeta
);
for
(
int32_t
j
=
0
;
j
<
pMeterMetaInfo
->
numOfTags
;
++
j
)
{
if
(
pMeterMetaInfo
->
tagColumnIndex
[
j
]
==
TSDB_TBNAME_COLUMN_INDEX
)
{
S
CM
Schema
tbSchema
=
{
SSchema
tbSchema
=
{
.
bytes
=
TSDB_METER_NAME_LEN
,
.
colId
=
TSDB_TBNAME_COLUMN_INDEX
,
.
type
=
TSDB_DATA_TYPE_BINARY
};
memcpy
(
pMsg
,
&
tbSchema
,
sizeof
(
S
CM
Schema
));
memcpy
(
pMsg
,
&
tbSchema
,
sizeof
(
SSchema
));
}
else
{
memcpy
(
pMsg
,
&
pTagSchema
[
pMeterMetaInfo
->
tagColumnIndex
[
j
]],
sizeof
(
S
CM
Schema
));
memcpy
(
pMsg
,
&
pTagSchema
[
pMeterMetaInfo
->
tagColumnIndex
[
j
]],
sizeof
(
SSchema
));
}
pMsg
+=
sizeof
(
S
CM
Schema
);
pMsg
+=
sizeof
(
SSchema
);
}
}
...
...
@@ -1651,19 +1651,19 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
int32_t
tscBuildCreateDbMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SC
MC
reateDbMsg
*
pCreateDbMsg
;
SCreateDbMsg
*
pCreateDbMsg
;
char
*
pMsg
,
*
pStart
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pMsg
=
doBuildMsgHeader
(
pSql
,
&
pStart
);
pCreateDbMsg
=
(
SC
MC
reateDbMsg
*
)
pMsg
;
pCreateDbMsg
=
(
SCreateDbMsg
*
)
pMsg
;
assert
(
pCmd
->
numOfClause
==
1
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
strncpy
(
pCreateDbMsg
->
db
,
pMeterMetaInfo
->
name
,
tListLen
(
pCreateDbMsg
->
db
));
pMsg
+=
sizeof
(
SC
MC
reateDbMsg
);
pMsg
+=
sizeof
(
SCreateDbMsg
);
pCmd
->
payloadLen
=
pMsg
-
pStart
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_CREATE_DB
;
...
...
@@ -1672,7 +1672,7 @@ int32_t tscBuildCreateDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
int32_t
tscBuildCreateDnodeMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SC
MC
reateDnodeMsg
*
pCreate
;
SCreateDnodeMsg
*
pCreate
;
char
*
pMsg
,
*
pStart
;
...
...
@@ -1680,10 +1680,10 @@ int32_t tscBuildCreateDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pMsg
=
doBuildMsgHeader
(
pSql
,
&
pStart
);
pCreate
=
(
SC
MC
reateDnodeMsg
*
)
pMsg
;
pCreate
=
(
SCreateDnodeMsg
*
)
pMsg
;
strncpy
(
pCreate
->
ip
,
pInfo
->
pDCLInfo
->
a
[
0
].
z
,
pInfo
->
pDCLInfo
->
a
[
0
].
n
);
pMsg
+=
sizeof
(
SC
MC
reateDnodeMsg
);
pMsg
+=
sizeof
(
SCreateDnodeMsg
);
pCmd
->
payloadLen
=
pMsg
-
pStart
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_CREATE_DNODE
;
...
...
@@ -1693,13 +1693,13 @@ int32_t tscBuildCreateDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int32_t
tscBuildAcctMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
payloadLen
=
sizeof
(
SC
MC
reateAcctMsg
);
pCmd
->
payloadLen
=
sizeof
(
SCreateAcctMsg
);
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
tscError
(
"%p failed to malloc for query msg"
,
pSql
);
return
TSDB_CODE_CLI_OUT_OF_MEMORY
;
}
SC
MCreateAcctMsg
*
pAlterMsg
=
(
SCM
CreateAcctMsg
*
)
pCmd
->
payload
;
SC
reateAcctMsg
*
pAlterMsg
=
(
S
CreateAcctMsg
*
)
pCmd
->
payload
;
SSQLToken
*
pName
=
&
pInfo
->
pDCLInfo
->
user
.
user
;
SSQLToken
*
pPwd
=
&
pInfo
->
pDCLInfo
->
user
.
passwd
;
...
...
@@ -1737,13 +1737,13 @@ int32_t tscBuildAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
int32_t
tscBuildUserMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SC
MC
reateUserMsg
*
pAlterMsg
;
SCreateUserMsg
*
pAlterMsg
;
char
*
pMsg
,
*
pStart
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pMsg
=
doBuildMsgHeader
(
pSql
,
&
pStart
);
pAlterMsg
=
(
SC
MC
reateUserMsg
*
)
pMsg
;
pAlterMsg
=
(
SCreateUserMsg
*
)
pMsg
;
SUserInfo
*
pUser
=
&
pInfo
->
pDCLInfo
->
user
;
strncpy
(
pAlterMsg
->
user
,
pUser
->
user
.
z
,
pUser
->
user
.
n
);
...
...
@@ -1758,7 +1758,7 @@ int32_t tscBuildUserMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
strncpy
(
pAlterMsg
->
pass
,
pUser
->
passwd
.
z
,
pUser
->
passwd
.
n
);
}
pMsg
+=
sizeof
(
SC
MC
reateUserMsg
);
pMsg
+=
sizeof
(
SCreateUserMsg
);
pCmd
->
payloadLen
=
pMsg
-
pStart
;
if
(
pUser
->
type
==
TSDB_ALTER_USER_PASSWD
||
pUser
->
type
==
TSDB_ALTER_USER_PRIVILEGES
)
{
...
...
@@ -1775,7 +1775,7 @@ int32_t tscBuildCfgDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
char
*
pMsg
=
doBuildMsgHeader
(
pSql
,
&
pStart
);
pMsg
+=
sizeof
(
SC
MC
fgDnodeMsg
);
pMsg
+=
sizeof
(
SCfgDnodeMsg
);
pCmd
->
payloadLen
=
pMsg
-
pStart
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_DNODE_CFG
;
...
...
@@ -1799,19 +1799,19 @@ char *doBuildMsgHeader(SSqlObj *pSql, char **pStart) {
}
int32_t
tscBuildDropDbMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
S
CM
DropDbMsg
*
pDropDbMsg
;
SDropDbMsg
*
pDropDbMsg
;
char
*
pMsg
,
*
pStart
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pMsg
=
doBuildMsgHeader
(
pSql
,
&
pStart
);
pDropDbMsg
=
(
S
CM
DropDbMsg
*
)
pMsg
;
pDropDbMsg
=
(
SDropDbMsg
*
)
pMsg
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
strncpy
(
pDropDbMsg
->
db
,
pMeterMetaInfo
->
name
,
tListLen
(
pDropDbMsg
->
db
));
pDropDbMsg
->
ignoreNotExists
=
pInfo
->
pDCLInfo
->
existsCheck
?
1
:
0
;
pMsg
+=
sizeof
(
S
CM
DropDbMsg
);
pMsg
+=
sizeof
(
SDropDbMsg
);
pCmd
->
payloadLen
=
pMsg
-
pStart
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_DROP_DB
;
...
...
@@ -1851,18 +1851,18 @@ int32_t tscBuildDropTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
int32_t
tscBuildDropDnodeMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
S
CM
DropDnodeMsg
*
pDrop
;
SDropDnodeMsg
*
pDrop
;
char
*
pMsg
,
*
pStart
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
pMsg
=
doBuildMsgHeader
(
pSql
,
&
pStart
);
pDrop
=
(
S
CM
DropDnodeMsg
*
)
pMsg
;
pDrop
=
(
SDropDnodeMsg
*
)
pMsg
;
strcpy
(
pDrop
->
ip
,
pMeterMetaInfo
->
name
);
pMsg
+=
sizeof
(
S
CM
DropDnodeMsg
);
pMsg
+=
sizeof
(
SDropDnodeMsg
);
pCmd
->
payloadLen
=
pMsg
-
pStart
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_DROP_DNODE
;
...
...
@@ -1871,18 +1871,18 @@ int32_t tscBuildDropDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
int32_t
tscBuildDropAcctMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
S
CM
DropUserMsg
*
pDropMsg
;
SDropUserMsg
*
pDropMsg
;
char
*
pMsg
,
*
pStart
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pMsg
=
doBuildMsgHeader
(
pSql
,
&
pStart
);
pDropMsg
=
(
S
CM
DropUserMsg
*
)
pMsg
;
pDropMsg
=
(
SDropUserMsg
*
)
pMsg
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
strcpy
(
pDropMsg
->
user
,
pMeterMetaInfo
->
name
);
pMsg
+=
sizeof
(
S
CM
DropUserMsg
);
pMsg
+=
sizeof
(
SDropUserMsg
);
pCmd
->
payloadLen
=
pMsg
-
pStart
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_DROP_USER
;
...
...
@@ -1891,18 +1891,18 @@ int32_t tscBuildDropAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
int32_t
tscBuildUseDbMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
S
CM
UseDbMsg
*
pUseDbMsg
;
SUseDbMsg
*
pUseDbMsg
;
char
*
pMsg
,
*
pStart
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pMsg
=
doBuildMsgHeader
(
pSql
,
&
pStart
);
pUseDbMsg
=
(
S
CM
UseDbMsg
*
)
pMsg
;
pUseDbMsg
=
(
SUseDbMsg
*
)
pMsg
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
strcpy
(
pUseDbMsg
->
db
,
pMeterMetaInfo
->
name
);
pMsg
+=
sizeof
(
S
CM
UseDbMsg
);
pMsg
+=
sizeof
(
SUseDbMsg
);
pCmd
->
payloadLen
=
pMsg
-
pStart
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_USE_DB
;
...
...
@@ -1918,7 +1918,7 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
STscObj
*
pObj
=
pSql
->
pTscObj
;
int32_t
size
=
minMsgSize
()
+
sizeof
(
SMgmtHead
)
+
sizeof
(
S
CM
ShowTableMsg
)
+
pCmd
->
payloadLen
+
TSDB_EXTRA_PAYLOAD_SIZE
;
int32_t
size
=
minMsgSize
()
+
sizeof
(
SMgmtHead
)
+
sizeof
(
SShowTableMsg
)
+
pCmd
->
payloadLen
+
TSDB_EXTRA_PAYLOAD_SIZE
;
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
size
))
{
tscError
(
"%p failed to malloc for show msg"
,
pSql
);
return
-
1
;
...
...
@@ -1951,7 +1951,7 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
strncpy
(
pShowMsg
->
payload
,
pPattern
->
z
,
pPattern
->
n
);
pShowMsg
->
payloadLen
=
htons
(
pPattern
->
n
);
}
pMsg
+=
(
sizeof
(
S
CM
ShowTableMsg
)
+
pPattern
->
n
);
pMsg
+=
(
sizeof
(
SShowTableMsg
)
+
pPattern
->
n
);
}
else
{
SSQLToken
*
pIpAddr
=
&
pShowInfo
->
prefix
;
assert
(
pIpAddr
->
n
>
0
&&
pIpAddr
->
type
>
0
);
...
...
@@ -1959,7 +1959,7 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
strncpy
(
pShowMsg
->
payload
,
pIpAddr
->
z
,
pIpAddr
->
n
);
pShowMsg
->
payloadLen
=
htons
(
pIpAddr
->
n
);
pMsg
+=
(
sizeof
(
S
CM
ShowTableMsg
)
+
pIpAddr
->
n
);
pMsg
+=
(
sizeof
(
SShowTableMsg
)
+
pIpAddr
->
n
);
}
pCmd
->
payloadLen
=
pMsg
-
pStart
;
...
...
@@ -1971,17 +1971,17 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
int32_t
tscBuildKillMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
S
CM
KillQueryMsg
*
pKill
;
SKillQueryMsg
*
pKill
;
char
*
pMsg
,
*
pStart
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pMsg
=
doBuildMsgHeader
(
pSql
,
&
pStart
);
pKill
=
(
S
CM
KillQueryMsg
*
)
pMsg
;
pKill
=
(
SKillQueryMsg
*
)
pMsg
;
strncpy
(
pKill
->
queryId
,
pInfo
->
pDCLInfo
->
ip
.
z
,
pInfo
->
pDCLInfo
->
ip
.
n
);
pMsg
+=
sizeof
(
S
CM
KillQueryMsg
);
pMsg
+=
sizeof
(
SKillQueryMsg
);
pCmd
->
payloadLen
=
pMsg
-
pStart
;
...
...
@@ -2002,13 +2002,13 @@ int32_t tscBuildKillMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int
tscEstimateCreateTableMsgLength
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SSqlCmd
*
pCmd
=
&
(
pSql
->
cmd
);
int32_t
size
=
minMsgSize
()
+
sizeof
(
SMgmtHead
)
+
sizeof
(
SC
MC
reateTableMsg
);
int32_t
size
=
minMsgSize
()
+
sizeof
(
SMgmtHead
)
+
sizeof
(
SCreateTableMsg
);
SCreateTableSQL
*
pCreateTableInfo
=
pInfo
->
pCreateTableInfo
;
if
(
pCreateTableInfo
->
type
==
TSQL_CREATE_TABLE_FROM_STABLE
)
{
size
+=
sizeof
(
STagData
);
}
else
{
size
+=
sizeof
(
S
CM
Schema
)
*
(
pCmd
->
numOfCols
+
pCmd
->
count
);
size
+=
sizeof
(
SSchema
)
*
(
pCmd
->
numOfCols
+
pCmd
->
count
);
}
if
(
pCreateTableInfo
->
pSelect
!=
NULL
)
{
...
...
@@ -2019,10 +2019,10 @@ int tscEstimateCreateTableMsgLength(SSqlObj *pSql, SSqlInfo *pInfo) {
}
int
tscBuildCreateTableMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SC
MC
reateTableMsg
*
pCreateTableMsg
;
SCreateTableMsg
*
pCreateTableMsg
;
char
*
pMsg
,
*
pStart
;
int
msgLen
=
0
;
S
CM
Schema
*
pSchema
;
SSchema
*
pSchema
;
int
size
=
0
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
...
...
@@ -2047,7 +2047,7 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pMsg
+=
sizeof
(
SMgmtHead
);
pCreateTableMsg
=
(
SC
MC
reateTableMsg
*
)
pMsg
;
pCreateTableMsg
=
(
SCreateTableMsg
*
)
pMsg
;
strcpy
(
pCreateTableMsg
->
tableId
,
pMeterMetaInfo
->
name
);
SCreateTableSQL
*
pCreateTable
=
pInfo
->
pCreateTableInfo
;
...
...
@@ -2099,7 +2099,7 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int
tscEstimateAlterTableMsgLength
(
SSqlCmd
*
pCmd
)
{
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
return
minMsgSize
()
+
sizeof
(
SMgmtHead
)
+
sizeof
(
SAlterTableMsg
)
+
sizeof
(
S
CM
Schema
)
*
tscNumOfFields
(
pQueryInfo
)
+
return
minMsgSize
()
+
sizeof
(
SMgmtHead
)
+
sizeof
(
SAlterTableMsg
)
+
sizeof
(
SSchema
)
*
tscNumOfFields
(
pQueryInfo
)
+
TSDB_EXTRA_PAYLOAD_SIZE
;
}
...
...
@@ -2136,7 +2136,7 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pAlterTableMsg
->
numOfCols
=
htons
(
tscNumOfFields
(
pQueryInfo
));
memcpy
(
pAlterTableMsg
->
tagVal
,
pAlterInfo
->
tagData
.
data
,
TSDB_MAX_TAGS_LEN
);
S
CM
Schema
*
pSchema
=
pAlterTableMsg
->
schema
;
SSchema
*
pSchema
=
pAlterTableMsg
->
schema
;
for
(
int
i
=
0
;
i
<
tscNumOfFields
(
pQueryInfo
);
++
i
)
{
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
pQueryInfo
,
i
);
...
...
@@ -2158,7 +2158,7 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
int
tscAlterDbMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
S
CM
AlterDbMsg
*
pAlterDbMsg
;
SAlterDbMsg
*
pAlterDbMsg
;
char
*
pMsg
,
*
pStart
;
int
msgLen
=
0
;
...
...
@@ -2173,10 +2173,10 @@ int tscAlterDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
strcpy
(
pMgmt
->
db
,
pObj
->
db
);
pMsg
+=
sizeof
(
SMgmtHead
);
pAlterDbMsg
=
(
S
CM
AlterDbMsg
*
)
pMsg
;
pAlterDbMsg
=
(
SAlterDbMsg
*
)
pMsg
;
strcpy
(
pAlterDbMsg
->
db
,
pMeterMetaInfo
->
name
);
pMsg
+=
sizeof
(
S
CM
AlterDbMsg
);
pMsg
+=
sizeof
(
SAlterDbMsg
);
msgLen
=
pMsg
-
pStart
;
pCmd
->
payloadLen
=
msgLen
;
...
...
@@ -2333,14 +2333,14 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
STscObj
*
pObj
=
pSql
->
pTscObj
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_CONNECT
;
pCmd
->
payloadLen
=
sizeof
(
SC
MC
onnectMsg
);
pCmd
->
payloadLen
=
sizeof
(
SConnectMsg
);
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
tscError
(
"%p failed to malloc for query msg"
,
pSql
);
return
TSDB_CODE_CLI_OUT_OF_MEMORY
;
}
SC
MConnectMsg
*
pConnect
=
(
SCM
ConnectMsg
*
)
pCmd
->
payload
;
SC
onnectMsg
*
pConnect
=
(
S
ConnectMsg
*
)
pCmd
->
payload
;
char
*
db
;
// ugly code to move the space
db
=
strstr
(
pObj
->
db
,
TS_PATH_DELIMITER
);
...
...
@@ -2610,18 +2610,18 @@ int tscEstimateHeartBeatMsgLength(SSqlObj *pSql) {
STscObj
*
pObj
=
pSql
->
pTscObj
;
size
+=
tsRpcHeadSize
+
sizeof
(
SMgmtHead
);
size
+=
sizeof
(
S
CM
QqueryList
);
size
+=
sizeof
(
SQqueryList
);
SSqlObj
*
tpSql
=
pObj
->
sqlList
;
while
(
tpSql
)
{
size
+=
sizeof
(
S
CM
QueryDesc
);
size
+=
sizeof
(
SQueryDesc
);
tpSql
=
tpSql
->
next
;
}
size
+=
sizeof
(
S
CM
StreamList
);
size
+=
sizeof
(
SStreamList
);
SSqlStream
*
pStream
=
pObj
->
streamList
;
while
(
pStream
)
{
size
+=
sizeof
(
S
CM
StreamDesc
);
size
+=
sizeof
(
SStreamDesc
);
pStream
=
pStream
->
next
;
}
...
...
@@ -2664,7 +2664,7 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int
tscProcessMeterMetaRsp
(
SSqlObj
*
pSql
)
{
SMeterMeta
*
pMeta
;
S
CM
Schema
*
pSchema
;
SSchema
*
pSchema
;
uint8_t
ieType
;
char
*
rsp
=
pSql
->
res
.
pRsp
;
...
...
@@ -2706,7 +2706,7 @@ int tscProcessMeterMetaRsp(SSqlObj *pSql) {
pMeta
->
rowSize
=
0
;
rsp
+=
sizeof
(
SMeterMeta
);
pSchema
=
(
S
CM
Schema
*
)
rsp
;
pSchema
=
(
SSchema
*
)
rsp
;
int32_t
numOfTotalCols
=
pMeta
->
numOfColumns
+
pMeta
->
numOfTags
;
for
(
int
i
=
0
;
i
<
numOfTotalCols
;
++
i
)
{
...
...
@@ -2720,10 +2720,10 @@ int tscProcessMeterMetaRsp(SSqlObj *pSql) {
pSchema
++
;
}
rsp
+=
numOfTotalCols
*
sizeof
(
S
CM
Schema
);
rsp
+=
numOfTotalCols
*
sizeof
(
SSchema
);
int32_t
tagLen
=
0
;
S
CM
Schema
*
pTagsSchema
=
tsGetTagSchema
(
pMeta
);
SSchema
*
pTagsSchema
=
tsGetTagSchema
(
pMeta
);
if
(
pMeta
->
tableType
==
TSDB_TABLE_TYPE_CHILD_TABLE
)
{
for
(
int32_t
i
=
0
;
i
<
pMeta
->
numOfTags
;
++
i
)
{
...
...
@@ -2751,11 +2751,11 @@ int tscProcessMeterMetaRsp(SSqlObj *pSql) {
/**
* multi meter meta rsp pkg format:
* | STaosRsp | ieType | SMultiMeterInfoMsg | SMeterMeta0 | S
CMSchema0 | SMeterMeta1 | SCMSchema1 | SMeterMeta2 | SCM
Schema2
* | STaosRsp | ieType | SMultiMeterInfoMsg | SMeterMeta0 | S
Schema0 | SMeterMeta1 | SSchema1 | SMeterMeta2 | S
Schema2
* |...... 1B 1B 4B
**/
int
tscProcessMultiMeterMetaRsp
(
SSqlObj
*
pSql
)
{
S
CM
Schema
*
pSchema
;
SSchema
*
pSchema
;
uint8_t
ieType
;
int32_t
totalNum
;
int32_t
i
;
...
...
@@ -2821,7 +2821,7 @@ int tscProcessMultiMeterMetaRsp(SSqlObj *pSql) {
pMeta
->
rowSize
=
0
;
rsp
+=
sizeof
(
SMultiMeterMeta
);
pSchema
=
(
S
CM
Schema
*
)
rsp
;
pSchema
=
(
SSchema
*
)
rsp
;
int32_t
numOfTotalCols
=
pMeta
->
numOfColumns
+
pMeta
->
numOfTags
;
for
(
int
j
=
0
;
j
<
numOfTotalCols
;
++
j
)
{
...
...
@@ -2835,10 +2835,10 @@ int tscProcessMultiMeterMetaRsp(SSqlObj *pSql) {
pSchema
++
;
}
rsp
+=
numOfTotalCols
*
sizeof
(
S
CM
Schema
);
rsp
+=
numOfTotalCols
*
sizeof
(
SSchema
);
int32_t
tagLen
=
0
;
S
CM
Schema
*
pTagsSchema
=
tsGetTagSchema
(
pMeta
);
SSchema
*
pTagsSchema
=
tsGetTagSchema
(
pMeta
);
if
(
pMeta
->
tableType
==
TSDB_TABLE_TYPE_CHILD_TABLE
)
{
for
(
int32_t
j
=
0
;
j
<
pMeta
->
numOfTags
;
++
j
)
{
...
...
@@ -2987,8 +2987,8 @@ _error_clean:
*/
int
tscProcessShowRsp
(
SSqlObj
*
pSql
)
{
SMeterMeta
*
pMeta
;
SShowRsp
Msg
*
pShow
;
S
CM
Schema
*
pSchema
;
SShowRsp
*
pShow
;
SSchema
*
pSchema
;
char
key
[
20
];
SSqlRes
*
pRes
=
&
pSql
->
res
;
...
...
@@ -2998,7 +2998,7 @@ int tscProcessShowRsp(SSqlObj *pSql) {
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
pShow
=
(
SShowRsp
Msg
*
)
pRes
->
pRsp
;
pShow
=
(
SShowRsp
*
)
pRes
->
pRsp
;
pRes
->
qhandle
=
pShow
->
qhandle
;
tscResetForNextRetrieve
(
pRes
);
...
...
@@ -3006,7 +3006,7 @@ int tscProcessShowRsp(SSqlObj *pSql) {
pMeta
->
numOfColumns
=
ntohs
(
pMeta
->
numOfColumns
);
pSchema
=
(
S
CM
Schema
*
)((
char
*
)
pMeta
+
sizeof
(
SMeterMeta
));
pSchema
=
(
SSchema
*
)((
char
*
)
pMeta
+
sizeof
(
SMeterMeta
));
pMeta
->
sid
=
ntohs
(
pMeta
->
sid
);
for
(
int
i
=
0
;
i
<
pMeta
->
numOfColumns
;
++
i
)
{
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
...
...
@@ -3018,11 +3018,11 @@ int tscProcessShowRsp(SSqlObj *pSql) {
taosRemoveDataFromCache
(
tscCacheHandle
,
(
void
*
)
&
(
pMeterMetaInfo
->
pMeterMeta
),
false
);
int32_t
size
=
pMeta
->
numOfColumns
*
sizeof
(
S
CM
Schema
)
+
sizeof
(
SMeterMeta
);
int32_t
size
=
pMeta
->
numOfColumns
*
sizeof
(
SSchema
)
+
sizeof
(
SMeterMeta
);
pMeterMetaInfo
->
pMeterMeta
=
(
SMeterMeta
*
)
taosAddDataIntoCache
(
tscCacheHandle
,
key
,
(
char
*
)
pMeta
,
size
,
tsMeterMetaKeepTimer
);
pCmd
->
numOfCols
=
pQueryInfo
->
fieldsInfo
.
numOfOutputCols
;
S
CM
Schema
*
pMeterSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
SSchema
*
pMeterSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
tscColumnBaseInfoReserve
(
&
pQueryInfo
->
colList
,
pMeta
->
numOfColumns
);
SColumnIndex
index
=
{
0
};
...
...
@@ -3042,7 +3042,7 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
STscObj
*
pObj
=
pSql
->
pTscObj
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
SC
MConnectRsp
*
pConnect
=
(
SCM
ConnectRsp
*
)
pRes
->
pRsp
;
SC
onnectRsp
*
pConnect
=
(
S
ConnectRsp
*
)
pRes
->
pRsp
;
strcpy
(
pObj
->
acctId
,
pConnect
->
acctId
);
// copy acctId from response
int32_t
len
=
sprintf
(
temp
,
"%s%s%s"
,
pObj
->
acctId
,
TS_PATH_DELIMITER
,
pObj
->
db
);
...
...
@@ -3050,7 +3050,7 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
strncpy
(
pObj
->
db
,
temp
,
tListLen
(
pObj
->
db
));
// SIpList * pIpList;
// char *rsp = pRes->pRsp + sizeof(SC
MC
onnectRsp);
// char *rsp = pRes->pRsp + sizeof(SConnectRsp);
// pIpList = (SIpList *)rsp;
// tscSetMgmtIpList(pIpList);
...
...
src/client/src/tscUtil.c
浏览文件 @
5b969523
...
...
@@ -856,7 +856,7 @@ static void setValueImpl(TAOS_FIELD* pField, int8_t type, const char* name, int1
pField
->
bytes
=
bytes
;
}
void
tscFieldInfoSetValFromSchema
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
,
S
CM
Schema
*
pSchema
)
{
void
tscFieldInfoSetValFromSchema
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
,
SSchema
*
pSchema
)
{
ensureSpace
(
pFieldInfo
,
pFieldInfo
->
numOfOutputCols
+
1
);
evic
(
pFieldInfo
,
index
);
...
...
@@ -1079,7 +1079,7 @@ SSqlExpr* tscSqlExprInsert(SQueryInfo* pQueryInfo, int32_t index, int16_t functi
if
(
pColIndex
->
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
pExpr
->
colInfo
.
colId
=
TSDB_TBNAME_COLUMN_INDEX
;
}
else
{
S
CM
Schema
*
pSchema
=
tsGetColumnSchema
(
pMeterMetaInfo
->
pMeterMeta
,
pColIndex
->
columnIndex
);
SSchema
*
pSchema
=
tsGetColumnSchema
(
pMeterMetaInfo
->
pMeterMeta
,
pColIndex
->
columnIndex
);
pExpr
->
colInfo
.
colId
=
pSchema
->
colId
;
}
...
...
@@ -1509,7 +1509,7 @@ bool tscValidateColumnId(SMeterMetaInfo* pMeterMetaInfo, int32_t colId) {
return
true
;
}
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
int32_t
numOfTotal
=
pMeterMetaInfo
->
pMeterMeta
->
numOfTags
+
pMeterMetaInfo
->
pMeterMeta
->
numOfColumns
;
for
(
int32_t
i
=
0
;
i
<
numOfTotal
;
++
i
)
{
...
...
@@ -1555,14 +1555,14 @@ void tscTagCondRelease(STagCond* pCond) {
void
tscGetSrcColumnInfo
(
SSrcColumnInfo
*
pColInfo
,
SQueryInfo
*
pQueryInfo
)
{
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
exprsInfo
.
numOfExprs
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
pColInfo
[
i
].
functionId
=
pExpr
->
functionId
;
if
(
TSDB_COL_IS_TAG
(
pExpr
->
colInfo
.
flag
))
{
S
CM
Schema
*
pTagSchema
=
tsGetTagSchema
(
pMeterMetaInfo
->
pMeterMeta
);
SSchema
*
pTagSchema
=
tsGetTagSchema
(
pMeterMetaInfo
->
pMeterMeta
);
int16_t
actualTagIndex
=
pMeterMetaInfo
->
tagColumnIndex
[
pExpr
->
colInfo
.
colIdx
];
pColInfo
[
i
].
type
=
(
actualTagIndex
!=
-
1
)
?
pTagSchema
[
actualTagIndex
].
type
:
TSDB_DATA_TYPE_BINARY
;
...
...
src/dnode/src/dnodeMgmt.c
浏览文件 @
5b969523
...
...
@@ -176,7 +176,7 @@ int32_t dnodeProcessFreeVnodeRequest(int8_t *pCont, int32_t contLen, int8_t msgT
}
int32_t
dnodeProcessDnodeCfgRequest
(
int8_t
*
pCont
,
int32_t
contLen
,
int8_t
msgType
,
void
*
pConn
)
{
SC
MCfgDnodeMsg
*
pCfg
=
(
SCM
CfgDnodeMsg
*
)
pCont
;
SC
fgDnodeMsg
*
pCfg
=
(
S
CfgDnodeMsg
*
)
pCont
;
int32_t
code
=
tsCfgDynamicOptions
(
pCfg
->
config
);
dnodeSendSimpleRspToMnode
(
pConn
,
msgType
+
1
,
code
);
return
code
;
...
...
src/inc/mnode.h
浏览文件 @
5b969523
...
...
@@ -130,7 +130,7 @@ typedef struct _tab_obj {
char
*
pReserve1
;
char
*
pReserve2
;
char
*
schema
;
// S
CM
Schema schema[];
// SSchema schema[];
}
STabObj
;
typedef
struct
{
...
...
@@ -156,7 +156,7 @@ typedef struct SSuperTableObj {
int8_t
reserved
[
7
];
int8_t
updateEnd
[
1
];
int16_t
nextColId
;
S
CM
Schema
*
schema
;
SSchema
*
schema
;
}
SSuperTableObj
;
typedef
struct
{
...
...
@@ -184,7 +184,7 @@ typedef struct {
int8_t
reserved
[
3
];
int8_t
updateEnd
[
1
];
int16_t
nextColId
;
S
CM
Schema
*
schema
;
SSchema
*
schema
;
}
SNormalTableObj
;
typedef
struct
{
...
...
@@ -201,7 +201,7 @@ typedef struct {
int8_t
updateEnd
[
1
];
int16_t
nextColId
;
char
*
sql
;
//null-terminated string
S
CM
Schema
*
schema
;
SSchema
*
schema
;
}
SStreamTableObj
;
typedef
struct
_vg_obj
{
...
...
@@ -257,8 +257,8 @@ typedef struct _user_obj {
char
updateEnd
[
1
];
struct
_user_obj
*
prev
,
*
next
;
struct
_acctObj
*
pAcct
;
S
CM
QqueryList
*
pQList
;
// query list
S
CM
StreamList
*
pSList
;
// stream list
SQqueryList
*
pQList
;
// query list
SStreamList
*
pSList
;
// stream list
}
SUserObj
;
typedef
struct
{
...
...
@@ -282,7 +282,7 @@ typedef struct {
typedef
struct
_acctObj
{
char
user
[
TSDB_USER_LEN
];
char
pass
[
TSDB_KEY_LEN
];
S
CM
AcctCfg
cfg
;
SAcctCfg
cfg
;
int32_t
acctId
;
int64_t
createdTime
;
int8_t
reserved
[
15
];
...
...
src/inc/taosmsg.h
浏览文件 @
5b969523
...
...
@@ -245,18 +245,12 @@ typedef struct {
SShellSubmitRspBlock
*
failedBlocks
;
}
SShellSubmitRspMsg
;
typedef
struct
S
CM
Schema
{
typedef
struct
SSchema
{
uint8_t
type
;
char
name
[
TSDB_COL_NAME_LEN
];
short
colId
;
short
bytes
;
}
SCMSchema
;
typedef
struct
{
int8_t
type
;
int16_t
colId
;
int16_t
bytes
;
}
SDTableColumn
;
}
SSchema
;
typedef
struct
{
int32_t
vnode
;
...
...
@@ -277,7 +271,7 @@ typedef struct {
typedef
struct
{
char
db
[
TSDB_DB_NAME_LEN
];
}
S
CM
ShowTableMsg
;
}
SShowTableMsg
;
typedef
struct
{
char
tableId
[
TSDB_TABLE_ID_LEN
];
...
...
@@ -287,8 +281,8 @@ typedef struct {
int16_t
numOfColumns
;
int16_t
sqlLen
;
// the length of SQL, it starts after schema , sql is a null-terminated string
int16_t
reserved
[
16
];
S
CM
Schema
schema
[];
}
SC
MC
reateTableMsg
;
SSchema
schema
[];
}
SCreateTableMsg
;
typedef
struct
{
char
meterId
[
TSDB_TABLE_ID_LEN
];
...
...
@@ -302,14 +296,14 @@ typedef struct {
int16_t
type
;
/* operation type */
char
tagVal
[
TSDB_MAX_BYTES_PER_ROW
];
int8_t
numOfCols
;
/* number of schema */
S
CM
Schema
schema
[];
SSchema
schema
[];
}
SAlterTableMsg
;
typedef
struct
{
char
clientVersion
[
TSDB_VERSION_LEN
];
char
msgVersion
[
TSDB_VERSION_LEN
];
char
db
[
TSDB_TABLE_ID_LEN
];
}
SC
MC
onnectMsg
;
}
SConnectMsg
;
typedef
struct
{
char
acctId
[
TSDB_ACCT_LEN
];
...
...
@@ -317,7 +311,7 @@ typedef struct {
int8_t
writeAuth
;
int8_t
superAuth
;
SRpcIpSet
ipList
;
}
SC
MC
onnectRsp
;
}
SConnectRsp
;
typedef
struct
{
int32_t
maxUsers
;
...
...
@@ -331,24 +325,24 @@ typedef struct {
int64_t
maxInbound
;
int64_t
maxOutbound
;
int8_t
accessState
;
// Configured only by command
}
S
CM
AcctCfg
;
}
SAcctCfg
;
typedef
struct
{
char
user
[
TSDB_USER_LEN
];
char
pass
[
TSDB_KEY_LEN
];
S
CM
AcctCfg
cfg
;
}
SC
MCreateAcctMsg
,
SCM
AlterAcctMsg
;
SAcctCfg
cfg
;
}
SC
reateAcctMsg
,
S
AlterAcctMsg
;
typedef
struct
{
char
user
[
TSDB_USER_LEN
];
}
S
CMDropUserMsg
,
SCM
DropAcctMsg
;
}
S
DropUserMsg
,
S
DropAcctMsg
;
typedef
struct
{
char
user
[
TSDB_USER_LEN
];
char
pass
[
TSDB_KEY_LEN
];
int8_t
privilege
;
int8_t
flag
;
}
SC
MCreateUserMsg
,
SCM
AlterUserMsg
;
}
SC
reateUserMsg
,
S
AlterUserMsg
;
typedef
struct
{
char
db
[
TSDB_TABLE_ID_LEN
];
...
...
@@ -582,12 +576,12 @@ typedef struct {
int8_t
loadLatest
;
// load into mem or not
uint8_t
precision
;
// time resolution
int8_t
reserved
[
16
];
}
SVnodeCfg
,
SC
MCreateDbMsg
,
SDbCfg
,
SCM
AlterDbMsg
;
}
SVnodeCfg
,
SC
reateDbMsg
,
SDbCfg
,
S
AlterDbMsg
;
typedef
struct
{
char
db
[
TSDB_TABLE_ID_LEN
];
uint8_t
ignoreNotExists
;
}
S
CMDropDbMsg
,
SCM
UseDbMsg
;
}
S
DropDbMsg
,
S
UseDbMsg
;
// IMPORTANT: sizeof(SVnodeStatisticInfo) should not exceed
// TSDB_FILE_HEADER_LEN/4 - TSDB_FILE_HEADER_VERSION_SIZE
...
...
@@ -744,19 +738,19 @@ typedef struct {
* payloadLen is the length of payload
*/
typedef
struct
{
char
type
;
int8_t
type
;
uint16_t
payloadLen
;
char
payload
[];
}
SShowMsg
;
typedef
struct
{
char
ip
[
20
];
}
SCMCreateMnodeMsg
,
SCMDropMnodeMsg
,
SCMCreateDnodeMsg
,
SCMDropDnodeMsg
;
typedef
struct
{
uint64_t
qhandle
;
SMeterMeta
meterMeta
;
}
SShowRspMsg
;
}
SShowRsp
;
typedef
struct
{
char
ip
[
20
];
}
SCreateMnodeMsg
,
SDropMnodeMsg
,
SCreateDnodeMsg
,
SDropDnodeMsg
;
typedef
struct
{
int32_t
vnode
;
...
...
@@ -770,14 +764,14 @@ typedef struct {
typedef
struct
{
char
ip
[
32
];
char
config
[
64
];
}
SC
MC
fgDnodeMsg
;
}
SCfgDnodeMsg
;
typedef
struct
{
char
sql
[
TSDB_SHOW_SQL_LEN
];
uint32_t
queryId
;
int64_t
useconds
;
int64_t
stime
;
}
S
CM
QueryDesc
;
}
SQueryDesc
;
typedef
struct
{
char
sql
[
TSDB_SHOW_SQL_LEN
];
...
...
@@ -788,33 +782,33 @@ typedef struct {
int64_t
stime
;
int64_t
slidingTime
;
int64_t
interval
;
}
S
CM
StreamDesc
;
}
SStreamDesc
;
typedef
struct
{
int32_t
numOfQueries
;
S
CM
QueryDesc
qdesc
[];
}
S
CM
QqueryList
;
SQueryDesc
qdesc
[];
}
SQqueryList
;
typedef
struct
{
int32_t
numOfStreams
;
S
CM
StreamDesc
sdesc
[];
}
S
CM
StreamList
;
SStreamDesc
sdesc
[];
}
SStreamList
;
typedef
struct
{
S
CM
QqueryList
qlist
;
S
CM
StreamList
slist
;
}
S
CM
HeartBeatMsg
;
SQqueryList
qlist
;
SStreamList
slist
;
}
SHeartBeatMsg
;
typedef
struct
{
uint32_t
queryId
;
uint32_t
streamId
;
int8_t
killConnection
;
SRpcIpSet
ipList
;
}
S
CM
HeartBeatRsp
;
}
SHeartBeatRsp
;
typedef
struct
{
char
queryId
[
TSDB_KILL_MSG_LEN
];
}
S
CMKillQueryMsg
,
SCM
KillStreamMsg
,
SKillConnectionMsg
;
}
S
KillQueryMsg
,
S
KillStreamMsg
,
SKillConnectionMsg
;
typedef
struct
{
int32_t
vnode
;
...
...
src/mnode/inc/mgmtAcct.h
浏览文件 @
5b969523
...
...
@@ -32,7 +32,7 @@ extern void (*mgmtCleanUpAccts)();
extern
SAcctObj
*
(
*
mgmtGetAcct
)(
char
*
acctName
);
extern
int32_t
(
*
mgmtCheckUserLimit
)(
SAcctObj
*
pAcct
);
extern
int32_t
(
*
mgmtCheckDbLimit
)(
SAcctObj
*
pAcct
);
extern
int32_t
(
*
mgmtCheckTableLimit
)(
SAcctObj
*
pAcct
,
SC
MC
reateTableMsg
*
pCreate
);
extern
int32_t
(
*
mgmtCheckTableLimit
)(
SAcctObj
*
pAcct
,
SCreateTableMsg
*
pCreate
);
extern
int32_t
(
*
mgmtGetAcctMeta
)(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
extern
int32_t
(
*
mgmtRetrieveAccts
)(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
...
...
src/mnode/inc/mgmtChildTable.h
浏览文件 @
5b969523
...
...
@@ -28,7 +28,7 @@ extern "C" {
int32_t
mgmtInitChildTables
();
void
mgmtCleanUpChildTables
();
int32_t
mgmtCreateChildTable
(
SDbObj
*
pDb
,
SC
MC
reateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
);
int32_t
mgmtCreateChildTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
);
int32_t
mgmtDropChildTable
(
SDbObj
*
pDb
,
SChildTableObj
*
pTable
);
int32_t
mgmtAlterChildTable
(
SDbObj
*
pDb
,
SAlterTableMsg
*
pAlter
);
int32_t
mgmtModifyChildTableTagValueByName
(
SChildTableObj
*
pTable
,
char
*
tagName
,
char
*
nContent
);
...
...
src/mnode/inc/mgmtDb.h
浏览文件 @
5b969523
...
...
@@ -23,7 +23,7 @@ extern "C" {
#include "mnode.h"
void
mgmtMonitorDbDrop
(
void
*
unused
,
void
*
unusedt
);
int32_t
mgmtAlterDb
(
SAcctObj
*
pAcct
,
S
CM
AlterDbMsg
*
pAlter
);
int32_t
mgmtAlterDb
(
SAcctObj
*
pAcct
,
SAlterDbMsg
*
pAlter
);
int32_t
mgmtAddVgroupIntoDb
(
SDbObj
*
pDb
,
SVgObj
*
pVgroup
);
int32_t
mgmtAddVgroupIntoDbTail
(
SDbObj
*
pDb
,
SVgObj
*
pVgroup
);
int32_t
mgmtRemoveVgroupFromDb
(
SDbObj
*
pDb
,
SVgObj
*
pVgroup
);
...
...
@@ -37,7 +37,7 @@ int32_t mgmtInitDbs();
int32_t
mgmtUpdateDb
(
SDbObj
*
pDb
);
SDbObj
*
mgmtGetDb
(
char
*
db
);
SDbObj
*
mgmtGetDbByTableId
(
char
*
db
);
int32_t
mgmtCreateDb
(
SAcctObj
*
pAcct
,
SC
MC
reateDbMsg
*
pCreate
);
int32_t
mgmtCreateDb
(
SAcctObj
*
pAcct
,
SCreateDbMsg
*
pCreate
);
int32_t
mgmtDropDbByName
(
SAcctObj
*
pAcct
,
char
*
name
,
short
ignoreNotExists
);
int32_t
mgmtDropDb
(
SDbObj
*
pDb
);
bool
mgmtCheckIsMonitorDB
(
char
*
db
,
char
*
monitordb
);
...
...
src/mnode/inc/mgmtNormalTable.h
浏览文件 @
5b969523
...
...
@@ -26,9 +26,9 @@ extern "C" {
int32_t
mgmtInitNormalTables
();
void
mgmtCleanUpNormalTables
();
int32_t
mgmtCreateNormalTable
(
SDbObj
*
pDb
,
SC
MC
reateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
);
int32_t
mgmtCreateNormalTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
);
int32_t
mgmtDropNormalTable
(
SDbObj
*
pDb
,
SNormalTableObj
*
pTable
);
int32_t
mgmtAddNormalTableColumn
(
SNormalTableObj
*
pTable
,
S
CM
Schema
schema
[],
int32_t
ncols
);
int32_t
mgmtAddNormalTableColumn
(
SNormalTableObj
*
pTable
,
SSchema
schema
[],
int32_t
ncols
);
int32_t
mgmtDropNormalTableColumnByName
(
SNormalTableObj
*
pTable
,
char
*
colName
);
SNormalTableObj
*
mgmtGetNormalTable
(
char
*
tableId
);
int8_t
*
mgmtBuildCreateNormalTableMsg
(
SNormalTableObj
*
pTable
);
...
...
src/mnode/inc/mgmtProfile.h
浏览文件 @
5b969523
...
...
@@ -30,7 +30,7 @@ int32_t mgmtRetrieveQueries(SShowObj *pShow, char *data, int32_t rows, void *pCo
int32_t
mgmtRetrieveStreams
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
int32_t
mgmtSaveQueryStreamList
(
S
CM
HeartBeatMsg
*
pHBMsg
);
int32_t
mgmtSaveQueryStreamList
(
SHeartBeatMsg
*
pHBMsg
);
int32_t
mgmtKillQuery
(
char
*
qidstr
,
void
*
pConn
);
...
...
src/mnode/inc/mgmtStreamTable.h
浏览文件 @
5b969523
...
...
@@ -26,7 +26,7 @@ extern "C" {
int32_t
mgmtInitStreamTables
();
void
mgmtCleanUpStreamTables
();
int32_t
mgmtCreateStreamTable
(
SDbObj
*
pDb
,
SC
MC
reateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
);
int32_t
mgmtCreateStreamTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
);
int32_t
mgmtDropStreamTable
(
SDbObj
*
pDb
,
SStreamTableObj
*
pTable
);
int32_t
mgmtAlterStreamTable
(
SDbObj
*
pDb
,
SAlterTableMsg
*
pAlter
);
SStreamTableObj
*
mgmtGetStreamTable
(
char
*
tableId
);
...
...
src/mnode/inc/mgmtSuperTable.h
浏览文件 @
5b969523
...
...
@@ -28,14 +28,14 @@ extern "C" {
int32_t
mgmtInitSuperTables
();
void
mgmtCleanUpSuperTables
();
int32_t
mgmtCreateSuperTable
(
SDbObj
*
pDb
,
SC
MC
reateTableMsg
*
pCreate
);
int32_t
mgmtCreateSuperTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
);
int32_t
mgmtDropSuperTable
(
SDbObj
*
pDb
,
SSuperTableObj
*
pTable
);
SSuperTableObj
*
mgmtGetSuperTable
(
char
*
tableId
);
int32_t
mgmtFindSuperTableTagIndex
(
SSuperTableObj
*
pTable
,
const
char
*
tagName
);
int32_t
mgmtAddSuperTableTag
(
SSuperTableObj
*
pTable
,
S
CM
Schema
schema
[],
int32_t
ntags
);
int32_t
mgmtAddSuperTableTag
(
SSuperTableObj
*
pTable
,
SSchema
schema
[],
int32_t
ntags
);
int32_t
mgmtDropSuperTableTag
(
SSuperTableObj
*
pTable
,
char
*
tagName
);
int32_t
mgmtModifySuperTableTagNameByName
(
SSuperTableObj
*
pTable
,
char
*
oldTagName
,
char
*
newTagName
);
int32_t
mgmtAddSuperTableColumn
(
SSuperTableObj
*
pTable
,
S
CM
Schema
schema
[],
int32_t
ncols
);
int32_t
mgmtAddSuperTableColumn
(
SSuperTableObj
*
pTable
,
SSchema
schema
[],
int32_t
ncols
);
int32_t
mgmtDropSuperTableColumnByName
(
SSuperTableObj
*
pTable
,
char
*
colName
);
int32_t
mgmtGetTagsLength
(
SSuperTableObj
*
pSuperTable
,
int32_t
col
);
...
...
src/mnode/inc/mgmtTable.h
浏览文件 @
5b969523
...
...
@@ -30,7 +30,7 @@ STableInfo* mgmtGetTable(char *tableId);
STableInfo
*
mgmtGetTableByPos
(
uint32_t
dnodeIp
,
int32_t
vnode
,
int32_t
sid
);
int32_t
mgmtRetrieveMetricMeta
(
void
*
pConn
,
char
**
pStart
,
SSuperTableMetaMsg
*
pInfo
);
int32_t
mgmtCreateTable
(
SDbObj
*
pDb
,
SC
MC
reateTableMsg
*
pCreate
);
int32_t
mgmtCreateTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
);
int32_t
mgmtDropTable
(
SDbObj
*
pDb
,
char
*
meterId
,
int32_t
ignore
);
int32_t
mgmtAlterTable
(
SDbObj
*
pDb
,
SAlterTableMsg
*
pAlter
);
int32_t
mgmtGetTableMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
...
...
src/mnode/src/mgmtAcct.c
浏览文件 @
5b969523
...
...
@@ -133,11 +133,11 @@ static int32_t mgmtCheckDbLimitImp(SAcctObj *pAcct) {
int32_t
(
*
mgmtCheckDbLimit
)(
SAcctObj
*
pAcct
)
=
mgmtCheckDbLimitImp
;
static
int32_t
mgmtCheckTableLimitImp
(
SAcctObj
*
pAcct
,
SC
MC
reateTableMsg
*
pCreate
)
{
static
int32_t
mgmtCheckTableLimitImp
(
SAcctObj
*
pAcct
,
SCreateTableMsg
*
pCreate
)
{
return
0
;
}
int32_t
(
*
mgmtCheckTableLimit
)(
SAcctObj
*
pAcct
,
SC
MC
reateTableMsg
*
pCreate
)
=
mgmtCheckTableLimitImp
;
int32_t
(
*
mgmtCheckTableLimit
)(
SAcctObj
*
pAcct
,
SCreateTableMsg
*
pCreate
)
=
mgmtCheckTableLimitImp
;
static
void
mgmtCleanUpAcctsImp
()
{
}
...
...
src/mnode/src/mgmtChildTable.c
浏览文件 @
5b969523
...
...
@@ -233,7 +233,7 @@ void mgmtCleanUpChildTables() {
}
int8_t
*
mgmtBuildCreateChildTableMsg
(
SChildTableObj
*
pTable
,
SVgObj
*
pVgroup
)
{
// SC
MCreateTableMsg *pCreateTable = (SCM
CreateTableMsg *) pMsg;
// SC
reateTableMsg *pCreateTable = (S
CreateTableMsg *) pMsg;
// memcpy(pCreateTable->tableId, pTable->tableId, TSDB_TABLE_ID_LEN);
// memcpy(pCreateTable->superTableId, pTable->superTable->tableId, TSDB_TABLE_ID_LEN);
// pCreateTable->vnode = htonl(vnode);
...
...
@@ -244,7 +244,7 @@ int8_t *mgmtBuildCreateChildTableMsg(SChildTableObj *pTable, SVgObj *pVgroup) {
// pCreateTable->numOfColumns = htons(pTable->superTable->numOfColumns);
// pCreateTable->numOfTags = htons(pTable->superTable->numOfTags);
//
// S
CM
Schema *pSchema = pTable->superTable->schema;
// SSchema *pSchema = pTable->superTable->schema;
// int32_t totalCols = pCreateTable->numOfColumns + pCreateTable->numOfTags;
//
// for (int32_t col = 0; col < totalCols; ++col) {
...
...
@@ -263,7 +263,7 @@ int8_t *mgmtBuildCreateChildTableMsg(SChildTableObj *pTable, SVgObj *pVgroup) {
return
NULL
;
}
int32_t
mgmtCreateChildTable
(
SDbObj
*
pDb
,
SC
MC
reateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
)
{
int32_t
mgmtCreateChildTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
)
{
int32_t
numOfTables
=
sdbGetNumOfRows
(
tsChildTableSdb
);
if
(
numOfTables
>=
tsMaxTables
)
{
mError
(
"table:%s, numOfTables:%d exceed maxTables:%d"
,
pCreate
->
tableId
,
numOfTables
,
tsMaxTables
);
...
...
@@ -291,7 +291,7 @@ int32_t mgmtCreateChildTable(SDbObj *pDb, SCMCreateTableMsg *pCreate, SVgObj *pV
((
uint64_t
)
sdbGetVersion
()
&
((
1ul
<<
16
)
-
1ul
));
int32_t
size
=
mgmtGetTagsLength
(
pSuperTable
,
INT_MAX
)
+
(
uint32_t
)
TSDB_TABLE_ID_LEN
;
S
CMSchema
*
schema
=
(
SCM
Schema
*
)
calloc
(
1
,
size
);
S
Schema
*
schema
=
(
S
Schema
*
)
calloc
(
1
,
size
);
if
(
schema
==
NULL
)
{
free
(
pTable
);
mError
(
"table:%s, corresponding super table schema is null"
,
pCreate
->
tableId
);
...
...
@@ -355,7 +355,7 @@ int32_t mgmtModifyChildTableTagValueByName(SChildTableObj *pTable, char *tagName
// return TSDB_CODE_SUCCESS;
// int32_t rowSize = 0;
// S
CMSchema *schema = (SCMSchema *)(pSuperTable->schema + (pSuperTable->numOfColumns + col) * sizeof(SCM
Schema));
// S
Schema *schema = (SSchema *)(pSuperTable->schema + (pSuperTable->numOfColumns + col) * sizeof(S
Schema));
//
// if (col == 0) {
// pTable->isDirty = 1;
...
...
src/mnode/src/mgmtConn.c
浏览文件 @
5b969523
...
...
@@ -71,7 +71,7 @@ int mgmtGetConnsMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
int
cols
=
0
;
pShow
->
bytes
[
cols
]
=
TSDB_METER_NAME_LEN
;
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"user"
);
...
...
src/mnode/src/mgmtDb.c
浏览文件 @
5b969523
...
...
@@ -116,7 +116,7 @@ SDbObj *mgmtGetDbByTableId(char *meterId) {
return
(
SDbObj
*
)
sdbGetRow
(
tsDbSdb
,
db
);
}
int32_t
mgmtCheckDBParams
(
SC
MC
reateDbMsg
*
pCreate
)
{
int32_t
mgmtCheckDBParams
(
SCreateDbMsg
*
pCreate
)
{
if
(
pCreate
->
commitLog
<
0
||
pCreate
->
commitLog
>
1
)
{
mError
(
"invalid db option commitLog: %d, only 0 or 1 allowed"
,
pCreate
->
commitLog
);
return
TSDB_CODE_INVALID_OPTION
;
...
...
@@ -189,7 +189,7 @@ int32_t mgmtCheckDBParams(SCMCreateDbMsg *pCreate) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
mgmtCheckDbParams
(
SC
MC
reateDbMsg
*
pCreate
)
{
int32_t
mgmtCheckDbParams
(
SCreateDbMsg
*
pCreate
)
{
// assign default parameters
if
(
pCreate
->
maxSessions
<
0
)
pCreate
->
maxSessions
=
tsSessionsPerVnode
;
//
if
(
pCreate
->
cacheBlockSize
<
0
)
pCreate
->
cacheBlockSize
=
tsCacheBlockSize
;
//
...
...
@@ -234,7 +234,7 @@ int32_t mgmtCheckDbParams(SCMCreateDbMsg *pCreate) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
mgmtCreateDb
(
SAcctObj
*
pAcct
,
SC
MC
reateDbMsg
*
pCreate
)
{
int32_t
mgmtCreateDb
(
SAcctObj
*
pAcct
,
SCreateDbMsg
*
pCreate
)
{
int32_t
code
=
mgmtCheckDbLimit
(
pAcct
);
if
(
code
!=
0
)
{
return
code
;
...
...
@@ -408,7 +408,7 @@ void mgmtMonitorDbDrop(void *unused, void *unusedt) {
}
}
int32_t
mgmtAlterDb
(
SAcctObj
*
pAcct
,
S
CM
AlterDbMsg
*
pAlter
)
{
int32_t
mgmtAlterDb
(
SAcctObj
*
pAcct
,
SAlterDbMsg
*
pAlter
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
SDbObj
*
pDb
=
(
SDbObj
*
)
sdbGetRow
(
tsDbSdb
,
pAlter
->
db
);
...
...
@@ -530,7 +530,7 @@ void mgmtCleanUpDbs() {
int32_t
mgmtGetDbMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
cols
=
0
;
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
if
(
pUser
==
NULL
)
return
0
;
...
...
src/mnode/src/mgmtDnode.c
浏览文件 @
5b969523
...
...
@@ -105,7 +105,7 @@ int32_t mgmtGetDnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
if
(
strcmp
(
pUser
->
user
,
"root"
)
!=
0
)
return
TSDB_CODE_NO_RIGHTS
;
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
pShow
->
bytes
[
cols
]
=
16
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
...
...
@@ -220,7 +220,7 @@ int32_t mgmtGetModuleMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
if
(
strcmp
(
pUser
->
user
,
"root"
)
!=
0
)
return
TSDB_CODE_NO_RIGHTS
;
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
pShow
->
bytes
[
cols
]
=
16
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
...
...
@@ -313,7 +313,7 @@ int32_t mgmtGetConfigMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
if
(
strcmp
(
pUser
->
user
,
"root"
)
!=
0
)
return
TSDB_CODE_NO_RIGHTS
;
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
pShow
->
bytes
[
cols
]
=
TSDB_CFG_OPTION_LEN
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
...
...
@@ -399,7 +399,7 @@ int32_t mgmtGetVnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
if
(
pUser
==
NULL
)
return
0
;
if
(
strcmp
(
pUser
->
user
,
"root"
)
!=
0
)
return
TSDB_CODE_NO_RIGHTS
;
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
...
...
src/mnode/src/mgmtDnodeInt.c
浏览文件 @
5b969523
...
...
@@ -499,7 +499,7 @@ int mgmtSendCfgDnodeMsg(char *cont) {
#endif
SDnodeObj
*
pDnode
;
SC
MCfgDnodeMsg
*
pCfg
=
(
SCM
CfgDnodeMsg
*
)
cont
;
SC
fgDnodeMsg
*
pCfg
=
(
S
CfgDnodeMsg
*
)
cont
;
uint32_t
ip
;
ip
=
inet_addr
(
pCfg
->
ip
);
...
...
@@ -520,8 +520,8 @@ int mgmtSendCfgDnodeMsg(char *cont) {
if
(
pStart
==
NULL
)
return
TSDB_CODE_NODE_OFFLINE
;
pMsg
=
pStart
;
memcpy
(
pMsg
,
cont
,
sizeof
(
SC
MC
fgDnodeMsg
));
pMsg
+=
sizeof
(
SC
MC
fgDnodeMsg
);
memcpy
(
pMsg
,
cont
,
sizeof
(
SCfgDnodeMsg
));
pMsg
+=
sizeof
(
SCfgDnodeMsg
);
msgLen
=
pMsg
-
pStart
;
mgmtSendMsgToDnode
(
pDnode
,
pStart
,
msgLen
);
...
...
src/mnode/src/mgmtNormalTable.c
浏览文件 @
5b969523
...
...
@@ -161,7 +161,7 @@ void *mgmtNormalTableActionEncode(void *row, char *str, int32_t size, int32_t *s
assert
(
row
!=
NULL
&&
str
!=
NULL
);
int32_t
tsize
=
pTable
->
updateEnd
-
(
int8_t
*
)
pTable
;
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
S
CM
Schema
);
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
SSchema
);
if
(
size
<
tsize
+
schemaSize
+
1
)
{
*
ssize
=
-
1
;
return
NULL
;
...
...
@@ -190,8 +190,8 @@ void *mgmtNormalTableActionDecode(void *row, char *str, int32_t size, int32_t *s
}
memcpy
(
pTable
,
str
,
tsize
);
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
S
CM
Schema
);
pTable
->
schema
=
(
S
CM
Schema
*
)
malloc
(
schemaSize
);
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
SSchema
);
pTable
->
schema
=
(
SSchema
*
)
malloc
(
schemaSize
);
if
(
pTable
->
schema
==
NULL
)
{
mgmtDestroyNormalTable
(
pTable
);
return
NULL
;
...
...
@@ -215,7 +215,7 @@ int32_t mgmtInitNormalTables() {
mgmtNormalTableActionInit
();
tsNormalTableSdb
=
sdbOpenTable
(
tsMaxTables
,
sizeof
(
SNormalTableObj
)
+
sizeof
(
S
CM
Schema
)
*
TSDB_MAX_COLUMNS
,
tsNormalTableSdb
=
sdbOpenTable
(
tsMaxTables
,
sizeof
(
SNormalTableObj
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
,
"ntables"
,
SDB_KEYTYPE_STRING
,
tsMgmtDirectory
,
mgmtNormalTableAction
);
if
(
tsNormalTableSdb
==
NULL
)
{
mError
(
"failed to init normal table data"
);
...
...
@@ -259,7 +259,7 @@ int8_t *mgmtBuildCreateNormalTableMsg(SNormalTableObj *pTable) {
// pCreateTable->sversion = htobe32(pTable->sversion);
// pCreateTable->numOfColumns = htobe16(pTable->numOfColumns);
//
// S
CM
Schema *pSchema = pTable->schema;
// SSchema *pSchema = pTable->schema;
// int32_t totalCols = pCreateTable->numOfColumns;
// for (int32_t col = 0; col < totalCols; ++col) {
...
...
@@ -276,7 +276,7 @@ int8_t *mgmtBuildCreateNormalTableMsg(SNormalTableObj *pTable) {
return
NULL
;
}
int32_t
mgmtCreateNormalTable
(
SDbObj
*
pDb
,
SC
MC
reateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
)
{
int32_t
mgmtCreateNormalTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
)
{
int32_t
numOfTables
=
sdbGetNumOfRows
(
tsChildTableSdb
);
if
(
numOfTables
>=
TSDB_MAX_TABLES
)
{
mError
(
"normal table:%s, numOfTables:%d exceed maxTables:%d"
,
pCreate
->
tableId
,
numOfTables
,
TSDB_MAX_TABLES
);
...
...
@@ -297,18 +297,18 @@ int32_t mgmtCreateNormalTable(SDbObj *pDb, SCMCreateTableMsg *pCreate, SVgObj *p
pTable
->
numOfColumns
=
pCreate
->
numOfColumns
;
int32_t
numOfCols
=
pCreate
->
numOfColumns
+
pCreate
->
numOfTags
;
int32_t
schemaSize
=
numOfCols
*
sizeof
(
S
CM
Schema
);
pTable
->
schema
=
(
S
CM
Schema
*
)
calloc
(
1
,
schemaSize
);
int32_t
schemaSize
=
numOfCols
*
sizeof
(
SSchema
);
pTable
->
schema
=
(
SSchema
*
)
calloc
(
1
,
schemaSize
);
if
(
pTable
->
schema
==
NULL
)
{
free
(
pTable
);
mError
(
"table:%s, no schema input"
,
pCreate
->
tableId
);
return
TSDB_CODE_INVALID_TABLE
;
}
memcpy
(
pTable
->
schema
,
pCreate
->
schema
,
numOfCols
*
sizeof
(
S
CM
Schema
));
memcpy
(
pTable
->
schema
,
pCreate
->
schema
,
numOfCols
*
sizeof
(
SSchema
));
pTable
->
nextColId
=
0
;
for
(
int32_t
col
=
0
;
col
<
pCreate
->
numOfColumns
;
col
++
)
{
S
CMSchema
*
tschema
=
(
SCM
Schema
*
)
pTable
->
schema
;
S
Schema
*
tschema
=
(
S
Schema
*
)
pTable
->
schema
;
tschema
[
col
].
colId
=
pTable
->
nextColId
++
;
}
...
...
@@ -362,7 +362,7 @@ SNormalTableObj* mgmtGetNormalTable(char *tableId) {
}
static
int32_t
mgmtFindNormalTableColumnIndex
(
SNormalTableObj
*
pTable
,
char
*
colName
)
{
S
CMSchema
*
schema
=
(
SCM
Schema
*
)
pTable
->
schema
;
S
Schema
*
schema
=
(
S
Schema
*
)
pTable
->
schema
;
for
(
int32_t
i
=
0
;
i
<
pTable
->
numOfColumns
;
i
++
)
{
if
(
strcasecmp
(
schema
[
i
].
name
,
colName
)
==
0
)
{
return
i
;
...
...
@@ -372,7 +372,7 @@ static int32_t mgmtFindNormalTableColumnIndex(SNormalTableObj *pTable, char *col
return
-
1
;
}
int32_t
mgmtAddNormalTableColumn
(
SNormalTableObj
*
pTable
,
S
CM
Schema
schema
[],
int32_t
ncols
)
{
int32_t
mgmtAddNormalTableColumn
(
SNormalTableObj
*
pTable
,
SSchema
schema
[],
int32_t
ncols
)
{
if
(
ncols
<=
0
)
{
return
TSDB_CODE_APP_ERROR
;
}
...
...
@@ -395,12 +395,12 @@ int32_t mgmtAddNormalTableColumn(SNormalTableObj *pTable, SCMSchema schema[], in
return
TSDB_CODE_APP_ERROR
;
}
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
S
CM
Schema
);
pTable
->
schema
=
realloc
(
pTable
->
schema
,
schemaSize
+
sizeof
(
S
CM
Schema
)
*
ncols
);
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
SSchema
);
pTable
->
schema
=
realloc
(
pTable
->
schema
,
schemaSize
+
sizeof
(
SSchema
)
*
ncols
);
memcpy
(
pTable
->
schema
+
schemaSize
,
schema
,
sizeof
(
S
CM
Schema
)
*
ncols
);
memcpy
(
pTable
->
schema
+
schemaSize
,
schema
,
sizeof
(
SSchema
)
*
ncols
);
S
CMSchema
*
tschema
=
(
SCMSchema
*
)
(
pTable
->
schema
+
sizeof
(
SCM
Schema
)
*
pTable
->
numOfColumns
);
S
Schema
*
tschema
=
(
SSchema
*
)
(
pTable
->
schema
+
sizeof
(
S
Schema
)
*
pTable
->
numOfColumns
);
for
(
int32_t
i
=
0
;
i
<
ncols
;
i
++
)
{
tschema
[
i
].
colId
=
pTable
->
nextColId
++
;
}
...
...
@@ -431,8 +431,8 @@ int32_t mgmtDropNormalTableColumnByName(SNormalTableObj *pTable, char *colName)
return
TSDB_CODE_APP_ERROR
;
}
memmove
(
pTable
->
schema
+
sizeof
(
S
CMSchema
)
*
col
,
pTable
->
schema
+
sizeof
(
SCM
Schema
)
*
(
col
+
1
),
sizeof
(
S
CM
Schema
)
*
(
pTable
->
numOfColumns
-
col
-
1
));
memmove
(
pTable
->
schema
+
sizeof
(
S
Schema
)
*
col
,
pTable
->
schema
+
sizeof
(
S
Schema
)
*
(
col
+
1
),
sizeof
(
SSchema
)
*
(
pTable
->
numOfColumns
-
col
-
1
));
pTable
->
numOfColumns
--
;
pTable
->
sversion
++
;
...
...
src/mnode/src/mgmtProfile.c
浏览文件 @
5b969523
...
...
@@ -32,7 +32,7 @@ typedef struct {
int32_t
numOfQueries
;
SCDesc
*
connInfo
;
SCDesc
**
cdesc
;
S
CM
QueryDesc
qdesc
[];
SQueryDesc
qdesc
[];
}
SQueryShow
;
typedef
struct
{
...
...
@@ -40,10 +40,10 @@ typedef struct {
int32_t
numOfStreams
;
SCDesc
*
connInfo
;
SCDesc
**
cdesc
;
S
CM
StreamDesc
sdesc
[];
SStreamDesc
sdesc
[];
}
SStreamShow
;
int32_t
mgmtSaveQueryStreamList
(
S
CM
HeartBeatMsg
*
pHBMsg
)
{
int32_t
mgmtSaveQueryStreamList
(
SHeartBeatMsg
*
pHBMsg
)
{
// SAcctObj *pAcct = pConn->pAcct;
//
// if (contLen <= 0 || pAcct == NULL) {
...
...
@@ -60,7 +60,7 @@ int32_t mgmtSaveQueryStreamList(SCMHeartBeatMsg *pHBMsg) {
// pConn->pQList = realloc(pConn->pQList, contLen);
// memcpy(pConn->pQList, cont, contLen);
//
// pConn->pSList = (S
CMStreamList *)(((char *)pConn->pQList) + pConn->pQList->numOfQueries * sizeof(SCMQueryDesc) + sizeof(SCM
QqueryList));
// pConn->pSList = (S
StreamList *)(((char *)pConn->pQList) + pConn->pQList->numOfQueries * sizeof(SQueryDesc) + sizeof(S
QqueryList));
//
// pAcct->acctInfo.numOfQueries += pConn->pQList->numOfQueries;
// pAcct->acctInfo.numOfStreams += pConn->pSList->numOfStreams;
...
...
@@ -76,7 +76,7 @@ int32_t mgmtGetQueries(SShowObj *pShow, void *pConn) {
//
// pthread_mutex_lock(&pAcct->mutex);
//
// pQueryShow = malloc(sizeof(S
CM
QueryDesc) * pAcct->acctInfo.numOfQueries + sizeof(SQueryShow));
// pQueryShow = malloc(sizeof(SQueryDesc) * pAcct->acctInfo.numOfQueries + sizeof(SQueryShow));
// pQueryShow->numOfQueries = 0;
// pQueryShow->index = 0;
// pQueryShow->connInfo = NULL;
...
...
@@ -87,7 +87,7 @@ int32_t mgmtGetQueries(SShowObj *pShow, void *pConn) {
// pQueryShow->cdesc = (SCDesc **)malloc(pAcct->acctInfo.numOfQueries * sizeof(SCDesc *));
//
// pConn = pAcct->pConn;
// S
CM
QueryDesc * pQdesc = pQueryShow->qdesc;
// SQueryDesc * pQdesc = pQueryShow->qdesc;
// SCDesc * pCDesc = pQueryShow->connInfo;
// SCDesc **ppCDesc = pQueryShow->cdesc;
//
...
...
@@ -97,7 +97,7 @@ int32_t mgmtGetQueries(SShowObj *pShow, void *pConn) {
// pCDesc->port = pConn->port;
// strcpy(pCDesc->user, pConn->pUser->user);
//
// memcpy(pQdesc, pConn->pQList->qdesc, sizeof(S
CM
QueryDesc) * pConn->pQList->numOfQueries);
// memcpy(pQdesc, pConn->pQList->qdesc, sizeof(SQueryDesc) * pConn->pQList->numOfQueries);
// pQdesc += pConn->pQList->numOfQueries;
// pQueryShow->numOfQueries += pConn->pQList->numOfQueries;
// for (int32_t i = 0; i < pConn->pQList->numOfQueries; ++i, ++ppCDesc) *ppCDesc = pCDesc;
...
...
@@ -120,7 +120,7 @@ int32_t mgmtGetQueries(SShowObj *pShow, void *pConn) {
int32_t
mgmtGetQueryMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
cols
=
0
;
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
pShow
->
bytes
[
cols
]
=
TSDB_USER_LEN
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
...
...
@@ -193,7 +193,7 @@ int32_t mgmtKillQuery(char *qidstr, void *pConn) {
// while (pConn) {
// if (pConn->ip == ip && pConn->port == port && pConn->pQList) {
// int32_t i;
// S
CM
QueryDesc *pQDesc = pConn->pQList->qdesc;
// SQueryDesc *pQDesc = pConn->pQList->qdesc;
// for (i = 0; i < pConn->pQList->numOfQueries; ++i, ++pQDesc) {
// if (pQDesc->queryId == queryId) break;
// }
...
...
@@ -229,7 +229,7 @@ int32_t mgmtRetrieveQueries(SShowObj *pShow, char *data, int32_t rows, void *pCo
if
(
rows
>
pQueryShow
->
numOfQueries
-
pQueryShow
->
index
)
rows
=
pQueryShow
->
numOfQueries
-
pQueryShow
->
index
;
while
(
numOfRows
<
rows
)
{
S
CM
QueryDesc
*
pNode
=
pQueryShow
->
qdesc
+
pQueryShow
->
index
;
SQueryDesc
*
pNode
=
pQueryShow
->
qdesc
+
pQueryShow
->
index
;
SCDesc
*
pCDesc
=
pQueryShow
->
cdesc
[
pQueryShow
->
index
];
cols
=
0
;
...
...
@@ -275,7 +275,7 @@ int32_t mgmtGetStreams(SShowObj *pShow, void *pConn) {
//
// pthread_mutex_lock(&pAcct->mutex);
//
// pStreamShow = malloc(sizeof(S
CM
StreamDesc) * pAcct->acctInfo.numOfStreams + sizeof(SQueryShow));
// pStreamShow = malloc(sizeof(SStreamDesc) * pAcct->acctInfo.numOfStreams + sizeof(SQueryShow));
// pStreamShow->numOfStreams = 0;
// pStreamShow->index = 0;
// pStreamShow->connInfo = NULL;
...
...
@@ -286,7 +286,7 @@ int32_t mgmtGetStreams(SShowObj *pShow, void *pConn) {
// pStreamShow->cdesc = (SCDesc **)malloc(pAcct->acctInfo.numOfStreams * sizeof(SCDesc *));
//
// pConn = pAcct->pConn;
// S
CM
StreamDesc * pSdesc = pStreamShow->sdesc;
// SStreamDesc * pSdesc = pStreamShow->sdesc;
// SCDesc * pCDesc = pStreamShow->connInfo;
// SCDesc **ppCDesc = pStreamShow->cdesc;
//
...
...
@@ -296,7 +296,7 @@ int32_t mgmtGetStreams(SShowObj *pShow, void *pConn) {
// pCDesc->port = pConn->port;
// strcpy(pCDesc->user, pConn->pUser->user);
//
// memcpy(pSdesc, pConn->pSList->sdesc, sizeof(S
CM
StreamDesc) * pConn->pSList->numOfStreams);
// memcpy(pSdesc, pConn->pSList->sdesc, sizeof(SStreamDesc) * pConn->pSList->numOfStreams);
// pSdesc += pConn->pSList->numOfStreams;
// pStreamShow->numOfStreams += pConn->pSList->numOfStreams;
// for (int32_t i = 0; i < pConn->pSList->numOfStreams; ++i, ++ppCDesc) *ppCDesc = pCDesc;
...
...
@@ -318,7 +318,7 @@ int32_t mgmtGetStreams(SShowObj *pShow, void *pConn) {
int32_t
mgmtGetStreamMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
cols
=
0
;
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
pShow
->
bytes
[
cols
]
=
TSDB_USER_LEN
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
...
...
@@ -386,7 +386,7 @@ int32_t mgmtRetrieveStreams(SShowObj *pShow, char *data, int32_t rows, void *pCo
if
(
rows
>
pStreamShow
->
numOfStreams
-
pStreamShow
->
index
)
rows
=
pStreamShow
->
numOfStreams
-
pStreamShow
->
index
;
while
(
numOfRows
<
rows
)
{
S
CM
StreamDesc
*
pNode
=
pStreamShow
->
sdesc
+
pStreamShow
->
index
;
SStreamDesc
*
pNode
=
pStreamShow
->
sdesc
+
pStreamShow
->
index
;
SCDesc
*
pCDesc
=
pStreamShow
->
cdesc
[
pStreamShow
->
index
];
cols
=
0
;
...
...
@@ -461,7 +461,7 @@ int32_t mgmtKillStream(char *qidstr, void *pConn) {
// while (pConn) {
// if (pConn->ip == ip && pConn->port == port && pConn->pSList) {
// int32_t i;
// S
CM
StreamDesc *pSDesc = pConn->pSList->sdesc;
// SStreamDesc *pSDesc = pConn->pSList->sdesc;
// for (i = 0; i < pConn->pSList->numOfStreams; ++i, ++pSDesc) {
// if (pSDesc->streamId == streamId) break;
// }
...
...
src/mnode/src/mgmtShell.c
浏览文件 @
5b969523
...
...
@@ -35,7 +35,7 @@
#include "mgmtUser.h"
#include "mgmtVgroup.h"
#define MAX_LEN_OF_METER_META (sizeof(SMultiMeterMeta) + sizeof(S
CMSchema) * TSDB_MAX_COLUMNS + sizeof(SCM
Schema) * TSDB_MAX_TAGS + TSDB_MAX_TAGS_LEN)
#define MAX_LEN_OF_METER_META (sizeof(SMultiMeterMeta) + sizeof(S
Schema) * TSDB_MAX_COLUMNS + sizeof(S
Schema) * TSDB_MAX_TAGS + TSDB_MAX_TAGS_LEN)
typedef
int32_t
(
*
GetMateFp
)(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
typedef
int32_t
(
*
RetrieveMetaFp
)(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
...
...
@@ -113,8 +113,8 @@ void mgmtCleanUpShell() {
}
}
static
void
mgmtSetSchemaFromMeters
(
S
CM
Schema
*
pSchema
,
STabObj
*
pMeterObj
,
uint32_t
numOfCols
)
{
S
CMSchema
*
pMeterSchema
=
(
SCM
Schema
*
)(
pMeterObj
->
schema
);
static
void
mgmtSetSchemaFromMeters
(
SSchema
*
pSchema
,
STabObj
*
pMeterObj
,
uint32_t
numOfCols
)
{
S
Schema
*
pMeterSchema
=
(
S
Schema
*
)(
pMeterObj
->
schema
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
strcpy
(
pSchema
->
name
,
pMeterSchema
[
i
].
name
);
pSchema
->
type
=
pMeterSchema
[
i
].
type
;
...
...
@@ -125,7 +125,7 @@ static void mgmtSetSchemaFromMeters(SCMSchema *pSchema, STabObj *pMeterObj, uint
}
static
uint32_t
mgmtSetMeterTagValue
(
char
*
pTags
,
STabObj
*
pMetric
,
STabObj
*
pMeterObj
)
{
S
CMSchema
*
pTagSchema
=
(
SCMSchema
*
)(
pMetric
->
schema
+
pMetric
->
numOfColumns
*
sizeof
(
SCM
Schema
));
S
Schema
*
pTagSchema
=
(
SSchema
*
)(
pMetric
->
schema
+
pMetric
->
numOfColumns
*
sizeof
(
S
Schema
));
char
*
tagVal
=
pMeterObj
->
pTagData
+
TSDB_TABLE_ID_LEN
;
// tag start position
...
...
@@ -143,14 +143,14 @@ int32_t mgmtProcessMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
// STabObj * pMeterObj = NULL;
// SVgObj * pVgroup = NULL;
// SMeterMeta * pMeta = NULL;
// S
CM
Schema * pSchema = NULL;
// SSchema * pSchema = NULL;
// STaosRsp * pRsp = NULL;
// char * pStart = NULL;
//
// pInfo->createFlag = htons(pInfo->createFlag);
//
// int32_t size = sizeof(STaosHeader) + sizeof(STaosRsp) + sizeof(SMeterMeta) + sizeof(S
CM
Schema) * TSDB_MAX_COLUMNS +
// sizeof(S
CM
Schema) * TSDB_MAX_TAGS + TSDB_MAX_TAGS_LEN + TSDB_EXTRA_PAYLOAD_SIZE;
// int32_t size = sizeof(STaosHeader) + sizeof(STaosRsp) + sizeof(SMeterMeta) + sizeof(SSchema) * TSDB_MAX_COLUMNS +
// sizeof(SSchema) * TSDB_MAX_TAGS + TSDB_MAX_TAGS_LEN + TSDB_EXTRA_PAYLOAD_SIZE;
//
// SDbObj *pDb = NULL;
// if (pConn->pDb != NULL) pDb = mgmtGetDb(pConn->pDb->name);
...
...
@@ -178,7 +178,7 @@ int32_t mgmtProcessMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
// return 0;
// }
//
// SC
MCreateTableMsg *pCreateMsg = calloc(1, sizeof(SCM
CreateTableMsg) + sizeof(STagData));
// SC
reateTableMsg *pCreateMsg = calloc(1, sizeof(S
CreateTableMsg) + sizeof(STagData));
// if (pCreateMsg == NULL) {
// taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_TABLE_META_RSP, TSDB_CODE_SERV_OUT_OF_MEMORY);
// return 0;
...
...
@@ -247,7 +247,7 @@ int32_t mgmtProcessMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
// pMeta->tableType = pMeterObj->tableType;
//
// pMsg += sizeof(SMeterMeta);
// pSchema = (S
CM
Schema *)pMsg; // schema locates at the end of SMeterMeta struct
// pSchema = (SSchema *)pMsg; // schema locates at the end of SMeterMeta struct
//
// if (mgmtTableCreateFromSuperTable(pMeterObj)) {
// assert(pMeterObj->numOfTags == 0);
...
...
@@ -257,7 +257,7 @@ int32_t mgmtProcessMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
//
// pMeta->numOfTags = pMetric->numOfTags; // update the numOfTags info
// mgmtSetSchemaFromMeters(pSchema, pMetric, numOfTotalCols);
// pMsg += numOfTotalCols * sizeof(S
CM
Schema);
// pMsg += numOfTotalCols * sizeof(SSchema);
//
// // for meters created from metric, we need the metric tag schema to parse the tag data
// int32_t tagsLen = mgmtSetMeterTagValue(pMsg, pMetric, pMeterObj);
...
...
@@ -269,7 +269,7 @@ int32_t mgmtProcessMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
// */
// uint32_t numOfTotalCols = (uint32_t)pMeterObj->numOfTags + pMeterObj->numOfColumns;
// mgmtSetSchemaFromMeters(pSchema, pMeterObj, numOfTotalCols);
// pMsg += numOfTotalCols * sizeof(S
CM
Schema);
// pMsg += numOfTotalCols * sizeof(SSchema);
// }
//
// if (mgmtIsNormalTable(pMeterObj)) {
...
...
@@ -301,10 +301,10 @@ int32_t mgmtProcessMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
/**
* multi meter meta rsp pkg format:
* | STaosRsp | ieType | SMultiMeterInfoMsg | SMeterMeta0 | S
CMSchema0 | SMeterMeta1 | SCMSchema1 | SMeterMeta2 | SCM
Schema2
* | STaosRsp | ieType | SMultiMeterInfoMsg | SMeterMeta0 | S
Schema0 | SMeterMeta1 | SSchema1 | SMeterMeta2 | S
Schema2
* 1B 1B 4B
*
* | STaosHeader | STaosRsp | ieType | SMultiMeterInfoMsg | SMeterMeta0 | S
CMSchema0 | SMeterMeta1 | SCM
Schema1 | ......................|
* | STaosHeader | STaosRsp | ieType | SMultiMeterInfoMsg | SMeterMeta0 | S
Schema0 | SMeterMeta1 | S
Schema1 | ......................|
* ^ ^ ^
* |<--------------------------------------size-----------------------------------------------|---------------------->|
* | | |
...
...
@@ -315,7 +315,7 @@ int32_t mgmtProcessMultiMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle
// STabObj * pMeterObj = NULL;
// SVgObj * pVgroup = NULL;
// SMultiMeterMeta * pMeta = NULL;
// S
CM
Schema * pSchema = NULL;
// SSchema * pSchema = NULL;
// STaosRsp * pRsp = NULL;
// char * pStart = NULL;
//
...
...
@@ -388,7 +388,7 @@ int32_t mgmtProcessMultiMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle
// pMeta->meta.tableType = pMeterObj->tableType;
//
// pCurMeter += sizeof(SMultiMeterMeta);
// pSchema = (S
CM
Schema *)pCurMeter; // schema locates at the end of SMeterMeta struct
// pSchema = (SSchema *)pCurMeter; // schema locates at the end of SMeterMeta struct
//
// if (mgmtTableCreateFromSuperTable(pMeterObj)) {
// assert(pMeterObj->numOfTags == 0);
...
...
@@ -398,7 +398,7 @@ int32_t mgmtProcessMultiMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle
//
// pMeta->meta.numOfTags = pMetric->numOfTags; // update the numOfTags info
// mgmtSetSchemaFromMeters(pSchema, pMetric, numOfTotalCols);
// pCurMeter += numOfTotalCols * sizeof(S
CM
Schema);
// pCurMeter += numOfTotalCols * sizeof(SSchema);
//
// // for meters created from metric, we need the metric tag schema to parse the tag data
// int32_t tagsLen = mgmtSetMeterTagValue(pCurMeter, pMetric, pMeterObj);
...
...
@@ -410,7 +410,7 @@ int32_t mgmtProcessMultiMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle
// */
// uint32_t numOfTotalCols = (uint32_t)pMeterObj->numOfTags + pMeterObj->numOfColumns;
// mgmtSetSchemaFromMeters(pSchema, pMeterObj, numOfTotalCols);
// pCurMeter += numOfTotalCols * sizeof(S
CM
Schema);
// pCurMeter += numOfTotalCols * sizeof(SSchema);
// }
//
// if (mgmtIsNormalTable(pMeterObj)) {
...
...
@@ -527,7 +527,7 @@ int32_t mgmtProcessCreateDbMsg(void *pCont, int32_t contLen, void *ahandle) {
return
TSDB_CODE_INVALID_USER
;
}
SC
MCreateDbMsg
*
pCreate
=
(
SCM
CreateDbMsg
*
)
pCont
;
SC
reateDbMsg
*
pCreate
=
(
S
CreateDbMsg
*
)
pCont
;
pCreate
->
maxSessions
=
htonl
(
pCreate
->
maxSessions
);
pCreate
->
cacheBlockSize
=
htonl
(
pCreate
->
cacheBlockSize
);
...
...
@@ -567,7 +567,7 @@ int32_t mgmtProcessAlterDbMsg(void *pCont, int32_t contLen, void *ahandle) {
return
TSDB_CODE_INVALID_USER
;
}
S
CMAlterDbMsg
*
pAlter
=
(
SCM
AlterDbMsg
*
)
pCont
;
S
AlterDbMsg
*
pAlter
=
(
S
AlterDbMsg
*
)
pCont
;
pAlter
->
daysPerFile
=
htonl
(
pAlter
->
daysPerFile
);
pAlter
->
daysToKeep
=
htonl
(
pAlter
->
daysToKeep
);
pAlter
->
maxSessions
=
htonl
(
pAlter
->
maxSessions
)
+
1
;
...
...
@@ -597,7 +597,7 @@ int32_t mgmtProcessKillQueryMsg(void *pCont, int32_t contLen, void *ahandle) {
return
TSDB_CODE_INVALID_USER
;
}
S
CMKillQueryMsg
*
pKill
=
(
SCM
KillQueryMsg
*
)
pCont
;
S
KillQueryMsg
*
pKill
=
(
S
KillQueryMsg
*
)
pCont
;
int32_t
code
;
if
(
!
pUser
->
writeAuth
)
{
...
...
@@ -621,7 +621,7 @@ int32_t mgmtProcessKillStreamMsg(void *pCont, int32_t contLen, void *ahandle) {
return
TSDB_CODE_INVALID_USER
;
}
S
CMKillStreamMsg
*
pKill
=
(
SCM
KillStreamMsg
*
)
pCont
;
S
KillStreamMsg
*
pKill
=
(
S
KillStreamMsg
*
)
pCont
;
int32_t
code
;
if
(
!
pUser
->
writeAuth
)
{
...
...
@@ -671,7 +671,7 @@ int32_t mgmtProcessCreateUserMsg(void *pCont, int32_t contLen, void *ahandle) {
int32_t
code
;
if
(
pUser
->
superAuth
)
{
SC
MC
reateUserMsg
*
pCreate
=
pCont
;
SCreateUserMsg
*
pCreate
=
pCont
;
code
=
mgmtCreateUser
(
pUser
->
pAcct
,
pCreate
->
user
,
pCreate
->
pass
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
mLPrint
(
"user:%s is created by %s"
,
pCreate
->
user
,
pUser
->
user
);
...
...
@@ -695,7 +695,7 @@ int32_t mgmtProcessAlterUserMsg(void *pCont, int32_t contLen, void *ahandle) {
return
TSDB_CODE_INVALID_USER
;
}
S
CM
AlterUserMsg
*
pAlter
=
pCont
;
SAlterUserMsg
*
pAlter
=
pCont
;
SUserObj
*
pUser
=
mgmtGetUser
(
pAlter
->
user
);
if
(
pUser
==
NULL
)
{
rpcSendResponse
(
ahandle
,
TSDB_CODE_INVALID_USER
,
NULL
,
0
);
...
...
@@ -802,7 +802,7 @@ int32_t mgmtProcessDropUserMsg(void *pCont, int32_t contLen, void *ahandle) {
return
TSDB_CODE_INVALID_USER
;
}
S
CM
DropUserMsg
*
pDrop
=
pCont
;
SDropUserMsg
*
pDrop
=
pCont
;
SUserObj
*
pUser
=
mgmtGetUser
(
pDrop
->
user
);
if
(
pUser
==
NULL
)
{
rpcSendResponse
(
ahandle
,
TSDB_CODE_INVALID_USER
,
NULL
,
0
);
...
...
@@ -858,7 +858,7 @@ int32_t mgmtProcessDropDbMsg(void *pCont, int32_t contLen, void *ahandle) {
int32_t
code
;
if
(
pUser
->
superAuth
)
{
S
CM
DropDbMsg
*
pDrop
=
pCont
;
SDropDbMsg
*
pDrop
=
pCont
;
code
=
mgmtDropDbByName
(
pUser
->
pAcct
,
pDrop
->
db
,
pDrop
->
ignoreNotExists
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
mLPrint
(
"DB:%s is dropped by %s"
,
pDrop
->
db
,
pUser
->
user
);
...
...
@@ -910,62 +910,62 @@ static void mgmtInitShowMsgFp() {
}
int32_t
mgmtProcessShowMsg
(
void
*
pCont
,
int32_t
contLen
,
void
*
ahandle
)
{
// SShowMsg * pShowMsg = (SShowMsg *)pMsg
;
// STaosRsp * pRsp;
// char * pStart
;
// int32_t code = 0
;
// SShowRspMsg *pShowRsp
;
// SShowObj * pShow = NULL
;
//
// if (pShowMsg->type == TSDB_MGMT_TABLE_DNODE || TSDB_MGMT_TABLE_GRANTS || TSDB_MGMT_TABLE_SCORES) {
// if (mgmtCheckRedirectMsg(pConn, TSDB_MSG_TYPE_SHOW_RSP) != 0
) {
// return 0;
// }
//
}
//
// int32_t size = sizeof(STaosHeader) + sizeof(STaosRsp) + sizeof(SShowRspMsg) + sizeof(SCMSchema) * TSDB_MAX_COLUMNS +
// TSDB_EXTRA_PAYLOAD_SIZE;
// pStart = taosBuildRspMsgWithSize(pConn->thandle, TSDB_MSG_TYPE_SHOW_RSP, size)
;
// if (pStart == NULL) {
// taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_SHOW_RSP, TSDB_CODE_SERV_OUT_OF_MEMORY);
// return 0
;
// }
//
// pMsg = pStart;
// pRsp = (STaosRsp *)pMsg
;
// pMsg = (char *)pRsp->more
;
//
// if (pShowMsg->type >= TSDB_MGMT_TABLE_MAX) {
// code = -1;
// } else {
// pShow = (SShowObj *)calloc(1, sizeof(SShowObj) + htons(pShowMsg->payloadLen));
// pShow->signature = pShow
;
// pShow->type = pShowMsg->type
;
// mTrace("pShow:%p is allocated", pShow)
;
//
// // set the table name query condition
// pShow->payloadLen = htons(pShowMsg->payloadLen);
// memcpy(pShow->payload, pShowMsg->payload, pShow
->payloadLen);
//
// pShowRsp = (SShowRspMsg *)pMsg;
// pShowRsp->qhandle = (uint64_t)pShow; // qhandle
;
// pConn->qhandle = pShowRsp->
qhandle;
//
// code = (*mgmtGetMetaFp[(uint8_t)pShowMsg->type])(&pShowRsp->meterMeta, pShow, pConn);
// if (code == 0) {
// pMsg += sizeof(SShowRspMsg) + sizeof(SCMSchema) * pShow->numOfColumns;
// } else {
// mError("pShow:%p, type:%d %s, failed to get Meta, code:%d", pShow, pShowMsg->type, taosMsg[(uint8_t)pShowMsg->type], code);
// free(pShow
);
// }
//
}
//
// pRsp->code = code;
// msgLen = pMsg - pStart
;
// taosSendMsgToPeer(pConn->thandle, pStart, msgLen)
;
//
// return msgLen;
return
0
;
SShowMsg
*
pShowMsg
=
(
SShowMsg
*
)
pCont
;
STaosRsp
*
pRsp
;
char
*
pStart
;
int32_t
code
=
0
;
SShowRsp
*
pShowRsp
;
SShowObj
*
pShow
=
NULL
;
if
(
pShowMsg
->
type
==
TSDB_MGMT_TABLE_DNODE
||
TSDB_MGMT_TABLE_GRANTS
||
TSDB_MGMT_TABLE_SCORES
)
{
if
(
mgmtCheckRedirectMsg
(
pConn
,
TSDB_MSG_TYPE_SHOW_RSP
)
!=
0
)
{
return
0
;
}
}
int32_t
size
=
sizeof
(
STaosHeader
)
+
sizeof
(
STaosRsp
)
+
sizeof
(
SShowRsp
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
+
TSDB_EXTRA_PAYLOAD_SIZE
;
pStart
=
taosBuildRspMsgWithSize
(
pConn
->
thandle
,
TSDB_MSG_TYPE_SHOW_RSP
,
size
);
if
(
pStart
==
NULL
)
{
taosSendSimpleRsp
(
pConn
->
thandle
,
TSDB_MSG_TYPE_SHOW_RSP
,
TSDB_CODE_SERV_OUT_OF_MEMORY
)
;
return
0
;
}
pMsg
=
pStart
;
pRsp
=
(
STaosRsp
*
)
pMsg
;
pMsg
=
(
char
*
)
pRsp
->
more
;
if
(
pShowMsg
->
type
>=
TSDB_MGMT_TABLE_MAX
)
{
code
=
-
1
;
}
else
{
pShow
=
(
SShowObj
*
)
calloc
(
1
,
sizeof
(
SShowObj
)
+
htons
(
pShowMsg
->
payloadLen
))
;
pShow
->
signature
=
pShow
;
pShow
->
type
=
pShowMsg
->
type
;
mTrace
(
"pShow:%p is allocated"
,
pShow
);
// set the table name query condition
pShow
->
payloadLen
=
htons
(
pShowMsg
->
payloadLen
);
memcpy
(
pShow
->
payload
,
pShowMsg
->
payload
,
pShow
->
payloadLen
);
pShowRsp
=
(
SShowRsp
*
)
pMsg
;
pShowRsp
->
qhandle
=
(
uint64_t
)
pShow
;
//
qhandle;
pConn
->
qhandle
=
pShowRsp
->
qhandle
;
code
=
(
*
mgmtGetMetaFp
[(
uint8_t
)
pShowMsg
->
type
])(
&
pShowRsp
->
meterMeta
,
pShow
,
pConn
);
if
(
code
==
0
)
{
pMsg
+=
sizeof
(
SShowRsp
)
+
sizeof
(
SSchema
)
*
pShow
->
numOfColumns
;
}
else
{
mError
(
"pShow:%p, type:%d %s, failed to get Meta, code:%d"
,
pShow
,
pShowMsg
->
type
,
taosMsg
[(
uint8_t
)
pShowMsg
->
type
],
code
);
free
(
pShow
);
}
}
pRsp
->
code
=
code
;
msgLen
=
pMsg
-
pStart
;
taosSendMsgToPeer
(
pConn
->
thandle
,
pStart
,
msgLen
);
return
msgLen
;
}
int32_t
mgmtProcessRetrieveMsg
(
void
*
pCont
,
int32_t
contLen
,
void
*
ahandle
)
{
...
...
@@ -1067,8 +1067,8 @@ int32_t mgmtProcessCreateTableMsg(void *pCont, int32_t contLen, void *ahandle) {
return
TSDB_CODE_INVALID_USER
;
}
SC
MCreateTableMsg
*
pCreate
=
(
SCM
CreateTableMsg
*
)
pCont
;
S
CM
Schema
*
pSchema
;
SC
reateTableMsg
*
pCreate
=
(
S
CreateTableMsg
*
)
pCont
;
SSchema
*
pSchema
;
int32_t
code
;
if
(
!
pUser
->
writeAuth
)
{
...
...
@@ -1195,7 +1195,7 @@ int32_t mgmtProcessCfgDnodeMsg(void *pCont, int32_t contLen, void *ahandle) {
return
TSDB_CODE_INVALID_USER
;
}
SC
MCfgDnodeMsg
*
pCfg
=
(
SCM
CfgDnodeMsg
*
)
pCont
;
SC
fgDnodeMsg
*
pCfg
=
(
S
CfgDnodeMsg
*
)
pCont
;
int32_t
code
;
if
(
strcmp
(
pUser
->
pAcct
->
user
,
"root"
)
!=
0
)
{
...
...
@@ -1213,10 +1213,10 @@ int32_t mgmtProcessCfgDnodeMsg(void *pCont, int32_t contLen, void *ahandle) {
}
int32_t
mgmtProcessHeartBeatMsg
(
void
*
pCont
,
int32_t
contLen
,
void
*
ahandle
)
{
S
CMHeartBeatMsg
*
pHBMsg
=
(
SCM
HeartBeatMsg
*
)
pCont
;
S
HeartBeatMsg
*
pHBMsg
=
(
S
HeartBeatMsg
*
)
pCont
;
mgmtSaveQueryStreamList
(
pHBMsg
);
S
CMHeartBeatRsp
*
pHBRsp
=
(
SCM
HeartBeatRsp
*
)
rpcMallocCont
(
contLen
);
S
HeartBeatRsp
*
pHBRsp
=
(
S
HeartBeatRsp
*
)
rpcMallocCont
(
contLen
);
if
(
pHBRsp
==
NULL
)
{
rpcSendResponse
(
ahandle
,
TSDB_CODE_SERV_OUT_OF_MEMORY
,
NULL
,
0
);
rpcFreeCont
(
pCont
);
...
...
@@ -1250,7 +1250,7 @@ int32_t mgmtProcessHeartBeatMsg(void *pCont, int32_t contLen, void *ahandle) {
pHBRsp
->
streamId
=
0
;
pHBRsp
->
killConnection
=
0
;
rpcSendResponse
(
ahandle
,
TSDB_CODE_SUCCESS
,
pHBRsp
,
sizeof
(
S
CM
HeartBeatMsg
));
rpcSendResponse
(
ahandle
,
TSDB_CODE_SUCCESS
,
pHBRsp
,
sizeof
(
SHeartBeatMsg
));
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1270,7 +1270,7 @@ int32_t mgmtRetriveUserAuthInfo(char *user, char *spi, char *encrypt, char *secr
}
static
int32_t
mgmtProcessConnectMsg
(
void
*
pCont
,
int32_t
contLen
,
void
*
thandle
)
{
SC
MConnectMsg
*
pConnectMsg
=
(
SCM
ConnectMsg
*
)
pCont
;
SC
onnectMsg
*
pConnectMsg
=
(
S
ConnectMsg
*
)
pCont
;
SRpcConnInfo
connInfo
;
rpcGetConnInfo
(
thandle
,
&
connInfo
);
int32_t
code
;
...
...
@@ -1307,7 +1307,7 @@ static int32_t mgmtProcessConnectMsg(void *pCont, int32_t contLen, void *thandle
}
}
SC
MConnectRsp
*
pConnectRsp
=
rpcMallocCont
(
sizeof
(
SCM
ConnectRsp
));
SC
onnectRsp
*
pConnectRsp
=
rpcMallocCont
(
sizeof
(
S
ConnectRsp
));
if
(
pConnectRsp
==
NULL
)
{
code
=
TSDB_CODE_SERV_OUT_OF_MEMORY
;
goto
connect_over
;
...
...
@@ -1339,7 +1339,7 @@ connect_over:
rpcSendResponse
(
thandle
,
code
,
NULL
,
0
);
}
else
{
mLPrint
(
"user:%s login from %s, code:%d"
,
connInfo
.
user
,
taosIpStr
(
connInfo
.
clientIp
),
code
);
rpcSendResponse
(
thandle
,
code
,
pConnectRsp
,
sizeof
(
SC
MC
onnectRsp
));
rpcSendResponse
(
thandle
,
code
,
pConnectRsp
,
sizeof
(
SConnectRsp
));
}
return
code
;
...
...
src/mnode/src/mgmtStreamTable.c
浏览文件 @
5b969523
...
...
@@ -67,8 +67,8 @@ void *mgmtStreamTableActionReset(void *row, char *str, int32_t size, int32_t *ss
int32_t
tsize
=
pTable
->
updateEnd
-
(
int8_t
*
)
pTable
;
memcpy
(
pTable
,
str
,
tsize
);
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
S
CM
Schema
);
pTable
->
schema
=
(
S
CM
Schema
*
)
realloc
(
pTable
->
schema
,
schemaSize
);
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
SSchema
);
pTable
->
schema
=
(
SSchema
*
)
realloc
(
pTable
->
schema
,
schemaSize
);
memcpy
(
pTable
->
schema
,
str
+
tsize
,
schemaSize
);
pTable
->
sql
=
(
char
*
)
realloc
(
pTable
->
sql
,
pTable
->
sqlLen
);
...
...
@@ -169,7 +169,7 @@ void *mgmtStreamTableActionEncode(void *row, char *str, int32_t size, int32_t *s
assert
(
row
!=
NULL
&&
str
!=
NULL
);
int32_t
tsize
=
pTable
->
updateEnd
-
(
int8_t
*
)
pTable
;
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
S
CM
Schema
);
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
SSchema
);
if
(
size
<
tsize
+
schemaSize
+
pTable
->
sqlLen
+
1
)
{
*
ssize
=
-
1
;
return
NULL
;
...
...
@@ -199,8 +199,8 @@ void *mgmtStreamTableActionDecode(void *row, char *str, int32_t size, int32_t *s
}
memcpy
(
pTable
,
str
,
tsize
);
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
S
CM
Schema
);
pTable
->
schema
=
(
S
CM
Schema
*
)
malloc
(
schemaSize
);
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
SSchema
);
pTable
->
schema
=
(
SSchema
*
)
malloc
(
schemaSize
);
if
(
pTable
->
schema
==
NULL
)
{
mgmtDestroyStreamTable
(
pTable
);
return
NULL
;
...
...
@@ -230,7 +230,7 @@ int32_t mgmtInitStreamTables() {
mgmtStreamTableActionInit
();
tsStreamTableSdb
=
sdbOpenTable
(
tsMaxTables
,
sizeof
(
SStreamTableObj
)
+
sizeof
(
S
CM
Schema
)
*
TSDB_MAX_COLUMNS
+
TSDB_MAX_SQL_LEN
,
tsStreamTableSdb
=
sdbOpenTable
(
tsMaxTables
,
sizeof
(
SStreamTableObj
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
+
TSDB_MAX_SQL_LEN
,
"streams"
,
SDB_KEYTYPE_STRING
,
tsMgmtDirectory
,
mgmtStreamTableAction
);
if
(
tsStreamTableSdb
==
NULL
)
{
mError
(
"failed to init stream table data"
);
...
...
@@ -273,7 +273,7 @@ int8_t *mgmtBuildCreateStreamTableMsg(SStreamTableObj *pTable, SVgObj *pVgroup)
// pCreateTable->numOfColumns = htons(pTable->numOfColumns);
// //pCreateTable->sqlLen = htons(pTable->sqlLen);
//
// S
CM
Schema *pSchema = pTable->schema;
// SSchema *pSchema = pTable->schema;
// int32_t totalCols = pCreateTable->numOfColumns;
// for (int32_t col = 0; col < totalCols; ++col) {
...
...
@@ -293,7 +293,7 @@ int8_t *mgmtBuildCreateStreamTableMsg(SStreamTableObj *pTable, SVgObj *pVgroup)
return
NULL
;
}
int32_t
mgmtCreateStreamTable
(
SDbObj
*
pDb
,
SC
MC
reateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
)
{
int32_t
mgmtCreateStreamTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
)
{
int32_t
numOfTables
=
sdbGetNumOfRows
(
tsStreamTableSdb
);
if
(
numOfTables
>=
TSDB_MAX_TABLES
)
{
mError
(
"stream table:%s, numOfTables:%d exceed maxTables:%d"
,
pCreate
->
tableId
,
numOfTables
,
TSDB_MAX_TABLES
);
...
...
@@ -314,23 +314,23 @@ int32_t mgmtCreateStreamTable(SDbObj *pDb, SCMCreateTableMsg *pCreate, SVgObj *p
pTable
->
numOfColumns
=
pCreate
->
numOfColumns
;
int32_t
numOfCols
=
pCreate
->
numOfColumns
+
pCreate
->
numOfTags
;
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
S
CM
Schema
);
pTable
->
schema
=
(
S
CM
Schema
*
)
calloc
(
1
,
schemaSize
);
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
SSchema
);
pTable
->
schema
=
(
SSchema
*
)
calloc
(
1
,
schemaSize
);
if
(
pTable
->
schema
==
NULL
)
{
free
(
pTable
);
mError
(
"table:%s, no schema input"
,
pCreate
->
tableId
);
return
TSDB_CODE_INVALID_TABLE
;
}
memcpy
(
pTable
->
schema
,
pCreate
->
schema
,
numOfCols
*
sizeof
(
S
CM
Schema
));
memcpy
(
pTable
->
schema
,
pCreate
->
schema
,
numOfCols
*
sizeof
(
SSchema
));
pTable
->
nextColId
=
0
;
for
(
int32_t
col
=
0
;
col
<
pCreate
->
numOfColumns
;
col
++
)
{
S
CMSchema
*
tschema
=
(
SCM
Schema
*
)
pTable
->
schema
;
S
Schema
*
tschema
=
(
S
Schema
*
)
pTable
->
schema
;
tschema
[
col
].
colId
=
pTable
->
nextColId
++
;
}
pTable
->
sql
=
(
char
*
)(
pTable
->
schema
+
numOfCols
*
sizeof
(
S
CM
Schema
));
memcpy
(
pTable
->
sql
,
(
char
*
)
(
pCreate
->
schema
)
+
numOfCols
*
sizeof
(
S
CM
Schema
),
pCreate
->
sqlLen
);
pTable
->
sql
=
(
char
*
)(
pTable
->
schema
+
numOfCols
*
sizeof
(
SSchema
));
memcpy
(
pTable
->
sql
,
(
char
*
)
(
pCreate
->
schema
)
+
numOfCols
*
sizeof
(
SSchema
),
pCreate
->
sqlLen
);
pTable
->
sql
[
pCreate
->
sqlLen
-
1
]
=
0
;
mTrace
(
"table:%s, stream sql len:%d sql:%s"
,
pCreate
->
tableId
,
pCreate
->
sqlLen
,
pTable
->
sql
);
...
...
src/mnode/src/mgmtSuperTable.c
浏览文件 @
5b969523
...
...
@@ -66,7 +66,7 @@ void *mgmtSuperTableActionReset(void *row, char *str, int32_t size, int32_t *ssi
int32_t
tsize
=
pTable
->
updateEnd
-
(
int8_t
*
)
pTable
;
memcpy
(
pTable
,
str
,
tsize
);
int32_t
schemaSize
=
sizeof
(
S
CM
Schema
)
*
(
pTable
->
numOfColumns
+
pTable
->
numOfTags
);
int32_t
schemaSize
=
sizeof
(
SSchema
)
*
(
pTable
->
numOfColumns
+
pTable
->
numOfTags
);
pTable
->
schema
=
realloc
(
pTable
->
schema
,
schemaSize
);
memcpy
(
pTable
->
schema
,
str
+
tsize
,
schemaSize
);
...
...
@@ -96,7 +96,7 @@ void *mgmtSuperTableActionEncode(void *row, char *str, int32_t size, int32_t *ss
assert
(
row
!=
NULL
&&
str
!=
NULL
);
int32_t
tsize
=
pTable
->
updateEnd
-
(
int8_t
*
)
pTable
;
int32_t
schemaSize
=
sizeof
(
S
CM
Schema
)
*
(
pTable
->
numOfColumns
+
pTable
->
numOfTags
);
int32_t
schemaSize
=
sizeof
(
SSchema
)
*
(
pTable
->
numOfColumns
+
pTable
->
numOfTags
);
if
(
size
<
tsize
+
schemaSize
+
1
)
{
*
ssize
=
-
1
;
...
...
@@ -126,7 +126,7 @@ void *mgmtSuperTableActionDecode(void *row, char *str, int32_t size, int32_t *ss
}
memcpy
(
pTable
,
str
,
tsize
);
int32_t
schemaSize
=
sizeof
(
S
CM
Schema
)
*
(
pTable
->
numOfColumns
+
pTable
->
numOfTags
);
int32_t
schemaSize
=
sizeof
(
SSchema
)
*
(
pTable
->
numOfColumns
+
pTable
->
numOfTags
);
pTable
->
schema
=
malloc
(
schemaSize
);
if
(
pTable
->
schema
==
NULL
)
{
mgmtDestroySuperTable
(
pTable
);
...
...
@@ -151,7 +151,7 @@ int32_t mgmtInitSuperTables() {
mgmtSuperTableActionInit
();
tsSuperTableSdb
=
sdbOpenTable
(
tsMaxTables
,
sizeof
(
STabObj
)
+
sizeof
(
S
CM
Schema
)
*
TSDB_MAX_COLUMNS
,
tsSuperTableSdb
=
sdbOpenTable
(
tsMaxTables
,
sizeof
(
STabObj
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
,
"stables"
,
SDB_KEYTYPE_STRING
,
tsMgmtDirectory
,
mgmtSuperTableAction
);
if
(
tsSuperTableSdb
==
NULL
)
{
mError
(
"failed to init super table data"
);
...
...
@@ -184,7 +184,7 @@ int32_t mgmtInitSuperTables() {
void
mgmtCleanUpSuperTables
()
{
}
int32_t
mgmtCreateSuperTable
(
SDbObj
*
pDb
,
SC
MC
reateTableMsg
*
pCreate
)
{
int32_t
mgmtCreateSuperTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
)
{
int32_t
numOfTables
=
sdbGetNumOfRows
(
tsSuperTableSdb
);
if
(
numOfTables
>=
TSDB_MAX_TABLES
)
{
mError
(
"super table:%s, numOfTables:%d exceed maxTables:%d"
,
pCreate
->
tableId
,
numOfTables
,
TSDB_MAX_TABLES
);
...
...
@@ -207,18 +207,18 @@ int32_t mgmtCreateSuperTable(SDbObj *pDb, SCMCreateTableMsg *pCreate) {
pStable
->
numOfTables
=
0
;
int32_t
numOfCols
=
pCreate
->
numOfColumns
+
pCreate
->
numOfTags
;
int32_t
schemaSize
=
numOfCols
*
sizeof
(
S
CM
Schema
);
pStable
->
schema
=
(
S
CM
Schema
*
)
calloc
(
1
,
schemaSize
);
int32_t
schemaSize
=
numOfCols
*
sizeof
(
SSchema
);
pStable
->
schema
=
(
SSchema
*
)
calloc
(
1
,
schemaSize
);
if
(
pStable
->
schema
==
NULL
)
{
free
(
pStable
);
mError
(
"table:%s, no schema input"
,
pCreate
->
tableId
);
return
TSDB_CODE_INVALID_TABLE
;
}
memcpy
(
pStable
->
schema
,
pCreate
->
schema
,
numOfCols
*
sizeof
(
S
CM
Schema
));
memcpy
(
pStable
->
schema
,
pCreate
->
schema
,
numOfCols
*
sizeof
(
SSchema
));
pStable
->
nextColId
=
0
;
for
(
int32_t
col
=
0
;
col
<
pCreate
->
numOfColumns
;
col
++
)
{
S
CMSchema
*
tschema
=
(
SCM
Schema
*
)
pStable
->
schema
;
S
Schema
*
tschema
=
(
S
Schema
*
)
pStable
->
schema
;
tschema
[
col
].
colId
=
pStable
->
nextColId
++
;
}
...
...
@@ -241,7 +241,7 @@ SSuperTableObj* mgmtGetSuperTable(char *tableId) {
int32_t
mgmtFindSuperTableTagIndex
(
SSuperTableObj
*
pStable
,
const
char
*
tagName
)
{
for
(
int32_t
i
=
0
;
i
<
pStable
->
numOfTags
;
i
++
)
{
S
CMSchema
*
schema
=
(
SCMSchema
*
)(
pStable
->
schema
+
(
pStable
->
numOfColumns
+
i
)
*
sizeof
(
SCM
Schema
));
S
Schema
*
schema
=
(
SSchema
*
)(
pStable
->
schema
+
(
pStable
->
numOfColumns
+
i
)
*
sizeof
(
S
Schema
));
if
(
strcasecmp
(
tagName
,
schema
->
name
)
==
0
)
{
return
i
;
}
...
...
@@ -250,7 +250,7 @@ int32_t mgmtFindSuperTableTagIndex(SSuperTableObj *pStable, const char *tagName)
return
-
1
;
}
int32_t
mgmtAddSuperTableTag
(
SSuperTableObj
*
pStable
,
S
CM
Schema
schema
[],
int32_t
ntags
)
{
int32_t
mgmtAddSuperTableTag
(
SSuperTableObj
*
pStable
,
SSchema
schema
[],
int32_t
ntags
)
{
if
(
pStable
->
numOfTags
+
ntags
>
TSDB_MAX_TAGS
)
{
return
TSDB_CODE_APP_ERROR
;
}
...
...
@@ -276,14 +276,14 @@ int32_t mgmtAddSuperTableTag(SSuperTableObj *pStable, SCMSchema schema[], int32_
return
TSDB_CODE_APP_ERROR
;
}
int32_t
schemaSize
=
sizeof
(
S
CM
Schema
)
*
(
pStable
->
numOfTags
+
pStable
->
numOfColumns
);
pStable
->
schema
=
realloc
(
pStable
->
schema
,
schemaSize
+
sizeof
(
S
CM
Schema
)
*
ntags
);
int32_t
schemaSize
=
sizeof
(
SSchema
)
*
(
pStable
->
numOfTags
+
pStable
->
numOfColumns
);
pStable
->
schema
=
realloc
(
pStable
->
schema
,
schemaSize
+
sizeof
(
SSchema
)
*
ntags
);
memmove
(
pStable
->
schema
+
sizeof
(
S
CM
Schema
)
*
(
pStable
->
numOfColumns
+
ntags
),
pStable
->
schema
+
sizeof
(
S
CMSchema
)
*
pStable
->
numOfColumns
,
sizeof
(
SCM
Schema
)
*
pStable
->
numOfTags
);
memcpy
(
pStable
->
schema
+
sizeof
(
S
CMSchema
)
*
pStable
->
numOfColumns
,
schema
,
sizeof
(
SCM
Schema
)
*
ntags
);
memmove
(
pStable
->
schema
+
sizeof
(
SSchema
)
*
(
pStable
->
numOfColumns
+
ntags
),
pStable
->
schema
+
sizeof
(
S
Schema
)
*
pStable
->
numOfColumns
,
sizeof
(
S
Schema
)
*
pStable
->
numOfTags
);
memcpy
(
pStable
->
schema
+
sizeof
(
S
Schema
)
*
pStable
->
numOfColumns
,
schema
,
sizeof
(
S
Schema
)
*
ntags
);
S
CMSchema
*
tschema
=
(
SCMSchema
*
)
(
pStable
->
schema
+
sizeof
(
SCM
Schema
)
*
pStable
->
numOfColumns
);
S
Schema
*
tschema
=
(
SSchema
*
)
(
pStable
->
schema
+
sizeof
(
S
Schema
)
*
pStable
->
numOfColumns
);
for
(
int32_t
i
=
0
;
i
<
ntags
;
i
++
)
{
tschema
[
i
].
colId
=
pStable
->
nextColId
++
;
}
...
...
@@ -316,13 +316,13 @@ int32_t mgmtDropSuperTableTag(SSuperTableObj *pStable, char *tagName) {
return
TSDB_CODE_APP_ERROR
;
}
memmove
(
pStable
->
schema
+
sizeof
(
S
CMSchema
)
*
col
,
pStable
->
schema
+
sizeof
(
SCM
Schema
)
*
(
col
+
1
),
sizeof
(
S
CM
Schema
)
*
(
pStable
->
numOfColumns
+
pStable
->
numOfTags
-
col
-
1
));
memmove
(
pStable
->
schema
+
sizeof
(
S
Schema
)
*
col
,
pStable
->
schema
+
sizeof
(
S
Schema
)
*
(
col
+
1
),
sizeof
(
SSchema
)
*
(
pStable
->
numOfColumns
+
pStable
->
numOfTags
-
col
-
1
));
pStable
->
numOfTags
--
;
pStable
->
sversion
++
;
int32_t
schemaSize
=
sizeof
(
S
CM
Schema
)
*
(
pStable
->
numOfTags
+
pStable
->
numOfColumns
);
int32_t
schemaSize
=
sizeof
(
SSchema
)
*
(
pStable
->
numOfTags
+
pStable
->
numOfColumns
);
pStable
->
schema
=
realloc
(
pStable
->
schema
,
schemaSize
);
sdbUpdateRow
(
tsSuperTableSdb
,
pStable
,
0
,
1
);
...
...
@@ -346,7 +346,7 @@ int32_t mgmtModifySuperTableTagNameByName(SSuperTableObj *pStable, char *oldTagN
}
// update
S
CMSchema
*
schema
=
(
SCMSchema
*
)
(
pStable
->
schema
+
(
pStable
->
numOfColumns
+
col
)
*
sizeof
(
SCM
Schema
));
S
Schema
*
schema
=
(
SSchema
*
)
(
pStable
->
schema
+
(
pStable
->
numOfColumns
+
col
)
*
sizeof
(
S
Schema
));
strncpy
(
schema
->
name
,
newTagName
,
TSDB_COL_NAME_LEN
);
// Encode string
...
...
@@ -370,7 +370,7 @@ int32_t mgmtModifySuperTableTagNameByName(SSuperTableObj *pStable, char *oldTagN
}
static
int32_t
mgmtFindSuperTableColumnIndex
(
SSuperTableObj
*
pStable
,
char
*
colName
)
{
S
CMSchema
*
schema
=
(
SCM
Schema
*
)
pStable
->
schema
;
S
Schema
*
schema
=
(
S
Schema
*
)
pStable
->
schema
;
for
(
int32_t
i
=
0
;
i
<
pStable
->
numOfColumns
;
i
++
)
{
if
(
strcasecmp
(
schema
[
i
].
name
,
colName
)
==
0
)
{
return
i
;
...
...
@@ -380,7 +380,7 @@ static int32_t mgmtFindSuperTableColumnIndex(SSuperTableObj *pStable, char *colN
return
-
1
;
}
int32_t
mgmtAddSuperTableColumn
(
SSuperTableObj
*
pStable
,
S
CM
Schema
schema
[],
int32_t
ncols
)
{
int32_t
mgmtAddSuperTableColumn
(
SSuperTableObj
*
pStable
,
SSchema
schema
[],
int32_t
ncols
)
{
if
(
ncols
<=
0
)
{
return
TSDB_CODE_APP_ERROR
;
}
...
...
@@ -403,14 +403,14 @@ int32_t mgmtAddSuperTableColumn(SSuperTableObj *pStable, SCMSchema schema[], int
return
TSDB_CODE_APP_ERROR
;
}
int32_t
schemaSize
=
sizeof
(
S
CM
Schema
)
*
(
pStable
->
numOfTags
+
pStable
->
numOfColumns
);
pStable
->
schema
=
realloc
(
pStable
->
schema
,
schemaSize
+
sizeof
(
S
CM
Schema
)
*
ncols
);
int32_t
schemaSize
=
sizeof
(
SSchema
)
*
(
pStable
->
numOfTags
+
pStable
->
numOfColumns
);
pStable
->
schema
=
realloc
(
pStable
->
schema
,
schemaSize
+
sizeof
(
SSchema
)
*
ncols
);
memmove
(
pStable
->
schema
+
sizeof
(
S
CM
Schema
)
*
(
pStable
->
numOfColumns
+
ncols
),
pStable
->
schema
+
sizeof
(
S
CMSchema
)
*
pStable
->
numOfColumns
,
sizeof
(
SCM
Schema
)
*
pStable
->
numOfTags
);
memcpy
(
pStable
->
schema
+
sizeof
(
S
CMSchema
)
*
pStable
->
numOfColumns
,
schema
,
sizeof
(
SCM
Schema
)
*
ncols
);
memmove
(
pStable
->
schema
+
sizeof
(
SSchema
)
*
(
pStable
->
numOfColumns
+
ncols
),
pStable
->
schema
+
sizeof
(
S
Schema
)
*
pStable
->
numOfColumns
,
sizeof
(
S
Schema
)
*
pStable
->
numOfTags
);
memcpy
(
pStable
->
schema
+
sizeof
(
S
Schema
)
*
pStable
->
numOfColumns
,
schema
,
sizeof
(
S
Schema
)
*
ncols
);
S
CMSchema
*
tschema
=
(
SCMSchema
*
)
(
pStable
->
schema
+
sizeof
(
SCM
Schema
)
*
pStable
->
numOfColumns
);
S
Schema
*
tschema
=
(
SSchema
*
)
(
pStable
->
schema
+
sizeof
(
S
Schema
)
*
pStable
->
numOfColumns
);
for
(
int32_t
i
=
0
;
i
<
ncols
;
i
++
)
{
tschema
[
i
].
colId
=
pStable
->
nextColId
++
;
}
...
...
@@ -442,13 +442,13 @@ int32_t mgmtDropSuperTableColumnByName(SSuperTableObj *pStable, char *colName) {
return
TSDB_CODE_APP_ERROR
;
}
memmove
(
pStable
->
schema
+
sizeof
(
S
CMSchema
)
*
col
,
pStable
->
schema
+
sizeof
(
SCM
Schema
)
*
(
col
+
1
),
sizeof
(
S
CM
Schema
)
*
(
pStable
->
numOfColumns
+
pStable
->
numOfTags
-
col
-
1
));
memmove
(
pStable
->
schema
+
sizeof
(
S
Schema
)
*
col
,
pStable
->
schema
+
sizeof
(
S
Schema
)
*
(
col
+
1
),
sizeof
(
SSchema
)
*
(
pStable
->
numOfColumns
+
pStable
->
numOfTags
-
col
-
1
));
pStable
->
numOfColumns
--
;
pStable
->
sversion
++
;
int32_t
schemaSize
=
sizeof
(
S
CM
Schema
)
*
(
pStable
->
numOfTags
+
pStable
->
numOfColumns
);
int32_t
schemaSize
=
sizeof
(
SSchema
)
*
(
pStable
->
numOfTags
+
pStable
->
numOfColumns
);
pStable
->
schema
=
realloc
(
pStable
->
schema
,
schemaSize
);
pAcct
->
acctInfo
.
numOfTimeSeries
-=
(
pStable
->
numOfTables
);
...
...
@@ -465,7 +465,7 @@ int32_t mgmtGetSuperTableMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
//
// if (pDb == NULL) return TSDB_CODE_DB_NOT_SELECTED;
//
// S
CM
Schema *pSchema = tsGetSchema(pMeta);
// SSchema *pSchema = tsGetSchema(pMeta);
//
// pShow->bytes[cols] = TSDB_METER_NAME_LEN;
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
...
...
@@ -597,7 +597,7 @@ int32_t mgmtGetTagsLength(SSuperTableObj* pSuperTable, int32_t col) { // length
int32_t
tagColumnIndexOffset
=
pSuperTable
->
numOfColumns
;
for
(
int32_t
i
=
0
;
i
<
pSuperTable
->
numOfTags
&&
i
<
col
;
++
i
)
{
len
+=
((
S
CM
Schema
*
)
pSuperTable
->
schema
)[
tagColumnIndexOffset
+
i
].
bytes
;
len
+=
((
SSchema
*
)
pSuperTable
->
schema
)[
tagColumnIndexOffset
+
i
].
bytes
;
}
return
len
;
...
...
src/mnode/src/mgmtTable.c
浏览文件 @
5b969523
...
...
@@ -99,7 +99,7 @@ STableInfo* mgmtGetTableByPos(uint32_t dnodeIp, int32_t vnode, int32_t sid) {
return
NULL
;
}
int32_t
mgmtCreateTable
(
SDbObj
*
pDb
,
SC
MC
reateTableMsg
*
pCreate
)
{
int32_t
mgmtCreateTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
)
{
STableInfo
*
pTable
=
mgmtGetTable
(
pCreate
->
tableId
);
if
(
pTable
!=
NULL
)
{
if
(
pCreate
->
igExists
)
{
...
...
@@ -241,7 +241,7 @@ int32_t mgmtGetTableMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
// return TSDB_CODE_DB_NOT_SELECTED;
// }
//
// S
CM
Schema *pSchema = tsGetSchema(pMeta);
// SSchema *pSchema = tsGetSchema(pMeta);
//
// pShow->bytes[cols] = TSDB_METER_NAME_LEN;
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
...
...
src/mnode/src/mgmtUser.c
浏览文件 @
5b969523
...
...
@@ -160,7 +160,7 @@ void mgmtCleanUpUsers() {
int32_t
mgmtGetUserMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
// int32_t cols = 0;
// S
CM
Schema *pSchema = tsGetSchema(pMeta);
// SSchema *pSchema = tsGetSchema(pMeta);
//
// pShow->bytes[cols] = TSDB_USER_LEN;
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
...
...
src/mnode/src/mgmtVgroup.c
浏览文件 @
5b969523
...
...
@@ -256,7 +256,7 @@ int32_t mgmtGetVgroupMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
//
// if (pDb == NULL) return TSDB_CODE_DB_NOT_SELECTED;
//
// S
CM
Schema *pSchema = tsGetSchema(pMeta);
// SSchema *pSchema = tsGetSchema(pMeta);
//
// pShow->bytes[cols] = 4;
// pSchema[cols].type = TSDB_DATA_TYPE_INT;
...
...
src/util/inc/tast.h
浏览文件 @
5b969523
...
...
@@ -28,7 +28,7 @@ extern "C" {
#include "ttypes.h"
struct
tSQLBinaryExpr
;
struct
S
CM
Schema
;
struct
SSchema
;
struct
tSkipList
;
struct
tSkipListNode
;
...
...
@@ -49,7 +49,7 @@ typedef struct tQueryInfo {
int32_t
offset
;
// offset value in tags
int32_t
colIdx
;
// index of column in schema
uint8_t
optr
;
// expression operator
S
CM
Schema
sch
;
// schema of tags
SSchema
sch
;
// schema of tags
tVariant
q
;
// query condition value on the specific schema, filter expression
__compar_fn_t
compare
;
// filter function
}
tQueryInfo
;
...
...
@@ -65,7 +65,7 @@ typedef struct tSQLSyntaxNode {
int16_t
colId
;
// for schema, the id of column
union
{
struct
tSQLBinaryExpr
*
pExpr
;
struct
S
CM
Schema
*
pSchema
;
struct
SSchema
*
pSchema
;
tVariant
*
pVal
;
};
}
tSQLSyntaxNode
;
...
...
@@ -88,7 +88,7 @@ typedef struct tQueryResultset {
int64_t
num
;
}
tQueryResultset
;
void
tSQLBinaryExprFromString
(
tSQLBinaryExpr
**
pExpr
,
S
CM
Schema
*
pSchema
,
int32_t
numOfCols
,
char
*
src
,
int32_t
len
);
void
tSQLBinaryExprFromString
(
tSQLBinaryExpr
**
pExpr
,
SSchema
*
pSchema
,
int32_t
numOfCols
,
char
*
src
,
int32_t
len
);
void
tSQLBinaryExprToString
(
tSQLBinaryExpr
*
pExpr
,
char
*
dst
,
int32_t
*
len
);
...
...
src/util/inc/textbuffer.h
浏览文件 @
5b969523
...
...
@@ -72,16 +72,16 @@ typedef struct tFilePagesItem {
tFilePage
item
;
}
tFilePagesItem
;
typedef
struct
S
CM
SchemaEx
{
struct
S
CM
Schema
field
;
typedef
struct
SSchemaEx
{
struct
SSchema
field
;
int16_t
offset
;
}
S
CM
SchemaEx
;
}
SSchemaEx
;
typedef
struct
SColumnModel
{
int32_t
capacity
;
int32_t
numOfCols
;
int16_t
rowSize
;
S
CM
SchemaEx
*
pFields
;
SSchemaEx
*
pFields
;
}
SColumnModel
;
typedef
struct
SColumnOrderInfo
{
...
...
@@ -116,7 +116,7 @@ typedef struct tExtMemBuffer {
}
tExtMemBuffer
;
typedef
struct
tTagSchema
{
struct
S
CM
Schema
*
pSchema
;
struct
SSchema
*
pSchema
;
int32_t
numOfCols
;
int32_t
colOffset
[];
}
tTagSchema
;
...
...
@@ -198,7 +198,7 @@ bool tExtMemBufferIsAllDataInMem(tExtMemBuffer *pMemBuffer);
* @param blockCapacity
* @return
*/
SColumnModel
*
createColumnModel
(
S
CM
Schema
*
fields
,
int32_t
numOfCols
,
int32_t
blockCapacity
);
SColumnModel
*
createColumnModel
(
SSchema
*
fields
,
int32_t
numOfCols
,
int32_t
blockCapacity
);
/**
*
...
...
@@ -219,7 +219,7 @@ void destroyColumnModel(SColumnModel *pModel);
void
tColModelCompact
(
SColumnModel
*
pModel
,
tFilePage
*
inputBuffer
,
int32_t
maxElemsCapacity
);
void
tColModelErase
(
SColumnModel
*
pModel
,
tFilePage
*
inputBuffer
,
int32_t
maxCapacity
,
int32_t
s
,
int32_t
e
);
S
CM
Schema
*
getColumnModelSchema
(
SColumnModel
*
pColumnModel
,
int32_t
index
);
SSchema
*
getColumnModelSchema
(
SColumnModel
*
pColumnModel
,
int32_t
index
);
int16_t
getColumnModelOffset
(
SColumnModel
*
pColumnModel
,
int32_t
index
);
...
...
src/util/inc/tschemautil.h
浏览文件 @
5b969523
...
...
@@ -26,7 +26,7 @@ extern "C" {
#define VALIDNUMOFCOLS(x) ((x) >= TSDB_MIN_COLUMNS && (x) <= TSDB_MAX_COLUMNS)
struct
S
CM
Schema
;
struct
SSchema
;
/**
* check if the schema is valid or not, including following aspects:
...
...
@@ -40,14 +40,14 @@ struct SCMSchema;
* @param numOfCols
* @return
*/
bool
isValidSchema
(
struct
S
CM
Schema
*
pSchema
,
int32_t
numOfCols
);
bool
isValidSchema
(
struct
SSchema
*
pSchema
,
int32_t
numOfCols
);
struct
S
CM
Schema
*
tsGetSchema
(
SMeterMeta
*
pMeta
);
struct
SSchema
*
tsGetSchema
(
SMeterMeta
*
pMeta
);
struct
S
CM
Schema
*
tsGetTagSchema
(
SMeterMeta
*
pMeta
);
struct
SSchema
*
tsGetTagSchema
(
SMeterMeta
*
pMeta
);
struct
S
CM
Schema
*
tsGetColumnSchema
(
SMeterMeta
*
pMeta
,
int32_t
startCol
);
struct
S
CM
Schema
tsGetTbnameColumnSchema
();
struct
SSchema
*
tsGetColumnSchema
(
SMeterMeta
*
pMeta
,
int32_t
startCol
);
struct
SSchema
tsGetTbnameColumnSchema
();
char
*
tsGetTagsValue
(
SMeterMeta
*
pMeta
);
...
...
src/util/src/textbuffer.c
浏览文件 @
5b969523
...
...
@@ -468,7 +468,7 @@ int32_t compare_a(tOrderDescriptor *pDescriptor, int32_t numOfRows1, int32_t s1,
return
ret
;
}
}
else
{
S
CM
Schema
*
pSchema
=
&
pDescriptor
->
pColumnModel
->
pFields
[
colIdx
];
SSchema
*
pSchema
=
&
pDescriptor
->
pColumnModel
->
pFields
[
colIdx
];
int32_t
ret
=
columnValueAscendingComparator
(
f1
,
f2
,
pSchema
->
type
,
pSchema
->
bytes
);
if
(
ret
==
0
)
{
continue
;
...
...
@@ -500,7 +500,7 @@ int32_t compare_d(tOrderDescriptor *pDescriptor, int32_t numOfRows1, int32_t s1,
return
ret
;
}
}
else
{
S
CM
Schema
*
pSchema
=
&
pDescriptor
->
pColumnModel
->
pFields
[
colIdx
];
SSchema
*
pSchema
=
&
pDescriptor
->
pColumnModel
->
pFields
[
colIdx
];
int32_t
ret
=
columnValueAscendingComparator
(
f1
,
f2
,
pSchema
->
type
,
pSchema
->
bytes
);
if
(
ret
==
0
)
{
continue
;
...
...
@@ -527,7 +527,7 @@ static void swap(SColumnModel *pColumnModel, int32_t count, int32_t s1, char *da
void
*
first
=
COLMODEL_GET_VAL
(
data1
,
pColumnModel
,
count
,
s1
,
i
);
void
*
second
=
COLMODEL_GET_VAL
(
data1
,
pColumnModel
,
count
,
s2
,
i
);
S
CM
Schema
*
pSchema
=
&
pColumnModel
->
pFields
[
i
].
field
;
SSchema
*
pSchema
=
&
pColumnModel
->
pFields
[
i
].
field
;
tsDataSwap
(
first
,
second
,
pSchema
->
type
,
pSchema
->
bytes
);
}
}
...
...
@@ -762,16 +762,16 @@ void tColDataQSort(tOrderDescriptor *pDescriptor, int32_t numOfRows, int32_t sta
/*
* deep copy of sschema
*/
SColumnModel
*
createColumnModel
(
S
CM
Schema
*
fields
,
int32_t
numOfCols
,
int32_t
blockCapacity
)
{
SColumnModel
*
pColumnModel
=
(
SColumnModel
*
)
calloc
(
1
,
sizeof
(
SColumnModel
)
+
numOfCols
*
sizeof
(
S
CM
SchemaEx
));
SColumnModel
*
createColumnModel
(
SSchema
*
fields
,
int32_t
numOfCols
,
int32_t
blockCapacity
)
{
SColumnModel
*
pColumnModel
=
(
SColumnModel
*
)
calloc
(
1
,
sizeof
(
SColumnModel
)
+
numOfCols
*
sizeof
(
SSchemaEx
));
if
(
pColumnModel
==
NULL
)
{
return
NULL
;
}
pColumnModel
->
pFields
=
(
S
CM
SchemaEx
*
)(
&
pColumnModel
[
1
]);
pColumnModel
->
pFields
=
(
SSchemaEx
*
)(
&
pColumnModel
[
1
]);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
S
CM
SchemaEx
*
pSchemaEx
=
&
pColumnModel
->
pFields
[
i
];
SSchemaEx
*
pSchemaEx
=
&
pColumnModel
->
pFields
[
i
];
pSchemaEx
->
field
=
fields
[
i
];
pSchemaEx
->
offset
=
pColumnModel
->
rowSize
;
...
...
@@ -789,15 +789,15 @@ SColumnModel *cloneColumnModel(SColumnModel *pSrc) {
return
NULL
;
}
SColumnModel
*
pColumnModel
=
(
SColumnModel
*
)
calloc
(
1
,
sizeof
(
SColumnModel
)
+
pSrc
->
numOfCols
*
sizeof
(
S
CM
SchemaEx
));
SColumnModel
*
pColumnModel
=
(
SColumnModel
*
)
calloc
(
1
,
sizeof
(
SColumnModel
)
+
pSrc
->
numOfCols
*
sizeof
(
SSchemaEx
));
if
(
pColumnModel
==
NULL
)
{
return
NULL
;
}
*
pColumnModel
=
*
pSrc
;
pColumnModel
->
pFields
=
(
S
CM
SchemaEx
*
)
(
&
pColumnModel
[
1
]);
memcpy
(
pColumnModel
->
pFields
,
pSrc
->
pFields
,
pSrc
->
numOfCols
*
sizeof
(
S
CM
SchemaEx
));
pColumnModel
->
pFields
=
(
SSchemaEx
*
)
(
&
pColumnModel
[
1
]);
memcpy
(
pColumnModel
->
pFields
,
pSrc
->
pFields
,
pSrc
->
numOfCols
*
sizeof
(
SSchemaEx
));
return
pColumnModel
;
}
...
...
@@ -1005,14 +1005,14 @@ void tColModelCompact(SColumnModel *pModel, tFilePage *inputBuffer, int32_t maxE
/* start from the second column */
for
(
int32_t
i
=
1
;
i
<
pModel
->
numOfCols
;
++
i
)
{
S
CM
SchemaEx
*
pSchemaEx
=
&
pModel
->
pFields
[
i
];
SSchemaEx
*
pSchemaEx
=
&
pModel
->
pFields
[
i
];
memmove
(
inputBuffer
->
data
+
pSchemaEx
->
offset
*
inputBuffer
->
numOfElems
,
inputBuffer
->
data
+
pSchemaEx
->
offset
*
maxElemsCapacity
,
pSchemaEx
->
field
.
bytes
*
inputBuffer
->
numOfElems
);
}
}
S
CM
Schema
*
getColumnModelSchema
(
SColumnModel
*
pColumnModel
,
int32_t
index
)
{
SSchema
*
getColumnModelSchema
(
SColumnModel
*
pColumnModel
,
int32_t
index
)
{
assert
(
pColumnModel
!=
NULL
&&
index
>=
0
&&
index
<
pColumnModel
->
numOfCols
);
return
&
pColumnModel
->
pFields
[
index
].
field
;
}
...
...
@@ -1034,7 +1034,7 @@ void tColModelErase(SColumnModel *pModel, tFilePage *inputBuffer, int32_t blockC
/* start from the second column */
for
(
int32_t
i
=
0
;
i
<
pModel
->
numOfCols
;
++
i
)
{
int16_t
offset
=
getColumnModelOffset
(
pModel
,
i
);
S
CM
Schema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
char
*
startPos
=
inputBuffer
->
data
+
offset
*
blockCapacity
+
s
*
pSchema
->
bytes
;
char
*
endPos
=
startPos
+
pSchema
->
bytes
*
removed
;
...
...
src/util/src/tinterpolation.c
浏览文件 @
5b969523
...
...
@@ -208,7 +208,7 @@ static char* getPos(char* data, int32_t bytes, int32_t order, int32_t capacity,
static
void
setTagsValueInInterpolation
(
tFilePage
**
data
,
char
**
pTags
,
SColumnModel
*
pModel
,
int32_t
order
,
int32_t
start
,
int32_t
capacity
,
int32_t
num
)
{
for
(
int32_t
j
=
0
,
i
=
start
;
i
<
pModel
->
numOfCols
;
++
i
,
++
j
)
{
S
CM
Schema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
char
*
val1
=
getPos
(
data
[
i
]
->
data
,
pSchema
->
bytes
,
order
,
capacity
,
num
);
assignVal
(
val1
,
pTags
[
j
],
pSchema
->
bytes
,
pSchema
->
type
);
...
...
@@ -236,7 +236,7 @@ static void doInterpoResultImpl(SInterpolationInfo* pInterpoInfo, int16_t interp
char
*
pInterpolationData
=
INTERPOL_IS_ASC_INTERPOL
(
pInterpoInfo
)
?
*
prevValues
:
*
nextValues
;
if
(
pInterpolationData
!=
NULL
)
{
for
(
int32_t
i
=
1
;
i
<
numOfValCols
;
++
i
)
{
S
CM
Schema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
int16_t
offset
=
getColumnModelOffset
(
pModel
,
i
);
char
*
val1
=
getPos
(
data
[
i
]
->
data
,
pSchema
->
bytes
,
pInterpoInfo
->
order
,
capacity
,
*
num
);
...
...
@@ -249,7 +249,7 @@ static void doInterpoResultImpl(SInterpolationInfo* pInterpoInfo, int16_t interp
}
}
else
{
/* no prev value yet, set the value for null */
for
(
int32_t
i
=
1
;
i
<
numOfValCols
;
++
i
)
{
S
CM
Schema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
char
*
val1
=
getPos
(
data
[
i
]
->
data
,
pSchema
->
bytes
,
pInterpoInfo
->
order
,
capacity
,
*
num
);
setNull
(
val1
,
pSchema
->
type
,
pSchema
->
bytes
);
...
...
@@ -261,7 +261,7 @@ static void doInterpoResultImpl(SInterpolationInfo* pInterpoInfo, int16_t interp
// TODO : linear interpolation supports NULL value
if
(
*
prevValues
!=
NULL
&&
!
outOfBound
)
{
for
(
int32_t
i
=
1
;
i
<
numOfValCols
;
++
i
)
{
S
CM
Schema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
int16_t
offset
=
getColumnModelOffset
(
pModel
,
i
);
int16_t
type
=
pSchema
->
type
;
...
...
@@ -282,7 +282,7 @@ static void doInterpoResultImpl(SInterpolationInfo* pInterpoInfo, int16_t interp
}
else
{
for
(
int32_t
i
=
1
;
i
<
numOfValCols
;
++
i
)
{
S
CM
Schema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
char
*
val1
=
getPos
(
data
[
i
]
->
data
,
pSchema
->
bytes
,
pInterpoInfo
->
order
,
capacity
,
*
num
);
setNull
(
val1
,
pSchema
->
type
,
pSchema
->
bytes
);
...
...
@@ -292,7 +292,7 @@ static void doInterpoResultImpl(SInterpolationInfo* pInterpoInfo, int16_t interp
}
}
else
{
/* default value interpolation */
for
(
int32_t
i
=
1
;
i
<
numOfValCols
;
++
i
)
{
S
CM
Schema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
char
*
val1
=
getPos
(
data
[
i
]
->
data
,
pSchema
->
bytes
,
pInterpoInfo
->
order
,
capacity
,
*
num
);
assignVal
(
val1
,
(
char
*
)
&
defaultVal
[
i
],
pSchema
->
bytes
,
pSchema
->
type
);
...
...
@@ -345,7 +345,7 @@ int32_t taosDoInterpoResult(SInterpolationInfo* pInterpoInfo, int16_t interpoTyp
*
nextValues
=
calloc
(
1
,
pModel
->
rowSize
);
for
(
int
i
=
1
;
i
<
pModel
->
numOfCols
;
i
++
)
{
int16_t
offset
=
getColumnModelOffset
(
pModel
,
i
);
S
CM
Schema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
setNull
(
*
nextValues
+
offset
,
pSchema
->
type
,
pSchema
->
bytes
);
}
...
...
@@ -353,7 +353,7 @@ int32_t taosDoInterpoResult(SInterpolationInfo* pInterpoInfo, int16_t interpoTyp
int32_t
offset
=
pInterpoInfo
->
rowIdx
;
for
(
int32_t
tlen
=
0
,
i
=
0
;
i
<
pModel
->
numOfCols
-
numOfTags
;
++
i
)
{
S
CM
Schema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
memcpy
(
*
nextValues
+
tlen
,
srcData
[
i
]
+
offset
*
pSchema
->
bytes
,
pSchema
->
bytes
);
tlen
+=
pSchema
->
bytes
;
...
...
@@ -379,7 +379,7 @@ int32_t taosDoInterpoResult(SInterpolationInfo* pInterpoInfo, int16_t interpoTyp
*
prevValues
=
calloc
(
1
,
pModel
->
rowSize
);
for
(
int
i
=
1
;
i
<
pModel
->
numOfCols
;
i
++
)
{
int16_t
offset
=
getColumnModelOffset
(
pModel
,
i
);
S
CM
Schema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
setNull
(
*
prevValues
+
offset
,
pSchema
->
type
,
pSchema
->
bytes
);
}
...
...
@@ -389,7 +389,7 @@ int32_t taosDoInterpoResult(SInterpolationInfo* pInterpoInfo, int16_t interpoTyp
int32_t
i
=
0
;
for
(
int32_t
tlen
=
0
;
i
<
pModel
->
numOfCols
-
numOfTags
;
++
i
)
{
int16_t
offset
=
getColumnModelOffset
(
pModel
,
i
);
S
CM
Schema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
char
*
val1
=
getPos
(
data
[
i
]
->
data
,
pSchema
->
bytes
,
pInterpoInfo
->
order
,
bufSize
,
num
);
...
...
src/util/src/tpercentile.c
浏览文件 @
5b969523
...
...
@@ -297,7 +297,7 @@ tMemBucket *tMemBucketCreate(int32_t totalSlots, int32_t nBufferSize, int16_t nE
return
NULL
;
}
S
CM
Schema
*
pSchema
=
getColumnModelSchema
(
pDesc
->
pColumnModel
,
0
);
SSchema
*
pSchema
=
getColumnModelSchema
(
pDesc
->
pColumnModel
,
0
);
if
(
pSchema
->
type
!=
dataType
)
{
pError
(
"MemBucket:%p,data type is not consistent,%d in schema, %d in param"
,
pBucket
,
pSchema
->
type
,
dataType
);
tfree
(
pBucket
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录