From 0447bbe9cbd4e67b66f7950bfefcdc5caa6fb810 Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@git-test.afi-sa.fr> Date: Tue, 3 Sep 2013 09:58:59 +0000 Subject: [PATCH] =?UTF-8?q?Cosmogramme:=20possibilit=C3=A9=20d'avoir=20des?= =?UTF-8?q?=20patchs=20type=20"CREATE=20FUNCTION"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cosmogramme/php/util_patch_sgbd.php | 40 +++++++++++++++++++---------- cosmogramme/sql/patch/patch_171.sql | 4 +-- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/cosmogramme/php/util_patch_sgbd.php b/cosmogramme/php/util_patch_sgbd.php index 54853db7e46..dfae7a94e9a 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 29d875fe6c8..f2c39ec32e1 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 ; + -- GitLab