diff options
author | Nils Adermann <naderman@naderman.de> | 2011-03-12 16:49:25 +0100 |
---|---|---|
committer | Nils Adermann <naderman@naderman.de> | 2011-03-15 01:41:16 +0100 |
commit | 91b319525546ea696653dbb7f2c494058a85b00b (patch) | |
tree | 04b83465e10dffab2a397ecc86dd11e384e5ea7f | |
parent | 2f57bfb6f297e9711bacb607faf6e33ab516db33 (diff) | |
download | forums-91b319525546ea696653dbb7f2c494058a85b00b.tar forums-91b319525546ea696653dbb7f2c494058a85b00b.tar.gz forums-91b319525546ea696653dbb7f2c494058a85b00b.tar.bz2 forums-91b319525546ea696653dbb7f2c494058a85b00b.tar.xz forums-91b319525546ea696653dbb7f2c494058a85b00b.zip |
[ticket/9685] Buffer posts for search indexing when using mssqlnative.
To have a generic solution there is now a sql_buffer_nested_transaction()
which indicates that the given SQL driver requires buffering to run a
transaction while iterating over another result set.
PHPBB3-9685
-rw-r--r-- | phpBB/includes/acp/acp_search.php | 18 | ||||
-rw-r--r-- | phpBB/includes/db/dbal.php | 10 | ||||
-rw-r--r-- | phpBB/includes/db/mssqlnative.php | 10 |
3 files changed, 35 insertions, 3 deletions
diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php index 930c8d2a26..0cd67b1c34 100644 --- a/phpBB/includes/acp/acp_search.php +++ b/phpBB/includes/acp/acp_search.php @@ -392,7 +392,18 @@ class acp_search AND post_id <= ' . (int) ($post_counter + $this->batch_size); $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + $buffer = $db->sql_buffer_nested_transactions(); + + if ($buffer) + { + $rows = $db->sql_fetchrowset($result); + $rows[] = false; // indicate end of array for while loop below + + $db->sql_freeresult($result); + } + + $i = 0; + while ($row = ($buffer ? $rows[$i++] : $db->sql_fetchrow($result))) { // Indexing enabled for this forum or global announcement? // Global announcements get indexed by default. @@ -402,7 +413,10 @@ class acp_search } $row_count++; } - $db->sql_freeresult($result); + if (!$buffer) + { + $db->sql_freeresult($result); + } $post_counter += $this->batch_size; } diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index 5d8d5fbd47..d7860fc8bc 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -242,6 +242,16 @@ class dbal } /** + * Returns whether results of a query need to be buffered to run a transaction while iterating over them. + * + * @return bool Whether buffering is required. + */ + function sql_buffer_nested_transaction() + { + return false; + } + + /** * SQL Transaction * @access private */ diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/mssqlnative.php index 7ed4146f27..8912cda178 100644 --- a/phpBB/includes/db/mssqlnative.php +++ b/phpBB/includes/db/mssqlnative.php @@ -259,6 +259,14 @@ class dbal_mssqlnative extends dbal } /** + * {@inheritDoc} + */ + function sql_buffer_nested_transaction() + { + return true; + } + + /** * SQL Transaction * @access private */ @@ -628,7 +636,7 @@ class dbal_mssqlnative extends dbal return false; } } - + /** * Allows setting mssqlnative specific query options passed to sqlsrv_query as 4th parameter. */ |