Why is this stored procedure deleting all objects in the database?
===

This is a stored procedure that is only supposed to wipe certain objects in the database, but it's wiping all of the objects.


DROP PROCEDURE IF EXISTS `server_WIPE`;
DELIMITER //
CREATE DEFINER=`root`@`localhost` PROCEDURE `server_WIPE`(IN `worldID` INT)
MAIN:BEGIN

	DECLARE UID BIGINT UNSIGNED;
	DECLARE finished INT DEFAULT 0;
	DECLARE cityLoop CURSOR FOR SELECT `object`.`parent` FROM `object` INNER JOIN `obj_city` ON `object`.`UID` = `obj_city`.`UID` WHERE `obj_city`.`worldServerID` = worldID;
	DECLARE CONTINUE HANDLER FOR NOT FOUND SET finished = 1;

	DECLARE EXIT HANDLER FOR SQLEXCEPTION, SQLWARNING
	BEGIN 
		ROLLBACK; 
		SELECT -1 AS `errorno`, 'Procedure failed and rolled back' as `errormsg`;
	END;

	#Verify worldID exists
	IF ISNULL(worldID) THEN
		SELECT -2 AS `errorno`, "worldID CANNOT be null" AS `errormsg`;
		LEAVE MAIN;
	ELSEIF NOT EXISTS(SELECT NULL FROM `obj_worldServer` WHERE `world_id` = worldID) THEN
		SELECT -3 AS `errorno`, "worldID must exist. World not found" AS `errormsg`;
		LEAVE MAIN;
	END IF;

	START TRANSACTION;

		#Delete all cities. This will also remove Buildings, npc's and mobs for city.
		OPEN cityLoop;
			read_loop: LOOP
				FETCH cityLoop INTO UID;
				IF finished THEN
					LEAVE read_loop;
				END IF;
				DELETE FROM `object` WHERE `UID` = UID;				
			END LOOP;
		CLOSE cityLoop;

		#Delete all player guilds for server
		DELETE `object` FROM `object` INNER JOIN `obj_guild` ON `object`.`UID` = `obj_guild`.`UID` WHERE `obj_guild`.`worldServerID` = worldID;

		#Delete all items for server
		DELETE `object` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `obj_item`.`worldServerID` = worldID;
		
		#Delete all players for server
		DELETE `object` FROM `object` INNER JOIN `obj_character` ON `object`.`UID` = `obj_character`.`UID` WHERE `obj_character`.`worldServerID` = worldID;

	COMMIT;	
	SELECT 'Server Wiped Successfully' AS `result`;

END MAIN//
DELIMITER ;