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);
db_query("REPLACE INTO {cache} (cid, data, created, expire, headers) VALUES ("%s", %b, %d, %d, "%s")", $data, time(), $expire, $headers);
if (!db_affected_rows()) {
db_query("INSERT INTO {cache} (cid, data, created, expire, headers) VALUES ("%s", %b, %d, %d, "%s") FOR UPDATE", $cid, $data, time(), $expire, $headers);
}
}
I am only checking now if these (for want of a better word) fixes work on a restricted environment.
Before anyone asks why don't I change provider - I like the one I have already - the service is great - I don't want to change for a simple 'LOCK TABLES' issue.
Paddy.







Post new comment