Commit 0f7fe2a7 authored by Galina Shalygina's avatar Galina Shalygina

Changes in test files

parent 46a2e413
This diff is collapsed.
...@@ -27,7 +27,7 @@ drop table t1; ...@@ -27,7 +27,7 @@ drop table t1;
create table folks(id int, name char(32), dob date, father int, mother int); create table folks(id int, name char(32), dob date, father int, mother int);
insert into folks values insert into folks values
(100, 'Vasya', '2000-01-01', 20, 30), (100, 'Me', '2000-01-01', 20, 30),
(20, 'Dad', '1970-02-02', 10, 9), (20, 'Dad', '1970-02-02', 10, 9),
(30, 'Mom', '1975-03-03', 8, 7), (30, 'Mom', '1975-03-03', 8, 7),
(10, 'Grandpa Bill', '1940-04-05', null, null), (10, 'Grandpa Bill', '1940-04-05', null, null),
...@@ -47,7 +47,7 @@ as ...@@ -47,7 +47,7 @@ as
( (
select * select *
from folks from folks
where name = 'Vasya' and dob = '2000-01-01' where name = 'Me' and dob = '2000-01-01'
union union
select p.id, p.name, p.dob, p.father, p.mother select p.id, p.name, p.dob, p.father, p.mother
from folks as p, ancestors AS a from folks as p, ancestors AS a
...@@ -65,7 +65,7 @@ as ...@@ -65,7 +65,7 @@ as
union union
select * select *
from folks from folks
where name = 'Vasya' and dob = '2000-01-01' where name = 'Me' and dob = '2000-01-01'
) )
select * from ancestors; select * from ancestors;
...@@ -89,7 +89,7 @@ as ...@@ -89,7 +89,7 @@ as
( (
select * select *
from folks from folks
where name = 'Vasya' or name='Sister Amy' where name = 'Me' or name='Sister Amy'
union union
select p.* select p.*
from folks as p, ancestors as a from folks as p, ancestors as a
...@@ -107,14 +107,14 @@ as ...@@ -107,14 +107,14 @@ as
union union
select * select *
from folks from folks
where name='Vasya' where name='Me'
), ),
ancestors ancestors
as as
( (
select * select *
from folks from folks
where name='Vasya' where name='Me'
union union
select * select *
from ancestors from ancestors
...@@ -160,7 +160,7 @@ as ...@@ -160,7 +160,7 @@ as
( (
select * select *
from folks from folks
where name = 'Vasya' and dob = '2000-01-01' where name = 'Me' and dob = '2000-01-01'
union union
select p.* select p.*
from folks as p, ancestors AS a from folks as p, ancestors AS a
...@@ -181,7 +181,7 @@ as ...@@ -181,7 +181,7 @@ as
( (
select * select *
from folks from folks
where name = 'Vasya' where name = 'Me'
union union
select p.* select p.*
from folks as p, ancestors AS a from folks as p, ancestors AS a
...@@ -200,7 +200,7 @@ as ...@@ -200,7 +200,7 @@ as
( (
select * select *
from folks from folks
where name = 'Vasya' where name = 'Me'
union union
select p.* select p.*
from folks as p, ancestors as fa from folks as p, ancestors as fa
...@@ -223,7 +223,7 @@ as ...@@ -223,7 +223,7 @@ as
union union
select h.*, w.* select h.*, w.*
from folks v, folks h, folks w from folks v, folks h, folks w
where v.name = 'Vasya' and where v.name = 'Me' and
(v.father = h.id AND v.mother= w.id) (v.father = h.id AND v.mother= w.id)
), ),
coupled_ancestors (id, name, dob, father, mother) coupled_ancestors (id, name, dob, father, mother)
...@@ -246,7 +246,7 @@ as ...@@ -246,7 +246,7 @@ as
( (
select * select *
from folks from folks
where name = 'Vasya' and dob = '2000-01-01' where name = 'Me' and dob = '2000-01-01'
union union
select p.id, p.name, p.dob, p.father, p.mother select p.id, p.name, p.dob, p.father, p.mother
from folks as p, ancestors AS a from folks as p, ancestors AS a
...@@ -268,7 +268,7 @@ as ...@@ -268,7 +268,7 @@ as
( (
select * select *
from folks from folks
where name = 'Vasya' and dob = '2000-01-01' where name = 'Me' and dob = '2000-01-01'
union union
select p.id, p.name, p.dob, p.father, p.mother select p.id, p.name, p.dob, p.father, p.mother
from folks as p, ancestors AS a from folks as p, ancestors AS a
...@@ -287,7 +287,7 @@ as ...@@ -287,7 +287,7 @@ as
( (
select * select *
from folks from folks
where name = 'Vasya' where name = 'Me'
union union
select p.* select p.*
from folks as p, ancestors as fa from folks as p, ancestors as fa
...@@ -312,7 +312,7 @@ as ...@@ -312,7 +312,7 @@ as
( (
select * select *
from folks from folks
where name = 'Vasya' and dob = '2000-01-01' where name = 'Me' and dob = '2000-01-01'
union union
select p.id, p.name, p.dob, p.father, p.mother select p.id, p.name, p.dob, p.father, p.mother
from folks as p, ancestors AS a from folks as p, ancestors AS a
...@@ -325,9 +325,9 @@ with recursive ...@@ -325,9 +325,9 @@ with recursive
ancestor_ids (id) ancestor_ids (id)
as as
( (
select father from folks where name = 'Vasya' select father from folks where name = 'Me'
union union
select mother from folks where name = 'Vasya' select mother from folks where name = 'Me'
union union
select father from folks, ancestor_ids a where folks.id = a.id select father from folks, ancestor_ids a where folks.id = a.id
union union
...@@ -347,7 +347,7 @@ as ...@@ -347,7 +347,7 @@ as
( (
select * select *
from folks from folks
where name = 'Vasya' where name = 'Me'
union all union all
select p.* select p.*
from folks as p, ancestors as fa from folks as p, ancestors as fa
...@@ -367,9 +367,9 @@ with recursive ...@@ -367,9 +367,9 @@ with recursive
ancestor_ids (id, generation) ancestor_ids (id, generation)
as as
( (
select father, 1 from folks where name = 'Vasya' and father is not null select father, 1 from folks where name = 'Me' and father is not null
union all union all
select mother, 1 from folks where name = 'Vasya' and mother is not null select mother, 1 from folks where name = 'Me' and mother is not null
union all union all
select father, fa.generation+1 from folks, ancestor_ids fa select father, fa.generation+1 from folks, ancestor_ids fa
where folks.id = fa.id and (father not in (select id from ancestor_ids)) where folks.id = fa.id and (father not in (select id from ancestor_ids))
...@@ -388,9 +388,9 @@ with recursive ...@@ -388,9 +388,9 @@ with recursive
ancestor_ids (id, generation) ancestor_ids (id, generation)
as as
( (
select father from folks where name = 'Vasya' and father is not null select father from folks where name = 'Me' and father is not null
union all union all
select mother from folks where name = 'Vasya' and mother is not null select mother from folks where name = 'Me' and mother is not null
union all union all
select father, fa.generation+1 from folks, ancestor_ids fa select father, fa.generation+1 from folks, ancestor_ids fa
where folks.id = fa.id and (father not in (select id from ancestor_ids)) where folks.id = fa.id and (father not in (select id from ancestor_ids))
...@@ -405,9 +405,9 @@ with recursive ...@@ -405,9 +405,9 @@ with recursive
ancestor_ids (id, generation) ancestor_ids (id, generation)
as as
( (
select father, 1 from folks where name = 'Vasya' and father is not null select father, 1 from folks where name = 'Me' and father is not null
union all union all
select mother, 1 from folks where name = 'Vasya' and mother is not null select mother, 1 from folks where name = 'Me' and mother is not null
union all union all
select father, fa.generation+1 from folks, ancestor_ids fa select father, fa.generation+1 from folks, ancestor_ids fa
where folks.id = fa.id and father is not null and where folks.id = fa.id and father is not null and
...@@ -428,9 +428,9 @@ with recursive ...@@ -428,9 +428,9 @@ with recursive
coupled_ancestor_ids (id) coupled_ancestor_ids (id)
as as
( (
select father from folks where name = 'Vasya' and father is not null select father from folks where name = 'Me' and father is not null
union union
select mother from folks where name = 'Vasya' and mother is not null select mother from folks where name = 'Me' and mother is not null
union union
select n.father select n.father
from folks, coupled_ancestor_ids fa, coupled_ancestor_ids ma, folks n from folks, coupled_ancestor_ids fa, coupled_ancestor_ids ma, folks n
...@@ -452,9 +452,9 @@ with recursive ...@@ -452,9 +452,9 @@ with recursive
coupled_ancestor_ids (id) coupled_ancestor_ids (id)
as as
( (
select father from folks where name = 'Vasya' and father is not null select father from folks where name = 'Me' and father is not null
union union
select mother from folks where name = 'Vasya' and mother is not null select mother from folks where name = 'Me' and mother is not null
union union
select n.father select n.father
from folks, coupled_ancestor_ids fa, coupled_ancestor_ids ma, folks n from folks, coupled_ancestor_ids fa, coupled_ancestor_ids ma, folks n
...@@ -476,9 +476,9 @@ with recursive ...@@ -476,9 +476,9 @@ with recursive
ancestor_ids (id) ancestor_ids (id)
as as
( (
select father from folks where name = 'Vasya' select father from folks where name = 'Me'
union union
select mother from folks where name = 'Vasya' select mother from folks where name = 'Me'
union union
select father from folks left join ancestor_ids a on folks.id = a.id select father from folks left join ancestor_ids a on folks.id = a.id
union union
...@@ -497,9 +497,9 @@ with recursive ...@@ -497,9 +497,9 @@ with recursive
ancestor_ids (id) ancestor_ids (id)
as as
( (
select father from folks where name = 'Vasya' select father from folks where name = 'Me'
union union
select mother from folks where name = 'Vasya' select mother from folks where name = 'Me'
union union
select father from folks left join ancestor_ids a on folks.id = a.id select father from folks left join ancestor_ids a on folks.id = a.id
union union
...@@ -517,9 +517,9 @@ with recursive ...@@ -517,9 +517,9 @@ with recursive
ancestor_ids (id, generation) ancestor_ids (id, generation)
as as
( (
select father, 1 from folks where name = 'Vasya' select father, 1 from folks where name = 'Me'
union union
select mother, 1 from folks where name = 'Vasya' select mother, 1 from folks where name = 'Me'
union union
select father, a.generation+1 from folks, ancestor_ids a select father, a.generation+1 from folks, ancestor_ids a
where folks.id = a.id where folks.id = a.id
...@@ -540,9 +540,9 @@ with recursive ...@@ -540,9 +540,9 @@ with recursive
ancestor_ids (id, generation) ancestor_ids (id, generation)
as as
( (
select father, 1 from folks where name = 'Vasya' select father, 1 from folks where name = 'Me'
union union
select mother, 1 from folks where name = 'Vasya' select mother, 1 from folks where name = 'Me'
union union
select max(father), max(a.generation)+1 from folks, ancestor_ids a select max(father), max(a.generation)+1 from folks, ancestor_ids a
where folks.id = a.id where folks.id = a.id
...@@ -565,9 +565,9 @@ with recursive ...@@ -565,9 +565,9 @@ with recursive
ancestor_ids (id, generation) ancestor_ids (id, generation)
as as
( (
select father, 1 from folks where name = 'Vasya' select father, 1 from folks where name = 'Me'
union union
select mother, 1 from folks where name = 'Vasya' select mother, 1 from folks where name = 'Me'
union union
select max(father), a.generation+1 from folks, ancestor_ids a select max(father), a.generation+1 from folks, ancestor_ids a
where folks.id = a.id where folks.id = a.id
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment