From 39569cbd9a8c176c319aaf47c46671688c425895 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Tue, 30 Aug 2022 13:49:35 +0800 Subject: [PATCH] enh: move some tables from perf to ins --- include/common/systable.h | 6 ++--- source/common/src/systable.c | 36 +++++++++++++------------ source/dnode/mnode/impl/src/mndShow.c | 6 ++--- source/libs/parser/src/parAstParser.c | 6 ++--- source/libs/parser/src/parTranslater.c | 12 ++++----- source/libs/parser/test/mockCatalog.cpp | 4 +-- 6 files changed, 36 insertions(+), 34 deletions(-) diff --git a/include/common/systable.h b/include/common/systable.h index 01c9807627..882c54de95 100644 --- a/include/common/systable.h +++ b/include/common/systable.h @@ -43,17 +43,17 @@ extern "C" { #define TSDB_INS_TABLE_VNODES "ins_vnodes" #define TSDB_INS_TABLE_CONFIGS "ins_configs" #define TSDB_INS_TABLE_DNODE_VARIABLES "ins_dnode_variables" +#define TSDB_INS_TABLE_SUBSCRIPTIONS "ins_subscriptions" +#define TSDB_INS_TABLE_TOPICS "ins_topics" +#define TSDB_INS_TABLE_STREAMS "ins_streams" #define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema" #define TSDB_PERFS_TABLE_SMAS "perf_smas" #define TSDB_PERFS_TABLE_CONNECTIONS "perf_connections" #define TSDB_PERFS_TABLE_QUERIES "perf_queries" -#define TSDB_PERFS_TABLE_TOPICS "perf_topics" #define TSDB_PERFS_TABLE_CONSUMERS "perf_consumers" -#define TSDB_PERFS_TABLE_SUBSCRIPTIONS "perf_subscriptions" #define TSDB_PERFS_TABLE_OFFSETS "perf_offsets" #define TSDB_PERFS_TABLE_TRANS "perf_trans" -#define TSDB_PERFS_TABLE_STREAMS "perf_streams" #define TSDB_PERFS_TABLE_APPS "perf_apps" typedef struct SSysDbTableSchema { diff --git a/source/common/src/systable.c b/source/common/src/systable.c index 9ca896c9ee..dffef21ac4 100644 --- a/source/common/src/systable.c +++ b/source/common/src/systable.c @@ -240,6 +240,22 @@ static const SSysDbTableSchema variablesSchema[] = { {.name = "value", .bytes = TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, }; +static const SSysDbTableSchema topicSchema[] = { + {.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, + {.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, + {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false}, + {.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, + // TODO config +}; + + +static const SSysDbTableSchema subscriptionSchema[] = { + {.name = "topic_name", .bytes = TSDB_TOPIC_FNAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, + {.name = "consumer_group", .bytes = TSDB_CGROUP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, + {.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false}, + {.name = "consumer_id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false}, +}; + static const SSysTableMeta infosMeta[] = { {TSDB_INS_TABLE_DNODES, dnodesSchema, tListLen(dnodesSchema), true}, {TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema), true}, @@ -260,6 +276,9 @@ static const SSysTableMeta infosMeta[] = { {TSDB_INS_TABLE_VGROUPS, vgroupsSchema, tListLen(vgroupsSchema), true}, {TSDB_INS_TABLE_CONFIGS, configSchema, tListLen(configSchema), true}, {TSDB_INS_TABLE_DNODE_VARIABLES, variablesSchema, tListLen(variablesSchema), true}, + {TSDB_INS_TABLE_TOPICS, topicSchema, tListLen(topicSchema), false}, + {TSDB_INS_TABLE_SUBSCRIPTIONS, subscriptionSchema, tListLen(subscriptionSchema), false}, + {TSDB_INS_TABLE_STREAMS, streamSchema, tListLen(streamSchema), false}, }; static const SSysDbTableSchema connectionsSchema[] = { @@ -272,13 +291,6 @@ static const SSysDbTableSchema connectionsSchema[] = { {.name = "last_access", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false}, }; -static const SSysDbTableSchema topicSchema[] = { - {.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, - {.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, - {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false}, - {.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, - // TODO config -}; static const SSysDbTableSchema consumerSchema[] = { {.name = "consumer_id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false}, @@ -292,13 +304,6 @@ static const SSysDbTableSchema consumerSchema[] = { {.name = "rebalance_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false}, }; -static const SSysDbTableSchema subscriptionSchema[] = { - {.name = "topic_name", .bytes = TSDB_TOPIC_FNAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, - {.name = "consumer_group", .bytes = TSDB_CGROUP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, - {.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false}, - {.name = "consumer_id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false}, -}; - static const SSysDbTableSchema offsetSchema[] = { {.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, {.name = "group_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, @@ -345,13 +350,10 @@ static const SSysDbTableSchema appSchema[] = { static const SSysTableMeta perfsMeta[] = { {TSDB_PERFS_TABLE_CONNECTIONS, connectionsSchema, tListLen(connectionsSchema), false}, {TSDB_PERFS_TABLE_QUERIES, querySchema, tListLen(querySchema), false}, - {TSDB_PERFS_TABLE_TOPICS, topicSchema, tListLen(topicSchema), false}, {TSDB_PERFS_TABLE_CONSUMERS, consumerSchema, tListLen(consumerSchema), false}, - {TSDB_PERFS_TABLE_SUBSCRIPTIONS, subscriptionSchema, tListLen(subscriptionSchema), false}, // {TSDB_PERFS_TABLE_OFFSETS, offsetSchema, tListLen(offsetSchema)}, {TSDB_PERFS_TABLE_TRANS, transSchema, tListLen(transSchema), false}, // {TSDB_PERFS_TABLE_SMAS, smaSchema, tListLen(smaSchema), false}, - {TSDB_PERFS_TABLE_STREAMS, streamSchema, tListLen(streamSchema), false}, {TSDB_PERFS_TABLE_APPS, appSchema, tListLen(appSchema), false}}; // clang-format on diff --git a/source/dnode/mnode/impl/src/mndShow.c b/source/dnode/mnode/impl/src/mndShow.c index 9499c90c57..5a998dfe98 100644 --- a/source/dnode/mnode/impl/src/mndShow.c +++ b/source/dnode/mnode/impl/src/mndShow.c @@ -88,7 +88,7 @@ static int32_t convertToRetrieveType(char *name, int32_t len) { type = TSDB_MGMT_TABLE_VGROUP; } else if (strncasecmp(name, TSDB_PERFS_TABLE_CONSUMERS, len) == 0) { type = TSDB_MGMT_TABLE_CONSUMERS; - } else if (strncasecmp(name, TSDB_PERFS_TABLE_SUBSCRIPTIONS, len) == 0) { + } else if (strncasecmp(name, TSDB_INS_TABLE_SUBSCRIPTIONS, len) == 0) { type = TSDB_MGMT_TABLE_SUBSCRIPTIONS; } else if (strncasecmp(name, TSDB_PERFS_TABLE_TRANS, len) == 0) { type = TSDB_MGMT_TABLE_TRANS; @@ -102,9 +102,9 @@ static int32_t convertToRetrieveType(char *name, int32_t len) { type = TSDB_MGMT_TABLE_QUERIES; } else if (strncasecmp(name, TSDB_INS_TABLE_VNODES, len) == 0) { type = TSDB_MGMT_TABLE_VNODES; - } else if (strncasecmp(name, TSDB_PERFS_TABLE_TOPICS, len) == 0) { + } else if (strncasecmp(name, TSDB_INS_TABLE_TOPICS, len) == 0) { type = TSDB_MGMT_TABLE_TOPICS; - } else if (strncasecmp(name, TSDB_PERFS_TABLE_STREAMS, len) == 0) { + } else if (strncasecmp(name, TSDB_INS_TABLE_STREAMS, len) == 0) { type = TSDB_MGMT_TABLE_STREAMS; } else if (strncasecmp(name, TSDB_PERFS_TABLE_APPS, len) == 0) { type = TSDB_MGMT_TABLE_APPS; diff --git a/source/libs/parser/src/parAstParser.c b/source/libs/parser/src/parAstParser.c index 82b5842663..1fb0642eb7 100644 --- a/source/libs/parser/src/parAstParser.c +++ b/source/libs/parser/src/parAstParser.c @@ -365,7 +365,7 @@ static int32_t collectMetaKeyFromShowStables(SCollectMetaKeyCxt* pCxt, SShowStmt } static int32_t collectMetaKeyFromShowStreams(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { - return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_STREAMS, + return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_STREAMS, pCxt->pMetaCache); } @@ -411,7 +411,7 @@ static int32_t collectMetaKeyFromShowVgroups(SCollectMetaKeyCxt* pCxt, SShowStmt } static int32_t collectMetaKeyFromShowTopics(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { - return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_TOPICS, + return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TOPICS, pCxt->pMetaCache); } @@ -506,7 +506,7 @@ static int32_t collectMetaKeyFromShowBlockDist(SCollectMetaKeyCxt* pCxt, SShowTa } static int32_t collectMetaKeyFromShowSubscriptions(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { - return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_SUBSCRIPTIONS, + return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_SUBSCRIPTIONS, pCxt->pMetaCache); } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 51a4295ce5..73e252fa87 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -142,8 +142,8 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = { }, { .showType = QUERY_NODE_SHOW_STREAMS_STMT, - .pDbName = TSDB_PERFORMANCE_SCHEMA_DB, - .pTableName = TSDB_PERFS_TABLE_STREAMS, + .pDbName = TSDB_INFORMATION_SCHEMA_DB, + .pTableName = TSDB_INS_TABLE_STREAMS, .numOfShowCols = 1, .pShowCols = {"stream_name"} }, @@ -184,8 +184,8 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = { }, { .showType = QUERY_NODE_SHOW_TOPICS_STMT, - .pDbName = TSDB_PERFORMANCE_SCHEMA_DB, - .pTableName = TSDB_PERFS_TABLE_TOPICS, + .pDbName = TSDB_INFORMATION_SCHEMA_DB, + .pTableName = TSDB_INS_TABLE_TOPICS, .numOfShowCols = 1, .pShowCols = {"topic_name"} }, @@ -240,8 +240,8 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = { }, { .showType = QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT, - .pDbName = TSDB_PERFORMANCE_SCHEMA_DB, - .pTableName = TSDB_PERFS_TABLE_SUBSCRIPTIONS, + .pDbName = TSDB_INFORMATION_SCHEMA_DB, + .pTableName = TSDB_INS_TABLE_SUBSCRIPTIONS, .numOfShowCols = 1, .pShowCols = {"*"} }, diff --git a/source/libs/parser/test/mockCatalog.cpp b/source/libs/parser/test/mockCatalog.cpp index b376c33d1a..cd7a9d549a 100644 --- a/source/libs/parser/test/mockCatalog.cpp +++ b/source/libs/parser/test/mockCatalog.cpp @@ -137,7 +137,7 @@ void generatePerformanceSchema(MockCatalogService* mcs) { } { ITableBuilder& builder = - mcs->createTableBuilder(TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_STREAMS, TSDB_SYSTEM_TABLE, 1) + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_STREAMS, TSDB_SYSTEM_TABLE, 1) .addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); builder.done(); } @@ -149,7 +149,7 @@ void generatePerformanceSchema(MockCatalogService* mcs) { } { ITableBuilder& builder = - mcs->createTableBuilder(TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_SUBSCRIPTIONS, TSDB_SYSTEM_TABLE, 1) + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_SUBSCRIPTIONS, TSDB_SYSTEM_TABLE, 1) .addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); builder.done(); }