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 1kcaIx-0002bT-O0 for pgsql-committers@arkaria.postgresql.org; Tue, 10 Nov 2020 20:31:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kcaIv-0001YP-V5 for pgsql-committers@arkaria.postgresql.org; Tue, 10 Nov 2020 20:31:49 +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 1kcaIv-0001YI-Pd for pgsql-committers@lists.postgresql.org; Tue, 10 Nov 2020 20:31:49 +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 1kcaIs-0001Ov-TM for pgsql-committers@lists.postgresql.org; Tue, 10 Nov 2020 20:31:49 +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 0AAKVhsM2255608; Tue, 10 Nov 2020 15:31:43 -0500 From: Tom Lane To: Andrew Dunstan cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Declare assorted array functions using anycompatible not anyelem In-reply-to: References: <1999748.1604957386@sss.pgh.pa.us> <2001798.1604960149@sss.pgh.pa.us> <52030649-c25c-c4e6-8316-2fd4f9a24f8b@dunslane.net> <2008195.1604961694@sss.pgh.pa.us> Comments: In-reply-to Andrew Dunstan message dated "Tue, 10 Nov 2020 08:45:06 -0500" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <2255550.1605040231.0@sss.pgh.pa.us> Date: Tue, 10 Nov 2020 15:31:43 -0500 Message-ID: <2255607.1605040303@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2255550.1605040231.1@sss.pgh.pa.us> Andrew Dunstan writes: > On 11/9/20 5:41 PM, Tom Lane wrote: >> What I have in mind to apply to 9.5 through 13 is per attached. > You also need to modify first_el_agg_any. ... doh. That one is a little messier because there's no equally useful substitute function. What I'm inclined to do for that is to add a SQL-language wrapper to reproduce the old signature for array_append. As attached. (I'm keeping this separate from the other patch, since this doesn't go back as far.) > Here's what I have working on crake:: OK. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="xversion-fix-2-head.patch"; charset="us-ascii" Content-ID: <2255550.1605040231.2@sss.pgh.pa.us> Content-Description: xversion-fix-2-head.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/test/regress/expected/polymorphism.out b/src/test/regress= /expected/polymorphism.out index 2c3bb0a60b..628a39612a 100644 --- a/src/test/regress/expected/polymorphism.out +++ b/src/test/regress/expected/polymorphism.out @@ -786,16 +786,18 @@ create aggregate build_group(int8, integer) ( STYPE =3D int8[] ); -- check proper resolution of data types for polymorphic transfn/finalfn -create function first_el(anycompatiblearray) returns anycompatible as +create function first_el_transfn(anyarray, anyelement) returns anyarray a= s +'select $1 || $2' language sql immutable; +create function first_el(anyarray) returns anyelement as 'select $1[1]' language sql strict immutable; create aggregate first_el_agg_f8(float8) ( SFUNC =3D array_append, STYPE =3D float8[], FINALFUNC =3D first_el ); -create aggregate first_el_agg_any(anycompatible) ( - SFUNC =3D array_append, - STYPE =3D anycompatiblearray, +create aggregate first_el_agg_any(anyelement) ( + SFUNC =3D first_el_transfn, + STYPE =3D anyarray, FINALFUNC =3D first_el ); select first_el_agg_f8(x::float8) from generate_series(1,10) x; diff --git a/src/test/regress/sql/polymorphism.sql b/src/test/regress/sql/= polymorphism.sql index 70a21c8978..d98a74c3f6 100644 --- a/src/test/regress/sql/polymorphism.sql +++ b/src/test/regress/sql/polymorphism.sql @@ -549,7 +549,10 @@ create aggregate build_group(int8, integer) ( = -- check proper resolution of data types for polymorphic transfn/finalfn = -create function first_el(anycompatiblearray) returns anycompatible as +create function first_el_transfn(anyarray, anyelement) returns anyarray a= s +'select $1 || $2' language sql immutable; + +create function first_el(anyarray) returns anyelement as 'select $1[1]' language sql strict immutable; = create aggregate first_el_agg_f8(float8) ( @@ -558,9 +561,9 @@ create aggregate first_el_agg_f8(float8) ( FINALFUNC =3D first_el ); = -create aggregate first_el_agg_any(anycompatible) ( - SFUNC =3D array_append, - STYPE =3D anycompatiblearray, +create aggregate first_el_agg_any(anyelement) ( + SFUNC =3D first_el_transfn, + STYPE =3D anyarray, FINALFUNC =3D first_el ); = ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="xversion-fix-2-13.patch"; charset="us-ascii" Content-ID: <2255550.1605040231.3@sss.pgh.pa.us> Content-Description: xversion-fix-2-13.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/test/regress/expected/polymorphism.out b/src/test/regress= /expected/polymorphism.out index 1ff40764d9..236b2532b3 100644 --- a/src/test/regress/expected/polymorphism.out +++ b/src/test/regress/expected/polymorphism.out @@ -786,6 +786,8 @@ create aggregate build_group(int8, integer) ( STYPE =3D int8[] ); -- check proper resolution of data types for polymorphic transfn/finalfn +create function first_el_transfn(anyarray, anyelement) returns anyarray a= s +'select $1 || $2' language sql immutable; create function first_el(anyarray) returns anyelement as 'select $1[1]' language sql strict immutable; create aggregate first_el_agg_f8(float8) ( @@ -794,7 +796,7 @@ create aggregate first_el_agg_f8(float8) ( FINALFUNC =3D first_el ); create aggregate first_el_agg_any(anyelement) ( - SFUNC =3D array_append, + SFUNC =3D first_el_transfn, STYPE =3D anyarray, FINALFUNC =3D first_el ); diff --git a/src/test/regress/sql/polymorphism.sql b/src/test/regress/sql/= polymorphism.sql index e5222f1f81..d2e302c330 100644 --- a/src/test/regress/sql/polymorphism.sql +++ b/src/test/regress/sql/polymorphism.sql @@ -549,6 +549,9 @@ create aggregate build_group(int8, integer) ( = -- check proper resolution of data types for polymorphic transfn/finalfn = +create function first_el_transfn(anyarray, anyelement) returns anyarray a= s +'select $1 || $2' language sql immutable; + create function first_el(anyarray) returns anyelement as 'select $1[1]' language sql strict immutable; = @@ -559,7 +562,7 @@ create aggregate first_el_agg_f8(float8) ( ); = create aggregate first_el_agg_any(anyelement) ( - SFUNC =3D array_append, + SFUNC =3D first_el_transfn, STYPE =3D anyarray, FINALFUNC =3D first_el ); ------- =_aaaaaaaaaa0--