Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql存储函数冻结_Mysql_Stored Functions - Fatal编程技术网

Mysql存储函数冻结

Mysql存储函数冻结,mysql,stored-functions,Mysql,Stored Functions,我在MySQL中有一个存储函数,它可以部分工作 DELIMITER $$ DROP FUNCTION IF EXISTS `getsubdomain`$$ CREATE FUNCTION getsubdomain(page_id int(11)) RETURNS CHAR(255) DETERMINISTIC READS SQL DATA SQL SECURITY INVOKER BEGIN declare current_p_id int(11); declare current_p_pare

我在MySQL中有一个存储函数,它可以部分工作

DELIMITER $$
DROP FUNCTION IF EXISTS `getsubdomain`$$
CREATE FUNCTION getsubdomain(page_id int(11))
RETURNS CHAR(255)
DETERMINISTIC
READS SQL DATA
SQL SECURITY INVOKER
BEGIN
declare current_p_id int(11);
declare current_p_parent_id int(11);
declare current_p_address_type char(255);
declare current_p_adress char(255);
SET current_p_id = page_id;
WHILE (current_p_id) <> 0
DO
select p_parent_id, p_address_type, p_adress from opu_pages where p_id = current_p_id into current_p_parent_id, current_p_address_type, current_p_adress;
IF current_p_address_type <> ''
THEN
IF current_p_address_type = 'subdomain'
THEN
RETURN current_p_adress;
ELSE
SET current_p_id = current_p_parent_id;
END IF;
ELSE
RETURN NULL;
END IF;
END WHILE;
RETURN NULL;
END$$
DELIMITER ;

根据你的帖子,我想说你的代码正在为一些输入参数进入一个无限循环


特别是在
opu\u页面
表中的
p\u id=p\u parent\u id
current\u address\u type='subdomain'

的情况下,它是递归工作的。但当我从opu页面调用selectgetsubdomain(p_id)这样的函数时;它运行得很快,问题及时解决了。查询需要更多的执行时间吗
p_id INT
p_parent_id INT
p_address_type ENUM (path, subdomain)
p_adress VARCHAR