Author: fw Date: 2005-09-22 10:52:10 +0000 (Thu, 22 Sep 2005) New Revision: 2084 Modified: lib/python/security_db.py Log: lib/python/security_db.py (DB.__init__): Create user-defined functions at an earlier point, before the schema. (DB.initSchema): Add testing_status view. Modified: lib/python/security_db.py ==================================================================--- lib/python/security_db.py 2005-09-22 10:30:14 UTC (rev 2083) +++ lib/python/security_db.py 2005-09-22 10:52:10 UTC (rev 2084) @@ -94,6 +94,7 @@ self.verbose = verbose self.schema_version = 11 + self._initFunctions() c = self.cursor() for (v,) in c.execute("PRAGMA user_version"): @@ -104,8 +105,6 @@ print "DB: schema version mismatch: expected %d, got %d" \ % (self.schema_version, v) raise SchemaMismatch, `v` - - self._initFunctions() return assert False @@ -261,7 +260,31 @@ cursor.execute( """CREATE INDEX binary_package_status_package ON binary_package_status(package)""") - + + cursor.execute( + """CREATE VIEW testing_status AS + SELECT DISTINCT sp.name AS package, st.bug_name AS bug, + sp.archive AS section, st.urgency AS urgency, + (SELECT vulnerable + FROM source_packages AS sidp, source_package_status AS sidst + WHERE sidp.name = sp.name + AND sidp.release = ''sid'' AND sidp.subrelease = '''' + AND sidp.archive = sp.archive + AND sidst.bug_name = st.bug_name + AND sidst.package = sidp.rowid) AS unstable_vulnerable, + COALESCE((SELECT NOT vulnerable + FROM source_packages AS tsecp, source_package_status AS tsecst + WHERE tsecp.name = sp.name + AND tsecp.release = ''etch'' AND tsecp.subrelease = ''security'' + AND tsecp.archive = sp.archive + AND tsecst.bug_name = st.bug_name + AND tsecst.package = tsecp.rowid), 0) AS testing_security_fixed + FROM source_package_status AS st, source_packages AS sp + WHERE st.vulnerable AND st.urgency <> ''unimportant'' + AND sp.rowid = st.package AND sp.release = ''etch'' + AND sp.subrelease = '''' + ORDER BY sp.name, urgency_to_number(st.urgency), st.bug_name""") + cursor.execute("PRAGMA user_version = %d" % self.schema_version) def _initFunctions(self):