Re: Proposal to introduce a shuffle function to intarray extension

Martin Kalcher <martin.kalcher@aboutsource.net>

From: Martin Kalcher <martin.kalcher@aboutsource.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Thomas Munro <thomas.munro@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2022-07-18T07:12:50Z
Lists: pgsql-hackers, pgsql-general
Am 18.07.22 um 01:20 schrieb Tom Lane:
>> I would expect that shuffle() only shuffles the first dimension and
>> keeps the inner arrays intact.
> 
> This argument is based on a false premise, ie that Postgres thinks
> multidimensional arrays are arrays-of-arrays.  They aren't, and
> we're not going to start making them so by defining shuffle()
> at variance with every other array-manipulating function.  Shuffling
> the individual elements regardless of array shape is the definition
> that's consistent with our existing functionality.

Hey Tom,

thank you for clarification. I did not know that. I will make a patch 
that is using deconstruct_array().

Martin



Commits

  1. Add array_sample() and array_shuffle() functions.

  2. Use a separate random seed for SQL random()/setseed() functions.