[Lxr-commits] CVS: lxr/lib/LXR/Index Mysql.pm, 1.26, 1.27 Postgres.pm, 1.26, 1.27
Brought to you by:
ajlittoz
From: Malcolm B. <mb...@us...> - 2009-05-06 22:38:02
|
Update of /cvsroot/lxr/lxr/lib/LXR/Index In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv28856/lib/LXR/Index Modified Files: Mysql.pm Postgres.pm Log Message: Fix for bugs 2787781 and 2787771. Changes the interface to Mysql & Postgres to match the documentation so that fileindexed returns whether the file has been indexed, not whether it needs indexing. Aligned the Postgres and Mysql implementations of fileindexed, filereferenced, setfileindexed and setfilereferenced. NOTE: This commit will break any Index module that has not been updated. Part II will fix these Index: Mysql.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Index/Mysql.pm,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- Mysql.pm 26 Apr 2009 09:14:37 -0000 1.26 +++ Mysql.pm 6 May 2009 22:37:50 -0000 1.27 @@ -208,15 +208,24 @@ $self->{status_get}->finish(); if (!defined($status)) { - $self->{status_insert}->execute($fileid + 0, 0); + $status = 0; } - - return $status == 0; + return $status; } sub setfileindexed { my ($self, $fileid) = @_; - $self->{status_update}->execute(1, $fileid, 0); + my ($status); + + $self->{status_get}->execute($fileid); + $status = $self->{status_get}->fetchrow_array(); + $self->{status_get}->finish(); + + if (!defined($status)) { + $self->{status_insert}->execute($fileid + 0, 1); + } else { + $self->{status_update}->execute(1, $fileid, 0); + } } sub filereferenced { @@ -227,12 +236,22 @@ $status = $self->{status_get}->fetchrow_array(); $self->{status_get}->finish(); - return $status < 2; + return defined($status) && $status == 2; } sub setfilereferenced { my ($self, $fileid) = @_; - $self->{status_update}->execute(2, $fileid, 1); + my ($status); + + $self->{status_get}->execute($fileid); + $status = $self->{status_get}->fetchrow_array(); + $self->{status_get}->finish(); + + if (!defined($status)) { + $self->{status_insert}->execute($fileid + 0, 2); + } else { + $self->{status_update}->execute(2, $fileid, 1); + } } sub symdeclarations { Index: Postgres.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Index/Postgres.pm,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- Postgres.pm 26 Apr 2009 09:14:37 -0000 1.26 +++ Postgres.pm 6 May 2009 22:37:50 -0000 1.27 @@ -28,7 +28,7 @@ $files_select $filenum_nextval $files_insert $symbols_byname $symbols_byid $symnum_nextval $symbols_remove $symbols_insert $indexes_select $indexes_insert - $releases_select $releases_insert $status_insert + $releases_select $releases_insert $status_get $status_insert $status_update $usage_insert $usage_select $decl_select $declid_nextnum $decl_insert $delete_indexes $delete_usage $delete_status $delete_releases $delete_files $prefix); @@ -81,13 +81,10 @@ $releases_select = $dbh->prepare("select * from ${prefix}releases where fileid = ? and release = ?"); $releases_insert = $dbh->prepare("insert into ${prefix}releases values (?, ?)"); - + $status_get = $dbh->prepare("select status from ${prefix}status where fileid = ?"); $status_insert = $dbh->prepare - - # ("insert into status select ?, 0 except select fileid, 0 from status"); - ( "insert into ${prefix}status select ?, 0 where not exists " - . "(select * from ${prefix}status where fileid = ?)"); - + ("insert into ${prefix}status (fileid, status) values (?, ?)"); + $status_update = $dbh->prepare("update ${prefix}status set status = ? where fileid = ? and status <= ?"); @@ -198,30 +195,59 @@ _commitIfLimit(); } -# If this file has not been indexed earlier, mark it as being indexed -# now and return true. Return false if already indexed. sub fileindexed { my ($self, $fileid) = @_; + my ($status); - $status_insert->execute($fileid + 0, $fileid + 0); - _commitIfLimit(); - return $status_update->execute(1, $fileid + 0, 0) > 0; + $status_get->execute($fileid); + $status = $status_get->fetchrow_array(); + $status_get->finish(); + + if (!defined($status)) { + $status = 0; + } + return $status; } sub setfileindexed { my ($self, $fileid) = @_; - $status_update->execute(1, $fileid, 0); + my ($status); + + $status_get->execute($fileid); + $status = $status_get->fetchrow_array(); + $status_get->finish(); + + if (!defined($status)) { + $status_insert->execute($fileid + 0, 1); + } else { + $status_update->execute(1, $fileid, 0); + } } sub filereferenced { my ($self, $fileid) = @_; + my ($status); - return $status_update->execute(2, $fileid, 1) > 0; + $status_get->execute($fileid); + $status = $status_get->fetchrow_array(); + $status_get->finish(); + + return defined($status) && $status == 2; } sub setfilereferenced { my ($self, $fileid) = @_; - $status_update->execute(2, $fileid, 1); + my ($status); + + $status_get->execute($fileid); + $status = $status_get->fetchrow_array(); + $status_get->finish(); + + if (!defined($status)) { + $status_insert->execute($fileid + 0, 2); + } else { + $status_update->execute(2, $fileid, 1); + } } sub symdeclarations { |