From 4c2287d7f727f6a43000ed35db7884d51db11a5d Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 6 Apr 2006 08:55:42 +0000 Subject: [PATCH] Alle Datenbankupgradescripte in ein eigenes Verzeichnis verschoben. SQL Update jetzt Regex escaped. " --" am Anfang einer Zeile laesst das Datenbankupgrade crashen. [Merge der Revisionen 818 964 980 aus dem LINET prog Repo] --- SL/User.pm | 27 ++++++++++--------- .../Pg-upgrade-1.0.0-2.1.0.sql | 0 .../Pg-upgrade-2.1.0-2.1.1.sql | 0 .../Pg-upgrade-2.1.1-2.2.0.sql | 0 4 files changed, 14 insertions(+), 13 deletions(-) rename sql/{ => Pg-upgrade}/Pg-upgrade-1.0.0-2.1.0.sql (100%) rename sql/{ => Pg-upgrade}/Pg-upgrade-2.1.0-2.1.1.sql (100%) rename sql/{ => Pg-upgrade}/Pg-upgrade-2.1.1-2.2.0.sql (100%) diff --git a/SL/User.pm b/SL/User.pm index c35ff0e91..6ce3c41b1 100644 --- a/SL/User.pm +++ b/SL/User.pm @@ -162,7 +162,7 @@ sub login { $rc = 0; - if (&update_available($dbversion)) { + if (&update_available($myconfig{"dbdriver"}, $dbversion)) { # update the tables open FH, ">$userspath/nologin" or die " @@ -407,10 +407,10 @@ sub process_query { while () { # Remove DOS and Unix style line endings. - s/[\r\n]//g; + chomp; - # don't add comments or empty lines - next if /^(--.*|\s+)$/; + # remove comments + s/--.*$//; for (my $i = 0; $i < length($_); $i++) { my $char = substr($_, $i, 1); @@ -655,13 +655,14 @@ sub cmp_script_version { ## /LINET sub update_available { - ($cur_version) = @_; - opendir SQLDIR, "sql/." or &error("", "$!"); - my @upgradescripts = - grep(/$form->{dbdriver}-upgrade-$cur_version.*\.sql/, readdir(SQLDIR)); - closedir SQLDIR; - - return ($#upgradescripts > -1); + my ($dbdriver, $cur_version) = @_; + + opendir SQLDIR, "sql/${dbdriver}-upgrade" or &error("", "sql/${dbdriver}-upgrade: $!"); + my @upgradescripts = + grep(/$form->{dbdriver}-upgrade-\Q$cur_version\E.*\.sql/, readdir(SQLDIR)); + closedir SQLDIR; + + return ($#upgradescripts > -1); } sub dbupdate { @@ -678,7 +679,7 @@ sub dbupdate { if ($form->{dbupdate}) { # read update scripts into memory - opendir SQLDIR, "sql/." or &error("", "$!"); + opendir SQLDIR, "sql/" . $form->{dbdriver} . "-upgrade" or &error("", "sql/" . $form->{dbdriver} . "-upgrade : $!"); ## LINET @upgradescripts = sort(cmp_script_version @@ -732,7 +733,7 @@ sub dbupdate { last if ($version < $mindb); # apply upgrade - $self->process_query($form, $dbh, "sql/$upgradescript", $str_maxdb); + $self->process_query($form, $dbh, "sql/" . $form->{"dbdriver"} . "-upgrade/$upgradescript", $str_maxdb); $version = $maxdb; diff --git a/sql/Pg-upgrade-1.0.0-2.1.0.sql b/sql/Pg-upgrade/Pg-upgrade-1.0.0-2.1.0.sql similarity index 100% rename from sql/Pg-upgrade-1.0.0-2.1.0.sql rename to sql/Pg-upgrade/Pg-upgrade-1.0.0-2.1.0.sql diff --git a/sql/Pg-upgrade-2.1.0-2.1.1.sql b/sql/Pg-upgrade/Pg-upgrade-2.1.0-2.1.1.sql similarity index 100% rename from sql/Pg-upgrade-2.1.0-2.1.1.sql rename to sql/Pg-upgrade/Pg-upgrade-2.1.0-2.1.1.sql diff --git a/sql/Pg-upgrade-2.1.1-2.2.0.sql b/sql/Pg-upgrade/Pg-upgrade-2.1.1-2.2.0.sql similarity index 100% rename from sql/Pg-upgrade-2.1.1-2.2.0.sql rename to sql/Pg-upgrade/Pg-upgrade-2.1.1-2.2.0.sql -- 2.20.1