Re: How to implement oracle like rownum(function or seudocolumn)

Поиск
Список
Период
Сортировка
От Jonah H. Harris
Тема Re: How to implement oracle like rownum(function or seudocolumn)
Дата
Msg-id 36e682920604081219q31adf9dct75b4c9fc65c3b3c1@mail.gmail.com
обсуждение исходный текст
Ответ на Re: How to implement oracle like rownum(function or seudocolumn)  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On 4/8/06, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> A function implemented as per Michael's example would not give the
> results that I think people would expect for
>
>         SELECT rownum(), * FROM foo ORDER BY whatever;
>

Yep, the query would have to be rewritten similar to Oracle's:

SELECT rownum(), * FROM (SELECT * FROM foo ORDER BY whatever);

IIRC, processing-wise, rownum and order-by processing is handled as follows:

SELECT id, whatever FROM foo WHERE rownum <= 10 ORDER BY id;

is the same as PostgreSQL's

SELECT id, whatever FROM (SELECT id, whatever FROM foo LIMIT 10) ORDER BY id;

--
Jonah H. Harris, Database Internals Architect
EnterpriseDB Corporation
732.331.1324


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: How to implement oracle like rownum(function or seudocolumn)
Следующее
От: Josh Berkus
Дата:
Сообщение: Summer of Code -- mentors needed as well