From cc7a24f9da43b160865dc7b8aba41398b2e96e34 Mon Sep 17 00:00:00 2001 From: Bernardo Gonzalez Kriegel Date: Wed, 18 May 2016 16:25:25 -0300 Subject: [PATCH] Bug 13669: (alternative) use DBIx::RunSQL Alternative POC solution, on top of previous patches, feel free to obsolte. This patch use DBIx::RunSQL->run_sql_file to procees each sql file. To test: 1) Apply all patches 2) Same test plan of patch 1 Timing test running web installer, marc21, all sample data, time in seconds a) without patch structure data 59.7 66.5 58.6 66.0 b) SQL::SplitStatement (patch 1+2) 59.4 101 59.7 102 c) DBIx::RunSQL (patch 3) 60.7 66.8 59.4 66.2 Tomas' version is a bit slower loading sample data, all give similar results processing kohastructure. New dependency to package: DBIx::RunSQL --- C4/Installer.pm | 18 ++++++------------ .../mysql/en/optional/marc21_holdings_coded_values.sql | 3 ++- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/C4/Installer.pm b/C4/Installer.pm index b239853..54587de 100644 --- a/C4/Installer.pm +++ b/C4/Installer.pm @@ -20,8 +20,7 @@ package C4::Installer; use Modern::Perl; use Encode qw( encode is_utf8 ); -use File::Slurp; -use SQL::SplitStatement; +use DBIx::RunSQL; use C4::Context; use C4::Installer::PerlModules; use DBI; @@ -435,17 +434,12 @@ sub load_sql { my $dbh = $self->{ dbh }; - my $sql = read_file( $filename, binmode => ':utf8'); - my $sql_splitter = SQL::SplitStatement->new; - my @statements = $sql_splitter->split($sql); - my $error = ""; + my $error = DBIx::RunSQL->run_sql_file( + dbh => $dbh, + sql => $filename, + ); - foreach my $statement ( @statements ) { - $dbh->do($statement); - if( $dbh->err) { - $error .= "$filename (" . $dbh->errstr . "): $statement\n"; - } - } + $error = ( $error ) ? "ERROR: $filename" : ""; return $error; } diff --git a/installer/data/mysql/en/optional/marc21_holdings_coded_values.sql b/installer/data/mysql/en/optional/marc21_holdings_coded_values.sql index adc3ea7..d630b8e 100644 --- a/installer/data/mysql/en/optional/marc21_holdings_coded_values.sql +++ b/installer/data/mysql/en/optional/marc21_holdings_coded_values.sql @@ -3,7 +3,8 @@ -- Refer to http://www.niso.org/standards/index.html -- General Holdings: Type of Unit Designator -INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('HINGS_UT','0','Information not available; Not applicable');INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('HINGS_UT','a','Basic bibliographic unit'); +INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('HINGS_UT','0','Information not available; Not applicable'); +INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('HINGS_UT','a','Basic bibliographic unit'); INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('HINGS_UT','c','Secondary bibliographic unit: supplements, special issues, accompanying material, other secondary bibliographic units'); INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('HINGS_UT','d','Indexes'); -- 1.9.1