pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Dunstan <andrew@dunslane.net>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Declare assorted array functions using anycompatible not anyelem
Date: Tue, 10 Nov 2020 15:31:43 -0500
Message-ID: <2255607.1605040303@sss.pgh.pa.us> (raw)
In-Reply-To: <dc77bfb2-3b98-c3e5-a825-6c087d51f51c@dunslane.net>
References: <E1kaQ2c-0005lx-Eg@gemulon.postgresql.org>
	<fff35eb5-765c-3e60-3a2a-45ba5f88777d@dunslane.net>
	<1999748.1604957386@sss.pgh.pa.us>
	<b300679b-6410-9124-271c-73893a2c3a1f@dunslane.net>
	<2001798.1604960149@sss.pgh.pa.us>
	<52030649-c25c-c4e6-8316-2fd4f9a24f8b@dunslane.net>
	<2008195.1604961694@sss.pgh.pa.us>
	<dc77bfb2-3b98-c3e5-a825-6c087d51f51c@dunslane.net>

Andrew Dunstan <andrew@dunslane.net> 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

Attachments: download all (2 files, .tar.gz)

xversion-fix-2-head.patch (text/x-diff, 2.1K) download 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 = 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 as +'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 = array_append, STYPE = float8[], FINALFUNC = first_el ); -create aggregate first_el_agg_any(anycompatible) ( - SFUNC = array_append, - STYPE = anycompatiblearray, +create aggregate first_el_agg_any(anyelement) ( + SFUNC = first_el_transfn, + STYPE = anyarray, FINALFUNC = 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 as +'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 = first_el ); -create aggregate first_el_agg_any(anycompatible) ( - SFUNC = array_append, - STYPE = anycompatiblearray, +create aggregate first_el_agg_any(anyelement) ( + SFUNC = first_el_transfn, + STYPE = anyarray, FINALFUNC = first_el ); =
xversion-fix-2-13.patch (text/x-diff, 1.7K) download 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 = int8[] ); -- check proper resolution of data types for polymorphic transfn/finalfn +create function first_el_transfn(anyarray, anyelement) returns anyarray as +'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 = first_el ); create aggregate first_el_agg_any(anyelement) ( - SFUNC = array_append, + SFUNC = first_el_transfn, STYPE = anyarray, FINALFUNC = 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 as +'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 = array_append, + SFUNC = first_el_transfn, STYPE = anyarray, FINALFUNC = first_el );

view thread (10+ messages)  latest in thread

Message-ID: <2255607.1605040303@sss.pgh.pa.us>
Permalink:  ../2255607.1605040303@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2255607.1605040303@sss.pgh.pa.us

 ·  · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andrew@dunslane.net, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Declare assorted array functions using anycompatible not anyelem
  In-Reply-To: <2255607.1605040303@sss.pgh.pa.us>

* 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