Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Hotfix]Delete sync tables when drop external catalogs #2235

Merged
merged 9 commits into from
Nov 3, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ Integer deleteTableIdByName(
@Param("databaseName") String databaseName,
@Param("tableName") String tableName);

@Delete("DELETE FROM table_identifier WHERE catalog_name = #{catalogName}")
Integer deleteTableIdByCatalogName(@Param("catalogName") String catalogName);

@Select(
"SELECT table_id, catalog_name, db_name, table_name, format FROM table_identifier"
+ " WHERE catalog_name = #{catalogName} AND db_name = #{databaseName} AND table_name = #{tableName}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,16 @@ private void initServerCatalog(CatalogMeta catalogMeta) {
@Override
public void dropCatalog(String catalogName) {
checkStarted();
doAsExisted(
CatalogMetaMapper.class,
mapper -> mapper.deleteCatalog(catalogName),
doAsTransaction(
() ->
doAsExisted(
CatalogMetaMapper.class,
mapper -> mapper.deleteCatalog(catalogName),
() ->
new IllegalMetadataException(
"Catalog " + catalogName + " has more than one database or table")),
() ->
new IllegalMetadataException(
"Catalog " + catalogName + " has more than one database or table"));
doAs(TableMetaMapper.class, mapper -> mapper.deleteTableIdByCatalogName(catalogName)));
internalCatalogMap.remove(catalogName);
externalCatalogMap.remove(catalogName);
}
Expand Down