Re: BUG #18151: pg_upgradecluster fails when column default refers to column

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: "liam(at)morland(dot)ca" <liam(at)morland(dot)ca>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #18151: pg_upgradecluster fails when column default refers to column
Date: 2023-10-09 14:31:32
Message-ID: CAKFQuwa8=RVgMFLVuyC7izD5-OaBMRhN_kjg7+fiD3GY3ivo1A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Sunday, October 8, 2023, PG Bug reporting form <noreply(at)postgresql(dot)org>
wrote:

> The following bug has been logged on the website:
>
> Bug reference: 18151
> Logged by: Liam Morland
> Email address: liam(at)morland(dot)ca
> PostgreSQL version: 15.4
> Operating system: Debian
> Description:
>
> I was trying to upgrade to PG 16:
> pg_upgradecluster 15 main
>
> I got this error:
> pg_restore: error: could not execute query: ERROR: relation "event" does
> not exist
>
> The reason is the the default value for column "event_id" of table "event"
> is "event_id_nextval()". That function is:
> SELECT COALESCE(MAX(event_id) + 1, 1) FROM event;

You are expressly forbidden to have the default value expression of a
column reference a subquery. You must use a trigger. The failure to
prevent the exoressions creation or consistently report such a failure is
the bug, not this. Unfortunately preventing the behavior is not
reasonable, we can only document its forbiddance.

David J.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2023-10-09 15:03:37 Re: BUG #18151: pg_upgradecluster fails when column default refers to column
Previous Message Tom Lane 2023-10-09 14:11:31 Re: BUG #18151: pg_upgradecluster fails when column default refers to column