PostgreSQL Source Code git master
Loading...
Searching...
No Matches
conflict.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 * conflict.h
3 * Exports for conflicts logging.
4 *
5 * Copyright (c) 2024-2026, PostgreSQL Global Development Group
6 *
7 *-------------------------------------------------------------------------
8 */
9#ifndef CONFLICT_H
10#define CONFLICT_H
11
12#include "access/xlogdefs.h"
13#include "nodes/pg_list.h"
14#include "utils/timestamp.h"
15
16/* Avoid including execnodes.h here */
17typedef struct EState EState;
20
21
22/*
23 * Conflict types that could occur while applying remote changes.
24 *
25 * This enum is used in statistics collection (see
26 * PgStat_StatSubEntry::conflict_count and
27 * PgStat_BackendSubEntry::conflict_count) as well, therefore, when adding new
28 * values or reordering existing ones, ensure to review and potentially adjust
29 * the corresponding statistics collection codes.
30 */
31typedef enum
32{
33 /* The row to be inserted violates unique constraint */
35
36 /* The row to be updated was modified by a different origin */
38
39 /* The updated row value violates unique constraint */
41
42 /* The row to be updated was concurrently deleted by a different origin */
44
45 /* The row to be updated is missing */
47
48 /* The row to be deleted was modified by a different origin */
50
51 /* The row to be deleted is missing */
53
54 /* The row to be inserted/updated violates multiple unique constraint */
56
57 /*
58 * Other conflicts, such as exclusion constraint violations, involve more
59 * complex rules than simple equality checks. These conflicts are left for
60 * future improvements.
61 */
63
64#define CONFLICT_NUM_TYPES (CT_MULTIPLE_UNIQUE_CONFLICTS + 1)
65
66/*
67 * Information for the local row that caused the conflict.
68 */
69typedef struct ConflictTupleInfo
70{
71 TupleTableSlot *slot; /* tuple slot holding the conflicting local
72 * tuple */
73 Oid indexoid; /* OID of the index where the conflict
74 * occurred */
75 TransactionId xmin; /* transaction ID of the modification causing
76 * the conflict */
77 RepOriginId origin; /* origin identifier of the modification */
78 TimestampTz ts; /* timestamp of when the modification on the
79 * conflicting local row occurred */
81
83 TransactionId *xmin,
87 int elevel, ConflictType type,
92#endif
uint32 TransactionId
Definition c.h:666
ConflictType
Definition conflict.h:32
@ CT_UPDATE_DELETED
Definition conflict.h:43
@ CT_MULTIPLE_UNIQUE_CONFLICTS
Definition conflict.h:55
@ CT_DELETE_MISSING
Definition conflict.h:52
@ CT_UPDATE_ORIGIN_DIFFERS
Definition conflict.h:37
@ CT_INSERT_EXISTS
Definition conflict.h:34
@ CT_UPDATE_EXISTS
Definition conflict.h:40
@ CT_UPDATE_MISSING
Definition conflict.h:46
@ CT_DELETE_ORIGIN_DIFFERS
Definition conflict.h:49
void ReportApplyConflict(EState *estate, ResultRelInfo *relinfo, int elevel, ConflictType type, TupleTableSlot *searchslot, TupleTableSlot *remoteslot, List *conflicttuples)
Definition conflict.c:104
void InitConflictIndexes(ResultRelInfo *relInfo)
Definition conflict.c:139
bool GetTupleTransactionInfo(TupleTableSlot *localslot, TransactionId *xmin, RepOriginId *localorigin, TimestampTz *localts)
Definition conflict.c:63
int64 TimestampTz
Definition timestamp.h:39
unsigned int Oid
static int fb(int x)
TimestampTz ts
Definition conflict.h:78
RepOriginId origin
Definition conflict.h:77
TransactionId xmin
Definition conflict.h:75
TupleTableSlot * slot
Definition conflict.h:71
Definition pg_list.h:54
const char * type
uint16 RepOriginId
Definition xlogdefs.h:69