Allow non-btree speculative insertion indexes
[pgsql.git] / src / include / replication / syncrep.h
blob675669a79f7d3f34380f890c0cb0fd885219cb91
1 /*-------------------------------------------------------------------------
3 * syncrep.h
4 * Exports from replication/syncrep.c.
6 * Portions Copyright (c) 2010-2025, PostgreSQL Global Development Group
8 * IDENTIFICATION
9 * src/include/replication/syncrep.h
11 *-------------------------------------------------------------------------
13 #ifndef _SYNCREP_H
14 #define _SYNCREP_H
16 #include "access/xlogdefs.h"
18 #define SyncRepRequested() \
19 (max_wal_senders > 0 && synchronous_commit > SYNCHRONOUS_COMMIT_LOCAL_FLUSH)
21 /* SyncRepWaitMode */
22 #define SYNC_REP_NO_WAIT (-1)
23 #define SYNC_REP_WAIT_WRITE 0
24 #define SYNC_REP_WAIT_FLUSH 1
25 #define SYNC_REP_WAIT_APPLY 2
27 #define NUM_SYNC_REP_WAIT_MODE 3
29 /* syncRepState */
30 #define SYNC_REP_NOT_WAITING 0
31 #define SYNC_REP_WAITING 1
32 #define SYNC_REP_WAIT_COMPLETE 2
34 /* syncrep_method of SyncRepConfigData */
35 #define SYNC_REP_PRIORITY 0
36 #define SYNC_REP_QUORUM 1
39 * SyncRepGetCandidateStandbys returns an array of these structs,
40 * one per candidate synchronous walsender.
42 typedef struct SyncRepStandbyData
44 /* Copies of relevant fields from WalSnd shared-memory struct */
45 pid_t pid;
46 XLogRecPtr write;
47 XLogRecPtr flush;
48 XLogRecPtr apply;
49 int sync_standby_priority;
50 /* Index of this walsender in the WalSnd shared-memory array */
51 int walsnd_index;
52 /* This flag indicates whether this struct is about our own process */
53 bool is_me;
54 } SyncRepStandbyData;
57 * Struct for the configuration of synchronous replication.
59 * Note: this must be a flat representation that can be held in a single
60 * chunk of malloc'd memory, so that it can be stored as the "extra" data
61 * for the synchronous_standby_names GUC.
63 typedef struct SyncRepConfigData
65 int config_size; /* total size of this struct, in bytes */
66 int num_sync; /* number of sync standbys that we need to
67 * wait for */
68 uint8 syncrep_method; /* method to choose sync standbys */
69 int nmembers; /* number of members in the following list */
70 /* member_names contains nmembers consecutive nul-terminated C strings */
71 char member_names[FLEXIBLE_ARRAY_MEMBER];
72 } SyncRepConfigData;
74 extern PGDLLIMPORT SyncRepConfigData *SyncRepConfig;
76 /* user-settable parameters for synchronous replication */
77 extern PGDLLIMPORT char *SyncRepStandbyNames;
79 /* called by user backend */
80 extern void SyncRepWaitForLSN(XLogRecPtr lsn, bool commit);
82 /* called at backend exit */
83 extern void SyncRepCleanupAtProcExit(void);
85 /* called by wal sender */
86 extern void SyncRepInitConfig(void);
87 extern void SyncRepReleaseWaiters(void);
89 /* called by wal sender and user backend */
90 extern int SyncRepGetCandidateStandbys(SyncRepStandbyData **standbys);
92 /* called by checkpointer */
93 extern void SyncRepUpdateSyncStandbysDefined(void);
96 * Internal functions for parsing synchronous_standby_names grammar,
97 * in syncrep_gram.y and syncrep_scanner.l
99 union YYSTYPE;
100 #ifndef YY_TYPEDEF_YY_SCANNER_T
101 #define YY_TYPEDEF_YY_SCANNER_T
102 typedef void *yyscan_t;
103 #endif
104 extern int syncrep_yyparse(SyncRepConfigData **syncrep_parse_result_p, char **syncrep_parse_error_msg_p, yyscan_t yyscanner);
105 extern int syncrep_yylex(union YYSTYPE *yylval_param, char **syncrep_parse_error_msg_p, yyscan_t yyscanner);
106 extern void syncrep_yyerror(SyncRepConfigData **syncrep_parse_result_p, char **syncrep_parse_error_msg_p, yyscan_t yyscanner, const char *str);
107 extern void syncrep_scanner_init(const char *str, yyscan_t *yyscannerp);
108 extern void syncrep_scanner_finish(yyscan_t yyscanner);
110 #endif /* _SYNCREP_H */