diff --git a/includes/database.mysql.inc b/includes/database.mysql.inc
index f13636b90983555945d3476311a70aed6a03c904..2f771d9e689ae2352eb6319ec543eebcf6cef435 100644
--- a/includes/database.mysql.inc
+++ b/includes/database.mysql.inc
@@ -269,6 +269,21 @@ function db_escape_string($text) {
   return addslashes($text);
 }
 
+/**
+ * Lock a table.
+ */
+function db_lock_table($table) {
+  db_query('LOCK TABLES {%s} WRITE', $table);
+}
+
+/**
+ * Unlock all locked tables.
+ */
+function db_unlock_tables() {
+  db_query('UNLOCK TABLES');
+}
+
+
 /**
  * @} End of "ingroup database".
  */
diff --git a/includes/database.pgsql.inc b/includes/database.pgsql.inc
index 12070dd304d6b38f1cfbc46d5412476c60c73e71..33c960a20221651c78b73bec143026c83a1e2a3b 100644
--- a/includes/database.pgsql.inc
+++ b/includes/database.pgsql.inc
@@ -255,6 +255,22 @@ function db_escape_string($text) {
   return pg_escape_string($text);
 }
 
+/**
+ * Lock a table.
+ * This function automatically starts a transaction.
+ */
+function db_lock_table($table) {
+  db_query('BEGIN; LOCK TABLE {%s} IN EXCLUSIVE MODE', $table);
+}
+
+/**
+ * Unlock all locked tables.
+ * This function automatically commits a transation.
+ */
+function db_unlock_tables() {
+  db_query('COMMIT');
+}
+
 /**
  * @} End of "ingroup database".
  */