[DBCleaner] Arithmetic overflow in PruneOldESpaces.Preparation.GetESpaceInfo

[DBCleaner] Arithmetic overflow in PruneOldESpaces.Preparation.GetESpaceInfo

  
Forge Component
(25)
Published on 6 Apr by Acácio Porta Nova
25 votes
Published on 6 Apr by Acácio Porta Nova
Had to change the PruneOldESpaces.Preparation.GetESpaceInfo query to prevent an arithmetic overflow error calculating the total. Changed query below.

SELECT {Espace}.[Id], {Espace}.[Name], {Espace}.[Is_Active], Count({Espace_Version}.[Id]), sum( @Datalength({Espace_Version}.[OML_File]) / 1024 ) as total
FROM {Espace}
INNER JOIN {Espace_Version} ON ({Espace}.[Id] = {Espace_Version}.[eSpace_Id] and {Espace}.[Version_Id] <> {Espace_Version}.[Id]) 
LEFT JOIN {Solution_Version_Reference} ON ({Solution_Version_Reference}.[Espace_Version_Id] = {Espace_Version}.[Id])
WHERE {Solution_Version_Reference}.[Id] IS NULL
AND {Espace_Version}.[Uploaded_Date] < @OlderThan
GROUP BY {Espace}.[Id], {Espace}.[Name], {Espace}.[Is_Active]
ORDER BY total DESC

Regards,

Tiago.
Hello Tiago,

Version 1.3 contains this fix. Thank you very much for the feedback.

Should now be possible to have an eSpace have 2 TiB of deletable versions without overflowing any puny 32 bit integer.