}
/**
- * Override database's default connection timeout. May be useful for very
- * long batch queries such as full-wiki dumps, where a single query reads
- * out over hours or days. May or may not be necessary for non-MySQL
- * databases. For most purposes, leaving it as a no-op should be fine.
+ * Override database's default connection timeout
*
* @param $timeout Integer in seconds
+ * @return void
+ * @deprecated since 1.19; use setSessionOptions()
*/
- public function setTimeout( $timeout ) {}
+ public function setTimeout( $timeout ) {
+ $this->setSessionOptions( array( 'connTimeout' => $timeout ) );
+ }
+
+ /**
+ * Override database's default behavior. $options include:
+ * 'connTimeout' : Set the connection timeout value in seconds.
+ * May be useful for very long batch queries such as
+ * full-wiki dumps, where a single query reads out over
+ * hours or days.
+ * 'lockTimeout' : Set the lock wait timeout value in seconds.
+ *
+ * @param $options Array
+ * @return void
+ */
+ public function setSessionOptions( array $options ) {}
/**
* Read and execute SQL commands from a file.
return false;
}
- public function setTimeout( $timeout ) {
- $this->query( "SET net_read_timeout=$timeout" );
- $this->query( "SET net_write_timeout=$timeout" );
+ public function setSessionOptions( array $options ) {
+ if ( isset( $options['connTimeout'] ) ) {
+ $timeout = (int)$options['connTimeout'];
+ $this->query( "SET net_read_timeout=$timeout" );
+ $this->query( "SET net_write_timeout=$timeout" );
+ }
+ if ( isset( $options['lockTimeout'] ) ) {
+ $timeout = (int)$options['lockTimeout'];
+ $this->query( "SET table_lock_wait_timeout=$timeout" ); // table level
+ $this->query( "SET innodb_lock_wait_timeout=$timeout" ); // row level
+ }
}
public function lock( $lockName, $method, $timeout = 5 ) {