Skip to content

Add a flag for table access method to force exclusive write #969

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/backend/executor/nodeModifyTable.c
Original file line number Diff line number Diff line change
Expand Up @@ -3186,6 +3186,11 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
{
resultRelInfo = &mtstate->resultRelInfo[i];

if (resultRelInfo->ri_RelationDesc->rd_tableam &&
(table_scan_flags(resultRelInfo->ri_RelationDesc) & SCAN_FORCE_BIG_WRITE_LOCK))
{
LockRelation(resultRelInfo->ri_RelationDesc, ExclusiveLock);
}
/* Let FDWs init themselves for foreign-table result rels */
if (!resultRelInfo->ri_usesFdwDirectModify &&
resultRelInfo->ri_FdwRoutine != NULL &&
Expand Down
3 changes: 3 additions & 0 deletions src/include/access/tableam.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ struct ValidateIndexState;
#define SCAN_SUPPORT_COLUMN_ORIENTED_SCAN (1 << 0) /* support column-oriented scanning*/
#define SCAN_SUPPORT_RUNTIME_FILTER (1 << 1) /* support runtime filter scan */

/* force to held big lock for write */
#define SCAN_FORCE_BIG_WRITE_LOCK (1 << 1)

/*
* Bitmask values for the flags argument to the scan_begin callback.
*/
Expand Down
Loading