CREATE PROCEDURE check_password_complexity(IN p_password VARCHAR(255))
BEGIN
DECLARE message VARCHAR(255);
IF LENGTH(p_password) < 8 THEN
SET message = 'Password must be at least 8 characters long.';
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = message;
ELSEIF NOT (p_password REGEXP '[A-Z]') THEN
SET message = 'Password must contain at least one uppercase letter.';
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = message;
ELSEIF NOT (p_password REGEXP '[a-z]') THEN
SET message = 'Password must contain at least one lowercase letter.';
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = message;
ELSEIF NOT (p_password REGEXP '[0-9]') THEN
SET message = 'Password must contain at least one digit.';
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = message;
ELSEIF NOT (p_password REGEXP '[^a-zA-Z0-9]') THEN
SET message = 'Password must contain at least one special character.';
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = message;
ELSE
SET message = 'Password is valid.';
END IF;
END //