| From: | Thomas Kellerer <shammat(at)gmx(dot)net> | 
|---|---|
| To: | Postgres General <pgsql-general(at)postgresql(dot)org> | 
| Subject: | PG 14 - can't upgrade from a database using an aggregate with anyelement and anyarray | 
| Date: | 2021-05-22 12:32:57 | 
| Message-ID: | 5c4ad9d6-e73a-a59c-6393-571fc69857e5@gmx.net | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
Hello,
this aggregate can be created without problems on PG 13 and before:
   CREATE AGGREGATE array_accum(anyelement) (
       SFUNC = array_append,
       STYPE = anyarray,
       INITCOND = '{}'
   );
However, that fails with PG 14beta1 because array_append's parameter are now (anycompatiblearray, anycompatible) while it used to be (anyarray, anyelement).
I guess this is a side-effect of:
> Allow some array functions to operate on a mix of compatible data
> types (Tom Lane)
>
> The functions are array_append() array_prepend(), array_cat(),
> array_position(), array_positions(), array_remove(), array_replace(),
> and width_bucket(). Previously only identical data types could be
> used.
On a database with the above aggregate, pg_upgrade fails with the following error:
     pg_restore: creating AGGREGATE "public.array_accum("anyelement")"
     pg_restore: while PROCESSING TOC:
     pg_restore: from TOC entry 2646; 1255 16552 AGGREGATE array_accum("anyelement") thomas
     pg_restore: error: could not execute query: ERROR:  function array_append(anyarray, anyelement) does not exist
     Command was: CREATE AGGREGATE "public"."array_accum"("anyelement") (
         SFUNC = "array_append",
         STYPE = "anyarray",
         INITCOND = '{}'
     );
The problem is, that the version that works in PG 14:
   CREATE AGGREGATE array_accum(anycompatible) (
       SFUNC = array_append,
       STYPE = anycompatiblearray,
       INITCOND = '{}'
   );
can't be created in PG 13 in preparation of the upgrade.
So the database can't be upgraded using pg_upgrade.
I am using PG14beta1 on Windows 10
Any ideas?
Thomas
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2021-05-22 13:25:02 | Re: PG 14 - can't upgrade from a database using an aggregate with anyelement and anyarray | 
| Previous Message | Nikolay Samokhvalov | 2021-05-22 12:31:30 | Re: Framework for 0 downtime deploys |