From db9c2a05f6301471fff530c9ee497e09d78a5e40 Mon Sep 17 00:00:00 2001 From: Irina Peshinskaya Date: Thu, 16 Jul 2015 09:29:29 +0300 Subject: [PATCH] MT#13971 Remove unnecessary debug from fill_billing_fees procedure Change-Id: I397f10fb8564a3edbdc0ad83e9d6d97a4e3bd13d --- db_scripts/diff/15172.down | 6 ++++++ db_scripts/diff/15172.up | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 db_scripts/diff/15172.down create mode 100644 db_scripts/diff/15172.up diff --git a/db_scripts/diff/15172.down b/db_scripts/diff/15172.down new file mode 100644 index 00000000..3e61dbca --- /dev/null +++ b/db_scripts/diff/15172.down @@ -0,0 +1,6 @@ +SET AUTOCOMMIT=0; +USE billing; + +drop procedure if exists fill_billing_fees; + +COMMIT; \ No newline at end of file diff --git a/db_scripts/diff/15172.up b/db_scripts/diff/15172.up new file mode 100644 index 00000000..79f60d57 --- /dev/null +++ b/db_scripts/diff/15172.up @@ -0,0 +1,40 @@ +SET AUTOCOMMIT=0; +USE billing; + +DELIMITER // +DROP PROCEDURE IF EXISTS fill_billing_fees; +CREATE PROCEDURE fill_billing_fees(IN in_profile_id INT) +BEGIN + + DECLARE columns varchar(1023); + DECLARE statement varchar(1023); + + SET @profile_id = in_profile_id; + + SELECT group_concat(COLUMN_NAME) INTO columns FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = database() AND TABLE_NAME = 'billing_fees_raw' AND COLUMN_NAME NOT IN ('id'); + +SET @statement = concat("insert into billing_fees(id,",columns,") +select min_id,",columns," +from billing_fees_raw bnu +inner join ( + select min(i_nu.id) min_id + from billing_fees_raw i_nu + left join billing.billing_fees i_u + on i_nu.billing_profile_id=i_u.billing_profile_id + and i_nu.source=i_u.source + and i_nu.destination=i_u.destination + and i_nu.direction=i_u.direction + and i_nu.type=i_u.type + where i_u.id is null ", + if( @profile_id is not null, " and i_nu.billing_profile_id = ? ", " and 1 = ? "), + " group by i_nu.billing_profile_id,i_nu.source,i_nu.destination,i_nu.direction,i_nu.type +) u on bnu.id=u.min_id"); + IF @profile_id is null THEN SET @profile_id = 1; END IF; + PREPARE stmt FROM @statement; + EXECUTE stmt USING @profile_id; + DEALLOCATE PREPARE stmt; +END// + +DELIMITER ; + +COMMIT;