mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[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
This commit is contained in:
parent
2f57bfb6f2
commit
91b3195255
3 changed files with 35 additions and 3 deletions
|
@ -392,7 +392,18 @@ class acp_search
|
||||||
AND post_id <= ' . (int) ($post_counter + $this->batch_size);
|
AND post_id <= ' . (int) ($post_counter + $this->batch_size);
|
||||||
$result = $db->sql_query($sql);
|
$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?
|
// Indexing enabled for this forum or global announcement?
|
||||||
// Global announcements get indexed by default.
|
// Global announcements get indexed by default.
|
||||||
|
@ -402,7 +413,10 @@ class acp_search
|
||||||
}
|
}
|
||||||
$row_count++;
|
$row_count++;
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
if (!$buffer)
|
||||||
|
{
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
}
|
||||||
|
|
||||||
$post_counter += $this->batch_size;
|
$post_counter += $this->batch_size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,6 +241,16 @@ class dbal
|
||||||
return $this->_sql_like_expression('LIKE \'' . $this->sql_escape($expression) . '\'');
|
return $this->_sql_like_expression('LIKE \'' . $this->sql_escape($expression) . '\'');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* SQL Transaction
|
||||||
* @access private
|
* @access private
|
||||||
|
|
|
@ -258,6 +258,14 @@ class dbal_mssqlnative extends dbal
|
||||||
return ($this->sql_server_version) ? 'MSSQL<br />' . $this->sql_server_version : 'MSSQL';
|
return ($this->sql_server_version) ? 'MSSQL<br />' . $this->sql_server_version : 'MSSQL';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
function sql_buffer_nested_transaction()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SQL Transaction
|
* SQL Transaction
|
||||||
* @access private
|
* @access private
|
||||||
|
|
Loading…
Add table
Reference in a new issue