PostgreSQL Source Code: src/include/replication/walreceiver.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12#ifndef _WALRECEIVER_H

13#define _WALRECEIVER_H

14

16

26

27

31

32

33

34

35

36

37#define MAXCONNINFO 1024

38

39

40#define AllowCascadeReplication() (EnableHotStandby && max_wal_senders > 0)

41

42

43

44

45typedef enum

46{

49

55

56

57typedef struct

58{

59

60

61

62

63

64

65

66

69

70

73

74

75

76

77

79

80

81

82

83

84

85

88

89

90

91

92

93

94

95

98

99

100

101

102

103

104

106

107

108

109

112

113

114

115

118

119

120

121

122

124

125

126

127

128

129 char sender_host[NI_MAXHOST];

131

132

133

134

135

137

138

139

140

141

143

144

146

147 slock_t mutex;

148

149

150

151

152

153

154

156

157

158

159

160

161

164

166

167typedef struct

168{

169 bool logical;

170

171 char *slotname;

173

174 union

175 {

176 struct

177 {

179 } physical;

180 struct

181 {

184 bool binary;

186 bool twophase;

187

188 char *origin;

189

190 } logical;

193

196

197

198

199

200

201

202typedef enum

203{

204 WALRCV_ERROR,

206

211

213

214

215

216

217

219{

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

243 bool replication,

244 bool logical,

245 bool must_use_password,

246 const char *appname,

247 char **err);

248

249

250

251

252

253

255 bool must_use_password);

256

257

258

259

260

261

262

264

265

266

267

268

269

270

271

273 char **sender_host,

274 int *sender_port);

275

276

277

278

279

280

281

282

285

286

287

288

289

290

291typedef char *(*walrcv_get_dbname_from_conninfo_fn) (const char *conninfo);

292

293

294

295

296

297

299

300

301

302

303

304

305

306

310 char **content,

311 int *size);

312

313

314

315

316

317

318

319

320

323

324

325

326

327

328

329

332

333

334

335

336

337

338

339

340

342 char **buffer,

344

345

346

347

348

349

350

352 const char *buffer,

353 int nbytes);

354

355

356

357

358

359

360

361

362

363

364

366 const char *slotname,

367 bool temporary,

372

373

374

375

376

377

378

380 const char *slotname,

383

384

385

386

387

388

389

391

392

393

394

395

396

397

398

399

401 const char *query,

402 const int nRetTypes,

403 const Oid *retTypes);

404

405

406

407

408

409

411

413{

432

434

435#define walrcv_connect(conninfo, replication, logical, must_use_password, appname, err) \

436 WalReceiverFunctions->walrcv_connect(conninfo, replication, logical, must_use_password, appname, err)

437#define walrcv_check_conninfo(conninfo, must_use_password) \

438 WalReceiverFunctions->walrcv_check_conninfo(conninfo, must_use_password)

439#define walrcv_get_conninfo(conn) \

440 WalReceiverFunctions->walrcv_get_conninfo(conn)

441#define walrcv_get_senderinfo(conn, sender_host, sender_port) \

442 WalReceiverFunctions->walrcv_get_senderinfo(conn, sender_host, sender_port)

443#define walrcv_identify_system(conn, primary_tli) \

444 WalReceiverFunctions->walrcv_identify_system(conn, primary_tli)

445#define walrcv_get_dbname_from_conninfo(conninfo) \

446 WalReceiverFunctions->walrcv_get_dbname_from_conninfo(conninfo)

447#define walrcv_server_version(conn) \

448 WalReceiverFunctions->walrcv_server_version(conn)

449#define walrcv_readtimelinehistoryfile(conn, tli, filename, content, size) \

450 WalReceiverFunctions->walrcv_readtimelinehistoryfile(conn, tli, filename, content, size)

451#define walrcv_startstreaming(conn, options) \

452 WalReceiverFunctions->walrcv_startstreaming(conn, options)

453#define walrcv_endstreaming(conn, next_tli) \

454 WalReceiverFunctions->walrcv_endstreaming(conn, next_tli)

455#define walrcv_receive(conn, buffer, wait_fd) \

456 WalReceiverFunctions->walrcv_receive(conn, buffer, wait_fd)

457#define walrcv_send(conn, buffer, nbytes) \

458 WalReceiverFunctions->walrcv_send(conn, buffer, nbytes)

459#define walrcv_create_slot(conn, slotname, temporary, two_phase, failover, snapshot_action, lsn) \

460 WalReceiverFunctions->walrcv_create_slot(conn, slotname, temporary, two_phase, failover, snapshot_action, lsn)

461#define walrcv_alter_slot(conn, slotname, failover, two_phase) \

462 WalReceiverFunctions->walrcv_alter_slot(conn, slotname, failover, two_phase)

463#define walrcv_get_backend_pid(conn) \

464 WalReceiverFunctions->walrcv_get_backend_pid(conn)

465#define walrcv_exec(conn, exec, nRetTypes, retTypes) \

466 WalReceiverFunctions->walrcv_exec(conn, exec, nRetTypes, retTypes)

467#define walrcv_disconnect(conn) \

468 WalReceiverFunctions->walrcv_disconnect(conn)

469

470static inline void

472{

473 if (!walres)

474 return;

475

476 if (walres->err)

478

481

484

486}

487

488

491

492

499 const char *conninfo, const char *slotname,

500 bool create_temp_slot);

505

506#endif

void err(int eval, const char *fmt,...)

void pfree(void *pointer)

TimestampTz lastMsgReceiptTime

TimeLineID receiveStartTLI

XLogRecPtr latestChunkStart

ConditionVariable walRcvStoppedCV

pg_atomic_uint64 writtenUpto

TimestampTz lastMsgSendTime

TimestampTz latestWalEndTime

Tuplestorestate * tuplestore

walrcv_identify_system_fn walrcv_identify_system

walrcv_receive_fn walrcv_receive

walrcv_server_version_fn walrcv_server_version

walrcv_disconnect_fn walrcv_disconnect

walrcv_get_backend_pid_fn walrcv_get_backend_pid

walrcv_connect_fn walrcv_connect

walrcv_get_dbname_from_conninfo_fn walrcv_get_dbname_from_conninfo

walrcv_get_senderinfo_fn walrcv_get_senderinfo

walrcv_check_conninfo_fn walrcv_check_conninfo

walrcv_send_fn walrcv_send

walrcv_get_conninfo_fn walrcv_get_conninfo

walrcv_exec_fn walrcv_exec

walrcv_startstreaming_fn walrcv_startstreaming

walrcv_create_slot_fn walrcv_create_slot

walrcv_readtimelinehistoryfile_fn walrcv_readtimelinehistoryfile

walrcv_alter_slot_fn walrcv_alter_slot

walrcv_endstreaming_fn walrcv_endstreaming

void FreeTupleDesc(TupleDesc tupdesc)

void tuplestore_end(Tuplestorestate *state)

XLogRecPtr GetWalRcvFlushRecPtr(XLogRecPtr *latestChunkStart, TimeLineID *receiveTLI)

void(* walrcv_endstreaming_fn)(WalReceiverConn *conn, TimeLineID *next_tli)

bool WalRcvStreaming(void)

struct WalRcvExecResult WalRcvExecResult

char *(* walrcv_get_dbname_from_conninfo_fn)(const char *conninfo)

void(* walrcv_send_fn)(WalReceiverConn *conn, const char *buffer, int nbytes)

void RequestXLogStreaming(TimeLineID tli, XLogRecPtr recptr, const char *conninfo, const char *slotname, bool create_temp_slot)

PGDLLIMPORT int wal_receiver_status_interval

char *(* walrcv_create_slot_fn)(WalReceiverConn *conn, const char *slotname, bool temporary, bool two_phase, bool failover, CRSSnapshotAction snapshot_action, XLogRecPtr *lsn)

pg_noreturn void WalReceiverMain(const void *startup_data, size_t startup_data_len)

WalReceiverConn *(* walrcv_connect_fn)(const char *conninfo, bool replication, bool logical, bool must_use_password, const char *appname, char **err)

pid_t(* walrcv_get_backend_pid_fn)(WalReceiverConn *conn)

XLogRecPtr GetWalRcvWriteRecPtr(void)

void ShutdownWalRcv(void)

bool(* walrcv_startstreaming_fn)(WalReceiverConn *conn, const WalRcvStreamOptions *options)

int(* walrcv_receive_fn)(WalReceiverConn *conn, char **buffer, pgsocket *wait_fd)

void(* walrcv_readtimelinehistoryfile_fn)(WalReceiverConn *conn, TimeLineID tli, char **filename, char **content, int *size)

WalRcvExecResult *(* walrcv_exec_fn)(WalReceiverConn *conn, const char *query, const int nRetTypes, const Oid *retTypes)

PGDLLIMPORT int wal_receiver_timeout

static void walrcv_clear_result(WalRcvExecResult *walres)

void(* walrcv_check_conninfo_fn)(const char *conninfo, bool must_use_password)

PGDLLIMPORT WalReceiverFunctionsType * WalReceiverFunctions

void(* walrcv_disconnect_fn)(WalReceiverConn *conn)

struct WalReceiverFunctionsType WalReceiverFunctionsType

char *(* walrcv_identify_system_fn)(WalReceiverConn *conn, TimeLineID *primary_tli)

void(* walrcv_get_senderinfo_fn)(WalReceiverConn *conn, char **sender_host, int *sender_port)

int GetReplicationApplyDelay(void)

PGDLLIMPORT WalRcvData * WalRcv

void WalRcvShmemInit(void)

char *(* walrcv_get_conninfo_fn)(WalReceiverConn *conn)

Size WalRcvShmemSize(void)

void(* walrcv_alter_slot_fn)(WalReceiverConn *conn, const char *slotname, const bool *failover, const bool *two_phase)

PGDLLIMPORT bool hot_standby_feedback

int(* walrcv_server_version_fn)(WalReceiverConn *conn)

void WalRcvForceReply(void)

int GetReplicationTransferLatency(void)

static TimeLineID receiveTLI