On testing Drupal 4.7 I was saddened to see that 4.7 still requires LOCK TABLE permission - only this time it's harder to fix.
Previously, the sole fix was in db_next_id in database.mysql.inc - of course such fixes are hotly contested and largey unsupported.
Now, two new functions have been added, db_lock_table and db_unlock_table. These are called to lock the variables and the cache tables in bootstrap.inc.
So, where previously, an update to db_next_id in database.mysql.inc such as:
function db_next_id($name) {
$name = db_prefix_tables($name);
$id = db_result(db_query("SELECT id FROM {sequences} WHERE name = '%s' FOR UPDATE", $name)) + 1;
db_query("REPLACE INTO {sequences} VALUES ('%s', %d)", $name, $id);
return $id;
}
has now to be replicated to bootstrap.inc such as:
function variable_set($name, $value) {
global $conf;
db_query("SELECT name FROM {variable} WHERE name = '%s' FOR UPDATE", $name);
db_query("REPLACE INTO {variable} (name, value) VALUES ('%s', '%s')", $name, serialize($value));
if (!db_affected_rows()) {
db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s') FOR UPDATE", $name, serialize($value));
}
cache_clear_all('variables');
$conf[$name] = $value;
}
and
function cache_set($cid, $data, $expire = CACHE_PERMANENT, $headers = NULL) {
db_query("SELECT cid FROM {cache} WHERE cid = '%s' FOR UPDATE", $cid);