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

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: lakradimarwan(at)gmail(dot)com
Subject: BUG #15904: ERROR: argument of LIMIT must not contain variables
Date: 2019-07-11 15:05:29
Message-ID: 15904-462bf7dbd5e7d11d@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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:

Good afternoon,

I would like to be able to conditionally limit my query (without python
script) based on a column value (for dynamic limit)

See example below:

SELECT summary.*
FROM
(
SELECT
id,
amount, date,
SUM(amount) OVER (PARTITION BY customer ORDER BY date, id) as
amount_summed
FROM
customer
ORDER BY date DESC, id DESC
) AS summary
LIMIT CASE WHEN summary.amount_summed >= 0 THEN summary.id ELSE NULL END;

The limit doesn't work, whereas :
- LIMIT CASE WHEN 100.0 >= 0 THEN 10 ELSE NULL END;
works well !

I don't see the point, what is the main difference between
summary.amount_summed which is a float, and directly pass 100.0 ?

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2019-07-11 15:27:44 Re: BUG #15904: ERROR: argument of LIMIT must not contain variables
Previous Message David G. Johnston 2019-07-11 14:36:08 Re: The result of the pattern matching is incorrect when the pattern string is bpchar type