salix/db/routines/cache/procedures/cache_calc_unlock.sql

23 lines
558 B
SQL

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`cache_calc_unlock`(IN `v_calc` INT)
proc: BEGIN
DECLARE v_cache_name VARCHAR(50);
DECLARE v_params VARCHAR(100);
IF v_calc IS NULL THEN
LEAVE proc;
END IF;
SELECT c.name, ca.params INTO v_cache_name, v_params
FROM cache c
JOIN cache_calc ca ON c.id = ca.cache_id
WHERE ca.id = v_calc;
DELETE FROM cache_calc WHERE id = v_calc;
IF v_cache_name IS NOT NULL THEN
DO RELEASE_LOCK(CONCAT_WS('/', v_cache_name, IFNULL(v_params, '')));
END IF;
END$$
DELIMITER ;