diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 9a05b65c7d804fd6f772f1ba7f51db41ec78395d..f29a9b6be9705b65a2d190dd8a873d2328737321 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -232,10 +232,10 @@ function variable_get($name, $default) {
 function variable_set($name, $value) {
   global $conf;
 
-  db_query('LOCK TABLE {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 TABLE');
+  db_unlock_tables();
 
   cache_clear_all('variables');
 
@@ -321,12 +321,12 @@ function cache_get($key) {
 function cache_set($cid, $data, $expire = CACHE_PERMANENT, $headers = NULL) {
   $data = db_encode_blob($data);
 
-  db_query('LOCK TABLE {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 TABLE');
+  db_unlock_tables();
 }
 
 /**