Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -62,7 +62,7 @@ public void analyze(Analyzer analyzer) throws UserException {
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);
}
Expand Down
13 changes: 3 additions & 10 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -893,11 +893,4 @@ public String toJson() {
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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -273,5 +273,5 @@ default long getLastUpdateTime() {
return -1L;
}

public Map<Long, TableIf> getIdToTable();
Map<Long, TableIf> getIdToTable();
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ public void readFields(DataInput in) throws IOException {
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
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;
Expand Down Expand Up @@ -280,7 +281,7 @@ private void checkTablets() {
continue;
}

if (db.isMysqlCompatibleDatabase()) {
if (db instanceof MysqlCompatibleDatabase) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ default CatalogLog constructEditLog() {
}

// 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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -841,8 +841,8 @@ public void dropTable(DropTableStmt stmt) throws DdlException {
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.");
}

Expand Down Expand Up @@ -1100,7 +1100,7 @@ public void createTable(CreateTableStmt stmt) throws UserException {
// 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");
}
Expand Down Expand Up @@ -3326,7 +3326,7 @@ public long saveDb(CountingDataOutputStream dos, long checksum) throws IOExcepti
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);
}
Expand All @@ -3345,7 +3345,7 @@ public long loadDb(DataInputStream dis, long checksum) throws IOException, DdlEx
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.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
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;
Expand Down Expand Up @@ -199,7 +200,7 @@ public Object show_data(HttpServletRequest request, HttpServletResponse response
} 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);
Expand Down Expand Up @@ -232,7 +233,7 @@ public Object show_table_data(HttpServletRequest request, HttpServletResponse re
} 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

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;
Expand Down Expand Up @@ -56,7 +57,7 @@ private void updatePartitionInMemoryInfo() {
LOG.warn("Database [" + dbId + "] does not exist, skip to update database used data quota");
continue;
}
if (db.isMysqlCompatibleDatabase()) {
if (db instanceof MysqlCompatibleDatabase) {
continue;
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

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;
Expand Down Expand Up @@ -50,7 +51,7 @@ private void updateAllDatabaseUsedDataQuota() {
LOG.warn("Database [" + dbId + "] does not exist, skip to update database used data quota");
continue;
}
if (db.isMysqlCompatibleDatabase()) {
if (db instanceof MysqlCompatibleDatabase) {
continue;
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.doris.catalog.DiskInfo;
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.MaterializedIndex;
import org.apache.doris.catalog.MysqlCompatibleDatabase;
import org.apache.doris.catalog.OlapTable;
import org.apache.doris.catalog.Partition;
import org.apache.doris.catalog.Replica;
Expand Down Expand Up @@ -145,7 +146,7 @@ public static void updateReplicaDataSize(long minReplicaSize, int tableSkew, in
continue;
}

if (db.isMysqlCompatibleDatabase()) {
if (db instanceof MysqlCompatibleDatabase) {
continue;
}

Expand Down