Skip to content

Commit

Permalink
Make the default pragma logic a bit simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
hinrik committed Feb 26, 2010
1 parent 4646d76 commit 3da1906
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
0.19
- Move File::Slurp from 'requires' to 'test_requires'
- Make the default pragma logic a bit simpler

0.18 Fri Feb 26 05:02:17 GMT 2010

Expand Down
20 changes: 8 additions & 12 deletions lib/Hailo/Storage/DBD/SQLite.pm
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,19 @@ sub _set_pragmas {
my ($self) = @_;

my %pragmas;

# speedy defaults when DB is not kept in memory
if (!$self->{in_memory}) {
$pragmas{synchronous} = 'OFF';
$pragmas{journal_mode} = 'OFF';
}

while (my ($k, $v) = each %{ $self->arguments }) {
if (my ($pragma) = $k =~ /^pragma_(.*)/) {
$pragmas{$pragma} = $v;
}
}

return if !%pragmas && $self->{in_memory};

# speedy defaults when DB is not kept in memory
if (!%pragmas) {
%pragmas = (
synchronous => 'OFF',
journal_mode => 'OFF',
);
}

while (my ($k, $v) = each %pragmas) {
$self->dbh->do(qq[PRAGMA $k="$v";])
}
Expand Down Expand Up @@ -186,8 +183,7 @@ is most likely not running as a mission-critical component this trade-off
should be acceptable in most cases. If the database becomes corrupt
it's easy to rebuild it by retraining from the input it was trained on
to begin with. For performance reasons, these two are set to B<'OFF'>
if no L<B<'pragma_*>|/pragma_*> parameters nor L<B<'in_memory'>|/in_memory>
are set.
by default unless L<B<'in_memory'>|/in_memory> is enabled.
=head3 C<in_memory>
Expand Down

0 comments on commit 3da1906

Please sign in to comment.