|
|
@@ -359,14 +359,21 @@ SQL;
|
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin2;
|
|
|
SQL;
|
|
|
$sqlList['RemoveProcedure'] = "DROP PROCEDURE if exists `update_proces_init_idx_rec`";
|
|
|
+ // throws errors:
|
|
|
+ // #1146 - Table '{DATABASE_NAME}.P5-MSG:Route_FixCrmProcesInitIdx:ERROR: Already executed' doesn't exist
|
|
|
$sqlList['CreateProcedure'] = <<<SQL
|
|
|
CREATE PROCEDURE `update_proces_init_idx_rec`()
|
|
|
BEGIN
|
|
|
SET @enabled = FALSE;
|
|
|
+ SET @conf_last_exec_lock_key = 'tbl_indexer_CRM_PROCES_last_exec_lock_date';
|
|
|
SET @conf_last_exec_start_key = 'tbl_indexer_CRM_PROCES_last_exec_start';
|
|
|
SET @conf_last_exec_end_key = 'tbl_indexer_CRM_PROCES_last_exec_end';
|
|
|
-- if already runnig mysql will throw "Commands out of sync; you can't run this command now"
|
|
|
- replace into `CRM_CONFIG` (`conf_key`, `conf_val`) values (@conf_last_exec_start_key, NOW());
|
|
|
+ IF (select count(1) from `CRM_CONFIG` where `conf_key`=@conf_last_exec_lock_key and `conf_val`!='')>0 THEN
|
|
|
+ UPDATE `P5-MSG:Route_FixCrmProcesInitIdx:ERROR: Already executed` SET x=1;
|
|
|
+ ELSE BEGIN
|
|
|
+
|
|
|
+ replace into `CRM_CONFIG` (`conf_key`, `conf_val`) values (@conf_last_exec_lock_key, NOW()), (@conf_last_exec_start_key, NOW());
|
|
|
|
|
|
-- select 'truncate->delete...';
|
|
|
truncate table `CRM_PROCES_idx`;
|
|
|
@@ -478,8 +485,9 @@ BEGIN
|
|
|
)
|
|
|
where i.`TYPE` in('PROCES_INIT', 'GOTO_AND_RETURN');
|
|
|
|
|
|
- replace into `CRM_CONFIG` (`conf_key`, `conf_val`) values (@conf_last_exec_end_key, NOW());
|
|
|
+ replace into `CRM_CONFIG` (`conf_key`, `conf_val`) values (@conf_last_exec_lock_key, ''), (@conf_last_exec_end_key, NOW());
|
|
|
|
|
|
+ END ; END IF ;
|
|
|
END ;
|
|
|
|
|
|
SQL;
|