uwdb / Cosette

Cosette is an automated SQL solver.
BSD 2-Clause "Simplified" License
666 stars 54 forks source link

Help, throw an exception when parsing #71

Closed wjinshui closed 5 years ago

wjinshui commented 5 years ago

Try to execute the following statement, but an exeception throws, please help!

schema s1(id:int, year_born:int);
schema s2(id:int);
table person(s1);
table writer(s2);
query q1 `select count(*) from person where exists (select * from writer where writer.id = person.id and person.year_born = 1935)`;
query q2 `select count(*) from (select distinct person.id from person,writer where person.id=writer.id and person.year_born=1935)`;
verify q1 q2;
stechu commented 5 years ago

Hi Jinshui,

I rewrite your query as below:

schema s1(id:int, year_born:int);
schema s2(id:int);
table person(s1);
table writer(s2);
query q1 
`select count(*) from person p where exists (select * from writer w where w.id = p.id and p.year_born = 1935)`;
query q2 `select count(*) from (select distinct p.id from person p, writer w where p.id=w.id and p.year_born=1935) a`;
verify q1 q2;

It returns a counterexample. Currently, we are forcing that user put an alias for each table.