pgschema icon indicating copy to clipboard operation
pgschema copied to clipboard

Bug: Can't track sequences properly

Open sam-mosleh opened this issue 10 months ago • 1 comments

Step 1

Create table below (old.sql)

CREATE TABLE public.table1 (
    c1 int NOT NULL,
    c2 serial,
    c3 int GENERATED ALWAYS AS IDENTITY
);

Step 2

Modify it (new.sql)

CREATE TABLE public.table1 (
    c1 serial NOT NULL,
    c2 int GENERATED ALWAYS AS IDENTITY,
    c3 int GENERATED BY DEFAULT AS IDENTITY
);

Expected behavior: To modify sequences after running the plan successfully Actual behavior: Plan fails because of missing statements and it doesn't even detect c3

Plan: 1 to modify.

Summary by type:
  tables: 1 to modify

Tables:
  ~ table1
    ~ c1 (column)
    ~ c2 (column)

DDL to be executed:
--------------------------------------------------

ALTER TABLE table1 ALTER COLUMN c1 SET DEFAULT nextval('table1_c1_seq'::regclass);

ALTER TABLE table1 ALTER COLUMN c2 DROP DEFAULT;

Do you want to apply these changes? (yes/no): yes

Applying changes...

Executing group 1/1...
  Executing 2 statements in implicit transaction
Error: failed to execute concatenated statements in group 1: ERROR: relation "table1_c1_seq" does not exist (SQLSTATE 42P01)

Context

Tested version 1.6.2@ca0a203 darwin/arm64

@tianzhou I'd be glad to do the PR.

sam-mosleh avatar Feb 03 '26 07:02 sam-mosleh

@sam-mosleh happy to review

tianzhou avatar Feb 05 '26 17:02 tianzhou