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 1oDXtb-0006Sp-1Z for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Jul 2022 21:03:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oDXtZ-0003AK-5r for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Jul 2022 21:03:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oDXtY-0003AB-Sz for pgsql-hackers@lists.postgresql.org; Mon, 18 Jul 2022 21:03:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oDXtW-0003uM-OY for pgsql-hackers@lists.postgresql.org; Mon, 18 Jul 2022 21:03:11 +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 26IL31l7817329; Mon, 18 Jul 2022 17:03:01 -0400 From: Tom Lane To: Robert Haas cc: Martin Kalcher , John Naylor , Thomas Munro , PostgreSQL Hackers Subject: Re: [PATCH] Introduce array_shuffle() and array_sample() In-reply-to: <809171.1658176490@sss.pgh.pa.us> References: <9d160a44-7675-51e8-60cf-6d64b76db831@aboutsource.net> <4073858.1658027909@sss.pgh.pa.us> <4077925.1658029046@sss.pgh.pa.us> <5ef15c6f-e108-53af-3d82-587fac394f1a@aboutsource.net> <463181.1658097987@sss.pgh.pa.us> <5b7a1ee9-f942-2502-3a0c-e9fc12511139@aboutsource.net> <469954.1658100033@sss.pgh.pa.us> <687490.1658152096@sss.pgh.pa.us> <1708d95a-629e-5ac5-deab-d20a8d0b2b0e@aboutsource.net> <809171.1658176490@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Mon, 18 Jul 2022 16:34:50 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <817327.1658178181.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 18 Jul 2022 17:03:01 -0400 Message-ID: <817328.1658178181@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > Martin had originally proposed (2), which I rejected on the grounds > that we don't treat multi-dimensional arrays as arrays-of-arrays for > any other purpose. Actually, after poking at it for awhile, that's an overstatement. It's true that the type system doesn't think N-D arrays are arrays-of-arrays, but there are individual functions/operators that do. For instance, @> is in the its-a-flat-list-of-elements camp: regression=3D# select array[[1,2],[3,4]] @> array[1,3]; ?column? = ---------- t (1 row) but || wants to preserve dimensionality: regression=3D# select array[[1,2],[3,4]] || array[1]; ERROR: cannot concatenate incompatible arrays DETAIL: Arrays with differing dimensions are not compatible for concatena= tion. Various other functions dodge the issue by refusing to work on arrays of more than one dimension. There seem to be more functions that think arrays are flat than otherwise, but it's not as black-and-white as I was thinking. regards, tom lane