提交 1fc3d4bb 编写于 作者: L liuyizhuo
上级 7cce8e5e
......@@ -18,7 +18,7 @@
path="oceanbase">
<folder type="org.jkiss.dbeaver.ext.oceanbase.mysql.model.OceanbaseMySQLCatalog" label="%tree.databases.node.name" icon="#folder_schema" description="%tree.databases.node.tip">
<items label="%tree.database.node.name" path="database" property="catalogs" icon="#database">
<folder type="org.jkiss.dbeaver.ext.mysql.model.MySQLTable" label="%tree.tables.node.name" icon="#folder_table" description="%tree.tables.node.tip">
<folder type="org.jkiss.dbeaver.ext.oceanbase.mysql.model.OceanbaseTable" label="%tree.tables.node.name" icon="#folder_table" description="%tree.tables.node.tip">
<items label="%tree.table.node.name" path="table" property="tables" icon="#table">
<folder type="org.jkiss.dbeaver.ext.mysql.model.MySQLTableColumn" label="%tree.columns.node.name" icon="#columns" description="Table columns">
<items label="%tree.column.node.name" path="attribute" property="attributes" icon="#column">
......
......@@ -20,11 +20,9 @@ public class OceanbaseAuthModelDatabaseNative extends AuthModelDatabaseNative {
AuthModelDatabaseNativeCredentials credentials, DBPConnectionConfiguration configuration,
@NotNull Properties connProperties) throws DBException {
String userName = configuration.getUserName();
if (!CommonUtils.isEmpty(userName)) {
if (!userName.contains("@")) {
if (!CommonUtils.isEmpty(userName) && !userName.contains("@")) {
userName += "@" + configuration.getServerName();
}
}
credentials.setUserName(userName);
return super.initAuthentication(monitor, dataSource, credentials, configuration, connProperties);
......
......@@ -94,7 +94,6 @@ public class OceanbasePlanAnalyzer extends AbstractExecutionPlanSerializer imple
@Override
public DBPDataSource getDataSource() {
// TODO Auto-generated method stub
return this.dataSource;
}
......@@ -106,7 +105,6 @@ public class OceanbasePlanAnalyzer extends AbstractExecutionPlanSerializer imple
@Override
public DBCPlanStyle getPlanStyle() {
// TODO Auto-generated method stub
return DBCPlanStyle.PLAN;
}
......
......@@ -29,8 +29,9 @@ public class OceanbasePlanJSON extends AbstractExecutionPlan {
public OceanbasePlanJSON(JDBCSession session, String query) throws DBCException {
this.dataSource = (OceanbaseMySQLDataSource) session.getDataSource();
this.query = query;
try (JDBCPreparedStatement dbStat = session.prepareStatement(getPlanQueryString())) {
try (JDBCResultSet dbResult = dbStat.executeQuery()) {
try{
JDBCPreparedStatement dbStat = session.prepareStatement(getPlanQueryString());
JDBCResultSet dbResult = dbStat.executeQuery();
List<OceanbasePlanNodeJSON> nodes = new ArrayList<>();
dbResult.next();
......@@ -47,10 +48,6 @@ public class OceanbasePlanJSON extends AbstractExecutionPlan {
nodes.add(rootNode);
rootNodes = nodes;
} catch (Exception e) {
// TODO: handle exception
throw new DBCException(e, session.getExecutionContext());
}
} catch (SQLException e) {
throw new DBCException(e, session.getExecutionContext());
}
......
......@@ -99,9 +99,7 @@ public class OceanbasePlanNodeJSON extends AbstractExecutionPlanNode implements
@Override
public String getNodeName() {
Object nodeName = nodeProps.get("table_name");
if (nodeName == null) {
} else {
if (nodeName != null) {
Object accessType = nodeProps.get("access_type");
if (accessType != null) {
return nodeName + " (" + accessType + ")";
......@@ -114,9 +112,6 @@ public class OceanbasePlanNodeJSON extends AbstractExecutionPlanNode implements
@Override
public Number getNodeCost() {
Object readCost = nodeProps.get("COST");
if (readCost == null) {
readCost = nodeProps.get("COST");
}
if (readCost == null) {
if (nested != null) {
long totalCost = 0;
......@@ -147,10 +142,7 @@ public class OceanbasePlanNodeJSON extends AbstractExecutionPlanNode implements
@Override
public Number getNodeRowCount() {
Object rowCount = nodeProps.get("EST.ROWS");
if (rowCount == null) {
rowCount = nodeProps.get("EST.ROWS"); // MariaDB-specific plan
if (rowCount == null) {
if (nested != null) {
if (rowCount == null && nested != null) {
long totalRC = 0;
for (OceanbasePlanNodeJSON child : nested) {
Number childRC = child.getNodeRowCount();
......@@ -160,8 +152,6 @@ public class OceanbasePlanNodeJSON extends AbstractExecutionPlanNode implements
}
return totalRC;
}
}
}
return rowCount == null ? null : CommonUtils.toLong(rowCount);
}
......@@ -205,7 +195,7 @@ public class OceanbasePlanNodeJSON extends AbstractExecutionPlanNode implements
@Override
public Object getPropertyValue(@Nullable DBRProgressMonitor monitor, String id) {
return nodeProps.get(id.toString());
return nodeProps.get(id);
}
@Override
......@@ -220,17 +210,17 @@ public class OceanbasePlanNodeJSON extends AbstractExecutionPlanNode implements
@Override
public void resetPropertyValue(@Nullable DBRProgressMonitor monitor, String id) {
// noting to do
}
@Override
public void resetPropertyValueToDefault(String id) {
// noting to do
}
@Override
public void setPropertyValue(@Nullable DBRProgressMonitor monitor, String id, Object value) {
// noting to do
}
}
......@@ -66,9 +66,11 @@ public class OceanbaseMySQLCatalog extends MySQLCatalog {
procedure == null ? null : JDBCUtils.escapeWildCards(session, procedure.getName()), "%")
.getSourceStatement();
} else {
String queryFunctionString = "select * from mysql.proc where db='%s' and type='FUNCTION' and name='%s'";
return session
.prepareStatement(String.format(queryFunctionString, owner.getName(), procedure.getName()));
String queryFunctionString = "select * from mysql.proc where db=? and type='FUNCTION' and name=?";
JDBCPreparedStatement statement = session.prepareStatement(String.format(queryFunctionString, owner.getName(), procedure.getName()));
statement.setString(1, owner.getName());
statement.setString(2, procedure.getName());
return statement;
}
}
......@@ -143,11 +145,7 @@ public class OceanbaseMySQLCatalog extends MySQLCatalog {
if (!getDataSource().supportsInformationSchema()) {
return Collections.emptyList();
}
List<MySQLProcedure> objects = new ArrayList<>();
for (OceanbaseMySQLProcedure oceanbaseMySQLProcedure : oceanbaseProceduresCache.getAllObjects(monitor, this)) {
objects.add(oceanbaseMySQLProcedure);
}
return objects;
return new ArrayList<>(oceanbaseProceduresCache.getAllObjects(monitor, this));
}
@Override
......
......@@ -94,7 +94,6 @@ public class OceanbaseMySQLDataSource extends MySQLDataSource {
if (name.equalsIgnoreCase("SHOW DB")) {
return DBUtils.findObject(getPrivileges(monitor), "Show databases", true);
}
;
return DBUtils.findObject(getPrivileges(monitor), name, true);
}
......@@ -155,11 +154,7 @@ public class OceanbaseMySQLDataSource extends MySQLDataSource {
@Override
public Collection<MySQLCatalog> getCatalogs() {
List<MySQLCatalog> catalogs = new ArrayList<>();
for (OceanbaseMySQLCatalog oceanbaseMySQLCatalog : oceanbaseCatalogCache.getCachedObjects()) {
catalogs.add(oceanbaseMySQLCatalog);
}
return catalogs;
return new ArrayList<>(oceanbaseCatalogCache.getCachedObjects());
}
static class OceanbaseCatalogCache extends JDBCObjectCache<OceanbaseMySQLDataSource, OceanbaseMySQLCatalog> {
......
......@@ -6,7 +6,6 @@ import java.util.Map;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.DBPDataSource;
import org.jkiss.dbeaver.model.edit.DBECommandContext;
import org.jkiss.dbeaver.model.edit.DBEObjectRenamer;
import org.jkiss.dbeaver.model.edit.DBEPersistAction;
import org.jkiss.dbeaver.model.exec.DBCExecutionContext;
import org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction;
......@@ -15,8 +14,7 @@ import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.model.struct.cache.DBSObjectCache;
public class OceanbaseMySQLDatabaseManager extends SQLObjectEditor<OceanbaseMySQLCatalog, OceanbaseMySQLDataSource>
implements DBEObjectRenamer<OceanbaseMySQLCatalog> {
public class OceanbaseMySQLDatabaseManager extends SQLObjectEditor<OceanbaseMySQLCatalog, OceanbaseMySQLDataSource>{
@Override
public long getMakerOptions(DBPDataSource dataSource) {
......@@ -28,17 +26,9 @@ public class OceanbaseMySQLDatabaseManager extends SQLObjectEditor<OceanbaseMySQ
return ((OceanbaseMySQLDataSource) object.getDataSource()).getOceanbaseCatalogCache();
}
@Override
public void renameObject(DBECommandContext commandContext, OceanbaseMySQLCatalog object,
Map<String, Object> options, String newName) throws DBException {
throw new DBException(
"Direct database rename is not yet implemented in MySQL. You should use export/import functions for that.");
}
@Override
protected OceanbaseMySQLCatalog createDatabaseObject(DBRProgressMonitor monitor, DBECommandContext context,
Object container, Object copyFrom, Map<String, Object> options) throws DBException {
System.out.println("11111");
return new OceanbaseMySQLCatalog((OceanbaseMySQLDataSource) container, null);
}
......
......@@ -25,6 +25,11 @@ import org.jkiss.dbeaver.model.struct.DBSEntity;
public class OceanbaseTable extends MySQLTable implements DBPObjectStatistics {
public OceanbaseTable(MySQLCatalog catalog)
{
super(catalog);
}
public OceanbaseTable(DBRProgressMonitor monitor, MySQLCatalog catalog, DBSEntity source) throws DBException {
super(monitor, catalog, source);
}
......
......@@ -49,7 +49,7 @@ public class OceanbaseConnectionPage extends ConnectionPageWithAuth implements I
private Text databaseText;
private Text tenantText;
private static ImageDescriptor logoImage = Activator.getImageDescriptor("icons/wmi_icon_big.png"); //$NON-NLS-1$
private static ImageDescriptor logoImage = Activator.getImageDescriptor("icons/ob_logo.png");
public OceanbaseConnectionPage() {
}
......@@ -157,34 +157,13 @@ public class OceanbaseConnectionPage extends ConnectionPageWithAuth implements I
setMessage(e.getMessage());
}
}
if (connectionInfo.getUrl() != null) {
urlText.setText(CommonUtils.notEmpty(connectionInfo.getUrl()));
} else {
urlText.setText("");
}
}
if (connectionInfo.getHostName() == null) {
connectionInfo.setHostName(DEFAULT_HOST);
}
if (hostText != null) {
hostText.setText(CommonUtils.notEmpty(connectionInfo.getHostName()));
}
if (portText != null) {
portText.setText(CommonUtils.notEmpty(connectionInfo.getHostPort()));
}
if (databaseText != null) {
databaseText.setText(CommonUtils.notEmpty(connectionInfo.getDatabaseName()));
}
if (tenantText != null) {
tenantText.setText(CommonUtils.notEmpty(connectionInfo.getServerName()));
}
UIUtils.asyncExec(() -> {
// Set first control
if (CommonUtils.isEmpty(site.getDriver().getSampleURL())) {
urlText.setFocus();
}
});
super.loadSettings();
}
......
......@@ -264,6 +264,7 @@
<setEntry value="org.jkiss.dbeaver.ext.mysql.ui@default:default"/>
<setEntry value="org.jkiss.dbeaver.ext.mysql@default:default"/>
<setEntry value="org.jkiss.dbeaver.ext.netezza@default:default"/>
<setEntry value="org.jkiss.dbeaver.ext.oceanbase@default:default"/>
<setEntry value="org.jkiss.dbeaver.ext.ocient@default:default"/>
<setEntry value="org.jkiss.dbeaver.ext.opendistro@default:default"/>
<setEntry value="org.jkiss.dbeaver.ext.oracle.ui@default:default"/>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册