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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23#ifndef MISCADMIN_H

24#define MISCADMIN_H

25

26#include <signal.h>

27

29#include "pgtime.h"

30

31

32#define InvalidPid (-1)

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

100

103

104

108

109

111

112

113#ifndef WIN32

114#define INTERRUPTS_PENDING_CONDITION() \

115 (unlikely(InterruptPending))

116#else

117#define INTERRUPTS_PENDING_CONDITION() \

118 (unlikely(UNBLOCKED_SIGNAL_QUEUE()) ? pgwin32_dispatch_queued_signals() : 0, \

119 unlikely(InterruptPending))

120#endif

121

122

123#define CHECK_FOR_INTERRUPTS() \

124do { \

125 if (INTERRUPTS_PENDING_CONDITION()) \

126 ProcessInterrupts(); \

127} while(0)

128

129

130#define INTERRUPTS_CAN_BE_PROCESSED() \

131 (InterruptHoldoffCount == 0 && CritSectionCount == 0 && \

132 QueryCancelHoldoffCount == 0)

133

134#define HOLD_INTERRUPTS() (InterruptHoldoffCount++)

135

136#define RESUME_INTERRUPTS() \

137do { \

138 Assert(InterruptHoldoffCount > 0); \

139 InterruptHoldoffCount--; \

140} while(0)

141

142#define HOLD_CANCEL_INTERRUPTS() (QueryCancelHoldoffCount++)

143

144#define RESUME_CANCEL_INTERRUPTS() \

145do { \

146 Assert(QueryCancelHoldoffCount > 0); \

147 QueryCancelHoldoffCount--; \

148} while(0)

149

150#define START_CRIT_SECTION() (CritSectionCount++)

151

152#define END_CRIT_SECTION() \

153do { \

154 Assert(CritSectionCount > 0); \

155 CritSectionCount--; \

156} while(0)

157

158

159

160

161

162

163

164

165

170

172

175

181

189

198

202

203#ifdef EXEC_BACKEND

204extern PGDLLIMPORT char postgres_exec_path[];

205#endif

206

208

210

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236#define USE_POSTGRES_DATES 0

237#define USE_ISO_DATES 1

238#define USE_SQL_DATES 2

239#define USE_GERMAN_DATES 3

240#define USE_XSD_DATES 4

241

242

243#define DATEORDER_YMD 0

244#define DATEORDER_DMY 1

245#define DATEORDER_MDY 2

246

249

250

251

252

253

254

255

256

257#define INTSTYLE_POSTGRES 0

258#define INTSTYLE_POSTGRES_VERBOSE 1

259#define INTSTYLE_SQL_STANDARD 2

260#define INTSTYLE_ISO_8601 3

261

263

264#define MAXTZLEN 10

265

272

273

274

275

276

277

278#define MIN_BAS_VAC_RING_SIZE_KB 128

279#define MAX_BAS_VAC_RING_SIZE_KB (16 * 1024 * 1024)

280

287

290

291

292

293

295

296

297#define STACK_DEPTH_SLOP (512 * 1024)

298

300

306

307

311

312

313

314

315

316

317

318#define SECURITY_LOCAL_USERID_CHANGE 0x0001

319#define SECURITY_RESTRICTED_OPERATION 0x0002

320#define SECURITY_NOFORCE_RLS 0x0004

321

323

324

330

331

332

333

334

335

336

338{

340

341

349

351

352

353

354

355

356

357

358

359

360

369

370

371

372

373

376

377#define BACKEND_NUM_TYPES (B_LOGGER + 1)

378

380

381#define AmRegularBackendProcess() (MyBackendType == B_BACKEND)

382#define AmAutoVacuumLauncherProcess() (MyBackendType == B_AUTOVAC_LAUNCHER)

383#define AmAutoVacuumWorkerProcess() (MyBackendType == B_AUTOVAC_WORKER)

384#define AmBackgroundWorkerProcess() (MyBackendType == B_BG_WORKER)

385#define AmWalSenderProcess() (MyBackendType == B_WAL_SENDER)

386#define AmLogicalSlotSyncWorkerProcess() (MyBackendType == B_SLOTSYNC_WORKER)

387#define AmArchiverProcess() (MyBackendType == B_ARCHIVER)

388#define AmBackgroundWriterProcess() (MyBackendType == B_BG_WRITER)

389#define AmCheckpointerProcess() (MyBackendType == B_CHECKPOINTER)

390#define AmStartupProcess() (MyBackendType == B_STARTUP)

391#define AmWalReceiverProcess() (MyBackendType == B_WAL_RECEIVER)

392#define AmWalSummarizerProcess() (MyBackendType == B_WAL_SUMMARIZER)

393#define AmWalWriterProcess() (MyBackendType == B_WAL_WRITER)

394#define AmIoWorkerProcess() (MyBackendType == B_IO_WORKER)

395

396#define AmSpecialWorkerProcess() \

397 (AmAutoVacuumLauncherProcess() || \

398 AmLogicalSlotSyncWorkerProcess())

399

400

401

402

403

404

405#define IsExternalConnectionBackend(backend_type) \

406 (backend_type == B_BACKEND || backend_type == B_WAL_SENDER)

407

409

412extern void SetDataDir(const char *dir);

414

430 bool bypass_login_check);

436 const char *auth_method);

438

439

440extern bool superuser(void);

441extern bool superuser_arg(Oid roleid);

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

469{

474

476

477#define IsBootstrapProcessingMode() (Mode == BootstrapProcessing)

478#define IsInitProcessingMode() (Mode == InitProcessing)

479#define IsNormalProcessingMode() (Mode == NormalProcessing)

480

481#define GetProcessingMode() Mode

482

483#define SetProcessingMode(mode) \

484 do { \

485 Assert((mode) == BootstrapProcessing || \

486 (mode) == InitProcessing || \

487 (mode) == NormalProcessing); \

488 Mode = (mode); \

489 } while(0)

490

491

492

493

494

495

496

497

498

499#define INIT_PG_LOAD_SESSION_LIBS 0x0001

500#define INIT_PG_OVERRIDE_ALLOW_CONNS 0x0002

501#define INIT_PG_OVERRIDE_ROLE_LOGIN 0x0004

502extern void pg_split_opts(char **argv, int *argcp, const char *optstr);

505extern void InitPostgres(const char *in_dbname, Oid dboid,

508 char *out_dbname);

510

511

519

522 const char *socketDir);

532

535

539

540

542

543#endif

PGDLLIMPORT int IntervalStyle

PGDLLIMPORT shmem_request_hook_type shmem_request_hook

PGDLLIMPORT double VacuumCostDelay

void ChangeToDataDir(void)

PGDLLIMPORT uint8 MyCancelKey[]

PGDLLIMPORT bool IsPostmasterEnvironment

void process_shmem_requests(void)

PGDLLIMPORT struct Port * MyProcPort

void restore_stack_base(pg_stack_base_t base)

void InitializeMaxBackends(void)

void PreventCommandIfReadOnly(const char *cmdname)

PGDLLIMPORT volatile uint32 InterruptHoldoffCount

void pg_split_opts(char **argv, int *argcp, const char *optstr)

void InitializeSessionUserId(const char *rolename, Oid roleid, bool bypass_login_check)

void InitStandaloneProcess(const char *argv0)

void SerializeClientConnectionInfo(Size maxsize, char *start_address)

void PreventCommandIfParallelMode(const char *cmdname)

PGDLLIMPORT int commit_timestamp_buffers

PGDLLIMPORT bool IsUnderPostmaster

void InitializeSystemUser(const char *authn_id, const char *auth_method)

PGDLLIMPORT int VacuumCostBalance

PGDLLIMPORT Oid MyDatabaseTableSpace

void InitializeSessionUserIdStandalone(void)

ssize_t get_stack_depth_rlimit(void)

void AddToDataDirLockFile(int target_line, const char *str)

void InitProcessLocalLatch(void)

PGDLLIMPORT int maintenance_work_mem

void GetUserIdAndSecContext(Oid *userid, int *sec_context)

PGDLLIMPORT int MyCancelKeyLength

void SetSessionAuthorization(Oid userid, bool is_superuser)

void process_session_preload_libraries(void)

PGDLLIMPORT bool enableFsync

PGDLLIMPORT bool ExitOnAnyError

PGDLLIMPORT volatile sig_atomic_t IdleInTransactionSessionTimeoutPending

const char * GetSystemUser(void)

bool InSecurityRestrictedOperation(void)

PGDLLIMPORT char * shared_preload_libraries_string

PGDLLIMPORT bool allowSystemTableMods

bool GetSessionUserIsSuperuser(void)

const char * GetBackendTypeDesc(BackendType backendType)

PGDLLIMPORT bool IsBinaryUpgrade

Size EstimateClientConnectionInfoSpace(void)

PGDLLIMPORT volatile sig_atomic_t LogMemoryContextPending

PGDLLIMPORT int VacuumCostPageDirty

PGDLLIMPORT int data_directory_mode

Oid GetSessionUserId(void)

void SetCurrentRoleId(Oid roleid, bool is_superuser)

PGDLLIMPORT bool VacuumCostActive

PGDLLIMPORT int subtransaction_buffers

PGDLLIMPORT volatile sig_atomic_t InterruptPending

PGDLLIMPORT bool IgnoreSystemIndexes

Oid GetAuthenticatedUserId(void)

PGDLLIMPORT int VacuumCostLimit

PGDLLIMPORT bool MyDatabaseHasLoginEventTriggers

PGDLLIMPORT volatile sig_atomic_t ProcSignalBarrierPending

PGDLLIMPORT int MaxConnections

PGDLLIMPORT volatile sig_atomic_t PublishMemoryContextPending

bool InLocalUserIdChange(void)

PGDLLIMPORT int VacuumCostPageHit

PGDLLIMPORT bool process_shmem_requests_in_progress

void SetDatabasePath(const char *path)

void InitPostmasterChild(void)

void process_shared_preload_libraries(void)

PGDLLIMPORT volatile sig_atomic_t IdleStatsUpdateTimeoutPending

PGDLLIMPORT int notify_buffers

PGDLLIMPORT bool process_shared_preload_libraries_in_progress

void InitializeFastPathLocks(void)

PGDLLIMPORT struct Latch * MyLatch

PGDLLIMPORT TimestampTz MyStartTimestamp

PGDLLIMPORT char * DatabasePath

PGDLLIMPORT int MyPMChildSlot

void TouchSocketLockFiles(void)

PGDLLIMPORT double hash_mem_multiplier

size_t get_hash_memory_limit(void)

PGDLLIMPORT int max_stack_depth

PGDLLIMPORT volatile sig_atomic_t ClientConnectionLost

void RestoreClientConnectionInfo(char *conninfo)

PGDLLIMPORT int DateOrder

PGDLLIMPORT int max_parallel_maintenance_workers

PGDLLIMPORT char * local_preload_libraries_string

PGDLLIMPORT BackendType MyBackendType

bool InNoForceRLSOperation(void)

PGDLLIMPORT int serializable_buffers

PGDLLIMPORT volatile sig_atomic_t QueryCancelPending

bool superuser_arg(Oid roleid)

PGDLLIMPORT char * session_preload_libraries_string

PGDLLIMPORT int multixact_member_buffers

void PreventCommandDuringRecovery(const char *cmdname)

PGDLLIMPORT volatile sig_atomic_t CheckClientConnectionPending

void InitPostgres(const char *in_dbname, Oid dboid, const char *username, Oid useroid, bits32 flags, char *out_dbname)

bool stack_is_too_deep(void)

PGDLLIMPORT pg_time_t MyStartTime

PGDLLIMPORT volatile sig_atomic_t ProcDiePending

void ProcessInterrupts(void)

void SetAuthenticatedUserId(Oid userid)

PGDLLIMPORT int VacuumBufferUsageLimit

PGDLLIMPORT char pkglib_path[]

PGDLLIMPORT char my_exec_path[]

Oid GetCurrentRoleId(void)

PGDLLIMPORT pid_t PostmasterPid

PGDLLIMPORT int VacuumCostPageMiss

PGDLLIMPORT volatile uint32 QueryCancelHoldoffCount

void SwitchToSharedLatch(void)

PGDLLIMPORT int multixact_offset_buffers

PGDLLIMPORT int DateStyle

void GetUserIdAndContext(Oid *userid, bool *sec_def_context)

void SetDataDir(const char *dir)

PGDLLIMPORT volatile sig_atomic_t IdleSessionTimeoutPending

PGDLLIMPORT Oid MyDatabaseId

void SetUserIdAndContext(Oid userid, bool sec_def_context)

PGDLLIMPORT char OutputFileName[]

PGDLLIMPORT int transaction_buffers

PGDLLIMPORT int max_worker_processes

PGDLLIMPORT ProcessingMode Mode

void(* shmem_request_hook_type)(void)

void pg_bindtextdomain(const char *domain)

bool has_rolreplication(Oid roleid)

char * GetUserNameFromId(Oid roleid, bool noerr)

PGDLLIMPORT char * DataDir

PGDLLIMPORT int MaxBackends

PGDLLIMPORT bool process_shared_preload_libraries_done

void ValidatePgVersion(const char *path)

PGDLLIMPORT volatile uint32 CritSectionCount

void SetUserIdAndSecContext(Oid userid, int sec_context)

bool RecheckDataDirLockFile(void)

void check_stack_depth(void)

pg_stack_base_t set_stack_base(void)

void CreateDataDirLockFile(bool amPostmaster)

void SwitchBackToLocalLatch(void)

void CreateSocketLockFile(const char *socketfile, bool amPostmaster, const char *socketDir)

PGDLLIMPORT volatile sig_atomic_t TransactionTimeoutPending

PGDLLIMPORT int max_parallel_workers

PGDLLIMPORT int MyProcPid

static bool is_superuser(Archive *fout)