Доброго времени суток, скидываю на ваш суд функцию:
DROP PROCEDURE IF EXISTS `set_auth3`;
DELIMITER $$
CREATE PROCEDURE `set_auth3` (IN usr_ip VARCHAR(15), IN auth_properties VARCHAR(255))
BEGIN
DECLARE usr_id INT;
DECLARE uid_ip VARCHAR(15);
SELECT uid INTO usr_id FROM ip_pool WHERE INET_ATON(usr_ip) = ip LIMIT 1;
SELECT ip INTO uid_ip FROM mac_uid WHERE ip = INET_ATON(usr_ip);
IF( usr_id > 0 AND uid_ip = INET_ATON(usr_ip) ) THEN
INSERT INTO auth_now SET
ip = usr_ip,
properties = auth_properties,
start = UNIX_TIMESTAMP(),
last = UNIX_TIMESTAMP()
ON DUPLICATE KEY UPDATE
properties = IF(auth_properties!='',auth_properties,properties),
last = UNIX_TIMESTAMP();
UPDATE ip_pool SET `release` = UNIX_TIMESTAMP() + 90
WHERE ip = INET_ATON(usr_ip)
AND type = 'dynamic'
AND `release` < (UNIX_TIMESTAMP() + 65)
LIMIT 1;
END IF;
END$$
DELIMITER ;
Проблема заключается в том что если
SELECT ip INTO uid_ip FROM mac_uid WHERE ip = INET_ATON(usr_ip);
возвращает пустое значение, видим ошибку:
ERROR 1172 (42000): Result consisted of more than one row
Помогите исправить