pgsql: De-reserve most statement-introducing keywords in plpgsql.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: De-reserve most statement-introducing keywords in plpgsql.
Дата
Msg-id E1XtMJV-0001ms-1k@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
De-reserve most statement-introducing keywords in plpgsql.

Add a bit of context sensitivity to plpgsql_yylex() so that it can
recognize when the word it is looking at is the first word of a new
statement, and if so whether it is the target of an assignment statement.
When we are at start of statement and it's not an assignment, we can
prefer recognizing unreserved keywords over recognizing variable names,
thereby allowing most statements' initial keywords to be demoted from
reserved to unreserved status.  This is rather useful already (there are
15 such words that get demoted here), and what's more to the point is
that future patches proposing to add new plpgsql statements can avoid
objections about having to add new reserved words.

The keywords BEGIN, DECLARE, FOR, FOREACH, LOOP, WHILE need to remain
reserved because they can be preceded by block labels, and the logic
added here doesn't understand about block labels.  In principle we
could probably fix that, but it would take more than one token of
lookback and the benefit doesn't seem worth extra complexity.

Also note I didn't de-reserve EXECUTE, because it is used in more places
than just statement start.  It's possible it could be de-reserved with
more work, but that would be an independent fix.

In passing, also de-reserve COLLATE and DEFAULT, which shouldn't have
been reserved in the first place since they only need to be recognized
within DECLARE sections.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/bb1b8f694ad2efc35ebae2acfa2c18a2197b82a1

Modified Files
--------------
src/pl/plpgsql/src/pl_gram.y          |   16 ++++
src/pl/plpgsql/src/pl_scanner.c       |  144 ++++++++++++++++++++++++---------
src/test/regress/expected/plpgsql.out |   14 ++++
src/test/regress/sql/plpgsql.sql      |   11 +++
4 files changed, 147 insertions(+), 38 deletions(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Support arrays as input to array_agg() and ARRAY(SELECT ...).
Следующее
От: Simon Riggs
Дата:
Сообщение: pgsql: action_at_recovery_target recovery config option