duckdb icon indicating copy to clipboard operation
duckdb copied to clipboard

I deleted SEQUENCE from default value of the table but i can't CREATE OR REPLACE SEQUENCE

Open serdardidan opened this issue 1 year ago • 2 comments

What happens?

Hi,

I have created a sequence and used it as the default value of a column in a table. I want to manually add data to the relevant column in this table and then set the start value of the sequence.

The error message: Dependency Error: Cannot drop entry "seq_personid" because there are entries that depend on it. table "Persons" depends on index "seq_personid". Use DROP...CASCADE to drop all dependents.

I added the sql.

To Reproduce

CREATE SEQUENCE if not exists seq_personid START 1;

CREATE TABLE if not exists Persons (
    id integer default nextval('seq_personid'),
    name varchar(255) not null
);

insert into Persons (name) values('a001');
insert into Persons (id, name) values(2, 'a002');

ALTER TABLE Persons ALTER COLUMN id SET default 0;

CREATE or REPLACE SEQUENCE seq_personid START 3;
--Dependency Error: Cannot drop entry "seq_personid" because there are entries that depend on it.
--table "Persons" depends on index "seq_personid".
--Use DROP...CASCADE to drop all dependents.

ALTER TABLE Persons ALTER COLUMN id SET default nextval('seq_personid');

insert into Persons (name) values('a003');
insert into Persons (name) values('a004');

select * from persons;

OS:

Windows 11

DuckDB Version:

v1.0.0

DuckDB Client:

.NET nuget and https://shell.duckdb.org/

Full Name:

Serdar Didan

Affiliation:

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a stable release

Did you include all relevant data sets for reproducing the issue?

Yes

Did you include all code required to reproduce the issue?

  • [X] Yes, I have

Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?

  • [X] Yes, I have

serdardidan avatar Aug 15 '24 03:08 serdardidan

Thanks for the report, that is a known limitation, but admittedly undocumented.

Dependencies don't have that level of granularity yet, the dependency is part of the table as a whole, resetting the DEFAULT or even removing the column will not get rid of the dependency yet

Tishj avatar Aug 15 '24 07:08 Tishj

Thanks for the reply

serdardidan avatar Aug 15 '24 18:08 serdardidan

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Nov 14 '24 00:11 github-actions[bot]

This issue was closed because it has been stale for 30 days with no activity.

github-actions[bot] avatar Dec 14 '24 00:12 github-actions[bot]