aboutsummaryrefslogtreecommitdiffstats
path: root/lib/LXRng/Index/Pg.pm
diff options
context:
space:
mode:
authorArne Georg Gleditsch <argggh@lxr.linpro.no>2007-11-27 01:10:58 +0100
committerArne Georg Gleditsch <argggh@lxr.linpro.no>2007-11-27 01:10:58 +0100
commit77f76725888920d10b527db5f291d704f0f5b26d (patch)
tree1c0e1874bcdc90352548f5125cbdb96643aa5002 /lib/LXRng/Index/Pg.pm
parent5c682b22600bbd08888af07f93422c1cd733609d (diff)
Rework usage stats.
Diffstat (limited to 'lib/LXRng/Index/Pg.pm')
-rw-r--r--lib/LXRng/Index/Pg.pm20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/LXRng/Index/Pg.pm b/lib/LXRng/Index/Pg.pm
index 1b905c0..a385767 100644
--- a/lib/LXRng/Index/Pg.pm
+++ b/lib/LXRng/Index/Pg.pm
@@ -154,9 +154,9 @@ sub init_db {
$dbh->do(qq{
create table ${pre}usage
(
- id_rfile int references ${pre}revisions(id) deferrable,
- id_symbol int references ${pre}symbols(id) deferrable,
- line int
+ id_rfile int,
+ id_symbol int,
+ lines int[]
)
}) or die($dbh->errstr);
@@ -407,6 +407,20 @@ sub _add_ident {
return $id;
}
+sub _add_usage {
+ my ($self, $file_id, $symbol_id, $lines) = @_;
+
+ my $dbh = $self->dbh;
+ my $pre = $self->prefix;
+ my $sth = $$self{'sth'}{'_add_usage'} ||=
+ $dbh->prepare(qq{insert into ${pre}usage(id_rfile, id_symbol, lines)
+ values (?, ?, ?)});
+ $sth->execute($file_id, $symbol_id, '{'.join(',', @$lines).'}');
+
+ return 1;
+}
+
+
sub DESTROY {
my ($self) = @_;