Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
~笨蛋陪你哭
TDengine
提交
aee99f11
T
TDengine
项目概览
~笨蛋陪你哭
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
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,发现更多精彩内容 >>
提交
aee99f11
编写于
2月 23, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sort out connect message from client to mgmt
上级
582e6ed6
变更
40
展开全部
隐藏空白更改
内联
并排
Showing
40 changed file
with
719 addition
and
698 deletion
+719
-698
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/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
+55
-56
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
+4
-4
src/inc/taosmsg.h
src/inc/taosmsg.h
+40
-49
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/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
+10
-10
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
+22
-22
src/mnode/src/mgmtProfile.c
src/mnode/src/mgmtProfile.c
+2
-2
src/mnode/src/mgmtShell.c
src/mnode/src/mgmtShell.c
+366
-335
src/mnode/src/mgmtStreamTable.c
src/mnode/src/mgmtStreamTable.c
+19
-19
src/mnode/src/mgmtSuperTable.c
src/mnode/src/mgmtSuperTable.c
+38
-38
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+7
-7
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
浏览文件 @
aee99f11
...
...
@@ -110,7 +110,7 @@ bool tscQueryMetricTags(SQueryInfo* pQueryInfo);
bool
tscIsSelectivityWithTagQuery
(
SSqlCmd
*
pCmd
);
void
tscAddSpecialColumnForSelect
(
SQueryInfo
*
pQueryInfo
,
int32_t
outputColIndex
,
int16_t
functionId
,
SColumnIndex
*
pIndex
,
SSchema
*
pColSchema
,
int16_t
isTag
);
S
CM
Schema
*
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
,
SSchema
*
pSchema
);
void
tscFieldInfoSetValFromSchema
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
,
S
CM
Schema
*
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
浏览文件 @
aee99f11
...
...
@@ -40,10 +40,10 @@
*
*/
static
tSQLSyntaxNode
*
tSQLSyntaxNodeCreate
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
SSQLToken
*
pToken
);
static
tSQLSyntaxNode
*
tSQLSyntaxNodeCreate
(
S
CM
Schema
*
pSchema
,
int32_t
numOfCols
,
SSQLToken
*
pToken
);
static
void
tSQLSyntaxNodeDestroy
(
tSQLSyntaxNode
*
pNode
,
void
(
*
fp
)(
void
*
));
static
tSQLSyntaxNode
*
createSyntaxTree
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
char
*
str
,
int32_t
*
i
);
static
tSQLSyntaxNode
*
createSyntaxTree
(
S
CM
Schema
*
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
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
SSQLToken
*
pToken
)
{
static
tSQLSyntaxNode
*
tSQLSyntaxNodeCreate
(
S
CM
Schema
*
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(SSchema *pSchema, int32_t numOfCols,
}
}
nodeSize
+=
sizeof
(
SSchema
);
nodeSize
+=
sizeof
(
S
CM
Schema
);
pNode
=
calloc
(
1
,
nodeSize
);
pNode
->
pSchema
=
(
struct
SSchema
*
)((
char
*
)
pNode
+
sizeof
(
tSQLSyntaxNode
));
pNode
->
pSchema
=
(
struct
S
CM
Schema
*
)((
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
(
SSchema
));
memcpy
(
pNode
->
pSchema
,
&
pSchema
[
i
],
sizeof
(
S
CM
Schema
));
}
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
,
SSchema
*
pSchema
,
int32_t
optr
,
static
tSQLSyntaxNode
*
parseRemainStr
(
char
*
pstr
,
tSQLBinaryExpr
*
pExpr
,
S
CM
Schema
*
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
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
char
*
str
,
int32_t
*
i
)
{
static
tSQLSyntaxNode
*
createSyntaxTree
(
S
CM
Schema
*
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(SSchema *pSchema, int32_t numOfCols, cha
}
}
void
tSQLBinaryExprFromString
(
tSQLBinaryExpr
**
pExpr
,
SSchema
*
pSchema
,
int32_t
numOfCols
,
char
*
src
,
int32_t
len
)
{
void
tSQLBinaryExprFromString
(
tSQLBinaryExpr
**
pExpr
,
S
CM
Schema
*
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
浏览文件 @
aee99f11
...
...
@@ -2437,7 +2437,7 @@ static bool percentile_function_setup(SQLFunctionCtx *pCtx) {
}
SResultInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SSchema
field
[
1
]
=
{{
pCtx
->
inputType
,
"dummyCol"
,
0
,
pCtx
->
inputBytes
}};
S
CM
Schema
field
[
1
]
=
{{
pCtx
->
inputType
,
"dummyCol"
,
0
,
pCtx
->
inputBytes
}};
SColumnModel
*
pModel
=
createColumnModel
(
field
,
1
,
1000
);
int32_t
orderIdx
=
0
;
...
...
src/client/src/tscLocal.c
浏览文件 @
aee99f11
...
...
@@ -85,7 +85,7 @@ static int32_t tscMaxLengthOfTagsFields(SSqlObj *pSql) {
}
char
*
pTagValue
=
tsGetTagsValue
(
pMeta
);
SSchema
*
pTagsSchema
=
tsGetTagSchema
(
pMeta
);
S
CM
Schema
*
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
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
S
CM
Schema
*
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
;
SSchema
*
pSchema
=
tsGetTagSchema
(
pMeterMetaInfo
->
pMeterMeta
);
S
CM
Schema
*
pSchema
=
tsGetTagSchema
(
pMeterMetaInfo
->
pMeterMeta
);
int32_t
vOffset
[
TSDB_MAX_COLUMNS
]
=
{
0
};
...
...
src/client/src/tscParseInsert.c
浏览文件 @
aee99f11
...
...
@@ -144,7 +144,7 @@ int tsParseTime(SSQLToken *pToken, int64_t *time, char **next, char *error, int1
return
TSDB_CODE_SUCCESS
;
}
int32_t
tsParseOneColumnData
(
SSchema
*
pSchema
,
SSQLToken
*
pToken
,
char
*
payload
,
char
*
msg
,
char
**
str
,
bool
primaryKey
,
int32_t
tsParseOneColumnData
(
S
CM
Schema
*
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
,
SSchema
schema
[],
SParsedDataColInfo
*
spd
,
char
*
error
,
int
tsParseOneRowData
(
char
**
str
,
STableDataBlocks
*
pDataBlocks
,
S
CM
Schema
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, SSchema schema[
// 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
;
SSchema
*
pSchema
=
schema
+
colIndex
;
S
CM
Schema
*
pSchema
=
schema
+
colIndex
;
rowSize
+=
pSchema
->
bytes
;
index
=
0
;
...
...
@@ -503,7 +503,7 @@ int tsParseValues(char **str, STableDataBlocks *pDataBlock, SMeterMeta *pMeterMe
int16_t
numOfRows
=
0
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
S
CM
Schema
*
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
,
SSchema
*
pSchema
,
int32_t
numOfCols
)
{
static
void
tscSetAssignedColumnInfo
(
SParsedDataColInfo
*
spd
,
S
CM
Schema
*
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
);
}
SSchema
*
pTagSchema
=
tsGetTagSchema
(
pSTableMeterMetaInfo
->
pMeterMeta
);
S
CM
Schema
*
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
};
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
S
CM
Schema
*
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
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
S
CM
Schema
*
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
};
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
tscSetAssignedColumnInfo
(
&
spd
,
pSchema
,
pMeterMeta
->
numOfColumns
);
...
...
src/client/src/tscSQLParser.c
浏览文件 @
aee99f11
...
...
@@ -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
,
SSchema
*
pSchema
);
static
int32_t
parseOrderbyClause
(
SQueryInfo
*
pQueryInfo
,
SQuerySQL
*
pQuerySql
,
S
CM
Schema
*
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
,
SCreateDbMsg
*
pCreate
);
static
int32_t
tscCheckCreateDbParams
(
SSqlCmd
*
pCmd
,
SC
MC
reateDbMsg
*
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
fgMsg
*
pCfg
=
(
SCfg
Msg
*
)
pMsg
;
SC
MCfgDnodeMsg
*
pCfg
=
(
SCMCfgDnode
Msg
*
)
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
;
}
SSchema
*
pTagSchema
=
tsGetTagSchema
(
pMeterMetaInfo
->
pMeterMeta
);
S
CM
Schema
*
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
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
S
CM
Schema
*
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
;
}
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
S
CM
Schema
*
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
;
SSchema
*
pSchema
=
tsGetColumnSchema
(
pMeterMeta
,
colIdx
);
S
CM
Schema
*
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
;
SSchema
*
pSchema
=
tsGetColumnSchema
(
pMeterMeta
,
pIndex
->
columnIndex
);
S
CM
Schema
*
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
,
SSchema
*
pColSchema
,
int16_t
flag
)
{
SColumnIndex
*
pIndex
,
S
CM
Schema
*
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
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
S
CM
Schema
*
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
)
{
SSchema
colSchema
=
{.
type
=
TSDB_DATA_TYPE_BINARY
,
.
bytes
=
TSDB_METER_NAME_LEN
};
S
CM
Schema
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
,
SSchema
*
pSchema
,
int32_t
functionID
,
char
*
aliasName
,
static
int32_t
setExprInfoForFunctions
(
SQueryInfo
*
pQueryInfo
,
S
CM
Schema
*
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
);
SSchema
*
pSchema
=
tsGetColumnSchema
(
pMeterMetaInfo
->
pMeterMeta
,
index
.
columnIndex
);
S
CM
Schema
*
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
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
S
CM
Schema
*
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
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
S
CM
Schema
*
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
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
S
CM
Schema
*
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
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
S
CM
Schema
*
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
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
S
CM
Schema
*
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
;
SSchema
*
pSchema
=
NULL
;
SSchema
s
=
tsGetTbnameColumnSchema
();
S
CM
Schema
*
pSchema
=
NULL
;
S
CM
Schema
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
);
SSchema
*
pSchema
=
tsGetColumnSchema
(
pMeterMetaInfo
->
pMeterMeta
,
columnIndex
->
columnIndex
);
S
CM
Schema
*
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
;
SSchema
*
pSchema
=
tsGetColumnSchema
(
pMeterMeta
,
pIndex
->
columnIndex
);
S
CM
Schema
*
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
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMeta
)
+
index
.
columnIndex
;
S
CM
Schema
*
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
);
SSchema
*
pLeftSchema
=
tsGetSchema
(
pLeftMeterMeta
->
pMeterMeta
);
S
CM
Schema
*
pLeftSchema
=
tsGetSchema
(
pLeftMeterMeta
->
pMeterMeta
);
int16_t
leftType
=
pLeftSchema
[
pLeftIndex
->
columnIndex
].
type
;
SMeterMetaInfo
*
pRightMeterMeta
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
rightIndex
.
tableIndex
);
SSchema
*
pRightSchema
=
tsGetSchema
(
pRightMeterMeta
->
pMeterMeta
);
S
CM
Schema
*
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
;
}
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
S
CM
Schema
*
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
,
SSchema
*
pSchema
)
{
int32_t
parseOrderbyClause
(
SQueryInfo
*
pQueryInfo
,
SQuerySQL
*
pQuerySql
,
S
CM
Schema
*
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
);
}
SSchema
*
pTagsSchema
=
tsGetColumnSchema
(
pMeterMetaInfo
->
pMeterMeta
,
columnIndex
.
columnIndex
);
S
CM
Schema
*
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
,
SCreateDbMsg
*
pMsg
,
SCreateDBInfo
*
pCreateDb
)
{
static
int32_t
setKeepOption
(
SSqlCmd
*
pCmd
,
SC
MC
reateDbMsg
*
pMsg
,
SCreateDBInfo
*
pCreateDb
)
{
const
char
*
msg
=
"invalid number of options"
;
pMsg
->
daysToKeep
=
htonl
(
-
1
);
...
...
@@ -4604,7 +4604,7 @@ static int32_t setKeepOption(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreateDBInfo* p
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
setTimePrecisionOption
(
SSqlCmd
*
pCmd
,
SCreateDbMsg
*
pMsg
,
SCreateDBInfo
*
pCreateDbInfo
)
{
static
int32_t
setTimePrecisionOption
(
SSqlCmd
*
pCmd
,
SC
MC
reateDbMsg
*
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, SCreateDbMsg* pMsg, SCreate
return
TSDB_CODE_SUCCESS
;
}
static
void
setCreateDBOption
(
SCreateDbMsg
*
pMsg
,
SCreateDBInfo
*
pCreateDb
)
{
static
void
setCreateDBOption
(
SC
MC
reateDbMsg
*
pMsg
,
SCreateDBInfo
*
pCreateDb
)
{
pMsg
->
blocksPerMeter
=
htons
(
pCreateDb
->
numOfBlocksPerTable
);
pMsg
->
compression
=
pCreateDb
->
compressionLevel
;
...
...
@@ -4643,7 +4643,7 @@ static void setCreateDBOption(SCreateDbMsg* pMsg, SCreateDBInfo* pCreateDb) {
}
int32_t
parseCreateDBOptions
(
SSqlCmd
*
pCmd
,
SCreateDBInfo
*
pCreateDbSql
)
{
SC
reateDbMsg
*
pMsg
=
(
S
CreateDbMsg
*
)(
pCmd
->
payload
+
tsRpcHeadSize
+
sizeof
(
SMgmtHead
));
SC
MCreateDbMsg
*
pMsg
=
(
SCM
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
};
SSchema
*
pSchema
=
tsGetTagSchema
(
pMeterMetaInfo
->
pMeterMeta
);
S
CM
Schema
*
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
);
SSchema
*
pSchema
=
tsGetColumnSchema
(
pMeterMetaInfo
->
pMeterMeta
,
index
);
S
CM
Schema
*
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
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
S
CM
Schema
*
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
)
{
SSchema
*
pColSchema
=
&
pSchema
[
pExpr
->
colInfo
.
colIdx
];
S
CM
Schema
*
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
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
S
CM
Schema
*
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
,
SCreateDbMsg
*
pCreate
)
{
int32_t
tscCheckCreateDbParams
(
SSqlCmd
*
pCmd
,
SC
MC
reateDbMsg
*
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
SSchema
*
pTagSchema
=
tsGetTagSchema
(
pStableMeterMetaInfo
->
pMeterMeta
);
S
CM
Schema
*
pTagSchema
=
tsGetTagSchema
(
pStableMeterMetaInfo
->
pMeterMeta
);
char
*
tagVal
=
pCreateTable
->
usingInfo
.
tagdata
.
data
;
for
(
int32_t
i
=
0
;
i
<
pList
->
nExpr
;
++
i
)
{
...
...
src/client/src/tscSchemaUtil.c
浏览文件 @
aee99f11
...
...
@@ -20,7 +20,7 @@
#include "ttypes.h"
#include "tutil.h"
bool
isValidSchema
(
struct
SSchema
*
pSchema
,
int32_t
numOfCols
)
{
bool
isValidSchema
(
struct
S
CM
Schema
*
pSchema
,
int32_t
numOfCols
)
{
if
(
!
VALIDNUMOFCOLS
(
numOfCols
))
{
return
false
;
}
...
...
@@ -64,14 +64,14 @@ bool isValidSchema(struct SSchema* pSchema, int32_t numOfCols) {
return
(
rowLen
<=
TSDB_MAX_BYTES_PER_ROW
);
}
struct
SSchema
*
tsGetSchema
(
SMeterMeta
*
pMeta
)
{
struct
S
CM
Schema
*
tsGetSchema
(
SMeterMeta
*
pMeta
)
{
if
(
pMeta
==
NULL
)
{
return
NULL
;
}
return
tsGetColumnSchema
(
pMeta
,
0
);
}
struct
SSchema
*
tsGetTagSchema
(
SMeterMeta
*
pMeta
)
{
struct
S
CM
Schema
*
tsGetTagSchema
(
SMeterMeta
*
pMeta
)
{
if
(
pMeta
==
NULL
||
pMeta
->
numOfTags
==
0
)
{
return
NULL
;
}
...
...
@@ -79,12 +79,12 @@ struct SSchema* tsGetTagSchema(SMeterMeta* pMeta) {
return
tsGetColumnSchema
(
pMeta
,
pMeta
->
numOfColumns
);
}
struct
SSchema
*
tsGetColumnSchema
(
SMeterMeta
*
pMeta
,
int32_t
startCol
)
{
return
(
S
Schema
*
)(((
char
*
)
pMeta
+
sizeof
(
SMeterMeta
))
+
startCol
*
sizeof
(
S
Schema
));
struct
S
CM
Schema
*
tsGetColumnSchema
(
SMeterMeta
*
pMeta
,
int32_t
startCol
)
{
return
(
S
CMSchema
*
)(((
char
*
)
pMeta
+
sizeof
(
SMeterMeta
))
+
startCol
*
sizeof
(
SCM
Schema
));
}
struct
SSchema
tsGetTbnameColumnSchema
()
{
struct
SSchema
s
=
{.
colId
=
TSDB_TBNAME_COLUMN_INDEX
,
.
type
=
TSDB_DATA_TYPE_BINARY
,
.
bytes
=
TSDB_METER_NAME_LEN
};
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
};
strcpy
(
s
.
name
,
TSQL_TBNAME_L
);
return
s
;
...
...
@@ -96,7 +96,7 @@ struct SSchema tsGetTbnameColumnSchema() {
* +--------------------+
* |SMeterMeta Body data| sizeof(SMeterMeta)
* +--------------------+
* |Schema data | numOfTotalColumns * sizeof(SSchema)
* |Schema data | numOfTotalColumns * sizeof(S
CM
Schema)
* +--------------------+
* |Tags data | tag_col_1.bytes + tag_col_2.bytes + ....
* +--------------------+
...
...
@@ -106,7 +106,7 @@ struct SSchema tsGetTbnameColumnSchema() {
*/
char
*
tsGetTagsValue
(
SMeterMeta
*
pMeta
)
{
int32_t
numOfTotalCols
=
pMeta
->
numOfColumns
+
pMeta
->
numOfTags
;
uint32_t
offset
=
sizeof
(
SMeterMeta
)
+
numOfTotalCols
*
sizeof
(
SSchema
);
uint32_t
offset
=
sizeof
(
SMeterMeta
)
+
numOfTotalCols
*
sizeof
(
S
CM
Schema
);
return
((
char
*
)
pMeta
+
offset
);
}
...
...
@@ -120,10 +120,10 @@ bool tsMeterMetaIdentical(SMeterMeta* p1, SMeterMeta* p2) {
return
true
;
}
size_t
size
=
sizeof
(
SMeterMeta
)
+
p1
->
numOfColumns
*
sizeof
(
SSchema
);
size_t
size
=
sizeof
(
SMeterMeta
)
+
p1
->
numOfColumns
*
sizeof
(
S
CM
Schema
);
for
(
int32_t
i
=
0
;
i
<
p1
->
numOfTags
;
++
i
)
{
SSchema
*
pColSchema
=
tsGetColumnSchema
(
p1
,
i
+
p1
->
numOfColumns
);
S
CM
Schema
*
pColSchema
=
tsGetColumnSchema
(
p1
,
i
+
p1
->
numOfColumns
);
size
+=
pColSchema
->
bytes
;
}
...
...
src/client/src/tscSecondaryMerge.c
浏览文件 @
aee99f11
...
...
@@ -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
);
SSchema
*
pSchema
=
getColumnModelSchema
(
pDesc
->
pColumnModel
,
i
);
S
CM
Schema
*
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
)
{
SSchema
*
pSchema
=
getColumnModelSchema
(
pReducer
->
resColModel
,
startIndex
+
i
-
1
);
S
CM
Schema
*
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
;
SSchema
*
pSchema
=
NULL
;
S
CM
Schema
*
pSchema
=
NULL
;
SColumnModel
*
pModel
=
NULL
;
*
pFinalModel
=
NULL
;
...
...
@@ -613,7 +613,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
return
pRes
->
code
;
}
pSchema
=
(
S
Schema
*
)
calloc
(
1
,
sizeof
(
S
Schema
)
*
pQueryInfo
->
fieldsInfo
.
numOfOutputCols
);
pSchema
=
(
S
CMSchema
*
)
calloc
(
1
,
sizeof
(
SCM
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
(
SSchema
)
*
pQueryInfo
->
fieldsInfo
.
numOfOutputCols
);
memset
(
pSchema
,
0
,
sizeof
(
S
CM
Schema
)
*
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
)
{
SSchema
*
pSchema
=
getColumnModelSchema
(
pColumnModel
,
i
);
S
CM
Schema
*
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
);
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
startIndex
+
i
);
S
CM
Schema
*
pSchema
=
getColumnModelSchema
(
pModel
,
startIndex
+
i
);
memcpy
(
pInterpoInfo
->
pTags
[
i
],
pLocalReducer
->
pBufForInterpo
+
offset
*
pResBuf
->
numOfElems
,
pSchema
->
bytes
);
...
...
src/client/src/tscServer.c
浏览文件 @
aee99f11
...
...
@@ -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
);
SSchema
colSchema
=
{.
type
=
TSDB_DATA_TYPE_BINARY
,
.
bytes
=
1
};
S
CM
Schema
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
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeterMeta
);
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
colList
.
numOfCols
;
++
i
)
{
SColumnBase
*
pCol
=
tscColumnBaseInfoGet
(
&
pQueryInfo
->
colList
,
i
);
SSchema
*
pColSchema
=
&
pSchema
[
pCol
->
colIndex
.
columnIndex
];
S
CM
Schema
*
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
SSchema
*
pTagSchema
=
tsGetTagSchema
(
pMeterMeta
);
S
CM
Schema
*
pTagSchema
=
tsGetTagSchema
(
pMeterMeta
);
for
(
int32_t
j
=
0
;
j
<
pMeterMetaInfo
->
numOfTags
;
++
j
)
{
if
(
pMeterMetaInfo
->
tagColumnIndex
[
j
]
==
TSDB_TBNAME_COLUMN_INDEX
)
{
SSchema
tbSchema
=
{
S
CM
Schema
tbSchema
=
{
.
bytes
=
TSDB_METER_NAME_LEN
,
.
colId
=
TSDB_TBNAME_COLUMN_INDEX
,
.
type
=
TSDB_DATA_TYPE_BINARY
};
memcpy
(
pMsg
,
&
tbSchema
,
sizeof
(
SSchema
));
memcpy
(
pMsg
,
&
tbSchema
,
sizeof
(
S
CM
Schema
));
}
else
{
memcpy
(
pMsg
,
&
pTagSchema
[
pMeterMetaInfo
->
tagColumnIndex
[
j
]],
sizeof
(
SSchema
));
memcpy
(
pMsg
,
&
pTagSchema
[
pMeterMetaInfo
->
tagColumnIndex
[
j
]],
sizeof
(
S
CM
Schema
));
}
pMsg
+=
sizeof
(
SSchema
);
pMsg
+=
sizeof
(
S
CM
Schema
);
}
}
...
...
@@ -1651,19 +1651,19 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
int32_t
tscBuildCreateDbMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SCreateDbMsg
*
pCreateDbMsg
;
SC
MC
reateDbMsg
*
pCreateDbMsg
;
char
*
pMsg
,
*
pStart
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pMsg
=
doBuildMsgHeader
(
pSql
,
&
pStart
);
pCreateDbMsg
=
(
SCreateDbMsg
*
)
pMsg
;
pCreateDbMsg
=
(
SC
MC
reateDbMsg
*
)
pMsg
;
assert
(
pCmd
->
numOfClause
==
1
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
strncpy
(
pCreateDbMsg
->
db
,
pMeterMetaInfo
->
name
,
tListLen
(
pCreateDbMsg
->
db
));
pMsg
+=
sizeof
(
SCreateDbMsg
);
pMsg
+=
sizeof
(
SC
MC
reateDbMsg
);
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
)
{
SCreateDnodeMsg
*
pCreate
;
SC
MC
reateDnodeMsg
*
pCreate
;
char
*
pMsg
,
*
pStart
;
...
...
@@ -1680,10 +1680,10 @@ int32_t tscBuildCreateDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pMsg
=
doBuildMsgHeader
(
pSql
,
&
pStart
);
pCreate
=
(
SCreateDnodeMsg
*
)
pMsg
;
pCreate
=
(
SC
MC
reateDnodeMsg
*
)
pMsg
;
strncpy
(
pCreate
->
ip
,
pInfo
->
pDCLInfo
->
a
[
0
].
z
,
pInfo
->
pDCLInfo
->
a
[
0
].
n
);
pMsg
+=
sizeof
(
SCreateDnodeMsg
);
pMsg
+=
sizeof
(
SC
MC
reateDnodeMsg
);
pCmd
->
payloadLen
=
pMsg
-
pStart
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_CREATE_DNODE
;
...
...
@@ -1775,7 +1775,7 @@ int32_t tscBuildCfgDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
char
*
pMsg
=
doBuildMsgHeader
(
pSql
,
&
pStart
);
pMsg
+=
sizeof
(
SC
fg
Msg
);
pMsg
+=
sizeof
(
SC
MCfgDnode
Msg
);
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
)
{
SDropDbMsg
*
pDropDbMsg
;
S
CM
DropDbMsg
*
pDropDbMsg
;
char
*
pMsg
,
*
pStart
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pMsg
=
doBuildMsgHeader
(
pSql
,
&
pStart
);
pDropDbMsg
=
(
SDropDbMsg
*
)
pMsg
;
pDropDbMsg
=
(
S
CM
DropDbMsg
*
)
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
(
SDropDbMsg
);
pMsg
+=
sizeof
(
S
CM
DropDbMsg
);
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
)
{
SDropDnodeMsg
*
pDrop
;
S
CM
DropDnodeMsg
*
pDrop
;
char
*
pMsg
,
*
pStart
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
pMsg
=
doBuildMsgHeader
(
pSql
,
&
pStart
);
pDrop
=
(
SDropDnodeMsg
*
)
pMsg
;
pDrop
=
(
S
CM
DropDnodeMsg
*
)
pMsg
;
strcpy
(
pDrop
->
ip
,
pMeterMetaInfo
->
name
);
pMsg
+=
sizeof
(
SDropDnodeMsg
);
pMsg
+=
sizeof
(
S
CM
DropDnodeMsg
);
pCmd
->
payloadLen
=
pMsg
-
pStart
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_DROP_DNODE
;
...
...
@@ -1891,18 +1891,18 @@ int32_t tscBuildDropAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
int32_t
tscBuildUseDbMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SUseDbMsg
*
pUseDbMsg
;
S
CM
UseDbMsg
*
pUseDbMsg
;
char
*
pMsg
,
*
pStart
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pMsg
=
doBuildMsgHeader
(
pSql
,
&
pStart
);
pUseDbMsg
=
(
SUseDbMsg
*
)
pMsg
;
pUseDbMsg
=
(
S
CM
UseDbMsg
*
)
pMsg
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
strcpy
(
pUseDbMsg
->
db
,
pMeterMetaInfo
->
name
);
pMsg
+=
sizeof
(
SUseDbMsg
);
pMsg
+=
sizeof
(
S
CM
UseDbMsg
);
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
(
SShowTableMsg
)
+
pCmd
->
payloadLen
+
TSDB_EXTRA_PAYLOAD_SIZE
;
int32_t
size
=
minMsgSize
()
+
sizeof
(
SMgmtHead
)
+
sizeof
(
S
CM
ShowTableMsg
)
+
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
(
SShowTableMsg
)
+
pPattern
->
n
);
pMsg
+=
(
sizeof
(
S
CM
ShowTableMsg
)
+
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
(
SShowTableMsg
)
+
pIpAddr
->
n
);
pMsg
+=
(
sizeof
(
S
CM
ShowTableMsg
)
+
pIpAddr
->
n
);
}
pCmd
->
payloadLen
=
pMsg
-
pStart
;
...
...
@@ -1971,18 +1971,17 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
int32_t
tscBuildKillMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
S
KillQuery
*
pKill
;
S
CMKillQueryMsg
*
pKill
;
char
*
pMsg
,
*
pStart
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pMsg
=
doBuildMsgHeader
(
pSql
,
&
pStart
);
pKill
=
(
S
KillQuery
*
)
pMsg
;
pKill
=
(
S
CMKillQueryMsg
*
)
pMsg
;
pKill
->
handle
=
0
;
strncpy
(
pKill
->
queryId
,
pInfo
->
pDCLInfo
->
ip
.
z
,
pInfo
->
pDCLInfo
->
ip
.
n
);
pMsg
+=
sizeof
(
S
KillQuery
);
pMsg
+=
sizeof
(
S
CMKillQueryMsg
);
pCmd
->
payloadLen
=
pMsg
-
pStart
;
...
...
@@ -2003,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
(
SCreateTableMsg
);
int32_t
size
=
minMsgSize
()
+
sizeof
(
SMgmtHead
)
+
sizeof
(
SC
MC
reateTableMsg
);
SCreateTableSQL
*
pCreateTableInfo
=
pInfo
->
pCreateTableInfo
;
if
(
pCreateTableInfo
->
type
==
TSQL_CREATE_TABLE_FROM_STABLE
)
{
size
+=
sizeof
(
STagData
);
}
else
{
size
+=
sizeof
(
SSchema
)
*
(
pCmd
->
numOfCols
+
pCmd
->
count
);
size
+=
sizeof
(
S
CM
Schema
)
*
(
pCmd
->
numOfCols
+
pCmd
->
count
);
}
if
(
pCreateTableInfo
->
pSelect
!=
NULL
)
{
...
...
@@ -2020,10 +2019,10 @@ int tscEstimateCreateTableMsgLength(SSqlObj *pSql, SSqlInfo *pInfo) {
}
int
tscBuildCreateTableMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SCreateTableMsg
*
pCreateTableMsg
;
SC
MC
reateTableMsg
*
pCreateTableMsg
;
char
*
pMsg
,
*
pStart
;
int
msgLen
=
0
;
SSchema
*
pSchema
;
S
CM
Schema
*
pSchema
;
int
size
=
0
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
...
...
@@ -2048,8 +2047,8 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pMsg
+=
sizeof
(
SMgmtHead
);
pCreateTableMsg
=
(
SCreateTableMsg
*
)
pMsg
;
strcpy
(
pCreateTableMsg
->
meter
Id
,
pMeterMetaInfo
->
name
);
pCreateTableMsg
=
(
SC
MC
reateTableMsg
*
)
pMsg
;
strcpy
(
pCreateTableMsg
->
table
Id
,
pMeterMetaInfo
->
name
);
SCreateTableSQL
*
pCreateTable
=
pInfo
->
pCreateTableInfo
;
...
...
@@ -2100,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
(
SSchema
)
*
tscNumOfFields
(
pQueryInfo
)
+
return
minMsgSize
()
+
sizeof
(
SMgmtHead
)
+
sizeof
(
SAlterTableMsg
)
+
sizeof
(
S
CM
Schema
)
*
tscNumOfFields
(
pQueryInfo
)
+
TSDB_EXTRA_PAYLOAD_SIZE
;
}
...
...
@@ -2131,13 +2130,13 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SAlterTableSQL
*
pAlterInfo
=
pInfo
->
pAlterInfo
;
pAlterTableMsg
=
(
SAlterTableMsg
*
)
pMsg
;
strcpy
(
pAlterTableMsg
->
meter
Id
,
pMeterMetaInfo
->
name
);
strcpy
(
pAlterTableMsg
->
table
Id
,
pMeterMetaInfo
->
name
);
pAlterTableMsg
->
type
=
htons
(
pAlterInfo
->
type
);
pAlterTableMsg
->
numOfCols
=
htons
(
tscNumOfFields
(
pQueryInfo
));
memcpy
(
pAlterTableMsg
->
tagVal
,
pAlterInfo
->
tagData
.
data
,
TSDB_MAX_TAGS_LEN
);
SSchema
*
pSchema
=
pAlterTableMsg
->
schema
;
S
CM
Schema
*
pSchema
=
pAlterTableMsg
->
schema
;
for
(
int
i
=
0
;
i
<
tscNumOfFields
(
pQueryInfo
);
++
i
)
{
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
pQueryInfo
,
i
);
...
...
@@ -2159,7 +2158,7 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
int
tscAlterDbMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SAlterDbMsg
*
pAlterDbMsg
;
S
CM
AlterDbMsg
*
pAlterDbMsg
;
char
*
pMsg
,
*
pStart
;
int
msgLen
=
0
;
...
...
@@ -2174,10 +2173,10 @@ int tscAlterDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
strcpy
(
pMgmt
->
db
,
pObj
->
db
);
pMsg
+=
sizeof
(
SMgmtHead
);
pAlterDbMsg
=
(
SAlterDbMsg
*
)
pMsg
;
pAlterDbMsg
=
(
S
CM
AlterDbMsg
*
)
pMsg
;
strcpy
(
pAlterDbMsg
->
db
,
pMeterMetaInfo
->
name
);
pMsg
+=
sizeof
(
SAlterDbMsg
);
pMsg
+=
sizeof
(
S
CM
AlterDbMsg
);
msgLen
=
pMsg
-
pStart
;
pCmd
->
payloadLen
=
msgLen
;
...
...
@@ -2665,7 +2664,7 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int
tscProcessMeterMetaRsp
(
SSqlObj
*
pSql
)
{
SMeterMeta
*
pMeta
;
SSchema
*
pSchema
;
S
CM
Schema
*
pSchema
;
uint8_t
ieType
;
char
*
rsp
=
pSql
->
res
.
pRsp
;
...
...
@@ -2707,7 +2706,7 @@ int tscProcessMeterMetaRsp(SSqlObj *pSql) {
pMeta
->
rowSize
=
0
;
rsp
+=
sizeof
(
SMeterMeta
);
pSchema
=
(
SSchema
*
)
rsp
;
pSchema
=
(
S
CM
Schema
*
)
rsp
;
int32_t
numOfTotalCols
=
pMeta
->
numOfColumns
+
pMeta
->
numOfTags
;
for
(
int
i
=
0
;
i
<
numOfTotalCols
;
++
i
)
{
...
...
@@ -2721,10 +2720,10 @@ int tscProcessMeterMetaRsp(SSqlObj *pSql) {
pSchema
++
;
}
rsp
+=
numOfTotalCols
*
sizeof
(
SSchema
);
rsp
+=
numOfTotalCols
*
sizeof
(
S
CM
Schema
);
int32_t
tagLen
=
0
;
SSchema
*
pTagsSchema
=
tsGetTagSchema
(
pMeta
);
S
CM
Schema
*
pTagsSchema
=
tsGetTagSchema
(
pMeta
);
if
(
pMeta
->
tableType
==
TSDB_TABLE_TYPE_CHILD_TABLE
)
{
for
(
int32_t
i
=
0
;
i
<
pMeta
->
numOfTags
;
++
i
)
{
...
...
@@ -2752,11 +2751,11 @@ int tscProcessMeterMetaRsp(SSqlObj *pSql) {
/**
* multi meter meta rsp pkg format:
* | STaosRsp | ieType | SMultiMeterInfoMsg | SMeterMeta0 | S
Schema0 | SMeterMeta1 | SSchema1 | SMeterMeta2 | S
Schema2
* | STaosRsp | ieType | SMultiMeterInfoMsg | SMeterMeta0 | S
CMSchema0 | SMeterMeta1 | SCMSchema1 | SMeterMeta2 | SCM
Schema2
* |...... 1B 1B 4B
**/
int
tscProcessMultiMeterMetaRsp
(
SSqlObj
*
pSql
)
{
SSchema
*
pSchema
;
S
CM
Schema
*
pSchema
;
uint8_t
ieType
;
int32_t
totalNum
;
int32_t
i
;
...
...
@@ -2822,7 +2821,7 @@ int tscProcessMultiMeterMetaRsp(SSqlObj *pSql) {
pMeta
->
rowSize
=
0
;
rsp
+=
sizeof
(
SMultiMeterMeta
);
pSchema
=
(
SSchema
*
)
rsp
;
pSchema
=
(
S
CM
Schema
*
)
rsp
;
int32_t
numOfTotalCols
=
pMeta
->
numOfColumns
+
pMeta
->
numOfTags
;
for
(
int
j
=
0
;
j
<
numOfTotalCols
;
++
j
)
{
...
...
@@ -2836,10 +2835,10 @@ int tscProcessMultiMeterMetaRsp(SSqlObj *pSql) {
pSchema
++
;
}
rsp
+=
numOfTotalCols
*
sizeof
(
SSchema
);
rsp
+=
numOfTotalCols
*
sizeof
(
S
CM
Schema
);
int32_t
tagLen
=
0
;
SSchema
*
pTagsSchema
=
tsGetTagSchema
(
pMeta
);
S
CM
Schema
*
pTagsSchema
=
tsGetTagSchema
(
pMeta
);
if
(
pMeta
->
tableType
==
TSDB_TABLE_TYPE_CHILD_TABLE
)
{
for
(
int32_t
j
=
0
;
j
<
pMeta
->
numOfTags
;
++
j
)
{
...
...
@@ -2989,7 +2988,7 @@ _error_clean:
int
tscProcessShowRsp
(
SSqlObj
*
pSql
)
{
SMeterMeta
*
pMeta
;
SShowRspMsg
*
pShow
;
SSchema
*
pSchema
;
S
CM
Schema
*
pSchema
;
char
key
[
20
];
SSqlRes
*
pRes
=
&
pSql
->
res
;
...
...
@@ -3007,7 +3006,7 @@ int tscProcessShowRsp(SSqlObj *pSql) {
pMeta
->
numOfColumns
=
ntohs
(
pMeta
->
numOfColumns
);
pSchema
=
(
SSchema
*
)((
char
*
)
pMeta
+
sizeof
(
SMeterMeta
));
pSchema
=
(
S
CM
Schema
*
)((
char
*
)
pMeta
+
sizeof
(
SMeterMeta
));
pMeta
->
sid
=
ntohs
(
pMeta
->
sid
);
for
(
int
i
=
0
;
i
<
pMeta
->
numOfColumns
;
++
i
)
{
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
...
...
@@ -3019,11 +3018,11 @@ int tscProcessShowRsp(SSqlObj *pSql) {
taosRemoveDataFromCache
(
tscCacheHandle
,
(
void
*
)
&
(
pMeterMetaInfo
->
pMeterMeta
),
false
);
int32_t
size
=
pMeta
->
numOfColumns
*
sizeof
(
SSchema
)
+
sizeof
(
SMeterMeta
);
int32_t
size
=
pMeta
->
numOfColumns
*
sizeof
(
S
CM
Schema
)
+
sizeof
(
SMeterMeta
);
pMeterMetaInfo
->
pMeterMeta
=
(
SMeterMeta
*
)
taosAddDataIntoCache
(
tscCacheHandle
,
key
,
(
char
*
)
pMeta
,
size
,
tsMeterMetaKeepTimer
);
pCmd
->
numOfCols
=
pQueryInfo
->
fieldsInfo
.
numOfOutputCols
;
SSchema
*
pMeterSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
S
CM
Schema
*
pMeterSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
tscColumnBaseInfoReserve
(
&
pQueryInfo
->
colList
,
pMeta
->
numOfColumns
);
SColumnIndex
index
=
{
0
};
...
...
src/client/src/tscUtil.c
浏览文件 @
aee99f11
...
...
@@ -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
,
SSchema
*
pSchema
)
{
void
tscFieldInfoSetValFromSchema
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
,
S
CM
Schema
*
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
{
SSchema
*
pSchema
=
tsGetColumnSchema
(
pMeterMetaInfo
->
pMeterMeta
,
pColIndex
->
columnIndex
);
S
CM
Schema
*
pSchema
=
tsGetColumnSchema
(
pMeterMetaInfo
->
pMeterMeta
,
pColIndex
->
columnIndex
);
pExpr
->
colInfo
.
colId
=
pSchema
->
colId
;
}
...
...
@@ -1509,7 +1509,7 @@ bool tscValidateColumnId(SMeterMetaInfo* pMeterMetaInfo, int32_t colId) {
return
true
;
}
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
S
CM
Schema
*
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
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeterMetaInfo
->
pMeterMeta
);
S
CM
Schema
*
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
))
{
SSchema
*
pTagSchema
=
tsGetTagSchema
(
pMeterMetaInfo
->
pMeterMeta
);
S
CM
Schema
*
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
浏览文件 @
aee99f11
...
...
@@ -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
fgMsg
*
pCfg
=
(
SCfg
Msg
*
)
pCont
;
SC
MCfgDnodeMsg
*
pCfg
=
(
SCMCfgDnode
Msg
*
)
pCont
;
int32_t
code
=
tsCfgDynamicOptions
(
pCfg
->
config
);
dnodeSendSimpleRspToMnode
(
pConn
,
msgType
+
1
,
code
);
return
code
;
...
...
src/inc/mnode.h
浏览文件 @
aee99f11
...
...
@@ -130,7 +130,7 @@ typedef struct _tab_obj {
char
*
pReserve1
;
char
*
pReserve2
;
char
*
schema
;
// SSchema schema[];
// S
CM
Schema schema[];
}
STabObj
;
typedef
struct
{
...
...
@@ -156,7 +156,7 @@ typedef struct SSuperTableObj {
int8_t
reserved
[
7
];
int8_t
updateEnd
[
1
];
int16_t
nextColId
;
SSchema
*
schema
;
S
CM
Schema
*
schema
;
}
SSuperTableObj
;
typedef
struct
{
...
...
@@ -184,7 +184,7 @@ typedef struct {
int8_t
reserved
[
3
];
int8_t
updateEnd
[
1
];
int16_t
nextColId
;
SSchema
*
schema
;
S
CM
Schema
*
schema
;
}
SNormalTableObj
;
typedef
struct
{
...
...
@@ -201,7 +201,7 @@ typedef struct {
int8_t
updateEnd
[
1
];
int16_t
nextColId
;
char
*
sql
;
//null-terminated string
SSchema
*
schema
;
S
CM
Schema
*
schema
;
}
SStreamTableObj
;
typedef
struct
_vg_obj
{
...
...
src/inc/taosmsg.h
浏览文件 @
aee99f11
...
...
@@ -245,12 +245,12 @@ typedef struct {
SShellSubmitRspBlock
*
failedBlocks
;
}
SShellSubmitRspMsg
;
typedef
struct
SSchema
{
typedef
struct
S
CM
Schema
{
uint8_t
type
;
char
name
[
TSDB_COL_NAME_LEN
];
short
colId
;
short
bytes
;
}
SSchema
;
}
S
CM
Schema
;
typedef
struct
{
int8_t
type
;
...
...
@@ -275,40 +275,34 @@ typedef struct {
int8_t
data
[];
}
SDCreateTableMsg
;
typedef
struct
{
char
db
[
TSDB_TABLE_ID_LEN
];
uint8_t
ignoreNotExists
;
}
SDropDbMsg
,
SUseDbMsg
;
typedef
struct
{
char
db
[
TSDB_DB_NAME_LEN
];
}
SShowTableMsg
;
}
S
CM
ShowTableMsg
;
typedef
struct
{
char
meterId
[
TSDB_TABLE_ID_LEN
];
char
igExists
;
short
numOfTags
;
short
numOfColumns
;
short
sqlLen
;
// the length of SQL, it starts after schema , sql is a
// null-terminated string
char
reserved
[
16
];
SSchema
schema
[];
}
SCreateTableMsg
;
char
tableId
[
TSDB_TABLE_ID_LEN
];
char
db
[
TSDB_DB_NAME_LEN
];
int8_t
igExists
;
int16_t
numOfTags
;
int16_t
numOfColumns
;
int16_t
sqlLen
;
// the length of SQL, it starts after schema , sql is a null-terminated string
int16_t
reserved
[
16
];
SCMSchema
schema
[];
}
SCMCreateTableMsg
;
typedef
struct
{
char
meterId
[
TSDB_TABLE_ID_LEN
];
char
igNotExists
;
char
meterId
[
TSDB_TABLE_ID_LEN
];
char
db
[
TSDB_DB_NAME_LEN
];
int8_t
igNotExists
;
}
SDropTableMsg
;
typedef
struct
{
char
meterId
[
TSDB_TABLE_ID_LEN
];
short
type
;
/* operation type */
char
tableId
[
TSDB_TABLE_ID_LEN
];
char
db
[
TSDB_DB_NAME_LEN
];
int16_t
type
;
/* operation type */
char
tagVal
[
TSDB_MAX_BYTES_PER_ROW
];
short
numOfCols
;
/* number of schema */
SSchema
schema
[];
int8_t
numOfCols
;
/* number of schema */
S
CM
Schema
schema
[];
}
SAlterTableMsg
;
typedef
struct
{
...
...
@@ -561,14 +555,11 @@ typedef struct {
char
accessState
;
}
SVnodeAccess
;
// NOTE: sizeof(SVnodeCfg) < TSDB_FILE_HEADER_LEN/4
/*
* NOTE: sizeof(SVnodeCfg) < TSDB_FILE_HEADER_LEN / 4
*/
typedef
struct
{
char
acct
[
TSDB_USER_LEN
];
/*
* the message is too large, so it may will overwrite the cfg information in meterobj.v*
* recover to origin codes
*/
//char db[TSDB_TABLE_ID_LEN+2]; // 8bytes align
char
db
[
TSDB_DB_NAME_LEN
];
uint32_t
vgId
;
int32_t
maxSessions
;
...
...
@@ -578,24 +569,25 @@ typedef struct {
float
fraction
;
}
cacheNumOfBlocks
;
int32_t
daysPerFile
;
int32_t
daysToKeep1
;
int32_t
daysToKeep2
;
int32_t
daysToKeep
;
int32_t
commitTime
;
int32_t
rowsInFileBlock
;
int16_t
blocksPerMeter
;
char
compression
;
char
commitLog
;
char
replications
;
char
repStrategy
;
char
loadLatest
;
// load into mem or not
int8_t
compression
;
int8_t
commitLog
;
int8_t
replications
;
int8_t
repStrategy
;
int8_t
loadLatest
;
// load into mem or not
uint8_t
precision
;
// time resolution
int8_t
reserved
[
16
];
}
SVnodeCfg
,
SCMCreateDbMsg
,
SDbCfg
,
SCMAlterDbMsg
;
char
reserved
[
16
];
}
SVnodeCfg
,
SCreateDbMsg
,
SDbCfg
,
SAlterDbMsg
;
typedef
struct
{
char
db
[
TSDB_TABLE_ID_LEN
];
uint8_t
ignoreNotExists
;
}
SCMDropDbMsg
,
SCMUseDbMsg
;
// IMPORTANT: sizeof(SVnodeStatisticInfo) should not exceed
// TSDB_FILE_HEADER_LEN/4 - TSDB_FILE_HEADER_VERSION_SIZE
...
...
@@ -759,7 +751,7 @@ typedef struct {
typedef
struct
{
char
ip
[
20
];
}
SC
reateMnodeMsg
,
SDropMnodeMsg
,
SCreateDnodeMsg
,
S
DropDnodeMsg
;
}
SC
MCreateMnodeMsg
,
SCMDropMnodeMsg
,
SCMCreateDnodeMsg
,
SCM
DropDnodeMsg
;
typedef
struct
{
uint64_t
qhandle
;
...
...
@@ -776,9 +768,9 @@ typedef struct {
}
SVpeerCfgMsg
;
typedef
struct
{
char
ip
[
20
];
char
config
[
6
0
];
}
SC
fg
Msg
;
char
ip
[
32
];
char
config
[
6
4
];
}
SC
MCfgDnode
Msg
;
typedef
struct
{
char
sql
[
TSDB_SHOW_SQL_LEN
];
...
...
@@ -821,9 +813,8 @@ typedef struct {
}
SCMHeartBeatRsp
;
typedef
struct
{
uint64_t
handle
;
char
queryId
[
TSDB_KILL_MSG_LEN
];
}
SKillQuery
,
SKillStream
,
SKillConnection
;
char
queryId
[
TSDB_KILL_MSG_LEN
];
}
SCMKillQueryMsg
,
SCMKillStreamMsg
,
SKillConnectionMsg
;
typedef
struct
{
int32_t
vnode
;
...
...
src/mnode/inc/mgmtAcct.h
浏览文件 @
aee99f11
...
...
@@ -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
,
SCreateTableMsg
*
pCreate
);
extern
int32_t
(
*
mgmtCheckTableLimit
)(
SAcctObj
*
pAcct
,
SC
MC
reateTableMsg
*
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
浏览文件 @
aee99f11
...
...
@@ -28,7 +28,7 @@ extern "C" {
int32_t
mgmtInitChildTables
();
void
mgmtCleanUpChildTables
();
int32_t
mgmtCreateChildTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
);
int32_t
mgmtCreateChildTable
(
SDbObj
*
pDb
,
SC
MC
reateTableMsg
*
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
浏览文件 @
aee99f11
...
...
@@ -23,7 +23,7 @@ extern "C" {
#include "mnode.h"
void
mgmtMonitorDbDrop
(
void
*
unused
,
void
*
unusedt
);
int32_t
mgmtAlterDb
(
SAcctObj
*
pAcct
,
SAlterDbMsg
*
pAlter
);
int32_t
mgmtAlterDb
(
SAcctObj
*
pAcct
,
S
CM
AlterDbMsg
*
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
,
SCreateDbMsg
*
pCreate
);
int32_t
mgmtCreateDb
(
SAcctObj
*
pAcct
,
SC
MC
reateDbMsg
*
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
浏览文件 @
aee99f11
...
...
@@ -26,9 +26,9 @@ extern "C" {
int32_t
mgmtInitNormalTables
();
void
mgmtCleanUpNormalTables
();
int32_t
mgmtCreateNormalTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
);
int32_t
mgmtCreateNormalTable
(
SDbObj
*
pDb
,
SC
MC
reateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
);
int32_t
mgmtDropNormalTable
(
SDbObj
*
pDb
,
SNormalTableObj
*
pTable
);
int32_t
mgmtAddNormalTableColumn
(
SNormalTableObj
*
pTable
,
SSchema
schema
[],
int32_t
ncols
);
int32_t
mgmtAddNormalTableColumn
(
SNormalTableObj
*
pTable
,
S
CM
Schema
schema
[],
int32_t
ncols
);
int32_t
mgmtDropNormalTableColumnByName
(
SNormalTableObj
*
pTable
,
char
*
colName
);
SNormalTableObj
*
mgmtGetNormalTable
(
char
*
tableId
);
int8_t
*
mgmtBuildCreateNormalTableMsg
(
SNormalTableObj
*
pTable
);
...
...
src/mnode/inc/mgmtStreamTable.h
浏览文件 @
aee99f11
...
...
@@ -26,7 +26,7 @@ extern "C" {
int32_t
mgmtInitStreamTables
();
void
mgmtCleanUpStreamTables
();
int32_t
mgmtCreateStreamTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
);
int32_t
mgmtCreateStreamTable
(
SDbObj
*
pDb
,
SC
MC
reateTableMsg
*
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
浏览文件 @
aee99f11
...
...
@@ -28,14 +28,14 @@ extern "C" {
int32_t
mgmtInitSuperTables
();
void
mgmtCleanUpSuperTables
();
int32_t
mgmtCreateSuperTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
);
int32_t
mgmtCreateSuperTable
(
SDbObj
*
pDb
,
SC
MC
reateTableMsg
*
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
,
SSchema
schema
[],
int32_t
ntags
);
int32_t
mgmtAddSuperTableTag
(
SSuperTableObj
*
pTable
,
S
CM
Schema
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
,
SSchema
schema
[],
int32_t
ncols
);
int32_t
mgmtAddSuperTableColumn
(
SSuperTableObj
*
pTable
,
S
CM
Schema
schema
[],
int32_t
ncols
);
int32_t
mgmtDropSuperTableColumnByName
(
SSuperTableObj
*
pTable
,
char
*
colName
);
int32_t
mgmtGetTagsLength
(
SSuperTableObj
*
pSuperTable
,
int32_t
col
);
...
...
src/mnode/inc/mgmtTable.h
浏览文件 @
aee99f11
...
...
@@ -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
,
SCreateTableMsg
*
pCreate
);
int32_t
mgmtCreateTable
(
SDbObj
*
pDb
,
SC
MC
reateTableMsg
*
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
浏览文件 @
aee99f11
...
...
@@ -133,11 +133,11 @@ static int32_t mgmtCheckDbLimitImp(SAcctObj *pAcct) {
int32_t
(
*
mgmtCheckDbLimit
)(
SAcctObj
*
pAcct
)
=
mgmtCheckDbLimitImp
;
static
int32_t
mgmtCheckTableLimitImp
(
SAcctObj
*
pAcct
,
SCreateTableMsg
*
pCreate
)
{
static
int32_t
mgmtCheckTableLimitImp
(
SAcctObj
*
pAcct
,
SC
MC
reateTableMsg
*
pCreate
)
{
return
0
;
}
int32_t
(
*
mgmtCheckTableLimit
)(
SAcctObj
*
pAcct
,
SCreateTableMsg
*
pCreate
)
=
mgmtCheckTableLimitImp
;
int32_t
(
*
mgmtCheckTableLimit
)(
SAcctObj
*
pAcct
,
SC
MC
reateTableMsg
*
pCreate
)
=
mgmtCheckTableLimitImp
;
static
void
mgmtCleanUpAcctsImp
()
{
}
...
...
src/mnode/src/mgmtChildTable.c
浏览文件 @
aee99f11
...
...
@@ -233,7 +233,7 @@ void mgmtCleanUpChildTables() {
}
int8_t
*
mgmtBuildCreateChildTableMsg
(
SChildTableObj
*
pTable
,
SVgObj
*
pVgroup
)
{
// SC
reateTableMsg *pCreateTable = (S
CreateTableMsg *) pMsg;
// SC
MCreateTableMsg *pCreateTable = (SCM
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);
//
// SSchema *pSchema = pTable->superTable->schema;
// S
CM
Schema *pSchema = pTable->superTable->schema;
// int32_t totalCols = pCreateTable->numOfColumns + pCreateTable->numOfTags;
//
// for (int32_t col = 0; col < totalCols; ++col) {
...
...
@@ -263,17 +263,17 @@ int8_t *mgmtBuildCreateChildTableMsg(SChildTableObj *pTable, SVgObj *pVgroup) {
return
NULL
;
}
int32_t
mgmtCreateChildTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
)
{
int32_t
mgmtCreateChildTable
(
SDbObj
*
pDb
,
SC
MC
reateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
)
{
int32_t
numOfTables
=
sdbGetNumOfRows
(
tsChildTableSdb
);
if
(
numOfTables
>=
tsMaxTables
)
{
mError
(
"table:%s, numOfTables:%d exceed maxTables:%d"
,
pCreate
->
meter
Id
,
numOfTables
,
tsMaxTables
);
mError
(
"table:%s, numOfTables:%d exceed maxTables:%d"
,
pCreate
->
table
Id
,
numOfTables
,
tsMaxTables
);
return
TSDB_CODE_TOO_MANY_TABLES
;
}
char
*
pTagData
=
(
char
*
)
pCreate
->
schema
;
// it is a tag key
SSuperTableObj
*
pSuperTable
=
mgmtGetSuperTable
(
pTagData
);
if
(
pSuperTable
==
NULL
)
{
mError
(
"table:%s, corresponding super table does not exist"
,
pCreate
->
meter
Id
);
mError
(
"table:%s, corresponding super table does not exist"
,
pCreate
->
table
Id
);
return
TSDB_CODE_INVALID_TABLE
;
}
...
...
@@ -281,7 +281,7 @@ int32_t mgmtCreateChildTable(SDbObj *pDb, SCreateTableMsg *pCreate, SVgObj *pVgr
if
(
pTable
==
NULL
)
{
return
TSDB_CODE_SERV_OUT_OF_MEMORY
;
}
strcpy
(
pTable
->
tableId
,
pCreate
->
meter
Id
);
strcpy
(
pTable
->
tableId
,
pCreate
->
table
Id
);
strcpy
(
pTable
->
superTableId
,
pSuperTable
->
tableId
);
pTable
->
createdTime
=
taosGetTimestampMs
();
pTable
->
superTable
=
pSuperTable
;
...
...
@@ -291,16 +291,16 @@ int32_t mgmtCreateChildTable(SDbObj *pDb, SCreateTableMsg *pCreate, SVgObj *pVgr
((
uint64_t
)
sdbGetVersion
()
&
((
1ul
<<
16
)
-
1ul
));
int32_t
size
=
mgmtGetTagsLength
(
pSuperTable
,
INT_MAX
)
+
(
uint32_t
)
TSDB_TABLE_ID_LEN
;
S
Schema
*
schema
=
(
S
Schema
*
)
calloc
(
1
,
size
);
S
CMSchema
*
schema
=
(
SCM
Schema
*
)
calloc
(
1
,
size
);
if
(
schema
==
NULL
)
{
free
(
pTable
);
mError
(
"table:%s, corresponding super table schema is null"
,
pCreate
->
meter
Id
);
mError
(
"table:%s, corresponding super table schema is null"
,
pCreate
->
table
Id
);
return
TSDB_CODE_INVALID_TABLE
;
}
memcpy
(
schema
,
pTagData
+
TSDB_TABLE_ID_LEN
+
1
,
size
);
if
(
sdbInsertRow
(
tsChildTableSdb
,
pTable
,
0
)
<
0
)
{
mError
(
"table:%s, update sdb error"
,
pCreate
->
meter
Id
);
mError
(
"table:%s, update sdb error"
,
pCreate
->
table
Id
);
return
TSDB_CODE_SDB_ERROR
;
}
...
...
@@ -355,7 +355,7 @@ int32_t mgmtModifyChildTableTagValueByName(SChildTableObj *pTable, char *tagName
// return TSDB_CODE_SUCCESS;
// int32_t rowSize = 0;
// S
Schema *schema = (SSchema *)(pSuperTable->schema + (pSuperTable->numOfColumns + col) * sizeof(S
Schema));
// S
CMSchema *schema = (SCMSchema *)(pSuperTable->schema + (pSuperTable->numOfColumns + col) * sizeof(SCM
Schema));
//
// if (col == 0) {
// pTable->isDirty = 1;
...
...
src/mnode/src/mgmtConn.c
浏览文件 @
aee99f11
...
...
@@ -71,7 +71,7 @@ int mgmtGetConnsMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
int
cols
=
0
;
pShow
->
bytes
[
cols
]
=
TSDB_METER_NAME_LEN
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeta
);
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"user"
);
...
...
src/mnode/src/mgmtDb.c
浏览文件 @
aee99f11
...
...
@@ -116,7 +116,7 @@ SDbObj *mgmtGetDbByTableId(char *meterId) {
return
(
SDbObj
*
)
sdbGetRow
(
tsDbSdb
,
db
);
}
int32_t
mgmtCheckDBParams
(
SCreateDbMsg
*
pCreate
)
{
int32_t
mgmtCheckDBParams
(
SC
MC
reateDbMsg
*
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(SCreateDbMsg *pCreate) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
mgmtCheckDbParams
(
SCreateDbMsg
*
pCreate
)
{
int32_t
mgmtCheckDbParams
(
SC
MC
reateDbMsg
*
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(SCreateDbMsg *pCreate) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
mgmtCreateDb
(
SAcctObj
*
pAcct
,
SCreateDbMsg
*
pCreate
)
{
int32_t
mgmtCreateDb
(
SAcctObj
*
pAcct
,
SC
MC
reateDbMsg
*
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
,
SAlterDbMsg
*
pAlter
)
{
int32_t
mgmtAlterDb
(
SAcctObj
*
pAcct
,
S
CM
AlterDbMsg
*
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
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeta
);
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
if
(
pUser
==
NULL
)
return
0
;
...
...
src/mnode/src/mgmtDnode.c
浏览文件 @
aee99f11
...
...
@@ -105,7 +105,7 @@ int32_t mgmtGetDnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
if
(
strcmp
(
pUser
->
user
,
"root"
)
!=
0
)
return
TSDB_CODE_NO_RIGHTS
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
S
CM
Schema
*
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
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
S
CM
Schema
*
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
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
S
CM
Schema
*
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
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeta
);
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
...
...
src/mnode/src/mgmtDnodeInt.c
浏览文件 @
aee99f11
...
...
@@ -499,7 +499,7 @@ int mgmtSendCfgDnodeMsg(char *cont) {
#endif
SDnodeObj
*
pDnode
;
SC
fgMsg
*
pCfg
=
(
SCfg
Msg
*
)
cont
;
SC
MCfgDnodeMsg
*
pCfg
=
(
SCMCfgDnode
Msg
*
)
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
fg
Msg
));
pMsg
+=
sizeof
(
SC
fg
Msg
);
memcpy
(
pMsg
,
cont
,
sizeof
(
SC
MCfgDnode
Msg
));
pMsg
+=
sizeof
(
SC
MCfgDnode
Msg
);
msgLen
=
pMsg
-
pStart
;
mgmtSendMsgToDnode
(
pDnode
,
pStart
,
msgLen
);
...
...
src/mnode/src/mgmtNormalTable.c
浏览文件 @
aee99f11
...
...
@@ -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
(
SSchema
);
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
S
CM
Schema
);
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
(
SSchema
);
pTable
->
schema
=
(
SSchema
*
)
malloc
(
schemaSize
);
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
S
CM
Schema
);
pTable
->
schema
=
(
S
CM
Schema
*
)
malloc
(
schemaSize
);
if
(
pTable
->
schema
==
NULL
)
{
mgmtDestroyNormalTable
(
pTable
);
return
NULL
;
...
...
@@ -215,7 +215,7 @@ int32_t mgmtInitNormalTables() {
mgmtNormalTableActionInit
();
tsNormalTableSdb
=
sdbOpenTable
(
tsMaxTables
,
sizeof
(
SNormalTableObj
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
,
tsNormalTableSdb
=
sdbOpenTable
(
tsMaxTables
,
sizeof
(
SNormalTableObj
)
+
sizeof
(
S
CM
Schema
)
*
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);
//
// SSchema *pSchema = pTable->schema;
// S
CM
Schema *pSchema = pTable->schema;
// int32_t totalCols = pCreateTable->numOfColumns;
// for (int32_t col = 0; col < totalCols; ++col) {
...
...
@@ -276,10 +276,10 @@ int8_t *mgmtBuildCreateNormalTableMsg(SNormalTableObj *pTable) {
return
NULL
;
}
int32_t
mgmtCreateNormalTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
)
{
int32_t
mgmtCreateNormalTable
(
SDbObj
*
pDb
,
SC
MC
reateTableMsg
*
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
->
meter
Id
,
numOfTables
,
TSDB_MAX_TABLES
);
mError
(
"normal table:%s, numOfTables:%d exceed maxTables:%d"
,
pCreate
->
table
Id
,
numOfTables
,
TSDB_MAX_TABLES
);
return
TSDB_CODE_TOO_MANY_TABLES
;
}
...
...
@@ -288,7 +288,7 @@ int32_t mgmtCreateNormalTable(SDbObj *pDb, SCreateTableMsg *pCreate, SVgObj *pVg
return
TSDB_CODE_SERV_OUT_OF_MEMORY
;
}
strcpy
(
pTable
->
tableId
,
pCreate
->
meter
Id
);
strcpy
(
pTable
->
tableId
,
pCreate
->
table
Id
);
pTable
->
createdTime
=
taosGetTimestampMs
();
pTable
->
vgId
=
pVgroup
->
vgId
;
pTable
->
sid
=
sid
;
...
...
@@ -297,23 +297,23 @@ int32_t mgmtCreateNormalTable(SDbObj *pDb, SCreateTableMsg *pCreate, SVgObj *pVg
pTable
->
numOfColumns
=
pCreate
->
numOfColumns
;
int32_t
numOfCols
=
pCreate
->
numOfColumns
+
pCreate
->
numOfTags
;
int32_t
schemaSize
=
numOfCols
*
sizeof
(
SSchema
);
pTable
->
schema
=
(
SSchema
*
)
calloc
(
1
,
schemaSize
);
int32_t
schemaSize
=
numOfCols
*
sizeof
(
S
CM
Schema
);
pTable
->
schema
=
(
S
CM
Schema
*
)
calloc
(
1
,
schemaSize
);
if
(
pTable
->
schema
==
NULL
)
{
free
(
pTable
);
mError
(
"table:%s, no schema input"
,
pCreate
->
meter
Id
);
mError
(
"table:%s, no schema input"
,
pCreate
->
table
Id
);
return
TSDB_CODE_INVALID_TABLE
;
}
memcpy
(
pTable
->
schema
,
pCreate
->
schema
,
numOfCols
*
sizeof
(
SSchema
));
memcpy
(
pTable
->
schema
,
pCreate
->
schema
,
numOfCols
*
sizeof
(
S
CM
Schema
));
pTable
->
nextColId
=
0
;
for
(
int32_t
col
=
0
;
col
<
pCreate
->
numOfColumns
;
col
++
)
{
S
Schema
*
tschema
=
(
S
Schema
*
)
pTable
->
schema
;
S
CMSchema
*
tschema
=
(
SCM
Schema
*
)
pTable
->
schema
;
tschema
[
col
].
colId
=
pTable
->
nextColId
++
;
}
if
(
sdbInsertRow
(
tsNormalTableSdb
,
pTable
,
0
)
<
0
)
{
mError
(
"table:%s, update sdb error"
,
pCreate
->
meter
Id
);
mError
(
"table:%s, update sdb error"
,
pCreate
->
table
Id
);
return
TSDB_CODE_SDB_ERROR
;
}
...
...
@@ -362,7 +362,7 @@ SNormalTableObj* mgmtGetNormalTable(char *tableId) {
}
static
int32_t
mgmtFindNormalTableColumnIndex
(
SNormalTableObj
*
pTable
,
char
*
colName
)
{
S
Schema
*
schema
=
(
S
Schema
*
)
pTable
->
schema
;
S
CMSchema
*
schema
=
(
SCM
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
,
SSchema
schema
[],
int32_t
ncols
)
{
int32_t
mgmtAddNormalTableColumn
(
SNormalTableObj
*
pTable
,
S
CM
Schema
schema
[],
int32_t
ncols
)
{
if
(
ncols
<=
0
)
{
return
TSDB_CODE_APP_ERROR
;
}
...
...
@@ -395,12 +395,12 @@ int32_t mgmtAddNormalTableColumn(SNormalTableObj *pTable, SSchema schema[], int3
return
TSDB_CODE_APP_ERROR
;
}
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
SSchema
);
pTable
->
schema
=
realloc
(
pTable
->
schema
,
schemaSize
+
sizeof
(
SSchema
)
*
ncols
);
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
S
CM
Schema
);
pTable
->
schema
=
realloc
(
pTable
->
schema
,
schemaSize
+
sizeof
(
S
CM
Schema
)
*
ncols
);
memcpy
(
pTable
->
schema
+
schemaSize
,
schema
,
sizeof
(
SSchema
)
*
ncols
);
memcpy
(
pTable
->
schema
+
schemaSize
,
schema
,
sizeof
(
S
CM
Schema
)
*
ncols
);
S
Schema
*
tschema
=
(
SSchema
*
)
(
pTable
->
schema
+
sizeof
(
S
Schema
)
*
pTable
->
numOfColumns
);
S
CMSchema
*
tschema
=
(
SCMSchema
*
)
(
pTable
->
schema
+
sizeof
(
SCM
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
Schema
)
*
col
,
pTable
->
schema
+
sizeof
(
S
Schema
)
*
(
col
+
1
),
sizeof
(
SSchema
)
*
(
pTable
->
numOfColumns
-
col
-
1
));
memmove
(
pTable
->
schema
+
sizeof
(
S
CMSchema
)
*
col
,
pTable
->
schema
+
sizeof
(
SCM
Schema
)
*
(
col
+
1
),
sizeof
(
S
CM
Schema
)
*
(
pTable
->
numOfColumns
-
col
-
1
));
pTable
->
numOfColumns
--
;
pTable
->
sversion
++
;
...
...
src/mnode/src/mgmtProfile.c
浏览文件 @
aee99f11
...
...
@@ -120,7 +120,7 @@ int32_t mgmtGetQueries(SShowObj *pShow, void *pConn) {
int32_t
mgmtGetQueryMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
cols
=
0
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeta
);
pShow
->
bytes
[
cols
]
=
TSDB_USER_LEN
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
...
...
@@ -318,7 +318,7 @@ int32_t mgmtGetStreams(SShowObj *pShow, void *pConn) {
int32_t
mgmtGetStreamMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
cols
=
0
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
S
CM
Schema
*
pSchema
=
tsGetSchema
(
pMeta
);
pShow
->
bytes
[
cols
]
=
TSDB_USER_LEN
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
...
...
src/mnode/src/mgmtShell.c
浏览文件 @
aee99f11
此差异已折叠。
点击以展开。
src/mnode/src/mgmtStreamTable.c
浏览文件 @
aee99f11
...
...
@@ -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
(
SSchema
);
pTable
->
schema
=
(
SSchema
*
)
realloc
(
pTable
->
schema
,
schemaSize
);
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
S
CM
Schema
);
pTable
->
schema
=
(
S
CM
Schema
*
)
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
(
SSchema
);
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
S
CM
Schema
);
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
(
SSchema
);
pTable
->
schema
=
(
SSchema
*
)
malloc
(
schemaSize
);
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
S
CM
Schema
);
pTable
->
schema
=
(
S
CM
Schema
*
)
malloc
(
schemaSize
);
if
(
pTable
->
schema
==
NULL
)
{
mgmtDestroyStreamTable
(
pTable
);
return
NULL
;
...
...
@@ -230,7 +230,7 @@ int32_t mgmtInitStreamTables() {
mgmtStreamTableActionInit
();
tsStreamTableSdb
=
sdbOpenTable
(
tsMaxTables
,
sizeof
(
SStreamTableObj
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
+
TSDB_MAX_SQL_LEN
,
tsStreamTableSdb
=
sdbOpenTable
(
tsMaxTables
,
sizeof
(
SStreamTableObj
)
+
sizeof
(
S
CM
Schema
)
*
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);
//
// SSchema *pSchema = pTable->schema;
// S
CM
Schema *pSchema = pTable->schema;
// int32_t totalCols = pCreateTable->numOfColumns;
// for (int32_t col = 0; col < totalCols; ++col) {
...
...
@@ -293,10 +293,10 @@ int8_t *mgmtBuildCreateStreamTableMsg(SStreamTableObj *pTable, SVgObj *pVgroup)
return
NULL
;
}
int32_t
mgmtCreateStreamTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
)
{
int32_t
mgmtCreateStreamTable
(
SDbObj
*
pDb
,
SC
MC
reateTableMsg
*
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
->
meter
Id
,
numOfTables
,
TSDB_MAX_TABLES
);
mError
(
"stream table:%s, numOfTables:%d exceed maxTables:%d"
,
pCreate
->
table
Id
,
numOfTables
,
TSDB_MAX_TABLES
);
return
TSDB_CODE_TOO_MANY_TABLES
;
}
...
...
@@ -305,7 +305,7 @@ int32_t mgmtCreateStreamTable(SDbObj *pDb, SCreateTableMsg *pCreate, SVgObj *pVg
return
TSDB_CODE_SERV_OUT_OF_MEMORY
;
}
strcpy
(
pTable
->
tableId
,
pCreate
->
meter
Id
);
strcpy
(
pTable
->
tableId
,
pCreate
->
table
Id
);
pTable
->
createdTime
=
taosGetTimestampMs
();
pTable
->
vgId
=
pVgroup
->
vgId
;
pTable
->
sid
=
sid
;
...
...
@@ -314,28 +314,28 @@ int32_t mgmtCreateStreamTable(SDbObj *pDb, SCreateTableMsg *pCreate, SVgObj *pVg
pTable
->
numOfColumns
=
pCreate
->
numOfColumns
;
int32_t
numOfCols
=
pCreate
->
numOfColumns
+
pCreate
->
numOfTags
;
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
SSchema
);
pTable
->
schema
=
(
SSchema
*
)
calloc
(
1
,
schemaSize
);
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
S
CM
Schema
);
pTable
->
schema
=
(
S
CM
Schema
*
)
calloc
(
1
,
schemaSize
);
if
(
pTable
->
schema
==
NULL
)
{
free
(
pTable
);
mError
(
"table:%s, no schema input"
,
pCreate
->
meter
Id
);
mError
(
"table:%s, no schema input"
,
pCreate
->
table
Id
);
return
TSDB_CODE_INVALID_TABLE
;
}
memcpy
(
pTable
->
schema
,
pCreate
->
schema
,
numOfCols
*
sizeof
(
SSchema
));
memcpy
(
pTable
->
schema
,
pCreate
->
schema
,
numOfCols
*
sizeof
(
S
CM
Schema
));
pTable
->
nextColId
=
0
;
for
(
int32_t
col
=
0
;
col
<
pCreate
->
numOfColumns
;
col
++
)
{
S
Schema
*
tschema
=
(
S
Schema
*
)
pTable
->
schema
;
S
CMSchema
*
tschema
=
(
SCM
Schema
*
)
pTable
->
schema
;
tschema
[
col
].
colId
=
pTable
->
nextColId
++
;
}
pTable
->
sql
=
(
char
*
)(
pTable
->
schema
+
numOfCols
*
sizeof
(
SSchema
));
memcpy
(
pTable
->
sql
,
(
char
*
)
(
pCreate
->
schema
)
+
numOfCols
*
sizeof
(
SSchema
),
pCreate
->
sqlLen
);
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
[
pCreate
->
sqlLen
-
1
]
=
0
;
mTrace
(
"table:%s, stream sql len:%d sql:%s"
,
pCreate
->
meter
Id
,
pCreate
->
sqlLen
,
pTable
->
sql
);
mTrace
(
"table:%s, stream sql len:%d sql:%s"
,
pCreate
->
table
Id
,
pCreate
->
sqlLen
,
pTable
->
sql
);
if
(
sdbInsertRow
(
tsStreamTableSdb
,
pTable
,
0
)
<
0
)
{
mError
(
"table:%s, update sdb error"
,
pCreate
->
meter
Id
);
mError
(
"table:%s, update sdb error"
,
pCreate
->
table
Id
);
return
TSDB_CODE_SDB_ERROR
;
}
...
...
src/mnode/src/mgmtSuperTable.c
浏览文件 @
aee99f11
...
...
@@ -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
(
SSchema
)
*
(
pTable
->
numOfColumns
+
pTable
->
numOfTags
);
int32_t
schemaSize
=
sizeof
(
S
CM
Schema
)
*
(
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
(
SSchema
)
*
(
pTable
->
numOfColumns
+
pTable
->
numOfTags
);
int32_t
schemaSize
=
sizeof
(
S
CM
Schema
)
*
(
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
(
SSchema
)
*
(
pTable
->
numOfColumns
+
pTable
->
numOfTags
);
int32_t
schemaSize
=
sizeof
(
S
CM
Schema
)
*
(
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
(
SSchema
)
*
TSDB_MAX_COLUMNS
,
tsSuperTableSdb
=
sdbOpenTable
(
tsMaxTables
,
sizeof
(
STabObj
)
+
sizeof
(
S
CM
Schema
)
*
TSDB_MAX_COLUMNS
,
"stables"
,
SDB_KEYTYPE_STRING
,
tsMgmtDirectory
,
mgmtSuperTableAction
);
if
(
tsSuperTableSdb
==
NULL
)
{
mError
(
"failed to init super table data"
);
...
...
@@ -184,10 +184,10 @@ int32_t mgmtInitSuperTables() {
void
mgmtCleanUpSuperTables
()
{
}
int32_t
mgmtCreateSuperTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
)
{
int32_t
mgmtCreateSuperTable
(
SDbObj
*
pDb
,
SC
MC
reateTableMsg
*
pCreate
)
{
int32_t
numOfTables
=
sdbGetNumOfRows
(
tsSuperTableSdb
);
if
(
numOfTables
>=
TSDB_MAX_TABLES
)
{
mError
(
"super table:%s, numOfTables:%d exceed maxTables:%d"
,
pCreate
->
meter
Id
,
numOfTables
,
TSDB_MAX_TABLES
);
mError
(
"super table:%s, numOfTables:%d exceed maxTables:%d"
,
pCreate
->
table
Id
,
numOfTables
,
TSDB_MAX_TABLES
);
return
TSDB_CODE_TOO_MANY_TABLES
;
}
...
...
@@ -196,7 +196,7 @@ int32_t mgmtCreateSuperTable(SDbObj *pDb, SCreateTableMsg *pCreate) {
return
TSDB_CODE_SERV_OUT_OF_MEMORY
;
}
strcpy
(
pStable
->
tableId
,
pCreate
->
meter
Id
);
strcpy
(
pStable
->
tableId
,
pCreate
->
table
Id
);
pStable
->
createdTime
=
taosGetTimestampMs
();
pStable
->
vgId
=
0
;
pStable
->
sid
=
0
;
...
...
@@ -207,23 +207,23 @@ int32_t mgmtCreateSuperTable(SDbObj *pDb, SCreateTableMsg *pCreate) {
pStable
->
numOfTables
=
0
;
int32_t
numOfCols
=
pCreate
->
numOfColumns
+
pCreate
->
numOfTags
;
int32_t
schemaSize
=
numOfCols
*
sizeof
(
SSchema
);
pStable
->
schema
=
(
SSchema
*
)
calloc
(
1
,
schemaSize
);
int32_t
schemaSize
=
numOfCols
*
sizeof
(
S
CM
Schema
);
pStable
->
schema
=
(
S
CM
Schema
*
)
calloc
(
1
,
schemaSize
);
if
(
pStable
->
schema
==
NULL
)
{
free
(
pStable
);
mError
(
"table:%s, no schema input"
,
pCreate
->
meter
Id
);
mError
(
"table:%s, no schema input"
,
pCreate
->
table
Id
);
return
TSDB_CODE_INVALID_TABLE
;
}
memcpy
(
pStable
->
schema
,
pCreate
->
schema
,
numOfCols
*
sizeof
(
SSchema
));
memcpy
(
pStable
->
schema
,
pCreate
->
schema
,
numOfCols
*
sizeof
(
S
CM
Schema
));
pStable
->
nextColId
=
0
;
for
(
int32_t
col
=
0
;
col
<
pCreate
->
numOfColumns
;
col
++
)
{
S
Schema
*
tschema
=
(
S
Schema
*
)
pStable
->
schema
;
S
CMSchema
*
tschema
=
(
SCM
Schema
*
)
pStable
->
schema
;
tschema
[
col
].
colId
=
pStable
->
nextColId
++
;
}
if
(
sdbInsertRow
(
tsSuperTableSdb
,
pStable
,
0
)
<
0
)
{
mError
(
"table:%s, update sdb error"
,
pCreate
->
meter
Id
);
mError
(
"table:%s, update sdb error"
,
pCreate
->
table
Id
);
return
TSDB_CODE_SDB_ERROR
;
}
...
...
@@ -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
Schema
*
schema
=
(
SSchema
*
)(
pStable
->
schema
+
(
pStable
->
numOfColumns
+
i
)
*
sizeof
(
S
Schema
));
S
CMSchema
*
schema
=
(
SCMSchema
*
)(
pStable
->
schema
+
(
pStable
->
numOfColumns
+
i
)
*
sizeof
(
SCM
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
,
SSchema
schema
[],
int32_t
ntags
)
{
int32_t
mgmtAddSuperTableTag
(
SSuperTableObj
*
pStable
,
S
CM
Schema
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, SSchema schema[], int32_t
return
TSDB_CODE_APP_ERROR
;
}
int32_t
schemaSize
=
sizeof
(
SSchema
)
*
(
pStable
->
numOfTags
+
pStable
->
numOfColumns
);
pStable
->
schema
=
realloc
(
pStable
->
schema
,
schemaSize
+
sizeof
(
SSchema
)
*
ntags
);
int32_t
schemaSize
=
sizeof
(
S
CM
Schema
)
*
(
pStable
->
numOfTags
+
pStable
->
numOfColumns
);
pStable
->
schema
=
realloc
(
pStable
->
schema
,
schemaSize
+
sizeof
(
S
CM
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
);
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
);
S
Schema
*
tschema
=
(
SSchema
*
)
(
pStable
->
schema
+
sizeof
(
S
Schema
)
*
pStable
->
numOfColumns
);
S
CMSchema
*
tschema
=
(
SCMSchema
*
)
(
pStable
->
schema
+
sizeof
(
SCM
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
Schema
)
*
col
,
pStable
->
schema
+
sizeof
(
S
Schema
)
*
(
col
+
1
),
sizeof
(
SSchema
)
*
(
pStable
->
numOfColumns
+
pStable
->
numOfTags
-
col
-
1
));
memmove
(
pStable
->
schema
+
sizeof
(
S
CMSchema
)
*
col
,
pStable
->
schema
+
sizeof
(
SCM
Schema
)
*
(
col
+
1
),
sizeof
(
S
CM
Schema
)
*
(
pStable
->
numOfColumns
+
pStable
->
numOfTags
-
col
-
1
));
pStable
->
numOfTags
--
;
pStable
->
sversion
++
;
int32_t
schemaSize
=
sizeof
(
SSchema
)
*
(
pStable
->
numOfTags
+
pStable
->
numOfColumns
);
int32_t
schemaSize
=
sizeof
(
S
CM
Schema
)
*
(
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
Schema
*
schema
=
(
SSchema
*
)
(
pStable
->
schema
+
(
pStable
->
numOfColumns
+
col
)
*
sizeof
(
S
Schema
));
S
CMSchema
*
schema
=
(
SCMSchema
*
)
(
pStable
->
schema
+
(
pStable
->
numOfColumns
+
col
)
*
sizeof
(
SCM
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
Schema
*
schema
=
(
S
Schema
*
)
pStable
->
schema
;
S
CMSchema
*
schema
=
(
SCM
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
,
SSchema
schema
[],
int32_t
ncols
)
{
int32_t
mgmtAddSuperTableColumn
(
SSuperTableObj
*
pStable
,
S
CM
Schema
schema
[],
int32_t
ncols
)
{
if
(
ncols
<=
0
)
{
return
TSDB_CODE_APP_ERROR
;
}
...
...
@@ -403,14 +403,14 @@ int32_t mgmtAddSuperTableColumn(SSuperTableObj *pStable, SSchema schema[], int32
return
TSDB_CODE_APP_ERROR
;
}
int32_t
schemaSize
=
sizeof
(
SSchema
)
*
(
pStable
->
numOfTags
+
pStable
->
numOfColumns
);
pStable
->
schema
=
realloc
(
pStable
->
schema
,
schemaSize
+
sizeof
(
SSchema
)
*
ncols
);
int32_t
schemaSize
=
sizeof
(
S
CM
Schema
)
*
(
pStable
->
numOfTags
+
pStable
->
numOfColumns
);
pStable
->
schema
=
realloc
(
pStable
->
schema
,
schemaSize
+
sizeof
(
S
CM
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
);
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
);
S
Schema
*
tschema
=
(
SSchema
*
)
(
pStable
->
schema
+
sizeof
(
S
Schema
)
*
pStable
->
numOfColumns
);
S
CMSchema
*
tschema
=
(
SCMSchema
*
)
(
pStable
->
schema
+
sizeof
(
SCM
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
Schema
)
*
col
,
pStable
->
schema
+
sizeof
(
S
Schema
)
*
(
col
+
1
),
sizeof
(
SSchema
)
*
(
pStable
->
numOfColumns
+
pStable
->
numOfTags
-
col
-
1
));
memmove
(
pStable
->
schema
+
sizeof
(
S
CMSchema
)
*
col
,
pStable
->
schema
+
sizeof
(
SCM
Schema
)
*
(
col
+
1
),
sizeof
(
S
CM
Schema
)
*
(
pStable
->
numOfColumns
+
pStable
->
numOfTags
-
col
-
1
));
pStable
->
numOfColumns
--
;
pStable
->
sversion
++
;
int32_t
schemaSize
=
sizeof
(
SSchema
)
*
(
pStable
->
numOfTags
+
pStable
->
numOfColumns
);
int32_t
schemaSize
=
sizeof
(
S
CM
Schema
)
*
(
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;
//
// SSchema *pSchema = tsGetSchema(pMeta);
// S
CM
Schema *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
+=
((
SSchema
*
)
pSuperTable
->
schema
)[
tagColumnIndexOffset
+
i
].
bytes
;
len
+=
((
S
CM
Schema
*
)
pSuperTable
->
schema
)[
tagColumnIndexOffset
+
i
].
bytes
;
}
return
len
;
...
...
src/mnode/src/mgmtTable.c
浏览文件 @
aee99f11
...
...
@@ -99,8 +99,8 @@ STableInfo* mgmtGetTableByPos(uint32_t dnodeIp, int32_t vnode, int32_t sid) {
return
NULL
;
}
int32_t
mgmtCreateTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
)
{
STableInfo
*
pTable
=
mgmtGetTable
(
pCreate
->
meter
Id
);
int32_t
mgmtCreateTable
(
SDbObj
*
pDb
,
SC
MC
reateTableMsg
*
pCreate
)
{
STableInfo
*
pTable
=
mgmtGetTable
(
pCreate
->
table
Id
);
if
(
pTable
!=
NULL
)
{
if
(
pCreate
->
igExists
)
{
return
TSDB_CODE_SUCCESS
;
...
...
@@ -113,19 +113,19 @@ int32_t mgmtCreateTable(SDbObj *pDb, SCreateTableMsg *pCreate) {
assert
(
pAcct
!=
NULL
);
int32_t
code
=
mgmtCheckTableLimit
(
pAcct
,
pCreate
);
if
(
code
!=
0
)
{
mError
(
"table:%s, exceed the limit"
,
pCreate
->
meter
Id
);
mError
(
"table:%s, exceed the limit"
,
pCreate
->
table
Id
);
return
code
;
}
if
(
mgmtCheckExpired
())
{
mError
(
"failed to create meter:%s, reason:grant expired"
,
pCreate
->
meter
Id
);
mError
(
"failed to create meter:%s, reason:grant expired"
,
pCreate
->
table
Id
);
return
TSDB_CODE_GRANT_EXPIRED
;
}
if
(
pCreate
->
numOfTags
==
0
)
{
int32_t
grantCode
=
mgmtCheckTimeSeries
(
pCreate
->
numOfColumns
);
if
(
grantCode
!=
0
)
{
mError
(
"table:%s, grant expired"
,
pCreate
->
meter
Id
);
mError
(
"table:%s, grant expired"
,
pCreate
->
table
Id
);
return
grantCode
;
}
...
...
@@ -180,7 +180,7 @@ int32_t mgmtDropTable(SDbObj *pDb, char *tableId, int32_t ignore) {
}
int32_t
mgmtAlterTable
(
SDbObj
*
pDb
,
SAlterTableMsg
*
pAlter
)
{
STableInfo
*
pTable
=
mgmtGetTable
(
pAlter
->
meter
Id
);
STableInfo
*
pTable
=
mgmtGetTable
(
pAlter
->
table
Id
);
if
(
pTable
==
NULL
)
{
return
TSDB_CODE_INVALID_TABLE
;
}
...
...
@@ -241,7 +241,7 @@ int32_t mgmtGetTableMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
// return TSDB_CODE_DB_NOT_SELECTED;
// }
//
// SSchema *pSchema = tsGetSchema(pMeta);
// S
CM
Schema *pSchema = tsGetSchema(pMeta);
//
// pShow->bytes[cols] = TSDB_METER_NAME_LEN;
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
...
...
src/mnode/src/mgmtUser.c
浏览文件 @
aee99f11
...
...
@@ -160,7 +160,7 @@ void mgmtCleanUpUsers() {
int32_t
mgmtGetUserMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
// int32_t cols = 0;
// SSchema *pSchema = tsGetSchema(pMeta);
// S
CM
Schema *pSchema = tsGetSchema(pMeta);
//
// pShow->bytes[cols] = TSDB_USER_LEN;
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
...
...
src/mnode/src/mgmtVgroup.c
浏览文件 @
aee99f11
...
...
@@ -256,7 +256,7 @@ int32_t mgmtGetVgroupMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
//
// if (pDb == NULL) return TSDB_CODE_DB_NOT_SELECTED;
//
// SSchema *pSchema = tsGetSchema(pMeta);
// S
CM
Schema *pSchema = tsGetSchema(pMeta);
//
// pShow->bytes[cols] = 4;
// pSchema[cols].type = TSDB_DATA_TYPE_INT;
...
...
src/util/inc/tast.h
浏览文件 @
aee99f11
...
...
@@ -28,7 +28,7 @@ extern "C" {
#include "ttypes.h"
struct
tSQLBinaryExpr
;
struct
SSchema
;
struct
S
CM
Schema
;
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
SSchema
sch
;
// schema of tags
S
CM
Schema
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
SSchema
*
pSchema
;
struct
S
CM
Schema
*
pSchema
;
tVariant
*
pVal
;
};
}
tSQLSyntaxNode
;
...
...
@@ -88,7 +88,7 @@ typedef struct tQueryResultset {
int64_t
num
;
}
tQueryResultset
;
void
tSQLBinaryExprFromString
(
tSQLBinaryExpr
**
pExpr
,
SSchema
*
pSchema
,
int32_t
numOfCols
,
char
*
src
,
int32_t
len
);
void
tSQLBinaryExprFromString
(
tSQLBinaryExpr
**
pExpr
,
S
CM
Schema
*
pSchema
,
int32_t
numOfCols
,
char
*
src
,
int32_t
len
);
void
tSQLBinaryExprToString
(
tSQLBinaryExpr
*
pExpr
,
char
*
dst
,
int32_t
*
len
);
...
...
src/util/inc/textbuffer.h
浏览文件 @
aee99f11
...
...
@@ -72,16 +72,16 @@ typedef struct tFilePagesItem {
tFilePage
item
;
}
tFilePagesItem
;
typedef
struct
SSchemaEx
{
struct
SSchema
field
;
typedef
struct
S
CM
SchemaEx
{
struct
S
CM
Schema
field
;
int16_t
offset
;
}
SSchemaEx
;
}
S
CM
SchemaEx
;
typedef
struct
SColumnModel
{
int32_t
capacity
;
int32_t
numOfCols
;
int16_t
rowSize
;
SSchemaEx
*
pFields
;
S
CM
SchemaEx
*
pFields
;
}
SColumnModel
;
typedef
struct
SColumnOrderInfo
{
...
...
@@ -116,7 +116,7 @@ typedef struct tExtMemBuffer {
}
tExtMemBuffer
;
typedef
struct
tTagSchema
{
struct
SSchema
*
pSchema
;
struct
S
CM
Schema
*
pSchema
;
int32_t
numOfCols
;
int32_t
colOffset
[];
}
tTagSchema
;
...
...
@@ -198,7 +198,7 @@ bool tExtMemBufferIsAllDataInMem(tExtMemBuffer *pMemBuffer);
* @param blockCapacity
* @return
*/
SColumnModel
*
createColumnModel
(
SSchema
*
fields
,
int32_t
numOfCols
,
int32_t
blockCapacity
);
SColumnModel
*
createColumnModel
(
S
CM
Schema
*
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
);
SSchema
*
getColumnModelSchema
(
SColumnModel
*
pColumnModel
,
int32_t
index
);
S
CM
Schema
*
getColumnModelSchema
(
SColumnModel
*
pColumnModel
,
int32_t
index
);
int16_t
getColumnModelOffset
(
SColumnModel
*
pColumnModel
,
int32_t
index
);
...
...
src/util/inc/tschemautil.h
浏览文件 @
aee99f11
...
...
@@ -26,7 +26,7 @@ extern "C" {
#define VALIDNUMOFCOLS(x) ((x) >= TSDB_MIN_COLUMNS && (x) <= TSDB_MAX_COLUMNS)
struct
SSchema
;
struct
S
CM
Schema
;
/**
* check if the schema is valid or not, including following aspects:
...
...
@@ -40,14 +40,14 @@ struct SSchema;
* @param numOfCols
* @return
*/
bool
isValidSchema
(
struct
SSchema
*
pSchema
,
int32_t
numOfCols
);
bool
isValidSchema
(
struct
S
CM
Schema
*
pSchema
,
int32_t
numOfCols
);
struct
SSchema
*
tsGetSchema
(
SMeterMeta
*
pMeta
);
struct
S
CM
Schema
*
tsGetSchema
(
SMeterMeta
*
pMeta
);
struct
SSchema
*
tsGetTagSchema
(
SMeterMeta
*
pMeta
);
struct
S
CM
Schema
*
tsGetTagSchema
(
SMeterMeta
*
pMeta
);
struct
SSchema
*
tsGetColumnSchema
(
SMeterMeta
*
pMeta
,
int32_t
startCol
);
struct
SSchema
tsGetTbnameColumnSchema
();
struct
S
CM
Schema
*
tsGetColumnSchema
(
SMeterMeta
*
pMeta
,
int32_t
startCol
);
struct
S
CM
Schema
tsGetTbnameColumnSchema
();
char
*
tsGetTagsValue
(
SMeterMeta
*
pMeta
);
...
...
src/util/src/textbuffer.c
浏览文件 @
aee99f11
...
...
@@ -468,7 +468,7 @@ int32_t compare_a(tOrderDescriptor *pDescriptor, int32_t numOfRows1, int32_t s1,
return
ret
;
}
}
else
{
SSchema
*
pSchema
=
&
pDescriptor
->
pColumnModel
->
pFields
[
colIdx
];
S
CM
Schema
*
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
{
SSchema
*
pSchema
=
&
pDescriptor
->
pColumnModel
->
pFields
[
colIdx
];
S
CM
Schema
*
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
);
SSchema
*
pSchema
=
&
pColumnModel
->
pFields
[
i
].
field
;
S
CM
Schema
*
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
(
SSchema
*
fields
,
int32_t
numOfCols
,
int32_t
blockCapacity
)
{
SColumnModel
*
pColumnModel
=
(
SColumnModel
*
)
calloc
(
1
,
sizeof
(
SColumnModel
)
+
numOfCols
*
sizeof
(
SSchemaEx
));
SColumnModel
*
createColumnModel
(
S
CM
Schema
*
fields
,
int32_t
numOfCols
,
int32_t
blockCapacity
)
{
SColumnModel
*
pColumnModel
=
(
SColumnModel
*
)
calloc
(
1
,
sizeof
(
SColumnModel
)
+
numOfCols
*
sizeof
(
S
CM
SchemaEx
));
if
(
pColumnModel
==
NULL
)
{
return
NULL
;
}
pColumnModel
->
pFields
=
(
SSchemaEx
*
)(
&
pColumnModel
[
1
]);
pColumnModel
->
pFields
=
(
S
CM
SchemaEx
*
)(
&
pColumnModel
[
1
]);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SSchemaEx
*
pSchemaEx
=
&
pColumnModel
->
pFields
[
i
];
S
CM
SchemaEx
*
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
(
SSchemaEx
));
SColumnModel
*
pColumnModel
=
(
SColumnModel
*
)
calloc
(
1
,
sizeof
(
SColumnModel
)
+
pSrc
->
numOfCols
*
sizeof
(
S
CM
SchemaEx
));
if
(
pColumnModel
==
NULL
)
{
return
NULL
;
}
*
pColumnModel
=
*
pSrc
;
pColumnModel
->
pFields
=
(
SSchemaEx
*
)
(
&
pColumnModel
[
1
]);
memcpy
(
pColumnModel
->
pFields
,
pSrc
->
pFields
,
pSrc
->
numOfCols
*
sizeof
(
SSchemaEx
));
pColumnModel
->
pFields
=
(
S
CM
SchemaEx
*
)
(
&
pColumnModel
[
1
]);
memcpy
(
pColumnModel
->
pFields
,
pSrc
->
pFields
,
pSrc
->
numOfCols
*
sizeof
(
S
CM
SchemaEx
));
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
)
{
SSchemaEx
*
pSchemaEx
=
&
pModel
->
pFields
[
i
];
S
CM
SchemaEx
*
pSchemaEx
=
&
pModel
->
pFields
[
i
];
memmove
(
inputBuffer
->
data
+
pSchemaEx
->
offset
*
inputBuffer
->
numOfElems
,
inputBuffer
->
data
+
pSchemaEx
->
offset
*
maxElemsCapacity
,
pSchemaEx
->
field
.
bytes
*
inputBuffer
->
numOfElems
);
}
}
SSchema
*
getColumnModelSchema
(
SColumnModel
*
pColumnModel
,
int32_t
index
)
{
S
CM
Schema
*
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
);
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
S
CM
Schema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
char
*
startPos
=
inputBuffer
->
data
+
offset
*
blockCapacity
+
s
*
pSchema
->
bytes
;
char
*
endPos
=
startPos
+
pSchema
->
bytes
*
removed
;
...
...
src/util/src/tinterpolation.c
浏览文件 @
aee99f11
...
...
@@ -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
)
{
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
S
CM
Schema
*
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
)
{
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
S
CM
Schema
*
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
)
{
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
S
CM
Schema
*
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
)
{
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
S
CM
Schema
*
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
)
{
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
S
CM
Schema
*
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
)
{
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
S
CM
Schema
*
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
);
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
S
CM
Schema
*
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
)
{
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
S
CM
Schema
*
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
);
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
S
CM
Schema
*
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
);
SSchema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
S
CM
Schema
*
pSchema
=
getColumnModelSchema
(
pModel
,
i
);
char
*
val1
=
getPos
(
data
[
i
]
->
data
,
pSchema
->
bytes
,
pInterpoInfo
->
order
,
bufSize
,
num
);
...
...
src/util/src/tpercentile.c
浏览文件 @
aee99f11
...
...
@@ -297,7 +297,7 @@ tMemBucket *tMemBucketCreate(int32_t totalSlots, int32_t nBufferSize, int16_t nE
return
NULL
;
}
SSchema
*
pSchema
=
getColumnModelSchema
(
pDesc
->
pColumnModel
,
0
);
S
CM
Schema
*
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录