diff options
-rw-r--r-- | bitbake/lib/prserv/db.py | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/bitbake/lib/prserv/db.py b/bitbake/lib/prserv/db.py index f430586d73..79c9001bf5 100644 --- a/bitbake/lib/prserv/db.py +++ b/bitbake/lib/prserv/db.py | |||
@@ -30,21 +30,18 @@ class PRTable(object): | |||
30 | self.read_only = read_only | 30 | self.read_only = read_only |
31 | self.table = table | 31 | self.table = table |
32 | 32 | ||
33 | # Creating the table even if the server is read-only. | ||
34 | # This avoids a race condition if a shared database | ||
35 | # is accessed by a read-only server first. | ||
36 | |||
33 | with closing(self.conn.cursor()) as cursor: | 37 | with closing(self.conn.cursor()) as cursor: |
34 | if self.read_only: | 38 | cursor.execute("CREATE TABLE IF NOT EXISTS %s \ |
35 | table_exists = cursor.execute( | 39 | (version TEXT NOT NULL, \ |
36 | "SELECT count(*) FROM sqlite_master \ | 40 | pkgarch TEXT NOT NULL, \ |
37 | WHERE type='table' AND name='%s'" % (self.table)) | 41 | checksum TEXT NOT NULL, \ |
38 | if not table_exists: | 42 | value TEXT, \ |
39 | raise prserv.NotFoundError | 43 | PRIMARY KEY (version, pkgarch, checksum, value));" % self.table) |
40 | else: | 44 | self.conn.commit() |
41 | cursor.execute("CREATE TABLE IF NOT EXISTS %s \ | ||
42 | (version TEXT NOT NULL, \ | ||
43 | pkgarch TEXT NOT NULL, \ | ||
44 | checksum TEXT NOT NULL, \ | ||
45 | value TEXT, \ | ||
46 | PRIMARY KEY (version, pkgarch, checksum, value));" % self.table) | ||
47 | self.conn.commit() | ||
48 | 45 | ||
49 | def _extremum_value(self, rows, is_max): | 46 | def _extremum_value(self, rows, is_max): |
50 | value = None | 47 | value = None |