Index: openacs-4/packages/acs-tcl/tcl/security-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/security-procs-postgresql.xql,v diff -u -N -r1.14.2.1 -r1.14.2.2 --- openacs-4/packages/acs-tcl/tcl/security-procs-postgresql.xql 16 Nov 2019 15:45:55 -0000 1.14.2.1 +++ openacs-4/packages/acs-tcl/tcl/security-procs-postgresql.xql 8 Jan 2020 11:28:30 -0000 1.14.2.2 @@ -36,8 +36,9 @@ select token_id, token from secret_tokens, - (select trunc(random()*(select count(*)-15 from secret_tokens))::integer as first) r - where token_id >= r.first and r.first+15 > token_id; + (select cast(random() * count(*) - :num_tokens as integer) as first + from secret_tokens) r + where token_id >= r.first and r.first + :num_tokens > token_id