X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=SL%2FDBUpgrade2.pm;h=f694b5aaca3cf813ecc9e1bc8777f297995c16e0;hb=3f90c9cac7fea1568957718eba46dfe5f9a621ce;hp=65d2fec24c3c42ec6625105952ea1912cc67f65d;hpb=03907d6fd3a6af1633eaa4ecf2d4a27b1439a3b2;p=kivitendo-erp.git diff --git a/SL/DBUpgrade2.pm b/SL/DBUpgrade2.pm index 65d2fec24..f694b5aac 100644 --- a/SL/DBUpgrade2.pm +++ b/SL/DBUpgrade2.pm @@ -26,7 +26,7 @@ sub init { $params{path_suffix} ||= ''; $params{schema} ||= ''; - $params{path} = "sql/Pg-upgrade2" . $params{path_suffix}; + $params{path} ||= "sql/Pg-upgrade2" . $params{path_suffix}; map { $self->{$_} = $params{$_} } keys %params; @@ -147,9 +147,6 @@ sub process_query { # Remove DOS and Unix style line endings. chomp; - # remove comments - s/--.*$//; - for (my $i = 0; $i < length($_); $i++) { my $char = substr($_, $i, 1); @@ -176,6 +173,11 @@ sub process_query { && $tag =~ /^ (?= [A-Za-z_] [A-Za-z0-9_]* | ) $/x) { # tag is identifier push @quote_chars, $char = '$' . $tag . '$'; $i = $tag_end; + } elsif ($char eq "-") { + if ( substr($_, $i+1, 1) eq "-") { + # found a comment outside quote + last; + } } elsif ($char eq ";") { # Query is complete. Send it. @@ -186,11 +188,13 @@ sub process_query { return $errstr // '' if $self->{return_on_error}; $sth->finish(); $dbh->rollback(); - $form->dberror("The database update/creation did not succeed. " . - "The file ${filename} containing the following " . - "query failed:
${query}
" . - "The error message was: ${errstr}
" . - "All changes in that file have been reverted."); + if (!ref $version_or_control || ref $version_or_control ne 'HASH' || !$version_or_control->{may_fail}) { + $form->dberror("The database update/creation did not succeed. " . + "The file ${filename} containing the following " . + "query failed:
${query}
" . + "The error message was: ${errstr}
" . + "All changes in that file have been reverted.") + } } $sth->finish(); @@ -234,7 +238,7 @@ sub process_perl_script { my ($self, $dbh, $filename, $version_or_control) = @_; - my %form_values = map { $_ => $::form->{$_} } qw(dbconnect dbdefault dbhost dbname dboptions dbpasswd dbport dbupdate dbuser login template_object version); + my %form_values = %$::form; $dbh->begin_work; @@ -260,10 +264,10 @@ sub process_perl_script { if (!defined($result)) { print $::form->parse_html_template("dbupgrade/error", { file => $filename, error => $error }); - ::end_of_request(); + $::dispatcher->end_request; } elsif (1 != $result) { SL::System::InstallationLock->unlock if 2 == $result; - ::end_of_request(); + $::dispatcher->end_request; } if (ref($version_or_control) eq "HASH") {