diff --git a/pkg/sql/drop_sequence.go b/pkg/sql/drop_sequence.go index d25c976310e9..57c4e0d91e88 100644 --- a/pkg/sql/drop_sequence.go +++ b/pkg/sql/drop_sequence.go @@ -107,6 +107,7 @@ func (p *planner) dropSequenceImpl( jobDesc string, behavior tree.DropBehavior, ) error { + removeSequenceOwnerIfExists(ctx, p, seqDesc.ID, seqDesc.GetSequenceOpts()) return p.initiateDropTable(ctx, seqDesc, queueJob, jobDesc, true /* drainName */) } diff --git a/pkg/sql/logictest/testdata/logic_test/sequences b/pkg/sql/logictest/testdata/logic_test/sequences index f503ff0b1c29..cddadc782708 100644 --- a/pkg/sql/logictest/testdata/logic_test/sequences +++ b/pkg/sql/logictest/testdata/logic_test/sequences @@ -1081,3 +1081,17 @@ CREATE TABLE c(a INT DEFAULT(currval('currval_dep_test'))) statement error pq: cannot drop sequence currval_dep_test because other objects depend on it DROP SEQUENCE currval_dep_test + +subtest regression_50649 + +statement ok +CREATE TABLE t_50649(a INT PRIMARY KEY) + +statement ok +CREATE SEQUENCE seq_50649 OWNED BY t_50649.a + +statement ok +DROP SEQUENCE seq_50649 + +statement ok +DROP TABLE t_50649