- Patch #22911 by Cvgbe: fixed table locking in PostgreSQL. You'll have to
use db_lock_table() and db_unlock_tables() for your code to be compatible.4.7.x
parent
8ae8865abc
commit
75fad91cf5
|
@ -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".
|
||||
*/
|
||||
|
|
|
@ -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".
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue