diff --git a/pkg/sql/logictest/testdata/logic_test/schema_change_in_txn b/pkg/sql/logictest/testdata/logic_test/schema_change_in_txn index 44c8c76bf7ac..c15cde27543a 100644 --- a/pkg/sql/logictest/testdata/logic_test/schema_change_in_txn +++ b/pkg/sql/logictest/testdata/logic_test/schema_change_in_txn @@ -1690,3 +1690,33 @@ COMMIT statement ok DROP TABLE t, t2 +subtest delete_index_in_other_table + +# Test setup +statement ok +BEGIN; + +statement ok +CREATE TABLE a (); + +statement ok +CREATE TABLE b ( key INT ); + +statement ok +CREATE INDEX b_idx ON b (key); + +statement ok +COMMIT; + +# Try to delete an index in the same transaction +statement ok +BEGIN; + +statement ok +DROP TABLE a; + +statement ok +DROP INDEX b_idx CASCADE; + +statement ok +COMMIT; diff --git a/pkg/sql/resolver.go b/pkg/sql/resolver.go index f6a66d9f4e29..927b61632a23 100644 --- a/pkg/sql/resolver.go +++ b/pkg/sql/resolver.go @@ -401,7 +401,7 @@ func findTableContainingIndex( result = nil for i := range tns { tn := &tns[i] - tableDesc, err := ResolveMutableExistingObject(ctx, sc, tn, true, ResolveAnyDescType) + tableDesc, err := ResolveMutableExistingObject(ctx, sc, tn, false /*required*/, ResolveAnyDescType) if err != nil { return nil, nil, err }