2022-07-28 16:55:21 +02:00
|
|
|
--liquibase formatted sql
|
|
|
|
|
|
|
|
--changeset random-in-range:1 endDelimiter:--//
|
|
|
|
|
|
|
|
/*
|
|
|
|
Returns a random integer in the given range (both included),
|
|
|
|
to be used for test data generation.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
randomInRange(0, 4) might return any of 0, 1, 2, 3, 4
|
|
|
|
*/
|
|
|
|
create or replace function randomInRange(min integer, max integer)
|
|
|
|
returns integer
|
|
|
|
returns null on null input
|
2022-07-29 08:46:04 +02:00
|
|
|
language 'plpgsql' as $$
|
2022-07-28 16:55:21 +02:00
|
|
|
begin
|
2022-07-29 08:46:04 +02:00
|
|
|
return floor(random() * (max - min + 1) + min);
|
2022-07-28 16:55:21 +02:00
|
|
|
end; $$;
|
|
|
|
--//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|