diff --git a/db/routines/floranet/procedures/catalogue_get.sql b/db/routines/floranet/procedures/catalogue_get.sql index b6ec61522..e45fa7ddf 100644 --- a/db/routines/floranet/procedures/catalogue_get.sql +++ b/db/routines/floranet/procedures/catalogue_get.sql @@ -4,7 +4,7 @@ DELIMITER $$ $$ CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.catalogue_get(vLanded DATE, vPostalCode VARCHAR(15)) READS SQL DATA -BEGIN +proc:BEGIN /** * Returns list, price and all the stuff regarding the floranet items * @@ -12,10 +12,22 @@ BEGIN * @param vPostalCode Delivery address postal code */ DECLARE vLastCatalogueFk INT; + DECLARE vLockName VARCHAR(20); + DECLARE vLockTime INT; - START TRANSACTION; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + DO RELEASE_LOCK(vLockName); - SELECT * FROM catalogue FOR UPDATE; + RESIGNAL; + END; + + SET vLockName = 'catalogue_get'; + SET vLockTime = 15; + + IF NOT GET_LOCK(vLockName, vLockTime) THEN + LEAVE proc; + END IF; SELECT MAX(id) INTO vLastCatalogueFk FROM catalogue; @@ -46,7 +58,7 @@ BEGIN FROM catalogue WHERE id > IFNULL(vLastCatalogueFk,0); - COMMIT; + DO RELEASE_LOCK(vLockName); END$$ DELIMITER ; diff --git a/db/routines/floranet/procedures/sliders_get.sql b/db/routines/floranet/procedures/sliders_get.sql index 2f77b8534..bd791dec7 100644 --- a/db/routines/floranet/procedures/sliders_get.sql +++ b/db/routines/floranet/procedures/sliders_get.sql @@ -13,7 +13,8 @@ BEGIN i.longName FROM vn.item i JOIN vn.itemType it ON it.id = i.typeFk - WHERE it.code IN ('FNR','FNP'); + WHERE it.code IN ('FNR','FNP') + LIMIT 3; END$$ DELIMITER ; \ No newline at end of file