3 #define _RPMSQL_INTERNAL
4 #define _RPMVT_INTERNAL
5 #define _RPMVC_INTERNAL
19 CREATE TABLE registry.metadata (
23 INSERT INTO registry.metadata (
key, value) VALUES (
'version', 1.000);
24 INSERT INTO registry.metadata (
key, value) VALUES (
'created', strftime(
'%s',
'now'));
27 CREATE TABLE registry.ports (
28 id INTEGER PRIMARY
KEY AUTOINCREMENT,
29 name TEXT COLLATE NOCASE,
37 negated_variants TEXT,
45 UNIQUE (
name, epoch, version, revision, variants),
46 UNIQUE (url, epoch, version, revision, variants)
48 CREATE INDEX registry.port_name ON ports
49 (
name, epoch, version, revision, variants);
50 CREATE INDEX registry.port_url ON ports
51 (url, epoch, version, revision, variants);
52 CREATE INDEX registry.port_state ON ports (state);
55 CREATE TABLE registry.files (
63 FOREIGN
KEY(
id) REFERENCES ports(
id));
64 CREATE INDEX registry.file_port ON files (
id);
65 CREATE INDEX registry.file_path ON files(path);
66 CREATE INDEX registry.file_actual ON files(actual_path);
69 CREATE TABLE registry.dependencies (
73 FOREIGN
KEY(
id) REFERENCES ports(
id));
74 CREATE INDEX registry.dep_name ON dependencies (
name);
82 CREATE TEMPORARY TABLE
items (refcount, proc UNIQUE,
name, url, path,
86 CREATE TEMPORARY TABLE indexes (
file,
name, attached);
95 create table
if not exists ValidPaths (
96 id integer primary
key autoincrement not null,
97 path text unique not null,
99 registrationTime integer not null,
103 create table
if not exists Refs (
104 referrer integer not null,
105 reference integer not null,
106 primary
key (referrer, reference),
107 foreign
key (referrer) references ValidPaths(
id) on
delete cascade,
108 foreign
key (reference) references ValidPaths(
id) on
delete restrict
111 create index
if not exists IndexReferrer on Refs(referrer);
112 create index
if not exists IndexReference on Refs(reference);
114 -- Paths can refer to themselves, causing a tuple (N, N)
in the Refs
115 -- table. This causes a deletion of the corresponding row
in
116 -- ValidPaths to cause a foreign
key constraint violation (due to `on
117 -- delete restrict' on the `reference' column). Therefore, explicitly
118 -- get rid of self-references.
119 create trigger if not exists DeleteSelfRefs before delete on ValidPaths
121 delete from Refs where referrer = old.
id and reference = old.
id;
124 create table if not exists DerivationOutputs (
125 drv integer not null,
126 id text not null, -- symbolic
output id, usually "
out"
128 primary
key (drv,
id),
129 foreign
key (drv) references ValidPaths(
id) on delete cascade
132 create index if not exists IndexDerivationOutputs on DerivationOutputs(path);
134 create table if not exists FailedPaths (
135 path text primary
key not null,
136 time integer not null
141 .dbpath =
"/nix/var/nix/db/db.sqlite",
143 .prefix =
"/nix/store/[a-z0-9]*-",
145 .parse =
"dir/instance-name",
146 .regex =
"^(.+/)([^-]+)-(.*)$",
151 int argc,
const char *
const * argv,
152 rpmvt * vtp,
char ** pzErr)
154 return rpmvtLoadArgv(
rpmvtNew(_db, pAux, argv, &_nixdbVD), vtp);
164 static struct rpmsqlVMT_s
__VMT[] = {
173 SQLDBG((stderr,
"--> %s(%p)\n", __FUNCTION__, _db));
174 rc = _rpmsqlLoadVMT(_db, __VMT);
175 SQLDBG((stderr,
"<-- %s(%p) rc %d\n", __FUNCTION__, _db, rc));
static struct rpmvd_s _nixdbVD
static int nixdbCreateConnect(void *_db, void *pAux, int argc, const char *const *argv, rpmvt *vtp, char **pzErr)
int sqlite3_extension_init(void *_db)
rpmvt rpmvtNew(void *db, void *pModule, const char *const *argv, rpmvd vd)
static unsigned int hash(const char *str)
static struct rpmsqlVMT_s __VMT[]
static void output(int indent, int *offset, const char *fmt,...)
const char const bson * key
const char const bson const bson bson * out
struct sqlite3_module nixdbModule
const char const bson const bson int int int options