-
-
Couldn't load subscription status.
- Fork 585
Closed
dolthub/go-mysql-server
#2148Labels
bugSomething isn't workingSomething isn't workingcorrectnessWe don't return the same result as MySQLWe don't return the same result as MySQLcustomer issuegood reproEasily reproducible bugsEasily reproducible bugspanic
Description
Repro:
create table parent(a int primary key, b int);
create table child(c int primary key);
alter table child add foreign key (c) references parent(a);
call dolt_commit('-Am', 'new tables');
set foreign_key_checks=0;
drop table parent;
set foreign_key_checks=1;Now selecting from the information_schema.referential_constraints table fails:
select * from information_schema.referential_constraints;
table not found: parentWorse, dolt diff panics:
dolt diff HEAD~
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x1c24085]
goroutine 1 [running]:
github.com/dolthub/dolt/go/libraries/doltcore/sqle/sqlfmt.GenerateCreateTableForeignKeyDefinition({{0xc000f66bd8, 0x8}, {0xc000f66be0, 0x5}, {0x0, 0x0}, {0xc000f66bc8, 0x1, 0x1}, {0xc000f66be6, ...}, ...}, ...)
/c/Users/zachmu/liquidata/go-workspace/src/github.com/dolthub/dolt/go/libraries/doltcore/sqle/sqlfmt/schema_fmt.go:77 +0x465
github.com/dolthub/dolt/go/libraries/doltcore/sqle/sqlfmt.GenerateCreateTableStatement({0xc000f67450, 0x5}, {0x30c2c28, 0xc000e81b60}, {0xc00018b800, 0x1, 0x302c830?}, 0xc0011514a0?)
/c/Users/zachmu/liquidata/go-workspace/src/github.com/dolthub/dolt/go/libraries/doltcore/sqle/sqlfmt/schema_fmt.go:290 +0x630
In general, it's not safe to assume that a referenced foreign key table exists, they can be invalid.
Other things to test that I haven't yet:
INSERT, DELETE operations should still work on child after this setup (the defunct foreign key should be ignored).
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingcorrectnessWe don't return the same result as MySQLWe don't return the same result as MySQLcustomer issuegood reproEasily reproducible bugsEasily reproducible bugspanic