-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test adding and satisfying constraint in same txn
Signed-off-by: Morgan Douglas <[email protected]> Tweak test Signed-off-by: Morgan Douglas <[email protected]> Tweak test Signed-off-by: Morgan Douglas <[email protected]> Tweak tests Signed-off-by: Morgan Douglas <[email protected]> Teak tests Signed-off-by: Morgan Douglas <[email protected]> Tweak tests Signed-off-by: Morgan Douglas <[email protected]> Tweak tests Signed-off-by: Morgan Douglas <[email protected]> Tweak tests Signed-off-by: Morgan Douglas <[email protected]> Tweak tests Signed-off-by: Morgan Douglas <[email protected]> Tweak tests Signed-off-by: Morgan Douglas <[email protected]> Tweak tests Signed-off-by: Morgan Douglas <[email protected]>
- Loading branch information
Showing
18 changed files
with
169 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- add unsatisfied constraint with table create in txn | ||
drop table if exists t | ||
begin | ||
create table t { schema { int a } keys { "a" = a } constraints { "a" -> "donut":"a" on delete cascade } }$$ | ||
commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[drop table if exists t] rc 0 | ||
[begin] rc 0 | ||
[create table t { schema { int a } keys { "a" = a } constraints { "a" -> "donut":"a" on delete cascade } }] rc 0 | ||
[commit] failed with rc 240 constraint error for table "t" key "a" -> <"donut":"a">: parent table not found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- add unsatisfied constraint with table create in txn (target table exists but doesn't have the right key) | ||
drop table if exists t | ||
drop table if exists q | ||
begin | ||
create table t { schema { int a } keys { "a" = a } constraints { "a" -> "q":"a" on delete cascade } }$$ | ||
create table q { schema { int a } keys { "wrong_name" = a } }$$ | ||
commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[drop table if exists t] rc 0 | ||
[drop table if exists q] rc 0 | ||
[begin] rc 0 | ||
[create table t { schema { int a } keys { "a" = a } constraints { "a" -> "q":"a" on delete cascade } }] rc 0 | ||
[create table q { schema { int a } keys { "wrong_name" = a } }] rc 0 | ||
[commit] failed with rc 240 constraint error for table "t" key "a" -> <"q":"a">: parent key not found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-- add constraint with table create and then satisfy it with table alter in a transaction. | ||
-- fails with an error now but can be supported in the future | ||
drop table if exists foo | ||
drop table if exists bar | ||
create table foo { schema { int a } keys { "donut" = a } }$$ | ||
begin | ||
create table bar { schema { int a } keys { "a" = a } constraints { "a" -> "foo":"a" on delete cascade } }$$ | ||
alter table foo { schema { int a } keys { "a" = a } }$$ | ||
commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[drop table if exists foo] rc 0 | ||
[drop table if exists bar] rc 0 | ||
[create table foo { schema { int a } keys { "donut" = a } }] rc 0 | ||
[begin] rc 0 | ||
[create table bar { schema { int a } keys { "a" = a } constraints { "a" -> "foo":"a" on delete cascade } }] rc 0 | ||
[alter table foo { schema { int a } keys { "a" = a } }] rc 0 | ||
[commit] failed with rc 240 constraint error for table "bar" key "a" -> <"foo":"a">: parent key not found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- add constraint with table alter and then satisfy it with table alter in a transaction. | ||
-- fails with an error now but can be supported in the future | ||
drop table if exists foo | ||
drop table if exists bar | ||
create table foo(i int)$$ | ||
create table bar(i int)$$ | ||
begin | ||
alter table foo {schema{int i} keys{dup "key" = i} constraints{"key" -> <"bar" : "pk">}} $$ | ||
alter table bar {schema{int i} keys{"pk" = i}} $$ | ||
commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[drop table if exists foo] rc 0 | ||
[drop table if exists bar] rc 0 | ||
[create table foo(i int)] rc 0 | ||
[create table bar(i int)] rc 0 | ||
[begin] rc 0 | ||
[alter table foo {schema{int i} keys{dup "key" = i} constraints{"key" -> <"bar" : "pk">}}] rc 0 | ||
[alter table bar {schema{int i} keys{"pk" = i}}] rc 0 | ||
[commit] failed with rc 240 constraint error for table "foo" key "key" -> <"bar":"pk">: parent key not found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-- add constraint with table create and then satisfy it with table create in a transaction. | ||
drop table if exists foo | ||
drop table if exists bar | ||
begin | ||
create table foo { schema { int a } keys { "a" = a } constraints { "a" -> "bar":"a" on delete cascade } }$$ | ||
create table bar { schema { int a } keys { "a" = a } }$$ | ||
commit | ||
insert into foo values(1) | ||
select 'shouldnt see me' from foo | ||
insert into bar values(1) | ||
insert into foo values(1) | ||
select 'should see me' from foo | ||
select 'should see me' from bar | ||
delete from bar where 1 | ||
select 'shouldnt see me' from foo | ||
select 'shouldnt see me' from bar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[drop table if exists foo] rc 0 | ||
[drop table if exists bar] rc 0 | ||
[begin] rc 0 | ||
[create table foo { schema { int a } keys { "a" = a } constraints { "a" -> "bar":"a" on delete cascade } }] rc 0 | ||
[create table bar { schema { int a } keys { "a" = a } }] rc 0 | ||
[commit] rc 0 | ||
[insert into foo values(1)] failed with rc 3 Transaction violates foreign key constraint foo(a) -> bar(a): key value does not exist in parent table | ||
[select 'shouldnt see me' from foo] rc 0 | ||
(rows inserted=1) | ||
[insert into bar values(1)] rc 0 | ||
(rows inserted=1) | ||
[insert into foo values(1)] rc 0 | ||
('should see me'='should see me') | ||
[select 'should see me' from foo] rc 0 | ||
('should see me'='should see me') | ||
[select 'should see me' from bar] rc 0 | ||
(rows deleted=1) | ||
[delete from bar where 1] rc 0 | ||
[select 'shouldnt see me' from foo] rc 0 | ||
[select 'shouldnt see me' from bar] rc 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
-- add constraint with table alter and then satisfy it with table create in a transaction. | ||
-- BUGGY -- cascade doesn't get registered somehow | ||
drop table if exists foo | ||
drop table if exists bar | ||
create table foo(i int)$$ | ||
begin | ||
alter table foo { schema { int a } keys { "a" = a } constraints { "a" -> "bar":"a" on delete cascade } }$$ | ||
create table bar { schema { int a } keys { "a" = a } }$$ | ||
commit | ||
insert into foo values(1) | ||
select 'shouldnt see me' from foo | ||
insert into bar values(1) | ||
insert into foo values(1) | ||
select 'should see me' from foo | ||
select 'should see me' from bar | ||
delete from bar where 1 | ||
select 'shouldnt see me' from foo | ||
select 'shouldnt see me' from bar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[drop table if exists foo] rc 0 | ||
[drop table if exists bar] rc 0 | ||
[create table foo(i int)] rc 0 | ||
[begin] rc 0 | ||
[alter table foo { schema { int a } keys { "a" = a } constraints { "a" -> "bar":"a" on delete cascade } }] rc 0 | ||
[create table bar { schema { int a } keys { "a" = a } }] rc 0 | ||
[commit] rc 0 | ||
[insert into foo values(1)] failed with rc 3 Transaction violates foreign key constraint foo(a) -> bar(a): key value does not exist in parent table | ||
[select 'shouldnt see me' from foo] rc 0 | ||
(rows inserted=1) | ||
[insert into bar values(1)] rc 0 | ||
(rows inserted=1) | ||
[insert into foo values(1)] rc 0 | ||
('should see me'='should see me') | ||
[select 'should see me' from foo] rc 0 | ||
('should see me'='should see me') | ||
[select 'should see me' from bar] rc 0 | ||
(rows deleted=1) | ||
[delete from bar where 1] rc 0 | ||
[select 'shouldnt see me' from foo] rc 0 | ||
[select 'shouldnt see me' from bar] rc 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-- satisfy a constraint with table create and then add it with table alter in a txn | ||
drop table if exists foo | ||
drop table if exists bar | ||
create table foo(i int)$$ | ||
begin | ||
create table bar { schema { int a } keys { "a" = a } }$$ | ||
alter table foo { schema { int a } keys { "a" = a } constraints { "a" -> "bar":"a" on delete cascade } }$$ | ||
commit | ||
insert into foo values(1) | ||
select 'shouldnt see me' from foo | ||
insert into bar values(1) | ||
insert into foo values(1) | ||
select 'should see me' from foo | ||
select 'should see me' from bar | ||
delete from bar where 1 | ||
select 'shouldnt see me' from foo | ||
select 'shouldnt see me' from bar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[drop table if exists foo] rc 0 | ||
[drop table if exists bar] rc 0 | ||
[create table foo(i int)] rc 0 | ||
[begin] rc 0 | ||
[create table bar { schema { int a } keys { "a" = a } }] rc 0 | ||
[alter table foo { schema { int a } keys { "a" = a } constraints { "a" -> "bar":"a" on delete cascade } }] rc 0 | ||
[commit] rc 0 | ||
[insert into foo values(1)] failed with rc 3 Transaction violates foreign key constraint foo(a) -> bar(a): key value does not exist in parent table | ||
[select 'shouldnt see me' from foo] rc 0 | ||
(rows inserted=1) | ||
[insert into bar values(1)] rc 0 | ||
(rows inserted=1) | ||
[insert into foo values(1)] rc 0 | ||
('should see me'='should see me') | ||
[select 'should see me' from foo] rc 0 | ||
('should see me'='should see me') | ||
[select 'should see me' from bar] rc 0 | ||
(rows deleted=1) | ||
[delete from bar where 1] rc 0 | ||
[select 'shouldnt see me' from foo] rc 0 | ||
[select 'shouldnt see me' from bar] rc 0 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.