From 200a6490914c7dd1a342cb5bf64e75e58784474e Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Mon, 24 Apr 2023 18:13:03 +0200 Subject: [PATCH] document mysql kill trigger --- .../db/MySqlDatabaseProcessorFactory.java | 24 ++++++++++++++----- .../mods/db/MySqlUserProcessorFactory.java | 19 +++++++++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/hsarback/src/de/hsadmin/mods/db/MySqlDatabaseProcessorFactory.java b/hsarback/src/de/hsadmin/mods/db/MySqlDatabaseProcessorFactory.java index a24635b..493e561 100644 --- a/hsarback/src/de/hsadmin/mods/db/MySqlDatabaseProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/db/MySqlDatabaseProcessorFactory.java @@ -15,13 +15,25 @@ import de.hsadmin.core.qserv.ProcessorException; * @author mi */ 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 { return new JDBCProcessor("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/"); } diff --git a/hsarback/src/de/hsadmin/mods/db/MySqlUserProcessorFactory.java b/hsarback/src/de/hsadmin/mods/db/MySqlUserProcessorFactory.java index 50bd68d..978f3e9 100644 --- a/hsarback/src/de/hsadmin/mods/db/MySqlUserProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/db/MySqlUserProcessorFactory.java @@ -16,6 +16,25 @@ import de.hsadmin.core.qserv.ProcessorException; */ 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 Processor createCreateProcessor(EntityManager em, T entity) throws ProcessorException { DatabaseUser dbu = (DatabaseUser) entity; assert dbu.getInstance().equals("mysql");