use of org.jkiss.dbeaver.ext.postgresql.model.PostgreProcedure in project dbeaver by dbeaver.
the class PostgreResolver method resolveContext.
@Override
public Map<String, Object> resolveContext(DBSObject databaseObject) {
HashMap<String, Object> context = new HashMap<String, Object>();
if (databaseObject instanceof PostgreProcedure) {
PostgreProcedure procedure = (PostgreProcedure) databaseObject;
context.put(DBGController.PROCEDURE_OID, procedure.getObjectId());
context.put(DBGController.PROCEDURE_NAME, procedure.getName());
PostgreSchema schema = procedure.getContainer();
if (schema != null) {
context.put(DBGController.SCHEMA_NAME, schema.getName());
}
PostgreDatabase database = procedure.getDatabase();
if (database != null) {
context.put(DBGController.DATABASE_NAME, database.getName());
}
}
return context;
}
use of org.jkiss.dbeaver.ext.postgresql.model.PostgreProcedure in project dbeaver by serge-rider.
the class PostgreProcedureManager method addObjectRenameActions.
@Override
protected void addObjectRenameActions(DBRProgressMonitor monitor, DBCExecutionContext executionContext, List<DBEPersistAction> actions, ObjectRenameCommand command, Map<String, Object> options) {
PostgreProcedure procedure = command.getObject();
actions.add(new SQLDatabasePersistAction("Rename function", "ALTER " + command.getObject().getProcedureTypeName() + " " + DBUtils.getQuotedIdentifier(procedure.getSchema()) + "." + PostgreProcedure.makeOverloadedName(procedure.getSchema(), command.getOldName(), procedure.getParameters(monitor), true, false) + " RENAME TO " + DBUtils.getQuotedIdentifier(procedure.getDataSource(), command.getNewName())));
}
use of org.jkiss.dbeaver.ext.postgresql.model.PostgreProcedure in project dbeaver by serge-rider.
the class PostgreDebugSession method attach.
/**
* This method attach debug session to debug object (procedure) and wait
* forever while target or any (depend on targetPID) session will run target
* procedure
*/
public void attach(DBRProgressMonitor monitor, Map<String, Object> configuration) throws DBException {
if (!checkDebugPlagin(monitor)) {
throw new DBGException("PostgreSQL debug plugin is not installed on the server.\n" + "Refer to this WIKI article for installation instructions:\n" + "https://github.com/dbeaver/dbeaver/wiki/PGDebugger#installation");
}
log.debug("Attaching...");
functionOid = CommonUtils.toInt(configuration.get(PostgreDebugConstants.ATTR_FUNCTION_OID));
log.debug(String.format("Function OID %d", functionOid));
boolean global = isGlobalSession(configuration);
if (global) {
int processId = CommonUtils.toInt(configuration.get(PostgreDebugConstants.ATTR_ATTACH_PROCESS));
attachKind = PostgreDebugAttachKind.GLOBAL;
attachGlobal(monitor, functionOid, processId);
log.debug("Global attached");
} else {
attachKind = PostgreDebugAttachKind.LOCAL;
PostgreProcedure function = PostgreSqlDebugCore.resolveFunction(monitor, controllerConnection.getDataSource().getContainer(), configuration);
List<String> parameterValues = (List<String>) configuration.get(PostgreDebugConstants.ATTR_FUNCTION_PARAMETERS);
attachLocal(monitor, function, parameterValues);
log.debug("Local attached");
}
}
use of org.jkiss.dbeaver.ext.postgresql.model.PostgreProcedure in project dbeaver by serge-rider.
the class PostgreSqlDebugCore method resolveFunction.
public static PostgreProcedure resolveFunction(DBRProgressMonitor monitor, DBPDataSourceContainer dsContainer, Map<String, Object> configuration) throws DBException {
if (!dsContainer.isConnected()) {
dsContainer.connect(monitor, true, true);
}
long functionId = CommonUtils.toLong(configuration.get(PostgreDebugConstants.ATTR_FUNCTION_OID));
String databaseName = (String) configuration.get(PostgreDebugConstants.ATTR_DATABASE_NAME);
String schemaName = (String) configuration.get(PostgreDebugConstants.ATTR_SCHEMA_NAME);
PostgreDataSource ds = (PostgreDataSource) dsContainer.getDataSource();
PostgreDatabase database = ds.getDatabase(databaseName);
if (database != null) {
PostgreSchema schema = database.getSchema(monitor, schemaName);
if (schema != null) {
PostgreProcedure function = schema.getProcedure(monitor, functionId);
if (function != null) {
return function;
}
throw new DBException("Function " + functionId + " not found in schema " + schemaName);
} else {
throw new DBException("Schema '" + schemaName + "' not found in database " + databaseName);
}
} else {
throw new DBException("Database '" + databaseName + "' not found");
}
}
use of org.jkiss.dbeaver.ext.postgresql.model.PostgreProcedure in project dbeaver by dbeaver.
the class PostgreSqlDebugCore method resolveFunction.
public static PostgreProcedure resolveFunction(DBRProgressMonitor monitor, DBPDataSourceContainer dsContainer, Map<String, Object> configuration) throws DBException {
if (!dsContainer.isConnected()) {
dsContainer.connect(monitor, true, true);
}
long functionId = CommonUtils.toLong(configuration.get(PostgreDebugConstants.ATTR_FUNCTION_OID));
String databaseName = (String) configuration.get(PostgreDebugConstants.ATTR_DATABASE_NAME);
String schemaName = (String) configuration.get(PostgreDebugConstants.ATTR_SCHEMA_NAME);
PostgreDataSource ds = (PostgreDataSource) dsContainer.getDataSource();
PostgreDatabase database = ds.getDatabase(databaseName);
if (database != null) {
PostgreSchema schema = database.getSchema(monitor, schemaName);
if (schema != null) {
PostgreProcedure function = schema.getProcedure(monitor, functionId);
if (function != null) {
return function;
}
throw new DBException("Function " + functionId + " not found in schema " + schemaName);
} else {
throw new DBException("Schema '" + schemaName + "' not found in database " + databaseName);
}
} else {
throw new DBException("Database '" + databaseName + "' not found");
}
}
Aggregations