--- trunk/index_DBI_cache.pm 2003/11/29 19:07:00 188 +++ trunk/index_DBI_cache.pm 2004/01/31 20:57:48 206 @@ -11,6 +11,7 @@ use vars qw($Count); use HTML::Entities; use URI::Escape; +use locale; use DBI; @@ -43,6 +44,8 @@ my $user = shift || die "need dbi_user= in [global] section of configuration file"; my $passwd = shift || die "need dbi_passwd= in [global] section of configuration file"; + $self->{dbd} = $dbd; + $self->{dbh} = DBI->connect("DBI:$dbd:$dsn",$user,$passwd) || die $DBI::errstr; $Count++; @@ -160,7 +163,7 @@ } else { # if no match is found when searching from beginning # of word in index, try substring match anywhere - $sql2 = "select ord from $field where upper(item) like '%'||upper(?)||'%'"; + $sql2 = "select ord from $field where upper(item) like '% '||upper(?)||'%'"; $sth = $self->{dbh}->prepare($sql2) || die "sql2: $sql2; ".$self->{dbh}->errstr(); $sth->execute($where) || die "sql2: $sql2; ".$self->{dbh}->errstr(); if (my $row = $sth->fetchrow_hashref) { @@ -210,6 +213,11 @@ $self->{dbh}->commit || die $self->{dbh}->errstr(); } + + if ($self->{dbd} =~ m/(Pg|SQLite)/) { + $self->{dbh}->do(qq{vacuum}) || warn "vacumming failed. It shouldn't if you are using PostgreSQL or SQLite: ".$self->{dbh}->errstr(); + } + $self->bench("disconnecting from database"); $self->{dbh}->disconnect;