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

sql: fix table lookup for drop index #40516

Merged
merged 1 commit into from
Sep 5, 2019
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
30 changes: 30 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/schema_change_in_txn
Original file line number Diff line number Diff line change
Expand Up @@ -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;
2 changes: 1 addition & 1 deletion pkg/sql/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down