Skip to content

Commit

Permalink
storage: Add keyspace_id to DT system tables (#210)
Browse files Browse the repository at this point in the history
Signed-off-by: Wish <breezewish@outlook.com>
  • Loading branch information
breezewish authored and JaySon-Huang committed Aug 6, 2024
1 parent 63d62cb commit 86629a5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
14 changes: 12 additions & 2 deletions dbms/src/Storages/System/StorageSystemDTSegments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <Columns/ColumnString.h>
#include <DataStreams/OneBlockInputStream.h>
#include <DataTypes/DataTypeNullable.h>
#include <DataTypes/DataTypeString.h>
#include <DataTypes/DataTypesNumber.h>
#include <Databases/DatabaseTiFlash.h>
Expand All @@ -37,6 +38,7 @@ StorageSystemDTSegments::StorageSystemDTSegments(const std::string & name_)

{"tidb_database", std::make_shared<DataTypeString>()},
{"tidb_table", std::make_shared<DataTypeString>()},
{"keyspace_id", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeUInt64>())},
{"table_id", std::make_shared<DataTypeInt64>()},
{"is_tombstone", std::make_shared<DataTypeUInt64>()},

Expand Down Expand Up @@ -115,11 +117,19 @@ BlockInputStreams StorageSystemDTSegments::read(
res_columns[j++]->insert(table_name);

String tidb_db_name;
KeyspaceID keyspace_id = NullspaceID;
if (db_tiflash)
tidb_db_name = mapper.displayDatabaseName(db_tiflash->getDatabaseInfo());
{
tidb_db_name = db_tiflash->getDatabaseInfo().name;
keyspace_id = db_tiflash->getDatabaseInfo().keyspace_id;
}
res_columns[j++]->insert(tidb_db_name);
String tidb_table_name = mapper.displayTableName(table_info);
String tidb_table_name = table_info.name;
res_columns[j++]->insert(tidb_table_name);
if (keyspace_id == NullspaceID)
res_columns[j++]->insert(Field());
else
res_columns[j++]->insert(static_cast<UInt64>(keyspace_id));
res_columns[j++]->insert(table_id);
res_columns[j++]->insert(dm_storage->getTombstone());

Expand Down
15 changes: 13 additions & 2 deletions dbms/src/Storages/System/StorageSystemDTTables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@

#include <Columns/ColumnString.h>
#include <DataStreams/OneBlockInputStream.h>
#include <DataTypes/DataTypeNullable.h>
#include <DataTypes/DataTypeString.h>
#include <DataTypes/DataTypesNumber.h>
#include <Databases/DatabaseTiFlash.h>
#include <Databases/IDatabase.h>
#include <Interpreters/Context.h>
#include <Storages/DeltaMerge/DeltaMergeStore.h>
#include <Storages/KVStore/Types.h>
#include <Storages/MutableSupport.h>
#include <Storages/StorageDeltaMerge.h>
#include <Storages/System/StorageSystemDTTables.h>
Expand All @@ -37,6 +39,7 @@ StorageSystemDTTables::StorageSystemDTTables(const std::string & name_)

{"tidb_database", std::make_shared<DataTypeString>()},
{"tidb_table", std::make_shared<DataTypeString>()},
{"keyspace_id", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeUInt64>())},
{"table_id", std::make_shared<DataTypeInt64>()},
{"is_tombstone", std::make_shared<DataTypeUInt64>()},

Expand Down Expand Up @@ -146,11 +149,19 @@ BlockInputStreams StorageSystemDTTables::read(
res_columns[j++]->insert(table_name);

String tidb_db_name;
KeyspaceID keyspace_id = NullspaceID;
if (db_tiflash)
tidb_db_name = mapper.displayDatabaseName(db_tiflash->getDatabaseInfo());
{
tidb_db_name = db_tiflash->getDatabaseInfo().name;
keyspace_id = db_tiflash->getDatabaseInfo().keyspace_id;
}
res_columns[j++]->insert(tidb_db_name);
String tidb_table_name = mapper.displayTableName(table_info);
String tidb_table_name = table_info.name;
res_columns[j++]->insert(tidb_table_name);
if (keyspace_id == NullspaceID)
res_columns[j++]->insert(Field());
else
res_columns[j++]->insert(static_cast<UInt64>(keyspace_id));
res_columns[j++]->insert(table_id);
res_columns[j++]->insert(dm_storage->getTombstone());

Expand Down

0 comments on commit 86629a5

Please sign in to comment.