Thanks to visit codestin.com
Credit goes to doxygen.postgresql.org
PostgreSQL Source Code
git master
conflict.h
Go to the documentation of this file.
1
/*-------------------------------------------------------------------------
2
* conflict.h
3
* Exports for conflicts logging.
4
*
5
* Copyright (c) 2024-2025, 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 */
17
typedef
struct
EState
EState
;
18
typedef
struct
ResultRelInfo
ResultRelInfo
;
19
typedef
struct
TupleTableSlot
TupleTableSlot
;
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
*/
31
typedef
enum
32
{
33
/* The row to be inserted violates unique constraint */
34
CT_INSERT_EXISTS
,
35
36
/* The row to be updated was modified by a different origin */
37
CT_UPDATE_ORIGIN_DIFFERS
,
38
39
/* The updated row value violates unique constraint */
40
CT_UPDATE_EXISTS
,
41
42
/* The row to be updated was concurrently deleted by a different origin */
43
CT_UPDATE_DELETED
,
44
45
/* The row to be updated is missing */
46
CT_UPDATE_MISSING
,
47
48
/* The row to be deleted was modified by a different origin */
49
CT_DELETE_ORIGIN_DIFFERS
,
50
51
/* The row to be deleted is missing */
52
CT_DELETE_MISSING
,
53
54
/* The row to be inserted/updated violates multiple unique constraint */
55
CT_MULTIPLE_UNIQUE_CONFLICTS
,
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
*/
62
}
ConflictType
;
63
64
#define CONFLICT_NUM_TYPES (CT_MULTIPLE_UNIQUE_CONFLICTS + 1)
65
66
/*
67
* Information for the existing local row that caused the conflict.
68
*/
69
typedef
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 */
80
}
ConflictTupleInfo
;
81
82
extern
bool
GetTupleTransactionInfo
(
TupleTableSlot
*localslot,
83
TransactionId
*xmin,
84
RepOriginId
*localorigin,
85
TimestampTz
*localts);
86
extern
void
ReportApplyConflict
(
EState
*estate,
ResultRelInfo
*relinfo,
87
int
elevel,
ConflictType
type
,
88
TupleTableSlot
*searchslot,
89
TupleTableSlot
*remoteslot,
90
List
*conflicttuples);
91
extern
void
InitConflictIndexes
(
ResultRelInfo
*relInfo);
92
#endif
TransactionId
uint32 TransactionId
Definition:
c.h:658
ConflictType
ConflictType
Definition:
conflict.h:32
CT_UPDATE_DELETED
@ CT_UPDATE_DELETED
Definition:
conflict.h:43
CT_MULTIPLE_UNIQUE_CONFLICTS
@ CT_MULTIPLE_UNIQUE_CONFLICTS
Definition:
conflict.h:55
CT_DELETE_MISSING
@ CT_DELETE_MISSING
Definition:
conflict.h:52
CT_UPDATE_ORIGIN_DIFFERS
@ CT_UPDATE_ORIGIN_DIFFERS
Definition:
conflict.h:37
CT_INSERT_EXISTS
@ CT_INSERT_EXISTS
Definition:
conflict.h:34
CT_UPDATE_EXISTS
@ CT_UPDATE_EXISTS
Definition:
conflict.h:40
CT_UPDATE_MISSING
@ CT_UPDATE_MISSING
Definition:
conflict.h:46
CT_DELETE_ORIGIN_DIFFERS
@ CT_DELETE_ORIGIN_DIFFERS
Definition:
conflict.h:49
ConflictTupleInfo
struct ConflictTupleInfo ConflictTupleInfo
ReportApplyConflict
void ReportApplyConflict(EState *estate, ResultRelInfo *relinfo, int elevel, ConflictType type, TupleTableSlot *searchslot, TupleTableSlot *remoteslot, List *conflicttuples)
Definition:
conflict.c:104
InitConflictIndexes
void InitConflictIndexes(ResultRelInfo *relInfo)
Definition:
conflict.c:139
GetTupleTransactionInfo
bool GetTupleTransactionInfo(TupleTableSlot *localslot, TransactionId *xmin, RepOriginId *localorigin, TimestampTz *localts)
Definition:
conflict.c:63
TimestampTz
int64 TimestampTz
Definition:
timestamp.h:39
pg_list.h
Oid
unsigned int Oid
Definition:
postgres_ext.h:32
ConflictTupleInfo
Definition:
conflict.h:70
ConflictTupleInfo::ts
TimestampTz ts
Definition:
conflict.h:78
ConflictTupleInfo::indexoid
Oid indexoid
Definition:
conflict.h:73
ConflictTupleInfo::origin
RepOriginId origin
Definition:
conflict.h:77
ConflictTupleInfo::xmin
TransactionId xmin
Definition:
conflict.h:75
ConflictTupleInfo::slot
TupleTableSlot * slot
Definition:
conflict.h:71
EState
Definition:
execnodes.h:655
List
Definition:
pg_list.h:54
ResultRelInfo
Definition:
execnodes.h:473
TupleTableSlot
Definition:
tuptable.h:115
timestamp.h
type
const char * type
Definition:
wait_event_funcs.c:27
xlogdefs.h
RepOriginId
uint16 RepOriginId
Definition:
xlogdefs.h:68
src
include
replication
conflict.h
Generated on Sun Sep 28 2025 00:13:17 for PostgreSQL Source Code by
1.9.4