pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add date and timestamp variants of random(min, max).
Date: Tue, 09 Sep 2025 09:48:46 +0000
Message-ID: <E1uvuxy-001Fry-2G@gemulon.postgresql.org> (raw)

Add date and timestamp variants of random(min, max).

This adds 3 new variants of the random() function:

    random(min date, max date) returns date
    random(min timestamp, max timestamp) returns timestamp
    random(min timestamptz, max timestamptz) returns timestamptz

Each returns a random value x in the range min <= x <= max.

Author: Damien Clochard <damien@dalibo.info>
Reviewed-by: Greg Sabino Mullane <htamfids@gmail.com>
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Reviewed-by: Vik Fearing <vik@postgresfriends.org>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/f524d8cab5914613d9e624d9ce177d3d@dalibo.info

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/faf071b553830d39fc583beabcaf56ed65259acc

Modified Files
--------------
doc/src/sgml/func/func-datetime.sgml      |  30 +++++++++
doc/src/sgml/func/func-math.sgml          |   3 +-
src/backend/utils/adt/pseudorandomfuncs.c | 104 +++++++++++++++++++++++++++---
src/include/catalog/catversion.h          |   2 +-
src/include/catalog/pg_proc.dat           |  12 ++++
src/test/regress/expected/random.out      |  87 +++++++++++++++++++++++++
src/test/regress/sql/random.sql           |  26 ++++++++
7 files changed, 254 insertions(+), 10 deletions(-)



Message-ID: <E1uvuxy-001Fry-2G@gemulon.postgresql.org>
Permalink:  ../E1uvuxy-001Fry-2G@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1uvuxy-001Fry-2G@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: dean.a.rasheed@gmail.com, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Add date and timestamp variants of random(min, max).
  In-Reply-To: <E1uvuxy-001Fry-2G@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox