Skip to content

Commit

Permalink
Merge branch 'master' into cop
Browse files Browse the repository at this point in the history
  • Loading branch information
zanmato1984 authored Aug 7, 2019
2 parents 2ade1cb + 8c524a2 commit 3870d93
Show file tree
Hide file tree
Showing 33 changed files with 248 additions and 529 deletions.
1 change: 0 additions & 1 deletion dbms/src/Debug/DBGInvoker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ DBGInvoker::DBGInvoker()
regFunc("dump_all_region", dbgFuncDumpAllRegion);

regFunc("enable_schema_sync_service", dbgFuncEnableSchemaSyncService);
regFunc("mock_schema_syncer", dbgFuncMockSchemaSyncer);
regFunc("refresh_schemas", dbgFuncRefreshSchemas);
}

Expand Down
51 changes: 51 additions & 0 deletions dbms/src/Debug/MockSchemaGetter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#pragma once

#include <Debug/MockTiDB.h>
#include <Storages/Transaction/SchemaGetter.h>

namespace DB
{

struct MockSchemaGetter
{

TiDB::DBInfoPtr getDatabase(DatabaseID db_id) { return MockTiDB::instance().getDBInfoByID(db_id); }

Int64 getVersion() { return MockTiDB::instance().getVersion(); }

SchemaDiff getSchemaDiff(Int64 version) { return MockTiDB::instance().getSchemaDiff(version); }

TiDB::TableInfoPtr getTableInfo(DatabaseID, TableID table_id) { return MockTiDB::instance().getTableInfoByID(table_id); }

std::vector<TiDB::DBInfoPtr> listDBs()
{
std::vector<TiDB::DBInfoPtr> res;
const auto & databases = MockTiDB::instance().getDatabases();
for (auto it = databases.begin(); it != databases.end(); it++)
{
auto db_id = it->second;
auto db_name = it->first;
TiDB::DBInfoPtr db_ptr = std::make_shared<TiDB::DBInfo>(TiDB::DBInfo());
db_ptr->id = db_id;
db_ptr->name = db_name;
res.push_back(db_ptr);
}
return res;
}

std::vector<TiDB::TableInfoPtr> listTables(Int64 db_id)
{
auto tables_by_id = MockTiDB::instance().getTables();
std::vector<TiDB::TableInfoPtr> res;
for (auto it = tables_by_id.begin(); it != tables_by_id.end(); it++)
{
if (it->second->table_info.db_id == db_id)
{
res.push_back(std::make_shared<TiDB::TableInfo>(TiDB::TableInfo(it->second->table_info)));
}
}
return res;
}
};

} // namespace DB
Loading

0 comments on commit 3870d93

Please sign in to comment.