[minor](Nereids): remove useless method isMysqlCompatibleDatabase (#30064)

This commit is contained in:
jakevin
2024-01-17 19:20:19 +08:00
committed by yiguolei
parent 30378f9bbc
commit 65b5a5436a
11 changed files with 25 additions and 32 deletions

View File

@ -17,9 +17,9 @@
package org.apache.doris.analysis;
import org.apache.doris.catalog.Database;
import org.apache.doris.catalog.DatabaseIf;
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.MysqlCompatibleDatabase;
import org.apache.doris.common.ErrorCode;
import org.apache.doris.common.ErrorReport;
import org.apache.doris.common.UserException;
@ -62,7 +62,7 @@ public class DropDbStmt extends DdlStmt {
InternalDatabaseUtil.checkDatabase(dbName, ConnectContext.get());
// Don't allow to drop mysql compatible databases
DatabaseIf db = Env.getCurrentInternalCatalog().getDbNullable(dbName);
if (db != null && (db instanceof Database) && ((Database) db).isMysqlCompatibleDatabase()) {
if (db != null && db instanceof MysqlCompatibleDatabase) {
ErrorReport.reportAnalysisException(ErrorCode.ERR_DBACCESS_DENIED_ERROR,
analyzer.getQualifiedUser(), dbName);
}

View File

@ -84,14 +84,14 @@ public class Database extends MetaObject implements Writable, DatabaseIf<Table>
private long id;
@SerializedName(value = "fullQualifiedName")
private volatile String fullQualifiedName;
private ReentrantReadWriteLock rwLock;
private final ReentrantReadWriteLock rwLock;
// table family group map
private Map<Long, Table> idToTable;
private final Map<Long, Table> idToTable;
@SerializedName(value = "nameToTable")
private Map<String, Table> nameToTable;
// table name lower cast -> table name
private Map<String, String> lowerCaseToTableName;
private final Map<String, String> lowerCaseToTableName;
// user define function
@SerializedName(value = "name2Function")
@ -893,11 +893,4 @@ public class Database extends MetaObject implements Writable, DatabaseIf<Table>
public String toString() {
return toJson();
}
// Return ture if database is created for mysql compatibility.
// Currently, we have two dbs that are created for this purpose, InformationSchemaDb and MysqlDb,
public boolean isMysqlCompatibleDatabase() {
return false;
}
}

View File

@ -273,5 +273,5 @@ public interface DatabaseIf<T extends TableIf> {
return -1L;
}
public Map<Long, TableIf> getIdToTable();
Map<Long, TableIf> getIdToTable();
}

View File

@ -77,11 +77,6 @@ public abstract class MysqlCompatibleDatabase extends Database {
throw new IOException("Not support.");
}
@Override
public boolean isMysqlCompatibleDatabase() {
return true;
}
/**
* This method must be re-implemented since {@link Env#createView(CreateViewStmt)}
* will call this method. And create view should not succeed under this database.

View File

@ -23,6 +23,7 @@ import org.apache.doris.catalog.Database;
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.MaterializedIndex;
import org.apache.doris.catalog.MaterializedIndex.IndexExtState;
import org.apache.doris.catalog.MysqlCompatibleDatabase;
import org.apache.doris.catalog.OlapTable;
import org.apache.doris.catalog.Partition;
import org.apache.doris.catalog.Partition.PartitionState;
@ -280,7 +281,7 @@ public class TabletChecker extends MasterDaemon {
continue;
}
if (db.isMysqlCompatibleDatabase()) {
if (db instanceof MysqlCompatibleDatabase) {
continue;
}

View File

@ -172,9 +172,9 @@ public interface CatalogIf<T extends DatabaseIf> {
}
// Return a copy of all db collection.
public Collection<DatabaseIf<? extends TableIf>> getAllDbs();
Collection<DatabaseIf<? extends TableIf>> getAllDbs();
public boolean enableAutoAnalyze();
boolean enableAutoAnalyze();
public ConcurrentHashMap<Long, DatabaseIf> getIdToDb();
ConcurrentHashMap<Long, DatabaseIf> getIdToDb();
}

View File

@ -839,8 +839,8 @@ public class InternalCatalog implements CatalogIf<Database> {
LOG.info("begin to drop table: {} from db: {}, is force: {}", tableName, dbName, stmt.isForceDrop());
// check database
Database db = (Database) getDbOrDdlException(dbName);
if (db.isMysqlCompatibleDatabase()) {
Database db = getDbOrDdlException(dbName);
if (db instanceof MysqlCompatibleDatabase) {
throw new DdlException("Drop table from this database is not allowed.");
}
@ -1066,7 +1066,7 @@ public class InternalCatalog implements CatalogIf<Database> {
// check if db exists
Database db = getDbOrDdlException(dbName);
// InfoSchemaDb and MysqlDb can not create table manually
if (db.isMysqlCompatibleDatabase()) {
if (db instanceof MysqlCompatibleDatabase) {
ErrorReport.reportDdlException(ErrorCode.ERR_CANT_CREATE_TABLE, tableName,
ErrorCode.ERR_CANT_CREATE_TABLE.getCode(), "not supported create table in this database");
}
@ -3227,7 +3227,7 @@ public class InternalCatalog implements CatalogIf<Database> {
for (Map.Entry<Long, Database> entry : idToDb.entrySet()) {
Database db = entry.getValue();
// Don't write internal database meta.
if (!db.isMysqlCompatibleDatabase()) {
if (!(db instanceof MysqlCompatibleDatabase)) {
checksum ^= entry.getKey();
db.write(dos);
}
@ -3246,7 +3246,7 @@ public class InternalCatalog implements CatalogIf<Database> {
Database dbPrev = fullNameToDb.get(db.getFullName());
if (dbPrev != null) {
String errMsg;
if (dbPrev.isMysqlCompatibleDatabase() || db.isMysqlCompatibleDatabase()) {
if (dbPrev instanceof MysqlCompatibleDatabase || db instanceof MysqlCompatibleDatabase) {
errMsg = String.format(
"Mysql compatibility problem, previous checkpoint already has a database with full name "
+ "%s. If its name is mysql, try to add mysqldb_replace_name=\"mysql_comp\" in fe.conf.",

View File

@ -20,6 +20,7 @@ package org.apache.doris.httpv2.rest;
import org.apache.doris.catalog.Database;
import org.apache.doris.catalog.DatabaseIf;
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.MysqlCompatibleDatabase;
import org.apache.doris.catalog.OlapTable;
import org.apache.doris.catalog.Table;
import org.apache.doris.catalog.TableIf.TableType;
@ -199,7 +200,7 @@ public class ShowAction extends RestBaseController {
} else {
for (long dbId : Env.getCurrentInternalCatalog().getDbIds()) {
DatabaseIf db = Env.getCurrentInternalCatalog().getDbNullable(dbId);
if (db == null || !(db instanceof Database) || ((Database) db).isMysqlCompatibleDatabase()) {
if (db == null || !(db instanceof Database) || db instanceof MysqlCompatibleDatabase) {
continue;
}
totalSize += getDataSizeOfDatabase(db);
@ -232,7 +233,7 @@ public class ShowAction extends RestBaseController {
} else {
for (long dbId : Env.getCurrentInternalCatalog().getDbIds()) {
DatabaseIf db = Env.getCurrentInternalCatalog().getDbNullable(dbId);
if (db == null || !(db instanceof Database) || ((Database) db).isMysqlCompatibleDatabase()) {
if (db == null || !(db instanceof Database) || ((Database) db) instanceof MysqlCompatibleDatabase) {
continue;
}
Map<String, Long> tablesEntry = getDataSizeOfTables(db, tableName, singleReplicaBool);

View File

@ -19,6 +19,7 @@ package org.apache.doris.master;
import org.apache.doris.catalog.Database;
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.MysqlCompatibleDatabase;
import org.apache.doris.catalog.OlapTable;
import org.apache.doris.catalog.Partition;
import org.apache.doris.catalog.Table;
@ -56,7 +57,7 @@ public class PartitionInMemoryInfoCollector extends MasterDaemon {
LOG.warn("Database [" + dbId + "] does not exist, skip to update database used data quota");
continue;
}
if (db.isMysqlCompatibleDatabase()) {
if (db instanceof MysqlCompatibleDatabase) {
continue;
}
try {

View File

@ -19,6 +19,7 @@ package org.apache.doris.transaction;
import org.apache.doris.catalog.Database;
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.MysqlCompatibleDatabase;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.Config;
import org.apache.doris.common.util.MasterDaemon;
@ -50,7 +51,7 @@ public class DbUsedDataQuotaInfoCollector extends MasterDaemon {
LOG.warn("Database [" + dbId + "] does not exist, skip to update database used data quota");
continue;
}
if (db.isMysqlCompatibleDatabase()) {
if (db instanceof MysqlCompatibleDatabase) {
continue;
}
try {