Index: trunk/phase3/includes/db/DatabaseMysql.php |
— | — | @@ -602,9 +602,17 @@ |
603 | 603 | return false; |
604 | 604 | } |
605 | 605 | |
606 | | - public function setTimeout( $timeout ) { |
607 | | - $this->query( "SET net_read_timeout=$timeout" ); |
608 | | - $this->query( "SET net_write_timeout=$timeout" ); |
| 606 | + public function setSessionOptions( array $options ) { |
| 607 | + if ( isset( $options['connTimeout'] ) ) { |
| 608 | + $timeout = (int)$options['connTimeout']; |
| 609 | + $this->query( "SET net_read_timeout=$timeout" ); |
| 610 | + $this->query( "SET net_write_timeout=$timeout" ); |
| 611 | + } |
| 612 | + if ( isset( $options['lockTimeout'] ) ) { |
| 613 | + $timeout = (int)$options['lockTimeout']; |
| 614 | + $this->query( "SET table_lock_wait_timeout=$timeout" ); // table level |
| 615 | + $this->query( "SET innodb_lock_wait_timeout=$timeout" ); // row level |
| 616 | + } |
609 | 617 | } |
610 | 618 | |
611 | 619 | public function lock( $lockName, $method, $timeout = 5 ) { |
Index: trunk/phase3/includes/db/Database.php |
— | — | @@ -2994,16 +2994,30 @@ |
2995 | 2995 | } |
2996 | 2996 | |
2997 | 2997 | /** |
2998 | | - * Override database's default connection timeout. May be useful for very |
2999 | | - * long batch queries such as full-wiki dumps, where a single query reads |
3000 | | - * out over hours or days. May or may not be necessary for non-MySQL |
3001 | | - * databases. For most purposes, leaving it as a no-op should be fine. |
| 2998 | + * Override database's default connection timeout |
3002 | 2999 | * |
3003 | 3000 | * @param $timeout Integer in seconds |
| 3001 | + * @return void |
| 3002 | + * @deprecated since 1.19; use setSessionOptions() |
3004 | 3003 | */ |
3005 | | - public function setTimeout( $timeout ) {} |
| 3004 | + public function setTimeout( $timeout ) { |
| 3005 | + $this->setSessionOptions( array( 'connTimeout' => $timeout ) ); |
| 3006 | + } |
3006 | 3007 | |
3007 | 3008 | /** |
| 3009 | + * Override database's default behavior. $options include: |
| 3010 | + * 'connTimeout' : Set the connection timeout value in seconds. |
| 3011 | + * May be useful for very long batch queries such as |
| 3012 | + * full-wiki dumps, where a single query reads out over |
| 3013 | + * hours or days. |
| 3014 | + * 'lockTimeout' : Set the lock wait timeout value in seconds. |
| 3015 | + * |
| 3016 | + * @param $options Array |
| 3017 | + * @return void |
| 3018 | + */ |
| 3019 | + public function setSessionOptions( array $options ) {} |
| 3020 | + |
| 3021 | + /** |
3008 | 3022 | * Read and execute SQL commands from a file. |
3009 | 3023 | * |
3010 | 3024 | * Returns true on success, error string or exception on failure (depending |