Re: Behavior of negative OFFSET

Поиск
Список
Период
Сортировка
Искать
От
Robert James
Тема
Re: Behavior of negative OFFSET
Дата
Msg-id
CAGYyBggFn5JhC3XGfH411UTvSKdcHvCL+gf8KgL4ymv4-eYJ2w@mail.gmail.com
Ответ на
Список
Дерево обсуждения
Behavior of negative OFFSET Robert James <srobertjames@gmail.com>
Re: Behavior of negative OFFSET Merlin Moncure <mmoncure@gmail.com>
Re: Behavior of negative OFFSET Robert James <srobertjames@gmail.com>
Re: Behavior of negative OFFSET Tom Lane <tgl@sss.pgh.pa.us>
On 11/7/11, Merlin Moncure  wrote:
> On Mon, Nov 7, 2011 at 3:47 PM, Robert James  wrote:
>> I've been using a query on Postgres 8.4 with a negative OFFSET, which
>> works fine:
>>
>>   SELECT DISTINCT s.* FROM s WHERE ... ORDER BY s.bday ASC, s.name
>> ASC LIMIT 15 OFFSET -15
>>
>
> the original behavior was undefined.

What do it do in reality? I'm debugging a legacy app which used it.

> to kinda sorta get it,
> create function oldoffset(int) returns int as
> $$
>   select case when $1 < 0 then 0 else $1 end;
> $$ language sql immutable;
>
> select v from generate_series(1,15) v limit 15 offset oldoffset(-15);
>

That sounds like if OFFSET was negative, it would be simply ignored.
Is that correct? When was the behavior of OFFSET changed?

Also: Is there any reference in the docs to this? I wasn't able to find this.
В списке pgsql-general по дате отправления
От: Scott Marlowe
Дата:
Сообщение: Re: Www emulator
От: Adrian Klaver
Дата:
FAQ