Db0058: Bugfix for other half of 0056

This commit is contained in:
Rick Falkvinge
2017-11-21 08:31:02 +01:00
parent 7282a2a679
commit 920560d1f3
3 changed files with 49 additions and 1 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ namespace Swarmops.Database
/// </summary>
public static int DbVersionExpected
{
get { return 57; }
get { return 58; }
}
+1
View File
@@ -55,3 +55,4 @@
0055 - Fix for bug introduced with 0054, hash collisions in index [RF]
0056 - Splitting a storedproc into two; debugging a weird multi-row select return [RF]
0057 - Bugfix for 0056: case insensitivity caused always-true comparison w/o qualifier [RF]
0058 - Fixing the other half of 0056
+47
View File
@@ -0,0 +1,47 @@
DROP PROCEDURE IF EXISTS `UpdateHotBitcoinAddressUnspentTotals`
#
DROP PROCEDURE IF EXISTS `UpdateHotBitcoinAddressUnspentTotal`
#
CREATE PROCEDURE `UpdateHotBitcoinAddressUnspentTotal` (
IN hotBitcoinAddressId INTEGER
)
BEGIN
UPDATE HotBitcoinAddresses
INNER JOIN
(
SELECT HotBitcoinAddressId, SUM(AmountSatoshis) AS UnspentAmountSum
FROM HotBitcoinAddressUnspents
GROUP BY HotBitcoinAddressId
) innerSelection ON HotBitcoinAddresses.HotBitcoinAddressId = innerSelection.HotBitcoinAddressId
SET HotBitcoinAddresses.BalanceSatoshis = innerSelection.UnspentAmountSum
WHERE HotBitcoinAddresses.HotBitcoinAddressId=hotBitcoinAddressId;
END
#
CREATE PROCEDURE `UpdateHotBitcoinAddressUnspentTotals` ()
BEGIN
UPDATE HotBitcoinAddresses
INNER JOIN
(
SELECT HotBitcoinAddressId, SUM(AmountSatoshis) AS UnspentAmountSum
FROM HotBitcoinAddressUnspents
GROUP BY HotBitcoinAddressId
) innerSelection ON HotBitcoinAddresses.HotBitcoinAddressId = innerSelection.HotBitcoinAddressId
SET HotBitcoinAddresses.BalanceSatoshis = innerSelection.UnspentAmountSum;
END