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