[Lxr-commits] CVS: lxr/lib/LXR/Index Mysql.pm,1.11,1.12 Postgres.pm,1.7,1.8
Brought to you by:
ajlittoz
From: Malcolm B. <mb...@us...> - 2001-11-18 03:31:37
|
Update of /cvsroot/lxr/lxr/lib/LXR/Index In directory usw-pr-cvs1:/tmp/cvs-serv15958/lib/LXR/Index Modified Files: Mysql.pm Postgres.pm Log Message: Fix bug 476695 - Java interfaces display as docs. Changes the type field in the indexes table to be a (langid, typeid) tuple, and adds another table to look up the (langid, typeid) -> string mapping. This means that each language module can manage its own string table and the right identifier type can easily be displayed. This also means that each identifier is tagged with the language it occurs in, which could be used for filtering displayed results when browsing. This has not been implemented. This change is database incompatible - you will need to drop and recreate the lxr database. MySQL has been tested, Postgres has not though the changes have been made. Also add some limited support for Makefile in generic.conf. Index: Mysql.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Index/Mysql.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- Mysql.pm 2001/11/14 15:41:37 1.11 +++ Mysql.pm 2001/11/18 03:31:34 1.12 @@ -59,13 +59,14 @@ ("delete from symbols where symname = ?"); $self->{indexes_select} = $self->{dbh}->prepare - ("select f.filename, i.line, i.type, i.relsym ". - "from symbols s, indexes i, files f, releases r ". + ("select f.filename, i.line, d.declaration, i.relsym ". + "from symbols s, indexes i, files f, releases r, declarations d ". "where s.symid = i.symid and i.fileid = f.fileid ". "and f.fileid = r.fileid ". + "and i.langid = d.langid and i.type = d.declid ". "and s.symname = ? and r.release = ?"); $self->{indexes_insert} = $self->{dbh}->prepare - ("insert into indexes (symid, fileid, line, type, relsym) values (?, ?, ?, ?, ?)"); + ("insert into indexes (symid, fileid, line, langid, type, relsym) values (?, ?, ?, ?, ?, ?)"); $self->{releases_select} = $self->{dbh}->prepare ("select * from releases where fileid = ? and release = ?"); @@ -89,21 +90,27 @@ "from symbols s, files f, releases r, useage u ". "where s.symid = u.symid ". "and f.fileid = u.fileid ". - "and u.fileid = r.fileid and ". - "s.symname = ? and r.release = ? ". + "and u.fileid = r.fileid ". + "and s.symname = ? and r.release = ? ". "order by f.filename"); + $self->{decl_select} = $self->{dbh}->prepare + ("select declid from declarations where langid = ? and ". + "declaration = ?"); + $self->{decl_insert} = $self->{dbh}->prepare + ("insert into declarations (declid, langid, declaration) values (NULL, ?, ?)"); return $self; } sub index { - my ($self, $symname, $fileid, $line, $type, $relsym) = @_; + my ($self, $symname, $fileid, $line, $langid, $type, $relsym) = @_; $self->{indexes_insert}->execute($self->symid($symname), - $fileid, - $line, - $type, - $relsym ? $self->symid($relsym) : undef); + $fileid, + $line, + $langid, + $type, + $relsym ? $self->symid($relsym) : undef); } sub reference { @@ -147,17 +154,6 @@ return @ret; } -sub relate { - my ($self, $symname, $release, $rsymname, $reltype) = @_; - -# $relation{$self->symid($symname, $release)} .= -# join("\t", $self->symid($rsymname, $release), $reltype, ''); -} - -sub getrelations { - my ($self, $symname, $release) = @_; -} - sub fileid { my ($self, $filename, $revision) = @_; my ($fileid); @@ -268,6 +264,24 @@ %symcache = (); } +sub getdecid { + my ($self, $lang, $string) = @_; + + my $rows = $self->{decl_select}->execute($lang, $string); + $self->{decl_select}->finish(); + + unless ($rows > 0) { + $self->{decl_insert}->execute($lang, $string); + } + + $self->{decl_select}->execute($lang, $string); + my $id = $self->{decl_select}->fetchrow_array(); + $self->{decl_select}->finish(); + + return $id; +} + + sub DESTROY { my ($self) = @_; $self->{files_select} = undef; @@ -281,7 +295,9 @@ $self->{status_update} = undef; $self->{usage_insert} = undef; $self->{usage_select} = undef; - + $self->{decl_select} = undef; + $self->{decl_insert} = undef; + if($self->{dbh}) { $self->{dbh}->disconnect(); $self->{dbh} = undef; Index: Postgres.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Index/Postgres.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Postgres.pm 2001/08/15 15:50:27 1.7 +++ Postgres.pm 2001/11/18 03:31:34 1.8 @@ -28,7 +28,8 @@ $symbols_byname $symbols_byid $symnum_nextval $symbols_remove $symbols_insert $indexes_select $indexes_insert $releases_select $releases_insert $status_insert - $status_update $usage_insert $usage_select); + $status_update $usage_insert $usage_select $decl_select + $declid_nextnum $decl_insert); sub new { @@ -65,13 +66,15 @@ ("delete from symbols where symname = ?"); $indexes_select = $dbh->prepare - ("select f.filename, i.line, i.type, i.relsym ". - "from symbols s, indexes i, files f, releases r ". + ("select f.filename, i.line, d.type, i.relsym ". + "from symbols s, indexes i, files f, releases r, declarations d ". "where s.symid = i.symid and i.fileid = f.fileid ". "and f.fileid = r.fileid ". + "and i.langid = d.langid and i.type = d.declid ". "and s.symname = ? and r.release = ?"); $indexes_insert = $dbh->prepare - ("insert into indexes values (?, ?, ?, ?, ?)"); + ("insert into indexes (symid, fileid, line, langid, type, relsym) ". + "values (?, ?, ?, ?, ?, ?)"); $releases_select = $dbh->prepare ("select * from releases where fileid = ? and release = ?"); @@ -96,6 +99,15 @@ "and f.fileid = r.fileid and ". "s.symname = ? and r.release = ?"); + $declid_nextnum = $dbh->prepare + ("select nextval('declnum')"); + + $decl_select = $dbh->prepare + ("select declid from declarations where langid = ? and ". + "declaration = ?"); + $decl_insert = $dbh->prepare + ("insert into declarations (declid, langid, declaration) values (?, ?, ?)"); + return $self; } @@ -104,11 +116,12 @@ } sub index { - my ($self, $symname, $fileid, $line, $type, $relsym) = @_; + my ($self, $symname, $fileid, $line, $langid, $type, $relsym) = @_; $indexes_insert->execute($self->symid($symname), $fileid, $line, + $langid, $type, $relsym ? $self->symid($relsym) : undef); unless (++$transactions % $commitlimit) { @@ -260,6 +273,26 @@ return $status_update->execute(2, $fileid, 1) > 0; } +sub getdecid { + my ($self, $lang, $string) = @_; + + my $rows = $decl_select->execute($lang, $string); + $decl_select->finish(); + + unless ($rows > 0) { + $declid_nextnum->execute(); + my ($declid) = $declid_nextnum->fetchrow_array(); + $decl_insert->execute($declid, $lang, $string); + } + + $decl_select->execute($lang, $string); + my $id = decl_select->fetchrow_array(); + $decl_select->finish(); + + return $id; +} + + sub END { $files_select = undef; $filenum_nextval = undef; @@ -274,7 +307,10 @@ $status_update = undef; $usage_insert = undef; $usage_select = undef; - + $declid_nextnum = undef; + $decl_select = undef; + $decl_insert = undef; + $dbh->commit(); $dbh->disconnect(); $dbh = undef; |