feature/qnode
This commit is contained in:
parent
5a383152c4
commit
bf4efa77cb
|
@ -111,7 +111,9 @@ int32_t tNameExtractFullName(const SName* name, char* dst) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
int32_t len = snprintf(dst, TSDB_DB_FNAME_LEN, "%d.%s", name->acctId, name->dbname);
|
||||
int32_t len = 0;
|
||||
|
||||
snprintf(dst, TSDB_DB_FNAME_LEN, "%d.%s", name->acctId, name->dbname);
|
||||
|
||||
size_t tnameLen = strlen(name->tname);
|
||||
if (tnameLen > 0) {
|
||||
|
|
|
@ -937,7 +937,8 @@ static int32_t mndProcessUseDbReq(SMnodeMsg *pReq) {
|
|||
goto USE_DB_OVER;
|
||||
}
|
||||
|
||||
if (0 == strcmp(usedbReq.db, TSDB_INFORMATION_SCHEMA_DB)) {
|
||||
char *p = strchr(usedbReq.db, '.');
|
||||
if (p && 0 == strcmp(p + 1, TSDB_INFORMATION_SCHEMA_DB)) {
|
||||
memcpy(usedbRsp.db, usedbReq.db, TSDB_DB_FNAME_LEN);
|
||||
} else {
|
||||
pDb = mndAcquireDb(pMnode, usedbReq.db);
|
||||
|
|
|
@ -28,100 +28,100 @@ static const SInfosTableSchema dnodesSchema[] = {{.name = "id", .byt
|
|||
static const SInfosTableSchema mnodesSchema[] = {{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "end_point", .bytes = 134, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "role", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "role_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "role_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
};
|
||||
static const SInfosTableSchema modulesSchema[] = {{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "end_point", .bytes = 134, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "module", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "end_point", .bytes = 134, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "module", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
||||
};
|
||||
static const SInfosTableSchema qnodesSchema[] = {{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "end_point", .bytes = 134, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
};
|
||||
static const SInfosTableSchema userDBSchema[] = {{.name = "name", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "created_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "ntables", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "vgroups", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "replica", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "quorum", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "days", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "keep", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "cache", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "blocks", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "minrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "maxrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "wallevel", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "fsync", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "comp", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "cachelast", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "precision", .bytes = 2, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "created_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "ntables", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "vgroups", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "replica", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "quorum", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "days", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "keep", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "cache", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "blocks", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "minrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "maxrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "wallevel", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "fsync", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "comp", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "cachelast", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "precision", .bytes = 2, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
||||
};
|
||||
static const SInfosTableSchema userFuncSchema[] = {{.name = "name", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "created_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "ntables", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "precision", .bytes = 2, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
||||
static const SInfosTableSchema userFuncSchema[] = {{.name = "name", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "created_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "ntables", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "precision", .bytes = 2, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
||||
};
|
||||
static const SInfosTableSchema userIdxSchema[] = {{.name = "table_database", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "table_name", .bytes = 192, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "index_database", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "index_name", .bytes = 192, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "column_name", .bytes = 64, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "index_type", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "index_extensions", .bytes = 256, .type = TSDB_DATA_TYPE_BINARY},
|
||||
static const SInfosTableSchema userIdxSchema[] = {{.name = "table_database", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "table_name", .bytes = 192, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "index_database", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "index_name", .bytes = 192, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "column_name", .bytes = 64, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "index_type", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "index_extensions", .bytes = 256, .type = TSDB_DATA_TYPE_BINARY},
|
||||
};
|
||||
static const SInfosTableSchema userStbsSchema[] = {{.name = "db_name", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "stable_name", .bytes = 192, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "created_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "columns", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "tags", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "tables", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
static const SInfosTableSchema userStbsSchema[] = {{.name = "db_name", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "stable_name", .bytes = 192, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "created_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "columns", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "tags", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "tables", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
};
|
||||
static const SInfosTableSchema userStreamsSchema[] = {{.name = "stream_name", .bytes = 192, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "user_name", .bytes = 23, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "dest_table", .bytes = 192, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "created_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "sql", .bytes = 1024, .type = TSDB_DATA_TYPE_BINARY},
|
||||
static const SInfosTableSchema userStreamsSchema[] = {{.name = "stream_name", .bytes = 192, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "user_name", .bytes = 23, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "dest_table", .bytes = 192, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "created_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "sql", .bytes = 1024, .type = TSDB_DATA_TYPE_BINARY},
|
||||
};
|
||||
static const SInfosTableSchema userTblsSchema[] = {{.name = "db_name", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "table_name", .bytes = 192, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "created_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "columns", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "stable_name", .bytes = 192, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "tid", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "vg_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
static const SInfosTableSchema userTblsSchema[] = {{.name = "db_name", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "table_name", .bytes = 192, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "created_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "columns", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "stable_name", .bytes = 192, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "tid", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "vg_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
};
|
||||
static const SInfosTableSchema userTblDistSchema[] = {{.name = "db_name", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "table_name", .bytes = 192, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "distributed_histogram", .bytes = 500, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "min_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "max_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "avg_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "stddev_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "rows", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "blocks", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "storage_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "compression_ratio", .bytes = 8, .type = TSDB_DATA_TYPE_DOUBLE},
|
||||
{.name = "rows_in_mem", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "seek_header_time", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
static const SInfosTableSchema userTblDistSchema[] = {{.name = "db_name", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "table_name", .bytes = 192, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "distributed_histogram", .bytes = 500, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "min_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "max_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "avg_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "stddev_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "rows", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "blocks", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "storage_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "compression_ratio", .bytes = 8, .type = TSDB_DATA_TYPE_DOUBLE},
|
||||
{.name = "rows_in_mem", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "seek_header_time", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
};
|
||||
static const SInfosTableSchema userUsersSchema[] = {{.name = "user_name", .bytes = 23, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "privilege", .bytes = 256, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
static const SInfosTableSchema userUsersSchema[] = {{.name = "user_name", .bytes = 23, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "privilege", .bytes = 256, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
};
|
||||
static const SInfosTableSchema vgroupsSchema[] = {{.name = "vg_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "tables", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "onlines", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "v1_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "v1_status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "v2_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "v2_status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "v3_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "v3_status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "compacting", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
static const SInfosTableSchema vgroupsSchema[] = {{.name = "vg_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "tables", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "onlines", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "v1_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "v1_status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "v2_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "v2_status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "v3_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "v3_status", .bytes = 10, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "compacting", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
};
|
||||
|
||||
static const SInfosTableMeta infosMeta[] = {{TSDB_INS_TABLE_DNODES, dnodesSchema, tListLen(dnodesSchema)},
|
||||
|
@ -149,13 +149,11 @@ int32_t mndInitInfosTableSchema(const SInfosTableSchema *pSrc, int32_t colNum, S
|
|||
|
||||
|
||||
for (int32_t i = 0; i < colNum; ++i) {
|
||||
strcpy(schema->name, pSrc->name);
|
||||
strcpy(schema[i].name, pSrc[i].name);
|
||||
|
||||
schema->type = pSrc->type;
|
||||
schema->colId = i + 1;
|
||||
schema->bytes = pSrc->bytes;
|
||||
|
||||
pSrc++;
|
||||
schema[i].type = pSrc[i].type;
|
||||
schema[i].colId = i + 1;
|
||||
schema[i].bytes = pSrc[i].bytes;
|
||||
}
|
||||
|
||||
*pDst = schema;
|
||||
|
|
|
@ -198,11 +198,12 @@ typedef struct SCtgAction {
|
|||
#define CTG_IS_NOT_STB(_flag) ((_flag) & CTG_FLAG_NOT_STB)
|
||||
#define CTG_IS_UNKNOWN_STB(_flag) ((_flag) & CTG_FLAG_UNKNOWN_STB)
|
||||
#define CTG_IS_INF_DB(_flag) ((_flag) & CTG_FLAG_INF_DB)
|
||||
#define CTG_SET_INF_DB(_flag) ((_flag) |= CTG_FLAG_INF_DB)
|
||||
#define CTG_SET_STB(_flag, tbType) do { (_flag) |= ((tbType) == TSDB_SUPER_TABLE) ? CTG_FLAG_STB : ((tbType) > TSDB_SUPER_TABLE ? CTG_FLAG_NOT_STB : CTG_FLAG_UNKNOWN_STB); } while (0)
|
||||
#define CTG_GEN_STB_FLAG(_isStb) ((_isStb) == 1) ? CTG_FLAG_STB : ((_isStb) == 0 ? CTG_FLAG_NOT_STB : CTG_FLAG_UNKNOWN_STB)
|
||||
#define CTG_TBTYPE_MATCH(_flag, tbType) (CTG_IS_UNKNOWN_STB(_flag) || (CTG_IS_STB(_flag) && (tbType) == TSDB_SUPER_TABLE) || (CTG_IS_NOT_STB(_flag) && (tbType) != TSDB_SUPER_TABLE))
|
||||
|
||||
#define CTG_IS_INF_DBNAME(_sname) ((_sname)->dbname[0] == 'i' && 0 == strcmp((_sname)->dbname, TSDB_INFORMATION_SCHEMA_DB))
|
||||
#define CTG_IS_INF_DBNAME(_dbname) ((*(_dbname) == 'i') && (0 == strcmp(_dbname, TSDB_INFORMATION_SCHEMA_DB)))
|
||||
|
||||
#define CTG_META_SIZE(pMeta) (sizeof(STableMeta) + ((pMeta)->tableInfo.numOfTags + (pMeta)->tableInfo.numOfColumns) * sizeof(SSchema))
|
||||
|
||||
|
|
|
@ -509,7 +509,7 @@ int32_t ctgIsTableMetaExistInCache(SCatalog* pCtg, char *dbFName, char* tbName,
|
|||
}
|
||||
|
||||
|
||||
int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STableMeta** pTableMeta, int32_t *exist) {
|
||||
int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STableMeta** pTableMeta, int32_t *exist, int32_t flag) {
|
||||
if (NULL == pCtg->dbCache) {
|
||||
*exist = 0;
|
||||
ctgWarn("empty tbmeta cache, tbName:%s", pTableName->tname);
|
||||
|
@ -517,7 +517,11 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable
|
|||
}
|
||||
|
||||
char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
||||
tNameGetFullDbName(pTableName, dbFName);
|
||||
if (CTG_IS_INF_DB(flag)) {
|
||||
strcpy(dbFName, pTableName->dbname);
|
||||
} else {
|
||||
tNameGetFullDbName(pTableName, dbFName);
|
||||
}
|
||||
|
||||
*pTableMeta = NULL;
|
||||
|
||||
|
@ -590,15 +594,19 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ctgGetTableTypeFromCache(SCatalog* pCtg, const SName* pTableName, int32_t *tbType) {
|
||||
int32_t ctgGetTableTypeFromCache(SCatalog* pCtg, const SName* pTableName, int32_t *tbType, int32_t flag) {
|
||||
if (NULL == pCtg->dbCache) {
|
||||
ctgWarn("empty db cache, tbName:%s", pTableName->tname);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
||||
tNameGetFullDbName(pTableName, dbFName);
|
||||
|
||||
if (CTG_IS_INF_DB(flag)) {
|
||||
strcpy(dbFName, pTableName->dbname);
|
||||
} else {
|
||||
tNameGetFullDbName(pTableName, dbFName);
|
||||
}
|
||||
|
||||
SCtgDBCache *dbCache = NULL;
|
||||
ctgAcquireDBCache(pCtg, dbFName, &dbCache);
|
||||
if (NULL == dbCache) {
|
||||
|
@ -1078,6 +1086,10 @@ int32_t ctgAddNewDBCache(SCatalog *pCtg, const char *dbFName, uint64_t dbId) {
|
|||
|
||||
ctgDebug("db added to cache, dbFName:%s, dbId:%"PRIx64, dbFName, dbId);
|
||||
|
||||
if (CTG_IS_INF_DBNAME(dbFName)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
CTG_ERR_RET(ctgMetaRentAdd(&pCtg->dbRent, &vgVersion, dbId, sizeof(SDbVgVersion)));
|
||||
|
||||
ctgDebug("db added to rent, dbFName:%s, vgVersion:%d, dbId:%"PRIx64, dbFName, vgVersion.vgVersion, dbId);
|
||||
|
@ -1544,8 +1556,12 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons
|
|||
int32_t exist = 0;
|
||||
int32_t code = 0;
|
||||
|
||||
if ((!forceUpdate) || (CTG_IS_INF_DBNAME(pTableName))) {
|
||||
CTG_ERR_RET(ctgGetTableMetaFromCache(pCtg, pTableName, pTableMeta, &exist));
|
||||
if (CTG_IS_INF_DBNAME(pTableName->dbname)) {
|
||||
CTG_SET_INF_DB(flag);
|
||||
}
|
||||
|
||||
if ((!forceUpdate) || (CTG_IS_INF_DB(flag))) {
|
||||
CTG_ERR_RET(ctgGetTableMetaFromCache(pCtg, pTableName, pTableMeta, &exist, flag));
|
||||
|
||||
if (exist && CTG_TBTYPE_MATCH(flag, (*pTableMeta)->tableType)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -1555,7 +1571,7 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons
|
|||
} else if (CTG_IS_UNKNOWN_STB(flag)) {
|
||||
int32_t tbType = 0;
|
||||
|
||||
CTG_ERR_RET(ctgGetTableTypeFromCache(pCtg, pTableName, &tbType));
|
||||
CTG_ERR_RET(ctgGetTableTypeFromCache(pCtg, pTableName, &tbType, flag));
|
||||
|
||||
CTG_SET_STB(flag, tbType);
|
||||
}
|
||||
|
@ -1588,7 +1604,7 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons
|
|||
SName stbName = *pTableName;
|
||||
strcpy(stbName.tname, output->tbName);
|
||||
|
||||
CTG_ERR_JRET(ctgGetTableMetaFromCache(pCtg, &stbName, pTableMeta, &exist));
|
||||
CTG_ERR_JRET(ctgGetTableMetaFromCache(pCtg, &stbName, pTableMeta, &exist, flag));
|
||||
if (0 == exist) {
|
||||
ctgDebug("stb no longer exist, dbFName:%s, tbName:%s", output->dbFName, pTableName->tname);
|
||||
continue;
|
||||
|
@ -1669,6 +1685,11 @@ int32_t ctgActUpdateTbl(SCtgMetaAction *action) {
|
|||
CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
char *p = strchr(output->dbFName, '.');
|
||||
if (p && CTG_IS_INF_DBNAME(p + 1)) {
|
||||
memmove(output->dbFName, p + 1, strlen(p + 1));
|
||||
}
|
||||
|
||||
CTG_ERR_JRET(ctgGetAddDBCache(pCtg, output->dbFName, output->dbId, &dbCache));
|
||||
if (NULL == dbCache) {
|
||||
ctgInfo("conflict db update, ignore this update, dbFName:%s, dbId:%"PRIx64, output->dbFName, output->dbId);
|
||||
|
@ -2232,6 +2253,11 @@ int32_t catalogGetTableDistVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgm
|
|||
if (NULL == pCtg || NULL == pRpc || NULL == pMgmtEps || NULL == pTableName || NULL == pVgList) {
|
||||
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
||||
}
|
||||
|
||||
if (CTG_IS_INF_DBNAME(pTableName->dbname)) {
|
||||
ctgError("no valid vgInfo for db, dbname:%s", pTableName->dbname);
|
||||
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
||||
}
|
||||
|
||||
STableMeta *tbMeta = NULL;
|
||||
int32_t code = 0;
|
||||
|
@ -2316,6 +2342,11 @@ _return:
|
|||
int32_t catalogGetTableHashVgroup(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, const SName *pTableName, SVgroupInfo *pVgroup) {
|
||||
CTG_API_ENTER();
|
||||
|
||||
if (CTG_IS_INF_DBNAME(pTableName->dbname)) {
|
||||
ctgError("no valid vgInfo for db, dbname:%s", pTableName->dbname);
|
||||
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
||||
}
|
||||
|
||||
SCtgDBCache* dbCache = NULL;
|
||||
int32_t code = 0;
|
||||
char db[TSDB_DB_FNAME_LEN] = {0};
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
namespace {
|
||||
|
||||
extern "C" int32_t ctgGetTableMetaFromCache(struct SCatalog *pCatalog, const SName *pTableName, STableMeta **pTableMeta,
|
||||
int32_t *exist);
|
||||
int32_t *exist, int32_t flag);
|
||||
extern "C" int32_t ctgDbgGetClusterCacheNum(struct SCatalog* pCatalog, int32_t type);
|
||||
extern "C" int32_t ctgActUpdateTbl(SCtgMetaAction *action);
|
||||
extern "C" int32_t ctgDbgEnableDebug(char *option);
|
||||
|
@ -243,6 +243,8 @@ void ctgTestBuildSTableMetaRsp(STableMetaRsp *rspMsg) {
|
|||
rspMsg->suid = ctgTestSuid + 1;
|
||||
rspMsg->tuid = ctgTestSuid + 1;
|
||||
rspMsg->vgId = 1;
|
||||
|
||||
rspMsg->pSchemas = (SSchema *)calloc(rspMsg->numOfTags + rspMsg->numOfColumns, sizeof(SSchema));
|
||||
|
||||
SSchema *s = NULL;
|
||||
s = &rspMsg->pSchemas[0];
|
||||
|
@ -770,7 +772,7 @@ void *ctgTestGetCtableMetaThread(void *param) {
|
|||
strcpy(cn.tname, ctgTestCTablename);
|
||||
|
||||
while (!ctgTestStop) {
|
||||
code = ctgGetTableMetaFromCache(pCtg, &cn, &tbMeta, &exist);
|
||||
code = ctgGetTableMetaFromCache(pCtg, &cn, &tbMeta, &exist, 0);
|
||||
if (code || 0 == exist) {
|
||||
assert(0);
|
||||
}
|
||||
|
@ -1290,6 +1292,7 @@ TEST(tableMeta, updateStbMeta) {
|
|||
|
||||
code = catalogUpdateSTableMeta(pCtg, &rsp);
|
||||
ASSERT_EQ(code, 0);
|
||||
tfree(rsp.pSchemas);
|
||||
|
||||
while (true) {
|
||||
uint64_t n = 0;
|
||||
|
|
|
@ -198,7 +198,7 @@ int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isSuperTable, STabl
|
|||
}
|
||||
|
||||
int32_t queryProcessTableMetaRsp(void *output, char *msg, int32_t msgSize) {
|
||||
int32_t code = -1;
|
||||
int32_t code = 0;
|
||||
STableMetaRsp metaRsp = {0};
|
||||
|
||||
if (NULL == output || NULL == msg || msgSize <= 0) {
|
||||
|
@ -216,7 +216,7 @@ int32_t queryProcessTableMetaRsp(void *output, char *msg, int32_t msgSize) {
|
|||
goto PROCESS_META_OVER;
|
||||
}
|
||||
|
||||
if (!tIsValidSchema(metaRsp.pSchemas, metaRsp.numOfColumns, metaRsp.numOfTags)) {
|
||||
if (0 != strcmp(metaRsp.dbFName, TSDB_INFORMATION_SCHEMA_DB) && !tIsValidSchema(metaRsp.pSchemas, metaRsp.numOfColumns, metaRsp.numOfTags)) {
|
||||
code = TSDB_CODE_TSC_INVALID_VALUE;
|
||||
goto PROCESS_META_OVER;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue