Changeset 27298

Show
Ignore:
Timestamp:
06.05.2013 14:18:28 (6 years ago)
Author:
jmt12
Message:

Add hidden support for the new experimental multiple reader/writer functionality available in SQLite

Files:
1 modified

Legend:

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

    r24190 r27298  
    3737my $db_fast = 0; 
    3838 
     39# Set to 1 to enable Write Ahead Logging - which is supposed to allow multiple 
     40# readers/writers on a SQLite database (incompatible with db_fast). From SQLite 
     41# 3.7 onwards, WAL offers limited parallel reader/writer support but is limited 
     42# to single computers (doesn't work over networked filesystems). For details 
     43# see: http://www.sqlite.org/draft/wal.html [jmt12] 
     44my $db_wal = 0; 
    3945 
    4046# ----------------------------------------------------------------------------- 
     
    6066  # to the web page first, as part of the web page's headers, thus ruining the web page 
    6167  # which causes an Internal Server Error (500). Therefore, we redirect sqlite's output to 
    62   # the nul device instead.  
     68  # the nul device instead. 
     69  # using WAL mode (which also changes the journal) suffers a similar issue [jmt12] 
    6370  my $nul_device=""; 
    64   if(defined $db_fast && $db_fast == 1) { 
     71  if($db_fast == 1 || $db_wal == 1) { 
    6572    if($ENV{'GSDLOS'} =~ m/windows/) { 
    6673        $nul_device=">NUL"; 
     
    8592    print $infodb_handle "PRAGMA journal_mode=MEMORY;\n"; 
    8693  } 
    87    
     94  # Allow parallel readers/writers by using a Write Ahead Logger 
     95  elsif ($db_wal) 
     96  { 
     97    print $infodb_handle "PRAGMA journal_mode=WAL;\n"; 
     98  } 
     99 
    88100  # This is very important for efficiency, otherwise each command will be actioned one at a time 
    89101  print $infodb_handle "BEGIN TRANSACTION;\n";