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, PostgreSQL Global Development Group
6  *
7  *-------------------------------------------------------------------------
8  */
9 #ifndef CONFLICT_H
10 #define CONFLICT_H
11 
12 #include "nodes/execnodes.h"
13 #include "utils/timestamp.h"
14 
15 /*
16  * Conflict types that could occur while applying remote changes.
17  *
18  * This enum is used in statistics collection (see
19  * PgStat_StatSubEntry::conflict_count and
20  * PgStat_BackendSubEntry::conflict_count) as well, therefore, when adding new
21  * values or reordering existing ones, ensure to review and potentially adjust
22  * the corresponding statistics collection codes.
23  */
24 typedef enum
25 {
26  /* The row to be inserted violates unique constraint */
28 
29  /* The row to be updated was modified by a different origin */
31 
32  /* The updated row value violates unique constraint */
34 
35  /* The row to be updated is missing */
37 
38  /* The row to be deleted was modified by a different origin */
40 
41  /* The row to be deleted is missing */
43 
44  /*
45  * Other conflicts, such as exclusion constraint violations, involve more
46  * complex rules than simple equality checks. These conflicts are left for
47  * future improvements.
48  */
49 } ConflictType;
50 
51 #define CONFLICT_NUM_TYPES (CT_DELETE_MISSING + 1)
52 
53 extern bool GetTupleTransactionInfo(TupleTableSlot *localslot,
54  TransactionId *xmin,
55  RepOriginId *localorigin,
56  TimestampTz *localts);
57 extern void ReportApplyConflict(EState *estate, ResultRelInfo *relinfo,
58  int elevel, ConflictType type,
59  TupleTableSlot *searchslot,
60  TupleTableSlot *localslot,
61  TupleTableSlot *remoteslot,
62  Oid indexoid, TransactionId localxmin,
63  RepOriginId localorigin, TimestampTz localts);
64 extern void InitConflictIndexes(ResultRelInfo *relInfo);
65 
66 #endif
uint32 TransactionId
Definition: c.h:643
ConflictType
Definition: conflict.h:25
@ CT_DELETE_MISSING
Definition: conflict.h:42
@ CT_UPDATE_ORIGIN_DIFFERS
Definition: conflict.h:30
@ CT_INSERT_EXISTS
Definition: conflict.h:27
@ CT_UPDATE_EXISTS
Definition: conflict.h:33
@ CT_UPDATE_MISSING
Definition: conflict.h:36
@ CT_DELETE_ORIGIN_DIFFERS
Definition: conflict.h:39
void InitConflictIndexes(ResultRelInfo *relInfo)
Definition: conflict.c:136
void ReportApplyConflict(EState *estate, ResultRelInfo *relinfo, int elevel, ConflictType type, TupleTableSlot *searchslot, TupleTableSlot *localslot, TupleTableSlot *remoteslot, Oid indexoid, TransactionId localxmin, RepOriginId localorigin, TimestampTz localts)
Definition: conflict.c:107
bool GetTupleTransactionInfo(TupleTableSlot *localslot, TransactionId *xmin, RepOriginId *localorigin, TimestampTz *localts)
Definition: conflict.c:61
int64 TimestampTz
Definition: timestamp.h:39
unsigned int Oid
Definition: postgres_ext.h:31
const char * type
uint16 RepOriginId
Definition: xlogdefs.h:65