Ignore:
Timestamp:
2010-12-07T16:55:10+13:00 (13 years ago)
Author:
max
Message:

Added (for GDBM and Sqlite) set_infodb_entry to directly change one value in the database. Print statements added to other versions of function, alterting that they are not implemented.

Also added read_infodb_rawentry. Plus, more efficient way of accessing a single record from Sqlite.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/dbutil.pm

    r22485 r23399  
    221221  my $infodb_key = shift(@_);
    222222
     223 
     224  if ($infodb_type eq "sqlite")
     225  {
     226    require dbutil::sqlite;
     227    return &dbutil::sqlite::read_infodb_entry($infodb_file_path, $infodb_key, @_);
     228  }
     229#  elsif ($infodb_type eq "gdbm-txtgz")
     230#  {
     231#    require dbutil::gdbmtxtgz;
     232#    return &dbutil::gdbmtxtgz::read_infodb_entry($infodb_file_path, $infodb_key, @_);
     233#  }
     234#  elsif ($infodb_type eq "jdbm")
     235#  {
     236#    require dbutil::jdbm;
     237#    return &dbutil::jdbm::read_infodb_entry($infodb_file_path, $infodb_key, @_);
     238#  }
     239#  elsif ($infodb_type eq "mssql")
     240#  {
     241#    require dbutil::mssql;
     242#    return &dbutil::mssql::read_infodb_entry($infodb_file_path, $infodb_key, @_);
     243#  }
     244 
     245#  # Use GDBM if the infodb type is empty or not one of the values above
     246#  require dbutil::gdbm;
     247#  return &dbutil::gdbm::read_infodb_entry($infodb_file_path, $infodb_key, @_);
     248 
     249 
     250 
    223251  # !! TEMPORARY: Slow and naive implementation that just reads the entire file and picks out the one value
    224252  # !! This will soon be replaced with database-specific versions that will use dbget etc.
     
    294322  require dbutil::gdbm;
    295323  return &dbutil::gdbm::write_infodb_rawentry($infodb_handle, $infodb_key, $infodb_val, @_);
     324}
     325
     326
     327sub set_infodb_entry
     328{
     329  my $infodb_type = shift(@_);
     330  my $infodb_file_path = shift(@_);
     331  my $infodb_key = shift(@_);
     332  my $infodb_map = shift(@_);
     333
     334  if ($infodb_type eq "sqlite")
     335  {
     336    require dbutil::sqlite;
     337    return &dbutil::sqlite::set_infodb_entry($infodb_file_path, $infodb_key, $infodb_map, @_);
     338  }
     339  elsif ($infodb_type eq "gdbm-txtgz")
     340  {
     341    require dbutil::gdbmtxtgz;
     342    return &dbutil::gdbmtxtgz::set_infodb_entry($infodb_file_path, $infodb_key, $infodb_map, @_);
     343  }
     344  elsif ($infodb_type eq "jdbm")
     345  {
     346    require dbutil::jdbm;
     347    return &dbutil::jdbm::set_infodb_entry($infodb_file_path, $infodb_key, $infodb_map, @_);
     348  }
     349  elsif ($infodb_type eq "mssql")
     350  {
     351    require dbutil::mssql;
     352    return &dbutil::mssql::set_infodb_entry($infodb_file_path, $infodb_key, $infodb_map, @_);
     353  }
     354
     355  # Use GDBM if the infodb type is empty or not one of the values above
     356  require dbutil::gdbm;
     357  return &dbutil::gdbm::set_infodb_entry($infodb_file_path, $infodb_key, $infodb_map, @_);
    296358}
    297359
Note: See TracChangeset for help on using the changeset viewer.