On Sunday, October 8, 2023, PG Bug reporting form <
noreply@postgresql.org> wrote:
The following bug has been logged on the website:
Bug reference: 18151
Logged by: Liam Morland
Email address: liam@morland.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.