Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nvJo5-0008Hr-PM for pgsql-bugs@arkaria.postgresql.org; Sun, 29 May 2022 14:22:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nvJo3-0001cM-Rl for pgsql-bugs@arkaria.postgresql.org; Sun, 29 May 2022 14:22:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nvJo3-0001cB-Fi for pgsql-bugs@lists.postgresql.org; Sun, 29 May 2022 14:22:11 +0000 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nvJo0-0002Rt-PS for pgsql-bugs@lists.postgresql.org; Sun, 29 May 2022 14:22:10 +0000 Received: by mail-lj1-x236.google.com with SMTP id g12so9217753lja.3 for ; Sun, 29 May 2022 07:22:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hagander-net.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=mkRxbeHxbCkqjNQRIF8JYX0tRGv/0LDzHObH+/vxnDQ=; b=Ci7YiES287ZDipkp03KpQB5Emc81Tttrda3+4KBLZDsG8Ze88yG30I9YQOEa1NTiHt QwQ6Q9Ja4xjb4AgD4VfGUnFudZ90VncnJO0PFD2PFxFqRsbph5oHgiXHRduEEuYTuEvY P6feUYGJK0outUK/oXndTkIuFNuIjaJmC8NDcxhaDssBKUSK3ecJoiYxohyi7jRTjxoU mDO2QXHSSLH7QRn0L0+bgNg+kIW04YLl8wc6pF4eb1CnpEsmLHx4h/3tQ/P4nuYAMTeJ d4bB4GBBqQ9G2LD0hnuhxppfDlucCelB2kJEK21AHvWGxFVIEK2CQDNJoB7sbBRJNRWi hUhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=mkRxbeHxbCkqjNQRIF8JYX0tRGv/0LDzHObH+/vxnDQ=; b=cc/2RHYgqFxVzfVgSDESnGVbxB+rG9BL5xDJd4MqpywS+8NWZ6wZ+0w0LZer00mLA3 peBzuXIiyzX9lYyk0j3wvufBUhk7CLMV4uO7efZYjdFTZKtO+wWL2lxw+h9uPPq9/Qbx ckwFb+cvNwlyD2Wh7QvHQC35NeIDGPy82jqzO3vDxahcZBe6qn8Jmkw2/08v0pxRkRKo FMMLd6DAT+uGuig4wL8IePayUNMbTp5Tyq+vQDpF9lFy0Xj5wsF4yeW5Phb7tBeWObeq w6St33iWovxDOlIBUNvITrIRYK0P8tSRAICtBOEc7B5jis9sEJKueP/LuRtBFXT/o3Va JQ+A== X-Gm-Message-State: AOAM532zwTOdnxszb/rN2BnII3FZVvwQ4K40VjTkVlcrdUlwEAy2t2LL +zjPamHIzzLnOIx2oQr0isOuMjoKCQPnTTQ5rD8FnHXfrXg= X-Google-Smtp-Source: ABdhPJx1YJBQTA7IbWYk2plmE8ruYGYJs+EkUh0rFUBlOEnaA1mp9r0cyMq+1n7snfz0xyHU+ZqnYAzs32JS0Zjjklg= X-Received: by 2002:a05:651c:1503:b0:24c:81df:e1f2 with SMTP id e3-20020a05651c150300b0024c81dfe1f2mr30871799ljf.182.1653834126603; Sun, 29 May 2022 07:22:06 -0700 (PDT) MIME-Version: 1.0 References: <17502-281a7aaacfaa872a@postgresql.org> In-Reply-To: <17502-281a7aaacfaa872a@postgresql.org> From: Magnus Hagander Date: Sun, 29 May 2022 16:21:54 +0200 Message-ID: Subject: Re: BUG #17502: View based on window functions returns wrong results when queried To: daniel.farkas@datoris.com, pgsql-bugs@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000a24cbb05e02743d1" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000a24cbb05e02743d1 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, May 29, 2022 at 4:20 PM PG Bug reporting form < noreply@postgresql.org> wrote: > The following bug has been logged on the website: > > Bug reference: 17502 > Logged by: Daniel Farka=C5=A1 > Email address: daniel.farkas@datoris.com > PostgreSQL version: 10.10 > Operating system: Linux > Description: > > Hey, > > Please be gentle, I've never been in contact with Postgres developers. > In short, I've created a view, which has rather sketchy window functions, > but it gives me results I need. > When I do select * on it, it gives me what I expect. One of the columns h= as > five distinct values. > But when I do group by on that column, it gives me only one of the values= . > When I drop the view and create materialized view, all is good, I get all > five values. > > My guess is that some parts of the inner select are affecting outer, view= 's > select, which is not something I would expect. > My current Postgres is PostgreSQL 10.10 on x86_64-pc-linux-musl, compiled > by > gcc (Alpine 8.3.0) 8.3.0, 64-bit. > If you think this is worth investigating further, I will try composing a > simpler example, and test it in a more recent Postgres version. > Maybe it's a known limitation I'm not aware of. > > Let me know what you think. > > Please see if you can reproduce this on a current version of PostgreSQL 10, which is 10.21. Version 10.10 is lacking more than two and a half years worth of bugfixes. If you can then yes, try to put together a simpler example, because it certainly does not sound like correct behavior. //Magnus --000000000000a24cbb05e02743d1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Sun, May 29, 2022 at 4:20 PM PG Bug re= porting form <noreply@postgres= ql.org> wrote:
The following bug has been logged on the website:

Bug reference:=C2=A0 =C2=A0 =C2=A0 17502
Logged by:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Daniel Farka=C5=A1
Email address:=C2=A0 =C2=A0 =C2=A0 daniel.farkas@datoris.com
PostgreSQL version: 10.10
Operating system:=C2=A0 =C2=A0Linux
Description:=C2=A0 =C2=A0 =C2=A0 =C2=A0

Hey,

Please be gentle, I've never been in contact with Postgres developers.<= br> In short, I've created a view, which has rather sketchy window function= s,
but it gives me results I need.
When I do select * on it, it gives me what I expect. One of the columns has=
five distinct values.
But when I do group by on that column, it gives me only one of the values.<= br> When I drop the view and create materialized view, all is good, I get all five values.

My guess is that some parts of the inner select are affecting outer, view&#= 39;s
select, which is not something I would expect.
My current Postgres is PostgreSQL 10.10 on x86_64-pc-linux-musl, compiled b= y
gcc (Alpine 8.3.0) 8.3.0, 64-bit.
If you think this is worth investigating further, I will try composing a simpler example, and test it in a more recent Postgres version.
Maybe it's a known limitation I'm not aware of.

Let me know what you think.


Please = see if you can reproduce this on a current version of PostgreSQL 10, which = is 10.21. Version 10.10 is lacking more than two and a half years worth of = bugfixes.

If you can then yes, try to put together= a simpler example, because it certainly does not sound like correct behavi= or.

//Magnus

--000000000000a24cbb05e02743d1--