提交 6a8d5948 编写于 作者: S Serge Rider

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

......@@ -3,7 +3,7 @@
IEclipsePreferences#org-eclipse-ui-workbench {
preferences:
'org.jkiss.dbeaver.sql.resultset.color.cell.odd.background=COLOR_BLACK'
'org.jkiss.dbeaver.sql.resultset.color.cell.odd.background=0,0,0'
'org.jkiss.dbeaver.sql.resultset.color.cell.modified.background=180,128,128'
'org.jkiss.dbeaver.sql.resultset.color.cell.new.background=128,180,128'
'org.jkiss.dbeaver.sql.resultset.color.cell.deleted.background=128,128,180'
......@@ -12,8 +12,8 @@
'org.jkiss.dbeaver.sql.editor.color.disabled.background=0,0,0'
'org.jkiss.dbeaver.sql.editor.color.keyword.foreground=255,128,64'
'org.jkiss.dbeaver.sql.editor.color.datatype.foreground=255,255,128'
'org.jkiss.dbeaver.sql.editor.color.string.foreground=COLOR_DARK_GREEN'
'org.jkiss.dbeaver.sql.editor.color.string.foreground=144,238,144'
'org.jkiss.dbeaver.sql.editor.color.number.foreground=0,128,128'
'org.jkiss.dbeaver.sql.editor.color.comment.foreground=COLOR_DARK_GRAY'
'org.jkiss.dbeaver.sql.editor.color.delimiter.foreground=COLOR_RED'
'org.jkiss.dbeaver.sql.editor.color.comment.foreground=169,169,169'
'org.jkiss.dbeaver.sql.editor.color.delimiter.foreground=255,0,0'
}
......@@ -239,6 +239,10 @@ public class DataSourceDescriptor
return id;
}
public void setId(String id) {
this.id = id;
}
@NotNull
@Override
public DriverDescriptor getDriver()
......
......@@ -157,6 +157,9 @@ public class QMMCollectorImpl extends DefaultExecutionHandler implements QMMColl
public synchronized void handleContextOpen(@NotNull DBCExecutionContext context, boolean transactional)
{
String contextId = makeContextId(context);
if (sessionMap.containsKey(contextId)) {
log.debug("Duplicate session '" + contextId + "' open");
}
QMMSessionInfo session = new QMMSessionInfo(
context,
transactional,
......
......@@ -16,6 +16,7 @@
*/
package org.jkiss.dbeaver.ui.controls;
import org.eclipse.jface.resource.JFaceColors;
import org.eclipse.jface.viewers.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
......@@ -184,7 +185,7 @@ public abstract class ObjectViewerRenderer {
} else if (isHyperlink(cellValue)) {
// Print link
boolean isSelected = gc.getBackground().equals(selectionBackgroundColor);
prepareLinkStyle(cellValue, isSelected ? gc.getForeground() : null);
prepareLinkStyle(cellValue, isSelected ? gc.getForeground() : JFaceColors.getHyperlinkText(event.item.getDisplay()));
Rectangle textBounds;
if (event.item instanceof TreeItem) {
textBounds = ((TreeItem) event.item).getTextBounds(event.index);
......
......@@ -511,7 +511,7 @@ class ResultSetFilterPanel extends Composite implements IContentProposalProvider
editor.createPartControl(editorPH);
editor.reloadSyntaxRules();
StyledText textWidget = editor.getTextViewer().getTextWidget();
textWidget.setAlwaysShowScrollBars(false);
//textWidget.setAlwaysShowScrollBars(false);
panel.setBackground(textWidget.getBackground());
panel.addDisposeListener(new DisposeListener() {
......@@ -614,8 +614,13 @@ class ResultSetFilterPanel extends Composite implements IContentProposalProvider
}
@Override
public void mouseDown(MouseEvent e) {
showObjectInfoPopup(e);
public void mouseDown(final MouseEvent e) {
DBeaverUI.asyncExec(new Runnable() {
@Override
public void run() {
showObjectInfoPopup(e);
}
});
}
});
}
......
......@@ -834,6 +834,19 @@ public class ResultSetModel {
}
}
if (filter.getConstraints().size() != attributes.length) {
// Update visibility
for (Iterator<DBDAttributeBinding> iter = visibleAttributes.iterator(); iter.hasNext(); ) {
final DBDAttributeBinding attr = iter.next();
if (filter.getConstraint(attr, true) == null) {
// No constraint for this attribute: use default visibility
if (!isVisibleByDefault(attr)) {
iter.remove();
}
}
}
}
Collections.sort(this.visibleAttributes, POSITION_SORTER);
this.dataFilter.setWhere(filter.getWhere());
......@@ -893,7 +906,7 @@ public class ResultSetModel {
if (executionSource != null && executionSource.getDataContainer() instanceof DBSEntity) {
// Filter pseudo attributes if we query single entity
for (DBDAttributeBinding binding : this.attributes) {
if (!binding.isPseudoAttribute()) {
if (isVisibleByDefault(binding)) {
// Make visible "real" attributes
this.visibleAttributes.add(binding);
}
......@@ -903,6 +916,10 @@ public class ResultSetModel {
}
}
private static boolean isVisibleByDefault(DBDAttributeBinding binding) {
return !binding.isPseudoAttribute();
}
public DBCStatistics getStatistics() {
return statistics;
}
......
......@@ -109,6 +109,8 @@ public abstract class ConnectionWizard extends Wizard implements INewWizard {
{
DataSourceDescriptor dataSource = getPageSettings().getActiveDataSource();
DataSourceDescriptor testDataSource = new DataSourceDescriptor(dataSource);
// Generate new ID to avoid session conflicts in QM
testDataSource.setId(DataSourceDescriptor.generateNewId(dataSource.getDriver()));
try {
saveSettings(testDataSource);
......
......@@ -119,7 +119,7 @@ public class TextViewDialog extends ValueViewDialog {
textEdit.setTextLimit((int) maxSize);
}
if (readOnly) {
textEdit.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
//textEdit.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
}
GridData gd = new GridData(isForeignKey ? GridData.FILL_HORIZONTAL : GridData.FILL_BOTH);
gd.widthHint = 300;
......
......@@ -95,7 +95,11 @@ public abstract class MySQLTableBase extends JDBCTable<MySQLDataSource, MySQLCat
public Collection<MySQLTableColumn> getAttributes(@NotNull DBRProgressMonitor monitor)
throws DBException
{
List<MySQLTableColumn> columns = new ArrayList<>(getContainer().tableCache.getChildren(monitor, getContainer(), this));
List<MySQLTableColumn> childColumns = getContainer().tableCache.getChildren(monitor, getContainer(), this);
if (childColumns == null) {
return Collections.emptyList();
}
List<MySQLTableColumn> columns = new ArrayList<>(childColumns);
columns.sort(DBUtils.orderComparator());
return columns;
}
......
......@@ -31,10 +31,7 @@ import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.DBPErrorAssistant;
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
import org.jkiss.dbeaver.model.exec.DBCException;
import org.jkiss.dbeaver.model.exec.DBCQueryTransformType;
import org.jkiss.dbeaver.model.exec.DBCQueryTransformer;
import org.jkiss.dbeaver.model.exec.DBCSession;
import org.jkiss.dbeaver.model.exec.*;
import org.jkiss.dbeaver.model.exec.jdbc.*;
import org.jkiss.dbeaver.model.exec.plan.DBCPlan;
import org.jkiss.dbeaver.model.exec.plan.DBCQueryPlanner;
......@@ -124,7 +121,17 @@ public class PostgreDataSource extends JDBCDataSource implements DBSObjectSelect
if (activeDatabase != null) {
final PostgreSchema activeSchema = activeDatabase.getDefaultObject();
if (activeSchema != null) {
activeDatabase.setSearchPath(monitor, activeSchema, context);
// Check default active schema
String curDefSchema;
try (JDBCSession session = context.openSession(monitor, DBCExecutionPurpose.META, "Get context active schema")) {
curDefSchema = JDBCUtils.queryString(session, "SELECT current_schema()");
} catch (SQLException e) {
throw new DBCException(e, getDataSource());
}
if (curDefSchema == null || !curDefSchema.equals(activeSchema.getName())) {
activeDatabase.setSearchPath(monitor, activeSchema, context);
}
}
}
}
......
......@@ -188,14 +188,7 @@ public abstract class JDBCDataSource
// Initialize SQL dialect. We need to make this ASAP because once datasource is connected
// it can be tracked by QM and other monitors. We have to have correct SQL dialect.
if (sqlDialect == BasicSQLDialect.INSTANCE) {
// Initialize SQL dialect
try (JDBCSession session = DBUtils.openMetaSession(monitor, this, "Initialize SQL dialect")) {
sqlDialect = createSQLDialect(new JDBCDatabaseMetaDataImpl(session, connection.getMetaData()));
} catch (Throwable e) {
log.error("Error creating SQL dialect", e);
}
}
initializeSQLDialect(monitor, connection);
return connection;
}
catch (SQLException ex) {
......@@ -600,6 +593,17 @@ public abstract class JDBCDataSource
return new JDBCFactoryDefault();
}
protected final void initializeSQLDialect(@NotNull DBRProgressMonitor monitor, Connection connection) {
if (sqlDialect == BasicSQLDialect.INSTANCE) {
// Initialize SQL dialect
try (JDBCSession session = DBUtils.openMetaSession(monitor, this, "Initialize SQL dialect")) {
sqlDialect = createSQLDialect(new JDBCDatabaseMetaDataImpl(session, connection.getMetaData()));
} catch (Throwable e) {
log.error("Error creating SQL dialect", e);
}
}
}
/////////////////////////////////////////////////
// Error assistance
......
......@@ -80,14 +80,16 @@ public class QMUtils {
if (executionContext == null || application == null) {
return false;
} else {
QMMSessionInfo sessionInfo = application.getQueryManager().getMetaCollector().getSessionInfo(executionContext);
QMMTransactionInfo txnInfo = sessionInfo.getTransaction();
if (txnInfo != null) {
QMMTransactionSavepointInfo sp = txnInfo.getCurrentSavepoint();
QMMStatementExecuteInfo execInfo = sp.getLastExecute();
for (QMMStatementExecuteInfo exec = execInfo; exec != null && exec.getSavepoint() == sp; exec = exec.getPrevious()) {
if (exec.isTransactional()) {
return true;
QMMSessionInfo sessionInfo = getCurrentSession(executionContext);
if (sessionInfo != null) {
QMMTransactionInfo txnInfo = sessionInfo.getTransaction();
if (txnInfo != null) {
QMMTransactionSavepointInfo sp = txnInfo.getCurrentSavepoint();
QMMStatementExecuteInfo execInfo = sp.getLastExecute();
for (QMMStatementExecuteInfo exec = execInfo; exec != null && exec.getSavepoint() == sp; exec = exec.getPrevious()) {
if (exec.isTransactional()) {
return true;
}
}
}
}
......@@ -100,8 +102,8 @@ public class QMUtils {
}
public static QMMTransactionSavepointInfo getCurrentTransaction(DBCExecutionContext executionContext) {
QMMSessionInfo sessionInfo = application.getQueryManager().getMetaCollector().getSessionInfo(executionContext);
if (!sessionInfo.isClosed() && sessionInfo.isTransactional()) {
QMMSessionInfo sessionInfo = getCurrentSession(executionContext);
if (sessionInfo != null && !sessionInfo.isClosed() && sessionInfo.isTransactional()) {
QMMTransactionInfo txnInfo = sessionInfo.getTransaction();
if (txnInfo != null) {
return txnInfo.getCurrentSavepoint();
......@@ -117,8 +119,8 @@ public class QMUtils {
if (executionContext == null || application == null) {
txnMode = false;
} else {
QMMSessionInfo sessionInfo = application.getQueryManager().getMetaCollector().getSessionInfo(executionContext);
if (sessionInfo.isClosed()) {
QMMSessionInfo sessionInfo = getCurrentSession(executionContext);
if (sessionInfo == null || sessionInfo.isClosed()) {
txnMode = false;
} else if (sessionInfo.isTransactional()) {
QMMTransactionInfo txnInfo = sessionInfo.getTransaction();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册