View | Details | Raw Unified | Return to bug 13669
Collapse All | Expand All

(-)a/C4/Installer.pm (-20 / +18 lines)
Lines 412-429 sub set_version_syspref { Link Here
412
412
413
  my $error = $installer->load_sql($filename);
413
  my $error = $installer->load_sql($filename);
414
414
415
Runs a the specified SQL using the DB's command-line
415
Runs a the specified SQL file using a sql loader DBIx::RunSQL
416
SQL tool, and returns any strings sent to STDERR
416
Returns any strings sent to STDERR
417
by the command-line tool.
418
417
419
B<FIXME:> there has been a long-standing desire to
418
# FIXME This should be improved: sometimes the caller and load_sql warn the same
420
replace this with an SQL loader that goes
419
error.
421
through DBI; partly for portability issues
422
and partly to improve error handling.
423
424
B<FIXME:> even using the command-line loader, some more
425
basic error handling should be added - deal
426
with missing files, e.g.
427
420
428
=cut
421
=cut
429
422
Lines 434-450 sub load_sql { Link Here
434
427
435
    my $dbh = $self->{ dbh };
428
    my $dbh = $self->{ dbh };
436
429
437
    eval {
430
    my $dup_stderr;
438
        DBIx::RunSQL->run_sql_file(
431
    do {
439
            dbh     => $dbh,
432
        local *STDERR;
440
            sql     => $filename,
433
        open STDERR, ">>", \$dup_stderr;
441
        );
434
435
        eval {
436
            DBIx::RunSQL->run_sql_file(
437
                dbh     => $dbh,
438
                sql     => $filename,
439
            );
440
        };
442
    };
441
    };
443
    #   errors thrown while loading installer data should be logged
442
    #   errors thrown while loading installer data should be logged
444
    if( $@ ) {
443
    if( $dup_stderr ) {
445
        warn "C4::Installer::load_sql returned the following errors while attempting to load $filename:\n";
444
        warn "C4::Installer::load_sql returned the following errors while attempting to load $filename:\n";
446
        warn "$@";
445
        $error = $dup_stderr;
447
        $error = "Error attempting to load $filename:\n$@";
446
448
    }
447
    }
449
448
450
    return $error;
449
    return $error;
451
- 

Return to bug 13669