create super table
This commit is contained in:
parent
a563fb8f74
commit
78812e6d90
|
@ -139,7 +139,7 @@ static tSQLSyntaxNode *tSQLSyntaxNodeCreate(SSchema *pSchema, int32_t numOfCols,
|
||||||
} else {
|
} else {
|
||||||
pNode->colId = -1;
|
pNode->colId = -1;
|
||||||
pNode->pSchema->type = TSDB_DATA_TYPE_BINARY;
|
pNode->pSchema->type = TSDB_DATA_TYPE_BINARY;
|
||||||
pNode->pSchema->bytes = TSDB_METER_NAME_LEN;
|
pNode->pSchema->bytes = TSDB_TABLE_NAME_LEN;
|
||||||
strcpy(pNode->pSchema->name, TSQL_TBNAME_L);
|
strcpy(pNode->pSchema->name, TSQL_TBNAME_L);
|
||||||
pNode->pSchema->colId = -1;
|
pNode->pSchema->colId = -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,7 +293,7 @@ static int tscBuildMetricTagProjectionResult(SSqlObj *pSql) {
|
||||||
for (int32_t f = 1; f < pMeterMetaInfo->numOfTags; ++f) {
|
for (int32_t f = 1; f < pMeterMetaInfo->numOfTags; ++f) {
|
||||||
int16_t tagColumnIndex = pMeterMetaInfo->tagColumnIndex[f - 1];
|
int16_t tagColumnIndex = pMeterMetaInfo->tagColumnIndex[f - 1];
|
||||||
if (tagColumnIndex == -1) {
|
if (tagColumnIndex == -1) {
|
||||||
vOffset[f] = vOffset[f - 1] + TSDB_METER_NAME_LEN;
|
vOffset[f] = vOffset[f - 1] + TSDB_TABLE_NAME_LEN;
|
||||||
} else {
|
} else {
|
||||||
vOffset[f] = vOffset[f - 1] + pSchema[tagColumnIndex].bytes;
|
vOffset[f] = vOffset[f - 1] + pSchema[tagColumnIndex].bytes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -363,7 +363,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pToken->n > TSDB_METER_NAME_LEN) {
|
if (pToken->n > TSDB_TABLE_NAME_LEN) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1054,12 +1054,12 @@ int32_t setObjFullName(char* fullName, const char* account, SSQLToken* pDB, SSQL
|
||||||
totalLen += 1;
|
totalLen += 1;
|
||||||
|
|
||||||
/* here we only check the table name length limitation */
|
/* here we only check the table name length limitation */
|
||||||
if (tableName->n > TSDB_METER_NAME_LEN) {
|
if (tableName->n > TSDB_TABLE_NAME_LEN) {
|
||||||
return TSDB_CODE_INVALID_SQL;
|
return TSDB_CODE_INVALID_SQL;
|
||||||
}
|
}
|
||||||
} else { // pDB == NULL, the db prefix name is specified in tableName
|
} else { // pDB == NULL, the db prefix name is specified in tableName
|
||||||
/* the length limitation includes tablename + dbname + sep */
|
/* the length limitation includes tablename + dbname + sep */
|
||||||
if (tableName->n > TSDB_METER_NAME_LEN + TSDB_DB_NAME_LEN + tListLen(TS_PATH_DELIMITER)) {
|
if (tableName->n > TSDB_TABLE_NAME_LEN + TSDB_DB_NAME_LEN + tListLen(TS_PATH_DELIMITER)) {
|
||||||
return TSDB_CODE_INVALID_SQL;
|
return TSDB_CODE_INVALID_SQL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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};
|
SSchema colSchema = {.type = TSDB_DATA_TYPE_BINARY, .bytes = TSDB_TABLE_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;
|
||||||
|
@ -2085,7 +2085,7 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg6);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg6);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pCmd->payloadLen > TSDB_METER_NAME_LEN) {
|
if (pCmd->payloadLen > TSDB_TABLE_NAME_LEN) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2679,7 +2679,7 @@ static int32_t tablenameListToString(tSQLExpr* pExpr, /*char* str*/ SStringBuild
|
||||||
taosStringBuilderAppendString(sb, TBNAME_LIST_SEP);
|
taosStringBuilderAppendString(sb, TBNAME_LIST_SEP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSub->val.nLen <= 0 || pSub->val.nLen > TSDB_METER_NAME_LEN) {
|
if (pSub->val.nLen <= 0 || pSub->val.nLen > TSDB_TABLE_NAME_LEN) {
|
||||||
return TSDB_CODE_INVALID_SQL;
|
return TSDB_CODE_INVALID_SQL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4951,7 +4951,7 @@ static int32_t doAddGroupbyColumnsOnDemand(SQueryInfo* pQueryInfo) {
|
||||||
int16_t colIndex = pColIndex->colIdx;
|
int16_t colIndex = pColIndex->colIdx;
|
||||||
if (pColIndex->colIdx == TSDB_TBNAME_COLUMN_INDEX) {
|
if (pColIndex->colIdx == TSDB_TBNAME_COLUMN_INDEX) {
|
||||||
type = TSDB_DATA_TYPE_BINARY;
|
type = TSDB_DATA_TYPE_BINARY;
|
||||||
bytes = TSDB_METER_NAME_LEN;
|
bytes = TSDB_TABLE_NAME_LEN;
|
||||||
name = TSQL_TBNAME_L;
|
name = TSQL_TBNAME_L;
|
||||||
} else {
|
} else {
|
||||||
colIndex = (TSDB_COL_IS_TAG(pColIndex->flag)) ? pMeterMetaInfo->pMeterMeta->numOfColumns + pColIndex->colIdx
|
colIndex = (TSDB_COL_IS_TAG(pColIndex->flag)) ? pMeterMetaInfo->pMeterMeta->numOfColumns + pColIndex->colIdx
|
||||||
|
|
|
@ -84,7 +84,7 @@ struct SSchema* tsGetColumnSchema(STableMeta* pMeta, int32_t startCol) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SSchema tsGetTbnameColumnSchema() {
|
struct SSchema tsGetTbnameColumnSchema() {
|
||||||
struct SSchema s = {.colId = TSDB_TBNAME_COLUMN_INDEX, .type = TSDB_DATA_TYPE_BINARY, .bytes = TSDB_METER_NAME_LEN};
|
struct SSchema s = {.colId = TSDB_TBNAME_COLUMN_INDEX, .type = TSDB_DATA_TYPE_BINARY, .bytes = TSDB_TABLE_NAME_LEN};
|
||||||
strcpy(s.name, TSQL_TBNAME_L);
|
strcpy(s.name, TSQL_TBNAME_L);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
|
|
@ -1575,7 +1575,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
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 = {
|
SSchema tbSchema = {
|
||||||
.bytes = TSDB_METER_NAME_LEN, .colId = TSDB_TBNAME_COLUMN_INDEX, .type = TSDB_DATA_TYPE_BINARY};
|
.bytes = TSDB_TABLE_NAME_LEN, .colId = TSDB_TBNAME_COLUMN_INDEX, .type = TSDB_DATA_TYPE_BINARY};
|
||||||
memcpy(pMsg, &tbSchema, sizeof(SSchema));
|
memcpy(pMsg, &tbSchema, sizeof(SSchema));
|
||||||
} else {
|
} else {
|
||||||
memcpy(pMsg, &pTagSchema[pMeterMetaInfo->tagColumnIndex[j]], sizeof(SSchema));
|
memcpy(pMsg, &pTagSchema[pMeterMetaInfo->tagColumnIndex[j]], sizeof(SSchema));
|
||||||
|
|
|
@ -101,40 +101,8 @@ typedef struct {
|
||||||
int32_t vgId; // vnode group ID
|
int32_t vgId; // vnode group ID
|
||||||
} STableGid;
|
} STableGid;
|
||||||
|
|
||||||
typedef struct _tab_obj {
|
|
||||||
char tableId[TSDB_TABLE_ID_LEN + 1];
|
|
||||||
uint64_t uid;
|
|
||||||
STableGid gid;
|
|
||||||
|
|
||||||
int32_t sversion; // schema version
|
|
||||||
int64_t createdTime;
|
|
||||||
int32_t numOfTags; // for metric
|
|
||||||
int32_t numOfTables; // for metric
|
|
||||||
int32_t numOfColumns;
|
|
||||||
int32_t schemaSize;
|
|
||||||
short nextColId;
|
|
||||||
char tableType : 4;
|
|
||||||
char status : 3;
|
|
||||||
char isDirty : 1; // if the table change tag column 1 value
|
|
||||||
char reserved[15];
|
|
||||||
char updateEnd[1];
|
|
||||||
|
|
||||||
pthread_rwlock_t rwLock;
|
|
||||||
tSkipList * pSkipList;
|
|
||||||
struct _tab_obj *pHead; // for metric, a link list for all meters created
|
|
||||||
// according to this metric
|
|
||||||
char *pTagData; // TSDB_TABLE_ID_LEN(metric_name)+
|
|
||||||
// tags_value1/tags_value2/tags_value3
|
|
||||||
struct _tab_obj *prev, *next;
|
|
||||||
char * pSql; // pointer to SQL, for SC, null-terminated string
|
|
||||||
char * pReserve1;
|
|
||||||
char * pReserve2;
|
|
||||||
char * schema;
|
|
||||||
// SSchema schema[];
|
|
||||||
} STabObj;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char tableId[TSDB_TABLE_ID_LEN + 1];
|
char tableId[TSDB_TABLE_ID_LEN];
|
||||||
int8_t type;
|
int8_t type;
|
||||||
uint64_t uid;
|
uint64_t uid;
|
||||||
int32_t sid;
|
int32_t sid;
|
||||||
|
@ -142,38 +110,40 @@ typedef struct {
|
||||||
int64_t createdTime;
|
int64_t createdTime;
|
||||||
} STableInfo;
|
} STableInfo;
|
||||||
|
|
||||||
|
struct _vg_obj;
|
||||||
|
|
||||||
typedef struct SSuperTableObj {
|
typedef struct SSuperTableObj {
|
||||||
char tableId[TSDB_TABLE_ID_LEN + 1];
|
char tableId[TSDB_TABLE_ID_LEN];
|
||||||
int8_t type;
|
int8_t type;
|
||||||
uint64_t uid;
|
uint64_t uid;
|
||||||
int32_t sid;
|
int32_t sid;
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
int64_t createdTime;
|
int64_t createdTime;
|
||||||
int32_t sversion;
|
int32_t sversion;
|
||||||
int32_t numOfTables;
|
|
||||||
int32_t numOfColumns;
|
int32_t numOfColumns;
|
||||||
int32_t numOfTags;
|
int32_t numOfTags;
|
||||||
int8_t reserved[7];
|
int8_t reserved[7];
|
||||||
int8_t updateEnd[1];
|
int8_t updateEnd[1];
|
||||||
|
int32_t numOfTables;
|
||||||
int16_t nextColId;
|
int16_t nextColId;
|
||||||
SSchema *schema;
|
SSchema *schema;
|
||||||
} SSuperTableObj;
|
} SSuperTableObj;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char tableId[TSDB_TABLE_ID_LEN + 1];
|
char tableId[TSDB_TABLE_ID_LEN];
|
||||||
int8_t type;
|
int8_t type;
|
||||||
uint64_t uid;
|
uint64_t uid;
|
||||||
int32_t sid;
|
int32_t sid;
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
int64_t createdTime;
|
int64_t createdTime;
|
||||||
char superTableId[TSDB_TABLE_ID_LEN + 1];
|
char superTableId[TSDB_TABLE_ID_LEN];
|
||||||
int8_t reserved[7];
|
int8_t reserved[7];
|
||||||
int8_t updateEnd[1];
|
int8_t updateEnd[1];
|
||||||
SSuperTableObj *superTable;
|
SSuperTableObj *superTable;
|
||||||
} SChildTableObj;
|
} SChildTableObj;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char tableId[TSDB_TABLE_ID_LEN + 1];
|
char tableId[TSDB_TABLE_ID_LEN];
|
||||||
int8_t type;
|
int8_t type;
|
||||||
uint64_t uid;
|
uint64_t uid;
|
||||||
int32_t sid;
|
int32_t sid;
|
||||||
|
@ -188,7 +158,7 @@ typedef struct {
|
||||||
} SNormalTableObj;
|
} SNormalTableObj;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char tableId[TSDB_TABLE_ID_LEN + 1];
|
char tableId[TSDB_TABLE_ID_LEN];
|
||||||
int8_t type;
|
int8_t type;
|
||||||
uint64_t uid;
|
uint64_t uid;
|
||||||
int32_t sid;
|
int32_t sid;
|
||||||
|
@ -224,24 +194,20 @@ typedef struct _vg_obj {
|
||||||
} SVgObj;
|
} SVgObj;
|
||||||
|
|
||||||
typedef struct _db_obj {
|
typedef struct _db_obj {
|
||||||
/*
|
char name[TSDB_DB_NAME_LEN];
|
||||||
* this length will cause the storage structure to change, rollback
|
|
||||||
*/
|
|
||||||
char name[TSDB_DB_NAME_LEN + 1];
|
|
||||||
int64_t createdTime;
|
int64_t createdTime;
|
||||||
SDbCfg cfg;
|
SDbCfg cfg;
|
||||||
int32_t numOfVgroups;
|
int8_t dropStatus;
|
||||||
int32_t numOfTables;
|
|
||||||
int32_t numOfMetrics;
|
|
||||||
uint8_t vgStatus;
|
|
||||||
uint8_t dropStatus;
|
|
||||||
char reserved[16];
|
char reserved[16];
|
||||||
char updateEnd[1];
|
char updateEnd[1];
|
||||||
|
|
||||||
struct _db_obj *prev, *next;
|
struct _db_obj *prev, *next;
|
||||||
SVgObj * pHead; // empty vgroup first
|
int32_t numOfVgroups;
|
||||||
SVgObj * pTail; // empty vgroup end
|
int32_t numOfTables;
|
||||||
void * vgTimer;
|
int32_t numOfSuperTables;
|
||||||
|
int32_t vgStatus;
|
||||||
|
SVgObj *pHead; // empty vgroup first
|
||||||
|
SVgObj *pTail; // empty vgroup end
|
||||||
|
void * vgTimer;
|
||||||
} SDbObj;
|
} SDbObj;
|
||||||
|
|
||||||
struct _acctObj;
|
struct _acctObj;
|
||||||
|
|
|
@ -86,7 +86,7 @@ extern "C" {
|
||||||
#define TS_PATH_DELIMITER_LEN 1
|
#define TS_PATH_DELIMITER_LEN 1
|
||||||
|
|
||||||
#define TSDB_METER_ID_LEN_MARGIN 10
|
#define TSDB_METER_ID_LEN_MARGIN 10
|
||||||
#define TSDB_TABLE_ID_LEN (TSDB_DB_NAME_LEN+TSDB_METER_NAME_LEN+2*TS_PATH_DELIMITER_LEN+TSDB_USERID_LEN+TSDB_METER_ID_LEN_MARGIN) //TSDB_DB_NAME_LEN+TSDB_METER_NAME_LEN+2*strlen(TS_PATH_DELIMITER)+strlen(USERID)
|
#define TSDB_TABLE_ID_LEN (TSDB_DB_NAME_LEN+TSDB_TABLE_NAME_LEN+2*TS_PATH_DELIMITER_LEN+TSDB_USERID_LEN+TSDB_METER_ID_LEN_MARGIN) //TSDB_DB_NAME_LEN+TSDB_TABLE_NAME_LEN+2*strlen(TS_PATH_DELIMITER)+strlen(USERID)
|
||||||
#define TSDB_UNI_LEN 24
|
#define TSDB_UNI_LEN 24
|
||||||
#define TSDB_USER_LEN TSDB_UNI_LEN
|
#define TSDB_USER_LEN TSDB_UNI_LEN
|
||||||
#define TSDB_ACCT_LEN TSDB_UNI_LEN
|
#define TSDB_ACCT_LEN TSDB_UNI_LEN
|
||||||
|
@ -95,7 +95,7 @@ extern "C" {
|
||||||
#define TSDB_MAX_COLUMNS 256
|
#define TSDB_MAX_COLUMNS 256
|
||||||
#define TSDB_MIN_COLUMNS 2 //PRIMARY COLUMN(timestamp) + other columns
|
#define TSDB_MIN_COLUMNS 2 //PRIMARY COLUMN(timestamp) + other columns
|
||||||
|
|
||||||
#define TSDB_METER_NAME_LEN 64
|
#define TSDB_TABLE_NAME_LEN 64
|
||||||
#define TSDB_DB_NAME_LEN 32
|
#define TSDB_DB_NAME_LEN 32
|
||||||
#define TSDB_COL_NAME_LEN 64
|
#define TSDB_COL_NAME_LEN 64
|
||||||
#define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 16
|
#define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 16
|
||||||
|
|
|
@ -116,8 +116,8 @@ typedef struct {
|
||||||
} SDbInfo;
|
} SDbInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_METER_NAME_LEN + 1];
|
char name[TSDB_TABLE_NAME_LEN + 1];
|
||||||
char metric[TSDB_METER_NAME_LEN + 1];
|
char metric[TSDB_TABLE_NAME_LEN + 1];
|
||||||
} STableRecord;
|
} STableRecord;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -42,6 +42,11 @@ 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);
|
||||||
|
|
||||||
|
void mgmtAddSuperTableIntoDb(SDbObj *pDb);
|
||||||
|
void mgmtRemoveSuperTableFromDb(SDbObj *pDb);
|
||||||
|
void mgmtAddTableIntoDb(SDbObj *pDb);
|
||||||
|
void mgmtRemoveTableFromDb(SDbObj *pDb);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -221,6 +221,8 @@ int32_t mgmtInitChildTables() {
|
||||||
pNode = pLastNode;
|
pNode = pLastNode;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mgmtAddTableIntoDb(pDb);
|
||||||
}
|
}
|
||||||
|
|
||||||
mgmtSetVgroupIdPool();
|
mgmtSetVgroupIdPool();
|
||||||
|
@ -305,12 +307,12 @@ int32_t mgmtCreateChildTable(SDbObj *pDb, SCreateTableMsg *pCreate, SVgObj *pVgr
|
||||||
}
|
}
|
||||||
|
|
||||||
mgmtAddTimeSeries(pTable->superTable->numOfColumns - 1);
|
mgmtAddTimeSeries(pTable->superTable->numOfColumns - 1);
|
||||||
|
|
||||||
mgmtSendCreateTableMsg(pTable, pVgroup);
|
mgmtSendCreateTableMsg(pTable, pVgroup);
|
||||||
|
|
||||||
mTrace("table:%s, create table in vgroup, vgId:%d sid:%d vnode:%d uid:%" PRIu64 " db:%s",
|
mTrace("table:%s, create table in vgroup, vgId:%d sid:%d vnode:%d uid:%" PRIu64 " db:%s",
|
||||||
pTable->tableId, pVgroup->vgId, sid, pVgroup->vnodeGid[0].vnode, pTable->uid, pDb->name);
|
pTable->tableId, pVgroup->vgId, sid, pVgroup->vnodeGid[0].vnode, pTable->uid, pDb->name);
|
||||||
|
|
||||||
|
mgmtAddTableIntoDb(pDb);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,6 +339,7 @@ int32_t mgmtDropChildTable(SDbObj *pDb, SChildTableObj *pTable) {
|
||||||
mgmtDropVgroup(pDb, pVgroup);
|
mgmtDropVgroup(pDb, pVgroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mgmtRemoveTableFromDb(pDb);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ int mgmtGetConns(SShowObj *pShow, void *pConn) {
|
||||||
int mgmtGetConnsMeta(STableMeta *pMeta, SShowObj *pShow, void *pConn) {
|
int mgmtGetConnsMeta(STableMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int cols = 0;
|
int cols = 0;
|
||||||
|
|
||||||
pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
pShow->bytes[cols] = TSDB_TABLE_NAME_LEN;
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
|
|
|
@ -86,7 +86,7 @@ int32_t mgmtInitDbs() {
|
||||||
pDb->next = NULL;
|
pDb->next = NULL;
|
||||||
pDb->numOfTables = 0;
|
pDb->numOfTables = 0;
|
||||||
pDb->numOfVgroups = 0;
|
pDb->numOfVgroups = 0;
|
||||||
pDb->numOfMetrics = 0;
|
pDb->numOfSuperTables = 0;
|
||||||
pDb->vgStatus = TSDB_VG_STATUS_READY;
|
pDb->vgStatus = TSDB_VG_STATUS_READY;
|
||||||
pDb->vgTimer = NULL;
|
pDb->vgTimer = NULL;
|
||||||
pAcct = mgmtGetAcct(pDb->cfg.acct);
|
pAcct = mgmtGetAcct(pDb->cfg.acct);
|
||||||
|
@ -853,3 +853,18 @@ void *mgmtDbActionDestroy(void *row, char *str, int32_t size, int32_t *ssize) {
|
||||||
tfree(row);
|
tfree(row);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mgmtAddSuperTableIntoDb(SDbObj *pDb) {
|
||||||
|
atomic_add_fetch_32(&pDb->numOfSuperTables, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void mgmtRemoveSuperTableFromDb(SDbObj *pDb) {
|
||||||
|
atomic_add_fetch_32(&pDb->numOfSuperTables, -1);
|
||||||
|
}
|
||||||
|
void mgmtAddTableIntoDb(SDbObj *pDb) {
|
||||||
|
atomic_add_fetch_32(&pDb->numOfTables, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void mgmtRemoveTableFromDb(SDbObj *pDb) {
|
||||||
|
atomic_add_fetch_32(&pDb->numOfTables, -1);
|
||||||
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
void mgmtProcessMsgFromDnode(int8_t *pCont, int32_t contLen, int32_t msgType, void *pConn);
|
void mgmtProcessMsgFromDnode(int8_t *pCont, int32_t contLen, int32_t msgType, void *pConn);
|
||||||
int mgmtSendVPeersMsg(SVgObj *pVgroup);
|
int mgmtSendVPeersMsg(SVgObj *pVgroup);
|
||||||
char *mgmtBuildVpeersIe(char *pMsg, SVgObj *pVgroup, int vnode);
|
char *mgmtBuildVpeersIe(char *pMsg, SVgObj *pVgroup, int vnode);
|
||||||
char *mgmtBuildCreateMeterIe(STabObj *pTable, char *pMsg, int vnode);
|
//char *mgmtBuildCreateMeterIe(STabObj *pTable, char *pMsg, int vnode);
|
||||||
extern void *tsDnodeMgmtQhandle;
|
extern void *tsDnodeMgmtQhandle;
|
||||||
void * mgmtStatusTimer = NULL;
|
void * mgmtStatusTimer = NULL;
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ int mgmtSendRemoveMeterMsgToDnode(STableInfo *pTable, SVgObj *pVgroup) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mgmtSendAlterStreamMsgToDnode(STabObj *pTable, SVgObj *pVgroup) {
|
int mgmtSendAlterStreamMsgToDnode(void *pTable, SVgObj *pVgroup) {
|
||||||
// SAlterStreamMsg *pAlter;
|
// SAlterStreamMsg *pAlter;
|
||||||
// char * pMsg, *pStart;
|
// char * pMsg, *pStart;
|
||||||
// int i, msgLen = 0;
|
// int i, msgLen = 0;
|
||||||
|
|
|
@ -236,6 +236,7 @@ int32_t mgmtInitNormalTables() {
|
||||||
pNode = pLastNode;
|
pNode = pLastNode;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
mgmtAddTableIntoDb(pDb);
|
||||||
}
|
}
|
||||||
|
|
||||||
mgmtSetVgroupIdPool();
|
mgmtSetVgroupIdPool();
|
||||||
|
@ -326,6 +327,7 @@ int32_t mgmtCreateNormalTable(SDbObj *pDb, SCreateTableMsg *pCreate, SVgObj *pVg
|
||||||
" db:%s",
|
" db:%s",
|
||||||
pTable->tableId, pVgroup->vgId, sid, pVgroup->vnodeGid[0].vnode, pTable->uid, pDb->name);
|
pTable->tableId, pVgroup->vgId, sid, pVgroup->vnodeGid[0].vnode, pTable->uid, pDb->name);
|
||||||
|
|
||||||
|
mgmtAddTableIntoDb(pDb);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,6 +356,7 @@ int32_t mgmtDropNormalTable(SDbObj *pDb, SNormalTableObj *pTable) {
|
||||||
mgmtDropVgroup(pDb, pVgroup);
|
mgmtDropVgroup(pDb, pVgroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mgmtRemoveTableFromDb(pDb);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -688,7 +688,7 @@ int32_t mgmtProcessShowMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
SShowObj *pShow = (SShowObj *) calloc(1, sizeof(SShowObj) + htons(pShowMsg->payloadLen));
|
SShowObj *pShow = (SShowObj *) calloc(1, sizeof(SShowObj) + htons(pShowMsg->payloadLen));
|
||||||
pShow->signature = pShow;
|
pShow->signature = pShow;
|
||||||
pShow->type = pShowMsg->type;
|
pShow->type = pShowMsg->type;
|
||||||
strcpy(pShow->db, pShow->db);
|
strcpy(pShow->db, pShowMsg->db);
|
||||||
mTrace("pShow:%p is allocated", pShow);
|
mTrace("pShow:%p is allocated", pShow);
|
||||||
|
|
||||||
// set the table name query condition
|
// set the table name query condition
|
||||||
|
@ -805,20 +805,12 @@ int32_t mgmtProcessCreateTableMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
SDbObj *pDb = mgmtGetDb(pCreate->db);
|
SDbObj *pDb = mgmtGetDb(pCreate->db);
|
||||||
if (pDb) {
|
if (pDb) {
|
||||||
code = mgmtCreateTable(pDb, pCreate);
|
code = mgmtCreateTable(pDb, pCreate);
|
||||||
if (code == TSDB_CODE_TABLE_ALREADY_EXIST) {
|
|
||||||
if (pCreate->igExists) {
|
|
||||||
code = TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
code = TSDB_CODE_DB_NOT_SELECTED;
|
code = TSDB_CODE_DB_NOT_SELECTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
rpcSendResponse(ahandle, code, NULL, 0);
|
||||||
rpcSendResponse(ahandle, TSDB_CODE_SUCCESS, NULL, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -190,7 +190,7 @@ void *mgmtStreamTableActionDecode(void *row, char *str, int32_t size, int32_t *s
|
||||||
if (pTable == NULL) {
|
if (pTable == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memset(pTable, 0, sizeof(STabObj));
|
memset(pTable, 0, sizeof(SStreamTableObj));
|
||||||
|
|
||||||
int32_t tsize = pTable->updateEnd - (int8_t *)pTable;
|
int32_t tsize = pTable->updateEnd - (int8_t *)pTable;
|
||||||
if (size < tsize) {
|
if (size < tsize) {
|
||||||
|
@ -251,6 +251,7 @@ int32_t mgmtInitStreamTables() {
|
||||||
pNode = pLastNode;
|
pNode = pLastNode;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
mgmtAddTableIntoDb(pDb);
|
||||||
}
|
}
|
||||||
|
|
||||||
mgmtSetVgroupIdPool();
|
mgmtSetVgroupIdPool();
|
||||||
|
@ -348,6 +349,7 @@ int32_t mgmtCreateStreamTable(SDbObj *pDb, SCreateTableMsg *pCreate, SVgObj *pVg
|
||||||
" db:%s",
|
" db:%s",
|
||||||
pTable->tableId, pVgroup->vgId, sid, pVgroup->vnodeGid[0].vnode, pTable->uid, pDb->name);
|
pTable->tableId, pVgroup->vgId, sid, pVgroup->vnodeGid[0].vnode, pTable->uid, pDb->name);
|
||||||
|
|
||||||
|
mgmtAddTableIntoDb(pDb);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,6 +378,7 @@ int32_t mgmtDropStreamTable(SDbObj *pDb, SStreamTableObj *pTable) {
|
||||||
mgmtDropVgroup(pDb, pVgroup);
|
mgmtDropVgroup(pDb, pVgroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mgmtRemoveTableFromDb(pDb);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,11 @@
|
||||||
#include "mgmtGrant.h"
|
#include "mgmtGrant.h"
|
||||||
#include "mgmtSuperTable.h"
|
#include "mgmtSuperTable.h"
|
||||||
#include "mgmtTable.h"
|
#include "mgmtTable.h"
|
||||||
|
#include "mgmtUser.h"
|
||||||
#include "mgmtVgroup.h"
|
#include "mgmtVgroup.h"
|
||||||
|
|
||||||
void *tsSuperTableSdb;
|
void *tsSuperTableSdb;
|
||||||
|
int32_t tsSuperTableUpdateSize;
|
||||||
void *(*mgmtSuperTableActionFp[SDB_MAX_ACTION_TYPES])(void *row, char *str, int32_t size, int32_t *ssize);
|
void *(*mgmtSuperTableActionFp[SDB_MAX_ACTION_TYPES])(void *row, char *str, int32_t size, int32_t *ssize);
|
||||||
|
|
||||||
void *mgmtSuperTableActionInsert(void *row, char *str, int32_t size, int32_t *ssize);
|
void *mgmtSuperTableActionInsert(void *row, char *str, int32_t size, int32_t *ssize);
|
||||||
|
@ -64,12 +66,11 @@ static void mgmtSuperTableActionInit() {
|
||||||
|
|
||||||
void *mgmtSuperTableActionReset(void *row, char *str, int32_t size, int32_t *ssize) {
|
void *mgmtSuperTableActionReset(void *row, char *str, int32_t size, int32_t *ssize) {
|
||||||
SSuperTableObj *pTable = (SSuperTableObj *) row;
|
SSuperTableObj *pTable = (SSuperTableObj *) row;
|
||||||
int32_t tsize = pTable->updateEnd - (int8_t *) pTable;
|
memcpy(pTable, str, tsDbUpdateSize);
|
||||||
memcpy(pTable, str, tsize);
|
|
||||||
|
|
||||||
int32_t schemaSize = sizeof(SSchema) * (pTable->numOfColumns + pTable->numOfTags);
|
int32_t schemaSize = sizeof(SSchema) * (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 + tsDbUpdateSize, schemaSize);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -96,17 +97,16 @@ void *mgmtSuperTableActionEncode(void *row, char *str, int32_t size, int32_t *ss
|
||||||
SSuperTableObj *pTable = (SSuperTableObj *) row;
|
SSuperTableObj *pTable = (SSuperTableObj *) row;
|
||||||
assert(row != NULL && str != NULL);
|
assert(row != NULL && str != NULL);
|
||||||
|
|
||||||
int32_t tsize = pTable->updateEnd - (int8_t *) pTable;
|
|
||||||
int32_t schemaSize = sizeof(SSchema) * (pTable->numOfColumns + pTable->numOfTags);
|
int32_t schemaSize = sizeof(SSchema) * (pTable->numOfColumns + pTable->numOfTags);
|
||||||
|
|
||||||
if (size < tsize + schemaSize + 1) {
|
if (size < tsSuperTableUpdateSize + schemaSize + 1) {
|
||||||
*ssize = -1;
|
*ssize = -1;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(str, pTable, tsize);
|
memcpy(str, pTable, tsSuperTableUpdateSize);
|
||||||
memcpy(str + tsize, pTable->schema, schemaSize);
|
memcpy(str + tsSuperTableUpdateSize, pTable->schema, schemaSize);
|
||||||
*ssize = tsize + schemaSize;
|
*ssize = tsSuperTableUpdateSize + schemaSize;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -118,14 +118,13 @@ void *mgmtSuperTableActionDecode(void *row, char *str, int32_t size, int32_t *ss
|
||||||
if (pTable == NULL) {
|
if (pTable == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memset(pTable, 0, sizeof(STabObj));
|
memset(pTable, 0, sizeof(SSuperTableObj));
|
||||||
|
|
||||||
int32_t tsize = pTable->updateEnd - (int8_t *)pTable;
|
if (size < tsSuperTableUpdateSize) {
|
||||||
if (size < tsize) {
|
|
||||||
mgmtDestroySuperTable(pTable);
|
mgmtDestroySuperTable(pTable);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memcpy(pTable, str, tsize);
|
memcpy(pTable, str, tsSuperTableUpdateSize);
|
||||||
|
|
||||||
int32_t schemaSize = sizeof(SSchema) * (pTable->numOfColumns + pTable->numOfTags);
|
int32_t schemaSize = sizeof(SSchema) * (pTable->numOfColumns + pTable->numOfTags);
|
||||||
pTable->schema = malloc(schemaSize);
|
pTable->schema = malloc(schemaSize);
|
||||||
|
@ -134,7 +133,7 @@ void *mgmtSuperTableActionDecode(void *row, char *str, int32_t size, int32_t *ss
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(pTable->schema, str + tsize, schemaSize);
|
memcpy(pTable->schema, str + tsSuperTableUpdateSize, schemaSize);
|
||||||
return (void *)pTable;
|
return (void *)pTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,8 +150,10 @@ int32_t mgmtInitSuperTables() {
|
||||||
SSuperTableObj * pTable = NULL;
|
SSuperTableObj * pTable = NULL;
|
||||||
|
|
||||||
mgmtSuperTableActionInit();
|
mgmtSuperTableActionInit();
|
||||||
|
SSuperTableObj tObj;
|
||||||
|
tsSuperTableUpdateSize = tObj.updateEnd - (int8_t *)&tObj;
|
||||||
|
|
||||||
tsSuperTableSdb = sdbOpenTable(tsMaxTables, sizeof(STabObj) + sizeof(SSchema) * TSDB_MAX_COLUMNS,
|
tsSuperTableSdb = sdbOpenTable(tsMaxTables, tsSuperTableUpdateSize + sizeof(SSchema) * 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");
|
||||||
|
@ -173,7 +174,8 @@ int32_t mgmtInitSuperTables() {
|
||||||
pNode = pLastNode;
|
pNode = pLastNode;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pTable->numOfTables = 0;
|
|
||||||
|
mgmtAddSuperTableIntoDb(pDb);
|
||||||
}
|
}
|
||||||
|
|
||||||
mgmtSetVgroupIdPool();
|
mgmtSetVgroupIdPool();
|
||||||
|
@ -183,6 +185,7 @@ int32_t mgmtInitSuperTables() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void mgmtCleanUpSuperTables() {
|
void mgmtCleanUpSuperTables() {
|
||||||
|
sdbCloseTable(tsSuperTableSdb);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtCreateSuperTable(SDbObj *pDb, SCreateTableMsg *pCreate) {
|
int32_t mgmtCreateSuperTable(SDbObj *pDb, SCreateTableMsg *pCreate) {
|
||||||
|
@ -205,7 +208,6 @@ int32_t mgmtCreateSuperTable(SDbObj *pDb, SCreateTableMsg *pCreate) {
|
||||||
pStable->sversion = 0;
|
pStable->sversion = 0;
|
||||||
pStable->numOfColumns = pCreate->numOfColumns;
|
pStable->numOfColumns = pCreate->numOfColumns;
|
||||||
pStable->numOfTags = pCreate->numOfTags;
|
pStable->numOfTags = pCreate->numOfTags;
|
||||||
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(SSchema);
|
||||||
|
@ -228,11 +230,14 @@ int32_t mgmtCreateSuperTable(SDbObj *pDb, SCreateTableMsg *pCreate) {
|
||||||
return TSDB_CODE_SDB_ERROR;
|
return TSDB_CODE_SDB_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
mgmtAddSuperTableIntoDb(pDb);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtDropSuperTable(SDbObj *pDb, SSuperTableObj *pSuperTable) {
|
int32_t mgmtDropSuperTable(SDbObj *pDb, SSuperTableObj *pSuperTable) {
|
||||||
//TODO drop all child tables
|
//TODO drop all child tables
|
||||||
|
|
||||||
|
mgmtRemoveSuperTableFromDb(pDb);
|
||||||
return sdbDeleteRow(tsSuperTableSdb, pSuperTable);
|
return sdbDeleteRow(tsSuperTableSdb, pSuperTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,6 +246,7 @@ void* mgmtGetSuperTable(char *tableId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void *mgmtGetSuperTableVgroup(SSuperTableObj *pStable) {
|
void *mgmtGetSuperTableVgroup(SSuperTableObj *pStable) {
|
||||||
|
//TODO get vgroup of dnodes
|
||||||
SSuperTableInfoRsp *rsp = rpcMallocCont(sizeof(SSuperTableInfoRsp) + sizeof(uint32_t) * mgmtGetDnodesNum());
|
SSuperTableInfoRsp *rsp = rpcMallocCont(sizeof(SSuperTableInfoRsp) + sizeof(uint32_t) * mgmtGetDnodesNum());
|
||||||
rsp->numOfDnodes = 1;
|
rsp->numOfDnodes = 1;
|
||||||
rsp->dnodeIps[0] = 0;
|
rsp->dnodeIps[0] = 0;
|
||||||
|
@ -358,7 +364,7 @@ int32_t mgmtModifySuperTableTagNameByName(SSuperTableObj *pStable, char *oldTagN
|
||||||
strncpy(schema->name, newTagName, TSDB_COL_NAME_LEN);
|
strncpy(schema->name, newTagName, TSDB_COL_NAME_LEN);
|
||||||
|
|
||||||
// Encode string
|
// Encode string
|
||||||
int32_t size = 1 + sizeof(STabObj) + TSDB_MAX_BYTES_PER_ROW;
|
int32_t size = 1 + sizeof(SSuperTableObj) + TSDB_MAX_BYTES_PER_ROW;
|
||||||
char *msg = (char *) malloc(size);
|
char *msg = (char *) malloc(size);
|
||||||
if (msg == NULL) return TSDB_CODE_APP_ERROR;
|
if (msg == NULL) return TSDB_CODE_APP_ERROR;
|
||||||
memset(msg, 0, size);
|
memset(msg, 0, size);
|
||||||
|
@ -466,129 +472,122 @@ int32_t mgmtDropSuperTableColumnByName(SSuperTableObj *pStable, char *colName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtGetShowSuperTableMeta(STableMeta *pMeta, SShowObj *pShow, void *pConn) {
|
int32_t mgmtGetShowSuperTableMeta(STableMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
// int32_t cols = 0;
|
SDbObj *pDb = mgmtGetDb(pShow->db);
|
||||||
//
|
if (pDb == NULL) {
|
||||||
// SDbObj *pDb = NULL;
|
return TSDB_CODE_DB_NOT_SELECTED;
|
||||||
// if (pConn->pDb != NULL) pDb = mgmtGetDb(pConn->pDb->name);
|
}
|
||||||
//
|
|
||||||
// if (pDb == NULL) return TSDB_CODE_DB_NOT_SELECTED;
|
int32_t cols = 0;
|
||||||
//
|
SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
// SSchema *pSchema = tsGetSchema(pMeta);
|
|
||||||
//
|
pShow->bytes[cols] = TSDB_TABLE_NAME_LEN;
|
||||||
// pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
strcpy(pSchema[cols].name, "name");
|
||||||
// strcpy(pSchema[cols].name, "name");
|
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
cols++;
|
||||||
// cols++;
|
|
||||||
//
|
pShow->bytes[cols] = 8;
|
||||||
// pShow->bytes[cols] = 8;
|
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||||
// pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
strcpy(pSchema[cols].name, "created_time");
|
||||||
// strcpy(pSchema[cols].name, "created_time");
|
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
cols++;
|
||||||
// cols++;
|
|
||||||
//
|
pShow->bytes[cols] = 2;
|
||||||
// pShow->bytes[cols] = 2;
|
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||||
// pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
strcpy(pSchema[cols].name, "columns");
|
||||||
// strcpy(pSchema[cols].name, "columns");
|
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
cols++;
|
||||||
// cols++;
|
|
||||||
//
|
pShow->bytes[cols] = 2;
|
||||||
// pShow->bytes[cols] = 2;
|
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||||
// pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
strcpy(pSchema[cols].name, "tags");
|
||||||
// strcpy(pSchema[cols].name, "tags");
|
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
cols++;
|
||||||
// cols++;
|
|
||||||
//
|
pShow->bytes[cols] = 4;
|
||||||
// pShow->bytes[cols] = 4;
|
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||||
// pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
strcpy(pSchema[cols].name, "tables");
|
||||||
// strcpy(pSchema[cols].name, "tables");
|
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
cols++;
|
||||||
// cols++;
|
|
||||||
//
|
pMeta->numOfColumns = htons(cols);
|
||||||
// pMeta->numOfColumns = htons(cols);
|
pShow->numOfColumns = cols;
|
||||||
// pShow->numOfColumns = cols;
|
|
||||||
//
|
pShow->offset[0] = 0;
|
||||||
// pShow->offset[0] = 0;
|
for (int32_t i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
||||||
// for (int32_t i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
|
||||||
//
|
pShow->numOfRows = pDb->numOfSuperTables;
|
||||||
// pShow->numOfRows = pDb->numOfMetrics;
|
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
||||||
// pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
int32_t mgmtRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
// char * pWrite;
|
char * pWrite;
|
||||||
// int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
// SSuperTableObj *pTable = NULL;
|
SSuperTableObj *pTable = NULL;
|
||||||
// char prefix[20] = {0};
|
char prefix[20] = {0};
|
||||||
// int32_t prefixLen;
|
int32_t prefixLen;
|
||||||
//
|
|
||||||
// SDbObj *pDb = NULL;
|
SDbObj *pDb = mgmtGetDb(pShow->db);
|
||||||
// if (pConn->pDb != NULL) {
|
if (pDb == NULL) return 0;
|
||||||
// pDb = mgmtGetDb(pConn->pDb->name);
|
|
||||||
// }
|
SUserObj *pUser = mgmtGetUserFromConn(pConn);
|
||||||
//
|
|
||||||
// if (pDb == NULL) {
|
if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) {
|
||||||
// return 0;
|
if (strcmp(pUser->user, "root") != 0 && strcmp(pUser->user, "_root") != 0 && strcmp(pUser->user, "monitor") != 0 ) {
|
||||||
// }
|
return 0;
|
||||||
//
|
}
|
||||||
// if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) {
|
}
|
||||||
// if (strcmp(pConn->pUser->user, "root") != 0 && strcmp(pConn->pUser->user, "_root") != 0 && strcmp(pConn->pUser->user, "monitor") != 0 ) {
|
|
||||||
// return 0;
|
strcpy(prefix, pDb->name);
|
||||||
// }
|
strcat(prefix, TS_PATH_DELIMITER);
|
||||||
// }
|
prefixLen = strlen(prefix);
|
||||||
//
|
|
||||||
// strcpy(prefix, pDb->name);
|
SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
|
||||||
// strcat(prefix, TS_PATH_DELIMITER);
|
char stableName[TSDB_TABLE_NAME_LEN] = {0};
|
||||||
// prefixLen = strlen(prefix);
|
|
||||||
//
|
while (numOfRows < rows) {
|
||||||
// SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
|
pShow->pNode = sdbFetchRow(tsSuperTableSdb, pShow->pNode, (void **) &pTable);
|
||||||
// char metricName[TSDB_METER_NAME_LEN] = {0};
|
if (pTable == NULL) break;
|
||||||
//
|
if (strncmp(pTable->tableId, prefix, prefixLen)) {
|
||||||
// while (numOfRows < rows) {
|
continue;
|
||||||
// pTable = (SSuperTableObj *)pShow->pNode;
|
}
|
||||||
// if (pTable == NULL) break;
|
|
||||||
// //pShow->pNode = (void *)pTable->next;
|
memset(stableName, 0, tListLen(stableName));
|
||||||
//
|
extractTableName(pTable->tableId, stableName);
|
||||||
// if (strncmp(pTable->tableId, prefix, prefixLen)) {
|
|
||||||
// continue;
|
if (pShow->payloadLen > 0 &&
|
||||||
// }
|
patternMatch(pShow->payload, stableName, TSDB_TABLE_NAME_LEN, &info) != TSDB_PATTERN_MATCH)
|
||||||
//
|
continue;
|
||||||
// memset(metricName, 0, tListLen(metricName));
|
|
||||||
// extractTableName(pTable->tableId, metricName);
|
cols = 0;
|
||||||
//
|
|
||||||
// if (pShow->payloadLen > 0 &&
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
// patternMatch(pShow->payload, metricName, TSDB_METER_NAME_LEN, &info) != TSDB_PATTERN_MATCH)
|
strncpy(pWrite, stableName, TSDB_TABLE_NAME_LEN);
|
||||||
// continue;
|
cols++;
|
||||||
//
|
|
||||||
// cols = 0;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
//
|
*(int64_t *)pWrite = pTable->createdTime;
|
||||||
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
cols++;
|
||||||
// extractTableName(pTable->tableId, pWrite);
|
|
||||||
// cols++;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
//
|
*(int16_t *)pWrite = pTable->numOfColumns;
|
||||||
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
cols++;
|
||||||
// *(int64_t *)pWrite = pTable->createdTime;
|
|
||||||
// cols++;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
//
|
*(int16_t *)pWrite = pTable->numOfTags;
|
||||||
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
cols++;
|
||||||
// *(int16_t *)pWrite = pTable->numOfColumns;
|
|
||||||
// cols++;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
//
|
*(int32_t *)pWrite = pTable->numOfTables;
|
||||||
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
cols++;
|
||||||
// *(int16_t *)pWrite = pTable->numOfTags;
|
|
||||||
// cols++;
|
numOfRows++;
|
||||||
//
|
}
|
||||||
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
|
||||||
// *(int32_t *)pWrite = pTable->numOfTables;
|
pShow->numOfReads += numOfRows;
|
||||||
// cols++;
|
|
||||||
//
|
|
||||||
// numOfRows++;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// pShow->numOfReads += numOfRows;
|
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -248,53 +248,48 @@ void mgmtCleanUpMeters() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtGetShowTableMeta(STableMeta *pMeta, SShowObj *pShow, void *pConn) {
|
int32_t mgmtGetShowTableMeta(STableMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
// int32_t cols = 0;
|
SDbObj *pDb = mgmtGetDb(pShow->db);
|
||||||
//
|
if (pDb == NULL) {
|
||||||
// SDbObj *pDb = NULL;
|
return TSDB_CODE_DB_NOT_SELECTED;
|
||||||
// if (pConn->pDb != NULL) {
|
}
|
||||||
// pDb = mgmtGetDb(pConn->pDb->name);
|
|
||||||
// }
|
int32_t cols = 0;
|
||||||
//
|
SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
// if (pDb == NULL) {
|
|
||||||
// return TSDB_CODE_DB_NOT_SELECTED;
|
pShow->bytes[cols] = TSDB_TABLE_NAME_LEN;
|
||||||
// }
|
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
//
|
strcpy(pSchema[cols].name, "table_name");
|
||||||
// SSchema *pSchema = tsGetSchema(pMeta);
|
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
//
|
cols++;
|
||||||
// pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
|
||||||
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
pShow->bytes[cols] = 8;
|
||||||
// strcpy(pSchema[cols].name, "table_name");
|
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||||
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
strcpy(pSchema[cols].name, "created_time");
|
||||||
// cols++;
|
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
//
|
cols++;
|
||||||
// pShow->bytes[cols] = 8;
|
|
||||||
// pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
pShow->bytes[cols] = 2;
|
||||||
// strcpy(pSchema[cols].name, "created_time");
|
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||||
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
strcpy(pSchema[cols].name, "columns");
|
||||||
// cols++;
|
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
//
|
cols++;
|
||||||
// pShow->bytes[cols] = 2;
|
|
||||||
// pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
pShow->bytes[cols] = TSDB_TABLE_NAME_LEN;
|
||||||
// strcpy(pSchema[cols].name, "columns");
|
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
strcpy(pSchema[cols].name, "stable");
|
||||||
// cols++;
|
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
//
|
cols++;
|
||||||
// pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
|
||||||
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
pMeta->numOfColumns = htons(cols);
|
||||||
// strcpy(pSchema[cols].name, "stable");
|
pShow->numOfColumns = cols;
|
||||||
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
|
||||||
// cols++;
|
pShow->offset[0] = 0;
|
||||||
//
|
for (int32_t i = 1; i < cols; ++i) {
|
||||||
// pMeta->numOfColumns = htons(cols);
|
pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
||||||
// pShow->numOfColumns = cols;
|
}
|
||||||
//
|
|
||||||
// pShow->offset[0] = 0;
|
pShow->numOfRows = pDb->numOfTables;
|
||||||
// for (int32_t i = 1; i < cols; ++i) {
|
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
||||||
// pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// pShow->numOfRows = pDb->numOfTables;
|
|
||||||
// pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -382,7 +377,7 @@ int32_t mgmtRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows, void *
|
||||||
// continue;
|
// continue;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// char meterName[TSDB_METER_NAME_LEN] = {0};
|
// char meterName[TSDB_TABLE_NAME_LEN] = {0};
|
||||||
// memset(meterName, 0, tListLen(meterName));
|
// memset(meterName, 0, tListLen(meterName));
|
||||||
// numOfRead++;
|
// numOfRead++;
|
||||||
//
|
//
|
||||||
|
@ -390,14 +385,14 @@ int32_t mgmtRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows, void *
|
||||||
// extractTableName(tableId, meterName);
|
// extractTableName(tableId, meterName);
|
||||||
//
|
//
|
||||||
// if (pShow->payloadLen > 0 &&
|
// if (pShow->payloadLen > 0 &&
|
||||||
// patternMatch(pShow->payload, meterName, TSDB_METER_NAME_LEN, &info) != TSDB_PATTERN_MATCH) {
|
// patternMatch(pShow->payload, meterName, TSDB_TABLE_NAME_LEN, &info) != TSDB_PATTERN_MATCH) {
|
||||||
// continue;
|
// continue;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// cols = 0;
|
// cols = 0;
|
||||||
//
|
//
|
||||||
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
// strncpy(pWrite, meterName, TSDB_METER_NAME_LEN);
|
// strncpy(pWrite, meterName, TSDB_TABLE_NAME_LEN);
|
||||||
// cols++;
|
// cols++;
|
||||||
//
|
//
|
||||||
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
|
|
|
@ -312,7 +312,7 @@ void httpTrimTableName(char *name) {
|
||||||
for (int i = 0; name[i] != 0; i++) {
|
for (int i = 0; name[i] != 0; i++) {
|
||||||
if (name[i] == ' ' || name[i] == ':' || name[i] == '.' || name[i] == '-' || name[i] == '/' || name[i] == '\'')
|
if (name[i] == ' ' || name[i] == ':' || name[i] == '.' || name[i] == '-' || name[i] == '/' || name[i] == '\'')
|
||||||
name[i] = '_';
|
name[i] = '_';
|
||||||
if (i == TSDB_METER_NAME_LEN + 1) {
|
if (i == TSDB_TABLE_NAME_LEN + 1) {
|
||||||
name[i] = 0;
|
name[i] = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -328,7 +328,7 @@ int httpShrinkTableName(HttpContext *pContext, int pos, char *name) {
|
||||||
len++;
|
len++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len < TSDB_METER_NAME_LEN) {
|
if (len < TSDB_TABLE_NAME_LEN) {
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,7 @@ void tgParseSchemaMetric(cJSON *metric) {
|
||||||
goto ParseEnd;
|
goto ParseEnd;
|
||||||
}
|
}
|
||||||
int nameLen = (int)strlen(field->valuestring);
|
int nameLen = (int)strlen(field->valuestring);
|
||||||
if (nameLen == 0 || nameLen > TSDB_METER_NAME_LEN) {
|
if (nameLen == 0 || nameLen > TSDB_TABLE_NAME_LEN) {
|
||||||
parsedOk = false;
|
parsedOk = false;
|
||||||
goto ParseEnd;
|
goto ParseEnd;
|
||||||
}
|
}
|
||||||
|
@ -395,7 +395,7 @@ bool tgProcessSingleMetric(HttpContext *pContext, cJSON *metric, char *db) {
|
||||||
httpSendErrorResp(pContext, HTTP_TG_METRIC_NAME_NULL);
|
httpSendErrorResp(pContext, HTTP_TG_METRIC_NAME_NULL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (nameLen >= TSDB_METER_NAME_LEN - 7) {
|
if (nameLen >= TSDB_TABLE_NAME_LEN - 7) {
|
||||||
httpSendErrorResp(pContext, HTTP_TG_METRIC_NAME_LONG);
|
httpSendErrorResp(pContext, HTTP_TG_METRIC_NAME_LONG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -484,7 +484,7 @@ bool tgProcessSingleMetric(HttpContext *pContext, cJSON *metric, char *db) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(host->valuestring) >= TSDB_METER_NAME_LEN) {
|
if (strlen(host->valuestring) >= TSDB_TABLE_NAME_LEN) {
|
||||||
httpSendErrorResp(pContext, HTTP_TG_TABLE_SIZE);
|
httpSendErrorResp(pContext, HTTP_TG_TABLE_SIZE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ extern uint32_t cdebugFlag;
|
||||||
|
|
||||||
#define tscError(...) \
|
#define tscError(...) \
|
||||||
if (cdebugFlag & DEBUG_ERROR) { \
|
if (cdebugFlag & DEBUG_ERROR) { \
|
||||||
tprintf("ERROR TSC ", cdebugFlag, __VA_ARGS__); \
|
tprintf("ERROR TSC ", 255, __VA_ARGS__); \
|
||||||
}
|
}
|
||||||
#define tscWarn(...) \
|
#define tscWarn(...) \
|
||||||
if (cdebugFlag & DEBUG_WARN) { \
|
if (cdebugFlag & DEBUG_WARN) { \
|
||||||
|
|
Loading…
Reference in New Issue