Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'not a sequence' issue #75

Open
amaximus opened this issue May 5, 2020 · 1 comment
Open

'not a sequence' issue #75

amaximus opened this issue May 5, 2020 · 1 comment

Comments

@amaximus
Copy link

amaximus commented May 5, 2020

I'm not a database expert, therefore I'm not sure if it was caused by the conversion tool but I ended up with the following error:

gerrit> SELECT nextval('change_id') from changes;
ERROR: ERROR: "change_id" is not a sequence
gerrit> \d changes
                     Table changes
 COLUMN_NAME          | TYPE
 ---------------------+--------------------------------------------------------------------
 change_key           | varchar(60) DEFAULT ''::character varying NOT NULL
 created_on           | timestamp DEFAULT now() NOT NULL
 last_updated_on      | timestamp DEFAULT '-infinity'::timestamp without time zone NOT NULL
 owner_account_id     | int4 DEFAULT 0 NOT NULL
 dest_project_name    | varchar(255) DEFAULT ''::character varying NOT NULL
 dest_branch_name     | varchar(255) DEFAULT ''::character varying NOT NULL
 status               | bpchar(1) DEFAULT ''::bpchar NOT NULL
 current_patch_set_id | int4 DEFAULT 0 NOT NULL
 subject              | varchar(255) DEFAULT ''::character varying NOT NULL
 topic                | varchar(255)
 row_version          | int4 DEFAULT 0 NOT NULL
 change_id            | int4 DEFAULT 0 NOT NULL
 original_subject     | varchar(255)
 submission_id        | varchar(255)

Indexes on changes:
  changes_pkey UNIQUE (change_id)
gerrit>

Reindex didn't help. Data can be queried, however inserts are failing.
Do you have any hint on what could have caused this?

Thanks.

@amaximus amaximus changed the title 'not in sequence' issue 'not a sequence' issue May 6, 2020
@amaximus
Copy link
Author

amaximus commented May 6, 2020

Turned out that the sequences all have an extra _s_seq postfix:

gerrit> SELECT c.relname FROM pg_class c WHERE c.relkind = 'S';
 relname
 -----------------------
 account_group_id_s_seq
 account_id_s_seq
 change_id_s_seq
 change_message_id_s_seq
(4 rows; 1 ms)
gerrit>

Renaming sequence fails with below message as existing change_id is not a sequence but a relation:

gerrit> alter sequence change_id_s_seq rename to change_id;
ERROR: ERROR: relation "change_id" already exists
gerrit> select c.relname, c.relnamespace from pg_class c where c.relname='change_id';
 relname   | relnamespace
 ----------+-------------
 change_id | 2200
(1 row; 1 ms)
gerrit>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant