Added methods to create utilize a lock table for managing access to the database during a multi-threaded import. Currently, only MySQL is supported

This commit is contained in:
Chaz Littlejohn
2011-03-23 19:27:55 +00:00
parent 3c2fdaf53e
commit dd6ce46487
2 changed files with 57 additions and 0 deletions
+28
View File
@@ -107,6 +107,15 @@ class Sql:
elif db_server == 'sqlite':
self.query['createSettingsTable'] = """CREATE TABLE Settings
(version INTEGER NOT NULL) """
################################
# Create InsertLock
################################
if db_server == 'mysql':
self.query['createLockTable'] = """CREATE TABLE InsertLock (
id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
locked BOOLEAN NOT NULL DEFAULT FALSE)
ENGINE=INNODB"""
################################
# Create RawHands (this table is all but identical with RawTourneys)
@@ -4501,6 +4510,25 @@ class Sql:
self.query['analyze'] = "analyze"
elif db_server == 'sqlite':
self.query['analyze'] = "analyze"
if db_server == 'mysql':
self.query['selectLock'] = """
SELECT locked
FROM InsertLock
WHERE locked=True
LOCK IN SHARE MODE"""
if db_server == 'mysql':
self.query['switchLock'] = """
UPDATE InsertLock SET
locked=%s
WHERE id=%s"""
if db_server == 'mysql':
self.query['missedLock'] = """
UPDATE InsertLock SET
missed=missed+%s
WHERE id=%s"""
if db_server == 'mysql':
self.query['lockForInsert'] = """