mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-15 21:30:23 +02:00
7c31874945
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.
35 lines
1.0 KiB
C
35 lines
1.0 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* rewriteHandler.h
|
|
* External interface to query rewriter.
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/rewrite/rewriteHandler.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef REWRITEHANDLER_H
|
|
#define REWRITEHANDLER_H
|
|
|
|
#include "utils/relcache.h"
|
|
#include "nodes/parsenodes.h"
|
|
|
|
extern List *QueryRewrite(Query *parsetree);
|
|
extern void AcquireRewriteLocks(Query *parsetree,
|
|
bool forExecute,
|
|
bool forUpdatePushedDown);
|
|
|
|
extern Node *build_column_default(Relation rel, int attrno);
|
|
extern Query *get_view_query(Relation view);
|
|
extern const char *view_query_is_auto_updatable(Query *viewquery,
|
|
bool security_barrier,
|
|
bool check_cols);
|
|
extern int relation_is_updatable(Oid reloid,
|
|
bool include_triggers,
|
|
Bitmapset *include_cols);
|
|
|
|
#endif /* REWRITEHANDLER_H */
|