-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
3.3.14
-
PHP 7.3.33, MSSQL 2012 SP4
Board is running on MSSQL. 350K+ posts, with many attachments. Total size of attachments is approximately 10GB, which exceeds the 2.1B limit for the MSSQL INT data type.
When attempting to do a Resynchronize Statistics, it fails with this error:
SQL ERROR [ mssqlnative ]
|
SQLSTATE: 22003 code: 8115 message: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Arithmetic overflow error converting expression to data type int. [8115]
|
SQL
|
SELECT SUM(filesize) as stat FROM phpbb_attachments WHERE is_orphan = 0
|
BACKTRACE
|
FILE: (not given by php)
|
LINE: (not given by php)
|
CALL: msg_handler()
|
FILE: [ROOT]/phpbb/db/driver/driver.php
|
LINE: 1031
|
CALL: trigger_error()
|
FILE: [ROOT]/phpbb/db/driver/mssqlnative.php
|
LINE: 155
|
CALL: phpbb\db\driver\driver->sql_error()
|
FILE: [ROOT]/phpbb/db/driver/factory.php
|
LINE: 353
|
CALL: phpbb\db\driver\mssqlnative->sql_query()
|
FILE: [ROOT]/includes/acp/acp_main.php
|
LINE: 174
|
CALL: phpbb\db\driver\factory->sql_query()
|
FILE: [ROOT]/includes/functions_module.php
|
LINE: 684
|
CALL: acp_main->main()
|
FILE: [ROOT]/adm/index.php
|
LINE: 81
|
CALL: p_master->load_active()
|
The problem is this line (and ones similar to it):
$sql = 'SELECT SUM(filesize) as stat
|
For this type of situation it needs to be cast to an appropriate datatype before the SUM is performed:
$sql = 'SELECT SUM(CAST(filesize AS BIGINT)) as stat
|
I found references to this in the following files:
/includes/acp/acp_attachments.php (line 1080)
|
/includes/acp/acp_forums.php (line 2074)
|
/includes acp/acp_main.php (line 171)
|
/includes/functions_convert.php (line 2001)
|
|
Manually inserting the CAST into the code in these files solved the issue for me, but doing this would likely break it for others not running on MSSQL.
- is related to
-
PHPBB-16245 Overflow in MSSQL attempting to manage attachments when collection > 2.1 GB
-
- Closed
-