diff --git a/cosmogramme/php/util_patch_sgbd.php b/cosmogramme/php/util_patch_sgbd.php index 54853db7e460d41eaf5d1003423b5c471bd795bf..dfae7a94e9a6acaaa6a1d12bee23c54d4f0d5f81 100644 --- a/cosmogramme/php/util_patch_sgbd.php +++ b/cosmogramme/php/util_patch_sgbd.php @@ -54,27 +54,39 @@ if($_REQUEST["action"]=="LANCER") print('<h3>Execution patch n° '.$num_patch.'</h3>'); $num_instruction=0; $data=file($script); - foreach($data as $ligne) + + $instructions = []; + $contents = implode(" ", $data); + if (false !== strpos($contents, 'CREATE FUNCTION')) + $instructions[] = $contents; + else { + $instruction = ''; + foreach($data as $ligne) + { + $ligne=trim($ligne); + if(!$ligne or substr($ligne,0,2)=="--") continue; + + $instruction.=$ligne.' '; + if(substr($ligne,-1)!=";") { + continue; + } + + $instructions[]=$instruction; + $instruction = ''; + } + } + + + foreach($instructions as $instruction) { - $ligne=trim($ligne); - if(!$ligne or substr($ligne,0,2)=="--") continue; - print($ligne.BR); + print($instruction.BR); flush(); - // Concatener la ligne d'instruction - if(substr($ligne,-1)!=";") - { - $instruction.=$ligne; - continue; - } - $instruction.=$ligne; - // Executer $num_instruction++; - if($_REQUEST["reprise"] > 0 and $_REQUEST["reprise"] >= $num_instruction){$instruction=""; continue;} + if($_REQUEST["reprise"] > 0 and $_REQUEST["reprise"] >= $num_instruction){continue;} try { $sql->execute($instruction); - $instruction=""; } catch(Exception $e) { diff --git a/cosmogramme/sql/patch/patch_171.sql b/cosmogramme/sql/patch/patch_171.sql index 29d875fe6c816fdd0651fc72744f4332c718fee2..f2c39ec32e1a2270cd1bc39ffb01fffe8bebea48 100644 --- a/cosmogramme/sql/patch/patch_171.sql +++ b/cosmogramme/sql/patch/patch_171.sql @@ -1,4 +1,3 @@ -DELIMITER // CREATE FUNCTION clean_spaces(str VARCHAR(255)) RETURNS VARCHAR(255) DETERMINISTIC BEGIN while instr(str, ' ') > 0 do @@ -6,5 +5,4 @@ BEGIN end while; return trim(str); END -// -DELIMITER ; +