提交 b6313b34 编写于 作者: S slguan

[TD-9] fix compile errors

上级 2180f6eb
......@@ -154,7 +154,7 @@ typedef struct _vg_obj {
struct _db_obj *pDb;
int32_t numOfTables;
void * idPool;
STableInfo ** tableList;
SChildTableObj ** tableList;
} SVgObj;
typedef struct _db_obj {
......@@ -241,6 +241,7 @@ typedef struct {
int8_t usePublicIp;
int8_t received;
int8_t successed;
int8_t expected;
int32_t contLen;
int32_t code;
void *ahandle;
......
......@@ -24,7 +24,7 @@ extern "C" {
int32_t mgmtInitUsers();
void mgmtCleanUpUsers();
SUserObj *mgmtGetUser(char *name);
SUserObj *mgmtGetUserFromConn(void *pConn, bool *usePublicIp)
SUserObj *mgmtGetUserFromConn(void *pConn, bool *usePublicIp);
#ifdef __cplusplus
}
......
......@@ -21,11 +21,23 @@
#include "ttime.h"
#include "tstatus.h"
#include "tutil.h"
#include "qast.h"
#include "qextbuffer.h"
#include "taoserror.h"
#include "taosmsg.h"
#include "tscompression.h"
#include "tskiplist.h"
#include "tsqlfunction.h"
#include "tstatus.h"
#include "ttime.h"
#include "name.h"
#include "mnode.h"
#include "mgmtAcct.h"
#include "mgmtChildTable.h"
#include "mgmtDb.h"
#include "mgmtDClient.h"
#include "mgmtDnode.h"
#include "mgmtDServer.h"
#include "mgmtGrant.h"
#include "mgmtMnode.h"
#include "mgmtProfile.h"
......@@ -34,6 +46,7 @@
#include "mgmtSuperTable.h"
#include "mgmtTable.h"
#include "mgmtVgroup.h"
#include "mgmtUser.h"
static void *tsChildTableSdb;
static int32_t tsChildTableUpdateSize;
......@@ -79,7 +92,7 @@ static int32_t mgmtChildTableActionInsert(SSdbOperDesc *pOper) {
if (pTable->info.type == TSDB_CHILD_TABLE) {
pTable->superTable = mgmtGetSuperTable(pTable->superTableId);
pStable->numOfTables++;
pTable->superTable->numOfTables++;
mgmtAddTimeSeries(pAcct, pTable->superTable->numOfColumns - 1);
} else {
mgmtAddTimeSeries(pAcct, pTable->numOfColumns - 1);
......@@ -115,12 +128,12 @@ static int32_t mgmtChildTableActionDelete(SSdbOperDesc *pOper) {
if (pTable->info.type == TSDB_CHILD_TABLE) {
mgmtRestoreTimeSeries(pAcct, pTable->superTable->numOfColumns - 1);
pStable->numOfTables--;
pTable->superTable->numOfTables--;
} else {
mgmtRestoreTimeSeries(pAcct, pTable->numOfColumns - 1);
}
mgmtRemoveTableFromDb(pDb);
mgmtRemoveTableFromVgroup(pVgroup, (STableInfo *) pTable);
mgmtRemoveTableFromVgroup(pVgroup, pTable);
return TSDB_CODE_SUCCESS;
}
......@@ -163,14 +176,14 @@ static int32_t mgmtChildTableActionDecode(SSdbOperDesc *pOper) {
int32_t schemaSize = pTable->numOfColumns * sizeof(SSchema);
pTable->schema = (SSchema *)malloc(schemaSize);
if (pTable->schema == NULL) {
mgmtDestroyNormalTable(pTable);
mgmtDestroyChildTable(pTable);
return TSDB_CODE_SERV_OUT_OF_MEMORY;
}
memcpy(pTable->schema, pOper->rowData + tsChildTableUpdateSize, schemaSize);
pTable->sql = (char *)malloc(pTable->sqlLen);
if (pTable->sql == NULL) {
mgmtDestroyNormalTable(pTable);
mgmtDestroyChildTable(pTable);
return TSDB_CODE_SERV_OUT_OF_MEMORY;
}
memcpy(pTable->sql, pOper->rowData + tsChildTableUpdateSize + schemaSize, pTable->sqlLen);
......@@ -191,7 +204,7 @@ int32_t mgmtInitChildTables() {
SSdbTableDesc tableDesc = {
.tableName = "ctables",
.hashSessions = tsMaxTables,
.maxRowSize = sizeof(SChildTableObj) + sizeof(SSchema) * TSDB_MAX_COLUMNS,,
.maxRowSize = sizeof(SChildTableObj) + sizeof(SSchema) * TSDB_MAX_COLUMNS,
.keyType = SDB_KEY_TYPE_STRING,
.insertFp = mgmtChildTableActionInsert,
.deleteFp = mgmtChildTableActionDelete,
......@@ -319,7 +332,7 @@ static void *mgmtBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableOb
}
memcpy(pCreate->tableId, pTable->info.tableId, TSDB_TABLE_ID_LEN + 1);
memcpy(pCreate->superTableId, pTable->superTable->tableId, TSDB_TABLE_ID_LEN + 1);
memcpy(pCreate->superTableId, pTable->superTable->info.tableId, TSDB_TABLE_ID_LEN + 1);
pCreate->contLen = htonl(contLen);
pCreate->vgId = htonl(pTable->vgId);
pCreate->tableType = pTable->info.type;
......@@ -381,7 +394,7 @@ static SChildTableObj* mgmtDoCreateChildTable(SCMCreateTableMsg *pCreate, SVgObj
pTable->sid = tid;
pTable->vgId = pVgroup->vgId;
if (Table->info.type == TSDB_CHILD_TABLE) {
if (pTable->info.type == TSDB_CHILD_TABLE) {
char *pTagData = (char *) pCreate->schema; // it is a tag key
SSuperTableObj *pSuperTable = mgmtGetSuperTable(pTagData);
if (pSuperTable == NULL) {
......@@ -391,7 +404,7 @@ static SChildTableObj* mgmtDoCreateChildTable(SCMCreateTableMsg *pCreate, SVgObj
return NULL;
}
strcpy(pTable->superTableId, pSuperTable->tableId);
strcpy(pTable->superTableId, pSuperTable->info.tableId);
pTable->uid = (((uint64_t) pTable->vgId) << 40) + ((((uint64_t) pTable->sid) & ((1ul << 24) - 1ul)) << 16) +
(sdbGetVersion() & ((1ul << 16) - 1ul));
pTable->superTable = pSuperTable;
......@@ -503,7 +516,7 @@ void mgmtCreateChildTable(SQueuedMsg *pMsg) {
mgmtSendMsgToDnode(&ipSet, &rpcMsg);
}
static int32_t mgmtDropChildTable(SQueuedMsg *newMsg, SChildTableObj *pTable) {
void mgmtDropChildTable(SQueuedMsg *pMsg, SChildTableObj *pTable) {
SVgObj *pVgroup = mgmtGetVgroup(pTable->vgId);
if (pVgroup == NULL) {
mError("ctable:%s, failed to drop child table, vgroup not exist", pTable->info.tableId);
......@@ -528,14 +541,14 @@ static int32_t mgmtDropChildTable(SQueuedMsg *newMsg, SChildTableObj *pTable) {
mTrace("ctable:%s, send drop table msg", pDrop->tableId);
SRpcMsg rpcMsg = {
.handle = newMsg,
.handle = pMsg,
.pCont = pDrop,
.contLen = sizeof(SMDDropTableMsg),
.code = 0,
.msgType = TSDB_MSG_TYPE_MD_DROP_TABLE
};
newMsg->ahandle = pTable;
pMsg->ahandle = pTable;
mgmtSendMsgToDnode(&ipSet, &rpcMsg);
}
......@@ -593,7 +606,7 @@ int32_t mgmtModifyChildTableTagValueByName(SChildTableObj *pTable, char *tagName
}
static int32_t mgmtFindNormalTableColumnIndex(SNormalTableObj *pTable, char *colName) {
static int32_t mgmtFindNormalTableColumnIndex(SChildTableObj *pTable, char *colName) {
SSchema *schema = (SSchema *) pTable->schema;
for (int32_t i = 0; i < pTable->numOfColumns; i++) {
if (strcasecmp(schema[i].name, colName) == 0) {
......@@ -604,7 +617,7 @@ static int32_t mgmtFindNormalTableColumnIndex(SNormalTableObj *pTable, char *col
return -1;
}
static int32_t mgmtAddNormalTableColumn(SNormalTableObj *pTable, SSchema schema[], int32_t ncols) {
static int32_t mgmtAddNormalTableColumn(SChildTableObj *pTable, SSchema schema[], int32_t ncols) {
if (ncols <= 0) {
return TSDB_CODE_APP_ERROR;
}
......@@ -644,7 +657,7 @@ static int32_t mgmtAddNormalTableColumn(SNormalTableObj *pTable, SSchema schema[
SSdbOperDesc desc = {0};
desc.type = SDB_OPER_TYPE_GLOBAL;
desc.pObj = pTable;
desc.table = tsNormalTableSdb;
desc.table = tsChildTableSdb;
desc.rowData = pTable;
desc.rowSize = tsChildTableUpdateSize;
sdbUpdateRow(&desc);
......@@ -652,7 +665,7 @@ static int32_t mgmtAddNormalTableColumn(SNormalTableObj *pTable, SSchema schema[
return TSDB_CODE_SUCCESS;
}
static int32_t mgmtDropNormalTableColumnByName(SNormalTableObj *pTable, char *colName) {
static int32_t mgmtDropNormalTableColumnByName(SChildTableObj *pTable, char *colName) {
int32_t col = mgmtFindNormalTableColumnIndex(pTable, colName);
if (col < 0) {
return TSDB_CODE_APP_ERROR;
......@@ -681,7 +694,7 @@ static int32_t mgmtDropNormalTableColumnByName(SNormalTableObj *pTable, char *co
SSdbOperDesc desc = {0};
desc.type = SDB_OPER_TYPE_GLOBAL;
desc.pObj = pTable;
desc.table = tsNormalTableSdb;
desc.table = tsChildTableSdb;
desc.rowData = pTable;
desc.rowSize = tsChildTableUpdateSize;
sdbUpdateRow(&desc);
......@@ -702,14 +715,7 @@ static int32_t mgmtSetSchemaFromNormalTable(SSchema *pSchema, SChildTableObj *pT
return numOfCols * sizeof(SSchema);
}
static void mgmtGetChildTableMeta(SQueuedMsg *pMsg, SDbObj *pDb, SChildTableObj *pTable) {
STableMetaMsg *pMeta = rpcMallocCont(sizeof(STableMetaMsg) + sizeof(SSchema) * TSDB_MAX_COLUMNS);
if (pMeta == NULL) {
mError("table:%s, failed to get table meta, no enough memory", pTable->info.tableId);
mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_SERV_OUT_OF_MEMORY);
return;
}
static int32_t mgmtDoGetChildTableMeta(SDbObj *pDb, SChildTableObj *pTable, STableMetaMsg *pMeta, bool usePublicIp) {
pMeta->uid = htobe64(pTable->uid);
pMeta->sid = htonl(pTable->sid);
pMeta->vgId = htonl(pTable->vgId);
......@@ -732,12 +738,11 @@ static void mgmtGetChildTableMeta(SQueuedMsg *pMsg, SDbObj *pDb, SChildTableObj
SVgObj *pVgroup = mgmtGetVgroup(pTable->vgId);
if (pVgroup == NULL) {
mError("table:%s, failed to get table meta, db not selected", pTable->info.tableId);
mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_INVALID_VGROUP_ID);
return;
return TSDB_CODE_INVALID_VGROUP_ID;
}
for (int32_t i = 0; i < TSDB_VNODES_SUPPORT; ++i) {
if (pMsg->usePublicIp) {
if (usePublicIp) {
pMeta->vpeerDesc[i].ip = pVgroup->vnodeGid[i].publicIp;
} else {
pMeta->vpeerDesc[i].ip = pVgroup->vnodeGid[i].privateIp;
......@@ -746,18 +751,12 @@ static void mgmtGetChildTableMeta(SQueuedMsg *pMsg, SDbObj *pDb, SChildTableObj
}
pMeta->numOfVpeers = pVgroup->numOfVnodes;
SRpcMsg rpcRsp = {
.handle = pMsg->thandle,
.pCont = pMeta,
.contLen = pMeta->contLen,
};
pMeta->contLen = htons(pMeta->contLen);
rpcSendResponse(&rpcRsp);
mTrace("table:%s, uid:%" PRIu64 " table meta is retrieved", pTable->info.tableId, pTable->uid);
return TSDB_CODE_SUCCESS;
}
void mgmtProcessChildTableMetaMsg(SQueuedMsg *pMsg) {
void mgmtGetChildTableMeta(SQueuedMsg *pMsg, SChildTableObj *pTable) {
SCMTableInfoMsg *pInfo = pMsg->pCont;
SDbObj *pDb = mgmtGetDbByTableId(pTable->info.tableId);
if (pDb == NULL || pDb->dirty) {
......@@ -766,7 +765,6 @@ void mgmtProcessChildTableMetaMsg(SQueuedMsg *pMsg) {
return;
}
STableInfo *pTable = mgmtGetTable(pInfo->tableId);
if (pTable == NULL) {
if (htons(pInfo->createFlag) != 1) {
mError("table:%s, failed to get table meta, table not exist", pInfo->tableId);
......@@ -796,7 +794,22 @@ void mgmtProcessChildTableMetaMsg(SQueuedMsg *pMsg) {
}
}
mgmtGetChildTableMeta(pMsg, pDb, pTable);
STableMetaMsg *pMeta = rpcMallocCont(sizeof(STableMetaMsg) + sizeof(SSchema) * TSDB_MAX_COLUMNS);
if (pMeta == NULL) {
mError("table:%s, failed to get table meta, no enough memory", pTable->info.tableId);
mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_SERV_OUT_OF_MEMORY);
return;
}
mgmtDoGetChildTableMeta(pDb, pTable, pMeta, pMsg->usePublicIp);
SRpcMsg rpcRsp = {
.handle = pMsg->thandle,
.pCont = pMeta,
.contLen = pMeta->contLen,
};
pMeta->contLen = htons(pMeta->contLen);
rpcSendResponse(&rpcRsp);
}
void mgmtDropAllChildTables(SDbObj *pDropDb) {
......@@ -853,7 +866,7 @@ void mgmtDropAllChildTablesInStable(SSuperTableObj *pStable) {
}
}
mTrace("stable:%s, all child tables:%d is dropped from sdb", pStable->tableId, numOfTables);
mTrace("stable:%s, all child tables:%d is dropped from sdb", pStable->info.tableId, numOfTables);
}
static STableInfo* mgmtGetTableByPos(uint32_t dnodeId, int32_t vnode, int32_t sid) {
......@@ -908,7 +921,7 @@ static void mgmtProcessDropTableRsp(SRpcMsg *rpcMsg) {
SQueuedMsg *queueMsg = rpcMsg->handle;
queueMsg->received++;
STableInfo *pTable = queueMsg->ahandle;
SChildTableObj *pTable = queueMsg->ahandle;
mTrace("table:%s, drop table rsp received, thandle:%p result:%s", pTable->info.tableId, queueMsg->thandle, tstrerror(rpcMsg->code));
if (rpcMsg->code != TSDB_CODE_SUCCESS) {
......@@ -948,17 +961,13 @@ static void mgmtProcessDropTableRsp(SRpcMsg *rpcMsg) {
free(queueMsg);
}
static void mgmtProcessDropStableRsp(SRpcMsg *rpcMsg) {
mTrace("drop stable rsp received, handle:%p code:%d", rpcMsg->handle, rpcMsg->code);
}
static void mgmtProcessCreateTableRsp(SRpcMsg *rpcMsg) {
if (rpcMsg->handle == NULL) return;
SQueuedMsg *queueMsg = rpcMsg->handle;
queueMsg->received++;
STableInfo *pTable = queueMsg->ahandle;
SChildTableObj *pTable = queueMsg->ahandle;
mTrace("table:%s, create table rsp received, thandle:%p ahandle:%p result:%s", pTable->info.tableId, queueMsg->thandle,
rpcMsg->handle, tstrerror(rpcMsg->code));
......@@ -1026,7 +1035,7 @@ static void mgmtProcessMultiTableMetaMsg(SQueuedMsg *pMsg) {
for (int t = 0; t < pInfo->numOfTables; ++t) {
char *tableId = (char*)(pInfo->tableIds + t * TSDB_TABLE_ID_LEN);
STableInfo *pTable = mgmtGetTable(tableId);
SChildTableObj *pTable = mgmtGetChildTable(tableId);
if (pTable == NULL) continue;
SDbObj *pDb = mgmtGetDbByTableId(tableId);
......@@ -1047,7 +1056,7 @@ static void mgmtProcessMultiTableMetaMsg(SQueuedMsg *pMsg) {
}
STableMetaMsg *pMeta = (STableMetaMsg *)(pMultiMeta->metas + pMultiMeta->contLen);
int32_t code = mgmtGetTableMeta(pDb, pTable, pMeta, usePublicIp);
int32_t code = mgmtDoGetChildTableMeta(pDb, pTable, pMeta, usePublicIp);
if (code == TSDB_CODE_SUCCESS) {
pMultiMeta->numOfTables ++;
pMultiMeta->contLen += pMeta->contLen;
......@@ -1120,7 +1129,7 @@ static int32_t mgmtRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows,
SDbObj *pDb = mgmtGetDb(pShow->db);
if (pDb == NULL) return 0;
SUserObj *pUser = mgmtGetUserFromConn(pConn);
SUserObj *pUser = mgmtGetUserFromConn(pConn, NULL);
if (pUser == NULL) return 0;
if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) {
......@@ -1140,18 +1149,17 @@ static int32_t mgmtRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows,
int32_t prefixLen = strlen(prefix);
while (numOfRows < rows) {
pShow->pNode = sdbFetchRow(tsNormalTableSdb, pShow->pNode, (void **) &pTable);
pShow->pNode = sdbFetchRow(tsChildTableSdb, pShow->pNode, (void **) &pTable);
if (pTable == NULL) break;
// not belong to current db
if (strncmp(tableId, prefix, prefixLen)) {
if (strncmp(pTable->info.tableId, prefix, prefixLen)) {
continue;
}
char tableName[TSDB_TABLE_NAME_LEN] = {0};
memset(tableName, 0, tListLen(tableName));
numOfRead++;
// pattern compare for meter name
mgmtExtractTableName(pTable->info.tableId, tableName);
......@@ -1188,7 +1196,7 @@ static int32_t mgmtRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows,
numOfRows++;
}
pShow->numOfReads += numOfRead;
pShow->numOfReads += numOfRows;
const int32_t NUM_OF_COLUMNS = 4;
mgmtVacuumResult(data, NUM_OF_COLUMNS, numOfRows, rows, pShow);
......@@ -1201,11 +1209,11 @@ void mgmtAlterChildTable(SQueuedMsg *pMsg, SChildTableObj *pTable) {
SCMAlterTableMsg *pAlter = pMsg->pCont;;
if (pAlter->type == TSDB_ALTER_TABLE_UPDATE_TAG_VAL) {
code = mgmtModifyChildTableTagValueByName((SChildTableObj *)pTable, pAlter->schema[0].name, pAlter->tagVal);
code = mgmtModifyChildTableTagValueByName(pTable, pAlter->schema[0].name, pAlter->tagVal);
} else if (pAlter->type == TSDB_ALTER_TABLE_ADD_COLUMN) {
code = mgmtAddNormalTableColumn((SNormalTableObj *)pTable, pAlter->schema, 1);
code = mgmtAddNormalTableColumn(pTable, pAlter->schema, 1);
} else if (pAlter->type == TSDB_ALTER_TABLE_DROP_COLUMN) {
code = mgmtDropNormalTableColumnByName((SNormalTableObj *)pTable, pAlter->schema[0].name);
code = mgmtDropNormalTableColumnByName(pTable, pAlter->schema[0].name);
} else {
}
......
......@@ -28,7 +28,6 @@
#include "mgmtGrant.h"
#include "mgmtShell.h"
#include "mgmtMnode.h"
#include "mgmtNormalTable.h"
#include "mgmtChildTable.h"
#include "mgmtSdb.h"
#include "mgmtSuperTable.h"
......@@ -82,7 +81,6 @@ static int32_t mgmtDbActionDelete(SSdbOperDesc *pOper) {
SAcctObj *pAcct = mgmtGetAcct(pDb->cfg.acct);
mgmtRemoveDbFromAcct(pAcct, pDb);
mgmtDropAllNormalTables(pDb);
mgmtDropAllChildTables(pDb);
mgmtDropAllSuperTables(pDb);
mgmtDropAllVgroups(pDb);
......@@ -382,7 +380,7 @@ static int32_t mgmtGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn)
int32_t cols = 0;
SSchema *pSchema = pMeta->schema;
SUserObj *pUser = mgmtGetUserFromConn(pConn);
SUserObj *pUser = mgmtGetUserFromConn(pConn, NULL);
if (pUser == NULL) return 0;
pShow->bytes[cols] = TSDB_DB_NAME_LEN;
......@@ -532,7 +530,7 @@ static int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void *
SDbObj *pDb = NULL;
char * pWrite;
int32_t cols = 0;
SUserObj *pUser = mgmtGetUserFromConn(pConn);
SUserObj *pUser = mgmtGetUserFromConn(pConn, NULL);
if (pUser == NULL) return 0;
while (numOfRows < rows) {
......
......@@ -76,7 +76,7 @@ bool mgmtCheckModuleInDnode(SDnodeObj *pDnode, int32_t moduleType) {
int32_t mgmtGetModuleMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
int32_t cols = 0;
SUserObj *pUser = mgmtGetUserFromConn(pConn);
SUserObj *pUser = mgmtGetUserFromConn(pConn, NULL);
if (pUser == NULL) return 0;
if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
......@@ -169,7 +169,7 @@ int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pCo
static int32_t mgmtGetConfigMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
int32_t cols = 0;
SUserObj *pUser = mgmtGetUserFromConn(pConn);
SUserObj *pUser = mgmtGetUserFromConn(pConn, NULL);
if (pUser == NULL) return 0;
if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
......@@ -256,7 +256,7 @@ static int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, vo
static int32_t mgmtGetVnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
int32_t cols = 0;
SUserObj *pUser = mgmtGetUserFromConn(pConn);
SUserObj *pUser = mgmtGetUserFromConn(pConn, NULL);
if (pUser == NULL) return 0;
if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
......
......@@ -118,7 +118,7 @@ static void *mgmtGetNextMnode(SShowObj *pShow, SMnodeObj **pMnode) {
static int32_t mgmtGetMnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
int32_t cols = 0;
SUserObj *pUser = mgmtGetUserFromConn(pConn);
SUserObj *pUser = mgmtGetUserFromConn(pConn, NULL);
if (pUser == NULL) return 0;
if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
......
......@@ -678,7 +678,7 @@ void mgmtProcessKillQueryMsg(SQueuedMsg *pMsg) {
SRpcMsg rpcRsp = {.handle = pMsg->thandle, .pCont = NULL, .contLen = 0, .code = 0, .msgType = 0};
if (mgmtCheckRedirect(pMsg->thandle)) return;
SUserObj *pUser = mgmtGetUserFromConn(pMsg->thandle);
SUserObj *pUser = mgmtGetUserFromConn(pMsg->thandle, NULL);
if (pUser == NULL) {
rpcRsp.code = TSDB_CODE_INVALID_USER;
rpcSendResponse(&rpcRsp);
......@@ -702,7 +702,7 @@ void mgmtProcessKillStreamMsg(SQueuedMsg *pMsg) {
SRpcMsg rpcRsp = {.handle = pMsg->thandle, .pCont = NULL, .contLen = 0, .code = 0, .msgType = 0};
if (mgmtCheckRedirect(pMsg->thandle)) return;
SUserObj *pUser = mgmtGetUserFromConn(pMsg->thandle);
SUserObj *pUser = mgmtGetUserFromConn(pMsg->thandle, NULL);
if (pUser == NULL) {
rpcRsp.code = TSDB_CODE_INVALID_USER;
rpcSendResponse(&rpcRsp);
......@@ -726,7 +726,7 @@ void mgmtProcessKillConnectionMsg(SQueuedMsg *pMsg) {
SRpcMsg rpcRsp = {.handle = pMsg->thandle, .pCont = NULL, .contLen = 0, .code = 0, .msgType = 0};
if (mgmtCheckRedirect(pMsg->thandle)) return;
SUserObj *pUser = mgmtGetUserFromConn(pMsg->thandle);
SUserObj *pUser = mgmtGetUserFromConn(pMsg->thandle, NULL);
if (pUser == NULL) {
rpcRsp.code = TSDB_CODE_INVALID_USER;
rpcSendResponse(&rpcRsp);
......
......@@ -30,7 +30,6 @@
#include "mgmtDnode.h"
#include "mgmtGrant.h"
#include "mgmtMnode.h"
#include "mgmtNormalTable.h"
#include "mgmtProfile.h"
#include "mgmtSdb.h"
#include "mgmtShell.h"
......@@ -139,7 +138,7 @@ static void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg) {
}
if (mgmtCheckExpired()) {
mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_GRANT_EXPIRED);
mgmtSendSimpleResp(rpcMsg->handle, TSDB_CODE_GRANT_EXPIRED);
return;
}
......@@ -174,7 +173,7 @@ static void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg) {
queuedMsg->contLen = rpcMsg->contLen;
queuedMsg->pCont = rpcMsg->pCont;
queuedMsg->pUser = pUser;
queuedMsg.usePublicIp = usePublicIp;
queuedMsg->usePublicIp = usePublicIp;
mgmtAddToShellQueue(queuedMsg);
}
}
......@@ -448,7 +447,7 @@ static bool mgmtCheckMeterMetaMsgType(void *pMsg) {
static bool mgmtCheckMsgReadOnly(int8_t type, void *pCont) {
if ((type == TSDB_MSG_TYPE_CM_TABLE_META && (!mgmtCheckMeterMetaMsgType(pCont))) ||
type == TSDB_MSG_TYPE_CM_STABLE_META || type == TSDB_MSG_TYPE_RETRIEVE ||
type == TSDB_MSG_TYPE_CM_STABLE_VGROUP || type == TSDB_MSG_TYPE_RETRIEVE ||
type == TSDB_MSG_TYPE_CM_SHOW || type == TSDB_MSG_TYPE_CM_TABLES_META ||
type == TSDB_MSG_TYPE_CM_CONNECT) {
return true;
......
......@@ -20,6 +20,7 @@
#include "mgmtAcct.h"
#include "mgmtChildTable.h"
#include "mgmtDb.h"
#include "mgmtDClient.h"
#include "mgmtDnode.h"
#include "mgmtGrant.h"
#include "mgmtShell.h"
......@@ -47,8 +48,8 @@ static int32_t mgmtSuperTableActionDestroy(SSdbOperDesc *pOper) {
}
static int32_t mgmtSuperTableActionInsert(SSdbOperDesc *pOper) {
STableInfo *pStable = pOper->pObj;
SDbObj *pDb = mgmtGetDbByTableId(pStable->tableId);
SSuperTableObj *pStable = pOper->pObj;
SDbObj *pDb = mgmtGetDbByTableId(pStable->info.tableId);
if (pDb != NULL) {
mgmtAddSuperTableIntoDb(pDb);
}
......@@ -56,8 +57,8 @@ static int32_t mgmtSuperTableActionInsert(SSdbOperDesc *pOper) {
}
static int32_t mgmtSuperTableActionDelete(SSdbOperDesc *pOper) {
STableInfo *pStable = pOper->pObj;
SDbObj *pDb = mgmtGetDbByTableId(pStable->tableId);
SSuperTableObj *pStable = pOper->pObj;
SDbObj *pDb = mgmtGetDbByTableId(pStable->info.tableId);
if (pDb != NULL) {
mgmtRemoveSuperTableFromDb(pDb);
mgmtDropAllChildTablesInStable((SSuperTableObj *)pStable);
......@@ -151,11 +152,9 @@ void mgmtCreateSuperTable(SQueuedMsg *pMsg) {
return;
}
strcpy(pStable->tableId, pCreate->tableId);
pStable->type = TSDB_SUPER_TABLE;
strcpy(pStable->info.tableId, pCreate->tableId);
pStable->info.type = TSDB_SUPER_TABLE;
pStable->createdTime = taosGetTimestampMs();
pStable->vgId = 0;
pStable->sid = 0;
pStable->uid = (((uint64_t) pStable->createdTime) << 16) + (sdbGetVersion() & ((1ul << 16) - 1ul));
pStable->sversion = 0;
pStable->numOfColumns = htons(pCreate->numOfColumns);
......@@ -191,14 +190,14 @@ void mgmtCreateSuperTable(SQueuedMsg *pMsg) {
mgmtDestroySuperTable(pStable);
mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_SDB_ERROR);
} else {
mLPrint("stable:%s, is created, tags:%d cols:%d", pStable->tableId, pStable->numOfTags, pStable->numOfColumns);
mLPrint("stable:%s, is created, tags:%d cols:%d", pStable->info.tableId, pStable->numOfTags, pStable->numOfColumns);
mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_SUCCESS);
}
}
void mgmtDropSuperTable(SQueuedMsg *newMsg, SSuperTableObj *pTable) {
void mgmtDropSuperTable(SQueuedMsg *pMsg, SSuperTableObj *pStable) {
if (pStable->numOfTables != 0) {
mError("stable:%s, numOfTables:%d not 0", pStable->tableId, pStable->numOfTables);
mError("stable:%s, numOfTables:%d not 0", pStable->info.tableId, pStable->numOfTables);
mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_OTHERS);
} else {
SSdbOperDesc oper = {
......@@ -207,7 +206,7 @@ void mgmtDropSuperTable(SQueuedMsg *newMsg, SSuperTableObj *pTable) {
.pObj = pStable
};
int32_t code = sdbDeleteRow(&oper);
mLPrint("stable:%s, is dropped from sdb, result:%s", pStable->tableId, tstrerror(code));
mLPrint("stable:%s, is dropped from sdb, result:%s", pStable->info.tableId, tstrerror(code));
mgmtSendSimpleResp(pMsg->thandle, code);
}
}
......@@ -248,9 +247,9 @@ static int32_t mgmtAddSuperTableTag(SSuperTableObj *pStable, SSchema schema[], i
}
}
SDbObj *pDb = mgmtGetDbByTableId(pStable->tableId);
SDbObj *pDb = mgmtGetDbByTableId(pStable->info.tableId);
if (pDb == NULL) {
mError("meter: %s not belongs to any database", pStable->tableId);
mError("meter: %s not belongs to any database", pStable->info.tableId);
return TSDB_CODE_APP_ERROR;
}
......@@ -278,7 +277,7 @@ static int32_t mgmtAddSuperTableTag(SSuperTableObj *pStable, SSchema schema[], i
pAcct->acctInfo.numOfTimeSeries += (ntags * pStable->numOfTables);
// sdbUpdateRow(tsSuperTableSdb, pStable, tsSuperTableUpdateSize, SDB_OPER_GLOBAL);
mTrace("Succeed to add tag column %s to table %s", schema[0].name, pStable->tableId);
mTrace("Succeed to add tag column %s to table %s", schema[0].name, pStable->info.tableId);
return TSDB_CODE_SUCCESS;
}
......@@ -288,9 +287,9 @@ static int32_t mgmtDropSuperTableTag(SSuperTableObj *pStable, char *tagName) {
return TSDB_CODE_APP_ERROR;
}
SDbObj *pDb = mgmtGetDbByTableId(pStable->tableId);
SDbObj *pDb = mgmtGetDbByTableId(pStable->info.tableId);
if (pDb == NULL) {
mError("table: %s not belongs to any database", pStable->tableId);
mError("table: %s not belongs to any database", pStable->info.tableId);
return TSDB_CODE_APP_ERROR;
}
......@@ -318,11 +317,11 @@ static int32_t mgmtModifySuperTableTagNameByName(SSuperTableObj *pStable, char *
int32_t col = mgmtFindSuperTableTagIndex(pStable, oldTagName);
if (col < 0) {
// Tag name does not exist
mError("Failed to modify table %s tag column, oname: %s, nname: %s", pStable->tableId, oldTagName, newTagName);
mError("Failed to modify table %s tag column, oname: %s, nname: %s", pStable->info.tableId, oldTagName, newTagName);
return TSDB_CODE_INVALID_MSG_TYPE;
}
int32_t rowSize = 0;
// int32_t rowSize = 0;
uint32_t len = strlen(newTagName);
if (col >= pStable->numOfTags || len >= TSDB_COL_NAME_LEN || mgmtFindSuperTableTagIndex(pStable, newTagName) >= 0) {
......@@ -346,11 +345,11 @@ static int32_t mgmtModifySuperTableTagNameByName(SSuperTableObj *pStable, char *
tfree(msg);
if (ret < 0) {
mError("Failed to modify table %s tag column", pStable->tableId);
mError("Failed to modify table %s tag column", pStable->info.tableId);
return TSDB_CODE_APP_ERROR;
}
mTrace("Succeed to modify table %s tag column", pStable->tableId);
mTrace("Succeed to modify table %s tag column", pStable->info.tableId);
return TSDB_CODE_SUCCESS;
}
......@@ -376,9 +375,9 @@ static int32_t mgmtAddSuperTableColumn(SSuperTableObj *pStable, SSchema schema[]
}
}
SDbObj *pDb = mgmtGetDbByTableId(pStable->tableId);
SDbObj *pDb = mgmtGetDbByTableId(pStable->info.tableId);
if (pDb == NULL) {
mError("meter: %s not belongs to any database", pStable->tableId);
mError("meter: %s not belongs to any database", pStable->info.tableId);
return TSDB_CODE_APP_ERROR;
}
......@@ -415,9 +414,9 @@ static int32_t mgmtDropSuperTableColumnByName(SSuperTableObj *pStable, char *col
return TSDB_CODE_APP_ERROR;
}
SDbObj *pDb = mgmtGetDbByTableId(pStable->tableId);
SDbObj *pDb = mgmtGetDbByTableId(pStable->info.tableId);
if (pDb == NULL) {
mError("table: %s not belongs to any database", pStable->tableId);
mError("table: %s not belongs to any database", pStable->info.tableId);
return TSDB_CODE_APP_ERROR;
}
......@@ -504,7 +503,7 @@ int32_t mgmtRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows, v
SDbObj *pDb = mgmtGetDb(pShow->db);
if (pDb == NULL) return 0;
SUserObj *pUser = mgmtGetUserFromConn(pConn);
SUserObj *pUser = mgmtGetUserFromConn(pConn, NULL);
if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) {
if (strcmp(pUser->user, "root") != 0 && strcmp(pUser->user, "_root") != 0 && strcmp(pUser->user, "monitor") != 0 ) {
......@@ -605,7 +604,6 @@ int32_t mgmtSetSchemaFromSuperTable(SSchema *pSchema, SSuperTableObj *pTable) {
}
void mgmtGetSuperTableMeta(SQueuedMsg *pMsg, SSuperTableObj *pTable) {
SCMTableInfoMsg *pInfo = pMsg->pCont;
SDbObj *pDb = pMsg->pDb;
STableMetaMsg *pMeta = rpcMallocCont(sizeof(STableMetaMsg) + sizeof(SSchema) * TSDB_MAX_COLUMNS);
......@@ -667,4 +665,8 @@ void mgmtAlterSuperTable(SQueuedMsg *pMsg, SSuperTableObj *pTable) {
} else {}
mgmtSendSimpleResp(pMsg->thandle, code);
}
static void mgmtProcessDropStableRsp(SRpcMsg *rpcMsg) {
mTrace("drop stable rsp received, handle:%p code:%d", rpcMsg->handle, rpcMsg->code);
}
\ No newline at end of file
......@@ -73,7 +73,7 @@ void mgmtCleanUpTables() {
mgmtCleanUpSuperTables();
}
void mgmtExtractTableName(const char* tableId, char* name) {
void mgmtExtractTableName(char* tableId, char* name) {
int pos = -1;
int num = 0;
for (pos = 0; tableId[pos] != 0; ++pos) {
......@@ -139,14 +139,14 @@ static void mgmtProcessDropTableMsg(SQueuedMsg *pMsg) {
return;
}
pMsg->pDb = mgmtGetDb(pCreate->db);
pMsg->pDb = mgmtGetDbByTableId(pDrop->tableId);
if (pMsg->pDb == NULL || pMsg->pDb->dirty) {
mError("table:%s, failed to drop table, db not selected", pDrop->tableId);
mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_DB_NOT_SELECTED);
return;
}
if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) {
if (mgmtCheckIsMonitorDB(pMsg->pDb->name, tsMonitorDbName)) {
mError("table:%s, failed to drop table, in monitor database", pDrop->tableId);
mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_MONITOR_DB_FORBIDDEN);
return;
......@@ -170,7 +170,7 @@ static void mgmtProcessDropTableMsg(SQueuedMsg *pMsg) {
mgmtDropSuperTable(pMsg, (SSuperTableObj *)pTable);
} else {
mTrace("table:%s, start to drop ctable", pDrop->tableId);
mgmtDropChildTable(pMsg, (SNormalTableObj *)pTable);
mgmtDropChildTable(pMsg, (SChildTableObj *)pTable);
}
}
......@@ -186,15 +186,15 @@ static void mgmtProcessAlterTableMsg(SQueuedMsg *pMsg) {
return;
}
pMsg->pDb = mgmtGetDbByTableId(pTable->tableId);
pMsg->pDb = mgmtGetDbByTableId(pAlter->tableId);
if (pMsg->pDb == NULL || pMsg->pDb->dirty) {
mError("table:%s, failed to alter table, db not selected", pTable->tableId);
mError("table:%s, failed to alter table, db not selected", pAlter->tableId);
mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_DB_NOT_SELECTED);
return;
}
if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) {
mError("table:%s, failed to alter table, its log db", pTable->tableId);
if (mgmtCheckIsMonitorDB(pMsg->pDb->name, tsMonitorDbName)) {
mError("table:%s, failed to alter table, its log db", pAlter->tableId);
mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_MONITOR_DB_FORBIDDEN);
return;
}
......@@ -218,22 +218,22 @@ static void mgmtProcessAlterTableMsg(SQueuedMsg *pMsg) {
}
if (pTable->type == TSDB_SUPER_TABLE) {
mTrace("table:%s, start to alter stable", pDrop->tableId);
mTrace("table:%s, start to alter stable", pAlter->tableId);
mgmtAlterSuperTable(pMsg, (SSuperTableObj *)pTable);
} else {
mTrace("table:%s, start to alter ctable", pDrop->tableId);
mgmtAlterChildTable(pMsg, (SNormalTableObj *)pTable);
mTrace("table:%s, start to alter ctable", pAlter->tableId);
mgmtAlterChildTable(pMsg, (SChildTableObj *)pTable);
}
}
static void mgmtProcessTableMetaMsg(SQueuedMsg *pMsg) {
SCMTableInfoMsg *pInfo = mgmtGetTable(pInfo->tableId);
SCMTableInfoMsg *pInfo = pMsg->pCont;
mTrace("table:%s, table meta msg is received from thandle:%p", pInfo->tableId, pMsg->thandle);
STableInfo *pTable = mgmtGetTable(pInfo->tableId);
if (pTable == NULL || pTable->type != TSDB_SUPER_TABLE) {
mgmtGetChildTableMeta(pMsg, (SSuperTableObj *)pTable);
mgmtGetChildTableMeta(pMsg, (SChildTableObj *)pTable);
} else {
mgmtGetSuperTableMeta(pMsg, (SNormalTableObj *)pTable);
mgmtGetSuperTableMeta(pMsg, (SSuperTableObj *)pTable);
}
}
\ No newline at end of file
......@@ -231,7 +231,7 @@ static int32_t mgmtDropUser(SAcctObj *pAcct, char *name) {
}
static int32_t mgmtGetUserMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
SUserObj *pUser = mgmtGetUserFromConn(pConn);
SUserObj *pUser = mgmtGetUserFromConn(pConn, NULL);
if (pUser == NULL) {
return TSDB_CODE_INVALID_USER;
}
......
......@@ -20,6 +20,7 @@
#include "tstatus.h"
#include "mnode.h"
#include "mgmtBalance.h"
#include "mgmtChildTable.h"
#include "mgmtDb.h"
#include "mgmtDClient.h"
#include "mgmtDnode.h"
......@@ -276,9 +277,9 @@ int32_t mgmtGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
int32_t maxReplica = 0;
SVgObj *pVgroup = NULL;
STableInfo *pTable = NULL;
SChildTableObj *pTable = NULL;
if (pShow->payloadLen > 0 ) {
pTable = mgmtGetTable(pShow->payload);
pTable = mgmtGetChildTable(pShow->payload);
if (NULL == pTable) {
return TSDB_CODE_INVALID_TABLE_ID;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册