Re: FETCH FIRST clause WITH TIES option

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: FETCH FIRST clause WITH TIES option
Дата
Msg-id 20191125203442.GA30191@alvherre.pgsql
обсуждение исходный текст
Ответ на Re: FETCH FIRST clause WITH TIES option  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Ответы Re: FETCH FIRST clause WITH TIES option  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Список pgsql-hackers
On 2019-Nov-11, Alvaro Herrera wrote:

> I'm not sure the proposed changes to gram.y are all that great, though.

Here's a proposed simplification of the gram.y changes.  There are two
things here:

1. cosmetic: we don't need the LimitClause struct; we can use just
   SelectLimit, and return that from limit_clause; that can be
   complemented using the offset_clause if there's any at select_limit
   level.

2. there's a gratuituous palloc() in opt_select_limit when there's no
   clause, that seems to be there just so that NULLs can be returned.
   That's one extra palloc for SELECTs parsed using one the affected
   productions ... it's not every single select, but it seems bad enough
   it's worth fixing.

I fixed #2 by just checking whether the return from opt_select_limit is
NULL.  ISTM it'd be better to pass the SelectLimit pointer to
insertSelectOptions instead (which is a static function in gram.y anyway
so there's no difficulty there).

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Вложения

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

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: GROUPING SETS and SQL standard
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: FETCH FIRST clause WITH TIES option