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