mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-22 19:01:32 +00:00
make random_smallint function work in postgresql 16
This commit is contained in:
parent
fbbf088932
commit
cd1b202612
1 changed files with 4 additions and 2 deletions
|
@ -5,8 +5,10 @@
|
|||
CREATE FUNCTION random_smallint ()
|
||||
RETURNS smallint
|
||||
LANGUAGE sql
|
||||
VOLATILE PARALLEL RESTRICTED RETURN random (
|
||||
-32768, 32767
|
||||
VOLATILE PARALLEL RESTRICTED RETURN
|
||||
-- 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
|
||||
|
|
Loading…
Reference in a new issue