<body class=3D"ApplePlainTextBody" dir=3D"auto" =
style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
-webkit-line-break: after-white-space;">Ooops, forgot to mail the =
list.WBegin forwarded =
message:From: wrb <wrb@autistici.org>Subject: Re: =
[BUGS] BUG #13863: Select from views gives wrong resultsDate: 14. =
ledna 2016 10:49:27 SE=C4=8CTo: Haribabu Kommi =
<kommi.haribabu@gmail.com>Followup: This query =
should show better what's wrong with the optimizer:select a, =
count(*) from test group by cube (a);a | count =
---+-------1 | 12 | =
1 | 2(3 =
rows)select * from (select a, count(*) from test group by =
cube (a)) t where a is null;a | count ---+------- | =
0explain select * from (select a, =
count(*) from test group by cube (a)) t where a is null; =
&n=
bsp; &nbs=
p; QUERY PLAN =
&n=
bsp; &nbs=
p; --------------------------------------------------------=
----------GroupAggregate (cost=3D32.79..32.89 rows=3D2 =
width=3D4) Group Key: test.a Group Key: () =
Filter: (test.a IS NULL) -> Sort =
(cost=3D32.79..32.82 rows=3D11 width=3D4) =
Sort Key: test.a =
-> Seq Scan on test =
(cost=3D0.00..32.60 rows=3D11 width=3D4) =
&n=
bsp;Filter: (a IS NULL)The predicate "a is null" in the =
outer select should refer to results of inner select and should =
therefore return (null, 2) instead of no rows, =
right?W=