-
Notifications
You must be signed in to change notification settings - Fork 217
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]> 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]> Remove dummy test Signed-off-by: Morgan Douglas <[email protected]> Update test Signed-off-by: Morgan Douglas <[email protected]> Fix test Signed-off-by: Morgan Douglas <[email protected]>
- Loading branch information
Showing
20 changed files
with
224 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,17 @@ | ||
-- add constraint with table create and then satisfy it with table alter in a transaction. | ||
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 | ||
insert into bar values(1) | ||
select 'shouldnt see me' from bar | ||
insert into foo values(1) | ||
insert into bar values(1) | ||
select 'should see me' from bar | ||
select 'should see me' from foo | ||
delete from foo where 1 | ||
select 'shouldnt see me' from bar | ||
select 'shouldnt see me' from foo |
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 { 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] rc 0 | ||
[insert into bar values(1)] failed with rc 3 Transaction violates foreign key constraint bar(a) -> foo(a): key value does not exist in parent table | ||
[select 'shouldnt see me' from bar] rc 0 | ||
(rows inserted=1) | ||
[insert into foo values(1)] rc 0 | ||
(rows inserted=1) | ||
[insert into bar values(1)] rc 0 | ||
('should see me'='should see me') | ||
[select 'should see me' from bar] rc 0 | ||
('should see me'='should see me') | ||
[select 'should see me' from foo] rc 0 | ||
(rows deleted=1) | ||
[delete from foo where 1] rc 0 | ||
[select 'shouldnt see me' from bar] rc 0 | ||
[select 'shouldnt see me' from foo] 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 alter in a transaction. | ||
drop table if exists bar | ||
drop table if exists foo | ||
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" on delete cascade }} $$ | ||
alter table bar {schema{int i} keys{"pk" = i}} $$ | ||
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,22 @@ | ||
[drop table if exists bar] rc 0 | ||
[drop table if exists foo] 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" on delete cascade }}] rc 0 | ||
[alter table bar {schema{int i} keys{"pk" = i}}] rc 0 | ||
[commit] rc 0 | ||
[insert into foo values(1)] failed with rc 3 Transaction violates foreign key constraint foo(i) -> bar(i): 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,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,17 @@ | ||
-- add constraint with table alter and then satisfy it with table create in a transaction. | ||
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 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 @@ | ||
-- Document that you can't change the parent key in a foreign key constraint | ||
-- Although this isn't currently supported, we could add support for it in the future | ||
drop table if exists foo | ||
drop table if exists bar | ||
create table bar {schema{int i int j} keys{"pk" = i+j}} $$ | ||
create table foo {schema{int i int j} keys{dup "key" = i+j} constraints{"key" -> "bar":"pk" on delete cascade }} $$ | ||
alter table bar {schema{int i} keys{"pk" = i}} $$ |
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 @@ | ||
[drop table if exists foo] rc 0 | ||
[drop table if exists bar] rc 0 | ||
[create table bar {schema{int i int j} keys{"pk" = i+j}}] rc 0 | ||
[create table foo {schema{int i int j} keys{dup "key" = i+j} constraints{"key" -> "bar":"pk" on delete cascade }}] rc 0 | ||
[alter table bar {schema{int i} keys{"pk" = i}}] failed with rc 240 cannot change index referenced by other tables |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.