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

lightning: add foreign key test #40103

Merged
merged 5 commits into from
Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions br/tests/lightning_foreign_key/data/fk.child-schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create table child (id int key, pid int, constraint fk_1 foreign key (pid) references parent(id));
1 change: 1 addition & 0 deletions br/tests/lightning_foreign_key/data/fk.child.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
insert into child values (1,1),(2,2),(3,3),(4,4);
1 change: 1 addition & 0 deletions br/tests/lightning_foreign_key/data/fk.parent-schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create table parent(id int key, a int);
1 change: 1 addition & 0 deletions br/tests/lightning_foreign_key/data/fk.parent.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
insert into parent values (1,1),(2,2),(3,3),(4,4);
12 changes: 10 additions & 2 deletions br/tests/lightning_foreign_key/run.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,21 @@

set -eu

# Create existing tables that import data will reference.
run_sql 'DROP DATABASE IF EXISTS fk;'
run_sql 'CREATE DATABASE IF NOT EXISTS fk;'
# Create existing tables that import data will reference.
run_sql 'CREATE TABLE fk.t2 (a BIGINT PRIMARY KEY);'

for BACKEND in tidb local; do
run_sql 'DROP TABLE IF EXISTS fk.t;'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

due to delete this line, so the local backend test failed.

run_lightning --backend $BACKEND
run_sql 'SELECT GROUP_CONCAT(a) FROM fk.t ORDER BY a;'
check_contains '1,2,3,4,5'

run_sql 'SELECT count(1), sum(a) FROM fk.parent;'
check_contains 'count(1): 4'
check_contains 'sum(a): 10'

run_sql 'SELECT count(1), sum(pid) FROM fk.child;'
check_contains 'count(1): 4'
check_contains 'sum(pid): 10'
done