uwdb / Cosette

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

count(*) should be different from count(column) #85

Open JsToCode opened 3 years ago

JsToCode commented 3 years ago

I use cosette online to prove the count projection equivalence. The answer should be not equivalent. Because count(*) will include NULL value, while count(column) will exclude NULL value. The following is the code:

schema s(a:int, b:int); table r(s); query q1 -- define query q1 select count(*) as a from r x;

query q2 -- define query q2 likewise select count(y.b) from r y;

verify q1 q2;

count There should be not equivalent if there exist some NULL values in y.b column. Even the int type, we can still set default value to NULL, not 0.