sort out connect message from client to mgmt
This commit is contained in:
parent
582e6ed6a5
commit
aee99f114f
|
@ -110,7 +110,7 @@ bool tscQueryMetricTags(SQueryInfo* pQueryInfo);
|
||||||
bool tscIsSelectivityWithTagQuery(SSqlCmd* pCmd);
|
bool tscIsSelectivityWithTagQuery(SSqlCmd* pCmd);
|
||||||
|
|
||||||
void tscAddSpecialColumnForSelect(SQueryInfo* pQueryInfo, int32_t outputColIndex, int16_t functionId, SColumnIndex* pIndex,
|
void tscAddSpecialColumnForSelect(SQueryInfo* pQueryInfo, int32_t outputColIndex, int16_t functionId, SColumnIndex* pIndex,
|
||||||
SSchema* pColSchema, int16_t isTag);
|
SCMSchema* pColSchema, int16_t isTag);
|
||||||
|
|
||||||
void addRequiredTagColumn(SQueryInfo* pQueryInfo, int32_t tagColIndex, int32_t tableIndex);
|
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);
|
int tscAllocPayload(SSqlCmd* pCmd, int size);
|
||||||
|
|
||||||
void tscFieldInfoSetValFromSchema(SFieldInfo* pFieldInfo, int32_t index, SSchema* pSchema);
|
void tscFieldInfoSetValFromSchema(SFieldInfo* pFieldInfo, int32_t index, SCMSchema* pSchema);
|
||||||
void tscFieldInfoSetValFromField(SFieldInfo* pFieldInfo, int32_t index, TAOS_FIELD* pField);
|
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 tscFieldInfoSetValue(SFieldInfo* pFieldInfo, int32_t index, int8_t type, const char* name, int16_t bytes);
|
||||||
void tscFieldInfoUpdateVisible(SFieldInfo* pFieldInfo, int32_t index, bool visible);
|
void tscFieldInfoUpdateVisible(SFieldInfo* pFieldInfo, int32_t index, bool visible);
|
||||||
|
|
|
@ -40,10 +40,10 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static tSQLSyntaxNode *tSQLSyntaxNodeCreate(SSchema *pSchema, int32_t numOfCols, SSQLToken *pToken);
|
static tSQLSyntaxNode *tSQLSyntaxNodeCreate(SCMSchema *pSchema, int32_t numOfCols, SSQLToken *pToken);
|
||||||
static void tSQLSyntaxNodeDestroy(tSQLSyntaxNode *pNode, void (*fp)(void *));
|
static void tSQLSyntaxNodeDestroy(tSQLSyntaxNode *pNode, void (*fp)(void *));
|
||||||
|
|
||||||
static tSQLSyntaxNode *createSyntaxTree(SSchema *pSchema, int32_t numOfCols, char *str, int32_t *i);
|
static tSQLSyntaxNode *createSyntaxTree(SCMSchema *pSchema, int32_t numOfCols, char *str, int32_t *i);
|
||||||
static void destroySyntaxTree(tSQLSyntaxNode *);
|
static void destroySyntaxTree(tSQLSyntaxNode *);
|
||||||
|
|
||||||
static uint8_t isQueryOnPrimaryKey(const char *primaryColumnName, const tSQLSyntaxNode *pLeft,
|
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(SCMSchema *pSchema, int32_t numOfCols, SSQLToken *pToken) {
|
||||||
/* if the token is not a value, return false */
|
/* 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 &&
|
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)) {
|
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(SCMSchema);
|
||||||
|
|
||||||
pNode = calloc(1, nodeSize);
|
pNode = calloc(1, nodeSize);
|
||||||
pNode->pSchema = (struct SSchema *)((char *)pNode + sizeof(tSQLSyntaxNode));
|
pNode->pSchema = (struct SCMSchema *)((char *)pNode + sizeof(tSQLSyntaxNode));
|
||||||
pNode->nodeType = TSQL_NODE_COL;
|
pNode->nodeType = TSQL_NODE_COL;
|
||||||
|
|
||||||
if (pToken->type == TK_ID) {
|
if (pToken->type == TK_ID) {
|
||||||
pNode->colId = (int16_t)pSchema[i].colId;
|
pNode->colId = (int16_t)pSchema[i].colId;
|
||||||
memcpy(pNode->pSchema, &pSchema[i], sizeof(SSchema));
|
memcpy(pNode->pSchema, &pSchema[i], sizeof(SCMSchema));
|
||||||
} else {
|
} else {
|
||||||
pNode->colId = -1;
|
pNode->colId = -1;
|
||||||
pNode->pSchema->type = TSDB_DATA_TYPE_BINARY;
|
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
|
// 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, SCMSchema *pSchema, int32_t optr,
|
||||||
int32_t numOfCols, int32_t *i) {
|
int32_t numOfCols, int32_t *i) {
|
||||||
// set the previous generated node as the left child of new root
|
// set the previous generated node as the left child of new root
|
||||||
tSQLSyntaxNode *pLeft = malloc(sizeof(tSQLSyntaxNode));
|
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(SCMSchema *pSchema, int32_t numOfCols, char *str, int32_t *i) {
|
||||||
SSQLToken t0;
|
SSQLToken t0;
|
||||||
|
|
||||||
t0 = tStrGetToken(str, i, false, 0, NULL);
|
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, SCMSchema *pSchema, int32_t numOfCols, char *src, int32_t len) {
|
||||||
*pExpr = NULL;
|
*pExpr = NULL;
|
||||||
if (len <= 0 || src == NULL || pSchema == NULL || numOfCols <= 0) {
|
if (len <= 0 || src == NULL || pSchema == NULL || numOfCols <= 0) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -2437,7 +2437,7 @@ static bool percentile_function_setup(SQLFunctionCtx *pCtx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SResultInfo *pResInfo = GET_RES_INFO(pCtx);
|
SResultInfo *pResInfo = GET_RES_INFO(pCtx);
|
||||||
SSchema field[1] = {{pCtx->inputType, "dummyCol", 0, pCtx->inputBytes}};
|
SCMSchema field[1] = {{pCtx->inputType, "dummyCol", 0, pCtx->inputBytes}};
|
||||||
|
|
||||||
SColumnModel *pModel = createColumnModel(field, 1, 1000);
|
SColumnModel *pModel = createColumnModel(field, 1, 1000);
|
||||||
int32_t orderIdx = 0;
|
int32_t orderIdx = 0;
|
||||||
|
|
|
@ -85,7 +85,7 @@ static int32_t tscMaxLengthOfTagsFields(SSqlObj *pSql) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char * pTagValue = tsGetTagsValue(pMeta);
|
char * pTagValue = tsGetTagsValue(pMeta);
|
||||||
SSchema *pTagsSchema = tsGetTagSchema(pMeta);
|
SCMSchema *pTagsSchema = tsGetTagSchema(pMeta);
|
||||||
|
|
||||||
int32_t len = getToStringLength(pTagValue, pTagsSchema[0].bytes, pTagsSchema[0].type);
|
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);
|
tscInitResObjForLocalQuery(pSql, totalNumOfRows, rowLen);
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SCMSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||||
TAOS_FIELD *pField = tscFieldInfoGetField(pQueryInfo, 0);
|
TAOS_FIELD *pField = tscFieldInfoGetField(pQueryInfo, 0);
|
||||||
|
@ -286,7 +286,7 @@ static int tscBuildMetricTagProjectionResult(SSqlObj *pSql) {
|
||||||
SMeterMetaInfo *pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, 0);
|
SMeterMetaInfo *pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, 0);
|
||||||
|
|
||||||
SMetricMeta *pMetricMeta = pMeterMetaInfo->pMetricMeta;
|
SMetricMeta *pMetricMeta = pMeterMetaInfo->pMetricMeta;
|
||||||
SSchema * pSchema = tsGetTagSchema(pMeterMetaInfo->pMeterMeta);
|
SCMSchema * pSchema = tsGetTagSchema(pMeterMetaInfo->pMeterMeta);
|
||||||
|
|
||||||
int32_t vOffset[TSDB_MAX_COLUMNS] = {0};
|
int32_t vOffset[TSDB_MAX_COLUMNS] = {0};
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ int tsParseTime(SSQLToken *pToken, int64_t *time, char **next, char *error, int1
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload, char *msg, char **str, bool primaryKey,
|
int32_t tsParseOneColumnData(SCMSchema *pSchema, SSQLToken *pToken, char *payload, char *msg, char **str, bool primaryKey,
|
||||||
int16_t timePrec) {
|
int16_t timePrec) {
|
||||||
int64_t iv;
|
int64_t iv;
|
||||||
int32_t numType;
|
int32_t numType;
|
||||||
|
@ -389,7 +389,7 @@ static int32_t tsCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[], SParsedDataColInfo *spd, char *error,
|
int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SCMSchema schema[], SParsedDataColInfo *spd, char *error,
|
||||||
int16_t timePrec, int32_t *code, char *tmpTokenBuf) {
|
int16_t timePrec, int32_t *code, char *tmpTokenBuf) {
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
// bool isPrevOptr; //fang, never used
|
// 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
|
// the start position in data block buffer of current value in sql
|
||||||
char * start = payload + spd->elems[i].offset;
|
char * start = payload + spd->elems[i].offset;
|
||||||
int16_t colIndex = spd->elems[i].colIndex;
|
int16_t colIndex = spd->elems[i].colIndex;
|
||||||
SSchema *pSchema = schema + colIndex;
|
SCMSchema *pSchema = schema + colIndex;
|
||||||
rowSize += pSchema->bytes;
|
rowSize += pSchema->bytes;
|
||||||
|
|
||||||
index = 0;
|
index = 0;
|
||||||
|
@ -503,7 +503,7 @@ int tsParseValues(char **str, STableDataBlocks *pDataBlock, SMeterMeta *pMeterMe
|
||||||
|
|
||||||
int16_t numOfRows = 0;
|
int16_t numOfRows = 0;
|
||||||
|
|
||||||
SSchema *pSchema = tsGetSchema(pMeterMeta);
|
SCMSchema *pSchema = tsGetSchema(pMeterMeta);
|
||||||
int32_t precision = pMeterMeta->precision;
|
int32_t precision = pMeterMeta->precision;
|
||||||
|
|
||||||
if (spd->hasVal[0] == false) {
|
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, SCMSchema *pSchema, int32_t numOfCols) {
|
||||||
spd->numOfCols = numOfCols;
|
spd->numOfCols = numOfCols;
|
||||||
spd->numOfAssignedCols = 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);
|
return tscInvalidSQLErrMsg(pCmd->payload, "create table only from super table is allowed", sToken.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchema *pTagSchema = tsGetTagSchema(pSTableMeterMetaInfo->pMeterMeta);
|
SCMSchema *pTagSchema = tsGetTagSchema(pSTableMeterMetaInfo->pMeterMeta);
|
||||||
|
|
||||||
index = 0;
|
index = 0;
|
||||||
sToken = tStrGetToken(sql, &index, false, 0, NULL);
|
sToken = tStrGetToken(sql, &index, false, 0, NULL);
|
||||||
|
@ -1094,7 +1094,7 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
|
||||||
|
|
||||||
if (sToken.type == TK_VALUES) {
|
if (sToken.type == TK_VALUES) {
|
||||||
SParsedDataColInfo spd = {.numOfCols = pMeterMetaInfo->pMeterMeta->numOfColumns};
|
SParsedDataColInfo spd = {.numOfCols = pMeterMetaInfo->pMeterMeta->numOfColumns};
|
||||||
SSchema * pSchema = tsGetSchema(pMeterMetaInfo->pMeterMeta);
|
SCMSchema * pSchema = tsGetSchema(pMeterMetaInfo->pMeterMeta);
|
||||||
|
|
||||||
tscSetAssignedColumnInfo(&spd, pSchema, pMeterMetaInfo->pMeterMeta->numOfColumns);
|
tscSetAssignedColumnInfo(&spd, pSchema, pMeterMetaInfo->pMeterMeta->numOfColumns);
|
||||||
|
|
||||||
|
@ -1149,7 +1149,7 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
|
||||||
} else if (sToken.type == TK_LP) {
|
} else if (sToken.type == TK_LP) {
|
||||||
/* insert into tablename(col1, col2,..., coln) values(v1, v2,... vn); */
|
/* insert into tablename(col1, col2,..., coln) values(v1, v2,... vn); */
|
||||||
SMeterMeta *pMeterMeta = tscGetMeterMetaInfo(pCmd, pCmd->clauseIndex, 0)->pMeterMeta;
|
SMeterMeta *pMeterMeta = tscGetMeterMetaInfo(pCmd, pCmd->clauseIndex, 0)->pMeterMeta;
|
||||||
SSchema * pSchema = tsGetSchema(pMeterMeta);
|
SCMSchema * pSchema = tsGetSchema(pMeterMeta);
|
||||||
|
|
||||||
if (validateDataSource(pCmd, DATA_FROM_SQL_STRING, sToken.z) != TSDB_CODE_SUCCESS) {
|
if (validateDataSource(pCmd, DATA_FROM_SQL_STRING, sToken.z) != TSDB_CODE_SUCCESS) {
|
||||||
goto _error_clean;
|
goto _error_clean;
|
||||||
|
@ -1403,7 +1403,7 @@ static int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp, char *tmpTokenBuf) {
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
SParsedDataColInfo spd = {.numOfCols = pMeterMeta->numOfColumns};
|
SParsedDataColInfo spd = {.numOfCols = pMeterMeta->numOfColumns};
|
||||||
SSchema * pSchema = tsGetSchema(pMeterMeta);
|
SCMSchema * pSchema = tsGetSchema(pMeterMeta);
|
||||||
|
|
||||||
tscSetAssignedColumnInfo(&spd, pSchema, pMeterMeta->numOfColumns);
|
tscSetAssignedColumnInfo(&spd, pSchema, pMeterMeta->numOfColumns);
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ static int32_t addProjectionExprAndResultField(SQueryInfo* pQueryInfo, tSQLExprI
|
||||||
|
|
||||||
static int32_t parseWhereClause(SQueryInfo* pQueryInfo, tSQLExpr** pExpr, SSqlObj* pSql);
|
static int32_t parseWhereClause(SQueryInfo* pQueryInfo, tSQLExpr** pExpr, SSqlObj* pSql);
|
||||||
static int32_t parseFillClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySQL);
|
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, SCMSchema* pSchema);
|
||||||
|
|
||||||
static int32_t tsRewriteFieldNameIfNecessary(SQueryInfo* pQueryInfo);
|
static int32_t tsRewriteFieldNameIfNecessary(SQueryInfo* pQueryInfo);
|
||||||
static int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo);
|
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 getMeterIndex(SSQLToken* pTableToken, SQueryInfo* pQueryInfo, SColumnIndex* pIndex);
|
||||||
static int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo);
|
static int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo);
|
||||||
static int32_t doLocalQueryProcess(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql);
|
static int32_t doLocalQueryProcess(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql);
|
||||||
static int32_t tscCheckCreateDbParams(SSqlCmd* pCmd, SCreateDbMsg* pCreate);
|
static int32_t tscCheckCreateDbParams(SSqlCmd* pCmd, SCMCreateDbMsg* pCreate);
|
||||||
|
|
||||||
static SColumnList getColumnList(int32_t num, int16_t tableIndex, int32_t columnIndex);
|
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;
|
char* pMsg = pCmd->payload + tsRpcHeadSize;
|
||||||
pMsg += sizeof(SMgmtHead);
|
pMsg += sizeof(SMgmtHead);
|
||||||
|
|
||||||
SCfgMsg* pCfg = (SCfgMsg*)pMsg;
|
SCMCfgDnodeMsg* pCfg = (SCMCfgDnodeMsg*)pMsg;
|
||||||
strncpy(pCfg->ip, pDCL->a[0].z, pDCL->a[0].n);
|
strncpy(pCfg->ip, pDCL->a[0].z, pDCL->a[0].n);
|
||||||
|
|
||||||
strncpy(pCfg->config, pDCL->a[1].z, pDCL->a[1].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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchema* pTagSchema = tsGetTagSchema(pMeterMetaInfo->pMeterMeta);
|
SCMSchema* pTagSchema = tsGetTagSchema(pMeterMetaInfo->pMeterMeta);
|
||||||
int32_t nLen = 0;
|
int32_t nLen = 0;
|
||||||
|
|
||||||
for (int32_t i = 0; i < pMeterMeta->numOfTags; ++i) {
|
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
|
// field name must be unique
|
||||||
SSchema* pSchema = tsGetSchema(pMeterMeta);
|
SCMSchema* pSchema = tsGetSchema(pMeterMeta);
|
||||||
|
|
||||||
for (int32_t i = 0; i < pMeterMeta->numOfTags + pMeterMeta->numOfColumns; ++i) {
|
for (int32_t i = 0; i < pMeterMeta->numOfTags + pMeterMeta->numOfColumns; ++i) {
|
||||||
if (strncasecmp(pTagField->name, pSchema[i].name, TSDB_COL_NAME_LEN) == 0) {
|
if (strncasecmp(pTagField->name, pSchema[i].name, TSDB_COL_NAME_LEN) == 0) {
|
||||||
|
@ -972,7 +972,7 @@ bool validateOneColumn(SSqlCmd* pCmd, TAOS_FIELD* pColField) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchema* pSchema = tsGetSchema(pMeterMeta);
|
SCMSchema* pSchema = tsGetSchema(pMeterMeta);
|
||||||
int32_t nLen = 0;
|
int32_t nLen = 0;
|
||||||
|
|
||||||
for (int32_t i = 0; i < pMeterMeta->numOfColumns; ++i) {
|
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);
|
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, tableIndex);
|
||||||
SMeterMeta* pMeterMeta = pMeterMetaInfo->pMeterMeta;
|
SMeterMeta* pMeterMeta = pMeterMetaInfo->pMeterMeta;
|
||||||
|
|
||||||
SSchema* pSchema = tsGetColumnSchema(pMeterMeta, colIdx);
|
SCMSchema* pSchema = tsGetColumnSchema(pMeterMeta, colIdx);
|
||||||
int32_t numOfCols = pMeterMeta->numOfColumns;
|
int32_t numOfCols = pMeterMeta->numOfColumns;
|
||||||
|
|
||||||
int16_t functionId = (int16_t)((colIdx >= numOfCols) ? TSDB_FUNC_TAGPRJ : TSDB_FUNC_PRJ);
|
int16_t functionId = (int16_t)((colIdx >= numOfCols) ? TSDB_FUNC_TAGPRJ : TSDB_FUNC_PRJ);
|
||||||
|
@ -1269,7 +1269,7 @@ static void addProjectQueryCol(SQueryInfo* pQueryInfo, int32_t startPos, SColumn
|
||||||
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, pIndex->tableIndex);
|
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, pIndex->tableIndex);
|
||||||
SMeterMeta* pMeterMeta = pMeterMetaInfo->pMeterMeta;
|
SMeterMeta* pMeterMeta = pMeterMetaInfo->pMeterMeta;
|
||||||
|
|
||||||
SSchema* pSchema = tsGetColumnSchema(pMeterMeta, pIndex->columnIndex);
|
SCMSchema* pSchema = tsGetColumnSchema(pMeterMeta, pIndex->columnIndex);
|
||||||
|
|
||||||
char* colName = (pItem->aliasName == NULL) ? pSchema->name : pItem->aliasName;
|
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,
|
void tscAddSpecialColumnForSelect(SQueryInfo* pQueryInfo, int32_t outputColIndex, int16_t functionId,
|
||||||
SColumnIndex* pIndex, SSchema* pColSchema, int16_t flag) {
|
SColumnIndex* pIndex, SCMSchema* pColSchema, int16_t flag) {
|
||||||
SSqlExpr* pExpr = tscSqlExprInsert(pQueryInfo, outputColIndex, functionId, pIndex, pColSchema->type,
|
SSqlExpr* pExpr = tscSqlExprInsert(pQueryInfo, outputColIndex, functionId, pIndex, pColSchema->type,
|
||||||
pColSchema->bytes, pColSchema->bytes);
|
pColSchema->bytes, pColSchema->bytes);
|
||||||
|
|
||||||
|
@ -1307,7 +1307,7 @@ static int32_t doAddProjectionExprAndResultFields(SQueryInfo* pQueryInfo, SColum
|
||||||
|
|
||||||
int32_t numOfTotalColumns = 0;
|
int32_t numOfTotalColumns = 0;
|
||||||
SMeterMeta* pMeterMeta = pMeterMetaInfo->pMeterMeta;
|
SMeterMeta* pMeterMeta = pMeterMetaInfo->pMeterMeta;
|
||||||
SSchema* pSchema = tsGetSchema(pMeterMeta);
|
SCMSchema* pSchema = tsGetSchema(pMeterMeta);
|
||||||
|
|
||||||
if (UTIL_METER_IS_SUPERTABLE(pMeterMetaInfo)) {
|
if (UTIL_METER_IS_SUPERTABLE(pMeterMetaInfo)) {
|
||||||
numOfTotalColumns = pMeterMeta->numOfColumns + pMeterMeta->numOfTags;
|
numOfTotalColumns = pMeterMeta->numOfColumns + pMeterMeta->numOfTags;
|
||||||
|
@ -1361,7 +1361,7 @@ int32_t addProjectionExprAndResultField(SQueryInfo* pQueryInfo, tSQLExprItem* pI
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) {
|
if (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) {
|
||||||
SSchema colSchema = {.type = TSDB_DATA_TYPE_BINARY, .bytes = TSDB_METER_NAME_LEN};
|
SCMSchema colSchema = {.type = TSDB_DATA_TYPE_BINARY, .bytes = TSDB_METER_NAME_LEN};
|
||||||
strcpy(colSchema.name, TSQL_TBNAME_L);
|
strcpy(colSchema.name, TSQL_TBNAME_L);
|
||||||
|
|
||||||
pQueryInfo->type = TSDB_QUERY_TYPE_STABLE_QUERY;
|
pQueryInfo->type = TSDB_QUERY_TYPE_STABLE_QUERY;
|
||||||
|
@ -1383,7 +1383,7 @@ int32_t addProjectionExprAndResultField(SQueryInfo* pQueryInfo, tSQLExprItem* pI
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t setExprInfoForFunctions(SQueryInfo* pQueryInfo, SSchema* pSchema, int32_t functionID, char* aliasName,
|
static int32_t setExprInfoForFunctions(SQueryInfo* pQueryInfo, SCMSchema* pSchema, int32_t functionID, char* aliasName,
|
||||||
int32_t resColIdx, SColumnIndex* pColIndex) {
|
int32_t resColIdx, SColumnIndex* pColIndex) {
|
||||||
int16_t type = 0;
|
int16_t type = 0;
|
||||||
int16_t bytes = 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
|
// 2. check if sql function can be applied on this column data type
|
||||||
pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, index.tableIndex);
|
pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, index.tableIndex);
|
||||||
SSchema* pSchema = tsGetColumnSchema(pMeterMetaInfo->pMeterMeta, index.columnIndex);
|
SCMSchema* pSchema = tsGetColumnSchema(pMeterMetaInfo->pMeterMeta, index.columnIndex);
|
||||||
int16_t colType = pSchema->type;
|
int16_t colType = pSchema->type;
|
||||||
|
|
||||||
if (colType <= TSDB_DATA_TYPE_BOOL || colType >= TSDB_DATA_TYPE_BINARY) {
|
if (colType <= TSDB_DATA_TYPE_BOOL || colType >= TSDB_DATA_TYPE_BINARY) {
|
||||||
|
@ -1637,7 +1637,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
|
||||||
}
|
}
|
||||||
|
|
||||||
pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, index.tableIndex);
|
pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, index.tableIndex);
|
||||||
SSchema* pSchema = tsGetSchema(pMeterMetaInfo->pMeterMeta);
|
SCMSchema* pSchema = tsGetSchema(pMeterMetaInfo->pMeterMeta);
|
||||||
|
|
||||||
for (int32_t j = 0; j < pMeterMetaInfo->pMeterMeta->numOfColumns; ++j) {
|
for (int32_t j = 0; j < pMeterMetaInfo->pMeterMeta->numOfColumns; ++j) {
|
||||||
index.columnIndex = j;
|
index.columnIndex = j;
|
||||||
|
@ -1652,7 +1652,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
|
||||||
}
|
}
|
||||||
|
|
||||||
pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, index.tableIndex);
|
pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, index.tableIndex);
|
||||||
SSchema* pSchema = tsGetSchema(pMeterMetaInfo->pMeterMeta);
|
SCMSchema* pSchema = tsGetSchema(pMeterMetaInfo->pMeterMeta);
|
||||||
|
|
||||||
// functions can not be applied to tags
|
// functions can not be applied to tags
|
||||||
if ((index.columnIndex >= pMeterMetaInfo->pMeterMeta->numOfColumns) || (index.columnIndex < 0)) {
|
if ((index.columnIndex >= 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) {
|
for (int32_t j = 0; j < pQueryInfo->numOfTables; ++j) {
|
||||||
pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, j);
|
pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, j);
|
||||||
SSchema* pSchema = tsGetSchema(pMeterMetaInfo->pMeterMeta);
|
SCMSchema* pSchema = tsGetSchema(pMeterMetaInfo->pMeterMeta);
|
||||||
|
|
||||||
for (int32_t i = 0; i < pMeterMetaInfo->pMeterMeta->numOfColumns; ++i) {
|
for (int32_t i = 0; i < pMeterMetaInfo->pMeterMeta->numOfColumns; ++i) {
|
||||||
SColumnIndex index = {.tableIndex = j, .columnIndex = 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);
|
pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, index.tableIndex);
|
||||||
SSchema* pSchema = tsGetSchema(pMeterMetaInfo->pMeterMeta);
|
SCMSchema* pSchema = tsGetSchema(pMeterMetaInfo->pMeterMeta);
|
||||||
|
|
||||||
// functions can not be applied to tags
|
// functions can not be applied to tags
|
||||||
if (index.columnIndex >= pMeterMetaInfo->pMeterMeta->numOfColumns) {
|
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;
|
SMeterMeta* pMeterMeta = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, index)->pMeterMeta;
|
||||||
|
|
||||||
int32_t numOfCols = pMeterMeta->numOfColumns + pMeterMeta->numOfTags;
|
int32_t numOfCols = pMeterMeta->numOfColumns + pMeterMeta->numOfTags;
|
||||||
SSchema* pSchema = tsGetSchema(pMeterMeta);
|
SCMSchema* pSchema = tsGetSchema(pMeterMeta);
|
||||||
|
|
||||||
int16_t columnIndex = COLUMN_INDEX_INITIAL_VAL;
|
int16_t columnIndex = COLUMN_INDEX_INITIAL_VAL;
|
||||||
|
|
||||||
|
@ -2361,8 +2361,8 @@ int32_t parseGroupbyClause(SQueryInfo* pQueryInfo, tVariantList* pList, SSqlCmd*
|
||||||
}
|
}
|
||||||
|
|
||||||
SMeterMeta* pMeterMeta = NULL;
|
SMeterMeta* pMeterMeta = NULL;
|
||||||
SSchema* pSchema = NULL;
|
SCMSchema* pSchema = NULL;
|
||||||
SSchema s = tsGetTbnameColumnSchema();
|
SCMSchema s = tsGetTbnameColumnSchema();
|
||||||
|
|
||||||
int32_t tableIndex = COLUMN_INDEX_INITIAL_VAL;
|
int32_t tableIndex = COLUMN_INDEX_INITIAL_VAL;
|
||||||
|
|
||||||
|
@ -2465,7 +2465,7 @@ static int32_t doExtractColumnFilterInfo(SQueryInfo* pQueryInfo, SColumnFilterIn
|
||||||
tSQLExpr* pRight = pExpr->pRight;
|
tSQLExpr* pRight = pExpr->pRight;
|
||||||
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, columnIndex->tableIndex);
|
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, columnIndex->tableIndex);
|
||||||
|
|
||||||
SSchema* pSchema = tsGetColumnSchema(pMeterMetaInfo->pMeterMeta, columnIndex->columnIndex);
|
SCMSchema* pSchema = tsGetColumnSchema(pMeterMetaInfo->pMeterMeta, columnIndex->columnIndex);
|
||||||
|
|
||||||
int16_t colType = pSchema->type;
|
int16_t colType = pSchema->type;
|
||||||
if (colType >= TSDB_DATA_TYPE_TINYINT && colType <= TSDB_DATA_TYPE_BIGINT) {
|
if (colType >= TSDB_DATA_TYPE_TINYINT && colType <= TSDB_DATA_TYPE_BIGINT) {
|
||||||
|
@ -2705,7 +2705,7 @@ static int32_t extractColumnFilterInfo(SQueryInfo* pQueryInfo, SColumnIndex* pIn
|
||||||
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, pIndex->tableIndex);
|
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, pIndex->tableIndex);
|
||||||
|
|
||||||
SMeterMeta* pMeterMeta = pMeterMetaInfo->pMeterMeta;
|
SMeterMeta* pMeterMeta = pMeterMetaInfo->pMeterMeta;
|
||||||
SSchema* pSchema = tsGetColumnSchema(pMeterMeta, pIndex->columnIndex);
|
SCMSchema* pSchema = tsGetColumnSchema(pMeterMeta, pIndex->columnIndex);
|
||||||
|
|
||||||
const char* msg1 = "non binary column not support like operator";
|
const char* msg1 = "non binary column not support like operator";
|
||||||
const char* msg2 = "binary column not support this operator";
|
const char* msg2 = "binary column not support this operator";
|
||||||
|
@ -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
|
// if column is timestamp, bool, binary, nchar, not support arithmetic, so return invalid sql
|
||||||
SMeterMeta* pMeterMeta = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, index.tableIndex)->pMeterMeta;
|
SMeterMeta* pMeterMeta = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, index.tableIndex)->pMeterMeta;
|
||||||
SSchema* pSchema = tsGetSchema(pMeterMeta) + index.columnIndex;
|
SCMSchema* pSchema = tsGetSchema(pMeterMeta) + index.columnIndex;
|
||||||
if ((pSchema->type == TSDB_DATA_TYPE_TIMESTAMP) || (pSchema->type == TSDB_DATA_TYPE_BOOL)
|
if ((pSchema->type == TSDB_DATA_TYPE_TIMESTAMP) || (pSchema->type == TSDB_DATA_TYPE_BOOL)
|
||||||
|| (pSchema->type == TSDB_DATA_TYPE_BINARY) || (pSchema->type == TSDB_DATA_TYPE_NCHAR)){
|
|| (pSchema->type == TSDB_DATA_TYPE_BINARY) || (pSchema->type == TSDB_DATA_TYPE_NCHAR)){
|
||||||
return TSDB_CODE_INVALID_SQL;
|
return TSDB_CODE_INVALID_SQL;
|
||||||
|
@ -3064,11 +3064,11 @@ static bool validateJoinExprNode(SQueryInfo* pQueryInfo, tSQLExpr* pExpr, SColum
|
||||||
|
|
||||||
// todo extract function
|
// todo extract function
|
||||||
SMeterMetaInfo* pLeftMeterMeta = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, pLeftIndex->tableIndex);
|
SMeterMetaInfo* pLeftMeterMeta = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, pLeftIndex->tableIndex);
|
||||||
SSchema* pLeftSchema = tsGetSchema(pLeftMeterMeta->pMeterMeta);
|
SCMSchema* pLeftSchema = tsGetSchema(pLeftMeterMeta->pMeterMeta);
|
||||||
int16_t leftType = pLeftSchema[pLeftIndex->columnIndex].type;
|
int16_t leftType = pLeftSchema[pLeftIndex->columnIndex].type;
|
||||||
|
|
||||||
SMeterMetaInfo* pRightMeterMeta = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, rightIndex.tableIndex);
|
SMeterMetaInfo* pRightMeterMeta = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, rightIndex.tableIndex);
|
||||||
SSchema* pRightSchema = tsGetSchema(pRightMeterMeta->pMeterMeta);
|
SCMSchema* pRightSchema = tsGetSchema(pRightMeterMeta->pMeterMeta);
|
||||||
int16_t rightType = pRightSchema[rightIndex.columnIndex].type;
|
int16_t rightType = pRightSchema[rightIndex.columnIndex].type;
|
||||||
|
|
||||||
if (leftType != rightType) {
|
if (leftType != rightType) {
|
||||||
|
@ -3176,7 +3176,7 @@ static int32_t handleExprInQueryCond(SQueryInfo* pQueryInfo, tSQLExpr** pExpr, S
|
||||||
return TSDB_CODE_INVALID_SQL;
|
return TSDB_CODE_INVALID_SQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchema* pSchema = tsGetSchema(pMeterMetaInfo->pMeterMeta);
|
SCMSchema* pSchema = tsGetSchema(pMeterMetaInfo->pMeterMeta);
|
||||||
|
|
||||||
if ((!isTablenameToken(&pLeft->colInfo)) && pSchema[index.columnIndex].type != TSDB_DATA_TYPE_BINARY &&
|
if ((!isTablenameToken(&pLeft->colInfo)) && pSchema[index.columnIndex].type != TSDB_DATA_TYPE_BINARY &&
|
||||||
pSchema[index.columnIndex].type != TSDB_DATA_TYPE_NCHAR) {
|
pSchema[index.columnIndex].type != TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
@ -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, SCMSchema* pSchema) {
|
||||||
const char* msg0 = "only support order by primary timestamp";
|
const char* msg0 = "only support order by primary timestamp";
|
||||||
const char* msg1 = "invalid column name";
|
const char* msg1 = "invalid column name";
|
||||||
const char* msg2 = "only support order by primary timestamp and queried column";
|
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);
|
return invalidSqlErrMsg(pQueryInfo->msg, msg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchema* pTagsSchema = tsGetColumnSchema(pMeterMetaInfo->pMeterMeta, columnIndex.columnIndex);
|
SCMSchema* pTagsSchema = tsGetColumnSchema(pMeterMetaInfo->pMeterMeta, columnIndex.columnIndex);
|
||||||
if (tVariantDump(&pVarList->a[1].pVar, pAlterSQL->tagData.data /*pCmd->payload*/, pTagsSchema->type) !=
|
if (tVariantDump(&pVarList->a[1].pVar, pAlterSQL->tagData.data /*pCmd->payload*/, pTagsSchema->type) !=
|
||||||
TSDB_CODE_SUCCESS) {
|
TSDB_CODE_SUCCESS) {
|
||||||
return invalidSqlErrMsg(pQueryInfo->msg, msg1);
|
return invalidSqlErrMsg(pQueryInfo->msg, msg1);
|
||||||
|
@ -4573,7 +4573,7 @@ int32_t parseLimitClause(SQueryInfo* pQueryInfo, int32_t clauseIndex, SQuerySQL*
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t setKeepOption(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreateDBInfo* pCreateDb) {
|
static int32_t setKeepOption(SSqlCmd* pCmd, SCMCreateDbMsg* pMsg, SCreateDBInfo* pCreateDb) {
|
||||||
const char* msg = "invalid number of options";
|
const char* msg = "invalid number of options";
|
||||||
|
|
||||||
pMsg->daysToKeep = htonl(-1);
|
pMsg->daysToKeep = htonl(-1);
|
||||||
|
@ -4604,7 +4604,7 @@ static int32_t setKeepOption(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreateDBInfo* p
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t setTimePrecisionOption(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreateDBInfo* pCreateDbInfo) {
|
static int32_t setTimePrecisionOption(SSqlCmd* pCmd, SCMCreateDbMsg* pMsg, SCreateDBInfo* pCreateDbInfo) {
|
||||||
const char* msg = "invalid time precision";
|
const char* msg = "invalid time precision";
|
||||||
|
|
||||||
pMsg->precision = TSDB_TIME_PRECISION_MILLI; // millisecond by default
|
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;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setCreateDBOption(SCreateDbMsg* pMsg, SCreateDBInfo* pCreateDb) {
|
static void setCreateDBOption(SCMCreateDbMsg* pMsg, SCreateDBInfo* pCreateDb) {
|
||||||
pMsg->blocksPerMeter = htons(pCreateDb->numOfBlocksPerTable);
|
pMsg->blocksPerMeter = htons(pCreateDb->numOfBlocksPerTable);
|
||||||
pMsg->compression = pCreateDb->compressionLevel;
|
pMsg->compression = pCreateDb->compressionLevel;
|
||||||
|
|
||||||
|
@ -4643,7 +4643,7 @@ static void setCreateDBOption(SCreateDbMsg* pMsg, SCreateDBInfo* pCreateDb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t parseCreateDBOptions(SSqlCmd* pCmd, SCreateDBInfo* pCreateDbSql) {
|
int32_t parseCreateDBOptions(SSqlCmd* pCmd, SCreateDBInfo* pCreateDbSql) {
|
||||||
SCreateDbMsg* pMsg = (SCreateDbMsg*)(pCmd->payload + tsRpcHeadSize + sizeof(SMgmtHead));
|
SCMCreateDbMsg* pMsg = (SCMCreateDbMsg*)(pCmd->payload + tsRpcHeadSize + sizeof(SMgmtHead));
|
||||||
setCreateDBOption(pMsg, pCreateDbSql);
|
setCreateDBOption(pMsg, pCreateDbSql);
|
||||||
|
|
||||||
if (setKeepOption(pCmd, pMsg, pCreateDbSql) != TSDB_CODE_SUCCESS) {
|
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);
|
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, tableIndex);
|
||||||
int16_t columnInfo = tscGetJoinTagColIndexByUid(&pQueryInfo->tagCond, pMeterMetaInfo->pMeterMeta->uid);
|
int16_t columnInfo = tscGetJoinTagColIndexByUid(&pQueryInfo->tagCond, pMeterMetaInfo->pMeterMeta->uid);
|
||||||
SColumnIndex index = {.tableIndex = 0, .columnIndex = columnInfo};
|
SColumnIndex index = {.tableIndex = 0, .columnIndex = columnInfo};
|
||||||
SSchema* pSchema = tsGetTagSchema(pMeterMetaInfo->pMeterMeta);
|
SCMSchema* pSchema = tsGetTagSchema(pMeterMetaInfo->pMeterMeta);
|
||||||
|
|
||||||
int16_t type = pSchema[index.columnIndex].type;
|
int16_t type = pSchema[index.columnIndex].type;
|
||||||
int16_t bytes = pSchema[index.columnIndex].bytes;
|
int16_t bytes = pSchema[index.columnIndex].bytes;
|
||||||
|
@ -4730,7 +4730,7 @@ void doAddGroupColumnForSubquery(SQueryInfo* pQueryInfo, int32_t tagIndex) {
|
||||||
|
|
||||||
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, 0);
|
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, 0);
|
||||||
|
|
||||||
SSchema* pSchema = tsGetColumnSchema(pMeterMetaInfo->pMeterMeta, index);
|
SCMSchema* pSchema = tsGetColumnSchema(pMeterMetaInfo->pMeterMeta, index);
|
||||||
SColumnIndex colIndex = {.tableIndex = 0, .columnIndex = index};
|
SColumnIndex colIndex = {.tableIndex = 0, .columnIndex = index};
|
||||||
|
|
||||||
SSqlExpr* pExpr = tscSqlExprInsert(pQueryInfo, pQueryInfo->fieldsInfo.numOfOutputCols, TSDB_FUNC_PRJ, &colIndex,
|
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);
|
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, 0);
|
||||||
SSchema* pSchema = tsGetSchema(pMeterMetaInfo->pMeterMeta);
|
SCMSchema* pSchema = tsGetSchema(pMeterMetaInfo->pMeterMeta);
|
||||||
|
|
||||||
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutputCols; ++i) {
|
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutputCols; ++i) {
|
||||||
SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i);
|
SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||||
if (pExpr->functionId != TSDB_FUNC_TAG_DUMMY && pExpr->functionId != TSDB_FUNC_TS_DUMMY) {
|
if (pExpr->functionId != TSDB_FUNC_TAG_DUMMY && pExpr->functionId != TSDB_FUNC_TS_DUMMY) {
|
||||||
SSchema* pColSchema = &pSchema[pExpr->colInfo.colIdx];
|
SCMSchema* pColSchema = &pSchema[pExpr->colInfo.colIdx];
|
||||||
getResultDataInfo(pColSchema->type, pColSchema->bytes, pExpr->functionId, pExpr->param[0].i64Key, &pExpr->resType,
|
getResultDataInfo(pColSchema->type, pColSchema->bytes, pExpr->functionId, pExpr->param[0].i64Key, &pExpr->resType,
|
||||||
&pExpr->resBytes, &pExpr->interResBytes, tagLength, true);
|
&pExpr->resBytes, &pExpr->interResBytes, tagLength, true);
|
||||||
}
|
}
|
||||||
|
@ -4940,7 +4940,7 @@ static int32_t doAddGroupbyColumnsOnDemand(SQueryInfo* pQueryInfo) {
|
||||||
|
|
||||||
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, 0);
|
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, 0);
|
||||||
|
|
||||||
SSchema* pSchema = tsGetSchema(pMeterMetaInfo->pMeterMeta);
|
SCMSchema* pSchema = tsGetSchema(pMeterMetaInfo->pMeterMeta);
|
||||||
int16_t bytes = 0;
|
int16_t bytes = 0;
|
||||||
int16_t type = 0;
|
int16_t type = 0;
|
||||||
char* name = NULL;
|
char* name = NULL;
|
||||||
|
@ -5138,7 +5138,7 @@ int32_t doLocalQueryProcess(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// can only perform the parameters based on the macro definitation
|
// can only perform the parameters based on the macro definitation
|
||||||
int32_t tscCheckCreateDbParams(SSqlCmd* pCmd, SCreateDbMsg* pCreate) {
|
int32_t tscCheckCreateDbParams(SSqlCmd* pCmd, SCMCreateDbMsg* pCreate) {
|
||||||
char msg[512] = {0};
|
char msg[512] = {0};
|
||||||
|
|
||||||
if (pCreate->commitLog != -1 && (pCreate->commitLog < 0 || pCreate->commitLog > 1)) {
|
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
|
// too long tag values will return invalid sql, not be truncated automatically
|
||||||
SSchema* pTagSchema = tsGetTagSchema(pStableMeterMetaInfo->pMeterMeta);
|
SCMSchema* pTagSchema = tsGetTagSchema(pStableMeterMetaInfo->pMeterMeta);
|
||||||
|
|
||||||
char* tagVal = pCreateTable->usingInfo.tagdata.data;
|
char* tagVal = pCreateTable->usingInfo.tagdata.data;
|
||||||
for (int32_t i = 0; i < pList->nExpr; ++i) {
|
for (int32_t i = 0; i < pList->nExpr; ++i) {
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "ttypes.h"
|
#include "ttypes.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
|
|
||||||
bool isValidSchema(struct SSchema* pSchema, int32_t numOfCols) {
|
bool isValidSchema(struct SCMSchema* pSchema, int32_t numOfCols) {
|
||||||
if (!VALIDNUMOFCOLS(numOfCols)) {
|
if (!VALIDNUMOFCOLS(numOfCols)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -64,14 +64,14 @@ bool isValidSchema(struct SSchema* pSchema, int32_t numOfCols) {
|
||||||
return (rowLen <= TSDB_MAX_BYTES_PER_ROW);
|
return (rowLen <= TSDB_MAX_BYTES_PER_ROW);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SSchema* tsGetSchema(SMeterMeta* pMeta) {
|
struct SCMSchema* tsGetSchema(SMeterMeta* pMeta) {
|
||||||
if (pMeta == NULL) {
|
if (pMeta == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return tsGetColumnSchema(pMeta, 0);
|
return tsGetColumnSchema(pMeta, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SSchema* tsGetTagSchema(SMeterMeta* pMeta) {
|
struct SCMSchema* tsGetTagSchema(SMeterMeta* pMeta) {
|
||||||
if (pMeta == NULL || pMeta->numOfTags == 0) {
|
if (pMeta == NULL || pMeta->numOfTags == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -79,12 +79,12 @@ struct SSchema* tsGetTagSchema(SMeterMeta* pMeta) {
|
||||||
return tsGetColumnSchema(pMeta, pMeta->numOfColumns);
|
return tsGetColumnSchema(pMeta, pMeta->numOfColumns);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SSchema* tsGetColumnSchema(SMeterMeta* pMeta, int32_t startCol) {
|
struct SCMSchema* tsGetColumnSchema(SMeterMeta* pMeta, int32_t startCol) {
|
||||||
return (SSchema*)(((char*)pMeta + sizeof(SMeterMeta)) + startCol * sizeof(SSchema));
|
return (SCMSchema*)(((char*)pMeta + sizeof(SMeterMeta)) + startCol * sizeof(SCMSchema));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SSchema tsGetTbnameColumnSchema() {
|
struct SCMSchema tsGetTbnameColumnSchema() {
|
||||||
struct SSchema s = {.colId = TSDB_TBNAME_COLUMN_INDEX, .type = TSDB_DATA_TYPE_BINARY, .bytes = TSDB_METER_NAME_LEN};
|
struct SCMSchema s = {.colId = TSDB_TBNAME_COLUMN_INDEX, .type = TSDB_DATA_TYPE_BINARY, .bytes = TSDB_METER_NAME_LEN};
|
||||||
strcpy(s.name, TSQL_TBNAME_L);
|
strcpy(s.name, TSQL_TBNAME_L);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
@ -96,7 +96,7 @@ struct SSchema tsGetTbnameColumnSchema() {
|
||||||
* +--------------------+
|
* +--------------------+
|
||||||
* |SMeterMeta Body data| sizeof(SMeterMeta)
|
* |SMeterMeta Body data| sizeof(SMeterMeta)
|
||||||
* +--------------------+
|
* +--------------------+
|
||||||
* |Schema data | numOfTotalColumns * sizeof(SSchema)
|
* |Schema data | numOfTotalColumns * sizeof(SCMSchema)
|
||||||
* +--------------------+
|
* +--------------------+
|
||||||
* |Tags data | tag_col_1.bytes + tag_col_2.bytes + ....
|
* |Tags data | tag_col_1.bytes + tag_col_2.bytes + ....
|
||||||
* +--------------------+
|
* +--------------------+
|
||||||
|
@ -106,7 +106,7 @@ struct SSchema tsGetTbnameColumnSchema() {
|
||||||
*/
|
*/
|
||||||
char* tsGetTagsValue(SMeterMeta* pMeta) {
|
char* tsGetTagsValue(SMeterMeta* pMeta) {
|
||||||
int32_t numOfTotalCols = pMeta->numOfColumns + pMeta->numOfTags;
|
int32_t numOfTotalCols = pMeta->numOfColumns + pMeta->numOfTags;
|
||||||
uint32_t offset = sizeof(SMeterMeta) + numOfTotalCols * sizeof(SSchema);
|
uint32_t offset = sizeof(SMeterMeta) + numOfTotalCols * sizeof(SCMSchema);
|
||||||
|
|
||||||
return ((char*)pMeta + offset);
|
return ((char*)pMeta + offset);
|
||||||
}
|
}
|
||||||
|
@ -120,10 +120,10 @@ bool tsMeterMetaIdentical(SMeterMeta* p1, SMeterMeta* p2) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t size = sizeof(SMeterMeta) + p1->numOfColumns * sizeof(SSchema);
|
size_t size = sizeof(SMeterMeta) + p1->numOfColumns * sizeof(SCMSchema);
|
||||||
|
|
||||||
for (int32_t i = 0; i < p1->numOfTags; ++i) {
|
for (int32_t i = 0; i < p1->numOfTags; ++i) {
|
||||||
SSchema* pColSchema = tsGetColumnSchema(p1, i + p1->numOfColumns);
|
SCMSchema* pColSchema = tsGetColumnSchema(p1, i + p1->numOfColumns);
|
||||||
size += pColSchema->bytes;
|
size += pColSchema->bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SSqlRes *pRes, SLocalReducer *pRedu
|
||||||
|
|
||||||
// input buffer hold only one point data
|
// input buffer hold only one point data
|
||||||
int16_t offset = getColumnModelOffset(pDesc->pColumnModel, i);
|
int16_t offset = getColumnModelOffset(pDesc->pColumnModel, i);
|
||||||
SSchema* pSchema = getColumnModelSchema(pDesc->pColumnModel, i);
|
SCMSchema* pSchema = getColumnModelSchema(pDesc->pColumnModel, i);
|
||||||
|
|
||||||
pCtx->aInputElemBuf = pReducer->pTempBuffer->data + offset;
|
pCtx->aInputElemBuf = pReducer->pTempBuffer->data + offset;
|
||||||
|
|
||||||
|
@ -336,7 +336,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
|
||||||
if (pQueryInfo->groupbyExpr.numOfGroupCols > 0) {
|
if (pQueryInfo->groupbyExpr.numOfGroupCols > 0) {
|
||||||
pInterpoInfo->pTags[0] = (char *)pInterpoInfo->pTags + POINTER_BYTES * pQueryInfo->groupbyExpr.numOfGroupCols;
|
pInterpoInfo->pTags[0] = (char *)pInterpoInfo->pTags + POINTER_BYTES * pQueryInfo->groupbyExpr.numOfGroupCols;
|
||||||
for (int32_t i = 1; i < pQueryInfo->groupbyExpr.numOfGroupCols; ++i) {
|
for (int32_t i = 1; i < pQueryInfo->groupbyExpr.numOfGroupCols; ++i) {
|
||||||
SSchema* pSchema = getColumnModelSchema(pReducer->resColModel, startIndex + i - 1);
|
SCMSchema* pSchema = getColumnModelSchema(pReducer->resColModel, startIndex + i - 1);
|
||||||
pInterpoInfo->pTags[i] = pSchema->bytes + pInterpoInfo->pTags[i - 1];
|
pInterpoInfo->pTags[i] = pSchema->bytes + pInterpoInfo->pTags[i - 1];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -599,7 +599,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
SSqlRes *pRes = &pSql->res;
|
SSqlRes *pRes = &pSql->res;
|
||||||
|
|
||||||
SSchema * pSchema = NULL;
|
SCMSchema * pSchema = NULL;
|
||||||
SColumnModel *pModel = NULL;
|
SColumnModel *pModel = NULL;
|
||||||
*pFinalModel = NULL;
|
*pFinalModel = NULL;
|
||||||
|
|
||||||
|
@ -613,7 +613,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
|
||||||
return pRes->code;
|
return pRes->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
pSchema = (SSchema *)calloc(1, sizeof(SSchema) * pQueryInfo->fieldsInfo.numOfOutputCols);
|
pSchema = (SCMSchema *)calloc(1, sizeof(SCMSchema) * pQueryInfo->fieldsInfo.numOfOutputCols);
|
||||||
if (pSchema == NULL) {
|
if (pSchema == NULL) {
|
||||||
tscError("%p failed to allocate memory", pSql);
|
tscError("%p failed to allocate memory", pSql);
|
||||||
pRes->code = TSDB_CODE_CLI_OUT_OF_MEMORY;
|
pRes->code = TSDB_CODE_CLI_OUT_OF_MEMORY;
|
||||||
|
@ -647,7 +647,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
|
||||||
return pRes->code;
|
return pRes->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(pSchema, 0, sizeof(SSchema) * pQueryInfo->fieldsInfo.numOfOutputCols);
|
memset(pSchema, 0, sizeof(SCMSchema) * pQueryInfo->fieldsInfo.numOfOutputCols);
|
||||||
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutputCols; ++i) {
|
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutputCols; ++i) {
|
||||||
TAOS_FIELD *pField = tscFieldInfoGetField(pQueryInfo, i);
|
TAOS_FIELD *pField = tscFieldInfoGetField(pQueryInfo, i);
|
||||||
|
|
||||||
|
@ -985,7 +985,7 @@ static void savePreviousRow(SLocalReducer *pLocalReducer, tFilePage *tmpBuffer)
|
||||||
|
|
||||||
// copy to previous temp buffer
|
// copy to previous temp buffer
|
||||||
for (int32_t i = 0; i < pColumnModel->numOfCols; ++i) {
|
for (int32_t i = 0; i < pColumnModel->numOfCols; ++i) {
|
||||||
SSchema* pSchema = getColumnModelSchema(pColumnModel, i);
|
SCMSchema* pSchema = getColumnModelSchema(pColumnModel, i);
|
||||||
int16_t offset = getColumnModelOffset(pColumnModel, i);
|
int16_t offset = getColumnModelOffset(pColumnModel, i);
|
||||||
|
|
||||||
memcpy(pLocalReducer->prevRowOfInput + offset, tmpBuffer->data + offset, pSchema->bytes);
|
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) {
|
for (int32_t i = 0; i < pQueryInfo->groupbyExpr.numOfGroupCols; ++i) {
|
||||||
int16_t offset = getColumnModelOffset(pModel, startIndex + i);
|
int16_t offset = getColumnModelOffset(pModel, startIndex + i);
|
||||||
SSchema* pSchema = getColumnModelSchema(pModel, startIndex + i);
|
SCMSchema* pSchema = getColumnModelSchema(pModel, startIndex + i);
|
||||||
|
|
||||||
memcpy(pInterpoInfo->pTags[i],
|
memcpy(pInterpoInfo->pTags[i],
|
||||||
pLocalReducer->pBufForInterpo + offset * pResBuf->numOfElems, pSchema->bytes);
|
pLocalReducer->pBufForInterpo + offset * pResBuf->numOfElems, pSchema->bytes);
|
||||||
|
|
|
@ -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
|
// set the ts,tags that involved in join, as the output column of intermediate result
|
||||||
tscClearSubqueryInfo(&pNew->cmd);
|
tscClearSubqueryInfo(&pNew->cmd);
|
||||||
|
|
||||||
SSchema colSchema = {.type = TSDB_DATA_TYPE_BINARY, .bytes = 1};
|
SCMSchema colSchema = {.type = TSDB_DATA_TYPE_BINARY, .bytes = 1};
|
||||||
SColumnIndex index = {0, PRIMARYKEY_TIMESTAMP_COL_INDEX};
|
SColumnIndex index = {0, PRIMARYKEY_TIMESTAMP_COL_INDEX};
|
||||||
|
|
||||||
tscAddSpecialColumnForSelect(pNewQueryInfo, 0, TSDB_FUNC_TS_COMP, &index, &colSchema, TSDB_COL_NORMAL);
|
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
|
// set column list ids
|
||||||
char * pMsg = (char *)(pQueryMsg->colList) + pQueryInfo->colList.numOfCols * sizeof(SColumnInfo);
|
char * pMsg = (char *)(pQueryMsg->colList) + pQueryInfo->colList.numOfCols * sizeof(SColumnInfo);
|
||||||
SSchema *pSchema = tsGetSchema(pMeterMeta);
|
SCMSchema *pSchema = tsGetSchema(pMeterMeta);
|
||||||
|
|
||||||
for (int32_t i = 0; i < pQueryInfo->colList.numOfCols; ++i) {
|
for (int32_t i = 0; i < pQueryInfo->colList.numOfCols; ++i) {
|
||||||
SColumnBase *pCol = tscColumnBaseInfoGet(&pQueryInfo->colList, i);
|
SColumnBase *pCol = tscColumnBaseInfoGet(&pQueryInfo->colList, i);
|
||||||
SSchema * pColSchema = &pSchema[pCol->colIndex.columnIndex];
|
SCMSchema * pColSchema = &pSchema[pCol->colIndex.columnIndex];
|
||||||
|
|
||||||
if (pCol->colIndex.columnIndex >= pMeterMeta->numOfColumns || pColSchema->type < TSDB_DATA_TYPE_BOOL ||
|
if (pCol->colIndex.columnIndex >= pMeterMeta->numOfColumns || pColSchema->type < TSDB_DATA_TYPE_BOOL ||
|
||||||
pColSchema->type > TSDB_DATA_TYPE_NCHAR) {
|
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
|
// only include the required tag column schema. If a tag is not required, it won't be sent to vnode
|
||||||
if (pMeterMetaInfo->numOfTags > 0) {
|
if (pMeterMetaInfo->numOfTags > 0) {
|
||||||
// always transfer tag schema to vnode if exists
|
// always transfer tag schema to vnode if exists
|
||||||
SSchema *pTagSchema = tsGetTagSchema(pMeterMeta);
|
SCMSchema *pTagSchema = tsGetTagSchema(pMeterMeta);
|
||||||
|
|
||||||
for (int32_t j = 0; j < pMeterMetaInfo->numOfTags; ++j) {
|
for (int32_t j = 0; j < pMeterMetaInfo->numOfTags; ++j) {
|
||||||
if (pMeterMetaInfo->tagColumnIndex[j] == TSDB_TBNAME_COLUMN_INDEX) {
|
if (pMeterMetaInfo->tagColumnIndex[j] == TSDB_TBNAME_COLUMN_INDEX) {
|
||||||
SSchema tbSchema = {
|
SCMSchema tbSchema = {
|
||||||
.bytes = TSDB_METER_NAME_LEN, .colId = TSDB_TBNAME_COLUMN_INDEX, .type = TSDB_DATA_TYPE_BINARY};
|
.bytes = TSDB_METER_NAME_LEN, .colId = TSDB_TBNAME_COLUMN_INDEX, .type = TSDB_DATA_TYPE_BINARY};
|
||||||
memcpy(pMsg, &tbSchema, sizeof(SSchema));
|
memcpy(pMsg, &tbSchema, sizeof(SCMSchema));
|
||||||
} else {
|
} else {
|
||||||
memcpy(pMsg, &pTagSchema[pMeterMetaInfo->tagColumnIndex[j]], sizeof(SSchema));
|
memcpy(pMsg, &pTagSchema[pMeterMetaInfo->tagColumnIndex[j]], sizeof(SCMSchema));
|
||||||
}
|
}
|
||||||
|
|
||||||
pMsg += sizeof(SSchema);
|
pMsg += sizeof(SCMSchema);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1651,19 +1651,19 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tscBuildCreateDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
int32_t tscBuildCreateDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SCreateDbMsg *pCreateDbMsg;
|
SCMCreateDbMsg *pCreateDbMsg;
|
||||||
char * pMsg, *pStart;
|
char * pMsg, *pStart;
|
||||||
|
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
|
|
||||||
pMsg = doBuildMsgHeader(pSql, &pStart);
|
pMsg = doBuildMsgHeader(pSql, &pStart);
|
||||||
pCreateDbMsg = (SCreateDbMsg *)pMsg;
|
pCreateDbMsg = (SCMCreateDbMsg *)pMsg;
|
||||||
|
|
||||||
assert(pCmd->numOfClause == 1);
|
assert(pCmd->numOfClause == 1);
|
||||||
SMeterMetaInfo *pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, pCmd->clauseIndex, 0);
|
SMeterMetaInfo *pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, pCmd->clauseIndex, 0);
|
||||||
|
|
||||||
strncpy(pCreateDbMsg->db, pMeterMetaInfo->name, tListLen(pCreateDbMsg->db));
|
strncpy(pCreateDbMsg->db, pMeterMetaInfo->name, tListLen(pCreateDbMsg->db));
|
||||||
pMsg += sizeof(SCreateDbMsg);
|
pMsg += sizeof(SCMCreateDbMsg);
|
||||||
|
|
||||||
pCmd->payloadLen = pMsg - pStart;
|
pCmd->payloadLen = pMsg - pStart;
|
||||||
pCmd->msgType = TSDB_MSG_TYPE_CREATE_DB;
|
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) {
|
int32_t tscBuildCreateDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SCreateDnodeMsg *pCreate;
|
SCMCreateDnodeMsg *pCreate;
|
||||||
|
|
||||||
char *pMsg, *pStart;
|
char *pMsg, *pStart;
|
||||||
|
|
||||||
|
@ -1680,10 +1680,10 @@ int32_t tscBuildCreateDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
|
|
||||||
pMsg = doBuildMsgHeader(pSql, &pStart);
|
pMsg = doBuildMsgHeader(pSql, &pStart);
|
||||||
|
|
||||||
pCreate = (SCreateDnodeMsg *)pMsg;
|
pCreate = (SCMCreateDnodeMsg *)pMsg;
|
||||||
strncpy(pCreate->ip, pInfo->pDCLInfo->a[0].z, pInfo->pDCLInfo->a[0].n);
|
strncpy(pCreate->ip, pInfo->pDCLInfo->a[0].z, pInfo->pDCLInfo->a[0].n);
|
||||||
|
|
||||||
pMsg += sizeof(SCreateDnodeMsg);
|
pMsg += sizeof(SCMCreateDnodeMsg);
|
||||||
|
|
||||||
pCmd->payloadLen = pMsg - pStart;
|
pCmd->payloadLen = pMsg - pStart;
|
||||||
pCmd->msgType = TSDB_MSG_TYPE_CREATE_DNODE;
|
pCmd->msgType = TSDB_MSG_TYPE_CREATE_DNODE;
|
||||||
|
@ -1775,7 +1775,7 @@ int32_t tscBuildCfgDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
|
|
||||||
char *pMsg = doBuildMsgHeader(pSql, &pStart);
|
char *pMsg = doBuildMsgHeader(pSql, &pStart);
|
||||||
pMsg += sizeof(SCfgMsg);
|
pMsg += sizeof(SCMCfgDnodeMsg);
|
||||||
|
|
||||||
pCmd->payloadLen = pMsg - pStart;
|
pCmd->payloadLen = pMsg - pStart;
|
||||||
pCmd->msgType = TSDB_MSG_TYPE_DNODE_CFG;
|
pCmd->msgType = TSDB_MSG_TYPE_DNODE_CFG;
|
||||||
|
@ -1799,19 +1799,19 @@ char *doBuildMsgHeader(SSqlObj *pSql, char **pStart) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tscBuildDropDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
int32_t tscBuildDropDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SDropDbMsg *pDropDbMsg;
|
SCMDropDbMsg *pDropDbMsg;
|
||||||
char * pMsg, *pStart;
|
char * pMsg, *pStart;
|
||||||
|
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
|
|
||||||
pMsg = doBuildMsgHeader(pSql, &pStart);
|
pMsg = doBuildMsgHeader(pSql, &pStart);
|
||||||
pDropDbMsg = (SDropDbMsg *)pMsg;
|
pDropDbMsg = (SCMDropDbMsg *)pMsg;
|
||||||
|
|
||||||
SMeterMetaInfo *pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, pCmd->clauseIndex, 0);
|
SMeterMetaInfo *pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, pCmd->clauseIndex, 0);
|
||||||
strncpy(pDropDbMsg->db, pMeterMetaInfo->name, tListLen(pDropDbMsg->db));
|
strncpy(pDropDbMsg->db, pMeterMetaInfo->name, tListLen(pDropDbMsg->db));
|
||||||
pDropDbMsg->ignoreNotExists = pInfo->pDCLInfo->existsCheck ? 1 : 0;
|
pDropDbMsg->ignoreNotExists = pInfo->pDCLInfo->existsCheck ? 1 : 0;
|
||||||
|
|
||||||
pMsg += sizeof(SDropDbMsg);
|
pMsg += sizeof(SCMDropDbMsg);
|
||||||
|
|
||||||
pCmd->payloadLen = pMsg - pStart;
|
pCmd->payloadLen = pMsg - pStart;
|
||||||
pCmd->msgType = TSDB_MSG_TYPE_DROP_DB;
|
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) {
|
int32_t tscBuildDropDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SDropDnodeMsg *pDrop;
|
SCMDropDnodeMsg *pDrop;
|
||||||
char * pMsg, *pStart;
|
char * pMsg, *pStart;
|
||||||
|
|
||||||
SSqlCmd * pCmd = &pSql->cmd;
|
SSqlCmd * pCmd = &pSql->cmd;
|
||||||
SMeterMetaInfo *pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, pCmd->clauseIndex, 0);
|
SMeterMetaInfo *pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, pCmd->clauseIndex, 0);
|
||||||
|
|
||||||
pMsg = doBuildMsgHeader(pSql, &pStart);
|
pMsg = doBuildMsgHeader(pSql, &pStart);
|
||||||
pDrop = (SDropDnodeMsg *)pMsg;
|
pDrop = (SCMDropDnodeMsg *)pMsg;
|
||||||
|
|
||||||
strcpy(pDrop->ip, pMeterMetaInfo->name);
|
strcpy(pDrop->ip, pMeterMetaInfo->name);
|
||||||
|
|
||||||
pMsg += sizeof(SDropDnodeMsg);
|
pMsg += sizeof(SCMDropDnodeMsg);
|
||||||
|
|
||||||
pCmd->payloadLen = pMsg - pStart;
|
pCmd->payloadLen = pMsg - pStart;
|
||||||
pCmd->msgType = TSDB_MSG_TYPE_DROP_DNODE;
|
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) {
|
int32_t tscBuildUseDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SUseDbMsg *pUseDbMsg;
|
SCMUseDbMsg *pUseDbMsg;
|
||||||
char * pMsg, *pStart;
|
char * pMsg, *pStart;
|
||||||
|
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
|
|
||||||
pMsg = doBuildMsgHeader(pSql, &pStart);
|
pMsg = doBuildMsgHeader(pSql, &pStart);
|
||||||
pUseDbMsg = (SUseDbMsg *)pMsg;
|
pUseDbMsg = (SCMUseDbMsg *)pMsg;
|
||||||
|
|
||||||
SMeterMetaInfo *pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, pCmd->clauseIndex, 0);
|
SMeterMetaInfo *pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, pCmd->clauseIndex, 0);
|
||||||
strcpy(pUseDbMsg->db, pMeterMetaInfo->name);
|
strcpy(pUseDbMsg->db, pMeterMetaInfo->name);
|
||||||
|
|
||||||
pMsg += sizeof(SUseDbMsg);
|
pMsg += sizeof(SCMUseDbMsg);
|
||||||
|
|
||||||
pCmd->payloadLen = pMsg - pStart;
|
pCmd->payloadLen = pMsg - pStart;
|
||||||
pCmd->msgType = TSDB_MSG_TYPE_USE_DB;
|
pCmd->msgType = TSDB_MSG_TYPE_USE_DB;
|
||||||
|
@ -1918,7 +1918,7 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
STscObj *pObj = pSql->pTscObj;
|
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(SCMShowTableMsg) + pCmd->payloadLen + TSDB_EXTRA_PAYLOAD_SIZE;
|
||||||
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, size)) {
|
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, size)) {
|
||||||
tscError("%p failed to malloc for show msg", pSql);
|
tscError("%p failed to malloc for show msg", pSql);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1951,7 +1951,7 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
strncpy(pShowMsg->payload, pPattern->z, pPattern->n);
|
strncpy(pShowMsg->payload, pPattern->z, pPattern->n);
|
||||||
pShowMsg->payloadLen = htons(pPattern->n);
|
pShowMsg->payloadLen = htons(pPattern->n);
|
||||||
}
|
}
|
||||||
pMsg += (sizeof(SShowTableMsg) + pPattern->n);
|
pMsg += (sizeof(SCMShowTableMsg) + pPattern->n);
|
||||||
} else {
|
} else {
|
||||||
SSQLToken *pIpAddr = &pShowInfo->prefix;
|
SSQLToken *pIpAddr = &pShowInfo->prefix;
|
||||||
assert(pIpAddr->n > 0 && pIpAddr->type > 0);
|
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);
|
strncpy(pShowMsg->payload, pIpAddr->z, pIpAddr->n);
|
||||||
pShowMsg->payloadLen = htons(pIpAddr->n);
|
pShowMsg->payloadLen = htons(pIpAddr->n);
|
||||||
|
|
||||||
pMsg += (sizeof(SShowTableMsg) + pIpAddr->n);
|
pMsg += (sizeof(SCMShowTableMsg) + pIpAddr->n);
|
||||||
}
|
}
|
||||||
|
|
||||||
pCmd->payloadLen = pMsg - pStart;
|
pCmd->payloadLen = pMsg - pStart;
|
||||||
|
@ -1971,18 +1971,17 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tscBuildKillMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
int32_t tscBuildKillMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SKillQuery *pKill;
|
SCMKillQueryMsg *pKill;
|
||||||
char * pMsg, *pStart;
|
char * pMsg, *pStart;
|
||||||
|
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
|
|
||||||
pMsg = doBuildMsgHeader(pSql, &pStart);
|
pMsg = doBuildMsgHeader(pSql, &pStart);
|
||||||
pKill = (SKillQuery *)pMsg;
|
pKill = (SCMKillQueryMsg *)pMsg;
|
||||||
|
|
||||||
pKill->handle = 0;
|
|
||||||
strncpy(pKill->queryId, pInfo->pDCLInfo->ip.z, pInfo->pDCLInfo->ip.n);
|
strncpy(pKill->queryId, pInfo->pDCLInfo->ip.z, pInfo->pDCLInfo->ip.n);
|
||||||
|
|
||||||
pMsg += sizeof(SKillQuery);
|
pMsg += sizeof(SCMKillQueryMsg);
|
||||||
|
|
||||||
pCmd->payloadLen = pMsg - pStart;
|
pCmd->payloadLen = pMsg - pStart;
|
||||||
|
|
||||||
|
@ -2003,13 +2002,13 @@ int32_t tscBuildKillMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
int tscEstimateCreateTableMsgLength(SSqlObj *pSql, SSqlInfo *pInfo) {
|
int tscEstimateCreateTableMsgLength(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SSqlCmd *pCmd = &(pSql->cmd);
|
SSqlCmd *pCmd = &(pSql->cmd);
|
||||||
|
|
||||||
int32_t size = minMsgSize() + sizeof(SMgmtHead) + sizeof(SCreateTableMsg);
|
int32_t size = minMsgSize() + sizeof(SMgmtHead) + sizeof(SCMCreateTableMsg);
|
||||||
|
|
||||||
SCreateTableSQL *pCreateTableInfo = pInfo->pCreateTableInfo;
|
SCreateTableSQL *pCreateTableInfo = pInfo->pCreateTableInfo;
|
||||||
if (pCreateTableInfo->type == TSQL_CREATE_TABLE_FROM_STABLE) {
|
if (pCreateTableInfo->type == TSQL_CREATE_TABLE_FROM_STABLE) {
|
||||||
size += sizeof(STagData);
|
size += sizeof(STagData);
|
||||||
} else {
|
} else {
|
||||||
size += sizeof(SSchema) * (pCmd->numOfCols + pCmd->count);
|
size += sizeof(SCMSchema) * (pCmd->numOfCols + pCmd->count);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pCreateTableInfo->pSelect != NULL) {
|
if (pCreateTableInfo->pSelect != NULL) {
|
||||||
|
@ -2020,10 +2019,10 @@ int tscEstimateCreateTableMsgLength(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SCreateTableMsg *pCreateTableMsg;
|
SCMCreateTableMsg *pCreateTableMsg;
|
||||||
char * pMsg, *pStart;
|
char * pMsg, *pStart;
|
||||||
int msgLen = 0;
|
int msgLen = 0;
|
||||||
SSchema * pSchema;
|
SCMSchema * pSchema;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
|
@ -2048,8 +2047,8 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
|
|
||||||
pMsg += sizeof(SMgmtHead);
|
pMsg += sizeof(SMgmtHead);
|
||||||
|
|
||||||
pCreateTableMsg = (SCreateTableMsg *)pMsg;
|
pCreateTableMsg = (SCMCreateTableMsg *)pMsg;
|
||||||
strcpy(pCreateTableMsg->meterId, pMeterMetaInfo->name);
|
strcpy(pCreateTableMsg->tableId, pMeterMetaInfo->name);
|
||||||
|
|
||||||
SCreateTableSQL *pCreateTable = pInfo->pCreateTableInfo;
|
SCreateTableSQL *pCreateTable = pInfo->pCreateTableInfo;
|
||||||
|
|
||||||
|
@ -2100,7 +2099,7 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
|
|
||||||
int tscEstimateAlterTableMsgLength(SSqlCmd *pCmd) {
|
int tscEstimateAlterTableMsgLength(SSqlCmd *pCmd) {
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, 0);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, 0);
|
||||||
return minMsgSize() + sizeof(SMgmtHead) + sizeof(SAlterTableMsg) + sizeof(SSchema) * tscNumOfFields(pQueryInfo) +
|
return minMsgSize() + sizeof(SMgmtHead) + sizeof(SAlterTableMsg) + sizeof(SCMSchema) * tscNumOfFields(pQueryInfo) +
|
||||||
TSDB_EXTRA_PAYLOAD_SIZE;
|
TSDB_EXTRA_PAYLOAD_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2131,13 +2130,13 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SAlterTableSQL *pAlterInfo = pInfo->pAlterInfo;
|
SAlterTableSQL *pAlterInfo = pInfo->pAlterInfo;
|
||||||
|
|
||||||
pAlterTableMsg = (SAlterTableMsg *)pMsg;
|
pAlterTableMsg = (SAlterTableMsg *)pMsg;
|
||||||
strcpy(pAlterTableMsg->meterId, pMeterMetaInfo->name);
|
strcpy(pAlterTableMsg->tableId, pMeterMetaInfo->name);
|
||||||
pAlterTableMsg->type = htons(pAlterInfo->type);
|
pAlterTableMsg->type = htons(pAlterInfo->type);
|
||||||
|
|
||||||
pAlterTableMsg->numOfCols = htons(tscNumOfFields(pQueryInfo));
|
pAlterTableMsg->numOfCols = htons(tscNumOfFields(pQueryInfo));
|
||||||
memcpy(pAlterTableMsg->tagVal, pAlterInfo->tagData.data, TSDB_MAX_TAGS_LEN);
|
memcpy(pAlterTableMsg->tagVal, pAlterInfo->tagData.data, TSDB_MAX_TAGS_LEN);
|
||||||
|
|
||||||
SSchema *pSchema = pAlterTableMsg->schema;
|
SCMSchema *pSchema = pAlterTableMsg->schema;
|
||||||
for (int i = 0; i < tscNumOfFields(pQueryInfo); ++i) {
|
for (int i = 0; i < tscNumOfFields(pQueryInfo); ++i) {
|
||||||
TAOS_FIELD *pField = tscFieldInfoGetField(pQueryInfo, i);
|
TAOS_FIELD *pField = tscFieldInfoGetField(pQueryInfo, i);
|
||||||
|
|
||||||
|
@ -2159,7 +2158,7 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int tscAlterDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
int tscAlterDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SAlterDbMsg *pAlterDbMsg;
|
SCMAlterDbMsg *pAlterDbMsg;
|
||||||
char * pMsg, *pStart;
|
char * pMsg, *pStart;
|
||||||
int msgLen = 0;
|
int msgLen = 0;
|
||||||
|
|
||||||
|
@ -2174,10 +2173,10 @@ int tscAlterDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
strcpy(pMgmt->db, pObj->db);
|
strcpy(pMgmt->db, pObj->db);
|
||||||
pMsg += sizeof(SMgmtHead);
|
pMsg += sizeof(SMgmtHead);
|
||||||
|
|
||||||
pAlterDbMsg = (SAlterDbMsg *)pMsg;
|
pAlterDbMsg = (SCMAlterDbMsg *)pMsg;
|
||||||
strcpy(pAlterDbMsg->db, pMeterMetaInfo->name);
|
strcpy(pAlterDbMsg->db, pMeterMetaInfo->name);
|
||||||
|
|
||||||
pMsg += sizeof(SAlterDbMsg);
|
pMsg += sizeof(SCMAlterDbMsg);
|
||||||
|
|
||||||
msgLen = pMsg - pStart;
|
msgLen = pMsg - pStart;
|
||||||
pCmd->payloadLen = msgLen;
|
pCmd->payloadLen = msgLen;
|
||||||
|
@ -2665,7 +2664,7 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
|
|
||||||
int tscProcessMeterMetaRsp(SSqlObj *pSql) {
|
int tscProcessMeterMetaRsp(SSqlObj *pSql) {
|
||||||
SMeterMeta *pMeta;
|
SMeterMeta *pMeta;
|
||||||
SSchema * pSchema;
|
SCMSchema * pSchema;
|
||||||
uint8_t ieType;
|
uint8_t ieType;
|
||||||
|
|
||||||
char *rsp = pSql->res.pRsp;
|
char *rsp = pSql->res.pRsp;
|
||||||
|
@ -2707,7 +2706,7 @@ int tscProcessMeterMetaRsp(SSqlObj *pSql) {
|
||||||
|
|
||||||
pMeta->rowSize = 0;
|
pMeta->rowSize = 0;
|
||||||
rsp += sizeof(SMeterMeta);
|
rsp += sizeof(SMeterMeta);
|
||||||
pSchema = (SSchema *)rsp;
|
pSchema = (SCMSchema *)rsp;
|
||||||
|
|
||||||
int32_t numOfTotalCols = pMeta->numOfColumns + pMeta->numOfTags;
|
int32_t numOfTotalCols = pMeta->numOfColumns + pMeta->numOfTags;
|
||||||
for (int i = 0; i < numOfTotalCols; ++i) {
|
for (int i = 0; i < numOfTotalCols; ++i) {
|
||||||
|
@ -2721,10 +2720,10 @@ int tscProcessMeterMetaRsp(SSqlObj *pSql) {
|
||||||
pSchema++;
|
pSchema++;
|
||||||
}
|
}
|
||||||
|
|
||||||
rsp += numOfTotalCols * sizeof(SSchema);
|
rsp += numOfTotalCols * sizeof(SCMSchema);
|
||||||
|
|
||||||
int32_t tagLen = 0;
|
int32_t tagLen = 0;
|
||||||
SSchema *pTagsSchema = tsGetTagSchema(pMeta);
|
SCMSchema *pTagsSchema = tsGetTagSchema(pMeta);
|
||||||
|
|
||||||
if (pMeta->tableType == TSDB_TABLE_TYPE_CHILD_TABLE) {
|
if (pMeta->tableType == TSDB_TABLE_TYPE_CHILD_TABLE) {
|
||||||
for (int32_t i = 0; i < pMeta->numOfTags; ++i) {
|
for (int32_t i = 0; i < pMeta->numOfTags; ++i) {
|
||||||
|
@ -2752,11 +2751,11 @@ int tscProcessMeterMetaRsp(SSqlObj *pSql) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* multi meter meta rsp pkg format:
|
* multi meter meta rsp pkg format:
|
||||||
* | STaosRsp | ieType | SMultiMeterInfoMsg | SMeterMeta0 | SSchema0 | SMeterMeta1 | SSchema1 | SMeterMeta2 | SSchema2
|
* | STaosRsp | ieType | SMultiMeterInfoMsg | SMeterMeta0 | SCMSchema0 | SMeterMeta1 | SCMSchema1 | SMeterMeta2 | SCMSchema2
|
||||||
* |...... 1B 1B 4B
|
* |...... 1B 1B 4B
|
||||||
**/
|
**/
|
||||||
int tscProcessMultiMeterMetaRsp(SSqlObj *pSql) {
|
int tscProcessMultiMeterMetaRsp(SSqlObj *pSql) {
|
||||||
SSchema *pSchema;
|
SCMSchema *pSchema;
|
||||||
uint8_t ieType;
|
uint8_t ieType;
|
||||||
int32_t totalNum;
|
int32_t totalNum;
|
||||||
int32_t i;
|
int32_t i;
|
||||||
|
@ -2822,7 +2821,7 @@ int tscProcessMultiMeterMetaRsp(SSqlObj *pSql) {
|
||||||
|
|
||||||
pMeta->rowSize = 0;
|
pMeta->rowSize = 0;
|
||||||
rsp += sizeof(SMultiMeterMeta);
|
rsp += sizeof(SMultiMeterMeta);
|
||||||
pSchema = (SSchema *)rsp;
|
pSchema = (SCMSchema *)rsp;
|
||||||
|
|
||||||
int32_t numOfTotalCols = pMeta->numOfColumns + pMeta->numOfTags;
|
int32_t numOfTotalCols = pMeta->numOfColumns + pMeta->numOfTags;
|
||||||
for (int j = 0; j < numOfTotalCols; ++j) {
|
for (int j = 0; j < numOfTotalCols; ++j) {
|
||||||
|
@ -2836,10 +2835,10 @@ int tscProcessMultiMeterMetaRsp(SSqlObj *pSql) {
|
||||||
pSchema++;
|
pSchema++;
|
||||||
}
|
}
|
||||||
|
|
||||||
rsp += numOfTotalCols * sizeof(SSchema);
|
rsp += numOfTotalCols * sizeof(SCMSchema);
|
||||||
|
|
||||||
int32_t tagLen = 0;
|
int32_t tagLen = 0;
|
||||||
SSchema *pTagsSchema = tsGetTagSchema(pMeta);
|
SCMSchema *pTagsSchema = tsGetTagSchema(pMeta);
|
||||||
|
|
||||||
if (pMeta->tableType == TSDB_TABLE_TYPE_CHILD_TABLE) {
|
if (pMeta->tableType == TSDB_TABLE_TYPE_CHILD_TABLE) {
|
||||||
for (int32_t j = 0; j < pMeta->numOfTags; ++j) {
|
for (int32_t j = 0; j < pMeta->numOfTags; ++j) {
|
||||||
|
@ -2989,7 +2988,7 @@ _error_clean:
|
||||||
int tscProcessShowRsp(SSqlObj *pSql) {
|
int tscProcessShowRsp(SSqlObj *pSql) {
|
||||||
SMeterMeta * pMeta;
|
SMeterMeta * pMeta;
|
||||||
SShowRspMsg *pShow;
|
SShowRspMsg *pShow;
|
||||||
SSchema * pSchema;
|
SCMSchema * pSchema;
|
||||||
char key[20];
|
char key[20];
|
||||||
|
|
||||||
SSqlRes *pRes = &pSql->res;
|
SSqlRes *pRes = &pSql->res;
|
||||||
|
@ -3007,7 +3006,7 @@ int tscProcessShowRsp(SSqlObj *pSql) {
|
||||||
|
|
||||||
pMeta->numOfColumns = ntohs(pMeta->numOfColumns);
|
pMeta->numOfColumns = ntohs(pMeta->numOfColumns);
|
||||||
|
|
||||||
pSchema = (SSchema *)((char *)pMeta + sizeof(SMeterMeta));
|
pSchema = (SCMSchema *)((char *)pMeta + sizeof(SMeterMeta));
|
||||||
pMeta->sid = ntohs(pMeta->sid);
|
pMeta->sid = ntohs(pMeta->sid);
|
||||||
for (int i = 0; i < pMeta->numOfColumns; ++i) {
|
for (int i = 0; i < pMeta->numOfColumns; ++i) {
|
||||||
pSchema->bytes = htons(pSchema->bytes);
|
pSchema->bytes = htons(pSchema->bytes);
|
||||||
|
@ -3019,11 +3018,11 @@ int tscProcessShowRsp(SSqlObj *pSql) {
|
||||||
|
|
||||||
taosRemoveDataFromCache(tscCacheHandle, (void *)&(pMeterMetaInfo->pMeterMeta), false);
|
taosRemoveDataFromCache(tscCacheHandle, (void *)&(pMeterMetaInfo->pMeterMeta), false);
|
||||||
|
|
||||||
int32_t size = pMeta->numOfColumns * sizeof(SSchema) + sizeof(SMeterMeta);
|
int32_t size = pMeta->numOfColumns * sizeof(SCMSchema) + sizeof(SMeterMeta);
|
||||||
pMeterMetaInfo->pMeterMeta =
|
pMeterMetaInfo->pMeterMeta =
|
||||||
(SMeterMeta *)taosAddDataIntoCache(tscCacheHandle, key, (char *)pMeta, size, tsMeterMetaKeepTimer);
|
(SMeterMeta *)taosAddDataIntoCache(tscCacheHandle, key, (char *)pMeta, size, tsMeterMetaKeepTimer);
|
||||||
pCmd->numOfCols = pQueryInfo->fieldsInfo.numOfOutputCols;
|
pCmd->numOfCols = pQueryInfo->fieldsInfo.numOfOutputCols;
|
||||||
SSchema *pMeterSchema = tsGetSchema(pMeterMetaInfo->pMeterMeta);
|
SCMSchema *pMeterSchema = tsGetSchema(pMeterMetaInfo->pMeterMeta);
|
||||||
|
|
||||||
tscColumnBaseInfoReserve(&pQueryInfo->colList, pMeta->numOfColumns);
|
tscColumnBaseInfoReserve(&pQueryInfo->colList, pMeta->numOfColumns);
|
||||||
SColumnIndex index = {0};
|
SColumnIndex index = {0};
|
||||||
|
|
|
@ -856,7 +856,7 @@ static void setValueImpl(TAOS_FIELD* pField, int8_t type, const char* name, int1
|
||||||
pField->bytes = bytes;
|
pField->bytes = bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscFieldInfoSetValFromSchema(SFieldInfo* pFieldInfo, int32_t index, SSchema* pSchema) {
|
void tscFieldInfoSetValFromSchema(SFieldInfo* pFieldInfo, int32_t index, SCMSchema* pSchema) {
|
||||||
ensureSpace(pFieldInfo, pFieldInfo->numOfOutputCols + 1);
|
ensureSpace(pFieldInfo, pFieldInfo->numOfOutputCols + 1);
|
||||||
evic(pFieldInfo, index);
|
evic(pFieldInfo, index);
|
||||||
|
|
||||||
|
@ -1079,7 +1079,7 @@ SSqlExpr* tscSqlExprInsert(SQueryInfo* pQueryInfo, int32_t index, int16_t functi
|
||||||
if (pColIndex->columnIndex == TSDB_TBNAME_COLUMN_INDEX) {
|
if (pColIndex->columnIndex == TSDB_TBNAME_COLUMN_INDEX) {
|
||||||
pExpr->colInfo.colId = TSDB_TBNAME_COLUMN_INDEX;
|
pExpr->colInfo.colId = TSDB_TBNAME_COLUMN_INDEX;
|
||||||
} else {
|
} else {
|
||||||
SSchema* pSchema = tsGetColumnSchema(pMeterMetaInfo->pMeterMeta, pColIndex->columnIndex);
|
SCMSchema* pSchema = tsGetColumnSchema(pMeterMetaInfo->pMeterMeta, pColIndex->columnIndex);
|
||||||
pExpr->colInfo.colId = pSchema->colId;
|
pExpr->colInfo.colId = pSchema->colId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1509,7 +1509,7 @@ bool tscValidateColumnId(SMeterMetaInfo* pMeterMetaInfo, int32_t colId) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchema* pSchema = tsGetSchema(pMeterMetaInfo->pMeterMeta);
|
SCMSchema* pSchema = tsGetSchema(pMeterMetaInfo->pMeterMeta);
|
||||||
int32_t numOfTotal = pMeterMetaInfo->pMeterMeta->numOfTags + pMeterMetaInfo->pMeterMeta->numOfColumns;
|
int32_t numOfTotal = pMeterMetaInfo->pMeterMeta->numOfTags + pMeterMetaInfo->pMeterMeta->numOfColumns;
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfTotal; ++i) {
|
for (int32_t i = 0; i < numOfTotal; ++i) {
|
||||||
|
@ -1555,14 +1555,14 @@ void tscTagCondRelease(STagCond* pCond) {
|
||||||
|
|
||||||
void tscGetSrcColumnInfo(SSrcColumnInfo* pColInfo, SQueryInfo* pQueryInfo) {
|
void tscGetSrcColumnInfo(SSrcColumnInfo* pColInfo, SQueryInfo* pQueryInfo) {
|
||||||
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, 0);
|
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, 0);
|
||||||
SSchema* pSchema = tsGetSchema(pMeterMetaInfo->pMeterMeta);
|
SCMSchema* pSchema = tsGetSchema(pMeterMetaInfo->pMeterMeta);
|
||||||
|
|
||||||
for (int32_t i = 0; i < pQueryInfo->exprsInfo.numOfExprs; ++i) {
|
for (int32_t i = 0; i < pQueryInfo->exprsInfo.numOfExprs; ++i) {
|
||||||
SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i);
|
SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||||
pColInfo[i].functionId = pExpr->functionId;
|
pColInfo[i].functionId = pExpr->functionId;
|
||||||
|
|
||||||
if (TSDB_COL_IS_TAG(pExpr->colInfo.flag)) {
|
if (TSDB_COL_IS_TAG(pExpr->colInfo.flag)) {
|
||||||
SSchema* pTagSchema = tsGetTagSchema(pMeterMetaInfo->pMeterMeta);
|
SCMSchema* pTagSchema = tsGetTagSchema(pMeterMetaInfo->pMeterMeta);
|
||||||
int16_t actualTagIndex = pMeterMetaInfo->tagColumnIndex[pExpr->colInfo.colIdx];
|
int16_t actualTagIndex = pMeterMetaInfo->tagColumnIndex[pExpr->colInfo.colIdx];
|
||||||
|
|
||||||
pColInfo[i].type = (actualTagIndex != -1) ? pTagSchema[actualTagIndex].type : TSDB_DATA_TYPE_BINARY;
|
pColInfo[i].type = (actualTagIndex != -1) ? pTagSchema[actualTagIndex].type : TSDB_DATA_TYPE_BINARY;
|
||||||
|
|
|
@ -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) {
|
int32_t dnodeProcessDnodeCfgRequest(int8_t *pCont, int32_t contLen, int8_t msgType, void *pConn) {
|
||||||
SCfgMsg *pCfg = (SCfgMsg *)pCont;
|
SCMCfgDnodeMsg *pCfg = (SCMCfgDnodeMsg *)pCont;
|
||||||
int32_t code = tsCfgDynamicOptions(pCfg->config);
|
int32_t code = tsCfgDynamicOptions(pCfg->config);
|
||||||
dnodeSendSimpleRspToMnode(pConn, msgType + 1, code);
|
dnodeSendSimpleRspToMnode(pConn, msgType + 1, code);
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -130,7 +130,7 @@ typedef struct _tab_obj {
|
||||||
char * pReserve1;
|
char * pReserve1;
|
||||||
char * pReserve2;
|
char * pReserve2;
|
||||||
char * schema;
|
char * schema;
|
||||||
// SSchema schema[];
|
// SCMSchema schema[];
|
||||||
} STabObj;
|
} STabObj;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -156,7 +156,7 @@ typedef struct SSuperTableObj {
|
||||||
int8_t reserved[7];
|
int8_t reserved[7];
|
||||||
int8_t updateEnd[1];
|
int8_t updateEnd[1];
|
||||||
int16_t nextColId;
|
int16_t nextColId;
|
||||||
SSchema *schema;
|
SCMSchema *schema;
|
||||||
} SSuperTableObj;
|
} SSuperTableObj;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -184,7 +184,7 @@ typedef struct {
|
||||||
int8_t reserved[3];
|
int8_t reserved[3];
|
||||||
int8_t updateEnd[1];
|
int8_t updateEnd[1];
|
||||||
int16_t nextColId;
|
int16_t nextColId;
|
||||||
SSchema* schema;
|
SCMSchema* schema;
|
||||||
} SNormalTableObj;
|
} SNormalTableObj;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -201,7 +201,7 @@ typedef struct {
|
||||||
int8_t updateEnd[1];
|
int8_t updateEnd[1];
|
||||||
int16_t nextColId;
|
int16_t nextColId;
|
||||||
char* sql; //null-terminated string
|
char* sql; //null-terminated string
|
||||||
SSchema* schema;
|
SCMSchema* schema;
|
||||||
} SStreamTableObj;
|
} SStreamTableObj;
|
||||||
|
|
||||||
typedef struct _vg_obj {
|
typedef struct _vg_obj {
|
||||||
|
|
|
@ -245,12 +245,12 @@ typedef struct {
|
||||||
SShellSubmitRspBlock *failedBlocks;
|
SShellSubmitRspBlock *failedBlocks;
|
||||||
} SShellSubmitRspMsg;
|
} SShellSubmitRspMsg;
|
||||||
|
|
||||||
typedef struct SSchema {
|
typedef struct SCMSchema {
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
char name[TSDB_COL_NAME_LEN];
|
char name[TSDB_COL_NAME_LEN];
|
||||||
short colId;
|
short colId;
|
||||||
short bytes;
|
short bytes;
|
||||||
} SSchema;
|
} SCMSchema;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t type;
|
int8_t type;
|
||||||
|
@ -275,40 +275,34 @@ typedef struct {
|
||||||
int8_t data[];
|
int8_t data[];
|
||||||
} SDCreateTableMsg;
|
} SDCreateTableMsg;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
char db[TSDB_TABLE_ID_LEN];
|
|
||||||
uint8_t ignoreNotExists;
|
|
||||||
} SDropDbMsg, SUseDbMsg;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char db[TSDB_DB_NAME_LEN];
|
char db[TSDB_DB_NAME_LEN];
|
||||||
} SShowTableMsg;
|
} SCMShowTableMsg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char meterId[TSDB_TABLE_ID_LEN];
|
char tableId[TSDB_TABLE_ID_LEN];
|
||||||
char igExists;
|
char db[TSDB_DB_NAME_LEN];
|
||||||
|
int8_t igExists;
|
||||||
short numOfTags;
|
int16_t numOfTags;
|
||||||
|
int16_t numOfColumns;
|
||||||
short numOfColumns;
|
int16_t sqlLen; // the length of SQL, it starts after schema , sql is a null-terminated string
|
||||||
short sqlLen; // the length of SQL, it starts after schema , sql is a
|
int16_t reserved[16];
|
||||||
// null-terminated string
|
SCMSchema schema[];
|
||||||
char reserved[16];
|
} SCMCreateTableMsg;
|
||||||
|
|
||||||
SSchema schema[];
|
|
||||||
} SCreateTableMsg;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char meterId[TSDB_TABLE_ID_LEN];
|
char meterId[TSDB_TABLE_ID_LEN];
|
||||||
char igNotExists;
|
char db[TSDB_DB_NAME_LEN];
|
||||||
|
int8_t igNotExists;
|
||||||
} SDropTableMsg;
|
} SDropTableMsg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char meterId[TSDB_TABLE_ID_LEN];
|
char tableId[TSDB_TABLE_ID_LEN];
|
||||||
short type; /* operation type */
|
char db[TSDB_DB_NAME_LEN];
|
||||||
|
int16_t type; /* operation type */
|
||||||
char tagVal[TSDB_MAX_BYTES_PER_ROW];
|
char tagVal[TSDB_MAX_BYTES_PER_ROW];
|
||||||
short numOfCols; /* number of schema */
|
int8_t numOfCols; /* number of schema */
|
||||||
SSchema schema[];
|
SCMSchema schema[];
|
||||||
} SAlterTableMsg;
|
} SAlterTableMsg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -561,14 +555,11 @@ typedef struct {
|
||||||
char accessState;
|
char accessState;
|
||||||
} SVnodeAccess;
|
} SVnodeAccess;
|
||||||
|
|
||||||
// NOTE: sizeof(SVnodeCfg) < TSDB_FILE_HEADER_LEN/4
|
/*
|
||||||
|
* NOTE: sizeof(SVnodeCfg) < TSDB_FILE_HEADER_LEN / 4
|
||||||
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char acct[TSDB_USER_LEN];
|
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];
|
char db[TSDB_DB_NAME_LEN];
|
||||||
uint32_t vgId;
|
uint32_t vgId;
|
||||||
int32_t maxSessions;
|
int32_t maxSessions;
|
||||||
|
@ -578,24 +569,25 @@ typedef struct {
|
||||||
float fraction;
|
float fraction;
|
||||||
} cacheNumOfBlocks;
|
} cacheNumOfBlocks;
|
||||||
int32_t daysPerFile;
|
int32_t daysPerFile;
|
||||||
|
|
||||||
int32_t daysToKeep1;
|
int32_t daysToKeep1;
|
||||||
int32_t daysToKeep2;
|
int32_t daysToKeep2;
|
||||||
int32_t daysToKeep;
|
int32_t daysToKeep;
|
||||||
|
|
||||||
int32_t commitTime;
|
int32_t commitTime;
|
||||||
int32_t rowsInFileBlock;
|
int32_t rowsInFileBlock;
|
||||||
int16_t blocksPerMeter;
|
int16_t blocksPerMeter;
|
||||||
char compression;
|
int8_t compression;
|
||||||
char commitLog;
|
int8_t commitLog;
|
||||||
char replications;
|
int8_t replications;
|
||||||
|
int8_t repStrategy;
|
||||||
char repStrategy;
|
int8_t loadLatest; // load into mem or not
|
||||||
char loadLatest; // load into mem or not
|
|
||||||
uint8_t precision; // time resolution
|
uint8_t precision; // time resolution
|
||||||
|
int8_t reserved[16];
|
||||||
|
} SVnodeCfg, SCMCreateDbMsg, SDbCfg, SCMAlterDbMsg;
|
||||||
|
|
||||||
char reserved[16];
|
typedef struct {
|
||||||
} SVnodeCfg, SCreateDbMsg, SDbCfg, SAlterDbMsg;
|
char db[TSDB_TABLE_ID_LEN];
|
||||||
|
uint8_t ignoreNotExists;
|
||||||
|
} SCMDropDbMsg, SCMUseDbMsg;
|
||||||
|
|
||||||
// IMPORTANT: sizeof(SVnodeStatisticInfo) should not exceed
|
// IMPORTANT: sizeof(SVnodeStatisticInfo) should not exceed
|
||||||
// TSDB_FILE_HEADER_LEN/4 - TSDB_FILE_HEADER_VERSION_SIZE
|
// TSDB_FILE_HEADER_LEN/4 - TSDB_FILE_HEADER_VERSION_SIZE
|
||||||
|
@ -759,7 +751,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char ip[20];
|
char ip[20];
|
||||||
} SCreateMnodeMsg, SDropMnodeMsg, SCreateDnodeMsg, SDropDnodeMsg;
|
} SCMCreateMnodeMsg, SCMDropMnodeMsg, SCMCreateDnodeMsg, SCMDropDnodeMsg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint64_t qhandle;
|
uint64_t qhandle;
|
||||||
|
@ -776,9 +768,9 @@ typedef struct {
|
||||||
} SVpeerCfgMsg;
|
} SVpeerCfgMsg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char ip[20];
|
char ip[32];
|
||||||
char config[60];
|
char config[64];
|
||||||
} SCfgMsg;
|
} SCMCfgDnodeMsg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char sql[TSDB_SHOW_SQL_LEN];
|
char sql[TSDB_SHOW_SQL_LEN];
|
||||||
|
@ -821,9 +813,8 @@ typedef struct {
|
||||||
} SCMHeartBeatRsp;
|
} SCMHeartBeatRsp;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint64_t handle;
|
char queryId[TSDB_KILL_MSG_LEN];
|
||||||
char queryId[TSDB_KILL_MSG_LEN];
|
} SCMKillQueryMsg, SCMKillStreamMsg, SKillConnectionMsg;
|
||||||
} SKillQuery, SKillStream, SKillConnection;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t vnode;
|
int32_t vnode;
|
||||||
|
|
|
@ -32,7 +32,7 @@ extern void (*mgmtCleanUpAccts)();
|
||||||
extern SAcctObj* (*mgmtGetAcct)(char *acctName);
|
extern SAcctObj* (*mgmtGetAcct)(char *acctName);
|
||||||
extern int32_t (*mgmtCheckUserLimit)(SAcctObj *pAcct);
|
extern int32_t (*mgmtCheckUserLimit)(SAcctObj *pAcct);
|
||||||
extern int32_t (*mgmtCheckDbLimit)(SAcctObj *pAcct);
|
extern int32_t (*mgmtCheckDbLimit)(SAcctObj *pAcct);
|
||||||
extern int32_t (*mgmtCheckTableLimit)(SAcctObj *pAcct, SCreateTableMsg *pCreate);
|
extern int32_t (*mgmtCheckTableLimit)(SAcctObj *pAcct, SCMCreateTableMsg *pCreate);
|
||||||
extern int32_t (*mgmtGetAcctMeta)(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
extern int32_t (*mgmtGetAcctMeta)(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
extern int32_t (*mgmtRetrieveAccts)(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
extern int32_t (*mgmtRetrieveAccts)(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ extern "C" {
|
||||||
|
|
||||||
int32_t mgmtInitChildTables();
|
int32_t mgmtInitChildTables();
|
||||||
void mgmtCleanUpChildTables();
|
void mgmtCleanUpChildTables();
|
||||||
int32_t mgmtCreateChildTable(SDbObj *pDb, SCreateTableMsg *pCreate, SVgObj *pVgroup, int32_t sid);
|
int32_t mgmtCreateChildTable(SDbObj *pDb, SCMCreateTableMsg *pCreate, SVgObj *pVgroup, int32_t sid);
|
||||||
int32_t mgmtDropChildTable(SDbObj *pDb, SChildTableObj *pTable);
|
int32_t mgmtDropChildTable(SDbObj *pDb, SChildTableObj *pTable);
|
||||||
int32_t mgmtAlterChildTable(SDbObj *pDb, SAlterTableMsg *pAlter);
|
int32_t mgmtAlterChildTable(SDbObj *pDb, SAlterTableMsg *pAlter);
|
||||||
int32_t mgmtModifyChildTableTagValueByName(SChildTableObj *pTable, char *tagName, char *nContent);
|
int32_t mgmtModifyChildTableTagValueByName(SChildTableObj *pTable, char *tagName, char *nContent);
|
||||||
|
|
|
@ -23,7 +23,7 @@ extern "C" {
|
||||||
#include "mnode.h"
|
#include "mnode.h"
|
||||||
|
|
||||||
void mgmtMonitorDbDrop(void *unused, void *unusedt);
|
void mgmtMonitorDbDrop(void *unused, void *unusedt);
|
||||||
int32_t mgmtAlterDb(SAcctObj *pAcct, SAlterDbMsg *pAlter);
|
int32_t mgmtAlterDb(SAcctObj *pAcct, SCMAlterDbMsg *pAlter);
|
||||||
int32_t mgmtAddVgroupIntoDb(SDbObj *pDb, SVgObj *pVgroup);
|
int32_t mgmtAddVgroupIntoDb(SDbObj *pDb, SVgObj *pVgroup);
|
||||||
int32_t mgmtAddVgroupIntoDbTail(SDbObj *pDb, SVgObj *pVgroup);
|
int32_t mgmtAddVgroupIntoDbTail(SDbObj *pDb, SVgObj *pVgroup);
|
||||||
int32_t mgmtRemoveVgroupFromDb(SDbObj *pDb, SVgObj *pVgroup);
|
int32_t mgmtRemoveVgroupFromDb(SDbObj *pDb, SVgObj *pVgroup);
|
||||||
|
@ -37,7 +37,7 @@ int32_t mgmtInitDbs();
|
||||||
int32_t mgmtUpdateDb(SDbObj *pDb);
|
int32_t mgmtUpdateDb(SDbObj *pDb);
|
||||||
SDbObj *mgmtGetDb(char *db);
|
SDbObj *mgmtGetDb(char *db);
|
||||||
SDbObj *mgmtGetDbByTableId(char *db);
|
SDbObj *mgmtGetDbByTableId(char *db);
|
||||||
int32_t mgmtCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate);
|
int32_t mgmtCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate);
|
||||||
int32_t mgmtDropDbByName(SAcctObj *pAcct, char *name, short ignoreNotExists);
|
int32_t mgmtDropDbByName(SAcctObj *pAcct, char *name, short ignoreNotExists);
|
||||||
int32_t mgmtDropDb(SDbObj *pDb);
|
int32_t mgmtDropDb(SDbObj *pDb);
|
||||||
bool mgmtCheckIsMonitorDB(char *db, char *monitordb);
|
bool mgmtCheckIsMonitorDB(char *db, char *monitordb);
|
||||||
|
|
|
@ -26,9 +26,9 @@ extern "C" {
|
||||||
|
|
||||||
int32_t mgmtInitNormalTables();
|
int32_t mgmtInitNormalTables();
|
||||||
void mgmtCleanUpNormalTables();
|
void mgmtCleanUpNormalTables();
|
||||||
int32_t mgmtCreateNormalTable(SDbObj *pDb, SCreateTableMsg *pCreate, SVgObj *pVgroup, int32_t sid);
|
int32_t mgmtCreateNormalTable(SDbObj *pDb, SCMCreateTableMsg *pCreate, SVgObj *pVgroup, int32_t sid);
|
||||||
int32_t mgmtDropNormalTable(SDbObj *pDb, SNormalTableObj *pTable);
|
int32_t mgmtDropNormalTable(SDbObj *pDb, SNormalTableObj *pTable);
|
||||||
int32_t mgmtAddNormalTableColumn(SNormalTableObj *pTable, SSchema schema[], int32_t ncols);
|
int32_t mgmtAddNormalTableColumn(SNormalTableObj *pTable, SCMSchema schema[], int32_t ncols);
|
||||||
int32_t mgmtDropNormalTableColumnByName(SNormalTableObj *pTable, char *colName);
|
int32_t mgmtDropNormalTableColumnByName(SNormalTableObj *pTable, char *colName);
|
||||||
SNormalTableObj* mgmtGetNormalTable(char *tableId);
|
SNormalTableObj* mgmtGetNormalTable(char *tableId);
|
||||||
int8_t * mgmtBuildCreateNormalTableMsg(SNormalTableObj *pTable);
|
int8_t * mgmtBuildCreateNormalTableMsg(SNormalTableObj *pTable);
|
||||||
|
|
|
@ -26,7 +26,7 @@ extern "C" {
|
||||||
|
|
||||||
int32_t mgmtInitStreamTables();
|
int32_t mgmtInitStreamTables();
|
||||||
void mgmtCleanUpStreamTables();
|
void mgmtCleanUpStreamTables();
|
||||||
int32_t mgmtCreateStreamTable(SDbObj *pDb, SCreateTableMsg *pCreate, SVgObj *pVgroup, int32_t sid);
|
int32_t mgmtCreateStreamTable(SDbObj *pDb, SCMCreateTableMsg *pCreate, SVgObj *pVgroup, int32_t sid);
|
||||||
int32_t mgmtDropStreamTable(SDbObj *pDb, SStreamTableObj *pTable);
|
int32_t mgmtDropStreamTable(SDbObj *pDb, SStreamTableObj *pTable);
|
||||||
int32_t mgmtAlterStreamTable(SDbObj *pDb, SAlterTableMsg *pAlter);
|
int32_t mgmtAlterStreamTable(SDbObj *pDb, SAlterTableMsg *pAlter);
|
||||||
SStreamTableObj* mgmtGetStreamTable(char *tableId);
|
SStreamTableObj* mgmtGetStreamTable(char *tableId);
|
||||||
|
|
|
@ -28,14 +28,14 @@ extern "C" {
|
||||||
|
|
||||||
int32_t mgmtInitSuperTables();
|
int32_t mgmtInitSuperTables();
|
||||||
void mgmtCleanUpSuperTables();
|
void mgmtCleanUpSuperTables();
|
||||||
int32_t mgmtCreateSuperTable(SDbObj *pDb, SCreateTableMsg *pCreate);
|
int32_t mgmtCreateSuperTable(SDbObj *pDb, SCMCreateTableMsg *pCreate);
|
||||||
int32_t mgmtDropSuperTable(SDbObj *pDb, SSuperTableObj *pTable);
|
int32_t mgmtDropSuperTable(SDbObj *pDb, SSuperTableObj *pTable);
|
||||||
SSuperTableObj* mgmtGetSuperTable(char *tableId);
|
SSuperTableObj* mgmtGetSuperTable(char *tableId);
|
||||||
int32_t mgmtFindSuperTableTagIndex(SSuperTableObj *pTable, const char *tagName);
|
int32_t mgmtFindSuperTableTagIndex(SSuperTableObj *pTable, const char *tagName);
|
||||||
int32_t mgmtAddSuperTableTag(SSuperTableObj *pTable, SSchema schema[], int32_t ntags);
|
int32_t mgmtAddSuperTableTag(SSuperTableObj *pTable, SCMSchema schema[], int32_t ntags);
|
||||||
int32_t mgmtDropSuperTableTag(SSuperTableObj *pTable, char *tagName);
|
int32_t mgmtDropSuperTableTag(SSuperTableObj *pTable, char *tagName);
|
||||||
int32_t mgmtModifySuperTableTagNameByName(SSuperTableObj *pTable, char *oldTagName, char *newTagName);
|
int32_t mgmtModifySuperTableTagNameByName(SSuperTableObj *pTable, char *oldTagName, char *newTagName);
|
||||||
int32_t mgmtAddSuperTableColumn(SSuperTableObj *pTable, SSchema schema[], int32_t ncols);
|
int32_t mgmtAddSuperTableColumn(SSuperTableObj *pTable, SCMSchema schema[], int32_t ncols);
|
||||||
int32_t mgmtDropSuperTableColumnByName(SSuperTableObj *pTable, char *colName);
|
int32_t mgmtDropSuperTableColumnByName(SSuperTableObj *pTable, char *colName);
|
||||||
int32_t mgmtGetTagsLength(SSuperTableObj* pSuperTable, int32_t col);
|
int32_t mgmtGetTagsLength(SSuperTableObj* pSuperTable, int32_t col);
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ STableInfo* mgmtGetTable(char *tableId);
|
||||||
STableInfo* mgmtGetTableByPos(uint32_t dnodeIp, int32_t vnode, int32_t sid);
|
STableInfo* mgmtGetTableByPos(uint32_t dnodeIp, int32_t vnode, int32_t sid);
|
||||||
|
|
||||||
int32_t mgmtRetrieveMetricMeta(void *pConn, char **pStart, SSuperTableMetaMsg *pInfo);
|
int32_t mgmtRetrieveMetricMeta(void *pConn, char **pStart, SSuperTableMetaMsg *pInfo);
|
||||||
int32_t mgmtCreateTable(SDbObj *pDb, SCreateTableMsg *pCreate);
|
int32_t mgmtCreateTable(SDbObj *pDb, SCMCreateTableMsg *pCreate);
|
||||||
int32_t mgmtDropTable(SDbObj *pDb, char *meterId, int32_t ignore);
|
int32_t mgmtDropTable(SDbObj *pDb, char *meterId, int32_t ignore);
|
||||||
int32_t mgmtAlterTable(SDbObj *pDb, SAlterTableMsg *pAlter);
|
int32_t mgmtAlterTable(SDbObj *pDb, SAlterTableMsg *pAlter);
|
||||||
int32_t mgmtGetTableMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
int32_t mgmtGetTableMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
|
|
|
@ -133,11 +133,11 @@ static int32_t mgmtCheckDbLimitImp(SAcctObj *pAcct) {
|
||||||
|
|
||||||
int32_t (*mgmtCheckDbLimit)(SAcctObj *pAcct) = mgmtCheckDbLimitImp;
|
int32_t (*mgmtCheckDbLimit)(SAcctObj *pAcct) = mgmtCheckDbLimitImp;
|
||||||
|
|
||||||
static int32_t mgmtCheckTableLimitImp(SAcctObj *pAcct, SCreateTableMsg *pCreate) {
|
static int32_t mgmtCheckTableLimitImp(SAcctObj *pAcct, SCMCreateTableMsg *pCreate) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t (*mgmtCheckTableLimit)(SAcctObj *pAcct, SCreateTableMsg *pCreate) = mgmtCheckTableLimitImp;
|
int32_t (*mgmtCheckTableLimit)(SAcctObj *pAcct, SCMCreateTableMsg *pCreate) = mgmtCheckTableLimitImp;
|
||||||
|
|
||||||
static void mgmtCleanUpAcctsImp() {
|
static void mgmtCleanUpAcctsImp() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,7 +233,7 @@ void mgmtCleanUpChildTables() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t *mgmtBuildCreateChildTableMsg(SChildTableObj *pTable, SVgObj *pVgroup) {
|
int8_t *mgmtBuildCreateChildTableMsg(SChildTableObj *pTable, SVgObj *pVgroup) {
|
||||||
// SCreateTableMsg *pCreateTable = (SCreateTableMsg *) pMsg;
|
// SCMCreateTableMsg *pCreateTable = (SCMCreateTableMsg *) pMsg;
|
||||||
// memcpy(pCreateTable->tableId, pTable->tableId, TSDB_TABLE_ID_LEN);
|
// memcpy(pCreateTable->tableId, pTable->tableId, TSDB_TABLE_ID_LEN);
|
||||||
// memcpy(pCreateTable->superTableId, pTable->superTable->tableId, TSDB_TABLE_ID_LEN);
|
// memcpy(pCreateTable->superTableId, pTable->superTable->tableId, TSDB_TABLE_ID_LEN);
|
||||||
// pCreateTable->vnode = htonl(vnode);
|
// pCreateTable->vnode = htonl(vnode);
|
||||||
|
@ -244,7 +244,7 @@ int8_t *mgmtBuildCreateChildTableMsg(SChildTableObj *pTable, SVgObj *pVgroup) {
|
||||||
// pCreateTable->numOfColumns = htons(pTable->superTable->numOfColumns);
|
// pCreateTable->numOfColumns = htons(pTable->superTable->numOfColumns);
|
||||||
// pCreateTable->numOfTags = htons(pTable->superTable->numOfTags);
|
// pCreateTable->numOfTags = htons(pTable->superTable->numOfTags);
|
||||||
//
|
//
|
||||||
// SSchema *pSchema = pTable->superTable->schema;
|
// SCMSchema *pSchema = pTable->superTable->schema;
|
||||||
// int32_t totalCols = pCreateTable->numOfColumns + pCreateTable->numOfTags;
|
// int32_t totalCols = pCreateTable->numOfColumns + pCreateTable->numOfTags;
|
||||||
//
|
//
|
||||||
// for (int32_t col = 0; col < totalCols; ++col) {
|
// for (int32_t col = 0; col < totalCols; ++col) {
|
||||||
|
@ -263,17 +263,17 @@ int8_t *mgmtBuildCreateChildTableMsg(SChildTableObj *pTable, SVgObj *pVgroup) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtCreateChildTable(SDbObj *pDb, SCreateTableMsg *pCreate, SVgObj *pVgroup, int32_t sid) {
|
int32_t mgmtCreateChildTable(SDbObj *pDb, SCMCreateTableMsg *pCreate, SVgObj *pVgroup, int32_t sid) {
|
||||||
int32_t numOfTables = sdbGetNumOfRows(tsChildTableSdb);
|
int32_t numOfTables = sdbGetNumOfRows(tsChildTableSdb);
|
||||||
if (numOfTables >= tsMaxTables) {
|
if (numOfTables >= tsMaxTables) {
|
||||||
mError("table:%s, numOfTables:%d exceed maxTables:%d", pCreate->meterId, numOfTables, tsMaxTables);
|
mError("table:%s, numOfTables:%d exceed maxTables:%d", pCreate->tableId, numOfTables, tsMaxTables);
|
||||||
return TSDB_CODE_TOO_MANY_TABLES;
|
return TSDB_CODE_TOO_MANY_TABLES;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *pTagData = (char *) pCreate->schema; // it is a tag key
|
char *pTagData = (char *) pCreate->schema; // it is a tag key
|
||||||
SSuperTableObj *pSuperTable = mgmtGetSuperTable(pTagData);
|
SSuperTableObj *pSuperTable = mgmtGetSuperTable(pTagData);
|
||||||
if (pSuperTable == NULL) {
|
if (pSuperTable == NULL) {
|
||||||
mError("table:%s, corresponding super table does not exist", pCreate->meterId);
|
mError("table:%s, corresponding super table does not exist", pCreate->tableId);
|
||||||
return TSDB_CODE_INVALID_TABLE;
|
return TSDB_CODE_INVALID_TABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ int32_t mgmtCreateChildTable(SDbObj *pDb, SCreateTableMsg *pCreate, SVgObj *pVgr
|
||||||
if (pTable == NULL) {
|
if (pTable == NULL) {
|
||||||
return TSDB_CODE_SERV_OUT_OF_MEMORY;
|
return TSDB_CODE_SERV_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
strcpy(pTable->tableId, pCreate->meterId);
|
strcpy(pTable->tableId, pCreate->tableId);
|
||||||
strcpy(pTable->superTableId, pSuperTable->tableId);
|
strcpy(pTable->superTableId, pSuperTable->tableId);
|
||||||
pTable->createdTime = taosGetTimestampMs();
|
pTable->createdTime = taosGetTimestampMs();
|
||||||
pTable->superTable = pSuperTable;
|
pTable->superTable = pSuperTable;
|
||||||
|
@ -291,16 +291,16 @@ int32_t mgmtCreateChildTable(SDbObj *pDb, SCreateTableMsg *pCreate, SVgObj *pVgr
|
||||||
((uint64_t) sdbGetVersion() & ((1ul << 16) - 1ul));
|
((uint64_t) sdbGetVersion() & ((1ul << 16) - 1ul));
|
||||||
|
|
||||||
int32_t size = mgmtGetTagsLength(pSuperTable, INT_MAX) + (uint32_t) TSDB_TABLE_ID_LEN;
|
int32_t size = mgmtGetTagsLength(pSuperTable, INT_MAX) + (uint32_t) TSDB_TABLE_ID_LEN;
|
||||||
SSchema * schema = (SSchema *) calloc(1, size);
|
SCMSchema * schema = (SCMSchema *) calloc(1, size);
|
||||||
if (schema == NULL) {
|
if (schema == NULL) {
|
||||||
free(pTable);
|
free(pTable);
|
||||||
mError("table:%s, corresponding super table schema is null", pCreate->meterId);
|
mError("table:%s, corresponding super table schema is null", pCreate->tableId);
|
||||||
return TSDB_CODE_INVALID_TABLE;
|
return TSDB_CODE_INVALID_TABLE;
|
||||||
}
|
}
|
||||||
memcpy(schema, pTagData + TSDB_TABLE_ID_LEN + 1, size);
|
memcpy(schema, pTagData + TSDB_TABLE_ID_LEN + 1, size);
|
||||||
|
|
||||||
if (sdbInsertRow(tsChildTableSdb, pTable, 0) < 0) {
|
if (sdbInsertRow(tsChildTableSdb, pTable, 0) < 0) {
|
||||||
mError("table:%s, update sdb error", pCreate->meterId);
|
mError("table:%s, update sdb error", pCreate->tableId);
|
||||||
return TSDB_CODE_SDB_ERROR;
|
return TSDB_CODE_SDB_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,7 +355,7 @@ int32_t mgmtModifyChildTableTagValueByName(SChildTableObj *pTable, char *tagName
|
||||||
// return TSDB_CODE_SUCCESS;
|
// return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
// int32_t rowSize = 0;
|
// int32_t rowSize = 0;
|
||||||
// SSchema *schema = (SSchema *)(pSuperTable->schema + (pSuperTable->numOfColumns + col) * sizeof(SSchema));
|
// SCMSchema *schema = (SCMSchema *)(pSuperTable->schema + (pSuperTable->numOfColumns + col) * sizeof(SCMSchema));
|
||||||
//
|
//
|
||||||
// if (col == 0) {
|
// if (col == 0) {
|
||||||
// pTable->isDirty = 1;
|
// pTable->isDirty = 1;
|
||||||
|
|
|
@ -71,7 +71,7 @@ int mgmtGetConnsMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int cols = 0;
|
int cols = 0;
|
||||||
|
|
||||||
pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SCMSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "user");
|
strcpy(pSchema[cols].name, "user");
|
||||||
|
|
|
@ -116,7 +116,7 @@ SDbObj *mgmtGetDbByTableId(char *meterId) {
|
||||||
return (SDbObj *)sdbGetRow(tsDbSdb, db);
|
return (SDbObj *)sdbGetRow(tsDbSdb, db);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtCheckDBParams(SCreateDbMsg *pCreate) {
|
int32_t mgmtCheckDBParams(SCMCreateDbMsg *pCreate) {
|
||||||
if (pCreate->commitLog < 0 || pCreate->commitLog > 1) {
|
if (pCreate->commitLog < 0 || pCreate->commitLog > 1) {
|
||||||
mError("invalid db option commitLog: %d, only 0 or 1 allowed", pCreate->commitLog);
|
mError("invalid db option commitLog: %d, only 0 or 1 allowed", pCreate->commitLog);
|
||||||
return TSDB_CODE_INVALID_OPTION;
|
return TSDB_CODE_INVALID_OPTION;
|
||||||
|
@ -189,7 +189,7 @@ int32_t mgmtCheckDBParams(SCreateDbMsg *pCreate) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtCheckDbParams(SCreateDbMsg *pCreate) {
|
int32_t mgmtCheckDbParams(SCMCreateDbMsg *pCreate) {
|
||||||
// assign default parameters
|
// assign default parameters
|
||||||
if (pCreate->maxSessions < 0) pCreate->maxSessions = tsSessionsPerVnode; //
|
if (pCreate->maxSessions < 0) pCreate->maxSessions = tsSessionsPerVnode; //
|
||||||
if (pCreate->cacheBlockSize < 0) pCreate->cacheBlockSize = tsCacheBlockSize; //
|
if (pCreate->cacheBlockSize < 0) pCreate->cacheBlockSize = tsCacheBlockSize; //
|
||||||
|
@ -234,7 +234,7 @@ int32_t mgmtCheckDbParams(SCreateDbMsg *pCreate) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate) {
|
int32_t mgmtCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate) {
|
||||||
int32_t code = mgmtCheckDbLimit(pAcct);
|
int32_t code = mgmtCheckDbLimit(pAcct);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -408,7 +408,7 @@ void mgmtMonitorDbDrop(void *unused, void *unusedt) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtAlterDb(SAcctObj *pAcct, SAlterDbMsg *pAlter) {
|
int32_t mgmtAlterDb(SAcctObj *pAcct, SCMAlterDbMsg *pAlter) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
SDbObj *pDb = (SDbObj *) sdbGetRow(tsDbSdb, pAlter->db);
|
SDbObj *pDb = (SDbObj *) sdbGetRow(tsDbSdb, pAlter->db);
|
||||||
|
@ -530,7 +530,7 @@ void mgmtCleanUpDbs() {
|
||||||
int32_t mgmtGetDbMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
int32_t mgmtGetDbMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SCMSchema *pSchema = tsGetSchema(pMeta);
|
||||||
SUserObj *pUser = mgmtGetUserFromConn(pConn);
|
SUserObj *pUser = mgmtGetUserFromConn(pConn);
|
||||||
if (pUser == NULL) return 0;
|
if (pUser == NULL) return 0;
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ int32_t mgmtGetDnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
|
|
||||||
if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
||||||
|
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SCMSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
|
||||||
pShow->bytes[cols] = 16;
|
pShow->bytes[cols] = 16;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
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;
|
if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
||||||
|
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SCMSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
|
||||||
pShow->bytes[cols] = 16;
|
pShow->bytes[cols] = 16;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
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;
|
if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
||||||
|
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SCMSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
|
||||||
pShow->bytes[cols] = TSDB_CFG_OPTION_LEN;
|
pShow->bytes[cols] = TSDB_CFG_OPTION_LEN;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
|
@ -399,7 +399,7 @@ int32_t mgmtGetVnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
if (pUser == NULL) return 0;
|
if (pUser == NULL) return 0;
|
||||||
if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
||||||
|
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SCMSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
|
||||||
pShow->bytes[cols] = 4;
|
pShow->bytes[cols] = 4;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||||
|
|
|
@ -499,7 +499,7 @@ int mgmtSendCfgDnodeMsg(char *cont) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SDnodeObj *pDnode;
|
SDnodeObj *pDnode;
|
||||||
SCfgMsg * pCfg = (SCfgMsg *)cont;
|
SCMCfgDnodeMsg * pCfg = (SCMCfgDnodeMsg *)cont;
|
||||||
uint32_t ip;
|
uint32_t ip;
|
||||||
|
|
||||||
ip = inet_addr(pCfg->ip);
|
ip = inet_addr(pCfg->ip);
|
||||||
|
@ -520,8 +520,8 @@ int mgmtSendCfgDnodeMsg(char *cont) {
|
||||||
if (pStart == NULL) return TSDB_CODE_NODE_OFFLINE;
|
if (pStart == NULL) return TSDB_CODE_NODE_OFFLINE;
|
||||||
pMsg = pStart;
|
pMsg = pStart;
|
||||||
|
|
||||||
memcpy(pMsg, cont, sizeof(SCfgMsg));
|
memcpy(pMsg, cont, sizeof(SCMCfgDnodeMsg));
|
||||||
pMsg += sizeof(SCfgMsg);
|
pMsg += sizeof(SCMCfgDnodeMsg);
|
||||||
|
|
||||||
msgLen = pMsg - pStart;
|
msgLen = pMsg - pStart;
|
||||||
mgmtSendMsgToDnode(pDnode, pStart, msgLen);
|
mgmtSendMsgToDnode(pDnode, pStart, msgLen);
|
||||||
|
|
|
@ -161,7 +161,7 @@ void *mgmtNormalTableActionEncode(void *row, char *str, int32_t size, int32_t *s
|
||||||
assert(row != NULL && str != NULL);
|
assert(row != NULL && str != NULL);
|
||||||
|
|
||||||
int32_t tsize = pTable->updateEnd - (int8_t *) pTable;
|
int32_t tsize = pTable->updateEnd - (int8_t *) pTable;
|
||||||
int32_t schemaSize = pTable->numOfColumns * sizeof(SSchema);
|
int32_t schemaSize = pTable->numOfColumns * sizeof(SCMSchema);
|
||||||
if (size < tsize + schemaSize + 1) {
|
if (size < tsize + schemaSize + 1) {
|
||||||
*ssize = -1;
|
*ssize = -1;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -190,8 +190,8 @@ void *mgmtNormalTableActionDecode(void *row, char *str, int32_t size, int32_t *s
|
||||||
}
|
}
|
||||||
memcpy(pTable, str, tsize);
|
memcpy(pTable, str, tsize);
|
||||||
|
|
||||||
int32_t schemaSize = pTable->numOfColumns * sizeof(SSchema);
|
int32_t schemaSize = pTable->numOfColumns * sizeof(SCMSchema);
|
||||||
pTable->schema = (SSchema *)malloc(schemaSize);
|
pTable->schema = (SCMSchema *)malloc(schemaSize);
|
||||||
if (pTable->schema == NULL) {
|
if (pTable->schema == NULL) {
|
||||||
mgmtDestroyNormalTable(pTable);
|
mgmtDestroyNormalTable(pTable);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -215,7 +215,7 @@ int32_t mgmtInitNormalTables() {
|
||||||
|
|
||||||
mgmtNormalTableActionInit();
|
mgmtNormalTableActionInit();
|
||||||
|
|
||||||
tsNormalTableSdb = sdbOpenTable(tsMaxTables, sizeof(SNormalTableObj) + sizeof(SSchema) * TSDB_MAX_COLUMNS,
|
tsNormalTableSdb = sdbOpenTable(tsMaxTables, sizeof(SNormalTableObj) + sizeof(SCMSchema) * TSDB_MAX_COLUMNS,
|
||||||
"ntables", SDB_KEYTYPE_STRING, tsMgmtDirectory, mgmtNormalTableAction);
|
"ntables", SDB_KEYTYPE_STRING, tsMgmtDirectory, mgmtNormalTableAction);
|
||||||
if (tsNormalTableSdb == NULL) {
|
if (tsNormalTableSdb == NULL) {
|
||||||
mError("failed to init normal table data");
|
mError("failed to init normal table data");
|
||||||
|
@ -259,7 +259,7 @@ int8_t *mgmtBuildCreateNormalTableMsg(SNormalTableObj *pTable) {
|
||||||
// pCreateTable->sversion = htobe32(pTable->sversion);
|
// pCreateTable->sversion = htobe32(pTable->sversion);
|
||||||
// pCreateTable->numOfColumns = htobe16(pTable->numOfColumns);
|
// pCreateTable->numOfColumns = htobe16(pTable->numOfColumns);
|
||||||
//
|
//
|
||||||
// SSchema *pSchema = pTable->schema;
|
// SCMSchema *pSchema = pTable->schema;
|
||||||
// int32_t totalCols = pCreateTable->numOfColumns;
|
// int32_t totalCols = pCreateTable->numOfColumns;
|
||||||
|
|
||||||
// for (int32_t col = 0; col < totalCols; ++col) {
|
// for (int32_t col = 0; col < totalCols; ++col) {
|
||||||
|
@ -276,10 +276,10 @@ int8_t *mgmtBuildCreateNormalTableMsg(SNormalTableObj *pTable) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtCreateNormalTable(SDbObj *pDb, SCreateTableMsg *pCreate, SVgObj *pVgroup, int32_t sid) {
|
int32_t mgmtCreateNormalTable(SDbObj *pDb, SCMCreateTableMsg *pCreate, SVgObj *pVgroup, int32_t sid) {
|
||||||
int32_t numOfTables = sdbGetNumOfRows(tsChildTableSdb);
|
int32_t numOfTables = sdbGetNumOfRows(tsChildTableSdb);
|
||||||
if (numOfTables >= TSDB_MAX_TABLES) {
|
if (numOfTables >= TSDB_MAX_TABLES) {
|
||||||
mError("normal table:%s, numOfTables:%d exceed maxTables:%d", pCreate->meterId, numOfTables, TSDB_MAX_TABLES);
|
mError("normal table:%s, numOfTables:%d exceed maxTables:%d", pCreate->tableId, numOfTables, TSDB_MAX_TABLES);
|
||||||
return TSDB_CODE_TOO_MANY_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;
|
return TSDB_CODE_SERV_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(pTable->tableId, pCreate->meterId);
|
strcpy(pTable->tableId, pCreate->tableId);
|
||||||
pTable->createdTime = taosGetTimestampMs();
|
pTable->createdTime = taosGetTimestampMs();
|
||||||
pTable->vgId = pVgroup->vgId;
|
pTable->vgId = pVgroup->vgId;
|
||||||
pTable->sid = sid;
|
pTable->sid = sid;
|
||||||
|
@ -297,23 +297,23 @@ int32_t mgmtCreateNormalTable(SDbObj *pDb, SCreateTableMsg *pCreate, SVgObj *pVg
|
||||||
pTable->numOfColumns = pCreate->numOfColumns;
|
pTable->numOfColumns = pCreate->numOfColumns;
|
||||||
|
|
||||||
int32_t numOfCols = pCreate->numOfColumns + pCreate->numOfTags;
|
int32_t numOfCols = pCreate->numOfColumns + pCreate->numOfTags;
|
||||||
int32_t schemaSize = numOfCols * sizeof(SSchema);
|
int32_t schemaSize = numOfCols * sizeof(SCMSchema);
|
||||||
pTable->schema = (SSchema *) calloc(1, schemaSize);
|
pTable->schema = (SCMSchema *) calloc(1, schemaSize);
|
||||||
if (pTable->schema == NULL) {
|
if (pTable->schema == NULL) {
|
||||||
free(pTable);
|
free(pTable);
|
||||||
mError("table:%s, no schema input", pCreate->meterId);
|
mError("table:%s, no schema input", pCreate->tableId);
|
||||||
return TSDB_CODE_INVALID_TABLE;
|
return TSDB_CODE_INVALID_TABLE;
|
||||||
}
|
}
|
||||||
memcpy(pTable->schema, pCreate->schema, numOfCols * sizeof(SSchema));
|
memcpy(pTable->schema, pCreate->schema, numOfCols * sizeof(SCMSchema));
|
||||||
|
|
||||||
pTable->nextColId = 0;
|
pTable->nextColId = 0;
|
||||||
for (int32_t col = 0; col < pCreate->numOfColumns; col++) {
|
for (int32_t col = 0; col < pCreate->numOfColumns; col++) {
|
||||||
SSchema *tschema = (SSchema *) pTable->schema;
|
SCMSchema *tschema = (SCMSchema *) pTable->schema;
|
||||||
tschema[col].colId = pTable->nextColId++;
|
tschema[col].colId = pTable->nextColId++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sdbInsertRow(tsNormalTableSdb, pTable, 0) < 0) {
|
if (sdbInsertRow(tsNormalTableSdb, pTable, 0) < 0) {
|
||||||
mError("table:%s, update sdb error", pCreate->meterId);
|
mError("table:%s, update sdb error", pCreate->tableId);
|
||||||
return TSDB_CODE_SDB_ERROR;
|
return TSDB_CODE_SDB_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,7 +362,7 @@ SNormalTableObj* mgmtGetNormalTable(char *tableId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mgmtFindNormalTableColumnIndex(SNormalTableObj *pTable, char *colName) {
|
static int32_t mgmtFindNormalTableColumnIndex(SNormalTableObj *pTable, char *colName) {
|
||||||
SSchema *schema = (SSchema *) pTable->schema;
|
SCMSchema *schema = (SCMSchema *) pTable->schema;
|
||||||
for (int32_t i = 0; i < pTable->numOfColumns; i++) {
|
for (int32_t i = 0; i < pTable->numOfColumns; i++) {
|
||||||
if (strcasecmp(schema[i].name, colName) == 0) {
|
if (strcasecmp(schema[i].name, colName) == 0) {
|
||||||
return i;
|
return i;
|
||||||
|
@ -372,7 +372,7 @@ static int32_t mgmtFindNormalTableColumnIndex(SNormalTableObj *pTable, char *col
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtAddNormalTableColumn(SNormalTableObj *pTable, SSchema schema[], int32_t ncols) {
|
int32_t mgmtAddNormalTableColumn(SNormalTableObj *pTable, SCMSchema schema[], int32_t ncols) {
|
||||||
if (ncols <= 0) {
|
if (ncols <= 0) {
|
||||||
return TSDB_CODE_APP_ERROR;
|
return TSDB_CODE_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -395,12 +395,12 @@ int32_t mgmtAddNormalTableColumn(SNormalTableObj *pTable, SSchema schema[], int3
|
||||||
return TSDB_CODE_APP_ERROR;
|
return TSDB_CODE_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schemaSize = pTable->numOfColumns * sizeof(SSchema);
|
int32_t schemaSize = pTable->numOfColumns * sizeof(SCMSchema);
|
||||||
pTable->schema = realloc(pTable->schema, schemaSize + sizeof(SSchema) * ncols);
|
pTable->schema = realloc(pTable->schema, schemaSize + sizeof(SCMSchema) * ncols);
|
||||||
|
|
||||||
memcpy(pTable->schema + schemaSize, schema, sizeof(SSchema) * ncols);
|
memcpy(pTable->schema + schemaSize, schema, sizeof(SCMSchema) * ncols);
|
||||||
|
|
||||||
SSchema *tschema = (SSchema *) (pTable->schema + sizeof(SSchema) * pTable->numOfColumns);
|
SCMSchema *tschema = (SCMSchema *) (pTable->schema + sizeof(SCMSchema) * pTable->numOfColumns);
|
||||||
for (int32_t i = 0; i < ncols; i++) {
|
for (int32_t i = 0; i < ncols; i++) {
|
||||||
tschema[i].colId = pTable->nextColId++;
|
tschema[i].colId = pTable->nextColId++;
|
||||||
}
|
}
|
||||||
|
@ -431,8 +431,8 @@ int32_t mgmtDropNormalTableColumnByName(SNormalTableObj *pTable, char *colName)
|
||||||
return TSDB_CODE_APP_ERROR;
|
return TSDB_CODE_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
memmove(pTable->schema + sizeof(SSchema) * col, pTable->schema + sizeof(SSchema) * (col + 1),
|
memmove(pTable->schema + sizeof(SCMSchema) * col, pTable->schema + sizeof(SCMSchema) * (col + 1),
|
||||||
sizeof(SSchema) * (pTable->numOfColumns - col - 1));
|
sizeof(SCMSchema) * (pTable->numOfColumns - col - 1));
|
||||||
|
|
||||||
pTable->numOfColumns--;
|
pTable->numOfColumns--;
|
||||||
pTable->sversion++;
|
pTable->sversion++;
|
||||||
|
|
|
@ -120,7 +120,7 @@ int32_t mgmtGetQueries(SShowObj *pShow, void *pConn) {
|
||||||
int32_t mgmtGetQueryMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
int32_t mgmtGetQueryMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SCMSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
|
||||||
pShow->bytes[cols] = TSDB_USER_LEN;
|
pShow->bytes[cols] = TSDB_USER_LEN;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
|
@ -318,7 +318,7 @@ int32_t mgmtGetStreams(SShowObj *pShow, void *pConn) {
|
||||||
|
|
||||||
int32_t mgmtGetStreamMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
int32_t mgmtGetStreamMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SCMSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
|
||||||
pShow->bytes[cols] = TSDB_USER_LEN;
|
pShow->bytes[cols] = TSDB_USER_LEN;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
#include "mgmtUser.h"
|
#include "mgmtUser.h"
|
||||||
#include "mgmtVgroup.h"
|
#include "mgmtVgroup.h"
|
||||||
|
|
||||||
#define MAX_LEN_OF_METER_META (sizeof(SMultiMeterMeta) + sizeof(SSchema) * TSDB_MAX_COLUMNS + sizeof(SSchema) * TSDB_MAX_TAGS + TSDB_MAX_TAGS_LEN)
|
#define MAX_LEN_OF_METER_META (sizeof(SMultiMeterMeta) + sizeof(SCMSchema) * TSDB_MAX_COLUMNS + sizeof(SCMSchema) * TSDB_MAX_TAGS + TSDB_MAX_TAGS_LEN)
|
||||||
|
|
||||||
typedef int32_t (*GetMateFp)(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
typedef int32_t (*GetMateFp)(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
typedef int32_t (*RetrieveMetaFp)(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
typedef int32_t (*RetrieveMetaFp)(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
|
@ -43,24 +43,21 @@ static GetMateFp* mgmtGetMetaFp;
|
||||||
static RetrieveMetaFp* mgmtRetrieveFp;
|
static RetrieveMetaFp* mgmtRetrieveFp;
|
||||||
static void mgmtInitShowMsgFp();
|
static void mgmtInitShowMsgFp();
|
||||||
|
|
||||||
void * tsShellConn = NULL;
|
void *tsShellConnServer = NULL;
|
||||||
|
|
||||||
|
static void mgmtInitProcessShellMsg();
|
||||||
static void mgmtProcessMsgFromShell(char type, void *pCont, int contLen, void *ahandle, int32_t code);
|
static void mgmtProcessMsgFromShell(char type, void *pCont, int contLen, void *ahandle, int32_t code);
|
||||||
static int32_t (*mgmtProcessShellMsg[TSDB_MSG_TYPE_MAX])(void *pCont, int32_t contLen, void *ahandle);
|
static int32_t (*mgmtProcessShellMsg[TSDB_MSG_TYPE_MAX])(void *pCont, int32_t contLen, void *ahandle);
|
||||||
|
static int32_t mgmtProcessUnSupportMsg(void *pCont, int32_t contLen, void *ahandle);
|
||||||
static int32_t mgmtRetriveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey);
|
static int32_t mgmtRetriveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey);
|
||||||
|
|
||||||
void mgmtInitProcessShellMsg();
|
|
||||||
int32_t mgmtKillQuery(char *queryId, void *pConn);
|
|
||||||
|
|
||||||
void mgmtProcessTranRequest(SSchedMsg *sched) {
|
void mgmtProcessTranRequest(SSchedMsg *sched) {
|
||||||
int8_t msgType = *(int8_t *) (sched->msg);
|
int8_t msgType = *(int8_t *) (sched->msg);
|
||||||
int32_t contLen = *(int32_t *) (sched->msg + sizeof(int8_t));
|
int32_t contLen = *(int32_t *) (sched->msg + sizeof(int8_t));
|
||||||
int8_t *pCont = sched->msg + sizeof(int32_t) + sizeof(int8_t);
|
int8_t *pCont = sched->msg + sizeof(int32_t) + sizeof(int8_t);
|
||||||
void *pConn = sched->thandle;
|
void *pConn = sched->thandle;
|
||||||
|
|
||||||
(*mgmtProcessShellMsg[msgType])(pCont, contLen, pConn);
|
(*mgmtProcessShellMsg[msgType])(pCont, contLen, pConn);
|
||||||
//rpcSendResponse(pConn, 12, NULL, 0);
|
|
||||||
|
|
||||||
if (sched->msg) {
|
if (sched->msg) {
|
||||||
free(sched->msg);
|
free(sched->msg);
|
||||||
}
|
}
|
||||||
|
@ -68,9 +65,9 @@ void mgmtProcessTranRequest(SSchedMsg *sched) {
|
||||||
|
|
||||||
void mgmtAddToTranRequest(int8_t type, void *pCont, int contLen, void *ahandle) {
|
void mgmtAddToTranRequest(int8_t type, void *pCont, int contLen, void *ahandle) {
|
||||||
SSchedMsg schedMsg;
|
SSchedMsg schedMsg;
|
||||||
schedMsg.msg = malloc(contLen + sizeof(int32_t) + sizeof(int8_t));
|
schedMsg.msg = malloc(contLen + sizeof(int32_t) + sizeof(int8_t));
|
||||||
schedMsg.fp = mgmtProcessTranRequest;
|
schedMsg.fp = mgmtProcessTranRequest;
|
||||||
schedMsg.tfp = NULL;
|
schedMsg.tfp = NULL;
|
||||||
schedMsg.thandle = ahandle;
|
schedMsg.thandle = ahandle;
|
||||||
*(int8_t *) (schedMsg.msg) = type;
|
*(int8_t *) (schedMsg.msg) = type;
|
||||||
*(int32_t *) (schedMsg.msg + sizeof(int8_t)) = contLen;
|
*(int32_t *) (schedMsg.msg + sizeof(int8_t)) = contLen;
|
||||||
|
@ -81,29 +78,27 @@ void mgmtAddToTranRequest(int8_t type, void *pCont, int contLen, void *ahandle)
|
||||||
|
|
||||||
int32_t mgmtInitShell() {
|
int32_t mgmtInitShell() {
|
||||||
SRpcInit rpcInit;
|
SRpcInit rpcInit;
|
||||||
|
|
||||||
mgmtInitProcessShellMsg();
|
mgmtInitProcessShellMsg();
|
||||||
mgmtInitShowMsgFp();
|
mgmtInitShowMsgFp();
|
||||||
|
|
||||||
int32_t numOfThreads = tsNumOfCores * tsNumOfThreadsPerCore / 4.0;
|
int32_t numOfThreads = tsNumOfCores * tsNumOfThreadsPerCore / 4.0;
|
||||||
if (numOfThreads < 1) numOfThreads = 1;
|
if (numOfThreads < 1) {
|
||||||
|
numOfThreads = 1;
|
||||||
//TODO
|
}
|
||||||
numOfThreads = 1;
|
|
||||||
|
|
||||||
memset(&rpcInit, 0, sizeof(rpcInit));
|
memset(&rpcInit, 0, sizeof(rpcInit));
|
||||||
rpcInit.localIp = tsAnyIp ? "0.0.0.0" : tsPrivateIp;;
|
rpcInit.localIp = tsAnyIp ? "0.0.0.0" : tsPrivateIp;;
|
||||||
rpcInit.localPort = tsMgmtShellPort;
|
rpcInit.localPort = tsMgmtShellPort;
|
||||||
rpcInit.label = "MND-shell";
|
rpcInit.label = "MND-shell";
|
||||||
rpcInit.numOfThreads = numOfThreads;
|
rpcInit.numOfThreads = numOfThreads;
|
||||||
rpcInit.cfp = mgmtProcessMsgFromShell;
|
rpcInit.cfp = mgmtProcessMsgFromShell;
|
||||||
rpcInit.sessions = tsMaxShellConns;
|
rpcInit.sessions = tsMaxShellConns;
|
||||||
rpcInit.connType = TAOS_CONN_SERVER;
|
rpcInit.connType = TAOS_CONN_SERVER;
|
||||||
rpcInit.idleTime = tsShellActivityTimer * 2000;
|
rpcInit.idleTime = tsShellActivityTimer * 2000;
|
||||||
rpcInit.afp = mgmtRetriveUserAuthInfo;
|
rpcInit.afp = mgmtRetriveUserAuthInfo;
|
||||||
|
|
||||||
tsShellConn = rpcOpen(&rpcInit);
|
tsShellConnServer = rpcOpen(&rpcInit);
|
||||||
if (tsShellConn == NULL) {
|
if (tsShellConnServer == NULL) {
|
||||||
mError("failed to init tcp connection to shell");
|
mError("failed to init tcp connection to shell");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -112,17 +107,17 @@ int32_t mgmtInitShell() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void mgmtCleanUpShell() {
|
void mgmtCleanUpShell() {
|
||||||
if (tsShellConn) {
|
if (tsShellConnServer) {
|
||||||
rpcClose(tsShellConn);
|
rpcClose(tsShellConnServer);
|
||||||
tsShellConn = NULL;
|
tsShellConnServer = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mgmtSetSchemaFromMeters(SSchema *pSchema, STabObj *pMeterObj, uint32_t numOfCols) {
|
static void mgmtSetSchemaFromMeters(SCMSchema *pSchema, STabObj *pMeterObj, uint32_t numOfCols) {
|
||||||
SSchema *pMeterSchema = (SSchema *)(pMeterObj->schema);
|
SCMSchema *pMeterSchema = (SCMSchema *)(pMeterObj->schema);
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
pSchema->type = pMeterSchema[i].type;
|
|
||||||
strcpy(pSchema->name, pMeterSchema[i].name);
|
strcpy(pSchema->name, pMeterSchema[i].name);
|
||||||
|
pSchema->type = pMeterSchema[i].type;
|
||||||
pSchema->bytes = htons(pMeterSchema[i].bytes);
|
pSchema->bytes = htons(pMeterSchema[i].bytes);
|
||||||
pSchema->colId = htons(pMeterSchema[i].colId);
|
pSchema->colId = htons(pMeterSchema[i].colId);
|
||||||
pSchema++;
|
pSchema++;
|
||||||
|
@ -130,7 +125,7 @@ static void mgmtSetSchemaFromMeters(SSchema *pSchema, STabObj *pMeterObj, uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t mgmtSetMeterTagValue(char *pTags, STabObj *pMetric, STabObj *pMeterObj) {
|
static uint32_t mgmtSetMeterTagValue(char *pTags, STabObj *pMetric, STabObj *pMeterObj) {
|
||||||
SSchema *pTagSchema = (SSchema *)(pMetric->schema + pMetric->numOfColumns * sizeof(SSchema));
|
SCMSchema *pTagSchema = (SCMSchema *)(pMetric->schema + pMetric->numOfColumns * sizeof(SCMSchema));
|
||||||
|
|
||||||
char *tagVal = pMeterObj->pTagData + TSDB_TABLE_ID_LEN; // tag start position
|
char *tagVal = pMeterObj->pTagData + TSDB_TABLE_ID_LEN; // tag start position
|
||||||
|
|
||||||
|
@ -148,14 +143,14 @@ int32_t mgmtProcessMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// STabObj * pMeterObj = NULL;
|
// STabObj * pMeterObj = NULL;
|
||||||
// SVgObj * pVgroup = NULL;
|
// SVgObj * pVgroup = NULL;
|
||||||
// SMeterMeta * pMeta = NULL;
|
// SMeterMeta * pMeta = NULL;
|
||||||
// SSchema * pSchema = NULL;
|
// SCMSchema * pSchema = NULL;
|
||||||
// STaosRsp * pRsp = NULL;
|
// STaosRsp * pRsp = NULL;
|
||||||
// char * pStart = NULL;
|
// char * pStart = NULL;
|
||||||
//
|
//
|
||||||
// pInfo->createFlag = htons(pInfo->createFlag);
|
// pInfo->createFlag = htons(pInfo->createFlag);
|
||||||
//
|
//
|
||||||
// int32_t size = sizeof(STaosHeader) + sizeof(STaosRsp) + sizeof(SMeterMeta) + sizeof(SSchema) * TSDB_MAX_COLUMNS +
|
// int32_t size = sizeof(STaosHeader) + sizeof(STaosRsp) + sizeof(SMeterMeta) + sizeof(SCMSchema) * TSDB_MAX_COLUMNS +
|
||||||
// sizeof(SSchema) * TSDB_MAX_TAGS + TSDB_MAX_TAGS_LEN + TSDB_EXTRA_PAYLOAD_SIZE;
|
// sizeof(SCMSchema) * TSDB_MAX_TAGS + TSDB_MAX_TAGS_LEN + TSDB_EXTRA_PAYLOAD_SIZE;
|
||||||
//
|
//
|
||||||
// SDbObj *pDb = NULL;
|
// SDbObj *pDb = NULL;
|
||||||
// if (pConn->pDb != NULL) pDb = mgmtGetDb(pConn->pDb->name);
|
// if (pConn->pDb != NULL) pDb = mgmtGetDb(pConn->pDb->name);
|
||||||
|
@ -183,7 +178,7 @@ int32_t mgmtProcessMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// return 0;
|
// return 0;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// SCreateTableMsg *pCreateMsg = calloc(1, sizeof(SCreateTableMsg) + sizeof(STagData));
|
// SCMCreateTableMsg *pCreateMsg = calloc(1, sizeof(SCMCreateTableMsg) + sizeof(STagData));
|
||||||
// if (pCreateMsg == NULL) {
|
// if (pCreateMsg == NULL) {
|
||||||
// taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_TABLE_META_RSP, TSDB_CODE_SERV_OUT_OF_MEMORY);
|
// taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_TABLE_META_RSP, TSDB_CODE_SERV_OUT_OF_MEMORY);
|
||||||
// return 0;
|
// return 0;
|
||||||
|
@ -193,7 +188,7 @@ int32_t mgmtProcessMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// strcpy(pCreateMsg->meterId, pInfo->meterId);
|
// strcpy(pCreateMsg->meterId, pInfo->meterId);
|
||||||
//
|
//
|
||||||
// SDbObj* pMeterDb = mgmtGetDbByTableId(pCreateMsg->meterId);
|
// SDbObj* pMeterDb = mgmtGetDbByTableId(pCreateMsg->meterId);
|
||||||
// mTrace("meter:%s, pConnDb:%p, pConnDbName:%s, pMeterDb:%p, pMeterDbName:%s",
|
// mTrace("table:%s, pConnDb:%p, pConnDbName:%s, pMeterDb:%p, pMeterDbName:%s",
|
||||||
// pCreateMsg->meterId, pDb, pDb->name, pMeterDb, pMeterDb->name);
|
// pCreateMsg->meterId, pDb, pDb->name, pMeterDb, pMeterDb->name);
|
||||||
// assert(pDb == pMeterDb);
|
// assert(pDb == pMeterDb);
|
||||||
//
|
//
|
||||||
|
@ -201,7 +196,7 @@ int32_t mgmtProcessMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
//
|
//
|
||||||
// char stableName[TSDB_TABLE_ID_LEN] = {0};
|
// char stableName[TSDB_TABLE_ID_LEN] = {0};
|
||||||
// strncpy(stableName, pInfo->tags, TSDB_TABLE_ID_LEN);
|
// strncpy(stableName, pInfo->tags, TSDB_TABLE_ID_LEN);
|
||||||
// mTrace("meter:%s is automatically created by %s from %s, code:%d", pCreateMsg->meterId, pConn->pUser->user,
|
// mTrace("table:%s is automatically created by %s from %s, code:%d", pCreateMsg->meterId, pConn->pUser->user,
|
||||||
// stableName, code);
|
// stableName, code);
|
||||||
//
|
//
|
||||||
// tfree(pCreateMsg);
|
// tfree(pCreateMsg);
|
||||||
|
@ -252,7 +247,7 @@ int32_t mgmtProcessMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// pMeta->tableType = pMeterObj->tableType;
|
// pMeta->tableType = pMeterObj->tableType;
|
||||||
//
|
//
|
||||||
// pMsg += sizeof(SMeterMeta);
|
// pMsg += sizeof(SMeterMeta);
|
||||||
// pSchema = (SSchema *)pMsg; // schema locates at the end of SMeterMeta struct
|
// pSchema = (SCMSchema *)pMsg; // schema locates at the end of SMeterMeta struct
|
||||||
//
|
//
|
||||||
// if (mgmtTableCreateFromSuperTable(pMeterObj)) {
|
// if (mgmtTableCreateFromSuperTable(pMeterObj)) {
|
||||||
// assert(pMeterObj->numOfTags == 0);
|
// assert(pMeterObj->numOfTags == 0);
|
||||||
|
@ -262,7 +257,7 @@ int32_t mgmtProcessMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
//
|
//
|
||||||
// pMeta->numOfTags = pMetric->numOfTags; // update the numOfTags info
|
// pMeta->numOfTags = pMetric->numOfTags; // update the numOfTags info
|
||||||
// mgmtSetSchemaFromMeters(pSchema, pMetric, numOfTotalCols);
|
// mgmtSetSchemaFromMeters(pSchema, pMetric, numOfTotalCols);
|
||||||
// pMsg += numOfTotalCols * sizeof(SSchema);
|
// pMsg += numOfTotalCols * sizeof(SCMSchema);
|
||||||
//
|
//
|
||||||
// // for meters created from metric, we need the metric tag schema to parse the tag data
|
// // for meters created from metric, we need the metric tag schema to parse the tag data
|
||||||
// int32_t tagsLen = mgmtSetMeterTagValue(pMsg, pMetric, pMeterObj);
|
// int32_t tagsLen = mgmtSetMeterTagValue(pMsg, pMetric, pMeterObj);
|
||||||
|
@ -274,7 +269,7 @@ int32_t mgmtProcessMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// */
|
// */
|
||||||
// uint32_t numOfTotalCols = (uint32_t)pMeterObj->numOfTags + pMeterObj->numOfColumns;
|
// uint32_t numOfTotalCols = (uint32_t)pMeterObj->numOfTags + pMeterObj->numOfColumns;
|
||||||
// mgmtSetSchemaFromMeters(pSchema, pMeterObj, numOfTotalCols);
|
// mgmtSetSchemaFromMeters(pSchema, pMeterObj, numOfTotalCols);
|
||||||
// pMsg += numOfTotalCols * sizeof(SSchema);
|
// pMsg += numOfTotalCols * sizeof(SCMSchema);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// if (mgmtIsNormalTable(pMeterObj)) {
|
// if (mgmtIsNormalTable(pMeterObj)) {
|
||||||
|
@ -306,10 +301,10 @@ int32_t mgmtProcessMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* multi meter meta rsp pkg format:
|
* multi meter meta rsp pkg format:
|
||||||
* | STaosRsp | ieType | SMultiMeterInfoMsg | SMeterMeta0 | SSchema0 | SMeterMeta1 | SSchema1 | SMeterMeta2 | SSchema2
|
* | STaosRsp | ieType | SMultiMeterInfoMsg | SMeterMeta0 | SCMSchema0 | SMeterMeta1 | SCMSchema1 | SMeterMeta2 | SCMSchema2
|
||||||
* 1B 1B 4B
|
* 1B 1B 4B
|
||||||
*
|
*
|
||||||
* | STaosHeader | STaosRsp | ieType | SMultiMeterInfoMsg | SMeterMeta0 | SSchema0 | SMeterMeta1 | SSchema1 | ......................|
|
* | STaosHeader | STaosRsp | ieType | SMultiMeterInfoMsg | SMeterMeta0 | SCMSchema0 | SMeterMeta1 | SCMSchema1 | ......................|
|
||||||
* ^ ^ ^
|
* ^ ^ ^
|
||||||
* |<--------------------------------------size-----------------------------------------------|---------------------->|
|
* |<--------------------------------------size-----------------------------------------------|---------------------->|
|
||||||
* | | |
|
* | | |
|
||||||
|
@ -320,7 +315,7 @@ int32_t mgmtProcessMultiMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle
|
||||||
// STabObj * pMeterObj = NULL;
|
// STabObj * pMeterObj = NULL;
|
||||||
// SVgObj * pVgroup = NULL;
|
// SVgObj * pVgroup = NULL;
|
||||||
// SMultiMeterMeta * pMeta = NULL;
|
// SMultiMeterMeta * pMeta = NULL;
|
||||||
// SSchema * pSchema = NULL;
|
// SCMSchema * pSchema = NULL;
|
||||||
// STaosRsp * pRsp = NULL;
|
// STaosRsp * pRsp = NULL;
|
||||||
// char * pStart = NULL;
|
// char * pStart = NULL;
|
||||||
//
|
//
|
||||||
|
@ -393,7 +388,7 @@ int32_t mgmtProcessMultiMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle
|
||||||
// pMeta->meta.tableType = pMeterObj->tableType;
|
// pMeta->meta.tableType = pMeterObj->tableType;
|
||||||
//
|
//
|
||||||
// pCurMeter += sizeof(SMultiMeterMeta);
|
// pCurMeter += sizeof(SMultiMeterMeta);
|
||||||
// pSchema = (SSchema *)pCurMeter; // schema locates at the end of SMeterMeta struct
|
// pSchema = (SCMSchema *)pCurMeter; // schema locates at the end of SMeterMeta struct
|
||||||
//
|
//
|
||||||
// if (mgmtTableCreateFromSuperTable(pMeterObj)) {
|
// if (mgmtTableCreateFromSuperTable(pMeterObj)) {
|
||||||
// assert(pMeterObj->numOfTags == 0);
|
// assert(pMeterObj->numOfTags == 0);
|
||||||
|
@ -403,7 +398,7 @@ int32_t mgmtProcessMultiMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle
|
||||||
//
|
//
|
||||||
// pMeta->meta.numOfTags = pMetric->numOfTags; // update the numOfTags info
|
// pMeta->meta.numOfTags = pMetric->numOfTags; // update the numOfTags info
|
||||||
// mgmtSetSchemaFromMeters(pSchema, pMetric, numOfTotalCols);
|
// mgmtSetSchemaFromMeters(pSchema, pMetric, numOfTotalCols);
|
||||||
// pCurMeter += numOfTotalCols * sizeof(SSchema);
|
// pCurMeter += numOfTotalCols * sizeof(SCMSchema);
|
||||||
//
|
//
|
||||||
// // for meters created from metric, we need the metric tag schema to parse the tag data
|
// // for meters created from metric, we need the metric tag schema to parse the tag data
|
||||||
// int32_t tagsLen = mgmtSetMeterTagValue(pCurMeter, pMetric, pMeterObj);
|
// int32_t tagsLen = mgmtSetMeterTagValue(pCurMeter, pMetric, pMeterObj);
|
||||||
|
@ -415,7 +410,7 @@ int32_t mgmtProcessMultiMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle
|
||||||
// */
|
// */
|
||||||
// uint32_t numOfTotalCols = (uint32_t)pMeterObj->numOfTags + pMeterObj->numOfColumns;
|
// uint32_t numOfTotalCols = (uint32_t)pMeterObj->numOfTags + pMeterObj->numOfColumns;
|
||||||
// mgmtSetSchemaFromMeters(pSchema, pMeterObj, numOfTotalCols);
|
// mgmtSetSchemaFromMeters(pSchema, pMeterObj, numOfTotalCols);
|
||||||
// pCurMeter += numOfTotalCols * sizeof(SSchema);
|
// pCurMeter += numOfTotalCols * sizeof(SCMSchema);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// if (mgmtIsNormalTable(pMeterObj)) {
|
// if (mgmtIsNormalTable(pMeterObj)) {
|
||||||
|
@ -522,114 +517,145 @@ int32_t mgmtProcessMetricMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessCreateDbMsg(void *pCont, int32_t contLen, void *ahandle) {
|
int32_t mgmtProcessCreateDbMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// SCreateDbMsg *pCreate = (SCreateDbMsg *)pMsg;
|
if (mgmtCheckRedirectMsg(ahandle) != 0) {
|
||||||
// int32_t code = 0;
|
return TSDB_CODE_REDIRECT;
|
||||||
//
|
}
|
||||||
// if (mgmtCheckRedirectMsg(pConn, TSDB_MSG_TYPE_CREATE_DB_RSP) != 0) {
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// pCreate->maxSessions = htonl(pCreate->maxSessions);
|
|
||||||
// pCreate->cacheBlockSize = htonl(pCreate->cacheBlockSize);
|
|
||||||
// // pCreate->cacheNumOfBlocks = htonl(pCreate->cacheNumOfBlocks);
|
|
||||||
// pCreate->daysPerFile = htonl(pCreate->daysPerFile);
|
|
||||||
// pCreate->daysToKeep = htonl(pCreate->daysToKeep);
|
|
||||||
// pCreate->daysToKeep1 = htonl(pCreate->daysToKeep1);
|
|
||||||
// pCreate->daysToKeep2 = htonl(pCreate->daysToKeep2);
|
|
||||||
// pCreate->commitTime = htonl(pCreate->commitTime);
|
|
||||||
// pCreate->blocksPerMeter = htons(pCreate->blocksPerMeter);
|
|
||||||
// pCreate->rowsInFileBlock = htonl(pCreate->rowsInFileBlock);
|
|
||||||
//
|
|
||||||
// if (mgmtCheckExpired()) {
|
|
||||||
// code = TSDB_CODE_GRANT_EXPIRED;
|
|
||||||
// } else if (!pConn->writeAuth) {
|
|
||||||
// code = TSDB_CODE_NO_RIGHTS;
|
|
||||||
// } else {
|
|
||||||
// code = mgmtCreateDb(pConn->pAcct, pCreate);
|
|
||||||
// if (code == TSDB_CODE_SUCCESS) {
|
|
||||||
// mLPrint("DB:%s is created by %s", pCreate->db, pConn->pUser->user);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_CREATE_DB_RSP, code);
|
|
||||||
|
|
||||||
return 0;
|
SUserObj *pUser = mgmtGetUserFromConn(ahandle);
|
||||||
}
|
if (pUser == NULL) {
|
||||||
|
rpcSendResponse(ahandle, TSDB_CODE_INVALID_USER, NULL, 0);
|
||||||
|
return TSDB_CODE_INVALID_USER;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessCreateMnodeMsg(void *pCont, int32_t contLen, void *ahandle) {
|
SCMCreateDbMsg *pCreate = (SCMCreateDbMsg *) pCont;
|
||||||
// return rpcSendResponse(pConn->thandle, TSDB_MSG_TYPE_CREATE_MNODE_RSP, TSDB_CODE_OPS_NOT_SUPPORT);
|
|
||||||
return 0;
|
pCreate->maxSessions = htonl(pCreate->maxSessions);
|
||||||
|
pCreate->cacheBlockSize = htonl(pCreate->cacheBlockSize);
|
||||||
|
pCreate->daysPerFile = htonl(pCreate->daysPerFile);
|
||||||
|
pCreate->daysToKeep = htonl(pCreate->daysToKeep);
|
||||||
|
pCreate->daysToKeep1 = htonl(pCreate->daysToKeep1);
|
||||||
|
pCreate->daysToKeep2 = htonl(pCreate->daysToKeep2);
|
||||||
|
pCreate->commitTime = htonl(pCreate->commitTime);
|
||||||
|
pCreate->blocksPerMeter = htons(pCreate->blocksPerMeter);
|
||||||
|
pCreate->rowsInFileBlock = htonl(pCreate->rowsInFileBlock);
|
||||||
|
// pCreate->cacheNumOfBlocks = htonl(pCreate->cacheNumOfBlocks);
|
||||||
|
|
||||||
|
int32_t code;
|
||||||
|
if (mgmtCheckExpired()) {
|
||||||
|
code = TSDB_CODE_GRANT_EXPIRED;
|
||||||
|
} else if (!pUser->writeAuth) {
|
||||||
|
code = TSDB_CODE_NO_RIGHTS;
|
||||||
|
} else {
|
||||||
|
code = mgmtCreateDb(pUser->pAcct, pCreate);
|
||||||
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
mLPrint("DB:%s is created by %s", pCreate->db, pUser->user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rpcSendResponse(ahandle, code, NULL, 0);
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessAlterDbMsg(void *pCont, int32_t contLen, void *ahandle) {
|
int32_t mgmtProcessAlterDbMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// SAlterDbMsg *pAlter = (SAlterDbMsg *)pMsg;
|
if (mgmtCheckRedirectMsg(ahandle) != 0) {
|
||||||
// int32_t code = 0;
|
return TSDB_CODE_REDIRECT;
|
||||||
//
|
}
|
||||||
// if (mgmtCheckRedirectMsg(pConn, TSDB_MSG_TYPE_ALTER_DB_RSP) != 0) {
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// pAlter->daysPerFile = htonl(pAlter->daysPerFile);
|
|
||||||
// pAlter->daysToKeep = htonl(pAlter->daysToKeep);
|
|
||||||
// pAlter->maxSessions = htonl(pAlter->maxSessions) + 1;
|
|
||||||
//
|
|
||||||
// if (!pConn->writeAuth) {
|
|
||||||
// code = TSDB_CODE_NO_RIGHTS;
|
|
||||||
// } else {
|
|
||||||
// code = mgmtAlterDb(pConn->pAcct, pAlter);
|
|
||||||
// if (code == TSDB_CODE_SUCCESS) {
|
|
||||||
// mLPrint("DB:%s is altered by %s", pAlter->db, pConn->pUser->user);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_ALTER_DB_RSP, code);
|
|
||||||
|
|
||||||
return 0;
|
SUserObj *pUser = mgmtGetUserFromConn(ahandle);
|
||||||
|
if (pUser == NULL) {
|
||||||
|
rpcSendResponse(ahandle, TSDB_CODE_INVALID_USER, NULL, 0);
|
||||||
|
return TSDB_CODE_INVALID_USER;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCMAlterDbMsg *pAlter = (SCMAlterDbMsg *) pCont;
|
||||||
|
pAlter->daysPerFile = htonl(pAlter->daysPerFile);
|
||||||
|
pAlter->daysToKeep = htonl(pAlter->daysToKeep);
|
||||||
|
pAlter->maxSessions = htonl(pAlter->maxSessions) + 1;
|
||||||
|
|
||||||
|
int32_t code;
|
||||||
|
if (!pUser->writeAuth) {
|
||||||
|
code = TSDB_CODE_NO_RIGHTS;
|
||||||
|
} else {
|
||||||
|
code = mgmtAlterDb(pUser->pAcct, pAlter);
|
||||||
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
mLPrint("DB:%s is altered by %s", pAlter->db, pUser->user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rpcSendResponse(ahandle, code, NULL, 0);
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessKillQueryMsg(void *pCont, int32_t contLen, void *ahandle) {
|
int32_t mgmtProcessKillQueryMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// int32_t code = 0;
|
if (mgmtCheckRedirectMsg(ahandle) != 0) {
|
||||||
// SKillQuery *pKill = (SKillQuery *)pMsg;
|
return TSDB_CODE_REDIRECT;
|
||||||
//
|
}
|
||||||
// if (!pConn->writeAuth) {
|
|
||||||
// code = TSDB_CODE_NO_RIGHTS;
|
|
||||||
// } else {
|
|
||||||
// code = mgmtKillQuery(pKill->queryId, pConn);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_KILL_QUERY_RSP, code);
|
|
||||||
|
|
||||||
return 0;
|
SUserObj *pUser = mgmtGetUserFromConn(ahandle);
|
||||||
|
if (pUser == NULL) {
|
||||||
|
rpcSendResponse(ahandle, TSDB_CODE_INVALID_USER, NULL, 0);
|
||||||
|
return TSDB_CODE_INVALID_USER;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCMKillQueryMsg *pKill = (SCMKillQueryMsg *) pCont;
|
||||||
|
int32_t code;
|
||||||
|
|
||||||
|
if (!pUser->writeAuth) {
|
||||||
|
code = TSDB_CODE_NO_RIGHTS;
|
||||||
|
} else {
|
||||||
|
code = mgmtKillQuery(pKill->queryId, ahandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
rpcSendResponse(ahandle, code, NULL, 0);
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessKillStreamMsg(void *pCont, int32_t contLen, void *ahandle) {
|
int32_t mgmtProcessKillStreamMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// int32_t code = 0;
|
if (mgmtCheckRedirectMsg(ahandle) != 0) {
|
||||||
// SKillStream *pKill = (SKillStream *)pMsg;
|
return TSDB_CODE_REDIRECT;
|
||||||
//
|
}
|
||||||
// if (!pConn->writeAuth) {
|
|
||||||
// code = TSDB_CODE_NO_RIGHTS;
|
|
||||||
// } else {
|
|
||||||
// code = mgmtKillStream(pKill->queryId, pConn);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_KILL_STREAM_RSP, code);
|
|
||||||
|
|
||||||
return 0;
|
SUserObj *pUser = mgmtGetUserFromConn(ahandle);
|
||||||
|
if (pUser == NULL) {
|
||||||
|
rpcSendResponse(ahandle, TSDB_CODE_INVALID_USER, NULL, 0);
|
||||||
|
return TSDB_CODE_INVALID_USER;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCMKillStreamMsg *pKill = (SCMKillStreamMsg *) pCont;
|
||||||
|
int32_t code;
|
||||||
|
|
||||||
|
if (!pUser->writeAuth) {
|
||||||
|
code = TSDB_CODE_NO_RIGHTS;
|
||||||
|
} else {
|
||||||
|
code = mgmtKillStream(pKill->queryId, ahandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
rpcSendResponse(ahandle, code, NULL, 0);
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessKillConnectionMsg(void *pCont, int32_t contLen, void *ahandle) {
|
int32_t mgmtProcessKillConnectionMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// int32_t code = 0;
|
if (mgmtCheckRedirectMsg(ahandle) != 0) {
|
||||||
// SKillConnection *pKill = (SKillConnection *)pMsg;
|
return TSDB_CODE_REDIRECT;
|
||||||
//
|
}
|
||||||
// if (!pConn->superAuth) {
|
|
||||||
// code = TSDB_CODE_NO_RIGHTS;
|
|
||||||
// } else {
|
|
||||||
// code = mgmtKillConnection(pKill->queryId, pConn);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_KILL_CONNECTION_RSP, code);
|
|
||||||
|
|
||||||
return 0;
|
SUserObj *pUser = mgmtGetUserFromConn(ahandle);
|
||||||
|
if (pUser == NULL) {
|
||||||
|
rpcSendResponse(ahandle, TSDB_CODE_INVALID_USER, NULL, 0);
|
||||||
|
return TSDB_CODE_INVALID_USER;
|
||||||
|
}
|
||||||
|
|
||||||
|
SKillConnectionMsg *pKill = (SKillConnectionMsg *) pCont;
|
||||||
|
int32_t code;
|
||||||
|
|
||||||
|
if (!pUser->writeAuth) {
|
||||||
|
code = TSDB_CODE_NO_RIGHTS;
|
||||||
|
} else {
|
||||||
|
code = mgmtKillConnection(pKill->queryId, ahandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
rpcSendResponse(ahandle, code, NULL, 0);
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessCreateUserMsg(void *pCont, int32_t contLen, void *ahandle) {
|
int32_t mgmtProcessCreateUserMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
|
@ -820,36 +846,29 @@ int32_t mgmtProcessDropUserMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessDropDbMsg(void *pCont, int32_t contLen, void *ahandle) {
|
int32_t mgmtProcessDropDbMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// SDropDbMsg *pDrop = (SDropDbMsg *)pMsg;
|
if (mgmtCheckRedirectMsg(ahandle) != 0) {
|
||||||
// int32_t code;
|
return TSDB_CODE_REDIRECT;
|
||||||
//
|
}
|
||||||
// if (mgmtCheckRedirectMsg(pConn, TSDB_MSG_TYPE_DROP_DB_RSP) != 0) {
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (!pConn->writeAuth) {
|
|
||||||
// code = TSDB_CODE_NO_RIGHTS;
|
|
||||||
// } else {
|
|
||||||
// code = mgmtDropDbByName(pConn->pAcct, pDrop->db, pDrop->ignoreNotExists);
|
|
||||||
// if (code == 0) {
|
|
||||||
// mLPrint("DB:%s is dropped by %s", pDrop->db, pConn->pUser->user);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_DROP_DB_RSP, code);
|
|
||||||
|
|
||||||
return 0;
|
SUserObj *pUser = mgmtGetUserFromConn(ahandle);
|
||||||
}
|
if (pUser == NULL) {
|
||||||
|
rpcSendResponse(ahandle, TSDB_CODE_INVALID_USER, NULL, 0);
|
||||||
|
return TSDB_CODE_INVALID_USER;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessUseDbMsg(void *pCont, int32_t contLen, void *ahandle) {
|
int32_t code;
|
||||||
// SUseDbMsg *pUse = (SUseDbMsg *)pMsg;
|
if (pUser->superAuth) {
|
||||||
// int32_t code;
|
SCMDropDbMsg *pDrop = pCont;
|
||||||
//
|
code = mgmtDropDbByName(pUser->pAcct, pDrop->db, pDrop->ignoreNotExists);
|
||||||
// code = mgmtUseDb(pConn, pUse->db);
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
// if (code == 0) mTrace("DB is change to:%s by %s", pUse->db, pConn->pUser->user);
|
mLPrint("DB:%s is dropped by %s", pDrop->db, pUser->user);
|
||||||
//
|
}
|
||||||
// taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_USE_DB_RSP, code);
|
} else {
|
||||||
|
code = TSDB_CODE_NO_RIGHTS;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
rpcSendResponse(ahandle, code, NULL, 0);
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mgmtInitShowMsgFp() {
|
static void mgmtInitShowMsgFp() {
|
||||||
|
@ -904,7 +923,7 @@ int32_t mgmtProcessShowMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// int32_t size = sizeof(STaosHeader) + sizeof(STaosRsp) + sizeof(SShowRspMsg) + sizeof(SSchema) * TSDB_MAX_COLUMNS +
|
// int32_t size = sizeof(STaosHeader) + sizeof(STaosRsp) + sizeof(SShowRspMsg) + sizeof(SCMSchema) * TSDB_MAX_COLUMNS +
|
||||||
// TSDB_EXTRA_PAYLOAD_SIZE;
|
// TSDB_EXTRA_PAYLOAD_SIZE;
|
||||||
// pStart = taosBuildRspMsgWithSize(pConn->thandle, TSDB_MSG_TYPE_SHOW_RSP, size);
|
// pStart = taosBuildRspMsgWithSize(pConn->thandle, TSDB_MSG_TYPE_SHOW_RSP, size);
|
||||||
// if (pStart == NULL) {
|
// if (pStart == NULL) {
|
||||||
|
@ -934,7 +953,7 @@ int32_t mgmtProcessShowMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
//
|
//
|
||||||
// code = (*mgmtGetMetaFp[(uint8_t)pShowMsg->type])(&pShowRsp->meterMeta, pShow, pConn);
|
// code = (*mgmtGetMetaFp[(uint8_t)pShowMsg->type])(&pShowRsp->meterMeta, pShow, pConn);
|
||||||
// if (code == 0) {
|
// if (code == 0) {
|
||||||
// pMsg += sizeof(SShowRspMsg) + sizeof(SSchema) * pShow->numOfColumns;
|
// pMsg += sizeof(SShowRspMsg) + sizeof(SCMSchema) * pShow->numOfColumns;
|
||||||
// } else {
|
// } else {
|
||||||
// mError("pShow:%p, type:%d %s, failed to get Meta, code:%d", pShow, pShowMsg->type, taosMsg[(uint8_t)pShowMsg->type], code);
|
// mError("pShow:%p, type:%d %s, failed to get Meta, code:%d", pShow, pShowMsg->type, taosMsg[(uint8_t)pShowMsg->type], code);
|
||||||
// free(pShow);
|
// free(pShow);
|
||||||
|
@ -1038,146 +1057,159 @@ int32_t mgmtProcessRetrieveMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessCreateTableMsg(void *pCont, int32_t contLen, void *ahandle) {
|
int32_t mgmtProcessCreateTableMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// SCreateTableMsg *pCreate = (SCreateTableMsg *)pMsg;
|
if (mgmtCheckRedirectMsg(ahandle) != 0) {
|
||||||
// int32_t code;
|
return TSDB_CODE_REDIRECT;
|
||||||
// SSchema * pSchema;
|
}
|
||||||
//
|
|
||||||
// if (mgmtCheckRedirectMsg(pConn, TSDB_MSG_TYPE_CREATE_TABLE_RSP) != 0) {
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (!pConn->writeAuth) {
|
|
||||||
// code = TSDB_CODE_NO_RIGHTS;
|
|
||||||
// } else {
|
|
||||||
// pCreate->numOfColumns = htons(pCreate->numOfColumns);
|
|
||||||
// pCreate->numOfTags = htons(pCreate->numOfTags);
|
|
||||||
//
|
|
||||||
// pCreate->sqlLen = htons(pCreate->sqlLen);
|
|
||||||
// pSchema = pCreate->schema;
|
|
||||||
// for (int32_t i = 0; i < pCreate->numOfColumns + pCreate->numOfTags; ++i) {
|
|
||||||
// pSchema->bytes = htons(pSchema->bytes);
|
|
||||||
// pSchema->colId = i;
|
|
||||||
// pSchema++;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// SDbObj *pDb = NULL;
|
|
||||||
// if (pConn->pDb != NULL) pDb = mgmtGetDb(pConn->pDb->name);
|
|
||||||
//
|
|
||||||
// if (pDb) {
|
|
||||||
// code = mgmtCreateTable(pDb, pCreate);
|
|
||||||
// } else {
|
|
||||||
// code = TSDB_CODE_DB_NOT_SELECTED;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (code == 1) {
|
|
||||||
// //mTrace("table:%s, wait vgroup create finish", pCreate->meterId, code);
|
|
||||||
// } else if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
// if (code == TSDB_CODE_TABLE_ALREADY_EXIST) { // table already created when the second attempt to create table
|
|
||||||
//
|
|
||||||
// STabObj* pTable = mgmtGetTable(pCreate->meterId);
|
|
||||||
// assert(pTable != NULL);
|
|
||||||
//
|
|
||||||
// mWarn("table:%s, table already created, failed to create table, ts:%" PRId64 ", code:%d", pCreate->meterId,
|
|
||||||
// pTable->createdTime, code);
|
|
||||||
// } else { // other errors
|
|
||||||
// mError("table:%s, failed to create table, code:%d", pCreate->meterId, code);
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// mTrace("table:%s, table is created by %s", pCreate->meterId, pConn->pUser->user);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_CREATE_TABLE_RSP, code);
|
|
||||||
|
|
||||||
return 0;
|
SUserObj *pUser = mgmtGetUserFromConn(ahandle);
|
||||||
|
if (pUser == NULL) {
|
||||||
|
rpcSendResponse(ahandle, TSDB_CODE_INVALID_USER, NULL, 0);
|
||||||
|
return TSDB_CODE_INVALID_USER;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCMCreateTableMsg *pCreate = (SCMCreateTableMsg *) pCont;
|
||||||
|
SCMSchema *pSchema;
|
||||||
|
int32_t code;
|
||||||
|
|
||||||
|
if (!pUser->writeAuth) {
|
||||||
|
code = TSDB_CODE_NO_RIGHTS;
|
||||||
|
} else {
|
||||||
|
pCreate->numOfColumns = htons(pCreate->numOfColumns);
|
||||||
|
pCreate->numOfTags = htons(pCreate->numOfTags);
|
||||||
|
pCreate->sqlLen = htons(pCreate->sqlLen);
|
||||||
|
pSchema = pCreate->schema;
|
||||||
|
for (int32_t i = 0; i < pCreate->numOfColumns + pCreate->numOfTags; ++i) {
|
||||||
|
pSchema->bytes = htons(pSchema->bytes);
|
||||||
|
pSchema->colId = i;
|
||||||
|
pSchema++;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDbObj *pDb = mgmtGetDb(pCreate->db);
|
||||||
|
if (pDb) {
|
||||||
|
code = mgmtCreateTable(pDb, pCreate);
|
||||||
|
if (code == TSDB_CODE_TABLE_ALREADY_EXIST) {
|
||||||
|
if (pCreate->igExists) {
|
||||||
|
code = TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
code = TSDB_CODE_DB_NOT_SELECTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
rpcSendResponse(ahandle, TSDB_CODE_SUCCESS, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessDropTableMsg(void *pCont, int32_t contLen, void *ahandle) {
|
int32_t mgmtProcessDropTableMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// SDropTableMsg *pDrop = (SDropTableMsg *)pMsg;
|
if (mgmtCheckRedirectMsg(ahandle) != 0) {
|
||||||
// int32_t code;
|
return TSDB_CODE_REDIRECT;
|
||||||
//
|
}
|
||||||
// if (mgmtCheckRedirectMsg(pConn, TSDB_MSG_TYPE_DROP_TABLE_RSP) != 0) {
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (!pConn->writeAuth) {
|
|
||||||
// code = TSDB_CODE_NO_RIGHTS;
|
|
||||||
// } else {
|
|
||||||
// SDbObj *pDb = NULL;
|
|
||||||
// if (pConn->pDb != NULL) pDb = mgmtGetDb(pConn->pDb->name);
|
|
||||||
//
|
|
||||||
// code = mgmtDropTable(pDb, pDrop->meterId, pDrop->igNotExists);
|
|
||||||
// if (code == 0) {
|
|
||||||
// mTrace("meter:%s is dropped by user:%s", pDrop->meterId, pConn->pUser->user);
|
|
||||||
// // mLPrint("meter:%s is dropped by user:%s", pDrop->meterId, pConn->pUser->user);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_DROP_TABLE_RSP, code);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return 0;
|
SUserObj *pUser = mgmtGetUserFromConn(ahandle);
|
||||||
|
if (pUser == NULL) {
|
||||||
|
rpcSendResponse(ahandle, TSDB_CODE_INVALID_USER, NULL, 0);
|
||||||
|
return TSDB_CODE_INVALID_USER;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDropTableMsg *pDrop = (SDropTableMsg *) pCont;
|
||||||
|
int32_t code;
|
||||||
|
|
||||||
|
if (!pUser->writeAuth) {
|
||||||
|
code = TSDB_CODE_NO_RIGHTS;
|
||||||
|
} else {
|
||||||
|
SDbObj *pDb = mgmtGetDb(pDrop->db);
|
||||||
|
if (pDb) {
|
||||||
|
code = mgmtDropTable(pDb, pDrop->meterId, pDrop->igNotExists);
|
||||||
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
mTrace("table:%s is dropped by user:%s", pDrop->meterId, pUser->user);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
code = TSDB_CODE_DB_NOT_SELECTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
rpcSendResponse(ahandle, code, NULL, 0);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessAlterTableMsg(void *pCont, int32_t contLen, void *ahandle) {
|
int32_t mgmtProcessAlterTableMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// SAlterTableMsg *pAlter = (SAlterTableMsg *)pMsg;
|
if (mgmtCheckRedirectMsg(ahandle) != 0) {
|
||||||
// int32_t code;
|
return TSDB_CODE_REDIRECT;
|
||||||
//
|
}
|
||||||
// if (mgmtCheckRedirectMsg(pConn, TSDB_MSG_TYPE_ALTER_TABLE_RSP) != 0) {
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (!pConn->writeAuth) {
|
|
||||||
// code = TSDB_CODE_NO_RIGHTS;
|
|
||||||
// } else {
|
|
||||||
// pAlter->type = htons(pAlter->type);
|
|
||||||
// pAlter->numOfCols = htons(pAlter->numOfCols);
|
|
||||||
//
|
|
||||||
// if (pAlter->numOfCols > 2) {
|
|
||||||
// mError("meter:%s error numOfCols:%d in alter table", pAlter->meterId, pAlter->numOfCols);
|
|
||||||
// code = TSDB_CODE_APP_ERROR;
|
|
||||||
// } else {
|
|
||||||
// SDbObj *pDb = NULL;
|
|
||||||
// if (pConn->pDb != NULL) pDb = mgmtGetDb(pConn->pDb->name);
|
|
||||||
//
|
|
||||||
// if (pDb) {
|
|
||||||
// for (int32_t i = 0; i < pAlter->numOfCols; ++i) {
|
|
||||||
// pAlter->schema[i].bytes = htons(pAlter->schema[i].bytes);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// code = mgmtAlterTable(pDb, pAlter);
|
|
||||||
// if (code == 0) {
|
|
||||||
// mLPrint("meter:%s is altered by %s", pAlter->meterId, pConn->pUser->user);
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// code = TSDB_CODE_DB_NOT_SELECTED;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_ALTER_TABLE_RSP, code);
|
|
||||||
|
|
||||||
return 0;
|
SUserObj *pUser = mgmtGetUserFromConn(ahandle);
|
||||||
|
if (pUser == NULL) {
|
||||||
|
rpcSendResponse(ahandle, TSDB_CODE_INVALID_USER, NULL, 0);
|
||||||
|
return TSDB_CODE_INVALID_USER;
|
||||||
|
}
|
||||||
|
|
||||||
|
SAlterTableMsg *pAlter = (SAlterTableMsg *) pCont;
|
||||||
|
int32_t code;
|
||||||
|
|
||||||
|
if (!pUser->writeAuth) {
|
||||||
|
code = TSDB_CODE_NO_RIGHTS;
|
||||||
|
} else {
|
||||||
|
pAlter->type = htons(pAlter->type);
|
||||||
|
pAlter->numOfCols = htons(pAlter->numOfCols);
|
||||||
|
|
||||||
|
if (pAlter->numOfCols > 2) {
|
||||||
|
mError("table:%s error numOfCols:%d in alter table", pAlter->tableId, pAlter->numOfCols);
|
||||||
|
code = TSDB_CODE_APP_ERROR;
|
||||||
|
} else {
|
||||||
|
SDbObj *pDb = mgmtGetDb(pAlter->db);
|
||||||
|
if (pDb) {
|
||||||
|
for (int32_t i = 0; i < pAlter->numOfCols; ++i) {
|
||||||
|
pAlter->schema[i].bytes = htons(pAlter->schema[i].bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
code = mgmtAlterTable(pDb, pAlter);
|
||||||
|
if (code == 0) {
|
||||||
|
mLPrint("table:%s is altered by %s", pAlter->tableId, pUser->user);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
code = TSDB_CODE_DB_NOT_SELECTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
rpcSendResponse(ahandle, code, NULL, 0);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessCfgDnodeMsg(void *pCont, int32_t contLen, void *ahandle) {
|
int32_t mgmtProcessCfgDnodeMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// int32_t code = 0;
|
if (mgmtCheckRedirectMsg(ahandle) != 0) {
|
||||||
// SCfgMsg *pCfg = (SCfgMsg *)pMsg;
|
return TSDB_CODE_REDIRECT;
|
||||||
//
|
}
|
||||||
// if (mgmtCheckRedirectMsg(pConn, TSDB_MSG_TYPE_CFG_MNODE_RSP) != 0) {
|
|
||||||
// return 0;
|
SUserObj *pUser = mgmtGetUserFromConn(ahandle);
|
||||||
// }
|
if (pUser == NULL) {
|
||||||
//
|
rpcSendResponse(ahandle, TSDB_CODE_INVALID_USER, NULL, 0);
|
||||||
// if (strcmp(pConn->pAcct->user, "root") != 0) {
|
return TSDB_CODE_INVALID_USER;
|
||||||
// code = TSDB_CODE_NO_RIGHTS;
|
}
|
||||||
// } else {
|
|
||||||
// code = mgmtSendCfgDnodeMsg(pMsg);
|
SCMCfgDnodeMsg *pCfg = (SCMCfgDnodeMsg *)pCont;
|
||||||
// }
|
int32_t code;
|
||||||
//
|
|
||||||
// taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_DNODE_CFG_RSP, code);
|
if (strcmp(pUser->pAcct->user, "root") != 0) {
|
||||||
//
|
code = TSDB_CODE_NO_RIGHTS;
|
||||||
// if (code == 0) mTrace("dnode:%s is configured by %s", pCfg->ip, pConn->pUser->user);
|
} else {
|
||||||
//
|
code = mgmtSendCfgDnodeMsg(pCont);
|
||||||
return 0;
|
}
|
||||||
|
|
||||||
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
mTrace("dnode:%s is configured by %s", pCfg->ip, pUser->user);
|
||||||
|
}
|
||||||
|
|
||||||
|
rpcSendResponse(ahandle, code, NULL, 0);
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtProcessHeartBeatMsg(void *pCont, int32_t contLen, void *ahandle) {
|
int32_t mgmtProcessHeartBeatMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
|
@ -1324,7 +1356,7 @@ static bool mgmtCheckMeterMetaMsgType(void *pMsg) {
|
||||||
// If table does not exists and autoCreate flag is set, we add the handler into task queue
|
// If table does not exists and autoCreate flag is set, we add the handler into task queue
|
||||||
bool addIntoTranQueue = (pTable == NULL && autoCreate == 1);
|
bool addIntoTranQueue = (pTable == NULL && autoCreate == 1);
|
||||||
if (addIntoTranQueue) {
|
if (addIntoTranQueue) {
|
||||||
mTrace("meter:%s auto created task added", pInfo->meterId);
|
mTrace("table:%s auto created task added", pInfo->meterId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return addIntoTranQueue;
|
return addIntoTranQueue;
|
||||||
|
@ -1362,53 +1394,52 @@ static void mgmtProcessMsgFromShell(char type, void *pCont, int contLen, void *a
|
||||||
}
|
}
|
||||||
|
|
||||||
void mgmtInitProcessShellMsg() {
|
void mgmtInitProcessShellMsg() {
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_TABLE_META] = mgmtProcessMeterMetaMsg;
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_CONNECT] = mgmtProcessConnectMsg;
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_STABLE_META] = mgmtProcessMetricMetaMsg;
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_HEARTBEAT] = mgmtProcessHeartBeatMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_CREATE_DB] = mgmtProcessCreateDbMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_ALTER_DB] = mgmtProcessAlterDbMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_DROP_DB] = mgmtProcessDropDbMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_USE_DB] = mgmtProcessUnSupportMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_CREATE_USER] = mgmtProcessCreateUserMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_ALTER_USER] = mgmtProcessAlterUserMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_DROP_USER] = mgmtProcessDropUserMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_CREATE_ACCT] = mgmtProcessCreateAcctMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_DROP_ACCT] = mgmtProcessDropAcctMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_ALTER_ACCT] = mgmtProcessAlterAcctMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_CREATE_TABLE] = mgmtProcessCreateTableMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_DROP_TABLE] = mgmtProcessDropTableMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_ALTER_TABLE] = mgmtProcessAlterTableMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_CREATE_DNODE] = mgmtProcessCreateDnodeMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_DROP_DNODE] = mgmtProcessDropDnodeMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_DNODE_CFG] = mgmtProcessCfgDnodeMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_CREATE_MNODE] = mgmtProcessUnSupportMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_DROP_MNODE] = mgmtProcessDropMnodeMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_CFG_MNODE] = mgmtProcessCfgMnodeMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_KILL_QUERY] = mgmtProcessKillQueryMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_KILL_STREAM] = mgmtProcessKillStreamMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_KILL_CONNECTION] = mgmtProcessKillConnectionMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_SHOW] = mgmtProcessShowMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_DNODE_RETRIEVE] = mgmtProcessRetrieveMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_TABLE_META] = mgmtProcessMeterMetaMsg;
|
||||||
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_STABLE_META] = mgmtProcessMetricMetaMsg;
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_MULTI_TABLE_META] = mgmtProcessMultiMeterMetaMsg;
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_MULTI_TABLE_META] = mgmtProcessMultiMeterMetaMsg;
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_CREATE_DB] = mgmtProcessCreateDbMsg;
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_ALTER_DB] = mgmtProcessAlterDbMsg;
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_CREATE_USER] = mgmtProcessCreateUserMsg;
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_ALTER_USER] = mgmtProcessAlterUserMsg;
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_CREATE_ACCT] = mgmtProcessCreateAcctMsg;
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_DROP_DB] = mgmtProcessDropDbMsg;
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_DROP_USER] = mgmtProcessDropUserMsg;
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_DROP_ACCT] = mgmtProcessDropAcctMsg;
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_ALTER_ACCT] = mgmtProcessAlterAcctMsg;
|
|
||||||
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_CREATE_TABLE] = mgmtProcessCreateTableMsg;
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_DROP_TABLE] = mgmtProcessDropTableMsg;
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_ALTER_TABLE] = mgmtProcessAlterTableMsg;
|
|
||||||
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_USE_DB] = mgmtProcessUseDbMsg;
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_DNODE_RETRIEVE] = mgmtProcessRetrieveMsg;
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_SHOW] = mgmtProcessShowMsg;
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_CONNECT] = mgmtProcessConnectMsg;
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_HEARTBEAT] = mgmtProcessHeartBeatMsg;
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_CREATE_DNODE] = mgmtProcessCreateDnodeMsg;
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_DROP_DNODE] = mgmtProcessDropDnodeMsg;
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_CREATE_MNODE] = mgmtProcessCreateMnodeMsg;
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_DROP_MNODE] = mgmtProcessDropMnodeMsg;
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_CFG_MNODE] = mgmtProcessCfgMnodeMsg;
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_DNODE_CFG] = mgmtProcessCfgDnodeMsg;
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_KILL_QUERY] = mgmtProcessKillQueryMsg;
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_KILL_STREAM] = mgmtProcessKillStreamMsg;
|
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_KILL_CONNECTION] = mgmtProcessKillConnectionMsg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtCheckRedirectMsgImp(void *pConn) {
|
static int32_t mgmtCheckRedirectMsgImp(void *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t (*mgmtCheckRedirectMsg)(void *pConn) = mgmtCheckRedirectMsgImp;
|
int32_t (*mgmtCheckRedirectMsg)(void *pConn) = mgmtCheckRedirectMsgImp;
|
||||||
|
|
||||||
static int32_t mgmtProcessUnSupportMsg(void *pCont, int32_t contLen, void *ahandle) {
|
static int32_t mgmtProcessUnSupportMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
rpcSendResponse(ahandle, TSDB_CODE_OPS_NOT_SUPPORT, NULL, 0);
|
rpcSendResponse(ahandle, TSDB_CODE_OPS_NOT_SUPPORT, NULL, 0);
|
||||||
return 0;
|
return TSDB_CODE_OPS_NOT_SUPPORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t (*mgmtProcessAlterAcctMsg)(void *pCont, int32_t contLen, void *ahandle) = mgmtProcessUnSupportMsg;
|
int32_t (*mgmtProcessAlterAcctMsg)(void *pCont, int32_t contLen, void *ahandle) = mgmtProcessUnSupportMsg;
|
||||||
int32_t (*mgmtProcessCreateDnodeMsg)(void *pCont, int32_t contLen, void *ahandle) = mgmtProcessUnSupportMsg;
|
int32_t (*mgmtProcessCreateDnodeMsg)(void *pCont, int32_t contLen, void *ahandle) = mgmtProcessUnSupportMsg;
|
||||||
int32_t (*mgmtProcessCfgMnodeMsg)(void *pCont, int32_t contLen, void *ahandle) = mgmtProcessUnSupportMsg;
|
int32_t (*mgmtProcessCfgMnodeMsg)(void *pCont, int32_t contLen, void *ahandle) = mgmtProcessUnSupportMsg;
|
||||||
int32_t (*mgmtProcessDropMnodeMsg)(void *pCont, int32_t contLen, void *ahandle) = mgmtProcessUnSupportMsg;
|
int32_t (*mgmtProcessDropMnodeMsg)(void *pCont, int32_t contLen, void *ahandle) = mgmtProcessUnSupportMsg;
|
||||||
int32_t (*mgmtProcessDropDnodeMsg)(void *pCont, int32_t contLen, void *ahandle) = mgmtProcessUnSupportMsg;
|
int32_t (*mgmtProcessDropDnodeMsg)(void *pCont, int32_t contLen, void *ahandle) = mgmtProcessUnSupportMsg;
|
||||||
int32_t (*mgmtProcessDropAcctMsg)(void *pCont, int32_t contLen, void *ahandle) = mgmtProcessUnSupportMsg;
|
int32_t (*mgmtProcessDropAcctMsg)(void *pCont, int32_t contLen, void *ahandle) = mgmtProcessUnSupportMsg;
|
||||||
int32_t (*mgmtProcessCreateAcctMsg)(void *pCont, int32_t contLen, void *ahandle) = mgmtProcessUnSupportMsg;
|
int32_t (*mgmtProcessCreateAcctMsg)(void *pCont, int32_t contLen, void *ahandle) = mgmtProcessUnSupportMsg;
|
|
@ -67,8 +67,8 @@ void *mgmtStreamTableActionReset(void *row, char *str, int32_t size, int32_t *ss
|
||||||
int32_t tsize = pTable->updateEnd - (int8_t *) pTable;
|
int32_t tsize = pTable->updateEnd - (int8_t *) pTable;
|
||||||
memcpy(pTable, str, tsize);
|
memcpy(pTable, str, tsize);
|
||||||
|
|
||||||
int32_t schemaSize = pTable->numOfColumns * sizeof(SSchema);
|
int32_t schemaSize = pTable->numOfColumns * sizeof(SCMSchema);
|
||||||
pTable->schema = (SSchema *) realloc(pTable->schema, schemaSize);
|
pTable->schema = (SCMSchema *) realloc(pTable->schema, schemaSize);
|
||||||
memcpy(pTable->schema, str + tsize, schemaSize);
|
memcpy(pTable->schema, str + tsize, schemaSize);
|
||||||
|
|
||||||
pTable->sql = (char *) realloc(pTable->sql, pTable->sqlLen);
|
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);
|
assert(row != NULL && str != NULL);
|
||||||
|
|
||||||
int32_t tsize = pTable->updateEnd - (int8_t *) pTable;
|
int32_t tsize = pTable->updateEnd - (int8_t *) pTable;
|
||||||
int32_t schemaSize = pTable->numOfColumns * sizeof(SSchema);
|
int32_t schemaSize = pTable->numOfColumns * sizeof(SCMSchema);
|
||||||
if (size < tsize + schemaSize + pTable->sqlLen + 1) {
|
if (size < tsize + schemaSize + pTable->sqlLen + 1) {
|
||||||
*ssize = -1;
|
*ssize = -1;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -199,8 +199,8 @@ void *mgmtStreamTableActionDecode(void *row, char *str, int32_t size, int32_t *s
|
||||||
}
|
}
|
||||||
memcpy(pTable, str, tsize);
|
memcpy(pTable, str, tsize);
|
||||||
|
|
||||||
int32_t schemaSize = pTable->numOfColumns * sizeof(SSchema);
|
int32_t schemaSize = pTable->numOfColumns * sizeof(SCMSchema);
|
||||||
pTable->schema = (SSchema *)malloc(schemaSize);
|
pTable->schema = (SCMSchema *)malloc(schemaSize);
|
||||||
if (pTable->schema == NULL) {
|
if (pTable->schema == NULL) {
|
||||||
mgmtDestroyStreamTable(pTable);
|
mgmtDestroyStreamTable(pTable);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -230,7 +230,7 @@ int32_t mgmtInitStreamTables() {
|
||||||
|
|
||||||
mgmtStreamTableActionInit();
|
mgmtStreamTableActionInit();
|
||||||
|
|
||||||
tsStreamTableSdb = sdbOpenTable(tsMaxTables, sizeof(SStreamTableObj) + sizeof(SSchema) * TSDB_MAX_COLUMNS + TSDB_MAX_SQL_LEN,
|
tsStreamTableSdb = sdbOpenTable(tsMaxTables, sizeof(SStreamTableObj) + sizeof(SCMSchema) * TSDB_MAX_COLUMNS + TSDB_MAX_SQL_LEN,
|
||||||
"streams", SDB_KEYTYPE_STRING, tsMgmtDirectory, mgmtStreamTableAction);
|
"streams", SDB_KEYTYPE_STRING, tsMgmtDirectory, mgmtStreamTableAction);
|
||||||
if (tsStreamTableSdb == NULL) {
|
if (tsStreamTableSdb == NULL) {
|
||||||
mError("failed to init stream table data");
|
mError("failed to init stream table data");
|
||||||
|
@ -273,7 +273,7 @@ int8_t *mgmtBuildCreateStreamTableMsg(SStreamTableObj *pTable, SVgObj *pVgroup)
|
||||||
// pCreateTable->numOfColumns = htons(pTable->numOfColumns);
|
// pCreateTable->numOfColumns = htons(pTable->numOfColumns);
|
||||||
// //pCreateTable->sqlLen = htons(pTable->sqlLen);
|
// //pCreateTable->sqlLen = htons(pTable->sqlLen);
|
||||||
//
|
//
|
||||||
// SSchema *pSchema = pTable->schema;
|
// SCMSchema *pSchema = pTable->schema;
|
||||||
// int32_t totalCols = pCreateTable->numOfColumns;
|
// int32_t totalCols = pCreateTable->numOfColumns;
|
||||||
|
|
||||||
// for (int32_t col = 0; col < totalCols; ++col) {
|
// for (int32_t col = 0; col < totalCols; ++col) {
|
||||||
|
@ -293,10 +293,10 @@ int8_t *mgmtBuildCreateStreamTableMsg(SStreamTableObj *pTable, SVgObj *pVgroup)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtCreateStreamTable(SDbObj *pDb, SCreateTableMsg *pCreate, SVgObj *pVgroup, int32_t sid) {
|
int32_t mgmtCreateStreamTable(SDbObj *pDb, SCMCreateTableMsg *pCreate, SVgObj *pVgroup, int32_t sid) {
|
||||||
int32_t numOfTables = sdbGetNumOfRows(tsStreamTableSdb);
|
int32_t numOfTables = sdbGetNumOfRows(tsStreamTableSdb);
|
||||||
if (numOfTables >= TSDB_MAX_TABLES) {
|
if (numOfTables >= TSDB_MAX_TABLES) {
|
||||||
mError("stream table:%s, numOfTables:%d exceed maxTables:%d", pCreate->meterId, numOfTables, TSDB_MAX_TABLES);
|
mError("stream table:%s, numOfTables:%d exceed maxTables:%d", pCreate->tableId, numOfTables, TSDB_MAX_TABLES);
|
||||||
return TSDB_CODE_TOO_MANY_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;
|
return TSDB_CODE_SERV_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(pTable->tableId, pCreate->meterId);
|
strcpy(pTable->tableId, pCreate->tableId);
|
||||||
pTable->createdTime = taosGetTimestampMs();
|
pTable->createdTime = taosGetTimestampMs();
|
||||||
pTable->vgId = pVgroup->vgId;
|
pTable->vgId = pVgroup->vgId;
|
||||||
pTable->sid = sid;
|
pTable->sid = sid;
|
||||||
|
@ -314,28 +314,28 @@ int32_t mgmtCreateStreamTable(SDbObj *pDb, SCreateTableMsg *pCreate, SVgObj *pVg
|
||||||
pTable->numOfColumns = pCreate->numOfColumns;
|
pTable->numOfColumns = pCreate->numOfColumns;
|
||||||
|
|
||||||
int32_t numOfCols = pCreate->numOfColumns + pCreate->numOfTags;
|
int32_t numOfCols = pCreate->numOfColumns + pCreate->numOfTags;
|
||||||
int32_t schemaSize = pTable->numOfColumns * sizeof(SSchema);
|
int32_t schemaSize = pTable->numOfColumns * sizeof(SCMSchema);
|
||||||
pTable->schema = (SSchema *) calloc(1, schemaSize);
|
pTable->schema = (SCMSchema *) calloc(1, schemaSize);
|
||||||
if (pTable->schema == NULL) {
|
if (pTable->schema == NULL) {
|
||||||
free(pTable);
|
free(pTable);
|
||||||
mError("table:%s, no schema input", pCreate->meterId);
|
mError("table:%s, no schema input", pCreate->tableId);
|
||||||
return TSDB_CODE_INVALID_TABLE;
|
return TSDB_CODE_INVALID_TABLE;
|
||||||
}
|
}
|
||||||
memcpy(pTable->schema, pCreate->schema, numOfCols * sizeof(SSchema));
|
memcpy(pTable->schema, pCreate->schema, numOfCols * sizeof(SCMSchema));
|
||||||
|
|
||||||
pTable->nextColId = 0;
|
pTable->nextColId = 0;
|
||||||
for (int32_t col = 0; col < pCreate->numOfColumns; col++) {
|
for (int32_t col = 0; col < pCreate->numOfColumns; col++) {
|
||||||
SSchema *tschema = (SSchema *) pTable->schema;
|
SCMSchema *tschema = (SCMSchema *) pTable->schema;
|
||||||
tschema[col].colId = pTable->nextColId++;
|
tschema[col].colId = pTable->nextColId++;
|
||||||
}
|
}
|
||||||
|
|
||||||
pTable->sql = (char*)(pTable->schema + numOfCols * sizeof(SSchema));
|
pTable->sql = (char*)(pTable->schema + numOfCols * sizeof(SCMSchema));
|
||||||
memcpy(pTable->sql, (char *) (pCreate->schema) + numOfCols * sizeof(SSchema), pCreate->sqlLen);
|
memcpy(pTable->sql, (char *) (pCreate->schema) + numOfCols * sizeof(SCMSchema), pCreate->sqlLen);
|
||||||
pTable->sql[pCreate->sqlLen - 1] = 0;
|
pTable->sql[pCreate->sqlLen - 1] = 0;
|
||||||
mTrace("table:%s, stream sql len:%d sql:%s", pCreate->meterId, pCreate->sqlLen, pTable->sql);
|
mTrace("table:%s, stream sql len:%d sql:%s", pCreate->tableId, pCreate->sqlLen, pTable->sql);
|
||||||
|
|
||||||
if (sdbInsertRow(tsStreamTableSdb, pTable, 0) < 0) {
|
if (sdbInsertRow(tsStreamTableSdb, pTable, 0) < 0) {
|
||||||
mError("table:%s, update sdb error", pCreate->meterId);
|
mError("table:%s, update sdb error", pCreate->tableId);
|
||||||
return TSDB_CODE_SDB_ERROR;
|
return TSDB_CODE_SDB_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ void *mgmtSuperTableActionReset(void *row, char *str, int32_t size, int32_t *ssi
|
||||||
int32_t tsize = pTable->updateEnd - (int8_t *) pTable;
|
int32_t tsize = pTable->updateEnd - (int8_t *) pTable;
|
||||||
memcpy(pTable, str, tsize);
|
memcpy(pTable, str, tsize);
|
||||||
|
|
||||||
int32_t schemaSize = sizeof(SSchema) * (pTable->numOfColumns + pTable->numOfTags);
|
int32_t schemaSize = sizeof(SCMSchema) * (pTable->numOfColumns + pTable->numOfTags);
|
||||||
pTable->schema = realloc(pTable->schema, schemaSize);
|
pTable->schema = realloc(pTable->schema, schemaSize);
|
||||||
memcpy(pTable->schema, str + tsize, 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);
|
assert(row != NULL && str != NULL);
|
||||||
|
|
||||||
int32_t tsize = pTable->updateEnd - (int8_t *) pTable;
|
int32_t tsize = pTable->updateEnd - (int8_t *) pTable;
|
||||||
int32_t schemaSize = sizeof(SSchema) * (pTable->numOfColumns + pTable->numOfTags);
|
int32_t schemaSize = sizeof(SCMSchema) * (pTable->numOfColumns + pTable->numOfTags);
|
||||||
|
|
||||||
if (size < tsize + schemaSize + 1) {
|
if (size < tsize + schemaSize + 1) {
|
||||||
*ssize = -1;
|
*ssize = -1;
|
||||||
|
@ -126,7 +126,7 @@ void *mgmtSuperTableActionDecode(void *row, char *str, int32_t size, int32_t *ss
|
||||||
}
|
}
|
||||||
memcpy(pTable, str, tsize);
|
memcpy(pTable, str, tsize);
|
||||||
|
|
||||||
int32_t schemaSize = sizeof(SSchema) * (pTable->numOfColumns + pTable->numOfTags);
|
int32_t schemaSize = sizeof(SCMSchema) * (pTable->numOfColumns + pTable->numOfTags);
|
||||||
pTable->schema = malloc(schemaSize);
|
pTable->schema = malloc(schemaSize);
|
||||||
if (pTable->schema == NULL) {
|
if (pTable->schema == NULL) {
|
||||||
mgmtDestroySuperTable(pTable);
|
mgmtDestroySuperTable(pTable);
|
||||||
|
@ -151,7 +151,7 @@ int32_t mgmtInitSuperTables() {
|
||||||
|
|
||||||
mgmtSuperTableActionInit();
|
mgmtSuperTableActionInit();
|
||||||
|
|
||||||
tsSuperTableSdb = sdbOpenTable(tsMaxTables, sizeof(STabObj) + sizeof(SSchema) * TSDB_MAX_COLUMNS,
|
tsSuperTableSdb = sdbOpenTable(tsMaxTables, sizeof(STabObj) + sizeof(SCMSchema) * TSDB_MAX_COLUMNS,
|
||||||
"stables", SDB_KEYTYPE_STRING, tsMgmtDirectory, mgmtSuperTableAction);
|
"stables", SDB_KEYTYPE_STRING, tsMgmtDirectory, mgmtSuperTableAction);
|
||||||
if (tsSuperTableSdb == NULL) {
|
if (tsSuperTableSdb == NULL) {
|
||||||
mError("failed to init super table data");
|
mError("failed to init super table data");
|
||||||
|
@ -184,10 +184,10 @@ int32_t mgmtInitSuperTables() {
|
||||||
void mgmtCleanUpSuperTables() {
|
void mgmtCleanUpSuperTables() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtCreateSuperTable(SDbObj *pDb, SCreateTableMsg *pCreate) {
|
int32_t mgmtCreateSuperTable(SDbObj *pDb, SCMCreateTableMsg *pCreate) {
|
||||||
int32_t numOfTables = sdbGetNumOfRows(tsSuperTableSdb);
|
int32_t numOfTables = sdbGetNumOfRows(tsSuperTableSdb);
|
||||||
if (numOfTables >= TSDB_MAX_TABLES) {
|
if (numOfTables >= TSDB_MAX_TABLES) {
|
||||||
mError("super table:%s, numOfTables:%d exceed maxTables:%d", pCreate->meterId, numOfTables, TSDB_MAX_TABLES);
|
mError("super table:%s, numOfTables:%d exceed maxTables:%d", pCreate->tableId, numOfTables, TSDB_MAX_TABLES);
|
||||||
return TSDB_CODE_TOO_MANY_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;
|
return TSDB_CODE_SERV_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(pStable->tableId, pCreate->meterId);
|
strcpy(pStable->tableId, pCreate->tableId);
|
||||||
pStable->createdTime = taosGetTimestampMs();
|
pStable->createdTime = taosGetTimestampMs();
|
||||||
pStable->vgId = 0;
|
pStable->vgId = 0;
|
||||||
pStable->sid = 0;
|
pStable->sid = 0;
|
||||||
|
@ -207,23 +207,23 @@ int32_t mgmtCreateSuperTable(SDbObj *pDb, SCreateTableMsg *pCreate) {
|
||||||
pStable->numOfTables = 0;
|
pStable->numOfTables = 0;
|
||||||
|
|
||||||
int32_t numOfCols = pCreate->numOfColumns + pCreate->numOfTags;
|
int32_t numOfCols = pCreate->numOfColumns + pCreate->numOfTags;
|
||||||
int32_t schemaSize = numOfCols * sizeof(SSchema);
|
int32_t schemaSize = numOfCols * sizeof(SCMSchema);
|
||||||
pStable->schema = (SSchema *)calloc(1, schemaSize);
|
pStable->schema = (SCMSchema *)calloc(1, schemaSize);
|
||||||
if (pStable->schema == NULL) {
|
if (pStable->schema == NULL) {
|
||||||
free(pStable);
|
free(pStable);
|
||||||
mError("table:%s, no schema input", pCreate->meterId);
|
mError("table:%s, no schema input", pCreate->tableId);
|
||||||
return TSDB_CODE_INVALID_TABLE;
|
return TSDB_CODE_INVALID_TABLE;
|
||||||
}
|
}
|
||||||
memcpy(pStable->schema, pCreate->schema, numOfCols * sizeof(SSchema));
|
memcpy(pStable->schema, pCreate->schema, numOfCols * sizeof(SCMSchema));
|
||||||
|
|
||||||
pStable->nextColId = 0;
|
pStable->nextColId = 0;
|
||||||
for (int32_t col = 0; col < pCreate->numOfColumns; col++) {
|
for (int32_t col = 0; col < pCreate->numOfColumns; col++) {
|
||||||
SSchema *tschema = (SSchema *)pStable->schema;
|
SCMSchema *tschema = (SCMSchema *)pStable->schema;
|
||||||
tschema[col].colId = pStable->nextColId++;
|
tschema[col].colId = pStable->nextColId++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sdbInsertRow(tsSuperTableSdb, pStable, 0) < 0) {
|
if (sdbInsertRow(tsSuperTableSdb, pStable, 0) < 0) {
|
||||||
mError("table:%s, update sdb error", pCreate->meterId);
|
mError("table:%s, update sdb error", pCreate->tableId);
|
||||||
return TSDB_CODE_SDB_ERROR;
|
return TSDB_CODE_SDB_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ SSuperTableObj* mgmtGetSuperTable(char *tableId) {
|
||||||
|
|
||||||
int32_t mgmtFindSuperTableTagIndex(SSuperTableObj *pStable, const char *tagName) {
|
int32_t mgmtFindSuperTableTagIndex(SSuperTableObj *pStable, const char *tagName) {
|
||||||
for (int32_t i = 0; i < pStable->numOfTags; i++) {
|
for (int32_t i = 0; i < pStable->numOfTags; i++) {
|
||||||
SSchema *schema = (SSchema *)(pStable->schema + (pStable->numOfColumns + i) * sizeof(SSchema));
|
SCMSchema *schema = (SCMSchema *)(pStable->schema + (pStable->numOfColumns + i) * sizeof(SCMSchema));
|
||||||
if (strcasecmp(tagName, schema->name) == 0) {
|
if (strcasecmp(tagName, schema->name) == 0) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -250,7 +250,7 @@ int32_t mgmtFindSuperTableTagIndex(SSuperTableObj *pStable, const char *tagName)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtAddSuperTableTag(SSuperTableObj *pStable, SSchema schema[], int32_t ntags) {
|
int32_t mgmtAddSuperTableTag(SSuperTableObj *pStable, SCMSchema schema[], int32_t ntags) {
|
||||||
if (pStable->numOfTags + ntags > TSDB_MAX_TAGS) {
|
if (pStable->numOfTags + ntags > TSDB_MAX_TAGS) {
|
||||||
return TSDB_CODE_APP_ERROR;
|
return TSDB_CODE_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -276,14 +276,14 @@ int32_t mgmtAddSuperTableTag(SSuperTableObj *pStable, SSchema schema[], int32_t
|
||||||
return TSDB_CODE_APP_ERROR;
|
return TSDB_CODE_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schemaSize = sizeof(SSchema) * (pStable->numOfTags + pStable->numOfColumns);
|
int32_t schemaSize = sizeof(SCMSchema) * (pStable->numOfTags + pStable->numOfColumns);
|
||||||
pStable->schema = realloc(pStable->schema, schemaSize + sizeof(SSchema) * ntags);
|
pStable->schema = realloc(pStable->schema, schemaSize + sizeof(SCMSchema) * ntags);
|
||||||
|
|
||||||
memmove(pStable->schema + sizeof(SSchema) * (pStable->numOfColumns + ntags),
|
memmove(pStable->schema + sizeof(SCMSchema) * (pStable->numOfColumns + ntags),
|
||||||
pStable->schema + sizeof(SSchema) * pStable->numOfColumns, sizeof(SSchema) * pStable->numOfTags);
|
pStable->schema + sizeof(SCMSchema) * pStable->numOfColumns, sizeof(SCMSchema) * pStable->numOfTags);
|
||||||
memcpy(pStable->schema + sizeof(SSchema) * pStable->numOfColumns, schema, sizeof(SSchema) * ntags);
|
memcpy(pStable->schema + sizeof(SCMSchema) * pStable->numOfColumns, schema, sizeof(SCMSchema) * ntags);
|
||||||
|
|
||||||
SSchema *tschema = (SSchema *) (pStable->schema + sizeof(SSchema) * pStable->numOfColumns);
|
SCMSchema *tschema = (SCMSchema *) (pStable->schema + sizeof(SCMSchema) * pStable->numOfColumns);
|
||||||
for (int32_t i = 0; i < ntags; i++) {
|
for (int32_t i = 0; i < ntags; i++) {
|
||||||
tschema[i].colId = pStable->nextColId++;
|
tschema[i].colId = pStable->nextColId++;
|
||||||
}
|
}
|
||||||
|
@ -316,13 +316,13 @@ int32_t mgmtDropSuperTableTag(SSuperTableObj *pStable, char *tagName) {
|
||||||
return TSDB_CODE_APP_ERROR;
|
return TSDB_CODE_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
memmove(pStable->schema + sizeof(SSchema) * col, pStable->schema + sizeof(SSchema) * (col + 1),
|
memmove(pStable->schema + sizeof(SCMSchema) * col, pStable->schema + sizeof(SCMSchema) * (col + 1),
|
||||||
sizeof(SSchema) * (pStable->numOfColumns + pStable->numOfTags - col - 1));
|
sizeof(SCMSchema) * (pStable->numOfColumns + pStable->numOfTags - col - 1));
|
||||||
|
|
||||||
pStable->numOfTags--;
|
pStable->numOfTags--;
|
||||||
pStable->sversion++;
|
pStable->sversion++;
|
||||||
|
|
||||||
int32_t schemaSize = sizeof(SSchema) * (pStable->numOfTags + pStable->numOfColumns);
|
int32_t schemaSize = sizeof(SCMSchema) * (pStable->numOfTags + pStable->numOfColumns);
|
||||||
pStable->schema = realloc(pStable->schema, schemaSize);
|
pStable->schema = realloc(pStable->schema, schemaSize);
|
||||||
|
|
||||||
sdbUpdateRow(tsSuperTableSdb, pStable, 0, 1);
|
sdbUpdateRow(tsSuperTableSdb, pStable, 0, 1);
|
||||||
|
@ -346,7 +346,7 @@ int32_t mgmtModifySuperTableTagNameByName(SSuperTableObj *pStable, char *oldTagN
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
SSchema *schema = (SSchema *) (pStable->schema + (pStable->numOfColumns + col) * sizeof(SSchema));
|
SCMSchema *schema = (SCMSchema *) (pStable->schema + (pStable->numOfColumns + col) * sizeof(SCMSchema));
|
||||||
strncpy(schema->name, newTagName, TSDB_COL_NAME_LEN);
|
strncpy(schema->name, newTagName, TSDB_COL_NAME_LEN);
|
||||||
|
|
||||||
// Encode string
|
// Encode string
|
||||||
|
@ -370,7 +370,7 @@ int32_t mgmtModifySuperTableTagNameByName(SSuperTableObj *pStable, char *oldTagN
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mgmtFindSuperTableColumnIndex(SSuperTableObj *pStable, char *colName) {
|
static int32_t mgmtFindSuperTableColumnIndex(SSuperTableObj *pStable, char *colName) {
|
||||||
SSchema *schema = (SSchema *) pStable->schema;
|
SCMSchema *schema = (SCMSchema *) pStable->schema;
|
||||||
for (int32_t i = 0; i < pStable->numOfColumns; i++) {
|
for (int32_t i = 0; i < pStable->numOfColumns; i++) {
|
||||||
if (strcasecmp(schema[i].name, colName) == 0) {
|
if (strcasecmp(schema[i].name, colName) == 0) {
|
||||||
return i;
|
return i;
|
||||||
|
@ -380,7 +380,7 @@ static int32_t mgmtFindSuperTableColumnIndex(SSuperTableObj *pStable, char *colN
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtAddSuperTableColumn(SSuperTableObj *pStable, SSchema schema[], int32_t ncols) {
|
int32_t mgmtAddSuperTableColumn(SSuperTableObj *pStable, SCMSchema schema[], int32_t ncols) {
|
||||||
if (ncols <= 0) {
|
if (ncols <= 0) {
|
||||||
return TSDB_CODE_APP_ERROR;
|
return TSDB_CODE_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -403,14 +403,14 @@ int32_t mgmtAddSuperTableColumn(SSuperTableObj *pStable, SSchema schema[], int32
|
||||||
return TSDB_CODE_APP_ERROR;
|
return TSDB_CODE_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schemaSize = sizeof(SSchema) * (pStable->numOfTags + pStable->numOfColumns);
|
int32_t schemaSize = sizeof(SCMSchema) * (pStable->numOfTags + pStable->numOfColumns);
|
||||||
pStable->schema = realloc(pStable->schema, schemaSize + sizeof(SSchema) * ncols);
|
pStable->schema = realloc(pStable->schema, schemaSize + sizeof(SCMSchema) * ncols);
|
||||||
|
|
||||||
memmove(pStable->schema + sizeof(SSchema) * (pStable->numOfColumns + ncols),
|
memmove(pStable->schema + sizeof(SCMSchema) * (pStable->numOfColumns + ncols),
|
||||||
pStable->schema + sizeof(SSchema) * pStable->numOfColumns, sizeof(SSchema) * pStable->numOfTags);
|
pStable->schema + sizeof(SCMSchema) * pStable->numOfColumns, sizeof(SCMSchema) * pStable->numOfTags);
|
||||||
memcpy(pStable->schema + sizeof(SSchema) * pStable->numOfColumns, schema, sizeof(SSchema) * ncols);
|
memcpy(pStable->schema + sizeof(SCMSchema) * pStable->numOfColumns, schema, sizeof(SCMSchema) * ncols);
|
||||||
|
|
||||||
SSchema *tschema = (SSchema *) (pStable->schema + sizeof(SSchema) * pStable->numOfColumns);
|
SCMSchema *tschema = (SCMSchema *) (pStable->schema + sizeof(SCMSchema) * pStable->numOfColumns);
|
||||||
for (int32_t i = 0; i < ncols; i++) {
|
for (int32_t i = 0; i < ncols; i++) {
|
||||||
tschema[i].colId = pStable->nextColId++;
|
tschema[i].colId = pStable->nextColId++;
|
||||||
}
|
}
|
||||||
|
@ -442,13 +442,13 @@ int32_t mgmtDropSuperTableColumnByName(SSuperTableObj *pStable, char *colName) {
|
||||||
return TSDB_CODE_APP_ERROR;
|
return TSDB_CODE_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
memmove(pStable->schema + sizeof(SSchema) * col, pStable->schema + sizeof(SSchema) * (col + 1),
|
memmove(pStable->schema + sizeof(SCMSchema) * col, pStable->schema + sizeof(SCMSchema) * (col + 1),
|
||||||
sizeof(SSchema) * (pStable->numOfColumns + pStable->numOfTags - col - 1));
|
sizeof(SCMSchema) * (pStable->numOfColumns + pStable->numOfTags - col - 1));
|
||||||
|
|
||||||
pStable->numOfColumns--;
|
pStable->numOfColumns--;
|
||||||
pStable->sversion++;
|
pStable->sversion++;
|
||||||
|
|
||||||
int32_t schemaSize = sizeof(SSchema) * (pStable->numOfTags + pStable->numOfColumns);
|
int32_t schemaSize = sizeof(SCMSchema) * (pStable->numOfTags + pStable->numOfColumns);
|
||||||
pStable->schema = realloc(pStable->schema, schemaSize);
|
pStable->schema = realloc(pStable->schema, schemaSize);
|
||||||
|
|
||||||
pAcct->acctInfo.numOfTimeSeries -= (pStable->numOfTables);
|
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;
|
// if (pDb == NULL) return TSDB_CODE_DB_NOT_SELECTED;
|
||||||
//
|
//
|
||||||
// SSchema *pSchema = tsGetSchema(pMeta);
|
// SCMSchema *pSchema = tsGetSchema(pMeta);
|
||||||
//
|
//
|
||||||
// pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
// pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
||||||
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
// 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;
|
int32_t tagColumnIndexOffset = pSuperTable->numOfColumns;
|
||||||
|
|
||||||
for (int32_t i = 0; i < pSuperTable->numOfTags && i < col; ++i) {
|
for (int32_t i = 0; i < pSuperTable->numOfTags && i < col; ++i) {
|
||||||
len += ((SSchema*)pSuperTable->schema)[tagColumnIndexOffset + i].bytes;
|
len += ((SCMSchema*)pSuperTable->schema)[tagColumnIndexOffset + i].bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
|
|
|
@ -99,8 +99,8 @@ STableInfo* mgmtGetTableByPos(uint32_t dnodeIp, int32_t vnode, int32_t sid) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtCreateTable(SDbObj *pDb, SCreateTableMsg *pCreate) {
|
int32_t mgmtCreateTable(SDbObj *pDb, SCMCreateTableMsg *pCreate) {
|
||||||
STableInfo *pTable = mgmtGetTable(pCreate->meterId);
|
STableInfo *pTable = mgmtGetTable(pCreate->tableId);
|
||||||
if (pTable != NULL) {
|
if (pTable != NULL) {
|
||||||
if (pCreate->igExists) {
|
if (pCreate->igExists) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -113,19 +113,19 @@ int32_t mgmtCreateTable(SDbObj *pDb, SCreateTableMsg *pCreate) {
|
||||||
assert(pAcct != NULL);
|
assert(pAcct != NULL);
|
||||||
int32_t code = mgmtCheckTableLimit(pAcct, pCreate);
|
int32_t code = mgmtCheckTableLimit(pAcct, pCreate);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
mError("table:%s, exceed the limit", pCreate->meterId);
|
mError("table:%s, exceed the limit", pCreate->tableId);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mgmtCheckExpired()) {
|
if (mgmtCheckExpired()) {
|
||||||
mError("failed to create meter:%s, reason:grant expired", pCreate->meterId);
|
mError("failed to create meter:%s, reason:grant expired", pCreate->tableId);
|
||||||
return TSDB_CODE_GRANT_EXPIRED;
|
return TSDB_CODE_GRANT_EXPIRED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pCreate->numOfTags == 0) {
|
if (pCreate->numOfTags == 0) {
|
||||||
int32_t grantCode = mgmtCheckTimeSeries(pCreate->numOfColumns);
|
int32_t grantCode = mgmtCheckTimeSeries(pCreate->numOfColumns);
|
||||||
if (grantCode != 0) {
|
if (grantCode != 0) {
|
||||||
mError("table:%s, grant expired", pCreate->meterId);
|
mError("table:%s, grant expired", pCreate->tableId);
|
||||||
return grantCode;
|
return grantCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ int32_t mgmtDropTable(SDbObj *pDb, char *tableId, int32_t ignore) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtAlterTable(SDbObj *pDb, SAlterTableMsg *pAlter) {
|
int32_t mgmtAlterTable(SDbObj *pDb, SAlterTableMsg *pAlter) {
|
||||||
STableInfo *pTable = mgmtGetTable(pAlter->meterId);
|
STableInfo *pTable = mgmtGetTable(pAlter->tableId);
|
||||||
if (pTable == NULL) {
|
if (pTable == NULL) {
|
||||||
return TSDB_CODE_INVALID_TABLE;
|
return TSDB_CODE_INVALID_TABLE;
|
||||||
}
|
}
|
||||||
|
@ -241,7 +241,7 @@ int32_t mgmtGetTableMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
// return TSDB_CODE_DB_NOT_SELECTED;
|
// return TSDB_CODE_DB_NOT_SELECTED;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// SSchema *pSchema = tsGetSchema(pMeta);
|
// SCMSchema *pSchema = tsGetSchema(pMeta);
|
||||||
//
|
//
|
||||||
// pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
// pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
||||||
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
|
|
|
@ -160,7 +160,7 @@ void mgmtCleanUpUsers() {
|
||||||
|
|
||||||
int32_t mgmtGetUserMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
int32_t mgmtGetUserMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
// int32_t cols = 0;
|
// int32_t cols = 0;
|
||||||
// SSchema *pSchema = tsGetSchema(pMeta);
|
// SCMSchema *pSchema = tsGetSchema(pMeta);
|
||||||
//
|
//
|
||||||
// pShow->bytes[cols] = TSDB_USER_LEN;
|
// pShow->bytes[cols] = TSDB_USER_LEN;
|
||||||
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
|
|
|
@ -256,7 +256,7 @@ int32_t mgmtGetVgroupMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
//
|
//
|
||||||
// if (pDb == NULL) return TSDB_CODE_DB_NOT_SELECTED;
|
// if (pDb == NULL) return TSDB_CODE_DB_NOT_SELECTED;
|
||||||
//
|
//
|
||||||
// SSchema *pSchema = tsGetSchema(pMeta);
|
// SCMSchema *pSchema = tsGetSchema(pMeta);
|
||||||
//
|
//
|
||||||
// pShow->bytes[cols] = 4;
|
// pShow->bytes[cols] = 4;
|
||||||
// pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
// pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||||
|
|
|
@ -28,7 +28,7 @@ extern "C" {
|
||||||
#include "ttypes.h"
|
#include "ttypes.h"
|
||||||
|
|
||||||
struct tSQLBinaryExpr;
|
struct tSQLBinaryExpr;
|
||||||
struct SSchema;
|
struct SCMSchema;
|
||||||
struct tSkipList;
|
struct tSkipList;
|
||||||
struct tSkipListNode;
|
struct tSkipListNode;
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ typedef struct tQueryInfo {
|
||||||
int32_t offset; // offset value in tags
|
int32_t offset; // offset value in tags
|
||||||
int32_t colIdx; // index of column in schema
|
int32_t colIdx; // index of column in schema
|
||||||
uint8_t optr; // expression operator
|
uint8_t optr; // expression operator
|
||||||
SSchema sch; // schema of tags
|
SCMSchema sch; // schema of tags
|
||||||
tVariant q; // query condition value on the specific schema, filter expression
|
tVariant q; // query condition value on the specific schema, filter expression
|
||||||
__compar_fn_t compare; // filter function
|
__compar_fn_t compare; // filter function
|
||||||
} tQueryInfo;
|
} tQueryInfo;
|
||||||
|
@ -65,7 +65,7 @@ typedef struct tSQLSyntaxNode {
|
||||||
int16_t colId; // for schema, the id of column
|
int16_t colId; // for schema, the id of column
|
||||||
union {
|
union {
|
||||||
struct tSQLBinaryExpr *pExpr;
|
struct tSQLBinaryExpr *pExpr;
|
||||||
struct SSchema * pSchema;
|
struct SCMSchema * pSchema;
|
||||||
tVariant * pVal;
|
tVariant * pVal;
|
||||||
};
|
};
|
||||||
} tSQLSyntaxNode;
|
} tSQLSyntaxNode;
|
||||||
|
@ -88,7 +88,7 @@ typedef struct tQueryResultset {
|
||||||
int64_t num;
|
int64_t num;
|
||||||
} tQueryResultset;
|
} tQueryResultset;
|
||||||
|
|
||||||
void tSQLBinaryExprFromString(tSQLBinaryExpr **pExpr, SSchema *pSchema, int32_t numOfCols, char *src, int32_t len);
|
void tSQLBinaryExprFromString(tSQLBinaryExpr **pExpr, SCMSchema *pSchema, int32_t numOfCols, char *src, int32_t len);
|
||||||
|
|
||||||
void tSQLBinaryExprToString(tSQLBinaryExpr *pExpr, char *dst, int32_t *len);
|
void tSQLBinaryExprToString(tSQLBinaryExpr *pExpr, char *dst, int32_t *len);
|
||||||
|
|
||||||
|
|
|
@ -72,16 +72,16 @@ typedef struct tFilePagesItem {
|
||||||
tFilePage item;
|
tFilePage item;
|
||||||
} tFilePagesItem;
|
} tFilePagesItem;
|
||||||
|
|
||||||
typedef struct SSchemaEx {
|
typedef struct SCMSchemaEx {
|
||||||
struct SSchema field;
|
struct SCMSchema field;
|
||||||
int16_t offset;
|
int16_t offset;
|
||||||
} SSchemaEx;
|
} SCMSchemaEx;
|
||||||
|
|
||||||
typedef struct SColumnModel {
|
typedef struct SColumnModel {
|
||||||
int32_t capacity;
|
int32_t capacity;
|
||||||
int32_t numOfCols;
|
int32_t numOfCols;
|
||||||
int16_t rowSize;
|
int16_t rowSize;
|
||||||
SSchemaEx *pFields;
|
SCMSchemaEx *pFields;
|
||||||
} SColumnModel;
|
} SColumnModel;
|
||||||
|
|
||||||
typedef struct SColumnOrderInfo {
|
typedef struct SColumnOrderInfo {
|
||||||
|
@ -116,7 +116,7 @@ typedef struct tExtMemBuffer {
|
||||||
} tExtMemBuffer;
|
} tExtMemBuffer;
|
||||||
|
|
||||||
typedef struct tTagSchema {
|
typedef struct tTagSchema {
|
||||||
struct SSchema *pSchema;
|
struct SCMSchema *pSchema;
|
||||||
int32_t numOfCols;
|
int32_t numOfCols;
|
||||||
int32_t colOffset[];
|
int32_t colOffset[];
|
||||||
} tTagSchema;
|
} tTagSchema;
|
||||||
|
@ -198,7 +198,7 @@ bool tExtMemBufferIsAllDataInMem(tExtMemBuffer *pMemBuffer);
|
||||||
* @param blockCapacity
|
* @param blockCapacity
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
SColumnModel *createColumnModel(SSchema *fields, int32_t numOfCols, int32_t blockCapacity);
|
SColumnModel *createColumnModel(SCMSchema *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 tColModelCompact(SColumnModel *pModel, tFilePage *inputBuffer, int32_t maxElemsCapacity);
|
||||||
|
|
||||||
void tColModelErase(SColumnModel *pModel, tFilePage *inputBuffer, int32_t maxCapacity, int32_t s, int32_t e);
|
void tColModelErase(SColumnModel *pModel, tFilePage *inputBuffer, int32_t maxCapacity, int32_t s, int32_t e);
|
||||||
SSchema *getColumnModelSchema(SColumnModel *pColumnModel, int32_t index);
|
SCMSchema *getColumnModelSchema(SColumnModel *pColumnModel, int32_t index);
|
||||||
|
|
||||||
int16_t getColumnModelOffset(SColumnModel *pColumnModel, int32_t index);
|
int16_t getColumnModelOffset(SColumnModel *pColumnModel, int32_t index);
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ extern "C" {
|
||||||
|
|
||||||
#define VALIDNUMOFCOLS(x) ((x) >= TSDB_MIN_COLUMNS && (x) <= TSDB_MAX_COLUMNS)
|
#define VALIDNUMOFCOLS(x) ((x) >= TSDB_MIN_COLUMNS && (x) <= TSDB_MAX_COLUMNS)
|
||||||
|
|
||||||
struct SSchema;
|
struct SCMSchema;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check if the schema is valid or not, including following aspects:
|
* check if the schema is valid or not, including following aspects:
|
||||||
|
@ -40,14 +40,14 @@ struct SSchema;
|
||||||
* @param numOfCols
|
* @param numOfCols
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
bool isValidSchema(struct SSchema *pSchema, int32_t numOfCols);
|
bool isValidSchema(struct SCMSchema *pSchema, int32_t numOfCols);
|
||||||
|
|
||||||
struct SSchema *tsGetSchema(SMeterMeta *pMeta);
|
struct SCMSchema *tsGetSchema(SMeterMeta *pMeta);
|
||||||
|
|
||||||
struct SSchema *tsGetTagSchema(SMeterMeta *pMeta);
|
struct SCMSchema *tsGetTagSchema(SMeterMeta *pMeta);
|
||||||
|
|
||||||
struct SSchema *tsGetColumnSchema(SMeterMeta *pMeta, int32_t startCol);
|
struct SCMSchema *tsGetColumnSchema(SMeterMeta *pMeta, int32_t startCol);
|
||||||
struct SSchema tsGetTbnameColumnSchema();
|
struct SCMSchema tsGetTbnameColumnSchema();
|
||||||
|
|
||||||
char *tsGetTagsValue(SMeterMeta *pMeta);
|
char *tsGetTagsValue(SMeterMeta *pMeta);
|
||||||
|
|
||||||
|
|
|
@ -468,7 +468,7 @@ int32_t compare_a(tOrderDescriptor *pDescriptor, int32_t numOfRows1, int32_t s1,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SSchema *pSchema = &pDescriptor->pColumnModel->pFields[colIdx];
|
SCMSchema *pSchema = &pDescriptor->pColumnModel->pFields[colIdx];
|
||||||
int32_t ret = columnValueAscendingComparator(f1, f2, pSchema->type, pSchema->bytes);
|
int32_t ret = columnValueAscendingComparator(f1, f2, pSchema->type, pSchema->bytes);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -500,7 +500,7 @@ int32_t compare_d(tOrderDescriptor *pDescriptor, int32_t numOfRows1, int32_t s1,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SSchema *pSchema = &pDescriptor->pColumnModel->pFields[colIdx];
|
SCMSchema *pSchema = &pDescriptor->pColumnModel->pFields[colIdx];
|
||||||
int32_t ret = columnValueAscendingComparator(f1, f2, pSchema->type, pSchema->bytes);
|
int32_t ret = columnValueAscendingComparator(f1, f2, pSchema->type, pSchema->bytes);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
continue;
|
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 *first = COLMODEL_GET_VAL(data1, pColumnModel, count, s1, i);
|
||||||
void *second = COLMODEL_GET_VAL(data1, pColumnModel, count, s2, i);
|
void *second = COLMODEL_GET_VAL(data1, pColumnModel, count, s2, i);
|
||||||
|
|
||||||
SSchema* pSchema = &pColumnModel->pFields[i].field;
|
SCMSchema* pSchema = &pColumnModel->pFields[i].field;
|
||||||
tsDataSwap(first, second, pSchema->type, pSchema->bytes);
|
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
|
* deep copy of sschema
|
||||||
*/
|
*/
|
||||||
SColumnModel *createColumnModel(SSchema *fields, int32_t numOfCols, int32_t blockCapacity) {
|
SColumnModel *createColumnModel(SCMSchema *fields, int32_t numOfCols, int32_t blockCapacity) {
|
||||||
SColumnModel *pColumnModel = (SColumnModel *)calloc(1, sizeof(SColumnModel) + numOfCols * sizeof(SSchemaEx));
|
SColumnModel *pColumnModel = (SColumnModel *)calloc(1, sizeof(SColumnModel) + numOfCols * sizeof(SCMSchemaEx));
|
||||||
if (pColumnModel == NULL) {
|
if (pColumnModel == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pColumnModel->pFields = (SSchemaEx *)(&pColumnModel[1]);
|
pColumnModel->pFields = (SCMSchemaEx *)(&pColumnModel[1]);
|
||||||
|
|
||||||
for(int32_t i = 0; i < numOfCols; ++i) {
|
for(int32_t i = 0; i < numOfCols; ++i) {
|
||||||
SSchemaEx* pSchemaEx = &pColumnModel->pFields[i];
|
SCMSchemaEx* pSchemaEx = &pColumnModel->pFields[i];
|
||||||
pSchemaEx->field = fields[i];
|
pSchemaEx->field = fields[i];
|
||||||
pSchemaEx->offset = pColumnModel->rowSize;
|
pSchemaEx->offset = pColumnModel->rowSize;
|
||||||
|
|
||||||
|
@ -789,15 +789,15 @@ SColumnModel *cloneColumnModel(SColumnModel *pSrc) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SColumnModel *pColumnModel = (SColumnModel *)calloc(1, sizeof(SColumnModel) + pSrc->numOfCols * sizeof(SSchemaEx));
|
SColumnModel *pColumnModel = (SColumnModel *)calloc(1, sizeof(SColumnModel) + pSrc->numOfCols * sizeof(SCMSchemaEx));
|
||||||
if (pColumnModel == NULL) {
|
if (pColumnModel == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*pColumnModel = *pSrc;
|
*pColumnModel = *pSrc;
|
||||||
|
|
||||||
pColumnModel->pFields = (SSchemaEx*) (&pColumnModel[1]);
|
pColumnModel->pFields = (SCMSchemaEx*) (&pColumnModel[1]);
|
||||||
memcpy(pColumnModel->pFields, pSrc->pFields, pSrc->numOfCols * sizeof(SSchemaEx));
|
memcpy(pColumnModel->pFields, pSrc->pFields, pSrc->numOfCols * sizeof(SCMSchemaEx));
|
||||||
|
|
||||||
return pColumnModel;
|
return pColumnModel;
|
||||||
}
|
}
|
||||||
|
@ -1005,14 +1005,14 @@ void tColModelCompact(SColumnModel *pModel, tFilePage *inputBuffer, int32_t maxE
|
||||||
|
|
||||||
/* start from the second column */
|
/* start from the second column */
|
||||||
for (int32_t i = 1; i < pModel->numOfCols; ++i) {
|
for (int32_t i = 1; i < pModel->numOfCols; ++i) {
|
||||||
SSchemaEx* pSchemaEx = &pModel->pFields[i];
|
SCMSchemaEx* pSchemaEx = &pModel->pFields[i];
|
||||||
memmove(inputBuffer->data + pSchemaEx->offset * inputBuffer->numOfElems,
|
memmove(inputBuffer->data + pSchemaEx->offset * inputBuffer->numOfElems,
|
||||||
inputBuffer->data + pSchemaEx->offset * maxElemsCapacity,
|
inputBuffer->data + pSchemaEx->offset * maxElemsCapacity,
|
||||||
pSchemaEx->field.bytes * inputBuffer->numOfElems);
|
pSchemaEx->field.bytes * inputBuffer->numOfElems);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchema* getColumnModelSchema(SColumnModel *pColumnModel, int32_t index) {
|
SCMSchema* getColumnModelSchema(SColumnModel *pColumnModel, int32_t index) {
|
||||||
assert(pColumnModel != NULL && index >= 0 && index < pColumnModel->numOfCols);
|
assert(pColumnModel != NULL && index >= 0 && index < pColumnModel->numOfCols);
|
||||||
return &pColumnModel->pFields[index].field;
|
return &pColumnModel->pFields[index].field;
|
||||||
}
|
}
|
||||||
|
@ -1034,7 +1034,7 @@ void tColModelErase(SColumnModel *pModel, tFilePage *inputBuffer, int32_t blockC
|
||||||
/* start from the second column */
|
/* start from the second column */
|
||||||
for (int32_t i = 0; i < pModel->numOfCols; ++i) {
|
for (int32_t i = 0; i < pModel->numOfCols; ++i) {
|
||||||
int16_t offset = getColumnModelOffset(pModel, i);
|
int16_t offset = getColumnModelOffset(pModel, i);
|
||||||
SSchema* pSchema = getColumnModelSchema(pModel, i);
|
SCMSchema* pSchema = getColumnModelSchema(pModel, i);
|
||||||
|
|
||||||
char *startPos = inputBuffer->data + offset * blockCapacity + s * pSchema->bytes;
|
char *startPos = inputBuffer->data + offset * blockCapacity + s * pSchema->bytes;
|
||||||
char *endPos = startPos + pSchema->bytes * removed;
|
char *endPos = startPos + pSchema->bytes * removed;
|
||||||
|
|
|
@ -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,
|
static void setTagsValueInInterpolation(tFilePage** data, char** pTags, SColumnModel* pModel, int32_t order, int32_t start,
|
||||||
int32_t capacity, int32_t num) {
|
int32_t capacity, int32_t num) {
|
||||||
for (int32_t j = 0, i = start; i < pModel->numOfCols; ++i, ++j) {
|
for (int32_t j = 0, i = start; i < pModel->numOfCols; ++i, ++j) {
|
||||||
SSchema* pSchema = getColumnModelSchema(pModel, i);
|
SCMSchema* pSchema = getColumnModelSchema(pModel, i);
|
||||||
|
|
||||||
char* val1 = getPos(data[i]->data, pSchema->bytes, order, capacity, num);
|
char* val1 = getPos(data[i]->data, pSchema->bytes, order, capacity, num);
|
||||||
assignVal(val1, pTags[j], pSchema->bytes, pSchema->type);
|
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;
|
char* pInterpolationData = INTERPOL_IS_ASC_INTERPOL(pInterpoInfo) ? *prevValues : *nextValues;
|
||||||
if (pInterpolationData != NULL) {
|
if (pInterpolationData != NULL) {
|
||||||
for (int32_t i = 1; i < numOfValCols; ++i) {
|
for (int32_t i = 1; i < numOfValCols; ++i) {
|
||||||
SSchema* pSchema = getColumnModelSchema(pModel, i);
|
SCMSchema* pSchema = getColumnModelSchema(pModel, i);
|
||||||
int16_t offset = getColumnModelOffset(pModel, i);
|
int16_t offset = getColumnModelOffset(pModel, i);
|
||||||
|
|
||||||
char* val1 = getPos(data[i]->data, pSchema->bytes, pInterpoInfo->order, capacity, *num);
|
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 */
|
} else { /* no prev value yet, set the value for null */
|
||||||
for (int32_t i = 1; i < numOfValCols; ++i) {
|
for (int32_t i = 1; i < numOfValCols; ++i) {
|
||||||
SSchema* pSchema = getColumnModelSchema(pModel, i);
|
SCMSchema* pSchema = getColumnModelSchema(pModel, i);
|
||||||
|
|
||||||
char* val1 = getPos(data[i]->data, pSchema->bytes, pInterpoInfo->order, capacity, *num);
|
char* val1 = getPos(data[i]->data, pSchema->bytes, pInterpoInfo->order, capacity, *num);
|
||||||
setNull(val1, pSchema->type, pSchema->bytes);
|
setNull(val1, pSchema->type, pSchema->bytes);
|
||||||
|
@ -261,7 +261,7 @@ static void doInterpoResultImpl(SInterpolationInfo* pInterpoInfo, int16_t interp
|
||||||
// TODO : linear interpolation supports NULL value
|
// TODO : linear interpolation supports NULL value
|
||||||
if (*prevValues != NULL && !outOfBound) {
|
if (*prevValues != NULL && !outOfBound) {
|
||||||
for (int32_t i = 1; i < numOfValCols; ++i) {
|
for (int32_t i = 1; i < numOfValCols; ++i) {
|
||||||
SSchema* pSchema = getColumnModelSchema(pModel, i);
|
SCMSchema* pSchema = getColumnModelSchema(pModel, i);
|
||||||
int16_t offset = getColumnModelOffset(pModel, i);
|
int16_t offset = getColumnModelOffset(pModel, i);
|
||||||
|
|
||||||
int16_t type = pSchema->type;
|
int16_t type = pSchema->type;
|
||||||
|
@ -282,7 +282,7 @@ static void doInterpoResultImpl(SInterpolationInfo* pInterpoInfo, int16_t interp
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
for (int32_t i = 1; i < numOfValCols; ++i) {
|
for (int32_t i = 1; i < numOfValCols; ++i) {
|
||||||
SSchema* pSchema = getColumnModelSchema(pModel, i);
|
SCMSchema* pSchema = getColumnModelSchema(pModel, i);
|
||||||
|
|
||||||
char* val1 = getPos(data[i]->data, pSchema->bytes, pInterpoInfo->order, capacity, *num);
|
char* val1 = getPos(data[i]->data, pSchema->bytes, pInterpoInfo->order, capacity, *num);
|
||||||
setNull(val1, pSchema->type, pSchema->bytes);
|
setNull(val1, pSchema->type, pSchema->bytes);
|
||||||
|
@ -292,7 +292,7 @@ static void doInterpoResultImpl(SInterpolationInfo* pInterpoInfo, int16_t interp
|
||||||
}
|
}
|
||||||
} else { /* default value interpolation */
|
} else { /* default value interpolation */
|
||||||
for (int32_t i = 1; i < numOfValCols; ++i) {
|
for (int32_t i = 1; i < numOfValCols; ++i) {
|
||||||
SSchema* pSchema = getColumnModelSchema(pModel, i);
|
SCMSchema* pSchema = getColumnModelSchema(pModel, i);
|
||||||
|
|
||||||
char* val1 = getPos(data[i]->data, pSchema->bytes, pInterpoInfo->order, capacity, *num);
|
char* val1 = getPos(data[i]->data, pSchema->bytes, pInterpoInfo->order, capacity, *num);
|
||||||
assignVal(val1, (char*)&defaultVal[i], pSchema->bytes, pSchema->type);
|
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);
|
*nextValues = calloc(1, pModel->rowSize);
|
||||||
for (int i = 1; i < pModel->numOfCols; i++) {
|
for (int i = 1; i < pModel->numOfCols; i++) {
|
||||||
int16_t offset = getColumnModelOffset(pModel, i);
|
int16_t offset = getColumnModelOffset(pModel, i);
|
||||||
SSchema* pSchema = getColumnModelSchema(pModel, i);
|
SCMSchema* pSchema = getColumnModelSchema(pModel, i);
|
||||||
|
|
||||||
setNull(*nextValues + offset, pSchema->type, pSchema->bytes);
|
setNull(*nextValues + offset, pSchema->type, pSchema->bytes);
|
||||||
}
|
}
|
||||||
|
@ -353,7 +353,7 @@ int32_t taosDoInterpoResult(SInterpolationInfo* pInterpoInfo, int16_t interpoTyp
|
||||||
|
|
||||||
int32_t offset = pInterpoInfo->rowIdx;
|
int32_t offset = pInterpoInfo->rowIdx;
|
||||||
for (int32_t tlen = 0, i = 0; i < pModel->numOfCols - numOfTags; ++i) {
|
for (int32_t tlen = 0, i = 0; i < pModel->numOfCols - numOfTags; ++i) {
|
||||||
SSchema* pSchema = getColumnModelSchema(pModel, i);
|
SCMSchema* pSchema = getColumnModelSchema(pModel, i);
|
||||||
|
|
||||||
memcpy(*nextValues + tlen, srcData[i] + offset * pSchema->bytes, pSchema->bytes);
|
memcpy(*nextValues + tlen, srcData[i] + offset * pSchema->bytes, pSchema->bytes);
|
||||||
tlen += pSchema->bytes;
|
tlen += pSchema->bytes;
|
||||||
|
@ -379,7 +379,7 @@ int32_t taosDoInterpoResult(SInterpolationInfo* pInterpoInfo, int16_t interpoTyp
|
||||||
*prevValues = calloc(1, pModel->rowSize);
|
*prevValues = calloc(1, pModel->rowSize);
|
||||||
for (int i = 1; i < pModel->numOfCols; i++) {
|
for (int i = 1; i < pModel->numOfCols; i++) {
|
||||||
int16_t offset = getColumnModelOffset(pModel, i);
|
int16_t offset = getColumnModelOffset(pModel, i);
|
||||||
SSchema* pSchema = getColumnModelSchema(pModel, i);
|
SCMSchema* pSchema = getColumnModelSchema(pModel, i);
|
||||||
|
|
||||||
setNull(*prevValues + offset, pSchema->type, pSchema->bytes);
|
setNull(*prevValues + offset, pSchema->type, pSchema->bytes);
|
||||||
}
|
}
|
||||||
|
@ -389,7 +389,7 @@ int32_t taosDoInterpoResult(SInterpolationInfo* pInterpoInfo, int16_t interpoTyp
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
for (int32_t tlen = 0; i < pModel->numOfCols - numOfTags; ++i) {
|
for (int32_t tlen = 0; i < pModel->numOfCols - numOfTags; ++i) {
|
||||||
int16_t offset = getColumnModelOffset(pModel, i);
|
int16_t offset = getColumnModelOffset(pModel, i);
|
||||||
SSchema* pSchema = getColumnModelSchema(pModel, i);
|
SCMSchema* pSchema = getColumnModelSchema(pModel, i);
|
||||||
|
|
||||||
char* val1 = getPos(data[i]->data, pSchema->bytes, pInterpoInfo->order, bufSize, num);
|
char* val1 = getPos(data[i]->data, pSchema->bytes, pInterpoInfo->order, bufSize, num);
|
||||||
|
|
||||||
|
|
|
@ -297,7 +297,7 @@ tMemBucket *tMemBucketCreate(int32_t totalSlots, int32_t nBufferSize, int16_t nE
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchema* pSchema = getColumnModelSchema(pDesc->pColumnModel, 0);
|
SCMSchema* pSchema = getColumnModelSchema(pDesc->pColumnModel, 0);
|
||||||
if (pSchema->type != dataType) {
|
if (pSchema->type != dataType) {
|
||||||
pError("MemBucket:%p,data type is not consistent,%d in schema, %d in param", pBucket, pSchema->type, dataType);
|
pError("MemBucket:%p,data type is not consistent,%d in schema, %d in param", pBucket, pSchema->type, dataType);
|
||||||
tfree(pBucket);
|
tfree(pBucket);
|
||||||
|
|
Loading…
Reference in New Issue