Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
39090: opt: add catalog test with FKs r=RaduBerinde a=RaduBerinde

Add `EXPLAIN (OPT, CATALOG)` tests with foreign keys, which show the
current problem with inbound references.

Release note: None

Co-authored-by: Radu Berinde <[email protected]>
  • Loading branch information
craig[bot] and RaduBerinde committed Jul 25, 2019
2 parents 7864306 + fb77d5d commit e0b2300
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions pkg/sql/opt/exec/execbuilder/testdata/catalog
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,48 @@ TABLE uvwxy
├── u int not null
└── v int not null
scan uvwxy

# Test foreign keys.
statement ok
CREATE TABLE parent (p INT, q INT, r INT, other INT, PRIMARY KEY (p, q, r))

statement ok
CREATE TABLE child (
c INT PRIMARY KEY,
p INT, q INT, r INT,
CONSTRAINT fk FOREIGN KEY (p,q,r) REFERENCES parent(p,q,r) MATCH FULL
)

query T
EXPLAIN (OPT, CATALOG) SELECT * from child
----
TABLE child
├── c int not null
├── p int
├── q int
├── r int
├── INDEX primary
│ └── c int not null
├── INDEX child_auto_index_fk
│ ├── p int
│ ├── q int
│ ├── r int
│ └── c int not null
└── CONSTRAINT fk FOREIGN KEY test.public.child (p, q, r) REFERENCES test.public.parent (p, q, r) MATCH FULL
scan child

# TODO(lucy/jordan/radu): the inbound foreign key reference is borked.
query T
EXPLAIN (OPT, CATALOG) SELECT * from parent
----
TABLE parent
├── p int not null
├── q int not null
├── r int not null
├── other int
├── INDEX primary
│ ├── p int not null
│ ├── q int not null
│ └── r int not null
└── REFERENCED BY CONSTRAINT FOREIGN KEY test.public.child () REFERENCES test.public.parent ()
scan parent

0 comments on commit e0b2300

Please sign in to comment.