Index: trunk/phase3/includes/db/DatabaseOracle.php |
— | — | @@ -721,4 +721,7 @@ |
722 | 722 | return "SearchOracle"; |
723 | 723 | } |
724 | 724 | |
| 725 | + /** No-op */ |
| 726 | + public function setBigSelects( $value = true ) {} |
| 727 | + |
725 | 728 | } // end DatabaseOracle class |
Index: trunk/phase3/includes/db/DatabasePostgres.php |
— | — | @@ -1438,4 +1438,7 @@ |
1439 | 1439 | return "SearchPostgres"; |
1440 | 1440 | } |
1441 | 1441 | |
| 1442 | + /** No-op */ |
| 1443 | + public function setBigSelects( $value = true ) {} |
| 1444 | + |
1442 | 1445 | } // end DatabasePostgres class |
Index: trunk/phase3/includes/db/DatabaseIbm_db2.php |
— | — | @@ -1792,5 +1792,8 @@ |
1793 | 1793 | // TODO |
1794 | 1794 | // see SpecialAncientpages |
1795 | 1795 | } |
| 1796 | + |
| 1797 | + /** No-op */ |
| 1798 | + public function setBigSelects( $value = true ) {} |
1796 | 1799 | } |
1797 | | -?> |
\ No newline at end of file |
| 1800 | +?> |
Index: trunk/phase3/includes/db/Database.php |
— | — | @@ -39,6 +39,7 @@ |
40 | 40 | protected $mErrorCount = 0; |
41 | 41 | protected $mLBInfo = array(); |
42 | 42 | protected $mFakeSlaveLag = null, $mFakeMaster = false; |
| 43 | + protected $mDefaultBigSelects = null; |
43 | 44 | |
44 | 45 | #------------------------------------------------------------------------------ |
45 | 46 | # Accessors |
— | — | @@ -2393,6 +2394,29 @@ |
2394 | 2395 | public function getSearchEngine() { |
2395 | 2396 | return "SearchMySQL"; |
2396 | 2397 | } |
| 2398 | + |
| 2399 | + /** |
| 2400 | + * Allow or deny "big selects" for this session only. This is done by setting |
| 2401 | + * the sql_big_selects session variable. |
| 2402 | + * |
| 2403 | + * This is a MySQL-specific feature. |
| 2404 | + * |
| 2405 | + * @param mixed $value true for allow, false for deny, or "default" to restore the initial value |
| 2406 | + */ |
| 2407 | + public function setBigSelects( $value = true ) { |
| 2408 | + if ( $value === 'default' ) { |
| 2409 | + if ( $this->mDefaultBigSelects === null ) { |
| 2410 | + # Function hasn't been called before so it must already be set to the default |
| 2411 | + return; |
| 2412 | + } else { |
| 2413 | + $value = $this->mDefaultBigSelects; |
| 2414 | + } |
| 2415 | + } elseif ( $this->mDefaultBigSelects === null ) { |
| 2416 | + $this->mDefaultBigSelects = (bool)$this->selectField( false, '@@sql_big_selects' ); |
| 2417 | + } |
| 2418 | + $encValue = $value ? '1' : '0'; |
| 2419 | + $this->query( "SET sql_big_selects=$encValue", __METHOD__ ); |
| 2420 | + } |
2397 | 2421 | } |
2398 | 2422 | |
2399 | 2423 | /** |
Index: trunk/phase3/includes/db/DatabaseMssql.php |
— | — | @@ -1015,6 +1015,8 @@ |
1016 | 1016 | return "SearchEngineDummy"; |
1017 | 1017 | } |
1018 | 1018 | |
| 1019 | + /** No-op */ |
| 1020 | + public function setBigSelects( $value = true ) {} |
1019 | 1021 | } |
1020 | 1022 | |
1021 | 1023 | /** |
Index: trunk/phase3/includes/db/DatabaseSqlite.php |
— | — | @@ -497,6 +497,9 @@ |
498 | 498 | return $s; |
499 | 499 | } |
500 | 500 | |
| 501 | + /** No-op */ |
| 502 | + public function setBigSelects( $value = true ) {} |
| 503 | + |
501 | 504 | } // end DatabaseSqlite class |
502 | 505 | |
503 | 506 | /** |
Index: trunk/phase3/includes/LogEventsList.php |
— | — | @@ -745,14 +745,10 @@ |
746 | 746 | } |
747 | 747 | |
748 | 748 | public function doQuery() { |
749 | | - // Work around MySQL optimizer bug |
750 | | - if ( in_array( get_class( $this->mDb ), array( 'Database', 'DatabaseMysql' ) ) ) { |
751 | | - $this->mDb->query( 'SET SQL_BIG_SELECTS=1' ); |
752 | | - parent::doQuery(); |
753 | | - $this->mDb->query( 'SET SQL_BIG_SELECTS=0' ); |
754 | | - } else { |
755 | | - parent::doQuery(); |
756 | | - } |
| 749 | + // Workaround MySQL optimizer bug |
| 750 | + $this->mDb->setBigSelects(); |
| 751 | + parent::doQuery(); |
| 752 | + $this->mDb->setBigSelects( 'default' ); |
757 | 753 | } |
758 | 754 | } |
759 | 755 | |