Index: includes/bootstrap.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v retrieving revision 1.60 diff -u -p -r1.60 bootstrap.inc --- includes/bootstrap.inc 5 Aug 2005 00:49:02 -0000 1.60 +++ includes/bootstrap.inc 19 Aug 2005 11:27:57 -0000 @@ -233,10 +233,10 @@ function variable_get($name, $default) { function variable_set($name, $value) { global $conf; - db_query('LOCK TABLES {variable} WRITE'); + db_lock_table('variable'); db_query("DELETE FROM {variable} WHERE name = '%s'", $name); db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", $name, serialize($value)); - db_query('UNLOCK TABLES'); + db_unlock_tables(); cache_clear_all('variables'); @@ -320,12 +320,12 @@ function cache_get($key) { function cache_set($cid, $data, $expire = CACHE_PERMANENT, $headers = NULL) { $data = db_encode_blob($data); - db_query('LOCK TABLES {cache} WRITE'); + db_lock_table('cache'); db_query("UPDATE {cache} SET data = '%s', created = %d, expire = %d, headers = '%s' WHERE cid = '%s'", $data, time(), $expire, $headers, $cid); if (!db_affected_rows()) { @db_query("INSERT INTO {cache} (cid, data, created, expire, headers) VALUES ('%s', '%s', %d, %d, '%s')", $cid, $data, time(), $expire, $headers); } - db_query('UNLOCK TABLES'); + db_unlock_tables(); } /** @@ -879,4 +879,4 @@ function drupal_maintenance_theme() { $theme = ''; } -?> \ No newline at end of file +?> Index: includes/database.mysql.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database.mysql.inc,v retrieving revision 1.34 diff -u -p -r1.34 database.mysql.inc --- includes/database.mysql.inc 11 Aug 2005 13:51:07 -0000 1.34 +++ includes/database.mysql.inc 19 Aug 2005 11:27:57 -0000 @@ -270,6 +270,21 @@ function db_escape_string($text) { } /** + * Lock a table. + */ +function db_lock_table($table) { + db_query("LOCK TABLES {$table} WRITE"); +} + +/** + * Unlock all locked tables. + */ +function db_unlock_tables() { + db_query('UNLOCK TABLES'); +} + + +/** * @} End of "ingroup database". */ Index: includes/database.pgsql.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database.pgsql.inc,v retrieving revision 1.12 diff -u -p -r1.12 database.pgsql.inc --- includes/database.pgsql.inc 11 Aug 2005 13:51:07 -0000 1.12 +++ includes/database.pgsql.inc 19 Aug 2005 11:27:57 -0000 @@ -256,6 +256,22 @@ function db_escape_string($text) { } /** + * Lock a table. + * This function automatically starts a transaction. + */ +function db_lock_table($table) { + db_query("BEGIN; LOCK TABLE {$table} IN EXCLUSIVE MODE"); +} + +/** + * Unlock all locked tables. + * This function automatically commits a transation. + */ +function db_unlock_tables() { + db_query('COMMIT'); +} + +/** * @} End of "ingroup database". */