Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
syncrep.h110 linesDownload Raw Back to replication
1/*-------------------------------------------------------------------------2 *3 * syncrep.h4 *	  Exports from replication/syncrep.c.5 *6 * Portions Copyright (c) 2010-2023, PostgreSQL Global Development Group7 *8 * IDENTIFICATION9 *		src/include/replication/syncrep.h10 *11 *-------------------------------------------------------------------------12 */13#ifndef _SYNCREP_H14#define _SYNCREP_H15 16#include "access/xlogdefs.h"17 18#define SyncRepRequested() \19	(max_wal_senders > 0 && synchronous_commit > SYNCHRONOUS_COMMIT_LOCAL_FLUSH)20 21/* SyncRepWaitMode */22#define SYNC_REP_NO_WAIT		(-1)23#define SYNC_REP_WAIT_WRITE		024#define SYNC_REP_WAIT_FLUSH		125#define SYNC_REP_WAIT_APPLY		226 27#define NUM_SYNC_REP_WAIT_MODE	328 29/* syncRepState */30#define SYNC_REP_NOT_WAITING		031#define SYNC_REP_WAITING			132#define SYNC_REP_WAIT_COMPLETE		233 34/* syncrep_method of SyncRepConfigData */35#define SYNC_REP_PRIORITY		036#define SYNC_REP_QUORUM		137 38/*39 * SyncRepGetCandidateStandbys returns an array of these structs,40 * one per candidate synchronous walsender.41 */42typedef struct SyncRepStandbyData43{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;55 56/*57 * Struct for the configuration of synchronous replication.58 *59 * Note: this must be a flat representation that can be held in a single60 * chunk of malloc'd memory, so that it can be stored as the "extra" data61 * for the synchronous_standby_names GUC.62 */63typedef struct SyncRepConfigData64{65	int			config_size;	/* total size of this struct, in bytes */66	int			num_sync;		/* number of sync standbys that we need to67								 * 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;73 74extern PGDLLIMPORT SyncRepConfigData *SyncRepConfig;75 76/* communication variables for parsing synchronous_standby_names GUC */77extern PGDLLIMPORT SyncRepConfigData *syncrep_parse_result;78extern PGDLLIMPORT char *syncrep_parse_error_msg;79 80/* user-settable parameters for synchronous replication */81extern PGDLLIMPORT char *SyncRepStandbyNames;82 83/* called by user backend */84extern void SyncRepWaitForLSN(XLogRecPtr lsn, bool commit);85 86/* called at backend exit */87extern void SyncRepCleanupAtProcExit(void);88 89/* called by wal sender */90extern void SyncRepInitConfig(void);91extern void SyncRepReleaseWaiters(void);92 93/* called by wal sender and user backend */94extern int	SyncRepGetCandidateStandbys(SyncRepStandbyData **standbys);95 96/* called by checkpointer */97extern void SyncRepUpdateSyncStandbysDefined(void);98 99/*100 * Internal functions for parsing synchronous_standby_names grammar,101 * in syncrep_gram.y and syncrep_scanner.l102 */103extern int	syncrep_yyparse(void);104extern int	syncrep_yylex(void);105extern void syncrep_yyerror(const char *str);106extern void syncrep_scanner_init(const char *str);107extern void syncrep_scanner_finish(void);108 109#endif							/* _SYNCREP_H */110 
codekingpro/portable-devtools · Team Ai