@@ -1,15 +1,16 @@
ALTER EVENT event_exec_proc_config ON COMPLETION PRESERVE DISABLE ;
ALTER TABLE cfg_num_statistics ADD COLUMN statistic_time datetime NULL COMMENT ' ͳ<EFBFBD> <EFBFBD> ʱ<EFBFBD> <EFBFBD> ' ;
ALTER TABLE request_num_statistics ADD COLUMN statistic_time datetime NULL COMMENT ' ͳ<EFBFBD> <EFBFBD> ʱ<EFBFBD> <EFBFBD> ' ;
update cfg_num_statistics set cfg_type = 0 ;
ALTER TABLE cfg_num_statistics CHANGE cfg_type compile_id int null default 0 ;
ALTER TABLE request_num_statistics add compile_id int null default 0 ;
ALTER TABLE cfg_num_statistics add statistic_time datetime null default null ;
ALTER TABLE request_num_statistics add statistic_time datetime null default null ;
delete from statistics_tables ;
INSERT INTO statistics_tables;
INSERT INTO statistics_tables
( )
VALUES
( 1 , ' app_byte_cfg ' , 1 , ' ' ) ;
( 1 , ' app_byte_cfg ' , 0 , ' ' ) ;
INSERT INTO statistics_tables
( )
@@ -224,7 +225,7 @@ VALUES
INSERT INTO statistics_tables
( )
VALUES
( 44 , ' app_session_cfg ' , 1 , ' ' ) ;
( 44 , ' app_session_cfg ' , 0 , ' ' ) ;
INSERT INTO statistics_tables
( )
@@ -251,5 +252,196 @@ INSERT INTO statistics_tables
VALUES
( 49 , ' proxy_file_strategy_cfg ' , 1 , ' ' ) ;
drop PROCEDURE proc_statistics_config ;
drop PROCEDURE proc_statistics_request ;
-- ----------------------------
-- Procedure structure for proc_statistics_config
-- ----------------------------
DELIMITER ; ;
CREATE DEFINER = ` root ` @ ` % ` PROCEDURE ` proc_statistics_config ` ( )
BEGIN
DECLARE ntime VARCHAR ( 40 ) ; /* <EFBFBD> <EFBFBD> ǰʱ<EFBFBD> <EFBFBD> */
DECLARE tabName VARCHAR ( 500 ) ;
DECLARE description VARCHAR ( 500 ) ;
DECLARE deleteSql VARCHAR ( 500 ) ;
DECLARE done INT ; /* <EFBFBD> α <EFBFBD> <EFBFBD> <EFBFBD> ʶ*/
DECLARE flag INT ; /* ѭ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʶ */
DECLARE proc_log_table VARCHAR ( 100 ) ; /* <EFBFBD> 洢<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ־<EFBFBD> <EFBFBD> */
DECLARE proc_name VARCHAR ( 100 ) ; /* <EFBFBD> 洢<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> */
DECLARE icursor CURSOR FOR SELECT tab_name FROM statistics_tables where is_valid = 1 ;
DECLARE CONTINUE HANDLER FOR NOT found SET done = 1 ;
DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK ;
SET done = 0 ;
SET proc_log_table = ' proc_exec_log ' ;
SET proc_name = ' proc_statistics_config ' ;
SET ntime = DATE_FORMAT ( SYSDATE ( ) , ' %Y-%m-%d %H:%k:%S ' ) ;
set @ deleteSql : = ' delete from cfg_num_statistics ' ;
PREPARE execs FROM @ deleteSql ;
EXECUTE execs ;
DEALLOCATE PREPARE execs ;
COMMIT ;
OPEN icursor ;
loop_iloop : LOOP
FETCH icursor INTO tabName ;
SET description = tabName ;
set @ descriptionStart = concat ( description , ' <EFBFBD> <EFBFBD> ͳ<EFBFBD> <EFBFBD> start' ) ;
/* ͳ<EFBFBD> Ƶ<EFBFBD> ǰ<EFBFBD> <EFBFBD> <EFBFBD> ñ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> ͳ<EFBFBD> Ʊ<EFBFBD> <EFBFBD> <EFBFBD> start */
set @ v_log_sql1 : = concat ( ' insert into ' , proc_log_table , ' (proc_name,table_name,log_time,description) values(?,?,?,?) ' ) ;
PREPARE execs FROM @ v_log_sql1 ;
EXECUTE execs using proc_name , proc_log_table , ntime , @ descriptionStart ;
DEALLOCATE PREPARE execs ;
COMMIT ;
set @ insert_statistics_sql : = concat ( ' insert into cfg_num_statistics(statistic_time,function_id,service_id,action,compile_id,cfg_state) select now(),function_id,service_id,action,compile_id,if(is_audit=3,3,if(is_audit=2,2,if(is_audit=1,1,if(is_valid=0,0,if(is_valid,-1,-1))))) cfg_state from ' , tabName ) ;
PREPARE execs FROM @ insert_statistics_sql ;
EXECUTE execs ;
DEALLOCATE PREPARE execs ;
COMMIT ;
set @ descriptionEnd = concat ( description , ' <EFBFBD> <EFBFBD> ͳ<EFBFBD> <EFBFBD> end' ) ;
set @ v_log_sql2 : = concat ( ' insert into ' , proc_log_table , ' (proc_name,table_name,log_time,description) values(?,?,?,?) ' ) ;
PREPARE execs FROM @ v_log_sql2 ;
EXECUTE execs using proc_name , proc_log_table , ntime , @ descriptionEnd ;
DEALLOCATE PREPARE execs ;
COMMIT ;
/* ͳ<EFBFBD> Ƶ<EFBFBD> ǰ<EFBFBD> <EFBFBD> <EFBFBD> ñ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> ͳ<EFBFBD> Ʊ<EFBFBD> <EFBFBD> <EFBFBD> end */
IF done = 1 THEN
LEAVE loop_iloop ;
ELSE
SET flag = 0 ;
END IF ;
IF flag = 0 THEN
SET done = 0 ;
END IF ;
END LOOP ;
CLOSE icursor ;
COMMIT ;
END ; ;
DELIMITER ;
-- ----------------------------
-- Procedure structure for proc_statistics_request
-- ----------------------------
DELIMITER ; ;
CREATE DEFINER = ` root ` @ ` % ` PROCEDURE ` proc_statistics_request ` ( )
BEGIN
DECLARE ntime VARCHAR ( 40 ) ; /* <EFBFBD> <EFBFBD> ǰʱ<EFBFBD> <EFBFBD> */
DECLARE tabName VARCHAR ( 500 ) ;
DECLARE description VARCHAR ( 500 ) ;
DECLARE deleteSql VARCHAR ( 500 ) ;
DECLARE done INT ; /* <EFBFBD> α <EFBFBD> <EFBFBD> <EFBFBD> ʶ*/
DECLARE flag INT ; /* ѭ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʶ */
DECLARE proc_log_table VARCHAR ( 100 ) ; /* <EFBFBD> 洢<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ־<EFBFBD> <EFBFBD> */
DECLARE proc_name VARCHAR ( 100 ) ; /* <EFBFBD> 洢<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> */
DECLARE icursor CURSOR FOR SELECT tab_name FROM statistics_tables where is_valid = 1 ;
DECLARE CONTINUE HANDLER FOR NOT found SET done = 1 ;
DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK ;
SET done = 0 ;
SET proc_log_table = ' proc_exec_log ' ;
SET proc_name = ' proc_statistics_request ' ;
SET ntime = DATE_FORMAT ( SYSDATE ( ) , ' %Y-%m-%d %H:%k:%S ' ) ;
set @ deleteSql : = ' delete from request_num_statistics ' ;
PREPARE execs FROM @ deleteSql ;
EXECUTE execs ;
DEALLOCATE PREPARE execs ;
COMMIT ;
OPEN icursor ;
loop_iloop : LOOP
FETCH icursor INTO tabName ;
SET description = tabName ;
set @ descriptionStart = concat ( description , ' <EFBFBD> <EFBFBD> requestͳ<EFBFBD> <EFBFBD> start' ) ;
/* ͳ<EFBFBD> Ƶ<EFBFBD> ǰ<EFBFBD> <EFBFBD> <EFBFBD> ñ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> ͳ<EFBFBD> Ʊ<EFBFBD> <EFBFBD> <EFBFBD> start */
set @ v_log_sql1 : = concat ( ' insert into ' , proc_log_table , ' (proc_name,table_name,log_time,description) values(?,?,?,?) ' ) ;
PREPARE execs FROM @ v_log_sql1 ;
EXECUTE execs using proc_name , proc_log_table , ntime , @ descriptionStart ;
DEALLOCATE PREPARE execs ;
COMMIT ;
set @ insert_statistics_sql : = concat ( ' insert into request_num_statistics(statistic_time,function_id,service_id,request_id,compile_id) select now(),function_id,service_id,request_id,compile_id from ' , tabName , ' where request_id <> 0 and is_valid <> -1 and is_audit <> 3 ' ) ;
PREPARE execs FROM @ insert_statistics_sql ;
EXECUTE execs ;
DEALLOCATE PREPARE execs ;
COMMIT ;
set @ descriptionEnd = concat ( description , ' <EFBFBD> <EFBFBD> requestͳ<EFBFBD> <EFBFBD> end' ) ;
set @ v_log_sql2 : = concat ( ' insert into ' , proc_log_table , ' (proc_name,table_name,log_time,description) values(?,?,?,?) ' ) ;
PREPARE execs FROM @ v_log_sql2 ;
EXECUTE execs using proc_name , proc_log_table , ntime , @ descriptionEnd ;
DEALLOCATE PREPARE execs ;
COMMIT ;
/* ͳ<EFBFBD> Ƶ<EFBFBD> ǰ<EFBFBD> <EFBFBD> <EFBFBD> ñ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> ͳ<EFBFBD> Ʊ<EFBFBD> <EFBFBD> <EFBFBD> end */
IF done = 1 THEN
LEAVE loop_iloop ;
ELSE
SET flag = 0 ;
END IF ;
IF flag = 0 THEN
SET done = 0 ;
END IF ;
END LOOP ;
CLOSE icursor ;
COMMIT ;
END ; ;
DELIMITER ;
ALTER EVENT event_exec_proc_config ON COMPLETION PRESERVE DISABLE ;