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

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: BUG #15904: ERROR: argument of LIMIT must not contain variables
Дата
Msg-id CAKFQuwZXPCO22LE0G6QGrnzsMaUb6Byem62dxq+ASKBvGqZGew@mail.gmail.com
обсуждение исходный текст
Ответ на Re: BUG #15904: ERROR: argument of LIMIT must not contain variables  (Lakradi Marwan <lakradimarwan@gmail.com>)
Ответы Re: BUG #15904: ERROR: argument of LIMIT must not contain variables  (Lakradi Marwan <lakradimarwan@gmail.com>)
Список pgsql-bugs
On Thu, Jul 11, 2019 at 9:26 AM Lakradi Marwan <lakradimarwan@gmail.com> wrote:
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}

That's not an unreasonable expectation.  But that isn't how LIMIT is defined.  LIMIT provides a query result max record count to return to the client - mostly to facilitate pagination when used in concert with ORDER BY (for determinism) and OFFSET (to skip already seen records).  That max is a constant determined at plan time which means it cannot rely upon any of the data the query itself may generate.

SQL is set oriented and your expectation is incompatible with that fundamental property of the system.  If you don't want records "after" something you need to apply a inequality filter in the WHERE clause to remove the undesired records.

David J.

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Lakradi Marwan
Дата:
Сообщение: Re: BUG #15904: ERROR: argument of LIMIT must not contain variables
Следующее
От: Andrew Gierth
Дата:
Сообщение: Re: The result of the pattern matching is incorrect when the pattern string is bpchar type