Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options

Поиск
Список
Период
Сортировка
Искать
От
Andrew Gierth
Тема
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options
Дата
Msg-id
87o9cnhjwh.fsf@news-spur.riddles.org.uk
Ответ на
Список
Дерево обсуждения
Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Oliver Ford <ojford@gmail.com>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options David Fetter <david@fetter.org>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Krasiyan Andreev <krasiyan@gmail.com>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Andrew Gierth <andrew@tao11.riddles.org.uk>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Tom Lane <tgl@sss.pgh.pa.us>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Andrew Gierth <andrew@tao11.riddles.org.uk>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Tom Lane <tgl@sss.pgh.pa.us>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Andrew Gierth <andrew@tao11.riddles.org.uk>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Stephen Frost <sfrost@snowman.net>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Krasiyan Andreev <krasiyan@gmail.com>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Tom Lane <tgl@sss.pgh.pa.us>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Tatsuo Ishii <ishii@sraoss.co.jp>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Oliver Ford <ojford@gmail.com>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Vik Fearing <vik@postgresfriends.org>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Tatsuo Ishii <ishii@sraoss.co.jp>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Tom Lane <tgl@sss.pgh.pa.us>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Tatsuo Ishii <ishii@sraoss.co.jp>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Oliver Ford <ojford@gmail.com>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Tatsuo Ishii <ishii@sraoss.co.jp>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Tatsuo Ishii <ishii@sraoss.co.jp>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Oliver Ford <ojford@gmail.com>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Tatsuo Ishii <ishii@sraoss.co.jp>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Andrew Gierth <andrew@tao11.riddles.org.uk>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Andrew Gierth <andrew@tao11.riddles.org.uk>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Tom Lane <tgl@sss.pgh.pa.us>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Andrew Gierth <andrew@tao11.riddles.org.uk>
Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options Andrew Gierth <andrew@tao11.riddles.org.uk>
>>>>> "Tom" == Tom Lane  writes:

 Tom> If you just think of recognizing FROM FIRST/LAST, you get nowhere
 Tom> because that's still legal in other contexts. But if you were to
 Tom> look for FROM followed by FIRST/LAST followed by
 Tom> IGNORE/RESPECT/OVER, I think that could only validly happen in
 Tom> this syntax.

No; you need to go four tokens ahead in total, not three. Assuming
nth_value is unreserved, then

  select nth_value(x) from first ignore;

is a valid query that has nth_value(x) as an expression, "first" as a
table name and "ignore" as its alias. Only when you see NULLS after
IGNORE, or OVER after FIRST/LAST, do you know that you're looking at
a window function and not a from clause.

So FROM_LA would have to mean "FROM" followed by any of:

  FIRST IGNORE NULLS
  LAST IGNORE NULLS
  FIRST RESPECT NULLS
  LAST RESPECT NULLS
  FIRST OVER
  LAST OVER

Remember that while OVER is reserved, all of FIRST, LAST, RESPECT and
IGNORE are unreserved.

 Tom> It'd take some work to extend base_yylex to look ahead 2 tokens
 Tom> not one, but I'm sure that could be done. (You'd also need a
 Tom> lookahead rule to match "IGNORE/RESPECT NULLS OVER", but that
 Tom> seems just as doable.) Then the relevant productions use FROM_LA,
 Tom> IGNORE_LA, RESPECT_LA instead of the corresponding bare tokens,
 Tom> and the grammar no longer has an ambiguity problem.

Yeah, but at the cost of having to extend base_yylex to go 3 tokens
ahead (not 2) rather than the current single lookahead slot.

Doable, certainly (probably not much harder to do 3 than 2 actually)

-- 
Andrew (irc:RhodiumToad)

В списке pgsql-hackers по дате отправления
От: Michael Paquier
Дата:
От: Michael Paquier
Дата:
FAQ