Skip to content

Backup of unlogged table with sequence is broken for PostgreSQL 14 #5678

@thisiself

Description

@thisiself

Describe the bug

When I try to restore a backup to PostgreSQL 14, I receive an error.

To Reproduce

Steps to reproduce the behavior:

  1. Create an empty database (server PostgreSQL 14)
  2. Execute following script:
CREATE UNLOGGED TABLE IF NOT EXISTS public.table1
(
    "Id" integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
    CONSTRAINT table1_pkey PRIMARY KEY ("Id")
)
  1. Backup database (right-click on database, choose "Backup...", fill filename, all the rest - as default)
  2. Try to restore backup (server PostgreSQL 14)
  3. See the error

Expected behavior

A backup is restored without errors.

Error message

pg_restore: error: could not execute query: ERROR: "table1_Id_seq" is not a table
Command was: ALTER TABLE public.table1 ALTER COLUMN "Id" ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME public."table1_Id_seq"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
ALTER SEQUENCE public."table1_Id_seq" SET LOGGED;

Desktop (please complete the following information):

  • OS: Windows 10, 22H2
  • Version: 6.16, 6.17, 6.18
  • Mode: Desktop

Additional context

I believe the bug was introduced with PostgreSQL 15 support, with its new feature of unlogged sequences. I guess the first version with this bug is 6.15, but i haven't tested it. Working versions I've tested - 6.9, 6.10, 6.11.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions