PostgreSQL Source Code: src/backend/utils/init/miscinit.c Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

16

18#include <signal.h>

21#include <sys/stat.h>

23#include <fcntl.h>

30

58

59

60#define DIRECTORY_LOCK_FILE "postmaster.pid"

61

63

65

66

68

70

71

72

73

74

75

76

77

78

79

80

82

83

84

85

86

87

88

89

90

91

92

93

94

95void

97{

98 IsUnderPostmaster = true;

99

100

101

102

103

104

105#ifdef WIN32

107#endif

108

110

111

112

113

114

115

116

117#ifdef WIN32

118 _setmode(fileno(stderr), _O_BINARY);

119#endif

120

121

123

124

125#ifdef EXEC_BACKEND

127#endif

128

129

133

134

135

136

137

138

139

140#ifdef HAVE_SETSID

141 if (setsid() < 0)

142 elog(FATAL, "setsid() failed: %m");

143#endif

144

145

146

147

148

149

150

151

153

155 sigprocmask(SIG_SETMASK, &BlockSig, NULL);

156

157

159

160

161#ifndef WIN32

165 errmsg_internal("could not set postmaster death monitoring pipe to FD_CLOEXEC mode: %m")));

166#endif

167}

168

169

170

171

172

173

174void

176{

178

180

181

182

183

184#ifdef WIN32

186#endif

187

189

190

194

195

196

197

198

200 sigprocmask(SIG_SETMASK, &BlockSig, NULL);

201

202

204 {

206 elog(FATAL, "%s: could not locate my own executable path",

208 }

209

212}

213

214void

216{

219

221

225

226

227

228

229

230

232}

233

234void

236{

239}

240

241void

243{

246

248

252

254}

255

256

257

258

259

260

261

262const char *

264{

265 const char *backendDesc = gettext_noop("unknown process type");

266

267 switch (backendType)

268 {

270 backendDesc = gettext_noop("not initialized");

271 break;

274 break;

276 backendDesc = gettext_noop("autovacuum launcher");

277 break;

279 backendDesc = gettext_noop("autovacuum worker");

280 break;

282 backendDesc = gettext_noop("client backend");

283 break;

285 backendDesc = gettext_noop("dead-end client backend");

286 break;

288 backendDesc = gettext_noop("background worker");

289 break;

291 backendDesc = gettext_noop("background writer");

292 break;

295 break;

298 break;

301 break;

303 backendDesc = gettext_noop("slotsync worker");

304 break;

306 backendDesc = gettext_noop("standalone backend");

307 break;

310 break;

313 break;

316 break;

319 break;

322 break;

323 }

324

325 return backendDesc;

326}

327

328

329

330

331

332

333void

335{

336

339}

340

341

342

343

344

345

346void

348{

349 struct stat stat_buf;

350

352

354 {

355 if (errno == ENOENT)

358 errmsg("data directory \"%s\" does not exist",

360 else

363 errmsg("could not read permissions of directory \"%s\": %m",

365 }

366

367

370 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

371 errmsg("specified data directory \"%s\" is not a directory",

373

374

375

376

377

378

379

380

381

382

383#if !defined(WIN32) && !defined(__CYGWIN__)

384 if (stat_buf.st_uid != geteuid())

386 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

387 errmsg("data directory \"%s\" has wrong ownership",

389 errhint("The server must be started by the user that owns the data directory.")));

390#endif

391

392

393

394

395

396

397

398

399

400

401

402

403#if !defined(WIN32) && !defined(__CYGWIN__)

406 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

407 errmsg("data directory \"%s\" has invalid permissions",

409 errdetail("Permissions should be u=rwx (0700) or u=rwx,g=rx (0750).")));

410#endif

411

412

413

414

415

416

417

418

419

420

421

422

423

424#if !defined(WIN32) && !defined(__CYGWIN__)

426

429#endif

430

431

433}

434

435

436

437

438

439void

441{

442 char *new;

443

445

446

448

451}

452

453

454

455

456

457

458

459void

461{

463

467 errmsg("could not change directory to \"%s\": %m",

469}

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

505

506

508

510

511

513

514

515

516

517

518

521{

524}

525

526

527

528

529

532{

535}

536

537

538static void

540{

544

545

547

548

552}

553

554

555

556

557

560{

563}

564

565bool

567{

570}

571

572static void

574{

579}

580

581

582

583

584

585const char *

587{

589}

590

591

592

593

594

597{

600}

601

602void

604{

606

607

609

611

612

613

615}

616

617

618

619

620

621

622

623

624

625

626

627

628

629

630

631

632

633

634

635

636

637

638

639

640

641

642

643

644

645

646

647

648

649

650

651

652

653

654

655

656

657

658

659

660

661

662void

664{

667}

668

669void

671{

674}

675

676

677

678

679

680bool

682{

684}

685

686

687

688

689bool

691{

693}

694

695

696

697

698bool

700{

702}

703

704

705

706

707

708

709

710

711void

713{

716}

717

718void

720{

721

724 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),

725 errmsg("cannot set parameter \"%s\" within security-restricted operation",

726 "role")));

728 if (sec_def_context)

730 else

732}

733

734

735

736

737

738bool

740{

741 bool result = false;

743

744

746 return true;

747

750 {

753 }

754 return result;

755}

756

757

758

759

760void

762 bool bypass_login_check)

763{

766 char *rname;

768

769

770

771

772

773

774

775

777 {

778 Assert(bypass_login_check);

779 return;

780 }

781

782

783

784

785

787

788

789

790

791

792

794

795

796

797

798 if (rolename != NULL)

799 {

803 (errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),

804 errmsg("role \"%s\" does not exist", rolename)));

805 }

806 else

807 {

811 (errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),

812 errmsg("role with OID %u does not exist", roleid)));

813 }

814

816 roleid = rform->oid;

817 rname = NameStr(rform->rolname);

819

821

822

823

824

825

826

827

828

829

830

831

832

833

834

835

836

837

838

839

840

843

844

845

846

847

848

850 {

851

852

853

854

855 if (!bypass_login_check && !rform->rolcanlogin)

857 (errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),

858 errmsg("role \"%s\" is not permitted to log in",

859 rname)));

860

861

862

863

864

865

866

867

868

869

870

871

872

873 if (rform->rolconnlimit >= 0 &&

878 (errcode(ERRCODE_TOO_MANY_CONNECTIONS),

879 errmsg("too many connections for role \"%s\"",

880 rname)));

881 }

882

884}

885

886

887

888

889

890void

892{

893

894

895

896

899

900

902

904

905

906

907

908

909

910

911

912

914

915

917}

918

919

920

921

922

923

924void

926{

928

929

931

932

933

934

935

937

939

940

943}

944

945

946

947

950{

952

953 if (sysuser)

955 else

957}

958

959

960

961

962

963

964

965

966

967

968

969

970void

972{

974

977}

978

979

980

981

982

983

984

987{

990 else

992}

993

994

995

996

997

998

999

1000

1001

1002

1003

1004

1005

1006void

1008{

1009

1010

1011

1012

1013

1014

1015

1016

1018 {

1020

1022 return;

1023

1026 }

1027 else

1029

1031}

1032

1033

1034

1035

1036

1037

1038char *

1040{

1042 char *result;

1043

1046 {

1047 if (!noerr)

1049 (errcode(ERRCODE_UNDEFINED_OBJECT),

1050 errmsg("invalid role OID: %u", roleid)));

1051 result = NULL;

1052 }

1053 else

1054 {

1057 }

1058 return result;

1059}

1060

1061

1062

1063

1064

1065

1066

1067

1068

1070

1071

1072

1073

1074

1075

1077{

1081

1082

1083

1084

1087{

1088 Size size = 0;

1089

1091

1094

1095 return size;

1096}

1097

1098

1099

1100

1101void

1103{

1105

1108

1111

1112

1113 Assert(maxsize >= sizeof(serialized));

1114 memcpy(start_address, &serialized, sizeof(serialized));

1115

1116 maxsize -= sizeof(serialized);

1117 start_address += sizeof(serialized);

1118

1119

1121 {

1123 memcpy(start_address,

1125

1127 }

1128}

1129

1130

1131

1132

1133void

1135{

1137

1138 memcpy(&serialized, conninfo, sizeof(serialized));

1139

1140

1143

1145 {

1147

1148 authn_id = conninfo + sizeof(serialized);

1151 }

1152}

1153

1154

1155

1156

1157

1158

1159

1160

1161

1162

1163

1164

1165

1166

1167

1168

1169

1170

1171

1172

1173static void

1175{

1177

1179 {

1180 char *curfile = (char *) lfirst(l);

1181

1182 unlink(curfile);

1183

1184 }

1185

1187

1188

1189

1190

1191

1192

1193

1194

1195

1197 (errmsg("database system is shut down")));

1198}

1199

1200

1201

1202

1203

1204

1205

1206

1207

1208static void

1210 const char *socketDir,

1211 bool isDDLock, const char *refName)

1212{

1213 int fd;

1214 char buffer[MAXPGPATH * 2 + 256];

1215 int ntries;

1216 int len;

1217 int encoded_pid;

1218 pid_t other_pid;

1219 pid_t my_pid,

1220 my_p_pid,

1221 my_gp_pid;

1222 const char *envvar;

1223

1224

1225

1226

1227

1228

1229

1230

1231

1232

1233

1234

1235

1236

1237

1238

1239

1240

1241

1242 my_pid = getpid();

1243

1244#ifndef WIN32

1245 my_p_pid = getppid();

1246#else

1247

1248

1249

1250

1251

1252 my_p_pid = 0;

1253#endif

1254

1255 envvar = getenv("PG_GRANDPARENT_PID");

1256 if (envvar)

1257 my_gp_pid = atoi(envvar);

1258 else

1259 my_gp_pid = 0;

1260

1261

1262

1263

1264

1265

1266 for (ntries = 0;; ntries++)

1267 {

1268

1269

1270

1271

1272

1273

1275 if (fd >= 0)

1276 break;

1277

1278

1279

1280

1281 if ((errno != EEXIST && errno != EACCES) || ntries > 100)

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

1286

1287

1288

1289

1290

1292 if (fd < 0)

1293 {

1294 if (errno == ENOENT)

1295 continue;

1298 errmsg("could not open lock file \"%s\": %m",

1300 }

1302 if ((len = read(fd, buffer, sizeof(buffer) - 1)) < 0)

1305 errmsg("could not read lock file \"%s\": %m",

1309

1310 if (len == 0)

1311 {

1313 (errcode(ERRCODE_LOCK_FILE_EXISTS),

1315 errhint("Either another server is starting, or the lock file is the remnant of a previous server startup crash.")));

1316 }

1317

1318 buffer[len] = '\0';

1319 encoded_pid = atoi(buffer);

1320

1321

1322 other_pid = (pid_t) (encoded_pid < 0 ? -encoded_pid : encoded_pid);

1323

1324 if (other_pid <= 0)

1325 elog(FATAL, "bogus data in lock file \"%s\": \"%s\"",

1327

1328

1329

1330

1331

1332

1333

1334

1335

1336

1337

1338

1339

1340

1341

1342

1343

1344

1345

1346

1347

1348

1349

1350 if (other_pid != my_pid && other_pid != my_p_pid &&

1351 other_pid != my_gp_pid)

1352 {

1353 if (kill(other_pid, 0) == 0 ||

1354 (errno != ESRCH && errno != EPERM))

1355 {

1356

1358 (errcode(ERRCODE_LOCK_FILE_EXISTS),

1359 errmsg("lock file \"%s\" already exists",

1361 isDDLock ?

1362 (encoded_pid < 0 ?

1363 errhint("Is another postgres (PID %d) running in data directory \"%s\"?",

1364 (int) other_pid, refName) :

1365 errhint("Is another postmaster (PID %d) running in data directory \"%s\"?",

1366 (int) other_pid, refName)) :

1367 (encoded_pid < 0 ?

1368 errhint("Is another postgres (PID %d) using socket file \"%s\"?",

1369 (int) other_pid, refName) :

1370 errhint("Is another postmaster (PID %d) using socket file \"%s\"?",

1371 (int) other_pid, refName))));

1372 }

1373 }

1374

1375

1376

1377

1378

1379

1380

1381

1382

1383

1384

1385

1386 if (isDDLock)

1387 {

1388 char *ptr = buffer;

1389 unsigned long id1,

1390 id2;

1391 int lineno;

1392

1394 {

1395 if ((ptr = strchr(ptr, '\n')) == NULL)

1396 break;

1397 ptr++;

1398 }

1399

1400 if (ptr != NULL &&

1401 sscanf(ptr, "%lu %lu", &id1, &id2) == 2)

1402 {

1405 (errcode(ERRCODE_LOCK_FILE_EXISTS),

1406 errmsg("pre-existing shared memory block (key %lu, ID %lu) is still in use",

1407 id1, id2),

1408 errhint("Terminate any old server processes associated with data directory \"%s\".",

1409 refName)));

1410 }

1411 }

1412

1413

1414

1415

1416

1417

1421 errmsg("could not remove old lock file \"%s\": %m",

1423 errhint("The file seems accidentally left over, but "

1424 "it could not be removed. Please remove the file "

1425 "by hand and try again.")));

1426 }

1427

1428

1429

1430

1431

1432

1433

1435 amPostmaster ? (int) my_pid : -((int) my_pid),

1439 socketDir);

1440

1441

1442

1443

1444

1445 if (isDDLock && !amPostmaster)

1446 strlcat(buffer, "\n", sizeof(buffer));

1447

1448 errno = 0;

1450 if (write(fd, buffer, strlen(buffer)) != strlen(buffer))

1451 {

1452 int save_errno = errno;

1453

1456

1457 errno = save_errno ? save_errno : ENOSPC;

1460 errmsg("could not write lock file \"%s\": %m", filename)));

1461 }

1463

1466 {

1467 int save_errno = errno;

1468

1471 errno = save_errno;

1474 errmsg("could not write lock file \"%s\": %m", filename)));

1475 }

1478 {

1479 int save_errno = errno;

1480

1482 errno = save_errno;

1485 errmsg("could not write lock file \"%s\": %m", filename)));

1486 }

1487

1488

1489

1490

1491

1492

1495

1496

1497

1498

1499

1501}

1502

1503

1504

1505

1506

1507

1508

1509

1510

1511

1512

1513void

1515{

1517}

1518

1519

1520

1521

1522void

1524 const char *socketDir)

1525{

1527

1528 snprintf(lockfile, sizeof(lockfile), "%s.lock", socketfile);

1529 CreateLockFile(lockfile, amPostmaster, socketDir, false, socketfile);

1530}

1531

1532

1533

1534

1535

1536

1537

1538

1539

1540void

1542{

1544

1546 {

1547 char *socketLockFile = (char *) lfirst(l);

1548

1549

1551 continue;

1552

1553

1554 (void) utime(socketLockFile, NULL);

1555 }

1556}

1557

1558

1559

1560

1561

1562

1563

1564

1565

1566

1567

1568

1569void

1571{

1572 int fd;

1573 int len;

1574 int lineno;

1575 char *srcptr;

1576 char *destptr;

1577 char srcbuffer[BLCKSZ];

1578 char destbuffer[BLCKSZ];

1579

1581 if (fd < 0)

1582 {

1585 errmsg("could not open file \"%s\": %m",

1587 return;

1588 }

1590 len = read(fd, srcbuffer, sizeof(srcbuffer) - 1);

1592 if (len < 0)

1593 {

1596 errmsg("could not read from file \"%s\": %m",

1599 return;

1600 }

1601 srcbuffer[len] = '\0';

1602

1603

1604

1605

1606

1607 srcptr = srcbuffer;

1608 for (lineno = 1; lineno < target_line; lineno++)

1609 {

1610 char *eol = strchr(srcptr, '\n');

1611

1612 if (eol == NULL)

1613 break;

1614 srcptr = eol + 1;

1615 }

1616 memcpy(destbuffer, srcbuffer, srcptr - srcbuffer);

1617 destptr = destbuffer + (srcptr - srcbuffer);

1618

1619

1620

1621

1622

1623 for (; lineno < target_line; lineno++)

1624 {

1625 if (destptr < destbuffer + sizeof(destbuffer))

1626 *destptr++ = '\n';

1627 }

1628

1629

1630

1631

1632 snprintf(destptr, destbuffer + sizeof(destbuffer) - destptr, "%s\n", str);

1633 destptr += strlen(destptr);

1634

1635

1636

1637

1638 if ((srcptr = strchr(srcptr, '\n')) != NULL)

1639 {

1640 srcptr++;

1641 snprintf(destptr, destbuffer + sizeof(destbuffer) - destptr, "%s",

1642 srcptr);

1643 }

1644

1645

1646

1647

1648

1649 len = strlen(destbuffer);

1650 errno = 0;

1653 {

1655

1656 if (errno == 0)

1657 errno = ENOSPC;

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

1663 return;

1664 }

1668 {

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

1673 }

1676 {

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

1681 }

1682}

1683

1684

1685

1686

1687

1688

1689

1690

1691

1692

1693

1694

1695

1696bool

1698{

1699 int fd;

1700 int len;

1701 long file_pid;

1702 char buffer[BLCKSZ];

1703

1705 if (fd < 0)

1706 {

1707

1708

1709

1710

1711

1712 switch (errno)

1713 {

1714 case ENOENT:

1715 case ENOTDIR:

1716

1719 errmsg("could not open file \"%s\": %m",

1721 return false;

1722 default:

1723

1726 errmsg("could not open file \"%s\": %m; continuing anyway",

1728 return true;

1729 }

1730 }

1732 len = read(fd, buffer, sizeof(buffer) - 1);

1734 if (len < 0)

1735 {

1738 errmsg("could not read from file \"%s\": %m",

1741 return true;

1742 }

1743 buffer[len] = '\0';

1745 file_pid = atol(buffer);

1746 if (file_pid == getpid())

1747 return true;

1748

1749

1751 (errmsg("lock file \"%s\" contains wrong PID: %ld instead of %ld",

1753 return false;

1754}

1755

1756

1757

1758

1759

1760

1761

1762

1763

1764

1765

1766

1767

1768void

1770{

1772 FILE *file;

1773 int ret;

1774 long file_major;

1775 long my_major;

1776 char *endptr;

1777 char file_version_string[64];

1778 const char *my_version_string = PG_VERSION;

1779

1780 my_major = strtol(my_version_string, &endptr, 10);

1781

1782 snprintf(full_path, sizeof(full_path), "%s/PG_VERSION", path);

1783

1785 if (!file)

1786 {

1787 if (errno == ENOENT)

1789 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

1790 errmsg("\"%s\" is not a valid data directory",

1791 path),

1792 errdetail("File \"%s\" is missing.", full_path)));

1793 else

1796 errmsg("could not open file \"%s\": %m", full_path)));

1797 }

1798

1799 file_version_string[0] = '\0';

1800 ret = fscanf(file, "%63s", file_version_string);

1801 file_major = strtol(file_version_string, &endptr, 10);

1802

1803 if (ret != 1 || endptr == file_version_string)

1805 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

1806 errmsg("\"%s\" is not a valid data directory",

1807 path),

1808 errdetail("File \"%s\" does not contain valid data.",

1809 full_path),

1810 errhint("You might need to initdb.")));

1811

1813

1814 if (my_major != file_major)

1816 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

1817 errmsg("database files are incompatible with server"),

1818 errdetail("The data directory was initialized by PostgreSQL version %s, "

1819 "which is not compatible with this version %s.",

1820 file_version_string, my_version_string)));

1821}

1822

1823

1824

1825

1826

1827

1828

1829

1830

1831

1835

1836

1839

1842

1843

1844

1845

1846

1847

1848

1849static void

1850load_libraries(const char *libraries, const char *gucname, bool restricted)

1851{

1852 char *rawstring;

1853 List *elemlist;

1855

1856 if (libraries == NULL || libraries[0] == '\0')

1857 return;

1858

1859

1860 rawstring = pstrdup(libraries);

1861

1862

1864 {

1865

1867 pfree(rawstring);

1869 (errcode(ERRCODE_SYNTAX_ERROR),

1870 errmsg("invalid list syntax in parameter \"%s\"",

1871 gucname)));

1872 return;

1873 }

1874

1875 foreach(l, elemlist)

1876 {

1877

1879 char *expanded = NULL;

1880

1881

1883 {

1886 }

1890 if (expanded)

1891 pfree(expanded);

1892 }

1893

1895 pfree(rawstring);

1896}

1897

1898

1899

1900

1901void

1903{

1906 "shared_preload_libraries",

1907 false);

1910}

1911

1912

1913

1914

1915void

1917{

1919 "session_preload_libraries",

1920 false);

1922 "local_preload_libraries",

1923 true);

1924}

1925

1926

1927

1928

1929void

1931{

1936}

1937

1938void

1940{

1941#ifdef ENABLE_NLS

1943 {

1945

1947 bindtextdomain(domain, locale_path);

1948 pg_bind_textdomain_codeset(domain);

1949 }

1950#endif

1951}

bool InitializingParallelWorker

#define CStringGetTextDatum(s)

#define OidIsValid(objectId)

int find_my_exec(const char *argv0, char *retpath)

void load_file(const char *filename, bool restricted)

int errcode_for_socket_access(void)

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

int errcode_for_file_access(void)

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

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

int errcode(int sqlerrcode)

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

#define ereport(elevel,...)

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

void SetDataDirectoryCreatePerm(int dataDirMode)

#define PG_MODE_MASK_GROUP

#define PG_RETURN_DATUM(x)

char pkglib_path[MAXPGPATH]

bool IsPostmasterEnvironment

char my_exec_path[MAXPGPATH]

void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)

Assert(PointerIsAligned(start, uint64))

#define HeapTupleIsValid(tuple)

static void * GETSTRUCT(const HeapTupleData *tuple)

void SignalHandlerForCrashExit(SIGNAL_ARGS)

void AcceptInvalidationMessages(void)

void on_proc_exit(pg_on_exit_callback function, Datum arg)

void InitializeLatchWaitSet(void)

void SetLatch(Latch *latch)

void InitLatch(Latch *latch)

#define FeBeWaitSetLatchPos

List * lcons(void *datum, List *list)

void list_free_deep(List *list)

char * MemoryContextStrdup(MemoryContext context, const char *string)

char * pstrdup(const char *in)

void pfree(void *pointer)

MemoryContext TopMemoryContext

#define IsBootstrapProcessingMode()

#define AmAutoVacuumWorkerProcess()

#define SECURITY_NOFORCE_RLS

#define AmBackgroundWorkerProcess()

#define SECURITY_RESTRICTED_OPERATION

#define AmLogicalSlotSyncWorkerProcess()

#define SECURITY_LOCAL_USERID_CHANGE

#define AmRegularBackendProcess()

void(* shmem_request_hook_type)(void)

struct SerializedClientConnectionInfo SerializedClientConnectionInfo

void ChangeToDataDir(void)

bool process_shared_preload_libraries_done

void process_shmem_requests(void)

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

void InitStandaloneProcess(const char *argv0)

void SerializeClientConnectionInfo(Size maxsize, char *start_address)

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

void InitializeSessionUserIdStandalone(void)

void AddToDataDirLockFile(int target_line, const char *str)

void InitProcessLocalLatch(void)

void GetUserIdAndSecContext(Oid *userid, int *sec_context)

void SetSessionAuthorization(Oid userid, bool is_superuser)

void process_session_preload_libraries(void)

static bool SessionUserIsSuperuser

bool process_shmem_requests_in_progress

const char * GetSystemUser(void)

bool InSecurityRestrictedOperation(void)

#define DIRECTORY_LOCK_FILE

static const char * SystemUser

bool GetSessionUserIsSuperuser(void)

const char * GetBackendTypeDesc(BackendType backendType)

static int SecurityRestrictionContext

static void SetOuterUserId(Oid userid, bool is_superuser)

Size EstimateClientConnectionInfoSpace(void)

Oid GetSessionUserId(void)

void SetCurrentRoleId(Oid roleid, bool is_superuser)

Oid GetAuthenticatedUserId(void)

bool InLocalUserIdChange(void)

Datum system_user(PG_FUNCTION_ARGS)

void SetDatabasePath(const char *path)

void InitPostmasterChild(void)

char * shared_preload_libraries_string

ClientConnectionInfo MyClientConnectionInfo

void process_shared_preload_libraries(void)

char * session_preload_libraries_string

static void SetSessionUserId(Oid userid, bool is_superuser)

shmem_request_hook_type shmem_request_hook

char * local_preload_libraries_string

static Latch LocalLatchData

void TouchSocketLockFiles(void)

void RestoreClientConnectionInfo(char *conninfo)

static bool SetRoleIsActive

bool InNoForceRLSOperation(void)

static Oid AuthenticatedUserId

static void load_libraries(const char *libraries, const char *gucname, bool restricted)

void SetAuthenticatedUserId(Oid userid)

Oid GetCurrentRoleId(void)

static void UnlinkLockFiles(int status, Datum arg)

void SwitchToSharedLatch(void)

BackendType MyBackendType

void GetUserIdAndContext(Oid *userid, bool *sec_def_context)

void SetDataDir(const char *dir)

void SetUserIdAndContext(Oid userid, bool sec_def_context)

bool process_shared_preload_libraries_in_progress

void pg_bindtextdomain(const char *domain)

bool has_rolreplication(Oid roleid)

char * GetUserNameFromId(Oid roleid, bool noerr)

static void CreateLockFile(const char *filename, bool amPostmaster, const char *socketDir, bool isDDLock, const char *refName)

void ValidatePgVersion(const char *path)

void SetUserIdAndSecContext(Oid userid, int sec_context)

bool RecheckDataDirLockFile(void)

void CreateDataDirLockFile(bool amPostmaster)

void SwitchBackToLocalLatch(void)

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

FormData_pg_authid * Form_pg_authid

static bool is_superuser(Archive *fout)

#define LOCK_FILE_LINE_SHMEM_KEY

void PostmasterDeathSignalInit(void)

void get_pkglib_path(const char *my_exec_path, char *ret_path)

void get_locale_path(const char *my_exec_path, char *ret_path)

char * make_absolute_path(const char *path)

char * first_dir_separator(const char *filename)

size_t strlcat(char *dst, const char *src, size_t siz)

static Datum PointerGetDatum(const void *X)

static Datum ObjectIdGetDatum(Oid X)

void InitProcessGlobals(void)

int postmaster_alive_fds[2]

#define POSTMASTER_FD_WATCH

WaitEventSet * FeBeWaitSet

static int fd(const char *x, int i)

int CountUserBackends(Oid roleid)

char * psprintf(const char *fmt,...)

Size add_size(Size s1, Size s2)

void pgwin32_signal_initialize(void)

bool superuser_arg(Oid roleid)

void ReleaseSysCache(HeapTuple tuple)

HeapTuple SearchSysCache1(int cacheId, Datum key1)

bool PGSharedMemoryIsInUse(unsigned long id1, unsigned long id2)

bool SplitDirectoriesString(char *rawstring, char separator, List **namelist)

static void pgstat_report_wait_start(uint32 wait_event_info)

static void pgstat_report_wait_end(void)

void ModifyWaitEvent(WaitEventSet *set, int pos, uint32 events, Latch *latch)

void InitializeWaitEventSupport(void)