[Bio] / FigKernelPackages / DBrtns.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/DBrtns.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18, Thu Jun 9 18:34:16 2005 UTC revision 1.25, Tue Jan 3 20:52:38 2006 UTC
# Line 1  Line 1 
1    #
2    # Copyright (c) 2003-2006 University of Chicago and Fellowship
3    # for Interpretations of Genomes. All Rights Reserved.
4    #
5    # This file is part of the SEED Toolkit.
6    #
7    # The SEED Toolkit is free software. You can redistribute
8    # it and/or modify it under the terms of the SEED Toolkit
9    # Public License.
10    #
11    # You should have received a copy of the SEED Toolkit Public License
12    # along with this program; if not write to the University of Chicago
13    # at info@ci.uchicago.edu or the Fellowship for Interpretation of
14    # Genomes at veronika@thefig.info or download a copy from
15    # http://www.theseed.org/LICENSE.TXT.
16    #
17    
18  package DBrtns;  package DBrtns;
19    
20      # Inherit the DBKernel methods. We must do this BEFORE the "use strict".      # Inherit the DBKernel methods. We must do this BEFORE the "use strict".
# Line 13  Line 30 
30  use Carp;  use Carp;
31    
32  sub new {  sub new {
33      my($class,$dbms,$dbname,$dbuser,$dbpass,$dbport) = @_;      my($class,$dbms,$dbname,$dbuser,$dbpass,$dbport, $dbhost) = @_;
34    
35      $dbms   = defined($dbms)   ? $dbms   : $FIG_Config::dbms;      $dbms   = defined($dbms)   ? $dbms   : $FIG_Config::dbms;
36      $dbname = defined($dbname) ? $dbname : $FIG_Config::db;      $dbname = defined($dbname) ? $dbname : $FIG_Config::db;
37      $dbuser = defined($dbuser) ? $dbuser : $FIG_Config::dbuser;      $dbuser = defined($dbuser) ? $dbuser : $FIG_Config::dbuser;
38      $dbpass = defined($dbpass) ? $dbpass : $FIG_Config::dbpass;      $dbpass = defined($dbpass) ? $dbpass : $FIG_Config::dbpass;
39      $dbport = defined($dbport) ? $dbport : $FIG_Config::dbport;      $dbport = defined($dbport) ? $dbport : $FIG_Config::dbport;
40        $dbhost = defined($dbhost) ? $dbhost : $FIG_Config::dbhost;
41    
42      return DBKernel::new($class, $dbms, $dbname, $dbuser, $dbpass, $dbport);      return DBKernel::new($class, $dbms, $dbname, $dbuser, $dbpass, $dbport, $dbhost);
 }  
   
 sub vacuum_it {  
     my($self,@tables) = @_;  
     my($table);  
   
     my $dbh  = $self->{_dbh};  
     my $dbms = $self->{_dbms};  
     if ($dbms eq "mysql") {  
         return;  
     }  
   
     # this chunk is for Pg  (Postgres)  
     if (@tables == 0) {  
         $self->SQL("VACUUM ANALYZE");  
     } else {  
         foreach $table (@tables) {  
             $self->SQL("VACUUM ANALYZE $table");  
         }  
     }  
43  }  }
44    
45  =head1 get_inserted_id  =head1 get_inserted_id
# Line 51  Line 49 
49  =cut  =cut
50    
51  sub get_inserted_id {  sub get_inserted_id {
52      my($self, $table, $sth) = @_;      my($self, $table, $sth, $id_column) = @_;
53    
54        $id_column = 'id' unless defined($id_column);
55      if ($self->{_dbms} eq "Pg") {      if ($self->{_dbms} eq "Pg") {
56          my $oid = $sth->{pg_oid_status};          my $oid = $sth->{pg_oid_status};
57          my $ret = $self->SQL("select id from $table where oid = ?", undef, $oid);          my $ret = $self->SQL("select $id_column from $table where oid = ?", undef, $oid);
58          return $ret->[0]->[0];          return $ret->[0]->[0];
59      } elsif ($self->{_dbms} eq "mysql") {      } elsif ($self->{_dbms} eq "mysql") {
60          my $id = $self->{_dbh}->{mysql_insertid};          my $id = $self->{_dbh}->{mysql_insertid};
61          # print "mysql got $id\n";          # print "mysql got $id\n";
62          return $id;          return $id;
63      }      }
64        else
65        {
66            confess "Attempting get_inserted_id on unsupported database $self->{_dbms}\n";
67        }
68  }  }
69    
70  #  #
# Line 189  Line 193 
193      push(@opts, "--old-password");      push(@opts, "--old-password");
194      push(@opts, "--max-allowed-packet=128M");      push(@opts, "--max-allowed-packet=128M");
195      #      #
196        # Use InnoDB for large-table support and allegedly better performance.
197        #
198    
199        #push(@opts, "--default-table-type=innodb");
200    
201        #
202      # Oddly, this doesn't seem to work. need to set the environment variable.      # Oddly, this doesn't seem to work. need to set the environment variable.
203      #      #
204      #push(@opts, "--port=$FIG_Config::dbport");      #push(@opts, "--port=$FIG_Config::dbport");
# Line 204  Line 214 
214      #      #
215    
216      my $exe = "$FIG_Config::ext_bin/mysqld_safe";      my $exe = "$FIG_Config::ext_bin/mysqld_safe";
217    
218        print "Start $exe @opts\n";
219      if (! -x $exe)      if (! -x $exe)
220      {      {
221          $exe = "mysqld_safe";          $exe = "mysqld_safe";

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.25

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3