pgsql: Change plpgsql from using textual substitution to insert variable

Поиск
Список
Период
Сортировка
От tgl@postgresql.org (Tom Lane)
Тема pgsql: Change plpgsql from using textual substitution to insert variable
Дата
Msg-id 20091106183755.15006753FB7@cvs.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Log Message:
-----------
Change plpgsql from using textual substitution to insert variable references
into SQL expressions, to using the newly added parser callback hooks.

This allows us to do the substitutions in a more semantically-aware way:
a variable reference will only be recognized where it can validly go,
ie, a place where a column value or parameter would be legal, instead of
the former behavior that would replace any textual match including
table names and column aliases (leading to syntax errors later on).
A release-note-worthy fine point is that plpgsql variable names that match
fully-reserved words will now need to be quoted.

This commit preserves the former behavior that variable references take
precedence over any possible match to a column name.  The infrastructure
is in place to support the reverse precedence or throwing an error on
ambiguity, but those behaviors aren't accessible yet.

Most of the code changes here are associated with making the namespace
data structure persist so that it can be consulted at runtime, instead
of throwing it away at the end of initial function parsing.

The plpgsql scanner is still doing name lookups, but that behavior is
now irrelevant for SQL expressions.  A future commit will deal with
removing unnecessary lookups.

Modified Files:
--------------
    pgsql/src/pl/plpgsql/src:
        gram.y (r1.130 -> r1.131)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/pl/plpgsql/src/gram.y?r1=1.130&r2=1.131)
        pl_comp.c (r1.140 -> r1.141)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/pl/plpgsql/src/pl_comp.c?r1=1.140&r2=1.141)
        pl_exec.c (r1.249 -> r1.250)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/pl/plpgsql/src/pl_exec.c?r1=1.249&r2=1.250)
        pl_funcs.c (r1.83 -> r1.84)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/pl/plpgsql/src/pl_funcs.c?r1=1.83&r2=1.84)
        plpgsql.h (r1.119 -> r1.120)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/pl/plpgsql/src/plpgsql.h?r1=1.119&r2=1.120)
    pgsql/src/test/regress/expected:
        plpgsql.out (r1.77 -> r1.78)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/plpgsql.out?r1=1.77&r2=1.78)
    pgsql/src/test/regress/sql:
        plpgsql.sql (r1.65 -> r1.66)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/sql/plpgsql.sql?r1=1.65&r2=1.66)

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

Предыдущее
От: tgl@postgresql.org (Tom Lane)
Дата:
Сообщение: pgsql: Don't treat NEW and OLD as reserved words anymore.
Следующее
От: adunstan@postgresql.org (Andrew Dunstan)
Дата:
Сообщение: pgsql: Keep track of language's trusted flag in InlineCodeBlock.