Abstrct/Schemaverse

Serious bug in upgrade()

Closed this issue · 2 comments

function upgrade() declares ship_value as smallint, which indicates a signed 2 byte integer.

Thus, the maximum value of ship_value is 32767.

Unfortunately, the value of SHIP_MAX_SPEED is 50000, which is larger than that.

if you try to upgrade a ship's speed to beyond ~32768, you get an error:

schemaverse@db.schemaverse.com-> select upgrade(34131, 'MAX_SPEED', 5000); ERROR: value "41795" is out of range for type smallint CONTEXT: PL/pgSQL function "upgrade" line 53 at SQL statement

Note that 41795 was the previous value of the maximum speed for that ship; that's a failure of
SELECT max_speed INTO ship_value FROM ship WHERE id=reference_id;

The fix should be to change the type of ship_value to integer.

ship_value has been changed to integer in the UPGRADE function.

d187bf1

Thanks for the bug report!
-Abstrct

Excellent, thanks!