PostgreSQL Source Code: src/backend/utils/adt/pgstatfuncs.c Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

16

34

35#define UINT32_ACCESS_ONCE(var) ((uint32)(*((volatile uint32 *)&(var))))

36

37#define HAS_PGSTAT_PERMISSIONS(role) (has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_STATS) || has_privs_of_role(GetUserId(), role))

38

39#define PG_STAT_GET_RELENTRY_INT64(stat) \

40Datum \

41CppConcat(pg_stat_get_,stat)(PG_FUNCTION_ARGS) \

42{ \

43 Oid relid = PG_GETARG_OID(0); \

44 int64 result; \

45 PgStat_StatTabEntry *tabentry; \

46 \

47 if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL) \

48 result = 0; \

49 else \

50 result = (int64) (tabentry->stat); \

51 \

52 PG_RETURN_INT64(result); \

53}

54

55

57

58

60

61

63

64

66

67

69

70

72

73

75

76

78

79

81

82

84

85

87

88

90

91

93

94

96

97

99

100

102

103

105

106

108

109#define PG_STAT_GET_RELENTRY_FLOAT8(stat) \

110Datum \

111CppConcat(pg_stat_get_,stat)(PG_FUNCTION_ARGS) \

112{ \

113 Oid relid = PG_GETARG_OID(0); \

114 double result; \

115 PgStat_StatTabEntry *tabentry; \

116 \

117 if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL) \

118 result = 0; \

119 else \

120 result = (double) (tabentry->stat); \

121 \

122 PG_RETURN_FLOAT8(result); \

123}

124

125

127

128

130

131

133

134

136

137#define PG_STAT_GET_RELENTRY_TIMESTAMPTZ(stat) \

138Datum \

139CppConcat(pg_stat_get_,stat)(PG_FUNCTION_ARGS) \

140{ \

141 Oid relid = PG_GETARG_OID(0); \

142 TimestampTz result; \

143 PgStat_StatTabEntry *tabentry; \

144 \

145 if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL) \

146 result = 0; \

147 else \

148 result = tabentry->stat; \

149 \

150 if (result == 0) \

151 PG_RETURN_NULL(); \

152 else \

153 PG_RETURN_TIMESTAMPTZ(result); \

154}

155

156

158

159

161

162

164

165

167

168

170

173{

176

180}

181

182

183#define PG_STAT_GET_FUNCENTRY_FLOAT8_MS(stat) \

184Datum \

185CppConcat(pg_stat_get_function_,stat)(PG_FUNCTION_ARGS) \

186{ \

187 Oid funcid = PG_GETARG_OID(0); \

188 double result; \

189 PgStat_StatFuncEntry *funcentry; \

190 \

191 if ((funcentry = pgstat_fetch_stat_funcentry(funcid)) == NULL) \

192 PG_RETURN_NULL(); \

193 result = ((double) funcentry->stat) / 1000.0; \

194 PG_RETURN_FLOAT8(result); \

195}

196

197

199

200

202

205{

207 int *fctx;

208

209

211 {

212

214

216 sizeof(int));

218

219 fctx[0] = 0;

220 }

221

222

225

226 fctx[0] += 1;

227

228

229

230

231

232

233

234

235

236

238 {

239

241

243 }

244 else

245 {

246

248 }

249}

250

251

252

253

256{

257#define PG_STAT_GET_PROGRESS_COLS PGSTAT_NUM_PROGRESS_PARAM + 3

259 int curr_backend;

263

264

271 else if (pg_strcasecmp(cmd, "CREATE INDEX") == 0)

277 else

279 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

280 errmsg("invalid command name: \"%s\"", cmd)));

281

283

284

285 for (curr_backend = 1; curr_backend <= num_backends; curr_backend++)

286 {

291 int i;

292

295

296

297

298

299

301 continue;

302

303

306

307

309 {

313 }

314 else

315 {

316 nulls[2] = true;

318 nulls[i + 3] = true;

319 }

320

322 }

323

324 return (Datum) 0;

325}

326

327

328

329

332{

333#define PG_STAT_GET_ACTIVITY_COLS 31

335 int curr_backend;

338

340

341

342 for (curr_backend = 1; curr_backend <= num_backends; curr_backend++)

343 {

344

350 const char *wait_event_type = NULL;

351 const char *wait_event = NULL;

352

353

356

357

358 if (pid != -1 && beentry->st_procpid != pid)

359 continue;

360

361

364 else

365 nulls[0] = true;

366

368

371 else

372 nulls[2] = true;

373

376 else

377 nulls[3] = true;

378

381 else

382 nulls[15] = true;

383

386 else

387 nulls[16] = true;

388

389

391 {

392 char *clipped_activity;

393

395 {

398 break;

401 break;

404 break;

407 break;

410 break;

413 break;

416 break;

418 nulls[4] = true;

419 break;

420 }

421

424 pfree(clipped_activity);

425

426

427 nulls[29] = true;

428

430

432 {

433

434

435

436

438 }

439

440

441

442

443

444

445

446 if (proc != NULL)

447 {

448 uint32 raw_wait_event;

450

454

456

457

458

459

460

461

462 if (leader && leader->pid != beentry->st_procpid)

463 {

465 nulls[29] = false;

466 }

468 {

470

472 {

474 nulls[29] = false;

475 }

476 }

477 }

478

479 if (wait_event_type)

481 else

482 nulls[6] = true;

483

484 if (wait_event)

486 else

487 nulls[7] = true;

488

489

490

491

492

493

497 else

498 nulls[8] = true;

499

502 else

503 nulls[9] = true;

504

507 else

508 nulls[10] = true;

509

512 else

513 nulls[11] = true;

514

515

518 {

519 nulls[12] = true;

520 nulls[13] = true;

521 nulls[14] = true;

522 }

523 else

524 {

527 {

528 char remote_host[NI_MAXHOST];

529 char remote_port[NI_MAXSERV];

530 int ret;

531

532 remote_host[0] = '\0';

533 remote_port[0] = '\0';

536 remote_host, sizeof(remote_host),

537 remote_port, sizeof(remote_port),

538 NI_NUMERICHOST | NI_NUMERICSERV);

539 if (ret == 0)

540 {

547 else

548 nulls[13] = true;

550 }

551 else

552 {

553 nulls[12] = true;

554 nulls[13] = true;

555 nulls[14] = true;

556 }

557 }

559 {

560

561

562

563

564

565

566 nulls[12] = true;

567 nulls[13] = true;

569 }

570 else

571 {

572

573 nulls[12] = true;

574 nulls[13] = true;

575 nulls[14] = true;

576 }

577 }

578

580 {

581 const char *bgw_type;

582

584 if (bgw_type)

586 else

587 nulls[17] = true;

588 }

589 else

592

593

595 {

600

603 else

604 nulls[22] = true;

605

611 else

612 nulls[23] = true;

613

616 else

617 nulls[24] = true;

618 }

619 else

620 {

622 nulls[19] = nulls[20] = nulls[21] = nulls[22] = nulls[23] = nulls[24] = true;

623 }

624

625

627 {

632

633 }

634 else

635 {

637 nulls[26] = true;

639

641

642 }

644 nulls[30] = true;

645 else

647 }

648 else

649 {

650

652 nulls[4] = true;

653 nulls[6] = true;

654 nulls[7] = true;

655 nulls[8] = true;

656 nulls[9] = true;

657 nulls[10] = true;

658 nulls[11] = true;

659 nulls[12] = true;

660 nulls[13] = true;

661 nulls[14] = true;

662 nulls[17] = true;

663 nulls[18] = true;

664 nulls[19] = true;

665 nulls[20] = true;

666 nulls[21] = true;

667 nulls[22] = true;

668 nulls[23] = true;

669 nulls[24] = true;

670 nulls[25] = true;

671 nulls[26] = true;

672 nulls[27] = true;

673 nulls[28] = true;

674 nulls[29] = true;

675 nulls[30] = true;

676 }

677

679

680

681 if (pid != -1)

682 break;

683 }

684

685 return (Datum) 0;

686}

687

688

691{

693}

694

695

698{

701

704

706}

707

708

711{

714

717

719}

720

721

724{

727

730

732}

733

736{

737#define PG_STAT_GET_SUBXACT_COLS 2

743

744

747 INT4OID, -1, 0);

749 BOOLOID, -1, 0);

750

752

754 {

755

758 }

759 else

760 {

761 nulls[0] = true;

762 nulls[1] = true;

763 }

764

765

767}

768

771{

774 const char *activity;

775 char *clipped_activity;

777

779 activity = "";

781 activity = "";

783 activity = "";

784 else

786

789 pfree(clipped_activity);

790

792}

793

796{

800 const char *wait_event_type = NULL;

801

803 wait_event_type = "";

805 wait_event_type = "";

808

809 if (!wait_event_type)

811

813}

814

817{

821 const char *wait_event = NULL;

822

824 wait_event = "";

826 wait_event = "";

829

830 if (!wait_event)

832

834}

835

836

839{

843

846

849

851

852

853

854

855

856 if (result == 0)

858

860}

861

862

865{

869

872

875

877

878 if (result == 0)

880

882}

883

884

887{

891

894

897

899

900 if (result == 0)

902

904}

905

906

909{

912 char remote_host[NI_MAXHOST];

913 int ret;

914

917

920

921

925

927 {

928 case AF_INET:

929 case AF_INET6:

930 break;

931 default:

933 }

934

935 remote_host[0] = '\0';

938 remote_host, sizeof(remote_host),

939 NULL, 0,

940 NI_NUMERICHOST | NI_NUMERICSERV);

941 if (ret != 0)

943

945

948}

949

952{

955 char remote_port[NI_MAXSERV];

956 int ret;

957

960

963

964

968

970 {

971 case AF_INET:

972 case AF_INET6:

973 break;

974 case AF_UNIX:

976 default:

978 }

979

980 remote_port[0] = '\0';

983 NULL, 0,

984 remote_port, sizeof(remote_port),

985 NI_NUMERICHOST | NI_NUMERICSERV);

986 if (ret != 0)

988

991}

992

993

996{

1000 int idx;

1001

1002 result = 0;

1003 for (idx = 1; idx <= tot_backends; idx++)

1004 {

1006

1008 result++;

1009 }

1010

1012}

1013

1014

1015#define PG_STAT_GET_DBENTRY_INT64(stat) \

1016Datum \

1017CppConcat(pg_stat_get_db_,stat)(PG_FUNCTION_ARGS) \

1018{ \

1019 Oid dbid = PG_GETARG_OID(0); \

1020 int64 result; \

1021 PgStat_StatDBEntry *dbentry; \

1022 \

1023 if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL) \

1024 result = 0; \

1025 else \

1026 result = (int64) (dbentry->stat); \

1027 \

1028 PG_RETURN_INT64(result); \

1029}

1030

1031

1033

1034

1036

1037

1039

1040

1042

1043

1045

1046

1048

1049

1051

1052

1054

1055

1057

1058

1060

1061

1063

1064

1066

1067

1069

1070

1072

1073

1075

1076

1078

1079

1081

1082

1084

1085

1087

1088

1090

1091

1093

1094

1096

1097

1099

1100

1102

1105{

1109

1111 result = 0;

1112 else

1114

1115 if (result == 0)

1117 else

1119}

1120

1121

1124{

1128

1130 result = 0;

1131 else

1138

1140}

1141

1144{

1148

1151

1153 result = 0;

1154 else

1156

1158}

1159

1162{

1166

1169

1171 result = 0;

1172 else

1174

1175 if (result == 0)

1177 else

1179}

1180

1181

1182#define PG_STAT_GET_DBENTRY_FLOAT8_MS(stat) \

1183Datum \

1184CppConcat(pg_stat_get_db_,stat)(PG_FUNCTION_ARGS) \

1185{ \

1186 Oid dbid = PG_GETARG_OID(0); \

1187 double result; \

1188 PgStat_StatDBEntry *dbentry; \

1189 \

1190 if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL) \

1191 result = 0; \

1192 else \

1193 result = ((double) dbentry->stat) / 1000.0; \

1194 \

1195 PG_RETURN_FLOAT8(result); \

1196}

1197

1198

1200

1201

1203

1204

1206

1207

1209

1210

1212

1215{

1217}

1218

1221{

1223}

1224

1227{

1229}

1230

1233{

1235}

1236

1239{

1241}

1242

1245{

1247}

1248

1251{

1253}

1254

1257{

1259}

1260

1263{

1265}

1266

1269{

1271}

1272

1275{

1276

1279}

1280

1283{

1284

1287}

1288

1291{

1293}

1294

1297{

1299}

1300

1303{

1305}

1306

1307

1308

1309

1310

1311

1313{

1337

1338

1339

1340

1341

1344{

1345 switch (io_op)

1346 {

1363 }

1364

1365 elog(ERROR, "unrecognized IOOp value: %d", io_op);

1367}

1368

1369

1370

1371

1372

1375{

1376 switch (io_op)

1377 {

1390 }

1391

1392 elog(ERROR, "unrecognized IOOp value: %d", io_op);

1394}

1395

1396

1397

1398

1399

1402{

1403 switch (io_op)

1404 {

1419 }

1420

1421 elog(ERROR, "unrecognized IOOp value: %d", io_op);

1423}

1424

1425static inline double

1427{

1428 return val_ms * (double) 0.001;

1429}

1430

1431

1432

1433

1434

1435

1436

1437

1438static void

1443{

1445

1447 {

1449

1450 for (int io_context = 0; io_context < IOCONTEXT_NUM_TYPES; io_context++)

1451 {

1453

1456

1457

1458

1459

1460

1461

1463 continue;

1464

1468 if (stat_reset_timestamp != 0)

1470 else

1472

1473 for (int io_op = 0; io_op < IOOP_NUM_TYPES; io_op++)

1474 {

1478

1479

1480

1481

1482

1483

1485 {

1487 bktype_stats->counts[io_obj][io_context][io_op];

1488

1490 }

1491 else

1492 nulls[op_idx] = true;

1493

1494 if (!nulls[op_idx])

1495 {

1496

1498 {

1500 bktype_stats->times[io_obj][io_context][io_op];

1501

1503 }

1504

1505

1507 {

1508 char buf[256];

1510 bktype_stats->bytes[io_obj][io_context][io_op];

1511

1512

1518 }

1519 }

1520 else

1521 {

1523 nulls[time_idx] = true;

1525 nulls[byte_idx] = true;

1526 }

1527 }

1528

1531 }

1532 }

1533}

1534

1537{

1540

1543

1545

1547 {

1549

1550

1551

1552

1553

1554

1555

1557

1558

1559

1560

1561

1563 continue;

1564

1565

1568 }

1569

1570 return (Datum) 0;

1571}

1572

1573

1574

1575

1578{

1581 int pid;

1584

1587

1590

1591 if (!backend_stats)

1592 return (Datum) 0;

1593

1594 bktype_stats = &backend_stats->io_stats;

1595

1596

1597

1598

1599

1600

1602

1603

1606 return (Datum) 0;

1607}

1608

1609

1610

1611

1612

1613

1614

1618{

1619#define PG_STAT_WAL_COLS 5

1623 char buf[256];

1624

1625

1628 INT8OID, -1, 0);

1630 INT8OID, -1, 0);

1632 NUMERICOID, -1, 0);

1634 INT8OID, -1, 0);

1636 TIMESTAMPTZOID, -1, 0);

1637

1639

1640

1643

1644

1650

1652

1653 if (stat_reset_timestamp != 0)

1655 else

1656 nulls[4] = true;

1657

1658

1660}

1661

1662

1663

1664

1667{

1668 int pid;

1671

1674

1675 if (!backend_stats)

1677

1679

1680

1682}

1683

1684

1685

1686

1689{

1691

1692

1694

1697}

1698

1699

1700

1701

1704{

1705#define PG_STAT_GET_SLRU_COLS 9

1707 int i;

1709

1711

1712

1714

1715 for (i = 0;; i++)

1716 {

1717

1721 const char *name;

1722

1724

1726 break;

1727

1728 stat = stats[i];

1729

1739

1741 }

1742

1743 return (Datum) 0;

1744}

1745

1746#define PG_STAT_GET_XACT_RELENTRY_INT64(stat) \

1747Datum \

1748CppConcat(pg_stat_get_xact_,stat)(PG_FUNCTION_ARGS) \

1749{ \

1750 Oid relid = PG_GETARG_OID(0); \

1751 int64 result; \

1752 PgStat_TableStatus *tabentry; \

1753 \

1754 if ((tabentry = find_tabstat_entry(relid)) == NULL) \

1755 result = 0; \

1756 else \

1757 result = (int64) (tabentry->counts.stat); \

1758 \

1759 PG_RETURN_INT64(result); \

1760}

1761

1762

1764

1765

1767

1768

1770

1771

1773

1774

1776

1777

1779

1780

1782

1783

1785

1786

1788

1789

1791

1794{

1797

1801}

1802

1803#define PG_STAT_GET_XACT_FUNCENTRY_FLOAT8_MS(stat) \

1804Datum \

1805CppConcat(pg_stat_get_xact_function_,stat)(PG_FUNCTION_ARGS) \

1806{ \

1807 Oid funcid = PG_GETARG_OID(0); \

1808 PgStat_FunctionCounts *funcentry; \

1809 \

1810 if ((funcentry = find_funcstat_entry(funcid)) == NULL) \

1811 PG_RETURN_NULL(); \

1812 PG_RETURN_FLOAT8(INSTR_TIME_GET_MILLISEC(funcentry->stat)); \

1813}

1814

1815

1817

1818

1820

1821

1824{

1825 bool have_snapshot;

1827

1829

1830 if (!have_snapshot)

1832

1834}

1835

1836

1839{

1841

1843}

1844

1845

1846

1849{

1851

1853}

1854

1855

1856

1859{

1861

1863}

1864

1865

1866

1867

1868

1869

1870

1873{

1874 char *target = NULL;

1875

1877 {

1878

1886

1888 }

1889

1891

1892 if (strcmp(target, "archiver") == 0)

1894 else if (strcmp(target, "bgwriter") == 0)

1896 else if (strcmp(target, "checkpointer") == 0)

1898 else if (strcmp(target, "io") == 0)

1900 else if (strcmp(target, "recovery_prefetch") == 0)

1902 else if (strcmp(target, "slru") == 0)

1904 else if (strcmp(target, "wal") == 0)

1906 else

1908 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

1909 errmsg("unrecognized reset target: \"%s\"", target),

1910 errhint("Target must be \"archiver\", \"bgwriter\", \"checkpointer\", \"io\", \"recovery_prefetch\", \"slru\", or \"wal\".")));

1911

1913}

1914

1915

1916

1917

1918

1921{

1924

1926

1928}

1929

1932{

1934

1936

1938}

1939

1940

1941

1942

1945{

1950

1952

1953

1954 if (!proc)

1956

1957 if (!proc)

1959

1961

1963 if (!beentry)

1965

1966

1969

1971

1973}

1974

1975

1978{

1979 char *target = NULL;

1980

1983 else

1984 {

1987 }

1988

1990}

1991

1992

1995{

1996 char *target = NULL;

1997

2000 else

2001 {

2004 }

2005

2007}

2008

2009

2012{

2013 Oid subid;

2014

2016 {

2017

2019 }

2020 else

2021 {

2023

2026 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

2027 errmsg("invalid subscription OID %u", subid)));

2029 }

2030

2032}

2033

2036{

2039 bool nulls[7] = {0};

2041

2042

2045 INT8OID, -1, 0);

2047 TEXTOID, -1, 0);

2049 TIMESTAMPTZOID, -1, 0);

2051 INT8OID, -1, 0);

2053 TEXTOID, -1, 0);

2055 TIMESTAMPTZOID, -1, 0);

2057 TIMESTAMPTZOID, -1, 0);

2058

2060

2061

2063

2064

2067 nulls[1] = true;

2068 else

2070

2072 nulls[2] = true;

2073 else

2075

2078 nulls[4] = true;

2079 else

2081

2083 nulls[5] = true;

2084 else

2086

2088 nulls[6] = true;

2089 else

2091

2092

2094}

2095

2096

2097

2098

2099

2102{

2103#define PG_STAT_GET_REPLICATION_SLOT_COLS 10

2111

2112

2115 TEXTOID, -1, 0);

2117 INT8OID, -1, 0);

2119 INT8OID, -1, 0);

2121 INT8OID, -1, 0);

2123 INT8OID, -1, 0);

2125 INT8OID, -1, 0);

2127 INT8OID, -1, 0);

2129 INT8OID, -1, 0);

2131 INT8OID, -1, 0);

2133 TIMESTAMPTZOID, -1, 0);

2135

2138 if (!slotent)

2139 {

2140

2141

2142

2143

2145 slotent = &allzero;

2146 }

2147

2157

2159 nulls[9] = true;

2160 else

2162

2163

2165}

2166

2167

2168

2169

2170

2173{

2174#define PG_STAT_GET_SUBSCRIPTION_STATS_COLS 11

2181 int i = 0;

2182

2183

2185

2186

2189 OIDOID, -1, 0);

2191 INT8OID, -1, 0);

2193 INT8OID, -1, 0);

2195 INT8OID, -1, 0);

2197 INT8OID, -1, 0);

2199 INT8OID, -1, 0);

2201 INT8OID, -1, 0);

2203 INT8OID, -1, 0);

2205 INT8OID, -1, 0);

2207 INT8OID, -1, 0);

2209 TIMESTAMPTZOID, -1, 0);

2211

2212 if (!subentry)

2213 {

2214

2216 subentry = &allzero;

2217 }

2218

2219

2221

2222

2224

2225

2227

2228

2229 for (int nconflict = 0; nconflict < CONFLICT_NUM_TYPES; nconflict++)

2231

2232

2234 nulls[i] = true;

2235 else

2237

2239

2240

2242}

2243

2244

2245

2246

2247

2248

2249

2250

2253{

2258

2260}

Datum idx(PG_FUNCTION_ARGS)

Datum numeric_in(PG_FUNCTION_ARGS)

#define PGSTAT_NUM_PROGRESS_PARAM

@ PROGRESS_COMMAND_ANALYZE

@ PROGRESS_COMMAND_CLUSTER

@ PROGRESS_COMMAND_CREATE_INDEX

@ PROGRESS_COMMAND_VACUUM

@ PROGRESS_COMMAND_BASEBACKUP

int pgstat_fetch_stat_numbackends(void)

LocalPgBackendStatus * pgstat_get_local_beentry_by_proc_number(ProcNumber procNumber)

char * pgstat_clip_activity(const char *raw_activity)

LocalPgBackendStatus * pgstat_get_local_beentry_by_index(int idx)

PgBackendStatus * pgstat_get_beentry_by_proc_number(ProcNumber procNumber)

@ STATE_IDLEINTRANSACTION_ABORTED

@ STATE_IDLEINTRANSACTION

const char * GetBackgroundWorkerTypeByPid(pid_t pid)

static Datum values[MAXATTR]

#define CStringGetTextDatum(s)

#define OidIsValid(objectId)

bool IsSharedRelation(Oid relationId)

#define CONFLICT_NUM_TYPES

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

int errcode(int sqlerrcode)

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

#define ereport(elevel,...)

TupleDesc BlessTupleDesc(TupleDesc tupdesc)

Datum Int64GetDatum(int64 X)

Datum Float8GetDatum(float8 X)

#define PG_GETARG_TEXT_PP(n)

#define PG_RETURN_FLOAT8(x)

#define PG_RETURN_INT64(x)

#define DirectFunctionCall1(func, arg1)

#define PG_GETARG_INT64(n)

#define PG_RETURN_TEXT_P(x)

#define PG_RETURN_INT32(x)

#define PG_GETARG_INT32(n)

#define PG_RETURN_DATUM(x)

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

#define PG_RETURN_BOOL(x)

#define PG_GETARG_TEXT_P(n)

void InitMaterializedSRF(FunctionCallInfo fcinfo, bits32 flags)

#define SRF_IS_FIRSTCALL()

#define SRF_PERCALL_SETUP()

#define SRF_RETURN_NEXT(_funcctx, _result)

#define SRF_FIRSTCALL_INIT()

static Datum HeapTupleGetDatum(const HeapTupleData *tuple)

#define SRF_RETURN_DONE(_funcctx)

Assert(PointerIsAligned(start, uint64))

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

Datum int4in(PG_FUNCTION_ARGS)

int pg_getnameinfo_all(const struct sockaddr_storage *addr, int salen, char *node, int nodelen, char *service, int servicelen, int flags)

if(TABLE==NULL||TABLE_index==NULL)

pid_t GetLeaderApplyWorkerPid(pid_t pid)

void * MemoryContextAlloc(MemoryContext context, Size size)

void pfree(void *pointer)

static bool pg_memory_is_all_zeros(const void *ptr, size_t len)

#define BACKEND_NUM_TYPES

const char * GetBackendTypeDesc(BackendType backendType)

void namestrcpy(Name name, const char *str)

void clean_ipv6_addr(int addr_family, char *addr)

Datum inet_in(PG_FUNCTION_ARGS)

void pgstat_reset(PgStat_Kind kind, Oid dboid, uint64 objid)

void pgstat_reset_counters(void)

void pgstat_reset_of_kind(PgStat_Kind kind)

void pgstat_force_next_flush(void)

void pgstat_clear_snapshot(void)

TimestampTz pgstat_get_stat_snapshot_timestamp(bool *have_snapshot)

bool pgstat_have_entry(PgStat_Kind kind, Oid dboid, uint64 objid)

PgStat_Kind pgstat_get_kind_from_str(char *kind_str)

#define IOCONTEXT_NUM_TYPES

#define IOOBJECT_NUM_TYPES

PgStat_ArchiverStats * pgstat_fetch_stat_archiver(void)

bool pgstat_tracks_backend_bktype(BackendType bktype)

PgStat_Backend * pgstat_fetch_stat_backend_by_pid(int pid, BackendType *bktype)

PgStat_BgWriterStats * pgstat_fetch_stat_bgwriter(void)

PgStat_CheckpointerStats * pgstat_fetch_stat_checkpointer(void)

PgStat_StatDBEntry * pgstat_fetch_stat_dbentry(Oid dboid)

PgStat_StatFuncEntry * pgstat_fetch_stat_funcentry(Oid func_id)

PgStat_FunctionCounts * find_funcstat_entry(Oid func_id)

PgStat_IO * pgstat_fetch_stat_io(void)

const char * pgstat_get_io_context_name(IOContext io_context)

bool pgstat_tracks_io_bktype(BackendType bktype)

const char * pgstat_get_io_object_name(IOObject io_object)

bool pgstat_bktype_io_stats_valid(PgStat_BktypeIO *backend_io, BackendType bktype)

bool pgstat_tracks_io_op(BackendType bktype, IOObject io_object, IOContext io_context, IOOp io_op)

bool pgstat_tracks_io_object(BackendType bktype, IOObject io_object, IOContext io_context)

#define PGSTAT_KIND_ARCHIVER

#define PGSTAT_KIND_BGWRITER

#define PGSTAT_KIND_REPLSLOT

#define PGSTAT_KIND_FUNCTION

#define PGSTAT_KIND_RELATION

#define PGSTAT_KIND_CHECKPOINTER

#define PGSTAT_KIND_SUBSCRIPTION

#define PGSTAT_KIND_BACKEND

void pgstat_reset_replslot(const char *name)

PgStat_StatReplSlotEntry * pgstat_fetch_replslot(NameData slotname)

PgStat_SLRUStats * pgstat_fetch_slru(void)

const char * pgstat_get_slru_name(int slru_idx)

void pgstat_reset_slru(const char *name)

PgStat_StatSubEntry * pgstat_fetch_stat_subscription(Oid subid)

PgStat_WalStats * pgstat_fetch_stat_wal(void)

#define PG_STAT_GET_XACT_RELENTRY_INT64(stat)

Datum pg_stat_get_progress_info(PG_FUNCTION_ARGS)

Datum pg_stat_get_checkpointer_num_requested(PG_FUNCTION_ARGS)

Datum pg_stat_get_snapshot_timestamp(PG_FUNCTION_ARGS)

Datum pg_stat_get_backend_client_addr(PG_FUNCTION_ARGS)

Datum pg_stat_get_db_stat_reset_time(PG_FUNCTION_ARGS)

Datum pg_stat_get_wal(PG_FUNCTION_ARGS)

Datum pg_stat_reset_replication_slot(PG_FUNCTION_ARGS)

Datum pg_stat_get_checkpointer_num_timed(PG_FUNCTION_ARGS)

#define UINT32_ACCESS_ONCE(var)

Datum pg_stat_get_activity(PG_FUNCTION_ARGS)

Datum pg_stat_get_slru(PG_FUNCTION_ARGS)

static void pg_stat_io_build_tuples(ReturnSetInfo *rsinfo, PgStat_BktypeIO *bktype_stats, BackendType bktype, TimestampTz stat_reset_timestamp)

Datum pg_stat_get_backend_client_port(PG_FUNCTION_ARGS)

Datum pg_stat_get_backend_start(PG_FUNCTION_ARGS)

Datum pg_stat_get_db_conflict_all(PG_FUNCTION_ARGS)

Datum pg_stat_get_subscription_stats(PG_FUNCTION_ARGS)

#define PG_STAT_GET_SLRU_COLS

#define PG_STAT_GET_DBENTRY_INT64(stat)

Datum pg_stat_get_checkpointer_buffers_written(PG_FUNCTION_ARGS)

Datum pg_stat_get_backend_pid(PG_FUNCTION_ARGS)

Datum pg_stat_get_checkpointer_sync_time(PG_FUNCTION_ARGS)

static double pg_stat_us_to_ms(PgStat_Counter val_ms)

#define PG_STAT_GET_ACTIVITY_COLS

static Datum pg_stat_wal_build_tuple(PgStat_WalCounters wal_counters, TimestampTz stat_reset_timestamp)

static io_stat_col pgstat_get_io_time_index(IOOp io_op)

Datum pg_stat_get_backend_activity(PG_FUNCTION_ARGS)

#define PG_STAT_GET_FUNCENTRY_FLOAT8_MS(stat)

Datum pg_stat_get_db_numbackends(PG_FUNCTION_ARGS)

Datum pg_stat_get_db_checksum_failures(PG_FUNCTION_ARGS)

Datum pg_stat_reset_subscription_stats(PG_FUNCTION_ARGS)

Datum pg_stat_clear_snapshot(PG_FUNCTION_ARGS)

Datum pg_stat_reset_slru(PG_FUNCTION_ARGS)

Datum pg_stat_get_checkpointer_restartpoints_requested(PG_FUNCTION_ARGS)

Datum pg_stat_get_checkpointer_num_performed(PG_FUNCTION_ARGS)

Datum pg_stat_get_db_checksum_last_failure(PG_FUNCTION_ARGS)

Datum pg_stat_get_backend_wal(PG_FUNCTION_ARGS)

static io_stat_col pgstat_get_io_op_index(IOOp io_op)

Datum pg_stat_have_stats(PG_FUNCTION_ARGS)

Datum pg_stat_get_backend_idset(PG_FUNCTION_ARGS)

Datum pg_stat_get_backend_wait_event_type(PG_FUNCTION_ARGS)

static io_stat_col pgstat_get_io_byte_index(IOOp io_op)

#define PG_STAT_GET_SUBSCRIPTION_STATS_COLS

Datum pg_stat_get_bgwriter_maxwritten_clean(PG_FUNCTION_ARGS)

Datum pg_stat_get_bgwriter_buf_written_clean(PG_FUNCTION_ARGS)

Datum pg_stat_get_io(PG_FUNCTION_ARGS)

Datum pg_stat_get_checkpointer_restartpoints_performed(PG_FUNCTION_ARGS)

#define PG_STAT_GET_DBENTRY_FLOAT8_MS(stat)

Datum pg_stat_get_backend_userid(PG_FUNCTION_ARGS)

Datum pg_stat_reset(PG_FUNCTION_ARGS)

Datum pg_stat_get_backend_wait_event(PG_FUNCTION_ARGS)

#define PG_STAT_GET_SUBXACT_COLS

#define PG_STAT_GET_XACT_FUNCENTRY_FLOAT8_MS(stat)

#define PG_STAT_GET_RELENTRY_INT64(stat)

Datum pg_stat_get_backend_dbid(PG_FUNCTION_ARGS)

Datum pg_stat_get_xact_function_calls(PG_FUNCTION_ARGS)

#define PG_STAT_GET_RELENTRY_TIMESTAMPTZ(stat)

Datum pg_stat_reset_backend_stats(PG_FUNCTION_ARGS)

#define PG_STAT_GET_PROGRESS_COLS

Datum pg_stat_get_checkpointer_write_time(PG_FUNCTION_ARGS)

#define HAS_PGSTAT_PERMISSIONS(role)

Datum pg_stat_get_backend_io(PG_FUNCTION_ARGS)

Datum pg_stat_get_checkpointer_slru_written(PG_FUNCTION_ARGS)

#define PG_STAT_GET_RELENTRY_FLOAT8(stat)

Datum pg_stat_get_archiver(PG_FUNCTION_ARGS)

Datum pg_stat_get_checkpointer_restartpoints_timed(PG_FUNCTION_ARGS)

Datum pg_stat_reset_shared(PG_FUNCTION_ARGS)

Datum pg_stat_force_next_flush(PG_FUNCTION_ARGS)

Datum pg_stat_reset_single_table_counters(PG_FUNCTION_ARGS)

Datum pg_stat_get_bgwriter_stat_reset_time(PG_FUNCTION_ARGS)

Datum pg_stat_get_backend_xact_start(PG_FUNCTION_ARGS)

Datum pg_stat_get_checkpointer_stat_reset_time(PG_FUNCTION_ARGS)

Datum pg_stat_get_function_calls(PG_FUNCTION_ARGS)

Datum pg_stat_get_backend_subxact(PG_FUNCTION_ARGS)

Datum pg_stat_get_replication_slot(PG_FUNCTION_ARGS)

Datum pg_stat_get_backend_activity_start(PG_FUNCTION_ARGS)

Datum pg_stat_reset_single_function_counters(PG_FUNCTION_ARGS)

Datum pg_stat_get_buf_alloc(PG_FUNCTION_ARGS)

Datum pg_backend_pid(PG_FUNCTION_ARGS)

#define PG_STAT_GET_REPLICATION_SLOT_COLS

int pg_strcasecmp(const char *s1, const char *s2)

static Datum PointerGetDatum(const void *X)

static Datum TransactionIdGetDatum(TransactionId X)

static Datum UInt64GetDatum(uint64 X)

static Datum BoolGetDatum(bool X)

static Datum ObjectIdGetDatum(Oid X)

static Datum CStringGetDatum(const char *X)

static Datum Int32GetDatum(int32 X)

#define GetNumberFromPGProc(proc)

PGPROC * BackendPidGetProc(int pid)

PGPROC * AuxiliaryPidGetProc(int pid)

MemoryContext multi_call_memory_ctx

TransactionId backend_xid

PgBackendStatus backendStatus

int backend_subxact_count

TransactionId backend_xmin

bool backend_subxact_overflowed

char gss_princ[NAMEDATALEN]

char ssl_version[NAMEDATALEN]

char ssl_cipher[NAMEDATALEN]

char ssl_client_dn[NAMEDATALEN]

char ssl_client_serial[NAMEDATALEN]

char ssl_issuer_dn[NAMEDATALEN]

BackendType st_backendType

TimestampTz st_state_start_timestamp

TimestampTz st_proc_start_timestamp

PgBackendGSSStatus * st_gssstatus

TimestampTz st_activity_start_timestamp

ProgressCommandType st_progress_command

int64 st_progress_param[PGSTAT_NUM_PROGRESS_PARAM]

PgBackendSSLStatus * st_sslstatus

TimestampTz st_xact_start_timestamp

Oid st_progress_command_target

TimestampTz last_failed_timestamp

TimestampTz stat_reset_timestamp

TimestampTz last_archived_timestamp

char last_failed_wal[MAX_XFN_CHARS+1]

PgStat_Counter failed_count

PgStat_Counter archived_count

char last_archived_wal[MAX_XFN_CHARS+1]

TimestampTz stat_reset_timestamp

PgStat_WalCounters wal_counters

PgStat_Counter times[IOOBJECT_NUM_TYPES][IOCONTEXT_NUM_TYPES][IOOP_NUM_TYPES]

uint64 bytes[IOOBJECT_NUM_TYPES][IOCONTEXT_NUM_TYPES][IOOP_NUM_TYPES]

PgStat_Counter counts[IOOBJECT_NUM_TYPES][IOCONTEXT_NUM_TYPES][IOOP_NUM_TYPES]

PgStat_BktypeIO stats[BACKEND_NUM_TYPES]

TimestampTz stat_reset_timestamp

PgStat_Counter conflict_startup_deadlock

PgStat_Counter conflict_lock

TimestampTz stat_reset_timestamp

PgStat_Counter conflict_snapshot

TimestampTz last_checksum_failure

PgStat_Counter conflict_bufferpin

PgStat_Counter conflict_logicalslot

PgStat_Counter checksum_failures

PgStat_Counter conflict_tablespace

TimestampTz stat_reset_timestamp

PgStat_Counter stream_count

PgStat_Counter total_txns

PgStat_Counter total_bytes

PgStat_Counter spill_txns

PgStat_Counter stream_txns

PgStat_Counter spill_count

PgStat_Counter stream_bytes

PgStat_Counter spill_bytes

PgStat_Counter apply_error_count

PgStat_Counter sync_error_count

PgStat_Counter conflict_count[CONFLICT_NUM_TYPES]

TimestampTz stat_reset_timestamp

PgStat_Counter wal_buffers_full

PgStat_Counter wal_records

TimestampTz stat_reset_timestamp

PgStat_WalCounters wal_counters

Tuplestorestate * setResult

struct sockaddr_storage addr

#define TransactionIdIsValid(xid)

TupleDesc CreateTemplateTupleDesc(int natts)

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

void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, const Datum *values, const bool *isnull)

static Datum TimestampTzGetDatum(TimestampTz X)

#define PG_RETURN_TIMESTAMPTZ(x)

text * cstring_to_text(const char *s)

char * text_to_cstring(const text *t)

const char * pgstat_get_wait_event_type(uint32 wait_event_info)

const char * pgstat_get_wait_event(uint32 wait_event_info)

bool DataChecksumsEnabled(void)

void XLogPrefetchResetStats(void)