Re: BUG #15485: Order by of inlineable stable function incorrect

From: Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #15485: Order by of inlineable stable function incorrect
Date: 2018-11-04 00:15:41
Message-ID: 48f15472-9355-d83d-9bb7-4f59a12c305e@archidevsys.co.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 04/11/2018 13:11, PG Bug reporting form wrote:
> The following bug has been logged on the website:
>
> Bug reference: 15485
> Logged by: Tommas Factorylab
> Email address: tommas(at)factorylab(dot)nl
> PostgreSQL version: 9.6.10
> Operating system: ubuntu 14.04 x64
> Description:
>
> Hi,
>
> I am encountering a problem where the resultset is not correctly ordered
> (and that results in incorrect behaviour of my application). The ordering is
> done by a table function that is referenced in the "from clause" (function
> "fA"). The query also left joins various other table functions. These table
> functions do not perform any ordering.
[...]
>
> SELECT
> fA.c1 AS fA_c1, fA.c4 AS fA_c4, fA.c6 AS fA_c6, fA.c7 AS fA_c7, fA.c8 AS
> fA_c8,
> fB.c1 AS fB_c1, fB.c4 AS fB_c4,
> fC.c1 AS fC_c1, fC.c2 AS fC_c2,
> fD.c1 AS fD_c1, fD.c4 AS fD_c4,
> fE.c1 AS fE_c1, fE.c2 AS fE_c2,
> fF.c1 AS fF_c1, fF.c2 AS fF_c2,
> fG.c1 AS fG_c1, fG.c2 AS fG_c2, fG.c3 AS fG_c3, fG.c4 AS fG_c4,
> fH.c1 AS fH_c1, fH.c2 AS fH_c2, fH.c3 AS fH_c3, fH.c4 AS fH_c4, fH.c5 AS
> fH_c5, fH.c6 AS fH_c6
> FROM fA(1) AS fA
> LEFT OUTER JOIN fB(fA.c2) AS fB ON true
> LEFT OUTER JOIN fC(fB.c3) AS fC ON true
> LEFT OUTER JOIN fD(fB.c2) AS fD ON true
> LEFT OUTER JOIN fE(fD.c2) AS fE ON true
> LEFT OUTER JOIN fF(fD.c3) AS fF ON true
> LEFT OUTER JOIN fG(fA.c3) AS fG ON true
> LEFT OUTER JOIN fH(fA.c5) AS fH ON true
>
I suspect that you still need to use an 'ORDER BY' clause.

Cheers,
Gavin

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrew Gierth 2018-11-04 11:53:11 Re: BUG #15485: Order by of inlineable stable function incorrect
Previous Message PG Bug reporting form 2018-11-04 00:11:29 BUG #15485: Order by of inlineable stable function incorrect