Re: BUG #15904: ERROR: argument of LIMIT must not contain variables

From: Lakradi Marwan <lakradimarwan(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #15904: ERROR: argument of LIMIT must not contain variables
Date: 2019-07-11 16:26:41
Message-ID: CAF5OE-y3b0YEQW0tUiSmySCvwMdw0_7e3ayzwHr8CMsCk=Nwrw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Thank you for your quick feedback,

In my opinion, your query should return :
Id, Text
1| 1, 'one'

and be interpreted as due to variable type :
LIMIT CASE WHEN 1 = 1 THEN 1 ELSE 2 END;

Am I wrong in the way I see the situation ?

I think that in the case of a variable, the data should be retrieved until
the condition is reached. Like LIMIT_TILL {condition}

Marwan L.

Le jeu. 11 juil. 2019 à 17:27, David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
a écrit :

> On Thu, Jul 11, 2019 at 8:06 AM PG Bug reporting form <
> noreply(at)postgresql(dot)org> wrote:
>
>> The following bug has been logged on the website:
>>
>> Bug reference: 15904
>> Logged by: Lakradi Marwan
>> Email address: lakradimarwan(at)gmail(dot)com
>> PostgreSQL version: 11.4
>> Operating system: Mac OS X - High Sierra
>> Description:
>>
>
>
>> I don't see the point, what is the main difference between
>> summary.amount_summed which is a float, and directly pass 100.0 ?
>>
>
> A limit applies to the query as a whole and cannot depend on individual
> records. If you think that is wrong explain what the following query is
> supposed to return and why.
>
> SELECT *
> FROM (VALUES (1, 'one'), (2, 'two')) vals (i, t)
> LIMIT CASE WHEN vals.i = 1 THEN 1 ELSE 2 END;
>
> David J.
>
>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2019-07-11 16:45:42 Re: BUG #15904: ERROR: argument of LIMIT must not contain variables
Previous Message David G. Johnston 2019-07-11 15:27:44 Re: BUG #15904: ERROR: argument of LIMIT must not contain variables