EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Bots (https://www.eqemulator.org/forums/forumdisplay.php?f=676)
-   -   Special Note For Bots Database Backups... (https://www.eqemulator.org/forums/showthread.php?t=40098)

Uleat 10-13-2015 05:39 PM

Special Note For Bots Database Backups...
 
After reading through the forums for bots issues, and having experienced this myself, I discovered an issue involving database backups.

I know this condition exists with the current eqemu_update.pl backup routine..but, it may apply to other backup techniques as well.


When sourcing a backup file into a clean database, you may get an error saying that the GetMobType() function could not be found.

This is due to the fact that the functions have not been included in the backup and one of the database views calls for it.


There are currently two that you need for proper server operation.

Which versions you need are dependent on what version your bots database is at.


For older, pre-update script, databases, where there is NO underscore after 'bot' in the table name:
Code:

DELIMITER $$

CREATE FUNCTION `GetMobType` (mob_name VARCHAR(64)) RETURNS CHAR(1)
BEGIN
        DECLARE Result CHAR(1);
       
        SET Result = NULL;
       
        IF ((SELECT COUNT(*) FROM `character_data` WHERE `name` = mob_name) > 0) THEN
                SET Result = 'C';
        ELSEIF ((SELECT COUNT(*) FROM `bots` WHERE `Name` = mob_name) > 0) THEN
                SET Result = 'B';
        END IF;
       
        RETURN Result;
END$$

CREATE FUNCTION `GetMobTypeById` (mob_id INTEGER UNSIGNED) RETURNS CHAR(1)
BEGIN
        DECLARE Result CHAR(1);
       
        SET Result = NULL;
       
        IF ((select `id` from `character_data` where `id` = mob_id) > 0) THEN
                SET Result = 'C';
        ELSEIF ((select `bot_id` from `bots` where `BotID` = mob_id) > 0) THEN
                SET Result = 'B';
        END IF;
       
        RETURN Result;
END$$

DELIMITER ;

Note: If you're using a pre-'Player Profile' conversion database, you will need to change `character_data` to `character_` in both of the above functions.



For newer databases where `db_version`.`bots_version` is set to 9000 or higher..in particular, using the table naming scheme 'bot_%' :
Code:

DELIMITER $$

CREATE FUNCTION `GetMobType` (mob_name VARCHAR(64)) RETURNS CHAR(1)
BEGIN
        DECLARE Result CHAR(1);
       
        SET Result = NULL;
       
        IF ((SELECT COUNT(*) FROM `character_data` WHERE `name` = mob_name) > 0) THEN
                SET Result = 'C';
        ELSEIF ((SELECT COUNT(*) FROM `bot_data` WHERE `name` = mob_name) > 0) THEN
                SET Result = 'B';
        END IF;
       
        RETURN Result;
END$$

CREATE FUNCTION `GetMobTypeById` (mob_id INTEGER UNSIGNED) RETURNS CHAR(1)
BEGIN
        DECLARE Result CHAR(1);
       
        SET Result = NULL;
       
        IF ((select `id` from `character_data` where `id` = mob_id) > 0) THEN
                SET Result = 'C';
        ELSEIF ((select `bot_id` from `bot_data` where `bot_id` = mob_id) > 0) THEN
                SET Result = 'B';
        END IF;
       
        RETURN Result;
END$$

DELIMITER ;


For whichever version you have, just run that as a query prior to sourcing in your backup file and that should alleviate the error..and set things
somewhat straight.

There are a few threads where the issue would be resolved using this procedure.


Note: Future updates will probably eliminate the need for views and functions altogether..but, this info will still be needed for older databases.


All times are GMT -4. The time now is 12:32 PM.

Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.