pgsql: Make FOR UPDATE/SHARE in the primary query not propagate into

Поиск
Список
Период
Сортировка
От tgl@postgresql.org (Tom Lane)
Тема pgsql: Make FOR UPDATE/SHARE in the primary query not propagate into
Дата
Msg-id 20091027171130.7A70A753FB7@cvs.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Log Message:
-----------
Make FOR UPDATE/SHARE in the primary query not propagate into WITH queries;
for example in
  WITH w AS (SELECT * FROM foo) SELECT * FROM w, bar ... FOR UPDATE
the FOR UPDATE will now affect bar but not foo.  This is more useful and
consistent than the original 8.4 behavior, which tried to propagate FOR UPDATE
into the WITH query but always failed due to assorted implementation
restrictions.  Even though we are in process of removing those restrictions,
it seems correct on philosophical grounds to not let the outer query's
FOR UPDATE affect the WITH query.

In passing, fix isLockedRel which frequently got things wrong in
nested-subquery cases: "FOR UPDATE OF foo" applies to an alias foo in the
current query level, not subqueries.  This has been broken for a long time,
but it doesn't seem worth back-patching further than 8.4 because the actual
consequences are minimal.  At worst the parser would sometimes get
RowShareLock on a relation when it should be AccessShareLock or vice versa.
That would only make a difference if someone were using ExclusiveLock
concurrently, which no standard operation does, and anyway FOR UPDATE
doesn't result in visible changes so it's not clear that the someone would
notice any problem.  Between that and the fact that FOR UPDATE barely works
with subqueries at all in existing releases, I'm not excited about worrying
about it.

Tags:
----
REL8_4_STABLE

Modified Files:
--------------
    pgsql/doc/src/sgml/ref:
        select.sgml (r1.122.2.1 -> r1.122.2.2)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/ref/select.sgml?r1=1.122.2.1&r2=1.122.2.2)
    pgsql/src/backend/parser:
        analyze.c (r1.389.2.2 -> r1.389.2.3)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/analyze.c?r1=1.389.2.2&r2=1.389.2.3)
        parse_clause.c (r1.189.2.2 -> r1.189.2.3)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/parse_clause.c?r1=1.189.2.2&r2=1.189.2.3)
        parse_cte.c (r2.6.2.1 -> r2.6.2.2)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/parse_cte.c?r1=2.6.2.1&r2=2.6.2.2)
        parse_expr.c (r1.241.2.1 -> r1.241.2.2)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/parse_expr.c?r1=1.241.2.1&r2=1.241.2.2)
        parse_relation.c (r1.142 -> r1.142.2.1)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/parse_relation.c?r1=1.142&r2=1.142.2.1)
    pgsql/src/backend/rewrite:
        rewriteHandler.c (r1.186.2.1 -> r1.186.2.2)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/rewrite/rewriteHandler.c?r1=1.186.2.1&r2=1.186.2.2)
    pgsql/src/include/parser:
        analyze.h (r1.40.2.1 -> r1.40.2.2)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/parser/analyze.h?r1=1.40.2.1&r2=1.40.2.2)
        parse_node.h (r1.62.2.1 -> r1.62.2.2)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/parser/parse_node.h?r1=1.62.2.1&r2=1.62.2.2)
        parse_relation.h (r1.64 -> r1.64.2.1)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/parser/parse_relation.h?r1=1.64&r2=1.64.2.1)

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

Предыдущее
От: tgl@postgresql.org (Tom Lane)
Дата:
Сообщение: pgsql: Make FOR UPDATE/SHARE in the primary query not propagate into
Следующее
От: tgl@postgresql.org (Tom Lane)
Дата:
Сообщение: pgsql: Fix AfterTriggerSaveEvent to use a test and elog, not just