Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1odXu4-0005fO-Fg for pgsql-hackers@arkaria.postgresql.org; Wed, 28 Sep 2022 14:19:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1odXu2-0007Vt-4T for pgsql-hackers@arkaria.postgresql.org; Wed, 28 Sep 2022 14:19:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1odXu1-0007V6-R4 for pgsql-hackers@lists.postgresql.org; Wed, 28 Sep 2022 14:19:09 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1odXty-0002cO-IA for pgsql-hackers@lists.postgresql.org; Wed, 28 Sep 2022 14:19:09 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 28SEIjvv3943592; Wed, 28 Sep 2022 10:18:45 -0400 From: Tom Lane To: Fabien COELHO cc: Martin Kalcher , Andres Freund , Dean Rasheed , Robert Haas , Andrew Dunstan , John Naylor , Thomas Munro , PostgreSQL Hackers Subject: Re: [PATCH] Introduce array_shuffle() and array_sample() In-reply-to: References: <459f6008-90bc-bc52-6f11-e68570e03ac0@aboutsource.net> <583b6409-df52-86d1-8c0a-ce8e74863ad7@aboutsource.net> <036ba529-1f25-d7b5-c5ad-e6c852d928df@aboutsource.net> <8fabf9e7-3422-58b0-93f6-d0976d4679df@aboutsource.net> <20220922152320.ukx6teo7wa7cuwkv@awork3.anarazel.de> <193caac5-941e-58b8-65e6-351f777ebd25@aboutsource.net> <3502301.1664223385@sss.pgh.pa.us> <9cd0925c-9839-a136-c21d-87de9e8a3aa4@aboutsource.net> Comments: In-reply-to Fabien COELHO message dated "Wed, 28 Sep 2022 15:07:06 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3943590.1664374725.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 28 Sep 2022 10:18:45 -0400 Message-ID: <3943591.1664374725@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Fabien COELHO writes: >> Thanks for your thoughts, Tom. I have a couple of questions. Should we = >> introduce a new seed function for the new PRNG state, used by array_shu= ffle() = >> and array_sample()? What would be a good name? Or should those function= s use = >> pg_global_prng_state? Is it safe to assume, that pg_global_prng_state i= s = >> seeded? > I'd suggest to use the existing global state. The global state should be= = > seeded at the process start, AFAIKR. It is seeded at process start, yes. If you don't feel a need for user control over the sequence used by these functions, then using pg_global_prng_state is fine. (Basically the point to be made here is that we need to keep a tight rein on what can be affected by setseed().) regards, tom lane