From 90bb521a25eeb37c5bbae1ff68c38e6c142b6e6b Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 12 Jun 2013 16:01:58 +0200 Subject: [PATCH] Alle Vorkommen von dbdriver, sid, Oracle entfernt MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ...und gegen das hardcodierte Werte für PostgreSQL ersetzt. --- SL/CA.pm | 9 +- SL/Controller/Admin.pm | 2 +- SL/DBUpgrade2.pm | 18 +- SL/DO.pm | 12 +- SL/GL.pm | 4 +- SL/IS.pm | 6 +- SL/OE.pm | 13 +- SL/RC.pm | 14 +- SL/User.pm | 190 +++++------------- bin/mozilla/admin.pl | 12 +- scripts/dbupgrade2_tool.pl | 6 +- templates/webpages/admin/backup_dataset.html | 1 - templates/webpages/admin/create_dataset.html | 1 - templates/webpages/admin/dbadmin.html | 2 - templates/webpages/admin/delete_dataset.html | 1 - templates/webpages/admin/restore_dataset.html | 1 - templates/webpages/admin/update_dataset.html | 2 - 17 files changed, 79 insertions(+), 215 deletions(-) diff --git a/SL/CA.pm b/SL/CA.pm index e24be69c3..ef6e9c373 100644 --- a/SL/CA.pm +++ b/SL/CA.pm @@ -182,13 +182,6 @@ sub all_transactions { my $sortorder = join ', ', $form->sort_columns(qw(transdate reference description)); - my $false = ($myconfig->{dbdriver} eq 'Pg') ? "FALSE" : q|'0'|; - - # Oracle workaround, use ordinal positions - my %ordinal = (transdate => 4, - reference => 2, - description => 3); - map { $sortorder =~ s/$_/$ordinal{$_}/ } keys %ordinal; my ($null, $department_id) = split(/--/, $form->{department}); my ($dpt_where, $dpt_join, @department_values); @@ -272,7 +265,7 @@ sub all_transactions { # get all transactions $query = qq|SELECT a.id, a.reference, a.description, ac.transdate, ac.chart_id, | . - qq| $false AS invoice, ac.amount, 'gl' as module, | . + qq| FALSE AS invoice, ac.amount, 'gl' as module, | . qq§(SELECT accno||'--'||rate FROM tax LEFT JOIN chart ON (tax.chart_id=chart.id) WHERE tax.id = (SELECT tax_id FROM taxkeys WHERE taxkey_id = ac.taxkey AND taxkeys.startdate <= ac.transdate ORDER BY taxkeys.startdate DESC LIMIT 1)) AS taxinfo, ac.source || ' ' || ac.memo AS memo § . qq|FROM acc_trans ac, gl a | . $dpt_join . diff --git a/SL/Controller/Admin.pm b/SL/Controller/Admin.pm index 62ab99a78..8ba249034 100644 --- a/SL/Controller/Admin.pm +++ b/SL/Controller/Admin.pm @@ -504,7 +504,7 @@ sub check_auth_db_and_tables { } sub apply_dbupgrade_scripts { - return SL::DBUpgrade2->new(form => $::form, dbdriver => 'Pg', auth => 1)->apply_admin_dbupgrade_scripts(1); + return SL::DBUpgrade2->new(form => $::form, auth => 1)->apply_admin_dbupgrade_scripts(1); } sub authenticate_root { diff --git a/SL/DBUpgrade2.pm b/SL/DBUpgrade2.pm index 5bf31d7e8..0daec3606 100644 --- a/SL/DBUpgrade2.pm +++ b/SL/DBUpgrade2.pm @@ -27,7 +27,7 @@ sub init { $params{path_suffix} ||= ''; $params{schema} ||= ''; - $params{path} = "sql/" . $params{dbdriver} . "-upgrade2" . $params{path_suffix}; + $params{path} = "sql/Pg-upgrade2" . $params{path_suffix}; map { $self->{$_} = $params{$_} } keys %params; @@ -243,7 +243,7 @@ sub process_perl_script { my ($self, $dbh, $filename, $version_or_control, $db_charset) = @_; - my %form_values = map { $_ => $::form->{$_} } qw(dbconnect dbdefault dbdriver dbhost dbmbkiviunstable dbname dboptions dbpasswd dbport dbupdate dbuser login template_object version); + my %form_values = map { $_ => $::form->{$_} } qw(dbconnect dbdefault dbhost dbmbkiviunstable dbname dboptions dbpasswd dbport dbupdate dbuser login template_object version); $dbh->begin_work; @@ -302,9 +302,8 @@ sub update_available { local *SQLDIR; - my $dbdriver = $self->{dbdriver}; - opendir SQLDIR, "sql/${dbdriver}-upgrade" || error("", "sql/${dbdriver}-upgrade: $!"); - my @upgradescripts = grep /${dbdriver}-upgrade-\Q$cur_version\E.*\.(sql|pl)$/, readdir SQLDIR; + opendir SQLDIR, "sql/Pg-upgrade" || error("", "sql/Pg-upgrade: $!"); + my @upgradescripts = grep /Pg-upgrade-\Q$cur_version\E.*\.(sql|pl)$/, readdir SQLDIR; closedir SQLDIR; return ($#upgradescripts > -1); @@ -374,7 +373,7 @@ sub apply_admin_dbupgrade_scripts { $::lxdebug->message(LXDebug->DEBUG2(), "Applying Update $control->{file}"); print $self->{form}->parse_html_template("dbupgrade/upgrade_message2", $control); - $self->process_file($dbh, "sql/$self->{dbdriver}-upgrade2-auth/$control->{file}", $control, $db_charset); + $self->process_file($dbh, "sql/Pg-upgrade2-auth/$control->{file}", $control, $db_charset); } print $self->{form}->parse_html_template("dbupgrade/footer", { is_admin => 1 }) if $called_from_admin; @@ -461,7 +460,6 @@ C) # Apply outstanding updates to the authentication database my $scripts = SL::DBUpgrade2->new( form => $::form, - dbdriver => 'Pg', auth => 1 ); $scripts->apply_admin_dbupgrade_scripts(1); @@ -469,7 +467,6 @@ C) # Apply updates to a user database my $scripts = SL::DBUpgrade2->new( form => $::form, - dbdriver => $::form->{dbdriver}, auth => 1 ); User->dbupdate2($form, $scripts->parse_dbupdate_controls); @@ -603,11 +600,6 @@ Path to the upgrade files to parse. Required. C object to use. Required. -=item dbdriver - -Name of the database driver. Currently only C for PostgreSQL is -supported. - =item auth Optional parameter defaulting to 0. If trueish then the scripts read diff --git a/SL/DO.pm b/SL/DO.pm index a4677bbd9..fb8672c6a 100644 --- a/SL/DO.pm +++ b/SL/DO.pm @@ -672,9 +672,6 @@ sub retrieve { delete $form->{id}; } - my %oid = ('Pg' => 'oid', - 'Oracle' => 'rowid'); - # retrieve individual items # this query looks up all information about the items # stuff different from the whole will not be overwritten, but saved with a suffix. @@ -693,7 +690,7 @@ sub retrieve { LEFT JOIN project pr ON (doi.project_id = pr.id) LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id) WHERE doi.delivery_order_id IN ($do_ids_placeholders) - ORDER BY doi.$oid{$myconfig->{dbdriver}}|; + ORDER BY doi.oid|; $form->{form_details} = selectall_hashref_query($form, $dbh, $query, @do_ids); @@ -752,9 +749,6 @@ sub order_details { my $partsgroup; my $position = 0; - my %oid = ('Pg' => 'oid', - 'Oracle' => 'rowid'); - my (@project_ids, %projectnumbers, %projectdescriptions); push(@project_ids, $form->{"globalproject_id"}) if ($form->{"globalproject_id"}); @@ -869,9 +863,9 @@ sub order_details { my $sortorder = ""; if ($form->{groupitems}) { $sortorder = - qq|ORDER BY pg.partsgroup, a.$oid{$myconfig->{dbdriver}}|; + qq|ORDER BY pg.partsgroup, a.oid|; } else { - $sortorder = qq|ORDER BY a.$oid{$myconfig->{dbdriver}}|; + $sortorder = qq|ORDER BY a.oid|; } do_statement($form, $h_pg, $q_pg, conv_i($form->{"id_$i"})); diff --git a/SL/GL.pm b/SL/GL.pm index ada29ac6a..e6c87b314 100644 --- a/SL/GL.pm +++ b/SL/GL.pm @@ -354,8 +354,6 @@ sub all_transactions { } } - my $false = ($myconfig->{dbdriver} eq 'Pg') ? "FALSE" : q|'0'|; - my %sort_columns = ( 'id' => [ qw(id) ], 'transdate' => [ qw(transdate id) ], @@ -385,7 +383,7 @@ sub all_transactions { $query = qq|SELECT - ac.acc_trans_id, g.id, 'gl' AS type, $false AS invoice, g.reference, ac.taxkey, c.link, + ac.acc_trans_id, g.id, 'gl' AS type, FALSE AS invoice, g.reference, ac.taxkey, c.link, g.description, ac.transdate, ac.gldate, ac.source, ac.trans_id, ac.amount, c.accno, g.notes, t.chart_id, CASE WHEN (COALESCE(e.name, '') = '') THEN e.login ELSE e.name END AS employee diff --git a/SL/IS.pm b/SL/IS.pm index 1dc1eff60..71d547bcd 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -114,8 +114,6 @@ sub invoice_details { my $i; my @partsgroup = (); my $partsgroup; - my %oid = ('Pg' => 'oid', - 'Oracle' => 'rowid'); # sort items by partsgroup for $i (1 .. $form->{rowcount}) { @@ -336,9 +334,9 @@ sub invoice_details { my $sortorder = ""; if ($form->{groupitems}) { $sortorder = - qq|ORDER BY pg.partsgroup, a.$oid{$myconfig->{dbdriver}}|; + qq|ORDER BY pg.partsgroup, a.oid|; } else { - $sortorder = qq|ORDER BY a.$oid{$myconfig->{dbdriver}}|; + $sortorder = qq|ORDER BY a.oid|; } $query = diff --git a/SL/OE.pm b/SL/OE.pm index 0c0b76796..fec7507ca 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -853,9 +853,6 @@ sub retrieve { map { $form->{$_} =~ s/ +$//g } qw(printed emailed queued); } # if !@ids - my %oid = ('Pg' => 'oid', - 'Oracle' => 'rowid'); - my $transdate = $form->{transdate} ? $dbh->quote($form->{transdate}) : "current_date"; $form->{taxzone_id} = 0 unless ($form->{taxzone_id}); @@ -887,7 +884,7 @@ sub retrieve { ($form->{id} ? qq|WHERE o.trans_id = ?| : qq|WHERE o.trans_id IN (| . join(", ", map("?", @ids)) . qq|)|) . - qq|ORDER BY o.$oid{$myconfig->{dbdriver}}|; + qq|ORDER BY o.oid|; @ids = $form->{id} ? ($form->{id}) : @ids; $sth = prepare_execute_query($form, $dbh, $query, @values); @@ -1055,10 +1052,6 @@ sub order_details { my $tax_rate; my $taxamount; - - my %oid = ('Pg' => 'oid', - 'Oracle' => 'rowid'); - my (@project_ids, %projectnumbers, %projectdescriptions); push(@project_ids, $form->{"globalproject_id"}) if ($form->{"globalproject_id"}); @@ -1277,9 +1270,9 @@ sub order_details { # get parts and push them onto the stack my $sortorder = ""; if ($form->{groupitems}) { - $sortorder = qq|ORDER BY pg.partsgroup, a.$oid{$myconfig->{dbdriver}}|; + $sortorder = qq|ORDER BY pg.partsgroup, a.oid|; } else { - $sortorder = qq|ORDER BY a.$oid{$myconfig->{dbdriver}}|; + $sortorder = qq|ORDER BY a.oid|; } $query = qq|SELECT p.partnumber, p.description, p.unit, a.qty, | . diff --git a/SL/RC.pm b/SL/RC.pm index 9493f0f6a..9c73d45e2 100644 --- a/SL/RC.pm +++ b/SL/RC.pm @@ -93,13 +93,11 @@ sub payment_transactions { ($form->{beginningbalance}, $form->{category}) = selectrow_query($form, $dbh, $query, @values); - my %oid = ('Pg' => 'ac.acc_trans_id', - 'Oracle' => 'ac.rowid'); @values = (); $query = qq|SELECT c.name, ac.source, ac.transdate, ac.cleared, | . qq| ac.fx_transaction, ac.amount, a.id, | . - qq| $oid{$myconfig->{dbdriver}} AS oid | . + qq| ac.acc_trans_id AS oid | . qq|FROM customer c, acc_trans ac, ar a, chart ch | . qq|WHERE c.id = a.customer_id | . qq| AND ac.cleared = '0' | . @@ -123,7 +121,7 @@ sub payment_transactions { qq|SELECT v.name, ac.source, ac.transdate, ac.cleared, | . qq| ac.fx_transaction, ac.amount, a.id, | . - qq| $oid{$myconfig->{dbdriver}} AS oid | . + qq| ac.acc_trans_id AS oid | . qq|FROM vendor v, acc_trans ac, ap a, chart ch | . qq|WHERE v.id = a.vendor_id | . qq| AND ac.cleared = '0' | . @@ -148,7 +146,7 @@ sub payment_transactions { qq|SELECT g.description, ac.source, ac.transdate, ac.cleared, | . qq| ac.fx_transaction, ac.amount, g.id, | . - qq| $oid{$myconfig->{dbdriver}} AS oid | . + qq| ac.acc_trans_id AS oid | . qq|FROM gl g, acc_trans ac, chart ch | . qq|WHERE g.id = ac.trans_id | . qq| AND ac.cleared = '0' | . @@ -186,22 +184,20 @@ sub reconcile { my $dbh = $form->dbconnect($myconfig); my ($query, $i); - my %oid = ('Pg' => 'acc_trans_id', - 'Oracle' => 'rowid'); # clear flags for $i (1 .. $form->{rowcount}) { if ($form->{"cleared_$i"}) { $query = qq|UPDATE acc_trans SET cleared = '1' | . - qq|WHERE $oid{$myconfig->{dbdriver}} = ?|; + qq|WHERE acc_trans_id = ?|; do_query($form, $dbh, $query, $form->{"oid_$i"}); # clear fx_transaction if ($form->{"fxoid_$i"}) { $query = qq|UPDATE acc_trans SET cleared = '1' | . - qq|WHERE $oid{$myconfig->{dbdriver}} = ?|; + qq|WHERE acc_trans_id = ?|; do_query($form, $dbh, $query, $form->{"fxoid_$i"}); } } diff --git a/SL/User.pm b/SL/User.pm index d51b1edd1..ae4c3edef 100644 --- a/SL/User.pm +++ b/SL/User.pm @@ -93,7 +93,6 @@ sub country_codes { sub login { my ($self, $form) = @_; - our $sid; return -3 if !$self->{login} || !$::auth->client; @@ -103,22 +102,17 @@ sub login { my $dbh = $form->dbconnect_noauto; # we got a connection, check the version - my $query = qq|SELECT version FROM defaults|; - my $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); - - my ($dbversion) = $sth->fetchrow_array; - $sth->finish; + my ($dbversion) = $dbh->selectrow_array(qq|SELECT version FROM defaults|); $self->create_employee_entry($form, $dbh, \%myconfig); $self->create_schema_info_table($form, $dbh); # Auth DB upgrades available? - my $dbupdater_auth = SL::DBUpgrade2->new(form => $form, dbdriver => 'Pg', auth => 1)->parse_dbupdate_controls; + my $dbupdater_auth = SL::DBUpgrade2->new(form => $form, auth => 1)->parse_dbupdate_controls; return -3 if $dbupdater_auth->unapplied_upgrade_scripts($::auth->dbconnect); - my $dbupdater = SL::DBUpgrade2->new(form => $form, dbdriver => $myconfig{dbdriver})->parse_dbupdate_controls; + my $dbupdater = SL::DBUpgrade2->new(form => $form)->parse_dbupdate_controls; $form->{$_} = $::auth->client->{$_} for qw(dbname dbhost dbport dbuser dbpasswd); $form->{$_} = $myconfig{$_} for qw(dateformat); @@ -155,7 +149,7 @@ sub login { $self->dbupdate($form); $self->dbupdate2($form, $dbupdater); - SL::DBUpgrade2->new(form => $::form, dbdriver => 'Pg', auth => 1)->apply_admin_dbupgrade_scripts(0); + SL::DBUpgrade2->new(form => $::form, auth => 1)->apply_admin_dbupgrade_scripts(0); close($fh); @@ -173,48 +167,17 @@ sub dbconnect_vars { my ($form, $db) = @_; my %dboptions = ( - 'Pg' => { 'yy-mm-dd' => 'set DateStyle to \'ISO\'', - 'yyyy-mm-dd' => 'set DateStyle to \'ISO\'', - 'mm/dd/yy' => 'set DateStyle to \'SQL, US\'', - 'dd/mm/yy' => 'set DateStyle to \'SQL, EUROPEAN\'', - 'dd.mm.yy' => 'set DateStyle to \'GERMAN\'' - }, - 'Oracle' => { - 'yy-mm-dd' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'YY-MM-DD\'', - 'yyyy-mm-dd' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'YYYY-MM-DD\'', - 'mm/dd/yy' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'MM/DD/YY\'', - 'dd/mm/yy' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'DD/MM/YY\'', - 'dd.mm.yy' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'DD.MM.YY\'', - }); - - $form->{dboptions} = $dboptions{ $form->{dbdriver} }{ $form->{dateformat} }; - - if ($form->{dbdriver} eq 'Pg') { - $form->{dbconnect} = "dbi:Pg:dbname=$db"; - } - - if ($form->{dbdriver} eq 'Oracle') { - $form->{dbconnect} = "dbi:Oracle:sid=$form->{sid}"; - } - - if ($form->{dbhost}) { - $form->{dbconnect} .= ";host=$form->{dbhost}"; - } - if ($form->{dbport}) { - $form->{dbconnect} .= ";port=$form->{dbport}"; - } - - $main::lxdebug->leave_sub(); -} - -sub dbdrivers { - $main::lxdebug->enter_sub(); + 'yy-mm-dd' => 'set DateStyle to \'ISO\'', + 'yyyy-mm-dd' => 'set DateStyle to \'ISO\'', + 'mm/dd/yy' => 'set DateStyle to \'SQL, US\'', + 'dd/mm/yy' => 'set DateStyle to \'SQL, EUROPEAN\'', + 'dd.mm.yy' => 'set DateStyle to \'GERMAN\'' + ); - my @drivers = DBI->available_drivers(); + $form->{dboptions} = $dboptions{ $form->{dateformat} }; + $form->{dbconnect} = "dbi:Pg:dbname=${db};host=" . ($form->{dbhost} || 'localhost') . ";port=" . ($form->{dbport} || 5432); $main::lxdebug->leave_sub(); - - return (grep { /(Pg|Oracle)/ } @drivers); } sub dbsources { @@ -226,62 +189,42 @@ sub dbsources { my ($sth, $query); $form->{dbdefault} = $form->{dbuser} unless $form->{dbdefault}; - $form->{sid} = $form->{dbdefault}; &dbconnect_vars($form, $form->{dbdefault}); my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}, SL::DBConnect->get_options) or $form->dberror; - if ($form->{dbdriver} eq 'Pg') { - $query = - qq|SELECT datname FROM pg_database | . - qq|WHERE NOT datname IN ('template0', 'template1')|; - $sth = $dbh->prepare($query); - $sth->execute() || $form->dberror($query); - - while (my ($db) = $sth->fetchrow_array) { - - if ($form->{only_acc_db}) { - - next if ($db =~ /^template/); - - &dbconnect_vars($form, $db); - my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}, SL::DBConnect->get_options) - or $form->dberror; - - $query = - qq|SELECT tablename FROM pg_tables | . - qq|WHERE (tablename = 'defaults') AND (tableowner = ?)|; - my $sth = $dbh->prepare($query); - $sth->execute($form->{dbuser}) || - $form->dberror($query . " ($form->{dbuser})"); - - if ($sth->fetchrow_array) { - push(@dbsources, $db); - } - $sth->finish; - $dbh->disconnect; - next; - } - push(@dbsources, $db); - } - } + $query = + qq|SELECT datname FROM pg_database | . + qq|WHERE NOT datname IN ('template0', 'template1')|; + $sth = $dbh->prepare($query); + $sth->execute() || $form->dberror($query); + + while (my ($db) = $sth->fetchrow_array) { - if ($form->{dbdriver} eq 'Oracle') { if ($form->{only_acc_db}) { - $query = - qq|SELECT owner FROM dba_objects | . - qq|WHERE object_name = 'DEFAULTS' AND object_type = 'TABLE'|; - } else { - $query = qq|SELECT username FROM dba_users|; - } - $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); + next if ($db =~ /^template/); + + &dbconnect_vars($form, $db); + my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}, SL::DBConnect->get_options) + or $form->dberror; - while (my ($db) = $sth->fetchrow_array) { - push(@dbsources, $db); + $query = + qq|SELECT tablename FROM pg_tables | . + qq|WHERE (tablename = 'defaults') AND (tableowner = ?)|; + my $sth = $dbh->prepare($query); + $sth->execute($form->{dbuser}) || + $form->dberror($query . " ($form->{dbuser})"); + + if ($sth->fetchrow_array) { + push(@dbsources, $db); + } + $sth->finish; + $dbh->disconnect; + next; } + push(@dbsources, $db); } $sth->finish; @@ -316,49 +259,29 @@ sub dbcreate { my ($self, $form) = @_; - $form->{sid} = $form->{dbdefault}; &dbconnect_vars($form, $form->{dbdefault}); my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}, SL::DBConnect->get_options) or $form->dberror; $form->{db} =~ s/\"//g; - my %dbcreate = ( - 'Pg' => qq|CREATE DATABASE "$form->{db}"|, - 'Oracle' => - qq|CREATE USER "$form->{db}" DEFAULT TABLESPACE USERS | . - qq|TEMPORARY TABLESPACE TEMP IDENTIFIED BY "$form->{db}"| - ); - my %dboptions = ( - 'Pg' => [], - ); + my @dboptions; - push(@{$dboptions{"Pg"}}, "ENCODING = " . $dbh->quote($form->{"encoding"})) - if ($form->{"encoding"}); + push @dboptions, "ENCODING = " . $dbh->quote($form->{"encoding"}) if $form->{"encoding"}; if ($form->{"dbdefault"}) { my $dbdefault = $form->{"dbdefault"}; $dbdefault =~ s/[^a-zA-Z0-9_\-]//g; - push(@{$dboptions{"Pg"}}, "TEMPLATE = $dbdefault"); + push @dboptions, "TEMPLATE = $dbdefault"; } - my $query = $dbcreate{$form->{dbdriver}}; - $query .= " WITH " . join(" ", @{$dboptions{"Pg"}}) if (@{$dboptions{"Pg"}}); + my $query = qq|CREATE DATABASE "$form->{db}"|; + $query .= " WITH " . join(" ", @dboptions) if @dboptions; # Ignore errors if the database exists. $dbh->do($query); - if ($form->{dbdriver} eq 'Oracle') { - $query = qq|GRANT CONNECT, RESOURCE TO "$form->{db}"|; - do_query($form, $dbh, $query); - } $dbh->disconnect; - # setup variables for the new database - if ($form->{dbdriver} eq 'Oracle') { - $form->{dbuser} = $form->{db}; - $form->{dbpasswd} = $form->{db}; - } - &dbconnect_vars($form, $form->{db}); $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}, SL::DBConnect->get_options) @@ -367,7 +290,7 @@ sub dbcreate { my $db_charset = $Common::db_encoding_to_charset{$form->{encoding}}; $db_charset ||= Common::DEFAULT_CHARSET; - my $dbupdater = SL::DBUpgrade2->new(form => $form, dbdriver => $form->{dbdriver}); + my $dbupdater = SL::DBUpgrade2->new(form => $form); # create the tables $dbupdater->process_query($dbh, "sql/lx-office.sql", undef, $db_charset); @@ -395,14 +318,11 @@ sub dbdelete { my ($self, $form) = @_; $form->{db} =~ s/\"//g; - my %dbdelete = ('Pg' => qq|DROP DATABASE "$form->{db}"|, - 'Oracle' => qq|DROP USER "$form->{db}" CASCADE|); - $form->{sid} = $form->{dbdefault}; &dbconnect_vars($form, $form->{dbdefault}); my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}, SL::DBConnect->get_options) or $form->dberror; - my $query = $dbdelete{$form->{dbdriver}}; + my $query = qq|DROP DATABASE "$form->{db}"|; do_query($form, $dbh, $query); $dbh->disconnect; @@ -436,7 +356,7 @@ sub dbneedsupdate { my ($self, $form) = @_; my %members = $main::auth->read_all_users(); - my $dbupdater = SL::DBUpgrade2->new(form => $form, dbdriver => $form->{dbdriver})->parse_dbupdate_controls; + my $dbupdater = SL::DBUpgrade2->new(form => $form)->parse_dbupdate_controls; my ($query, $sth, %dbs_needing_updates); @@ -545,8 +465,6 @@ sub dbupdate { local *SQLDIR; - $form->{sid} = $form->{dbdefault}; - my @upgradescripts = (); my $query; my $rc = -2; @@ -554,11 +472,11 @@ sub dbupdate { if ($form->{dbupdate}) { # read update scripts into memory - opendir(SQLDIR, "sql/" . $form->{dbdriver} . "-upgrade") - or &error("", "sql/" . $form->{dbdriver} . "-upgrade : $!"); + opendir(SQLDIR, "sql/Pg-upgrade") + or &error("", "sql/Pg-upgrade : $!"); @upgradescripts = sort(cmp_script_version - grep(/$form->{dbdriver}-upgrade-.*?\.(sql|pl)$/, + grep(/Pg-upgrade-.*?\.(sql|pl)$/, readdir(SQLDIR))); closedir(SQLDIR); } @@ -566,7 +484,7 @@ sub dbupdate { my $db_charset = $::lx_office_conf{system}->{dbcharset}; $db_charset ||= Common::DEFAULT_CHARSET; - my $dbupdater = SL::DBUpgrade2->new(form => $form, dbdriver => $form->{dbdriver}); + my $dbupdater = SL::DBUpgrade2->new(form => $form); foreach my $db (split(/ /, $form->{dbupdate})) { @@ -591,7 +509,7 @@ sub dbupdate { foreach my $upgradescript (@upgradescripts) { my $a = $upgradescript; - $a =~ s/^\Q$form->{dbdriver}\E-upgrade-|\.(sql|pl)$//g; + $a =~ s/^Pg-upgrade-|\.(sql|pl)$//g; my ($mindb, $maxdb) = split /-/, $a; my $str_maxdb = $maxdb; @@ -605,7 +523,7 @@ sub dbupdate { # apply upgrade $main::lxdebug->message(LXDebug->DEBUG2(), "Applying Update $upgradescript"); - $dbupdater->process_file($dbh, "sql/" . $form->{"dbdriver"} . "-upgrade/$upgradescript", $str_maxdb, $db_charset); + $dbupdater->process_file($dbh, "sql/Pg-upgrade/$upgradescript", $str_maxdb, $db_charset); $version = $maxdb; @@ -626,8 +544,6 @@ sub dbupdate2 { my ($self, $form, $dbupdater) = @_; - $form->{sid} = $form->{dbdefault}; - my $rc = -2; my $db_charset = $::lx_office_conf{system}->{dbcharset} || Common::DEFAULT_CHARSET; @@ -655,7 +571,7 @@ sub dbupdate2 { $main::lxdebug->message(LXDebug->DEBUG2(), "Applying Update $control->{file}"); print $form->parse_html_template("dbupgrade/upgrade_message2", $control); - $dbupdater->process_file($dbh, "sql/" . $form->{"dbdriver"} . "-upgrade2/$control->{file}", $control, $db_charset); + $dbupdater->process_file($dbh, "sql/Pg-upgrade2/$control->{file}", $control, $db_charset); } $rc = 0; diff --git a/bin/mozilla/admin.pl b/bin/mozilla/admin.pl index 3eca96f2b..d1194ee8a 100755 --- a/bin/mozilla/admin.pl +++ b/bin/mozilla/admin.pl @@ -101,10 +101,6 @@ sub run { call_sub($locale->findsub($form->{action})); } } else { - # if there are no drivers bail out - $form->error($locale->text('No Database Drivers available!')) - unless (User->dbdrivers); - adminlogin(); } $::lxdebug->leave_sub; @@ -143,10 +139,7 @@ sub get_value { sub pg_database_administration { my $form = $main::form; - - $form->{dbdriver} = 'Pg'; dbselect_source(); - } sub dbselect_source { @@ -171,7 +164,6 @@ sub test_db_connection { my $form = $main::form; my $locale = $main::locale; - $form->{dbdriver} = 'Pg'; User::dbconnect_vars($form, $form->{dbname}); my $dbh = DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}); @@ -225,7 +217,7 @@ sub dbupdate { restore_form($saved_form); %::myconfig = (); - map { $form->{$_} = $::myconfig{$_} = $form->{"${_}_${i}"} } qw(dbname dbdriver dbhost dbport dbuser dbpasswd); + map { $form->{$_} = $::myconfig{$_} = $form->{"${_}_${i}"} } qw(dbname dbhost dbport dbuser dbpasswd); print $form->parse_html_template("admin/dbupgrade_header"); @@ -233,7 +225,7 @@ sub dbupdate { $form->{$form->{dbname}} = 1; User->dbupdate($form); - User->dbupdate2($form, SL::DBUpgrade2->new(form => $form, dbdriver => $form->{dbdriver})->parse_dbupdate_controls); + User->dbupdate2($form, SL::DBUpgrade2->new(form => $form)->parse_dbupdate_controls); print $form->parse_html_template("admin/dbupgrade_footer"); } diff --git a/scripts/dbupgrade2_tool.pl b/scripts/dbupgrade2_tool.pl index eb928f63e..3b9faf976 100755 --- a/scripts/dbupgrade2_tool.pl +++ b/scripts/dbupgrade2_tool.pl @@ -360,9 +360,9 @@ sub apply_upgrade { print "Applying upgrade $control->{file}\n"; if ($file_type eq "sql") { - $dbupgrader->process_query($dbh, "sql/$form->{dbdriver}-upgrade2/$control->{file}", $control, $db_charset); + $dbupgrader->process_query($dbh, "sql/Pg-upgrade2/$control->{file}", $control, $db_charset); } else { - $dbupgrader->process_perl_script($dbh, "sql/$form->{dbdriver}-upgrade2/$control->{file}", $control, $db_charset); + $dbupgrader->process_perl_script($dbh, "sql/Pg-upgrade2/$control->{file}", $control, $db_charset); } } @@ -499,7 +499,7 @@ GetOptions("list" => \$opt_list, show_help() if ($opt_help); -$dbupgrader = SL::DBUpgrade2->new(form => $form, dbdriver => 'Pg', auth => $opt_auth_db); +$dbupgrader = SL::DBUpgrade2->new(form => $form, auth => $opt_auth_db); $controls = $dbupgrader->parse_dbupdate_controls->{all_controls}; dump_list() if ($opt_list); diff --git a/templates/webpages/admin/backup_dataset.html b/templates/webpages/admin/backup_dataset.html index 3df1c89a7..baa70e548 100644 --- a/templates/webpages/admin/backup_dataset.html +++ b/templates/webpages/admin/backup_dataset.html @@ -27,7 +27,6 @@
- diff --git a/templates/webpages/admin/create_dataset.html b/templates/webpages/admin/create_dataset.html index 45938ca68..9f8b60d44 100644 --- a/templates/webpages/admin/create_dataset.html +++ b/templates/webpages/admin/create_dataset.html @@ -83,7 +83,6 @@ - diff --git a/templates/webpages/admin/dbadmin.html b/templates/webpages/admin/dbadmin.html index 014a1150b..1a07dc749 100644 --- a/templates/webpages/admin/dbadmin.html +++ b/templates/webpages/admin/dbadmin.html @@ -11,8 +11,6 @@ - -
diff --git a/templates/webpages/admin/delete_dataset.html b/templates/webpages/admin/delete_dataset.html index 082a76faf..1de867f8a 100644 --- a/templates/webpages/admin/delete_dataset.html +++ b/templates/webpages/admin/delete_dataset.html @@ -11,7 +11,6 @@

- diff --git a/templates/webpages/admin/restore_dataset.html b/templates/webpages/admin/restore_dataset.html index 6e297068e..bf23926a5 100644 --- a/templates/webpages/admin/restore_dataset.html +++ b/templates/webpages/admin/restore_dataset.html @@ -8,7 +8,6 @@ - diff --git a/templates/webpages/admin/update_dataset.html b/templates/webpages/admin/update_dataset.html index 29a5e6226..d8fb9336c 100644 --- a/templates/webpages/admin/update_dataset.html +++ b/templates/webpages/admin/update_dataset.html @@ -14,7 +14,6 @@
- @@ -28,7 +27,6 @@ - -- 2.20.1
[% 'Update?' | $T8 %][% 'Dataset' | $T8 %] [% 'Driver' | $T8 %] [% 'Host' | $T8 %] [% 'Port' | $T8 %] PostgreSQL [% HTML.escape(row.dbhost) %] [% HTML.escape(row.dbport) %] [% HTML.escape(row.dbuser) %]