Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#8422
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
JaySon-Huang authored and ti-chi-bot committed Nov 30, 2023
1 parent c8d1b80 commit fb4cb48
Show file tree
Hide file tree
Showing 22 changed files with 3,739 additions and 56 deletions.
14 changes: 14 additions & 0 deletions dbms/src/Debug/MockSchemaGetter.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,21 @@ struct MockSchemaGetter

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

<<<<<<< HEAD
std::vector<TiDB::DBInfoPtr> listDBs()
=======
static std::pair<TiDB::TableInfoPtr, bool> getTableInfoAndCheckMvcc(DatabaseID db_id, TableID table_id)
{
return {getTableInfo(db_id, table_id), false};
}

static std::tuple<TiDB::DBInfoPtr, TiDB::TableInfoPtr> getDatabaseAndTableInfo(DatabaseID db_id, TableID table_id)
{
return std::make_tuple(getDatabase(db_id), getTableInfo(db_id, table_id));
}

static std::vector<TiDB::DBInfoPtr> listDBs()
>>>>>>> fbf4a35f38 (ddl: Fix unstable `DROP TABLE`/`FLASHBACK TABLE`/`RECOVER TABLE` (#8422))
{
std::vector<TiDB::DBInfoPtr> res;
const auto & databases = MockTiDB::instance().getDatabases();
Expand Down
25 changes: 25 additions & 0 deletions dbms/src/Storages/Transaction/SchemaGetter.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,36 @@ struct SchemaGetter

TiDB::DBInfoPtr getDatabase(DatabaseID db_id);

<<<<<<< HEAD:dbms/src/Storages/Transaction/SchemaGetter.h
TiDB::TableInfoPtr getTableInfo(DatabaseID db_id, TableID table_id);
=======
TiDB::TableInfoPtr getTableInfo(DatabaseID db_id, TableID table_id, bool try_mvcc = true)
{
if (try_mvcc)
return getTableInfoImpl</*mvcc_get*/ true>(db_id, table_id).first;
return getTableInfoImpl</*mvcc_get*/ false>(db_id, table_id).first;
}

std::pair<TiDB::TableInfoPtr, bool> getTableInfoAndCheckMvcc(DatabaseID db_id, TableID table_id)
{
return getTableInfoImpl</*mvcc_get*/ true>(db_id, table_id);
}

std::tuple<TiDB::DBInfoPtr, TiDB::TableInfoPtr> getDatabaseAndTableInfo(DatabaseID db_id, TableID table_id);
>>>>>>> fbf4a35f38 (ddl: Fix unstable `DROP TABLE`/`FLASHBACK TABLE`/`RECOVER TABLE` (#8422)):dbms/src/TiDB/Schema/SchemaGetter.h

std::vector<TiDB::DBInfoPtr> listDBs();

std::vector<TiDB::TableInfoPtr> listTables(DatabaseID db_id);
<<<<<<< HEAD:dbms/src/Storages/Transaction/SchemaGetter.h
=======

KeyspaceID getKeyspaceID() const { return keyspace_id; }

private:
template <bool mvcc_get>
std::pair<TiDB::TableInfoPtr, bool> getTableInfoImpl(DatabaseID db_id, TableID table_id);
>>>>>>> fbf4a35f38 (ddl: Fix unstable `DROP TABLE`/`FLASHBACK TABLE`/`RECOVER TABLE` (#8422)):dbms/src/TiDB/Schema/SchemaGetter.h
};

} // namespace DB
8 changes: 8 additions & 0 deletions dbms/src/Storages/Transaction/SchemaSyncer.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,15 @@ class SchemaSyncer

virtual TiDB::DBInfoPtr getDBInfoByMappedName(const String & mapped_database_name) = 0;

<<<<<<< HEAD:dbms/src/Storages/Transaction/SchemaSyncer.h
virtual std::vector<TiDB::DBInfoPtr> fetchAllDBs() = 0;
=======
/**
* Drop all schema of a given keyspace.
* When a keyspace is removed, drop all its databases and tables.
*/
virtual void dropAllSchema(Context & context) = 0;
>>>>>>> fbf4a35f38 (ddl: Fix unstable `DROP TABLE`/`FLASHBACK TABLE`/`RECOVER TABLE` (#8422)):dbms/src/TiDB/Schema/SchemaSyncer.h
};

using SchemaSyncerPtr = std::shared_ptr<SchemaSyncer>;
Expand Down

0 comments on commit fb4cb48

Please sign in to comment.