deal better with canonical paths: actually create a view row for

each fullpkgpath that results in a given canonical path.

note that there are "orphans" in _paths: the few bare pkgpaths entries that do
NOT correspond to a full-fledged fullpkgpath.

Add a paths view that shows the actual text associated with pkgpath and
canonical.
This commit is contained in:
espie 2018-11-29 11:44:58 +00:00
parent 634c9cdaa8
commit 0902eb5907
3 changed files with 13 additions and 5 deletions

View File

@ -1,7 +1,7 @@
# $OpenBSD: Makefile,v 1.89 2018/11/28 14:57:45 espie Exp $
# $OpenBSD: Makefile,v 1.90 2018/11/29 11:44:58 espie Exp $
CATEGORIES = databases
V = 7.0
V = 7.1
DISTNAME = sqlports-$V
DISTFILES =
COMMENT = sqlite database of ports

View File

@ -1,5 +1,5 @@
#! /usr/bin/perl
# $OpenBSD: Column.pm,v 1.12 2018/11/27 10:36:17 espie Exp $
# $OpenBSD: Column.pm,v 1.13 2018/11/29 11:44:58 espie Exp $
#
# Copyright (c) 2006-2010 Marc Espie <espie@openbsd.org>
#
@ -138,7 +138,7 @@ sub normal_schema
sub join_schema
{
my ($self, $table, $inserter) = @_;
return "JOIN ".$inserter->table_name("Paths")." ".$self->{table}." ON ".$self->table.".ID=$table.".$self->name;
return "JOIN ".$inserter->table_name("Paths")." ".$self->{table}." ON ".$self->table.".Canonical=$table.".$self->name;
}
package ValueColumn;

View File

@ -1,5 +1,5 @@
#! /usr/bin/perl
# $OpenBSD: Inserter.pm,v 1.23 2018/11/28 17:34:28 espie Exp $
# $OpenBSD: Inserter.pm,v 1.24 2018/11/29 11:44:58 espie Exp $
#
# Copyright (c) 2006-2010 Marc Espie <espie@openbsd.org>
#
@ -328,6 +328,14 @@ sub create_path_table
$self->new_table("Paths", "ID INTEGER PRIMARY KEY",
"FULLPKGPATH TEXT NOT NULL UNIQUE",
$self->pathref("PKGPATH"), $self->pathref("CANONICAL"));
my $t = $self->table_name("Paths");
$self->new_object('VIEW', "Paths",
qq{as select
$t.id as pathid, $t.fullpkgpath as fullpkgpath,
p1.fullpkgpath as pkgpath, p2.fullpkgpath as canonical
from $t
join $t p1 on p1.id=$t.pkgpath
join $t p2 on p2.id=$t.canonical});
$self->{adjust} = $self->db->prepare("UPDATE ".
$self->table_name("Paths")." set canonical=? where id=?");
}