X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;ds=sidebyside;f=db.sql;h=a9e2a5e0e10f4626003c227709b93658b5a29ad2;hb=34c41d71027a3e94c1f613baeea2e74e038e0108;hp=94ffce308a19b726172ff4e9e987d9ef24053750;hpb=51a6d79f8a532376a9f27dbb5133bf13a5474703;p=zpackage diff --git a/db.sql b/db.sql index 94ffce3..a9e2a5e 100644 --- a/db.sql +++ b/db.sql @@ -139,16 +139,47 @@ create table packagefiles ( foreign key (package,version,release) references packages (package,version,release) on delete cascade on update cascade, check (not (filetype = 'l' and target is null)), check (not (filetype = 'r' and hash is null)), - check (not (filetype = 'c' and (devmajor is null or devminor is null))) + check (not (filetype = 'c' and (devmajor is null or devminor is null))), + check (not (filetype = 'b' and (devmajor is null or devminor is null))), + check (configuration = 0 or configuration = 1) ) without rowid ; create view packagefiles_pkgid as -select printf('%s-%s-%s', package, version, release) as pkgid, * +select printf('%s-%s-%s', package, version, release) as pkgid, *, +printf('%s:%o:%s:%s', filetype, mode, username, groupname) as mds from packagefiles ; +create trigger packagefiles_update_trigger instead of +update on packagefiles_pkgid +begin + update packagefiles + set package = NEW.package, + version = NEW.version, + release = NEW.release, + path = NEW.path, + mode = NEW.mode, + username = NEW.username, + groupname = NEW.groupname, + uid = NEW.uid, + gid = NEW.gid, + configuration = NEW.configuration, + filetype = NEW.filetype, + target = NEW.target, + devmajor = NEW.devmajor, + devminor = NEW.devminor, + hash = NEW.hash, + mtime = NEW.mtime + where package = OLD.package + and version = OLD.version + and release = OLD.release + and path = OLD.path + ; +end +; + create view installed_ref_count as select I.path, count(*) as refcount from installedfiles I @@ -233,30 +264,20 @@ create table pathtags ( without rowid ; -create table elfinfo ( - file text primary key, -- hash of blob - elftype text, - foreign key (file) references files on delete cascade -) -without rowid -; - -create table elfdeps ( - file text, - soname text, - dependency text, - primary key (file, soname, dependency), - foreign key (file) references files on delete cascade -) -without rowid +create view elfdeps as +select PF.pkgid, PF.status, PF.path, N.needed as needs, +PL.path as library, PL.pkgid provider, PL.status as library_status +from packagefiles_status PF +join elfneeded N on N.file = PF.hash +left join elflibraries L on N.needed = L.soname +left join packagefiles_status PL on PL.hash = L.file ; -- TODO just elf information? -- and just hash, not package? create table elflibraries ( file text primary key, - soname text, - foreign key (file) references files on delete cascade + soname text ) without rowid ; @@ -264,8 +285,7 @@ without rowid create table elfneeded ( file text, needed text, -- soname of dependency - primary key (file, needed), - foreign key (file) references files on delete cascade + primary key (file, needed) ) without rowid ;