:-(( Drupal still requires LOCK TABLE permission

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

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post PHP code. You should include <?php ?> tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is used to make sure you are a human visitor and to prevent spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.
Get Firefox W3C Markup Validation Service W3C CSS Validation Service drupal.org | Community Plumbing Taylor McKnight  -  //gtmcknight Creative Commons License Irish

Syndicate

Syndicate content

Who's online

There are currently 0 users and 4 guests online.

pair Networks