Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/sequences
Original file line number Diff line number Diff line change
Expand Up @@ -2539,3 +2539,39 @@ SELECT substring(sequence_schema FOR 7), sequence_name FROM [SHOW SEQUENCES] WHE
pg_temp temp_seq

subtest end


subtest incorrect_cleanup_of_owned_by

statement ok
CREATE TABLE t_seq_owner (id BIGSERIAL NOT NULL);

statement ok
CREATE SEQUENCE id_seq_owned OWNED BY t_seq_owner.id;

statement ok
ALTER TABLE t_seq_owner ALTER COLUMN id SET DEFAULT nextval('id_seq_owned');

# Confirm the sequence still exists.
query I
SELECT count(*) FROM pg_sequences WHERE sequencename='id_seq_owned';
----
1


statement ok
drop table t_seq_owner;

# Confirm the sequence is dropped.
query I
SELECT count(*) FROM pg_sequences WHERE sequencename='id_seq_owned';
----
0

# Confirm the table is dropped.
query I
SELECT count(*) FROM pg_tables WHERE tablename='t_seq_owner';
----
0

subtest end
1 change: 0 additions & 1 deletion pkg/sql/schemachanger/scexec/scmutationexec/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ func updateColumnExprSequenceUsage(d *descpb.ColumnDescriptor) error {
ids.ForEach(all.Add)
}
d.UsesSequenceIds = all.Ordered()
d.OwnsSequenceIds = all.Ordered()
return nil
}

Expand Down