PostgreSQL Source Code: src/backend/access/transam/xlogfuncs.c Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

18

20

37

38

39

40

43

44

46

47

48

49

50

51

52

53

54

55

58{

61 char *backupidstr;

64

66

69 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

70 errmsg("a backup is already in progress in this session")));

71

72

73

74

75

76

77

78

80 {

82 "on-line backup context",

84 }

85 else

86 {

90 }

91

96

99

101}

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

125{

126#define PG_BACKUP_STOP_V2_COLS 3

131 char *backup_label;

133

134

136 elog(ERROR, "return type must be a row type");

137

140 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

141 errmsg("backup is not in progress"),

142 errhint("Did you call pg_backup_start()?")));

143

146

147

149

150

152

156

157

158 pfree(backup_label);

159

160

165

166

168}

169

170

171

172

173

174

175

178{

180

183 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

184 errmsg("recovery is in progress"),

185 errhint("WAL control functions cannot be executed during recovery.")));

186

188

189

190

191

193}

194

195

196

197

198

199

200

203{

205

208 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

209 errmsg("recovery is in progress"),

210 errhint("%s cannot be executed during recovery.",

211 "pg_log_standby_snapshot()")));

212

215 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

216 errmsg("pg_log_standby_snapshot() can only be used if \"wal_level\" >= \"replica\"")));

217

219

220

221

222

224}

225

226

227

228

229

230

231

234{

236 char *restore_name_str;

238

241 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

242 errmsg("recovery is in progress"),

243 errhint("WAL control functions cannot be executed during recovery.")));

244

247 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

248 errmsg("WAL level not sufficient for creating a restore point"),

249 errhint("\"wal_level\" must be set to \"replica\" or \"logical\" at server start.")));

250

252

253 if (strlen(restore_name_str) >= MAXFNAMELEN)

255 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

256 errmsg("value too long for restore point (maximum %d characters)", MAXFNAMELEN - 1)));

257

259

260

261

262

264}

265

266

267

268

269

270

271

272

275{

277

280 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

281 errmsg("recovery is in progress"),

282 errhint("WAL control functions cannot be executed during recovery.")));

283

285

287}

288

289

290

291

292

293

296{

298

301 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

302 errmsg("recovery is in progress"),

303 errhint("WAL control functions cannot be executed during recovery.")));

304

306

308}

309

310

311

312

313

314

317{

319

322 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

323 errmsg("recovery is in progress"),

324 errhint("WAL control functions cannot be executed during recovery.")));

325

327

329}

330

331

332

333

334

335

336

339{

341

343

344 if (recptr == 0)

346

348}

349

350

351

352

353

354

355

358{

360

362

363 if (recptr == 0)

365

367}

368

369

370

371

372

375{

381 bool isnull[2];

385

388 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

389 errmsg("recovery is in progress"),

390 errhint("%s cannot be executed during recovery.",

391 "pg_walfile_name_offset()")));

392

393

394

395

396

399 TEXTOID, -1, 0);

401 INT4OID, -1, 0);

402

404

405

406

407

411

413 isnull[0] = false;

414

415

416

417

419

421 isnull[1] = false;

422

423

424

425

427

429

431}

432

433

434

435

436

439{

443

446 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

447 errmsg("recovery is in progress"),

448 errhint("%s cannot be executed during recovery.",

449 "pg_walfile_name()")));

450

454

456}

457

458

459

460

461

464{

465#define PG_SPLIT_WALFILE_NAME_COLS 2

467 char *fname_upper;

468 char *p;

475 char buf[256];

477

478 fname_upper = pstrdup(fname);

479

480

481 for (p = fname_upper; *p; p++)

483

486 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

487 errmsg("invalid WAL file name \"%s\"", fname)));

488

490

492 elog(ERROR, "return type must be a row type");

493

494

500

502

505

507

508#undef PG_SPLIT_WALFILE_NAME_COLS

509}

510

511

512

513

514

515

516

519{

522 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

523 errmsg("recovery is not in progress"),

524 errhint("Recovery control functions can only be executed during recovery.")));

525

528 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

529 errmsg("standby promotion is ongoing"),

530 errhint("%s cannot be executed after promotion is triggered.",

531 "pg_wal_replay_pause()")));

532

534

535

537

539}

540

541

542

543

544

545

546

549{

552 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

553 errmsg("recovery is not in progress"),

554 errhint("Recovery control functions can only be executed during recovery.")));

555

558 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

559 errmsg("standby promotion is ongoing"),

560 errhint("%s cannot be executed after promotion is triggered.",

561 "pg_wal_replay_resume()")));

562

564

566}

567

568

569

570

573{

576 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

577 errmsg("recovery is not in progress"),

578 errhint("Recovery control functions can only be executed during recovery.")));

579

581}

582

583

584

585

586

587

588

589

590

591

594{

595 char *statestr = NULL;

596

599 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

600 errmsg("recovery is not in progress"),

601 errhint("Recovery control functions can only be executed during recovery.")));

602

603

605 {

607 statestr = "not paused";

608 break;

610 statestr = "pause requested";

611 break;

613 statestr = "paused";

614 break;

615 }

616

617 Assert(statestr != NULL);

619}

620

621

622

623

624

625

626

629{

631

633 if (xtime == 0)

635

637}

638

639

640

641

644{

646}

647

648

649

650

653{

655

659

661}

662

663

664

665

666

667

668

671{

675 int i;

676

679 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

680 errmsg("recovery is not in progress"),

681 errhint("Recovery control functions can only be executed during recovery.")));

682

685 (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),

686 errmsg("\"wait_seconds\" must not be negative or zero")));

687

688

693 errmsg("could not create file \"%s\": %m",

695

699 errmsg("could not write file \"%s\": %m",

701

702

704 {

707 (errcode(ERRCODE_SYSTEM_ERROR),

708 errmsg("failed to send signal to postmaster: %m")));

709 }

710

711

712 if (!wait)

714

715

716#define WAITS_PER_SECOND 10

718 {

719 int rc;

720

722

725

727

731 WAIT_EVENT_PROMOTE);

732

733

734

735

736

739 (errcode(ERRCODE_ADMIN_SHUTDOWN),

740 errmsg("terminating connection due to unexpected postmaster exit"),

741 errcontext("while waiting on promotion")));

742 }

743

745 (errmsg_plural("server did not promote within %d second",

746 "server did not promote within %d seconds",

750}

Datum numeric_in(PG_FUNCTION_ARGS)

static Datum values[MAXATTR]

#define CStringGetTextDatum(s)

int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)

int errcode_for_file_access(void)

int errhint(const char *fmt,...)

int errcode(int sqlerrcode)

int errmsg(const char *fmt,...)

#define ereport(elevel,...)

TupleDesc BlessTupleDesc(TupleDesc tupdesc)

FILE * AllocateFile(const char *name, const char *mode)

Datum Int64GetDatum(int64 X)

#define PG_GETARG_TEXT_PP(n)

#define DirectFunctionCall2(func, arg1, arg2)

#define PG_GETARG_DATUM(n)

#define PG_RETURN_TEXT_P(x)

#define PG_GETARG_INT32(n)

#define PG_GETARG_BOOL(n)

#define PG_RETURN_DATUM(x)

#define DirectFunctionCall3(func, arg1, arg2, arg3)

#define PG_RETURN_BOOL(x)

TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)

static Datum HeapTupleGetDatum(const HeapTupleData *tuple)

Assert(PointerIsAligned(start, uint64))

HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)

void ResetLatch(Latch *latch)

int WaitLatch(Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)

void MemoryContextReset(MemoryContext context)

char * pstrdup(const char *in)

void pfree(void *pointer)

void * palloc0(Size size)

MemoryContext TopMemoryContext

void MemoryContextDelete(MemoryContext context)

#define AllocSetContextCreate

#define ALLOCSET_START_SMALL_SIZES

#define CHECK_FOR_INTERRUPTS()

static MemoryContext MemoryContextSwitchTo(MemoryContext context)

static char promote_file[MAXPGPATH]

Datum pg_lsn_mi(PG_FUNCTION_ARGS)

static Datum LSNGetDatum(XLogRecPtr X)

unsigned char pg_toupper(unsigned char ch)

static Datum ObjectIdGetDatum(Oid X)

static Datum CStringGetDatum(const char *X)

static Datum Int32GetDatum(int32 X)

static Datum UInt32GetDatum(uint32 X)

XLogRecPtr LogStandbySnapshot(void)

StringInfo makeStringInfo(void)

TupleDesc CreateTemplateTupleDesc(int natts)

void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)

#define PG_RETURN_TIMESTAMPTZ(x)

text * cstring_to_text(const char *s)

char * text_to_cstring(const text *t)

#define WL_POSTMASTER_DEATH

XLogRecPtr GetWalRcvFlushRecPtr(XLogRecPtr *latestChunkStart, TimeLineID *receiveTLI)

bool RecoveryInProgress(void)

TimeLineID GetWALInsertionTimeLine(void)

XLogRecPtr RequestXLogSwitch(bool mark_unimportant)

SessionBackupState get_backup_status(void)

XLogRecPtr GetXLogInsertRecPtr(void)

XLogRecPtr GetFlushRecPtr(TimeLineID *insertTLI)

void register_persistent_abort_backup_handler(void)

XLogRecPtr GetXLogWriteRecPtr(void)

void do_pg_backup_start(const char *backupidstr, bool fast, List **tablespaces, BackupState *state, StringInfo tblspcmapfile)

XLogRecPtr XLogRestorePoint(const char *rpName)

void do_pg_backup_stop(BackupState *state, bool waitforarchive)

#define PROMOTE_SIGNAL_FILE

#define XLogStandbyInfoActive()

#define XLogSegmentOffset(xlogptr, wal_segsz_bytes)

static bool IsXLogFileName(const char *fname)

static void XLogFromFileName(const char *fname, TimeLineID *tli, XLogSegNo *logSegNo, int wal_segsz_bytes)

#define XLByteToSeg(xlrp, logSegNo, wal_segsz_bytes)

static void XLogFileName(char *fname, TimeLineID tli, XLogSegNo logSegNo, int wal_segsz_bytes)

char * build_backup_content(BackupState *state, bool ishistoryfile)

Datum pg_is_wal_replay_paused(PG_FUNCTION_ARGS)

Datum pg_wal_lsn_diff(PG_FUNCTION_ARGS)

Datum pg_backup_start(PG_FUNCTION_ARGS)

Datum pg_create_restore_point(PG_FUNCTION_ARGS)

Datum pg_current_wal_insert_lsn(PG_FUNCTION_ARGS)

Datum pg_switch_wal(PG_FUNCTION_ARGS)

Datum pg_is_in_recovery(PG_FUNCTION_ARGS)

#define PG_SPLIT_WALFILE_NAME_COLS

Datum pg_split_walfile_name(PG_FUNCTION_ARGS)

Datum pg_backup_stop(PG_FUNCTION_ARGS)

Datum pg_last_xact_replay_timestamp(PG_FUNCTION_ARGS)

Datum pg_log_standby_snapshot(PG_FUNCTION_ARGS)

static BackupState * backup_state

Datum pg_current_wal_lsn(PG_FUNCTION_ARGS)

Datum pg_last_wal_receive_lsn(PG_FUNCTION_ARGS)

#define PG_BACKUP_STOP_V2_COLS

Datum pg_walfile_name(PG_FUNCTION_ARGS)

Datum pg_current_wal_flush_lsn(PG_FUNCTION_ARGS)

Datum pg_walfile_name_offset(PG_FUNCTION_ARGS)

static MemoryContext backupcontext

static StringInfo tablespace_map

Datum pg_promote(PG_FUNCTION_ARGS)

Datum pg_get_wal_replay_pause_state(PG_FUNCTION_ARGS)

Datum pg_last_wal_replay_lsn(PG_FUNCTION_ARGS)

Datum pg_wal_replay_pause(PG_FUNCTION_ARGS)

Datum pg_wal_replay_resume(PG_FUNCTION_ARGS)

void SetRecoveryPause(bool recoveryPause)

void WakeupRecovery(void)

bool PromoteIsTriggered(void)

XLogRecPtr GetXLogReplayRecPtr(TimeLineID *replayTLI)

RecoveryPauseState GetRecoveryPauseState(void)

TimestampTz GetLatestXTime(void)

@ RECOVERY_PAUSE_REQUESTED