Replaced procedures with prepared statements.

The Update Manager client cannot load MySQL procedures because the
parser breaks them.
This commit is contained in:
Ramon Novoa 2017-06-15 15:43:00 +02:00
parent d2d56b4b89
commit 035829ce91
1 changed files with 20 additions and 21 deletions

View File

@ -1,25 +1,24 @@
START TRANSACTION;
DROP PROCEDURE IF EXISTS addcol_oum706;
delimiter '//'
CREATE PROCEDURE addcol_oum706() BEGIN
IF NOT EXISTS (
SELECT * FROM information_schema.columns WHERE table_name='treport_content' AND column_name='historical_db'
) THEN
ALTER TABLE treport_content ADD COLUMN historical_db tinyint(1) UNSIGNED NOT NULL default 0;
END IF;
IF NOT EXISTS (
SELECT * FROM information_schema.columns WHERE table_name='tpolicy_modules' AND column_name='ip_target'
) THEN
ALTER TABLE tpolicy_modules ADD COLUMN ip_target varchar(100) default '';
END IF;
END;
//
delimiter ';'
CALL addcol_oum706();
DROP PROCEDURE addcol_oum706;
SET @st_oum706 = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'treport_content' AND table_schema = DATABASE() AND column_name = 'historical_db') > 0,
"SELECT 1",
"ALTER TABLE treport_content ADD COLUMN historical_db tinyint(1) UNSIGNED NOT NULL default 0"
));
PREPARE pr_oum706 FROM @st_oum706;
EXECUTE pr_oum706;
DEALLOCATE PREPARE pr_oum706;
SET @st_oum706 = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'tpolicy_modules' AND table_schema = DATABASE() AND column_name = 'ip_target') > 0,
"SELECT 1",
"ALTER TABLE tpolicy_modules ADD COLUMN ip_target varchar(100) default ''"
));
PREPARE pr_oum706 FROM @st_oum706;
EXECUTE pr_oum706;
DEALLOCATE PREPARE pr_oum706;
COMMIT;