DROP PROCEDURE IF EXISTS `get_user_profile`;
DELIMITER ;;
CREATE PROCEDURE `get_user_profile` (
    IN p_session_id CHAR(64)
)
proc:BEGIN
    IF (SELECT COUNT(session_id) FROM sessions WHERE session_id = LOWER(p_session_id)) = 0 OR p_session_id IS NULL THEN
        SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'get_user_profile: No user logged in';
        LEAVE proc;
    END IF;
    SELECT user_id INTO @user_id FROM sessions WHERE session_id = LOWER(p_session_id);
    SELECT 0 AS 'status', `name`, `username`, `location`, `bio`, `phone_number`, `picture`, 'get_user_profile' AS 'proc' FROM users WHERE id = @user_id;
END ;;
DELIMITER ;
