[Secure-testing-commits] r16130 - lib/python
Florian Weimer
fw at alioth.debian.org
Sun Feb 13 21:07:03 UTC 2011
Author: fw
Date: 2011-02-13 21:06:56 +0000 (Sun, 13 Feb 2011)
New Revision: 16130
Modified:
lib/python/security_db.py
Log:
security_db.DB: upgrade to schema version 22 and use temporary views
We already use user-defined functions in some of them, so the views
are useless outside of the Python program. Temporary views are easier
to upgrade.
Modified: lib/python/security_db.py
===================================================================
--- lib/python/security_db.py 2011-02-13 21:01:42 UTC (rev 16129)
+++ lib/python/security_db.py 2011-02-13 21:06:56 UTC (rev 16130)
@@ -115,7 +115,7 @@
self.db = apsw.Connection(name)
self.verbose = verbose
- self.schema_version = 21
+ self.schema_version = 22
self._initFunctions()
c = self.cursor()
@@ -124,11 +124,21 @@
self.initSchema()
elif v == 20:
self._initSchema20()
+ elif v == 21:
+ # Remove legacy views.
+ for view in ('testing_status', 'stable_status',
+ 'oldstable_status'):
+ try:
+ c.execute('DROP VIEW ' + view)
+ except apsw.SQLError:
+ pass
+ c.execute("PRAGMA user_version = 22")
elif v <> self.schema_version:
if self.verbose:
print "DB: schema version mismatch: expected %d, got %d" \
% (self.schema_version, v)
raise SchemaMismatch, `v`
+ self._initViews(c)
# Database has been created at this point. Small race
# condition here (the already opened database might refer
# to an older file).
@@ -315,7 +325,6 @@
data TEXT NOT NULL)""")
self._initNoDSA(cursor)
- self._initViews(cursor)
cursor.execute("PRAGMA user_version = %d" % self.schema_version)
@@ -340,14 +349,8 @@
""")
def _initViews(self, cursor):
- for view in ('testing_status', 'stable_status', 'oldstable_status'):
- try:
- cursor.execute('DROP VIEW ' + view)
- except apsw.SQLError:
- pass
-
cursor.execute(
- """CREATE VIEW testing_status AS
+ """CREATE TEMPORARY VIEW testing_status AS
SELECT DISTINCT sp.name AS package, st.bug_name AS bug,
sp.archive AS section, st.urgency AS urgency,
st.vulnerable AS vulnerable,
@@ -378,7 +381,7 @@
for (name, nickname) in (('stable', 'squeeze'), ('oldstable', 'lenny'),):
cursor.execute(
- """CREATE VIEW %s_status AS
+ """CREATE TEMPORARY VIEW %s_status AS
SELECT DISTINCT sp.name AS package, st.bug_name AS bug,
sp.archive AS section, st.urgency AS urgency,
st.vulnerable AS vulnerable,
More information about the Secure-testing-commits
mailing list