pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: tablefunc: Reject negative number of tuples passed to normal_ran
Date: Wed, 25 Nov 2020 14:31:03 +0000
Message-ID: <E1khvp1-0002nB-An@gemulon.postgresql.org> (raw)

tablefunc: Reject negative number of tuples passed to normal_rand()

The function converted the first argument i.e. the number of tuples to
return into an unsigned integer which turns out to be huge number when
a negative value is passed.  This causes the function to take much
longer time to execute.  Instead, reject a negative value.

(If someone really wants to generate many more result rows, they
should consider adding a bigint or numeric variant.)

While at it, improve SQL test to test the number of tuples returned by
this function.

Author: Ashutosh Bapat <ashutosh.bapat@2ndquadrant.com>
Discussion: https://www.postgresql.org/message-id/CAG-ACPW3PUUmSnM6cLa9Rw4BEC5cEMKjX8Gogc8gvQcT3cYA1A@mail.gmail...

Branch
------
master

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

Modified Files
--------------
contrib/tablefunc/expected/tablefunc.out | 11 +++++++----
contrib/tablefunc/sql/tablefunc.sql      |  4 +++-
contrib/tablefunc/tablefunc.c            |  9 ++++++++-
3 files changed, 18 insertions(+), 6 deletions(-)



Message-ID: <E1khvp1-0002nB-An@gemulon.postgresql.org>
Permalink:  ../E1khvp1-0002nB-An@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1khvp1-0002nB-An@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: peter@eisentraut.org
  Subject: Re: pgsql: tablefunc: Reject negative number of tuples passed to normal_ran
  In-Reply-To: <E1khvp1-0002nB-An@gemulon.postgresql.org>
  References: <E1khvp1-0002nB-An@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