pgsql: Avoid getting more than AccessShareLock when deparsing a query.
От | Tom Lane |
---|---|
Тема | pgsql: Avoid getting more than AccessShareLock when deparsing a query. |
Дата | |
Msg-id | E1WLihd-0007Bb-1D@gemulon.postgresql.org обсуждение исходный текст |
Список | pgsql-committers |
Avoid getting more than AccessShareLock when deparsing a query. In make_ruledef and get_query_def, we have long used AcquireRewriteLocks to ensure that the querytree we are about to deparse is up-to-date and the schemas of the underlying relations aren't changing. Howwever, that function thinks the query is about to be executed, so it acquires locks that are stronger than necessary for the purpose of deparsing. Thus for example, if pg_dump asks to deparse a rule that includes "INSERT INTO t", we'd acquire RowExclusiveLock on t. That results in interference with concurrent transactions that might for example ask for ShareLock on t. Since pg_dump is documented as being purely read-only, this is unexpected. (Worse, it used to actually be read-only; this behavior dates back only to 8.1, cf commit ba4200246.) Fix this by adding a parameter to AcquireRewriteLocks to tell it whether we want the "real" execution locks or only AccessShareLock. Report, diagnosis, and patch by Dean Rasheed. Back-patch to all supported branches. Branch ------ REL9_1_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/f3e3f6c5ba061ca8228649a5b9c0faa3d0ff4121 Modified Files -------------- src/backend/rewrite/rewriteHandler.c | 68 ++++++++++++++++++++++++---------- src/backend/utils/adt/ruleutils.c | 7 +++- src/include/rewrite/rewriteHandler.h | 4 +- 3 files changed, 56 insertions(+), 23 deletions(-)
В списке pgsql-committers по дате отправления: