make random_smallint function work in postgresql 16

This commit is contained in:
Dull Bananas 2024-12-19 13:30:05 -07:00
parent fbbf088932
commit cd1b202612

View file

@ -5,8 +5,10 @@
CREATE FUNCTION random_smallint () CREATE FUNCTION random_smallint ()
RETURNS smallint RETURNS smallint
LANGUAGE sql LANGUAGE sql
VOLATILE PARALLEL RESTRICTED RETURN random ( VOLATILE PARALLEL RESTRICTED RETURN
-32768, 32767 -- https://stackoverflow.com/questions/1400505/generate-a-random-number-in-the-range-1-10/1400752#1400752
-- (`+ 1` makes the upper bound inclusive)
trunc ((random() * (32768 + 32767 + 1)) - 32768
); );
ALTER TABLE community ALTER TABLE community