提交 4325b0c2 编写于 作者: S Serge Rider

Merge remote-tracking branch 'origin/devel' into devel

......@@ -114,12 +114,12 @@ meta.org.jkiss.dbeaver.ext.exasol.model.ExasolSchema.sql.name = Create SQL
meta.org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn.dataType.name=Type
meta.org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn.stringLength.name=String Length
meta.org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn.keyseq.name=Key Sequence
meta.org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn.isDistKey.name=Is Part of the Distribution Key
meta.org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn.status.name=Status
meta.org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn.description.name=Description
meta.org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn.owner.name=Table
meta.org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn.identityValue.name=Current Value of Identity Col
meta.org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn.inUniqueKey.name=Key
meta.org.jkiss.dbeaver.ext.exasol.model.ExasolTableBase.owner.name=Owner
meta.org.jkiss.dbeaver.ext.exasol.model.ExasolTableBase.name.name=Name
......@@ -252,3 +252,10 @@ meta.org.jkiss.dbeaver.ext.exasol.model.ExasolVirtualSchema.adapterScriptName.na
meta.org.jkiss.dbeaver.ext.exasol.model.ExasolVirtualSchemaParameter.name.name=Property Name
meta.org.jkiss.dbeaver.ext.exasol.model.ExasolVirtualSchemaParameter.value.name=Property Value
meta.org.jkiss.dbeaver.model.struct.rdb.DBSTableConstraintColumn.attribute.name=Column Name
meta.org.jkiss.dbeaver.model.struct.rdb.DBSTableConstraintColumn.ordinalPosition.name=Seq
meta.org.jkiss.dbeaver.model.impl.struct.AbstractTableConstraint.description.name=Description
meta.org.jkiss.dbeaver.model.impl.struct.AbstractTableConstraint.constraintType.name=Constraint Type
......@@ -357,22 +357,6 @@
</extension>
<extension
point="org.jkiss.dbeaver.databaseEditor">
<editor id="source.declaration"
class="org.jkiss.dbeaver.ui.editors.sql.SQLSourceViewer"
label="%editor.source.declaration.name"
description="%editor.source.declaration.description"
icon="#sql_text"
position="additions_middle"
contributor="org.jkiss.dbeaver.ui.editors.sql.SQLEditorContributorNested"
type="folder"
embeddable="true">
<objectType
name="org.jkiss.dbeaver.ext.exasol.model.ExasolScript">
</objectType>
<objectType
name="org.jkiss.dbeaver.ext.exasol.model.ExasolView">
</objectType>
</editor>
<editor
class="org.jkiss.dbeaver.ui.editors.sql.SQLSourceViewer"
contributor="org.jkiss.dbeaver.ui.editors.sql.SQLEditorContributorNested"
......@@ -391,6 +375,9 @@
<objectType
name="org.jkiss.dbeaver.ext.exasol.model.ExasolSchema">
</objectType>
<objectType
name="org.jkiss.dbeaver.ext.exasol.model.ExasolScript">
</objectType>
</editor>
<manager
class="org.jkiss.dbeaver.ext.exasol.manager.ExasolTableManager"
......
......@@ -50,8 +50,13 @@ public class ExasolConstants {
public static final String DRV_USE_BACKUP_HOST_LIST = DBConstants.INTERNAL_PROP_PREFIX + "useBackupHostList";
public static final DBDPseudoAttribute PSEUDO_ATTR_RID_BIT = new DBDPseudoAttribute(DBDPseudoAttributeType.ROWID,
"ROWID", "ROWID", "row_id", "Unique physical row identifier", true);
public static final DBDPseudoAttribute PSEUDO_ATTR_ROWID = new DBDPseudoAttribute(
DBDPseudoAttributeType.ROWID,
"ROWID",
"$alias.ROWID",
null,
"Unique row identifier",
true);
public static final Map<String,String> encoding = new HashMap<String, String>();
public static final ArrayList<String> encodings = new ArrayList<String>();
......
......@@ -35,6 +35,7 @@ import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.utils.CommonUtils;
import java.math.BigDecimal;
import java.util.List;
/**
......@@ -94,7 +95,7 @@ public class ExasolTableColumnManager extends SQLTableColumnManager<ExasolTableC
if (!command.getProperties().isEmpty()) {
final String deltaSQL = exasolColumn.getName() + " " + exasolColumn.getFormatType()
+ " " + (exasolColumn.getDefaultValue() == null ? "" : " DEFAULT " + exasolColumn.getDefaultValue())
+ " " + (exasolColumn.isIdentity() ? " IDENTITY " + exasolColumn.getIdentityValue().toString() : "")
+ " " + formatIdentiy(exasolColumn.isAutoGenerated(), exasolColumn.getIdentityValue())
+ " " + (exasolColumn.isRequired() ? "NOT NULL" : "NULL");
if (!deltaSQL.isEmpty()) {
String sqlAlterColumn = String.format(SQL_ALTER, exasolColumn.getTable().getFullyQualifiedName(DBPEvaluationContext.DDL), deltaSQL);
......@@ -109,6 +110,22 @@ public class ExasolTableColumnManager extends SQLTableColumnManager<ExasolTableC
}
}
private String formatIdentiy(Boolean isAutoGenerated,BigDecimal identityValue)
{
String ret = "";
if (isAutoGenerated)
{
ret = "IDENTITY ";
if (identityValue != null)
{
ret = ret + identityValue.toString() + " ";
}
}
return ret;
}
// -------
// Helpers
......
......@@ -136,7 +136,7 @@ public class ExasolScript extends ExasolObject<DBSObject> implements DBSProcedur
}
@NotNull
@Property(viewable = false, order = 15)
@Property(hidden = true)
public String getSql() {
return this.scriptSQL;
}
......
......@@ -26,16 +26,23 @@ import org.jkiss.dbeaver.ext.exasol.editors.ExasolSourceObject;
import org.jkiss.dbeaver.ext.exasol.tools.ExasolUtils;
import org.jkiss.dbeaver.model.DBPNamedObject2;
import org.jkiss.dbeaver.model.DBPRefreshableObject;
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.exec.DBCException;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCSession;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils;
import org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCStructCache;
import org.jkiss.dbeaver.model.meta.Association;
import org.jkiss.dbeaver.model.meta.Property;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.model.struct.DBSObjectState;
import org.jkiss.dbeaver.model.struct.rdb.DBSTableForeignKey;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Collection;
......@@ -46,65 +53,154 @@ public class ExasolTable extends ExasolTableBase implements DBPRefreshableObject
private Boolean hasDistKey;
private Timestamp lastCommit;
private long sizeRaw;
private long sizeCompressed;
private float deletePercentage;
private Timestamp createTime;
private Boolean hasRead;
private static String readAdditionalInfo = "select * from ("
+ "select" +
" table_schema," +
" table_name," +
" table_owner," +
" table_has_distribution_key," +
" table_comment," +
" delete_percentage," +
" o.created," +
" o.last_commit," +
" s.raw_object_size," +
" s.mem_object_size," +
" s.object_type" +
" from" +
" EXA_ALL_OBJECTS o" +
" inner join" +
" EXA_ALL_TABLES T" +
" on" +
" o.root_name = t.table_schema and" +
" t.table_name = o.object_name and" +
" o.object_type = 'TABLE'" +
" inner join " +
" EXA_ALL_OBJECT_SIZES s" +
" on" +
" o.root_name = s.root_name and" +
" o.object_name = s.object_name and" +
" o.object_type = s.object_type" +
" where o.root_name = ? and o.object_name = ? and t.table_schema = ? and t.table_name = ?" +
" union all "
+ " select schema_name as table_schema,"
+ " object_name as table_name,"
+ " 'SYS' as table_owner,"
+ " false as table_has_distribution_key,"
+ " object_comment as table_comment,"
+ " 0 as delete_percentage,"
+ " cast( null as timestamp) as created,"
+ " cast( null as timestamp) as last_commit,"
+ " 0 as raw_object_size,"
+ " 0 as mem_object_size,"
+ " object_type"
+ " from SYS.EXA_SYSCAT WHERE object_type = 'TABLE' and schema_name = ? and object_name = ?"
+ ") as o"
+ " order by table_schema,o.table_name";
public ExasolTable(DBRProgressMonitor monitor, ExasolSchema schema, ResultSet dbResult) {
super(monitor, schema, dbResult);
this.hasDistKey = JDBCUtils.safeGetBoolean(dbResult, "TABLE_HAS_DISTRIBUTION_KEY");
this.lastCommit = JDBCUtils.safeGetTimestamp(dbResult, "LAST_COMMIT");
this.sizeRaw = JDBCUtils.safeGetLong(dbResult, "RAW_OBJECT_SIZE");
this.sizeCompressed = JDBCUtils.safeGetLong(dbResult, "MEM_OBJECT_SIZE");
this.deletePercentage = JDBCUtils.safeGetFloat(dbResult, "DELETE_PERCENTAGE");
this.createTime = JDBCUtils.safeGetTimestamp(dbResult, "CREATED");
hasRead=false;
}
public ExasolTable(ExasolSchema schema, String name) {
super(schema, name, false);
hasRead=false;
}
private void read() throws DBCException
{
JDBCSession session = DBUtils.openMetaSession(VoidProgressMonitor.INSTANCE, getDataSource(), "Read Table Details");
try (JDBCPreparedStatement stmt = session.prepareStatement(readAdditionalInfo))
{
stmt.setString(1, this.getSchema().getName());
stmt.setString(2, this.getName());
stmt.setString(3, this.getSchema().getName());
stmt.setString(4, this.getName());
stmt.setString(5, this.getSchema().getName());
stmt.setString(6, this.getName());
try (JDBCResultSet dbResult = stmt.executeQuery())
{
dbResult.next();
this.hasDistKey = JDBCUtils.safeGetBoolean(dbResult, "TABLE_HAS_DISTRIBUTION_KEY");
this.lastCommit = JDBCUtils.safeGetTimestamp(dbResult, "LAST_COMMIT");
this.sizeRaw = JDBCUtils.safeGetLong(dbResult, "RAW_OBJECT_SIZE");
this.sizeCompressed = JDBCUtils.safeGetLong(dbResult, "MEM_OBJECT_SIZE");
this.deletePercentage = JDBCUtils.safeGetFloat(dbResult, "DELETE_PERCENTAGE");
this.createTime = JDBCUtils.safeGetTimestamp(dbResult, "CREATED");
this.hasRead = true;
}
} catch (SQLException e) {
throw new DBCException(e,getDataSource());
}
}
@Override
public void refreshObjectState(DBRProgressMonitor monitor)
throws DBCException
{
this.read();
super.refreshObjectState(monitor);
}
// -----------------
// Properties
// -----------------
@Property(viewable = false, editable = false, order = 90, category = ExasolConstants.CAT_BASEOBJECT)
public Boolean getHasDistKey() {
public Boolean getHasDistKey() throws DBCException {
if (! hasRead)
read();
return hasDistKey;
}
@Property(viewable = false, editable = false, order = 100, category = ExasolConstants.CAT_BASEOBJECT)
public Timestamp getLastCommit() {
public Timestamp getLastCommit() throws DBCException {
if (! hasRead)
read();
return lastCommit;
}
@Property(viewable = false, editable = false, order = 100, category = ExasolConstants.CAT_DATETIME)
public Timestamp getCreateTime() {
public Timestamp getCreateTime() throws DBCException {
if (! hasRead)
read();
return createTime;
}
@Property(viewable = false, editable = false, order = 150, category = ExasolConstants.CAT_STATS)
public String getRawsize() {
public String getRawsize() throws DBCException {
if (! hasRead)
read();
return ExasolUtils.humanReadableByteCount(sizeRaw, true);
}
@Property(viewable = false, editable = false, order = 200, category = ExasolConstants.CAT_STATS)
public String getCompressedsize() {
public String getCompressedsize() throws DBCException {
if (! hasRead)
read();
return ExasolUtils.humanReadableByteCount(sizeCompressed, true);
}
@Property(viewable = false, editable = false, order = 250, category = ExasolConstants.CAT_STATS)
public float getDeletePercentage() {
public float getDeletePercentage() throws DBCException {
if (! hasRead)
read();
return this.deletePercentage;
}
}
// -----------------
// Associations
// -----------------
......
......@@ -46,7 +46,6 @@ import java.util.Collections;
public abstract class ExasolTableBase extends JDBCTable<ExasolDataSource, ExasolSchema> implements DBPNamedObject2, DBPRefreshableObject, ExasolStatefulObject {
private String owner;
private String remarks;
private String objectType;
......@@ -58,9 +57,8 @@ public abstract class ExasolTableBase extends JDBCTable<ExasolDataSource, Exasol
public ExasolTableBase(DBRProgressMonitor monitor, ExasolSchema schema, ResultSet dbResult) {
super(schema, true);
setName(JDBCUtils.safeGetString(dbResult, "TABLE_NAME"));
this.owner = JDBCUtils.safeGetString(dbResult, "TABLE_OWNER");
this.remarks = JDBCUtils.safeGetString(dbResult, "TABLE_COMMENT");
this.objectType = JDBCUtils.safeGetString(dbResult, "OBJECT_TYPE");
this.remarks = JDBCUtils.safeGetString(dbResult, "REMARKS");
this.objectType = JDBCUtils.safeGetString(dbResult, "TABLE_TYPE");
}
......@@ -139,12 +137,6 @@ public abstract class ExasolTableBase extends JDBCTable<ExasolDataSource, Exasol
return super.getContainer();
}
@Property(viewable = true, editable = false, order = 3)
public String getOwner() {
return owner;
}
// -----------------
// Associations (Imposed from DBSTable). In Exasol, Most of objects "derived"
// from Tables don't have those..
......
......@@ -28,21 +28,26 @@ import org.jkiss.dbeaver.model.DBPHiddenObject;
import org.jkiss.dbeaver.model.DBPNamedObject2;
import org.jkiss.dbeaver.model.impl.DBPositiveNumberTransformer;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils;
import org.jkiss.dbeaver.model.impl.jdbc.struct.JDBCColumnKeyType;
import org.jkiss.dbeaver.model.impl.jdbc.struct.JDBCTableColumn;
import org.jkiss.dbeaver.model.meta.Property;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
import org.jkiss.dbeaver.model.struct.DBSDataType;
import org.jkiss.dbeaver.model.struct.DBSTypedObjectEx;
import org.jkiss.dbeaver.model.struct.rdb.DBSTableColumn;
import org.jkiss.utils.CommonUtils;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
/**
* @author Karl Griesser
*/
public class ExasolTableColumn extends JDBCTableColumn<ExasolTableBase>
implements DBSTableColumn, DBSTypedObjectEx, DBPHiddenObject, DBPNamedObject2 {
implements DBSTableColumn, DBSTypedObjectEx, DBPHiddenObject, DBPNamedObject2, JDBCColumnKeyType {
private ExasolDataType dataType;
private Boolean identity;
......@@ -75,7 +80,6 @@ public class ExasolTableColumn extends JDBCTableColumn<ExasolTableBase>
this.identityValue = JDBCUtils.safeGetBigDecimal(dbResult, "COLUMN_IDENTITY");
this.remarks = JDBCUtils.safeGetString(dbResult, "COLUMN_COMMENT");
this.dataType = tableBase.getDataSource().getDataType(monitor, JDBCUtils.safeGetString(dbResult, "TYPE_NAME"));
this.keySeq = JDBCUtils.safeGetInteger(dbResult, "KEY_SEQ");
this.changed = true;
......@@ -211,11 +215,6 @@ public class ExasolTableColumn extends JDBCTableColumn<ExasolTableBase>
super.setDefaultValue(defaultValue);
}
@Property(viewable = true, editable = true, updatable = true, order = 45)
public Boolean isIdentity() {
return identity;
}
public void setIdentity(Boolean identity) {
this.identity = identity;
}
......@@ -231,11 +230,6 @@ public class ExasolTableColumn extends JDBCTableColumn<ExasolTableBase>
this.remarks = remarks;
}
@Property(viewable = false, order = 120)
public Integer getKeySeq() {
return keySeq;
}
@Property(viewable = false, order = 121)
public Boolean isDistKey() {
return isInDistKey;
......@@ -247,6 +241,18 @@ public class ExasolTableColumn extends JDBCTableColumn<ExasolTableBase>
public boolean isHidden() {
return false;
}
@Override
@Property(viewable = true, editable = true, updatable = true, order = 45)
public boolean isAutoGenerated()
{
return this.identity;
}
public void setAutoGenerated(Boolean identity)
{
this.identity = identity;
}
public String getFormatType() {
if (changed) {
......@@ -264,5 +270,34 @@ public class ExasolTableColumn extends JDBCTableColumn<ExasolTableBase>
return this.formatType;
}
@Override
@Property(viewable = true, order = 80)
public boolean isInUniqueKey()
{
ExasolTableBase table = (ExasolTable) getTable();
try {
final Collection<ExasolTableUniqueKey> uniqueKeysCache = table.getConstraints(VoidProgressMonitor.INSTANCE);
if (!CommonUtils.isEmpty(uniqueKeysCache))
{
for (ExasolTableUniqueKey key : uniqueKeysCache)
{
if (key.hasColumn(this))
return true;
}
}
} catch ( DBException e)
{
return false;
}
return false;
}
@Override
public boolean isInReferenceKey()
{
// don't need this one
return false;
}
}
......@@ -31,6 +31,7 @@ import org.jkiss.dbeaver.model.meta.Property;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.struct.DBSEntityAttributeRef;
import org.jkiss.dbeaver.model.struct.DBSEntityConstraintType;
import org.jkiss.dbeaver.model.struct.DBSEntityReferrer;
import java.sql.ResultSet;
import java.util.List;
......@@ -38,7 +39,7 @@ import java.util.List;
/**
* @author Karl Griesser
*/
public class ExasolTableUniqueKey extends JDBCTableConstraint<ExasolTable> {
public class ExasolTableUniqueKey extends JDBCTableConstraint<ExasolTable> implements DBSEntityReferrer {
private String owner;
private Boolean enabled;
......@@ -117,10 +118,22 @@ public class ExasolTableUniqueKey extends JDBCTableConstraint<ExasolTable> {
return owner;
}
@Property(viewable = false, editable = false)
@Property(viewable = true, editable = false)
public Boolean getEnabled() {
return enabled;
}
public boolean hasColumn(ExasolTableColumn column)
{
if (this.columns != null) {
for (ExasolTableKeyColumn constColumn : columns) {
if (constColumn.getAttribute() == column) {
return true;
}
}
}
return false;
}
}
......@@ -24,6 +24,7 @@ import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.ext.exasol.model.ExasolSchema;
import org.jkiss.dbeaver.ext.exasol.model.ExasolTable;
import org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCDatabaseMetaData;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCSession;
......@@ -35,131 +36,69 @@ import java.sql.SQLException;
/**
* @author Karl
*/
public final class ExasolTableCache extends JDBCStructCache<ExasolSchema, ExasolTable, ExasolTableColumn> {
public final class ExasolTableCache
extends JDBCStructCache<ExasolSchema, ExasolTable, ExasolTableColumn> {
private static final String SQL_TABS =
"select * from ("
+ "select" +
" table_schema," +
" table_name," +
" table_owner," +
" table_has_distribution_key," +
" table_comment," +
" delete_percentage," +
" o.created," +
" o.last_commit," +
" s.raw_object_size," +
" s.mem_object_size," +
" s.object_type" +
" from" +
" EXA_ALL_OBJECTS o" +
" inner join" +
" EXA_ALL_TABLES T" +
" on" +
" o.root_name = t.table_schema and" +
" t.table_name = o.object_name and" +
" o.object_type = 'TABLE'" +
" inner join " +
" EXA_ALL_OBJECT_SIZES s" +
" on" +
" o.root_name = s.root_name and" +
" o.object_name = s.object_name and" +
" o.object_type = s.object_type" +
" where o.root_name = ? and t.table_schema = ?" +
" union all "
+ " select schema_name as table_schema,"
+ " object_name as table_name,"
+ " 'SYS' as table_owner,"
+ " false as table_has_distribution_key,"
+ " object_comment as table_comment,"
+ " 0 as delete_percentage,"
+ " cast( null as timestamp) as created,"
+ " cast( null as timestamp) as last_commit,"
+ " 0 as raw_object_size,"
+ " 0 as mem_object_size,"
+ " object_type"
+ " from SYS.EXA_SYSCAT WHERE object_type = 'TABLE' and schema_name = ?"
+ ") as o"
+ " order by table_schema,o.table_name";
// TODO: change to "$ODBCJDBC"."ALL_COLUMNS"
private static final String SQL_COLS_TAB =
"select\r\n" +
" c.*,\r\n" +
" cc.ordinal_position as KEY_SEQ\r\n" +
"from\r\n" +
" \"$ODBCJDBC\".\"ALL_COLUMNS\" c\r\n" +
" left outer join\r\n" +
" EXA_ALL_CONSTRAINT_COLUMNS cc\r\n" +
" on\r\n" +
" c.table_name = cc.constraint_table and\r\n" +
" c.table_schem = cc.constraint_schema and\r\n " +
" cc.constraint_type = 'PRIMARY KEY' and\r\n" +
" cc.COLUMN_NAME = c.COLUMN_NAME\r\n" +
"where\r\n" +
" table_schem = ? and\r\n" +
" table_name = ?\r\n" +
"order by\r\n" +
" c.ordinal_position";
// TODO: change to "$ODBCJDBC"."ALL_COLUMNS"
private static final String SQL_COLS_ALL = "select\r\n" +
" c.*,\r\n" +
" cc.ordinal_position as KEY_SEQ\r\n" +
"from\r\n" +
" \"$ODBCJDBC\".\"ALL_COLUMNS\" c\r\n" +
" left outer join\r\n" +
" EXA_ALL_CONSTRAINT_COLUMNS cc\r\n" +
" on\r\n" +
" c.table_name = cc.constraint_table and\r\n" +
" c.table_schem = cc.constraint_schema and\r\n " +
" cc.constraint_type = 'PRIMARY KEY' and\r\n" +
" cc.COLUMN_NAME = c.COLUMN_NAME\r\n" +
"where\r\n" +
" table_schem = ? and\r\n" +
"order by\r\n" +
" table_name,c.ordinal_position";
private static final String SQL_COLS_TAB = "select " + " c.* " + "from "
+ " \"$ODBCJDBC\".\"ALL_COLUMNS\" c " + "where "
+ " table_schem = ? and " + " table_name = ? " + "order by "
+ " c.ordinal_position";
private static final String SQL_COLS_ALL = "select " + " c.* " + "from "
+ " \"$ODBCJDBC\".\"ALL_COLUMNS\" c " + "where "
+ " table_schem = ?" + "order by "
+ " table_name,c.ordinal_position";
public ExasolTableCache() {
super("TABLE_NAME");
}
public ExasolTableCache()
{
super("TABLE_NAME");
}
@Override
protected JDBCStatement prepareObjectsStatement(@NotNull JDBCSession session, @NotNull ExasolSchema exasolSchema) throws SQLException {
final JDBCPreparedStatement dbstat = session.prepareStatement(SQL_TABS);
dbstat.setString(1, exasolSchema.getName());
dbstat.setString(2, exasolSchema.getName());
dbstat.setString(3, exasolSchema.getName());
return dbstat;
}
@Override
protected JDBCStatement prepareObjectsStatement(
@NotNull JDBCSession session, @NotNull ExasolSchema exasolSchema)
throws SQLException
{
JDBCDatabaseMetaData meta = session.getMetaData();
@Override
protected JDBCStatement prepareChildrenStatement(@NotNull JDBCSession session, @NotNull ExasolSchema exasolSchema, @Nullable ExasolTable exasolTable)
throws SQLException {
String sql;
return meta.getTables("EXA_DB", exasolSchema.getName(), null,
new String[] { "TABLE" }).getSourceStatement();
}
if (exasolTable != null)
sql = SQL_COLS_TAB;
else
sql = SQL_COLS_ALL;
@Override
protected JDBCStatement prepareChildrenStatement(
@NotNull JDBCSession session, @NotNull ExasolSchema exasolSchema,
@Nullable ExasolTable exasolTable) throws SQLException
{
String sql;
JDBCPreparedStatement dbstat = session.prepareStatement(sql);
dbstat.setString(1, exasolSchema.getName());
if (exasolTable != null)
dbstat.setString(2, exasolTable.getName());
if (exasolTable != null)
sql = SQL_COLS_TAB;
else
sql = SQL_COLS_ALL;
return dbstat;
}
JDBCPreparedStatement dbstat = session.prepareStatement(sql);
dbstat.setString(1, exasolSchema.getName());
if (exasolTable != null)
dbstat.setString(2, exasolTable.getName());
@Override
protected ExasolTableColumn fetchChild(@NotNull JDBCSession session, @NotNull ExasolSchema owner, @NotNull ExasolTable parent,
JDBCResultSet dbResult) throws SQLException, DBException {
return new ExasolTableColumn(session.getProgressMonitor(), parent, dbResult);
}
return dbstat;
}
@Override
protected ExasolTableColumn fetchChild(@NotNull JDBCSession session,
@NotNull ExasolSchema owner, @NotNull ExasolTable parent,
JDBCResultSet dbResult) throws SQLException, DBException
{
return new ExasolTableColumn(session.getProgressMonitor(), parent,
dbResult);
}
@Override
protected ExasolTable fetchObject(@NotNull JDBCSession session, @NotNull ExasolSchema owner, @NotNull JDBCResultSet resultSet)
throws SQLException, DBException {
return new ExasolTable(session.getProgressMonitor(), owner, resultSet);
}
@Override
protected ExasolTable fetchObject(@NotNull JDBCSession session,
@NotNull ExasolSchema owner, @NotNull JDBCResultSet resultSet)
throws SQLException, DBException
{
return new ExasolTable(session.getProgressMonitor(), owner, resultSet);
}
}
......@@ -115,9 +115,18 @@ public final class ExasolTableUniqueKeyCache
log.debug("Column '" + columnName + "' not found in table '" + exasolTable.getFullyQualifiedName(DBPEvaluationContext.UI) + "' ??");
return null;
} else {
/* verify that the column is not null -> even though it is not in the meta data
* Exasol always verify not null for columns in a PK
* this is necessary for the automatic unique identifiers detection to work
*/
tableColumn.setRequired(true);
return new ExasolTableKeyColumn[]{
new ExasolTableKeyColumn(object, tableColumn, JDBCUtils.safeGetInteger(dbResult, "ORDINAL_POSITION"))
};
}
}
......
......@@ -63,7 +63,7 @@ public class ExasolViewCache extends JDBCStructCache<ExasolSchema, ExasolView, E
+ " ) "
+ "order by table_name";
private static final String SQL_COLS_VIEW = "SELECT c.*,CAST(NULL AS INTEGER) as key_seq FROM \"$ODBCJDBC\".\"ALL_COLUMNS\" c WHERE c.table_SCHEM = ? AND c.TABLE_name = ? order by ORDINAL_POSITION";
private static final String SQL_COLS_ALL = "SELECT c.*,CAST(NULL AS INTEGER) as key_seq FROM \"$ODBCJDBC\\.\"ALL_COLUMNS\" c WHERE c.table_SCHEM = ? order by c.TABLE_name,ORDINAL_POSITION";
private static final String SQL_COLS_ALL = "SELECT c.*,CAST(NULL AS INTEGER) as key_seq FROM \"$ODBCJDBC\".\"ALL_COLUMNS\" c WHERE c.table_SCHEM = ? order by c.TABLE_name,ORDINAL_POSITION";
public ExasolViewCache() {
......
......@@ -5,7 +5,7 @@ Bundle-SymbolicName: org.jkiss.dbeaver.ext.lang;singleton:=true
Bundle-Version: 1.0.0
Require-Bundle: org.eclipse.ui,
org.jkiss.dbeaver.model,
org.jkiss.utils
org.jkiss.utils,
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-Vendor: JKISS
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册