2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zoneGeo_calcTree`()
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Calculates the #path, #lft, #rgt, #sons and #depth columns of
|
|
|
|
* the #zoneGeo table. To build the tree, it uses the #parentFk
|
|
|
|
* column.
|
|
|
|
*/
|
|
|
|
DECLARE vIndex INT DEFAULT 0;
|
|
|
|
DECLARE vSons INT;
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE IF EXISTS tNestedTree;
|
|
|
|
CREATE TEMPORARY TABLE tNestedTree
|
|
|
|
SELECT id, path, lft, rgt, depth, sons
|
|
|
|
FROM zoneGeo LIMIT 0;
|
|
|
|
|
|
|
|
SET max_sp_recursion_depth = 5;
|
|
|
|
CALL zoneGeo_calcTreeRec(NULL, '/', 0, vIndex, vSons);
|
|
|
|
SET max_sp_recursion_depth = 0;
|
|
|
|
|
|
|
|
UPDATE zoneGeo z
|
|
|
|
JOIN tNestedTree t ON t.id = z.id
|
|
|
|
SET z.path = t.path,
|
|
|
|
z.lft = t.lft,
|
|
|
|
z.rgt = t.rgt,
|
|
|
|
z.depth = t.depth,
|
|
|
|
z.sons = t.sons;
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE tNestedTree;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|