Skip to content

Commit 86822df

Browse files
committed
Split walsender.h in public/private headers
This dramatically cuts short the number of headers the public one brings into whatever includes it.
1 parent 6693c9a commit 86822df

File tree

6 files changed

+115
-91
lines changed

6 files changed

+115
-91
lines changed

src/backend/replication/basebackup.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "nodes/pg_list.h"
2626
#include "replication/basebackup.h"
2727
#include "replication/walsender.h"
28+
#include "replication/walsender_private.h"
2829
#include "storage/fd.h"
2930
#include "storage/ipc.h"
3031
#include "utils/builtins.h"

src/backend/replication/repl_gram.y

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "nodes/makefuncs.h"
2020
#include "nodes/replnodes.h"
2121
#include "replication/walsender.h"
22+
#include "replication/walsender_private.h"
2223

2324

2425
/* Result of the parsing is returned here */

src/backend/replication/syncrep.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include "miscadmin.h"
5050
#include "replication/syncrep.h"
5151
#include "replication/walsender.h"
52+
#include "replication/walsender_private.h"
5253
#include "storage/pmsignal.h"
5354
#include "storage/proc.h"
5455
#include "tcop/tcopprot.h"

src/backend/replication/walsender.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include "replication/walprotocol.h"
5252
#include "replication/walreceiver.h"
5353
#include "replication/walsender.h"
54+
#include "replication/walsender_private.h"
5455
#include "storage/fd.h"
5556
#include "storage/ipc.h"
5657
#include "storage/pmsignal.h"

src/include/replication/walsender.h

Lines changed: 2 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -12,84 +12,9 @@
1212
#ifndef _WALSENDER_H
1313
#define _WALSENDER_H
1414

15-
#include "access/xlog.h"
16-
#include "fmgr.h"
17-
#include "nodes/nodes.h"
18-
#include "storage/latch.h"
19-
#include "storage/shmem.h"
20-
#include "storage/spin.h"
21-
22-
typedef enum WalSndState
23-
{
24-
WALSNDSTATE_STARTUP = 0,
25-
WALSNDSTATE_BACKUP,
26-
WALSNDSTATE_CATCHUP,
27-
WALSNDSTATE_STREAMING
28-
} WalSndState;
29-
30-
/*
31-
* Each walsender has a WalSnd struct in shared memory.
32-
*/
33-
typedef struct WalSnd
34-
{
35-
pid_t pid; /* this walsender's process id, or 0 */
36-
WalSndState state; /* this walsender's state */
37-
XLogRecPtr sentPtr; /* WAL has been sent up to this point */
38-
bool needreload; /* does currently-open file need to be reloaded? */
39-
40-
/*
41-
* The xlog locations that have been written, flushed, and applied by
42-
* standby-side. These may be invalid if the standby-side has not offered
43-
* values yet.
44-
*/
45-
XLogRecPtr write;
46-
XLogRecPtr flush;
47-
XLogRecPtr apply;
48-
49-
/* Protects shared variables shown above. */
50-
slock_t mutex;
51-
52-
/*
53-
* Latch used by backends to wake up this walsender when it has work to
54-
* do.
55-
*/
56-
Latch latch;
57-
58-
/*
59-
* The priority order of the standby managed by this WALSender, as listed
60-
* in synchronous_standby_names, or 0 if not-listed. Protected by
61-
* SyncRepLock.
62-
*/
63-
int sync_standby_priority;
64-
} WalSnd;
65-
66-
extern WalSnd *MyWalSnd;
15+
#include <signal.h>
6716

68-
/* There is one WalSndCtl struct for the whole database cluster */
69-
typedef struct
70-
{
71-
/*
72-
* Synchronous replication queue. Protected by SyncRepLock.
73-
*/
74-
SHM_QUEUE SyncRepQueue;
75-
76-
/*
77-
* Current location of the head of the queue. All waiters should have a
78-
* waitLSN that follows this value. Protected by SyncRepLock.
79-
*/
80-
XLogRecPtr lsn;
81-
82-
/*
83-
* Are any sync standbys defined? Waiting backends can't reload the
84-
* config file safely, so WAL writer updates this value as needed.
85-
* Protected by SyncRepLock.
86-
*/
87-
bool sync_standbys_defined;
88-
89-
WalSnd walsnds[1]; /* VARIABLE LENGTH ARRAY */
90-
} WalSndCtlData;
91-
92-
extern WalSndCtlData *WalSndCtl;
17+
#include "fmgr.h"
9318

9419
/* global state */
9520
extern bool am_walsender;
@@ -106,22 +31,8 @@ extern void WalSndSignals(void);
10631
extern Size WalSndShmemSize(void);
10732
extern void WalSndShmemInit(void);
10833
extern void WalSndWakeup(void);
109-
extern void WalSndSetState(WalSndState state);
110-
extern void XLogRead(char *buf, XLogRecPtr startptr, Size count);
11134
extern void WalSndRqstFileReload(void);
11235

11336
extern Datum pg_stat_get_wal_senders(PG_FUNCTION_ARGS);
11437

115-
/*
116-
* Internal functions for parsing the replication grammar, in repl_gram.y and
117-
* repl_scanner.l
118-
*/
119-
extern int replication_yyparse(void);
120-
extern int replication_yylex(void);
121-
extern void replication_yyerror(const char *str);
122-
extern void replication_scanner_init(const char *query_string);
123-
extern void replication_scanner_finish(void);
124-
125-
extern Node *replication_parse_result;
126-
12738
#endif /* _WALSENDER_H */
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* walsender_private.h
4+
* Private definitions from replication/walsender.c.
5+
*
6+
* Portions Copyright (c) 2010-2011, PostgreSQL Global Development Group
7+
*
8+
* src/include/replication/walsender_private.h
9+
*
10+
*-------------------------------------------------------------------------
11+
*/
12+
#ifndef _WALSENDER_PRIVATE_H
13+
#define _WALSENDER_PRIVATE_H
14+
15+
#include "access/xlog.h"
16+
#include "nodes/nodes.h"
17+
#include "storage/latch.h"
18+
#include "storage/shmem.h"
19+
#include "storage/spin.h"
20+
21+
typedef enum WalSndState
22+
{
23+
WALSNDSTATE_STARTUP = 0,
24+
WALSNDSTATE_BACKUP,
25+
WALSNDSTATE_CATCHUP,
26+
WALSNDSTATE_STREAMING
27+
} WalSndState;
28+
29+
/*
30+
* Each walsender has a WalSnd struct in shared memory.
31+
*/
32+
typedef struct WalSnd
33+
{
34+
pid_t pid; /* this walsender's process id, or 0 */
35+
WalSndState state; /* this walsender's state */
36+
XLogRecPtr sentPtr; /* WAL has been sent up to this point */
37+
bool needreload; /* does currently-open file need to be reloaded? */
38+
39+
/*
40+
* The xlog locations that have been written, flushed, and applied by
41+
* standby-side. These may be invalid if the standby-side has not offered
42+
* values yet.
43+
*/
44+
XLogRecPtr write;
45+
XLogRecPtr flush;
46+
XLogRecPtr apply;
47+
48+
/* Protects shared variables shown above. */
49+
slock_t mutex;
50+
51+
/*
52+
* Latch used by backends to wake up this walsender when it has work to
53+
* do.
54+
*/
55+
Latch latch;
56+
57+
/*
58+
* The priority order of the standby managed by this WALSender, as listed
59+
* in synchronous_standby_names, or 0 if not-listed. Protected by
60+
* SyncRepLock.
61+
*/
62+
int sync_standby_priority;
63+
} WalSnd;
64+
65+
extern WalSnd *MyWalSnd;
66+
67+
/* There is one WalSndCtl struct for the whole database cluster */
68+
typedef struct
69+
{
70+
/*
71+
* Synchronous replication queue. Protected by SyncRepLock.
72+
*/
73+
SHM_QUEUE SyncRepQueue;
74+
75+
/*
76+
* Current location of the head of the queue. All waiters should have a
77+
* waitLSN that follows this value. Protected by SyncRepLock.
78+
*/
79+
XLogRecPtr lsn;
80+
81+
/*
82+
* Are any sync standbys defined? Waiting backends can't reload the
83+
* config file safely, so WAL writer updates this value as needed.
84+
* Protected by SyncRepLock.
85+
*/
86+
bool sync_standbys_defined;
87+
88+
WalSnd walsnds[1]; /* VARIABLE LENGTH ARRAY */
89+
} WalSndCtlData;
90+
91+
extern WalSndCtlData *WalSndCtl;
92+
93+
94+
extern void WalSndSetState(WalSndState state);
95+
extern void XLogRead(char *buf, XLogRecPtr startptr, Size count);
96+
97+
/*
98+
* Internal functions for parsing the replication grammar, in repl_gram.y and
99+
* repl_scanner.l
100+
*/
101+
extern int replication_yyparse(void);
102+
extern int replication_yylex(void);
103+
extern void replication_yyerror(const char *str);
104+
extern void replication_scanner_init(const char *query_string);
105+
extern void replication_scanner_finish(void);
106+
107+
extern Node *replication_parse_result;
108+
109+
#endif /* _WALSENDER_PRIVATE_H */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy