document mysql kill trigger

This commit is contained in:
Peter Hormanns 2023-04-24 18:13:03 +02:00
parent 0fa256f76b
commit 200a649091
2 changed files with 37 additions and 6 deletions

View File

@ -15,13 +15,25 @@ import de.hsadmin.core.qserv.ProcessorException;
* @author mi * @author mi
*/ */
public class MySqlDatabaseProcessorFactory implements EntityProcessorFactory { public class MySqlDatabaseProcessorFactory implements EntityProcessorFactory {
// public static JDBCProcessor createMySqlProcessor(String database,
// String user, String password) {
// return new JDBCProcessor("com.mysql.jdbc.Driver",
// "jdbc:mysql://localhost/" + database, user, password);
// }
/*
CREATE PROCEDURE kill_by_database (IN database_name VARCHAR(64))
BEGIN
DECLARE query_id INT;
DECLARE iteration_complete INT DEFAULT 0;
DECLARE select_cursor CURSOR FOR SELECT id FROM information_schema.processlist WHERE db = database_name;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET iteration_complete=1;
OPEN select_cursor;
cursor_loop: LOOP
FETCH select_cursor INTO query_id;
IF iteration_complete THEN
LEAVE cursor_loop;
END IF;
KILL query_id;
END LOOP;
CLOSE select_cursor;
END;
*/
public static JDBCProcessor createMySqlAdminProcessor() throws ProcessorException { public static JDBCProcessor createMySqlAdminProcessor() throws ProcessorException {
return new JDBCProcessor("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/"); return new JDBCProcessor("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/");
} }

View File

@ -16,6 +16,25 @@ import de.hsadmin.core.qserv.ProcessorException;
*/ */
public class MySqlUserProcessorFactory implements EntityProcessorFactory { public class MySqlUserProcessorFactory implements EntityProcessorFactory {
/*
CREATE PROCEDURE kill_by_user (IN user_name VARCHAR(64))
BEGIN
DECLARE query_id INT;
DECLARE iteration_complete INT DEFAULT 0;
DECLARE select_cursor CURSOR FOR SELECT id FROM information_schema.processlist WHERE user = user_name;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET iteration_complete=1;
OPEN select_cursor;
cursor_loop: LOOP
FETCH select_cursor INTO query_id;
IF iteration_complete THEN
LEAVE cursor_loop;
END IF;
KILL query_id;
END LOOP;
CLOSE select_cursor;
END;
*/
public <T extends AbstractEntity> Processor createCreateProcessor(EntityManager em, T entity) throws ProcessorException { public <T extends AbstractEntity> Processor createCreateProcessor(EntityManager em, T entity) throws ProcessorException {
DatabaseUser dbu = (DatabaseUser) entity; DatabaseUser dbu = (DatabaseUser) entity;
assert dbu.getInstance().equals("mysql"); assert dbu.getInstance().equals("mysql");