尝试使用 MySQL 函数时返回以下错误。
#1418 - This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its
declaration and binary logging is enabled (you *might* want to use the less safe
log_bin_trust_function_creators variable)
我几天前开始使用复制..?不知道这对它有没有影响?!但我知道一件事——它奏效了:)
如果我尝试覆盖(再次添加函数)会发生同样的错误..
功能
DELIMITER $$
DROP FUNCTION IF EXISTS `stock_in_stock_ids` $$
CREATE DEFINER=`dynaccount`@`localhost` FUNCTION `stock_in_stock_ids`(_running_total_limit INT, _product_id INT, _group_id INT) RETURNS TEXT
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE _running_count INT default 0;
DECLARE _id INT;
DECLARE _count INT;
DECLARE _ids TEXT DEFAULT NULL;
DECLARE _cur CURSOR FOR SELECT id, count FROM stock WHERE group_id=_group_id && type=2 && product_id=_product_id ORDER BY time DESC, id DESC;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN _cur;
read_loop: LOOP
FETCH _cur INTO _id, _count;
IF done THEN
SET _ids = '0';
LEAVE read_loop;
END IF;
SET _running_count = _running_count + _count;
SET _ids = CONCAT_WS(',', _ids, _id);
IF _running_count >= _running_total_limit THEN
LEAVE read_loop;
END IF;
END LOOP read_loop;
CLOSE _cur;
RETURN _ids;
END $$
DELIMITER ;