PostgreSQL Source Code: src/backend/tcop/postgres.c Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

21

22#include <fcntl.h>

23#include <limits.h>

24#include <signal.h>

29

30#ifdef USE_VALGRIND

31#include <valgrind/valgrind.h>

32#endif

33

83

84

85

86

87

89

90

92

93

95

97

98

100

101

103

104

106

107

108

109

110

111

112

114{

116 int paramno;

117 const char *paramval;

119

120

121

122

123

124

125

126

127

128

130

131

132

133

134

135

137

138

139

140

141

144

145

146

147

148

149

151

152

153static const char *userDoption = NULL;

154static bool EchoQuery = false;

156

157

160

161

164

165

166

167

168

188

189

190

191

192

193

194#ifdef USE_VALGRIND

195

196static unsigned int old_valgrind_error_count;

197

198

199

200

201

202

203static void

205{

206 unsigned int valgrind_error_count = VALGRIND_COUNT_ERRORS;

207

208 if (unlikely(valgrind_error_count != old_valgrind_error_count) &&

209 query != NULL)

210 VALGRIND_PRINTF("Valgrind detected %u error(s) during execution of \"%s\"\n",

211 valgrind_error_count - old_valgrind_error_count,

212 query);

213}

214

215#else

216#define valgrind_report_error_query(query) ((void) 0)

217#endif

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235static int

237{

238 int c;

239

240

241

242

245

247

248

249

250

252 {

253 if (c == '\n')

254 {

256 {

257

258

259

260

261 if (inBuf->len > 1 &&

262 inBuf->data[inBuf->len - 1] == '\n' &&

263 inBuf->data[inBuf->len - 2] == ';')

264 {

265

266 break;

267 }

268 }

269 else

270 {

271

272

273

274

275 if (inBuf->len > 0 &&

276 inBuf->data[inBuf->len - 1] == '\\')

277 {

278

279 inBuf->data[--inBuf->len] = '\0';

280

281 continue;

282 }

283 else

284 {

285

287 break;

288 }

289 }

290 }

291

292

294 }

295

296

297 if (c == EOF && inBuf->len == 0)

298 return EOF;

299

300

301

302

303

304

306

307

308

309

311 printf("statement: %s\n", inBuf->data);

313

315}

316

317

318

319

320

321

322

323static int

325{

326 int c;

327

328

329

330

331

332

333

335

336 c = getc(stdin);

337

339

340 return c;

341}

342

343

344

345

346

347

348

349

350

351static int

353{

354 int qtype;

355 int maxmsglen;

356

357

358

359

363

364 if (qtype == EOF)

365 {

368 (errcode(ERRCODE_CONNECTION_FAILURE),

369 errmsg("unexpected EOF on client connection with an open transaction")));

370 else

371 {

372

373

374

375

376

379 (errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST),

380 errmsg_internal("unexpected EOF on client connection")));

381 }

382 return qtype;

383 }

384

385

386

387

388

389

390

391

392

393

394

395 switch (qtype)

396 {

400 break;

401

405 break;

406

411 break;

412

417 break;

418

425 break;

426

429

431

433 break;

434

438 break;

439

444 break;

445

446 default:

447

448

449

450

451

452

454 (errcode(ERRCODE_PROTOCOL_VIOLATION),

455 errmsg("invalid frontend message type %d", qtype)));

456 maxmsglen = 0;

457 break;

458 }

459

460

461

462

463

464

466 return EOF;

468

469 return qtype;

470}

471

472

473

474

475

476

477

478

479static int

481{

482 int result;

483

486 else

488 return result;

489}

490

491

492

493

494

495

496

497

498

499

500void

502{

503 int save_errno = errno;

504

506 {

507

509

510

513

514

517 }

519 {

520

521

522

523

524

525

526

527

528 if (blocked)

530 else

532 }

533

534 errno = save_errno;

535}

536

537

538

539

540

541

542

543

544

545

546void

548{

549 int save_errno = errno;

550

552 {

553

554

555

556

557

558

559

560

561

562 if (blocked)

563 {

564

565

566

567

569 {

570

571

572

573

574

575

578

580 }

581 }

582 else

584 }

585

586 errno = save_errno;

587}

588

589

590

591

592

593

594

595

596

597

598

599

600

601

604{

605 List *raw_parsetree_list;

606

607 TRACE_POSTGRESQL_QUERY_PARSE_START(query_string);

608

611

613

616

617#ifdef DEBUG_NODE_TESTS_ENABLED

618

619

620 if (Debug_copy_parse_plan_trees)

621 {

623

624

626 elog(WARNING, "copyObject() failed to produce an equal raw parse tree");

627 else

628 raw_parsetree_list = new_list;

629 }

630

631

632

633

634

635 if (Debug_write_read_parse_plan_trees)

636 {

639

641

643 elog(WARNING, "outfuncs/readfuncs failed to produce an equal raw parse tree");

644 else

645 raw_parsetree_list = new_list;

646 }

647

648#endif

649

650 TRACE_POSTGRESQL_QUERY_PARSE_DONE(query_string);

651

652 return raw_parsetree_list;

653}

654

655

656

657

658

659

660

661

662

663

666 const char *query_string,

667 const Oid *paramTypes,

668 int numParams,

670{

672 List *querytree_list;

673

674 TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);

675

676

677

678

681

683 queryEnv);

684

686 ShowUsage("PARSE ANALYSIS STATISTICS");

687

688

689

690

692

693 TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);

694

695 return querytree_list;

696}

697

698

699

700

701

702

705 const char *query_string,

706 Oid **paramTypes,

707 int *numParams,

709{

711 List *querytree_list;

712

713 TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);

714

715

716

717

720

722 queryEnv);

723

724

725

726

727 for (int i = 0; i < *numParams; i++)

728 {

729 Oid ptype = (*paramTypes)[i];

730

731 if (ptype == InvalidOid || ptype == UNKNOWNOID)

733 (errcode(ERRCODE_INDETERMINATE_DATATYPE),

734 errmsg("could not determine data type of parameter $%d",

735 i + 1)));

736 }

737

739 ShowUsage("PARSE ANALYSIS STATISTICS");

740

741

742

743

745

746 TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);

747

748 return querytree_list;

749}

750

751

752

753

754

755

756

759 const char *query_string,

761 void *parserSetupArg,

763{

765 List *querytree_list;

766

767 TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);

768

769

770

771

774

775 query = parse_analyze_withcb(parsetree, query_string, parserSetup, parserSetupArg,

776 queryEnv);

777

779 ShowUsage("PARSE ANALYSIS STATISTICS");

780

781

782

783

785

786 TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);

787

788 return querytree_list;

789}

790

791

792

793

794

795

796

799{

800 List *querytree_list;

801

805

808

810 {

811

813 }

814 else

815 {

816

818 }

819

821 ShowUsage("REWRITER STATISTICS");

822

823#ifdef DEBUG_NODE_TESTS_ENABLED

824

825

826 if (Debug_copy_parse_plan_trees)

827 {

829

831

833 elog(WARNING, "copyObject() failed to produce an equal rewritten parse tree");

834 else

836 }

837

838

839 if (Debug_write_read_parse_plan_trees)

840 {

843

844 foreach(lc, querytree_list)

845 {

848 Query *new_query = stringToNodeWithLocations(str);

849

850

851

852

853

854 new_query->queryId = curr_query->queryId;

855

858 }

859

860

862 elog(WARNING, "outfuncs/readfuncs failed to produce an equal rewritten parse tree");

863 else

865 }

866

867#endif

868

872

873 return querytree_list;

874}

875

876

877

878

879

880

884{

886

887

889 return NULL;

890

891

893

894 TRACE_POSTGRESQL_QUERY_PLAN_START();

895

898

899

901

904

905#ifdef DEBUG_NODE_TESTS_ENABLED

906

907

908 if (Debug_copy_parse_plan_trees)

909 {

911

912

913

914

915

916#ifdef NOT_USED

917

919 elog(WARNING, "copyObject() failed to produce an equal plan tree");

920 else

921#endif

922 plan = new_plan;

923 }

924

925

926 if (Debug_write_read_parse_plan_trees)

927 {

928 char *str;

930

932 new_plan = stringToNodeWithLocations(str);

934

935

936

937

938

939#ifdef NOT_USED

940

942 elog(WARNING, "outfuncs/readfuncs failed to produce an equal plan tree");

943 else

944#endif

945 plan = new_plan;

946 }

947

948#endif

949

950

951

952

955

956 TRACE_POSTGRESQL_QUERY_PLAN_DONE();

957

959}

960

961

962

963

964

965

966

967

968

972{

975

976 foreach(query_list, querytrees)

977 {

980

982 {

983

986 stmt->canSetTag = query->canSetTag;

989 stmt->stmt_len = query->stmt_len;

990 stmt->queryId = query->queryId;

991 }

992 else

993 {

995 boundParams);

996 }

997

999 }

1000

1001 return stmt_list;

1002}

1003

1004

1005

1006

1007

1008

1009

1010static void

1012{

1015 List *parsetree_list;

1018 bool was_logged = false;

1019 bool use_implicit_block;

1020 char msec_str[32];

1021

1022

1023

1024

1026

1028

1029 TRACE_POSTGRESQL_QUERY_START(query_string);

1030

1031

1032

1033

1034

1035 if (save_log_statement_stats)

1037

1038

1039

1040

1041

1042

1043

1044

1046

1047

1048

1049

1050

1051

1052

1054

1055

1056

1057

1059

1060

1061

1062

1063

1065

1066

1068 {

1070 (errmsg("statement: %s", query_string),

1073 was_logged = true;

1074 }

1075

1076

1077

1078

1080

1081

1082

1083

1084

1085

1086

1087

1088

1089 use_implicit_block = (list_length(parsetree_list) > 1);

1090

1091

1092

1093

1094 foreach(parsetree_item, parsetree_list)

1095 {

1097 bool snapshot_set = false;

1101 List *querytree_list,

1102 *plantree_list;

1106 const char *cmdtagname;

1107 size_t cmdtaglen;

1108

1111

1112

1113

1114

1115

1116

1117

1120

1122

1124

1125

1126

1127

1128

1129

1130

1131

1132

1136 (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),

1137 errmsg("current transaction is aborted, "

1138 "commands ignored until end of transaction block"),

1140

1141

1143

1144

1145

1146

1147

1148

1149

1150

1151 if (use_implicit_block)

1153

1154

1156

1157

1158

1159

1161 {

1163 snapshot_set = true;

1164 }

1165

1166

1167

1168

1169

1170

1171

1172

1173

1174

1175

1176

1177

1178 if (lnext(parsetree_list, parsetree_item) != NULL)

1179 {

1180 per_parsetree_context =

1182 "per-parsetree message context",

1185 }

1186 else

1188

1190 NULL, 0, NULL);

1191

1192 plantree_list = pg_plan_queries(querytree_list, query_string,

1194

1195

1196

1197

1198

1199

1200

1201

1202

1203

1204

1205 if (snapshot_set)

1207

1208

1210

1211

1212

1213

1214

1216

1217 portal->visible = false;

1218

1219

1220

1221

1222

1223

1225 NULL,

1226 query_string,

1227 commandTag,

1228 plantree_list,

1229 NULL);

1230

1231

1232

1233

1235

1236

1237

1238

1239

1240

1241

1242 format = 0;

1244 {

1246

1248 {

1250

1253 format = 1;

1254 }

1255 }

1257

1258

1259

1260

1264

1265

1266

1267

1269

1270

1271

1272

1275 true,

1276 receiver,

1277 receiver,

1278 &qc);

1279

1280 receiver->rDestroy(receiver);

1281

1283

1284 if (lnext(parsetree_list, parsetree_item) == NULL)

1285 {

1286

1287

1288

1289

1290

1291

1292

1293

1294

1295 if (use_implicit_block)

1298 }

1300 {

1301

1302

1303

1304

1306 }

1307 else

1308 {

1309

1310

1311

1312

1313

1315

1316

1317

1318

1319

1321

1322

1323

1324

1325

1326

1328 }

1329

1330

1331

1332

1333

1334

1335

1337

1338

1339 if (per_parsetree_context)

1341 }

1342

1343

1344

1345

1346

1347

1349

1350

1351

1352

1353 if (!parsetree_list)

1355

1356

1357

1358

1360 {

1361 case 1:

1363 (errmsg("duration: %s ms", msec_str),

1365 break;

1366 case 2:

1368 (errmsg("duration: %s ms statement: %s",

1369 msec_str, query_string),

1372 break;

1373 }

1374

1375 if (save_log_statement_stats)

1377

1378 TRACE_POSTGRESQL_QUERY_DONE(query_string);

1379

1381}

1382

1383

1384

1385

1386

1387

1388static void

1390 const char *stmt_name,

1391 Oid *paramTypes,

1392 int numParams)

1393{

1396 List *parsetree_list;

1397 RawStmt *raw_parse_tree;

1398 List *querytree_list;

1400 bool is_named;

1402 char msec_str[32];

1403

1404

1405

1406

1408

1410

1412

1413 if (save_log_statement_stats)

1415

1418 *stmt_name ? stmt_name : "",

1419 query_string)));

1420

1421

1422

1423

1424

1425

1426

1428

1429

1430

1431

1432

1433

1434

1435

1436

1437

1438

1439

1440

1441

1442 is_named = (stmt_name[0] != '\0');

1443 if (is_named)

1444 {

1445

1447 }

1448 else

1449 {

1450

1452

1453 unnamed_stmt_context =

1455 "unnamed prepared statement",

1458 }

1459

1460

1461

1462

1463

1465

1466

1467

1468

1469

1470

1473 (errcode(ERRCODE_SYNTAX_ERROR),

1474 errmsg("cannot insert multiple commands into a prepared statement")));

1475

1476 if (parsetree_list != NIL)

1477 {

1478 bool snapshot_set = false;

1479

1481

1482

1483

1484

1485

1486

1487

1488

1489

1493 (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),

1494 errmsg("current transaction is aborted, "

1495 "commands ignored until end of transaction block"),

1497

1498

1499

1500

1501

1504

1505

1506

1507

1509 {

1511 snapshot_set = true;

1512 }

1513

1514

1515

1516

1517

1518

1520 query_string,

1521 &paramTypes,

1522 &numParams,

1523 NULL);

1524

1525

1526 if (snapshot_set)

1528 }

1529 else

1530 {

1531

1532 raw_parse_tree = NULL;

1534 CMDTAG_UNKNOWN);

1535 querytree_list = NIL;

1536 }

1537

1538

1539

1540

1541

1542

1543

1544 if (unnamed_stmt_context)

1546

1547

1549 querytree_list,

1550 unnamed_stmt_context,

1551 paramTypes,

1552 numParams,

1553 NULL,

1554 NULL,

1556 true);

1557

1558

1560

1561 if (is_named)

1562 {

1563

1564

1565

1567 }

1568 else

1569 {

1570

1571

1572

1575 }

1576

1578

1579

1580

1581

1582

1583

1585

1586

1587

1588

1591

1592

1593

1594

1596 {

1597 case 1:

1599 (errmsg("duration: %s ms", msec_str),

1601 break;

1602 case 2:

1604 (errmsg("duration: %s ms parse %s: %s",

1605 msec_str,

1606 *stmt_name ? stmt_name : "",

1607 query_string),

1609 break;

1610 }

1611

1612 if (save_log_statement_stats)

1613 ShowUsage("PARSE MESSAGE STATISTICS");

1614

1616}

1617

1618

1619

1620

1621

1622

1623static void

1625{

1626 const char *portal_name;

1627 const char *stmt_name;

1628 int numPFormats;

1629 int16 *pformats = NULL;

1630 int numParams;

1631 int numRFormats;

1632 int16 *rformats = NULL;

1636 char *query_string;

1637 char *saved_stmt_name;

1641 bool snapshot_set = false;

1642 char msec_str[32];

1646

1647

1650

1653 *portal_name ? portal_name : "",

1654 *stmt_name ? stmt_name : "")));

1655

1656

1657 if (stmt_name[0] != '\0')

1658 {

1660

1663 }

1664 else

1665 {

1666

1668 if (!psrc)

1670 (errcode(ERRCODE_UNDEFINED_PSTATEMENT),

1671 errmsg("unnamed prepared statement does not exist")));

1672 }

1673

1674

1675

1676

1678

1680

1682 {

1684

1686 {

1688 break;

1689 }

1690 }

1691

1693

1694 if (save_log_statement_stats)

1696

1697

1698

1699

1700

1701

1702

1704

1705

1707

1708

1709 numPFormats = pq_getmsgint(input_message, 2);

1710 if (numPFormats > 0)

1711 {

1713 for (int i = 0; i < numPFormats; i++)

1715 }

1716

1717

1719

1720 if (numPFormats > 1 && numPFormats != numParams)

1722 (errcode(ERRCODE_PROTOCOL_VIOLATION),

1723 errmsg("bind message has %d parameter formats but %d parameters",

1724 numPFormats, numParams)));

1725

1728 (errcode(ERRCODE_PROTOCOL_VIOLATION),

1729 errmsg("bind message supplies %d parameters, but prepared statement \"%s\" requires %d",

1730 numParams, stmt_name, psrc->num_params)));

1731

1732

1733

1734

1735

1736

1737

1738

1739

1743 numParams != 0))

1745 (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),

1746 errmsg("current transaction is aborted, "

1747 "commands ignored until end of transaction block"),

1749

1750

1751

1752

1753

1754 if (portal_name[0] == '\0')

1755 portal = CreatePortal(portal_name, true, true);

1756 else

1757 portal = CreatePortal(portal_name, false, false);

1758

1759

1760

1761

1762

1763

1764

1766

1767

1769

1770

1771 if (stmt_name[0])

1772 saved_stmt_name = pstrdup(stmt_name);

1773 else

1774 saved_stmt_name = NULL;

1775

1776

1777

1778

1779

1780

1781

1782

1783 if (numParams > 0 ||

1786 {

1788 snapshot_set = true;

1789 }

1790

1791

1792

1793

1794 if (numParams > 0)

1795 {

1796 char **knownTextValues = NULL;

1798

1799

1800

1801

1802

1804 one_param_data.paramno = -1;

1805 one_param_data.paramval = NULL;

1808 params_errcxt.arg = &one_param_data;

1810

1812

1813 for (int paramno = 0; paramno < numParams; paramno++)

1814 {

1818 bool isNull;

1820 char csave;

1822

1823 one_param_data.paramno = paramno;

1824 one_param_data.paramval = NULL;

1825

1827 isNull = (plength == -1);

1828

1829 if (!isNull)

1830 {

1831 char *pvalue;

1832

1833

1834

1835

1836

1837

1838

1839

1841 csave = pvalue[plength];

1842 pvalue[plength] = '\0';

1844 }

1845 else

1846 {

1847 pbuf.data = NULL;

1848 csave = 0;

1849 }

1850

1851 if (numPFormats > 1)

1852 pformat = pformats[paramno];

1853 else if (numPFormats > 0)

1854 pformat = pformats[0];

1855 else

1856 pformat = 0;

1857

1858 if (pformat == 0)

1859 {

1860 Oid typinput;

1861 Oid typioparam;

1862 char *pstring;

1863

1865

1866

1867

1868

1869

1870 if (isNull)

1871 pstring = NULL;

1872 else

1874

1875

1876 one_param_data.paramval = pstring;

1877

1879

1880 one_param_data.paramval = NULL;

1881

1882

1883

1884

1885

1886

1887 if (pstring)

1888 {

1890 {

1892

1894

1895 if (knownTextValues == NULL)

1896 knownTextValues = palloc0_array(char *, numParams);

1897

1899 knownTextValues[paramno] = pstrdup(pstring);

1900 else

1901 {

1902

1903

1904

1905

1906

1907

1908

1909 knownTextValues[paramno] =

1913 }

1914

1916 }

1917 if (pstring != pbuf.data)

1919 }

1920 }

1921 else if (pformat == 1)

1922 {

1923 Oid typreceive;

1924 Oid typioparam;

1926

1927

1928

1929

1931

1932 if (isNull)

1933 bufptr = NULL;

1934 else

1935 bufptr = &pbuf;

1936

1938

1939

1940 if (!isNull && pbuf.cursor != pbuf.len)

1942 (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),

1943 errmsg("incorrect binary data format in bind parameter %d",

1944 paramno + 1)));

1945 }

1946 else

1947 {

1949 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

1950 errmsg("unsupported format code: %d",

1951 pformat)));

1952 pval = 0;

1953 }

1954

1955

1956 if (!isNull)

1957 pbuf.data[plength] = csave;

1958

1961

1962

1963

1964

1965

1968 }

1969

1970

1972

1973

1974

1975

1976

1977

1981 knownTextValues,

1983 }

1984 else

1985 params = NULL;

1986

1987

1989

1990

1991

1992

1993

1995 params_data.params = params;

1998 params_errcxt.arg = &params_data;

2000

2001

2002 numRFormats = pq_getmsgint(input_message, 2);

2003 if (numRFormats > 0)

2004 {

2006 for (int i = 0; i < numRFormats; i++)

2008 }

2009

2011

2012

2013

2014

2015

2016

2017 cplan = GetCachedPlan(psrc, params, NULL, NULL);

2018

2019

2020

2021

2022

2023

2024

2026 saved_stmt_name,

2027 query_string,

2030 cplan);

2031

2032

2033 foreach(lc, portal->stmts)

2034 {

2036

2038 {

2040 break;

2041 }

2042 }

2043

2044

2045 if (snapshot_set)

2047

2048

2049

2050

2052

2053

2054

2055

2057

2058

2059

2060

2061

2063

2064

2065

2066

2069

2070

2071

2072

2074 {

2075 case 1:

2077 (errmsg("duration: %s ms", msec_str),

2079 break;

2080 case 2:

2082 (errmsg("duration: %s ms bind %s%s%s: %s",

2083 msec_str,

2084 *stmt_name ? stmt_name : "",

2085 *portal_name ? "/" : "",

2086 *portal_name ? portal_name : "",

2090 break;

2091 }

2092

2093 if (save_log_statement_stats)

2094 ShowUsage("BIND MESSAGE STATISTICS");

2095

2097

2099}

2100

2101

2102

2103

2104

2105

2106static void

2108{

2112 bool completed;

2114 const char *sourceText;

2115 const char *prepStmtName;

2118 bool is_xact_command;

2119 bool execute_is_fetch;

2120 bool was_logged = false;

2121 char msec_str[32];

2124 const char *cmdtagname;

2125 size_t cmdtaglen;

2127

2128

2132

2136 (errcode(ERRCODE_UNDEFINED_CURSOR),

2137 errmsg("portal \"%s\" does not exist", portal_name)));

2138

2139

2140

2141

2142

2143 if (portal->commandTag == CMDTAG_UNKNOWN)

2144 {

2147 return;

2148 }

2149

2150

2152

2153

2154

2155

2156

2157

2158

2162 else

2163 prepStmtName = "";

2165

2166

2167

2168

2170

2172

2173 foreach(lc, portal->stmts)

2174 {

2176

2178 {

2180 break;

2181 }

2182 }

2183

2184 foreach(lc, portal->stmts)

2185 {

2187

2189 {

2191 break;

2192 }

2193 }

2194

2196

2198

2199 if (save_log_statement_stats)

2201

2203

2204

2205

2206

2207

2211

2212

2213

2214

2215

2217

2218

2219

2220

2221

2222

2223

2224 execute_is_fetch = !portal->atStart;

2225

2226

2228 {

2230 (errmsg("%s %s%s%s: %s",

2231 execute_is_fetch ?

2232 _("execute fetch from") :

2233 _("execute"),

2234 prepStmtName,

2235 *portal_name ? "/" : "",

2236 *portal_name ? portal_name : "",

2237 sourceText),

2240 was_logged = true;

2241 }

2242

2243

2244

2245

2246

2250 (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),

2251 errmsg("current transaction is aborted, "

2252 "commands ignored until end of transaction block"),

2254

2255

2257

2258

2259

2260

2261

2263 params_data.params = portalParams;

2266 params_errcxt.arg = &params_data;

2268

2269 if (max_rows <= 0)

2271

2273 max_rows,

2274 true,

2275 receiver,

2276 receiver,

2277 &qc);

2278

2279 receiver->rDestroy(receiver);

2280

2281

2283

2284 if (completed)

2285 {

2287 {

2288

2289

2290

2291

2292

2293

2294

2295

2297

2298

2299

2300

2301

2302

2303 portalParams = NULL;

2304 }

2305 else

2306 {

2307

2308

2309

2310

2312

2313

2314

2315

2316

2318

2319

2320

2321

2322

2324 }

2325

2326

2328 }

2329 else

2330 {

2331

2334

2335

2336

2337

2338

2340 }

2341

2342

2343

2344

2346 {

2347 case 1:

2349 (errmsg("duration: %s ms", msec_str),

2351 break;

2352 case 2:

2354 (errmsg("duration: %s ms %s %s%s%s: %s",

2355 msec_str,

2356 execute_is_fetch ?

2357 _("execute fetch from") :

2358 _("execute"),

2359 prepStmtName,

2360 *portal_name ? "/" : "",

2361 *portal_name ? portal_name : "",

2362 sourceText),

2365 break;

2366 }

2367

2368 if (save_log_statement_stats)

2369 ShowUsage("EXECUTE MESSAGE STATISTICS");

2370

2372

2374}

2375

2376

2377

2378

2379

2380

2381

2382

2383static bool

2385{

2387

2389 return false;

2391 return true;

2392

2393

2394 foreach(stmt_item, stmt_list)

2395 {

2397

2399 return true;

2400 }

2401

2402 return false;

2403}

2404

2405

2406

2407

2408

2409

2410

2411

2412

2413

2414

2415

2416

2417

2418

2419

2420

2421

2422int

2424{

2427 {

2428 long secs;

2429 int usecs;

2430 int msecs;

2431 bool exceeded_duration;

2432 bool exceeded_sample_duration;

2433 bool in_sample = false;

2434

2437 &secs, &usecs);

2438 msecs = usecs / 1000;

2439

2440

2441

2442

2443

2444

2449

2454

2455

2456

2457

2458

2459

2460 if (exceeded_sample_duration)

2464

2466 {

2467 snprintf(msec_str, 32, "%ld.%03d",

2468 secs * 1000 + msecs, usecs % 1000);

2469 if ((exceeded_duration || in_sample || xact_is_sampled) && !was_logged)

2470 return 2;

2471 else

2472 return 1;

2473 }

2474 }

2475

2476 return 0;

2477}

2478

2479

2480

2481

2482

2483

2484

2485static int

2487{

2489

2490 foreach(parsetree_item, raw_parsetree_list)

2491 {

2493

2495 {

2498

2500 if (pstmt)

2501 {

2502 errdetail("prepare: %s", pstmt->plansource->query_string);

2503 return 0;

2504 }

2505 }

2506 }

2507

2508 return 0;

2509}

2510

2511

2512

2513

2514

2515

2516

2517

2518static int

2520{

2522 {

2523 char *str;

2524

2526 if (str && str[0] != '\0')

2528 }

2529

2530 return 0;

2531}

2532

2533

2534

2535

2536

2537

2538static int

2540{

2542 errdetail("Abort reason: recovery conflict");

2543

2544 return 0;

2545}

2546

2547

2548

2549

2550

2551

2552static int

2554{

2555 switch (reason)

2556 {

2558 errdetail("User was holding shared buffer pin for too long.");

2559 break;

2561 errdetail("User was holding a relation lock for too long.");

2562 break;

2564 errdetail("User was or might have been using tablespace that must be dropped.");

2565 break;

2567 errdetail("User query might have needed to see row versions that must be removed.");

2568 break;

2570 errdetail("User was using a logical replication slot that must be invalidated.");

2571 break;

2573 errdetail("User transaction caused buffer deadlock with recovery.");

2574 break;

2576 errdetail("User was connected to a database that must be dropped.");

2577 break;

2578 default:

2579 break;

2580

2581 }

2582

2583 return 0;

2584}

2585

2586

2587

2588

2589

2590

2591static void

2593{

2596 char *quotedval;

2597

2598 if (data->paramno < 0)

2599 return;

2600

2601

2602 if (data->paramval)

2603 {

2607 quotedval = buf.data;

2608 }

2609 else

2610 quotedval = NULL;

2611

2612 if (data->portalName && data->portalName[0] != '\0')

2613 {

2614 if (quotedval)

2615 errcontext("portal \"%s\" parameter $%d = %s",

2616 data->portalName, data->paramno + 1, quotedval);

2617 else

2618 errcontext("portal \"%s\" parameter $%d",

2619 data->portalName, data->paramno + 1);

2620 }

2621 else

2622 {

2623 if (quotedval)

2624 errcontext("unnamed portal parameter $%d = %s",

2625 data->paramno + 1, quotedval);

2626 else

2627 errcontext("unnamed portal parameter $%d",

2628 data->paramno + 1);

2629 }

2630

2631 if (quotedval)

2632 pfree(quotedval);

2633}

2634

2635

2636

2637

2638

2639

2640static void

2642{

2644

2645

2646

2647

2648

2650

2651

2653

2654

2655 if (stmt_name[0] != '\0')

2656 {

2658

2661 }

2662 else

2663 {

2664

2666 if (!psrc)

2668 (errcode(ERRCODE_UNDEFINED_PSTATEMENT),

2669 errmsg("unnamed prepared statement does not exist")));

2670 }

2671

2672

2674

2675

2676

2677

2678

2679

2680

2681

2682

2683

2687 (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),

2688 errmsg("current transaction is aborted, "

2689 "commands ignored until end of transaction block"),

2691

2693 return;

2694

2695

2696

2697

2700

2702 {

2704

2706 }

2708

2709

2710

2711

2713 {

2714 List *tlist;

2715

2716

2718

2721 tlist,

2722 NULL);

2723 }

2724 else

2726}

2727

2728

2729

2730

2731

2732

2733static void

2735{

2737

2738

2739

2740

2741

2743

2744

2746

2750 (errcode(ERRCODE_UNDEFINED_CURSOR),

2751 errmsg("portal \"%s\" does not exist", portal_name)));

2752

2753

2754

2755

2756

2757

2758

2759

2760

2764 (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),

2765 errmsg("current transaction is aborted, "

2766 "commands ignored until end of transaction block"),

2768

2770 return;

2771

2777 else

2779}

2780

2781

2782

2783

2784

2785static void

2787{

2789 {

2791

2793 }

2795 {

2796

2797

2798

2799

2800

2801

2802

2804 }

2805

2806

2807

2808

2809

2810

2811

2812

2814

2815

2822}

2823

2824static void

2826{

2827

2829

2831 {

2833

2834#ifdef MEMORY_CONTEXT_CHECKING

2835

2836

2838#endif

2839

2840#ifdef SHOW_MEMORY_STATS

2841

2843#endif

2844

2846 }

2847}

2848

2849

2850

2851

2852

2853

2854

2855

2856static bool

2858{

2860 {

2862

2867 return true;

2868 }

2869 return false;

2870}

2871

2872

2873static bool

2875{

2877 {

2879

2882 return true;

2883 }

2884 return false;

2885}

2886

2887

2888static bool

2890{

2892 {

2894

2897 return true;

2898 }

2899 return false;

2900}

2901

2902

2903static void

2905{

2906

2908 {

2910

2913 }

2914}

2915

2916

2917

2918

2919

2920

2921

2922

2923

2924

2925

2926

2927

2928void

2930{

2931 sigaddset(&BlockSig, SIGQUIT);

2932 sigprocmask(SIG_SETMASK, &BlockSig, NULL);

2933

2934

2935

2936

2937

2938

2940

2941

2942

2943

2944

2945

2946

2949

2950

2951

2952

2953

2954

2955

2956

2957

2958

2959

2960

2961

2962

2963

2964

2965

2967

2968

2969

2970

2971

2972

2973

2974

2975

2977 {

2979

2981 (errcode(ERRCODE_ADMIN_SHUTDOWN),

2982 errmsg("terminating connection because of unexpected SIGQUIT signal")));

2983 break;

2985

2987 (errcode(ERRCODE_CRASH_SHUTDOWN),

2988 errmsg("terminating connection because of crash of another server process"),

2989 errdetail("The postmaster has commanded this server process to roll back"

2990 " the current transaction and exit, because another"

2991 " server process exited abnormally and possibly corrupted"

2992 " shared memory."),

2993 errhint("In a moment you should be able to reconnect to the"

2994 " database and repeat your command.")));

2995 break;

2997

2999 (errcode(ERRCODE_ADMIN_SHUTDOWN),

3000 errmsg("terminating connection due to immediate shutdown command")));

3001 break;

3002 }

3003

3004

3005

3006

3007

3008

3009

3010

3011

3012

3013

3014

3015

3016

3017

3018 _exit(2);

3019}

3020

3021

3022

3023

3024

3025void

3027{

3028

3030 {

3033 }

3034

3035

3037

3038

3040

3041

3042

3043

3044

3045

3046

3049}

3050

3051

3052

3053

3054

3055void

3057{

3058

3059

3060

3062 {

3065 }

3066

3067

3069}

3070

3071

3072void

3074{

3075

3077 (errcode(ERRCODE_FLOATING_POINT_EXCEPTION),

3078 errmsg("floating-point exception"),

3079 errdetail("An invalid floating-point operation was signaled. "

3080 "This probably means an out-of-range result or an "

3081 "invalid operation, such as division by zero.")));

3082}

3083

3084

3085

3086

3087

3088void

3090{

3094

3095}

3096

3097

3098

3099

3100static void

3102{

3103 switch (reason)

3104 {

3106

3107

3108

3109

3111 return;

3112

3113

3114

3115

3117

3118

3119

3120

3121

3122

3123

3124

3125

3126

3127

3129 {

3133 return;

3134 }

3135

3137

3138

3139

3140

3144

3145

3146

3147

3149 return;

3150

3151

3152

3154

3155

3156

3157

3158

3159

3160

3161

3162

3163

3164

3165

3166

3167

3168

3169

3170

3171

3172

3173

3174

3175

3176

3177

3178

3179

3182 {

3183

3184

3185

3186

3187

3189 return;

3190

3191

3192

3193

3194

3195

3196

3197

3199 {

3200

3202 {

3203

3204

3205

3206

3210 return;

3211 }

3212

3213

3214

3215

3216

3217

3218

3223 errmsg("canceling statement due to conflict with recovery"),

3225 break;

3226 }

3227 }

3228

3229

3230

3231

3233

3234

3235

3236

3237

3238

3242 ERRCODE_DATABASE_DROPPED :

3244 errmsg("terminating connection due to conflict with recovery"),

3246 errhint("In a moment you should be able to reconnect to the"

3247 " database and repeat your command.")));

3248 break;

3249

3250 default:

3251 elog(FATAL, "unrecognized conflict mode: %d", (int) reason);

3252 }

3253}

3254

3255

3256

3257

3258static void

3260{

3261

3262

3263

3264

3265

3269

3271

3274 reason++)

3275 {

3277 {

3280 }

3281 }

3282}

3283

3284

3285

3286

3287

3288

3289

3290

3291

3292

3293

3294

3295

3296

3297void

3299{

3300

3302 return;

3304

3306 {

3310

3315 (errcode(ERRCODE_QUERY_CANCELED),

3316 errmsg("canceling authentication due to timeout")));

3319 (errcode(ERRCODE_ADMIN_SHUTDOWN),

3320 errmsg("terminating autovacuum process due to administrator command")));

3323 (errcode(ERRCODE_ADMIN_SHUTDOWN),

3324 errmsg("terminating logical replication worker due to administrator command")));

3326 {

3328 (errmsg_internal("logical replication launcher shutting down")));

3329

3330

3331

3332

3333

3335 }

3338 (errcode(ERRCODE_ADMIN_SHUTDOWN),

3339 errmsg("terminating walreceiver process due to administrator command")));

3342 (errcode(ERRCODE_ADMIN_SHUTDOWN),

3343 errmsg("terminating background worker \"%s\" due to administrator command",

3346 {

3348 (errmsg_internal("io worker shutting down due to administrator command")));

3349

3351 }

3352 else

3354 (errcode(ERRCODE_ADMIN_SHUTDOWN),

3355 errmsg("terminating connection due to administrator command")));

3356 }

3357

3359 {

3361

3362

3363

3364

3365

3366

3367

3369 {

3372 else

3375 }

3376 }

3377

3379 {

3380 QueryCancelPending = false;

3382

3385 (errcode(ERRCODE_CONNECTION_FAILURE),

3386 errmsg("connection to client lost")));

3387 }

3388

3389

3390

3391

3392

3393

3394

3395

3396

3398 {

3399

3400

3401

3402

3403

3404

3405

3406

3408 }

3410 {

3411 bool lock_timeout_occurred;

3412 bool stmt_timeout_occurred;

3413

3415

3416

3417

3418

3419

3422

3423

3424

3425

3426

3427

3428

3429 if (lock_timeout_occurred && stmt_timeout_occurred &&

3431 lock_timeout_occurred = false;

3432

3433 if (lock_timeout_occurred)

3434 {

3437 (errcode(ERRCODE_LOCK_NOT_AVAILABLE),

3438 errmsg("canceling statement due to lock timeout")));

3439 }

3440 if (stmt_timeout_occurred)

3441 {

3444 (errcode(ERRCODE_QUERY_CANCELED),

3445 errmsg("canceling statement due to statement timeout")));

3446 }

3448 {

3451 (errcode(ERRCODE_QUERY_CANCELED),

3452 errmsg("canceling autovacuum task")));

3453 }

3454

3455

3456

3457

3458

3459

3461 {

3464 (errcode(ERRCODE_QUERY_CANCELED),

3465 errmsg("canceling statement due to user request")));

3466 }

3467 }

3468

3471

3473 {

3474

3475

3476

3477

3478

3479

3482 {

3483 INJECTION_POINT("idle-in-transaction-session-timeout", NULL);

3485 (errcode(ERRCODE_IDLE_IN_TRANSACTION_SESSION_TIMEOUT),

3486 errmsg("terminating connection due to idle-in-transaction timeout")));

3487 }

3488 }

3489

3491 {

3492

3495 {

3498 (errcode(ERRCODE_TRANSACTION_TIMEOUT),

3499 errmsg("terminating connection due to transaction timeout")));

3500 }

3501 }

3502

3504 {

3505

3508 {

3511 (errcode(ERRCODE_IDLE_SESSION_TIMEOUT),

3512 errmsg("terminating connection due to idle-session timeout")));

3513 }

3514 }

3515

3516

3517

3518

3519

3522 {

3525 }

3526

3529

3532

3535

3538}

3539

3540

3541

3542

3543bool

3545{

3547 {

3548 GUC_check_errdetail("\"client_connection_check_interval\" must be set to 0 on this platform.");

3549 return false;

3550 }

3551 return true;

3552}

3553

3554

3555

3556

3557

3558

3559

3560

3561

3562

3563

3564bool

3566{

3568 {

3569 GUC_check_errdetail("Cannot enable parameter when \"log_statement_stats\" is true.");

3570 return false;

3571 }

3572 return true;

3573}

3574

3575

3576

3577

3578bool

3580{

3583 {

3585 "\"log_parser_stats\", \"log_planner_stats\", "

3586 "or \"log_executor_stats\" is true.");

3587 return false;

3588 }

3589 return true;

3590}

3591

3592

3593void

3595{

3597 {

3598

3599

3600

3601

3606 }

3607}

3608

3609

3610

3611

3612bool

3614{

3615 char *rawstring;

3616 List *elemlist;

3618 int flags = 0;

3619

3620

3622

3624 {

3625

3627 pfree(rawstring);

3629 return false;

3630 }

3631

3632 foreach(l, elemlist)

3633 {

3634 char *tok = (char *) lfirst(l);

3635

3638 else if (pg_strcasecmp(tok, "foreign-table") == 0)

3640 else

3641 {

3643 pfree(rawstring);

3645 return false;

3646 }

3647 }

3648

3649 pfree(rawstring);

3651

3652

3654 if (!*extra)

3655 return false;

3656 *((int *) *extra) = flags;

3657

3658 return true;

3659}

3660

3661

3662

3663

3664void

3666{

3667 int *flags = (int *) extra;

3668

3670}

3671

3672

3673

3674

3675

3676

3677

3678void

3680{

3681 if (debug_flag > 0)

3682 {

3683 char debugstr[64];

3684

3685 sprintf(debugstr, "debug%d", debug_flag);

3687 }

3688 else

3690

3692 {

3695 }

3696 if (debug_flag >= 2)

3698 if (debug_flag >= 3)

3700 if (debug_flag >= 4)

3702 if (debug_flag >= 5)

3704}

3705

3706

3707bool

3709{

3710 const char *tmp = NULL;

3711

3712 switch (arg[0])

3713 {

3714 case 's':

3715 tmp = "enable_seqscan";

3716 break;

3717 case 'i':

3718 tmp = "enable_indexscan";

3719 break;

3720 case 'o':

3721 tmp = "enable_indexonlyscan";

3722 break;

3723 case 'b':

3724 tmp = "enable_bitmapscan";

3725 break;

3726 case 't':

3727 tmp = "enable_tidscan";

3728 break;

3729 case 'n':

3730 tmp = "enable_nestloop";

3731 break;

3732 case 'm':

3733 tmp = "enable_mergejoin";

3734 break;

3735 case 'h':

3736 tmp = "enable_hashjoin";

3737 break;

3738 }

3739 if (tmp)

3740 {

3742 return true;

3743 }

3744 else

3745 return false;

3746}

3747

3748

3749const char *

3751{

3752 switch (arg[0])

3753 {

3754 case 'p':

3755 if (optarg[1] == 'a')

3756 return "log_parser_stats";

3757 else if (optarg[1] == 'l')

3758 return "log_planner_stats";

3759 break;

3760

3761 case 'e':

3762 return "log_executor_stats";

3763 break;

3764 }

3765

3766 return NULL;

3767}

3768

3769

3770

3771

3772

3773

3774

3775

3776

3777

3778

3779

3780

3781

3782

3783

3784

3785

3786

3787

3788

3789void

3791 const char **dbname)

3792{

3794 int errs = 0;

3797

3798 if (secure)

3799 {

3800 gucsource = PGC_S_ARGV;

3801

3802

3803 if (argc > 1 && strcmp(argv[1], "--single") == 0)

3804 {

3805 argv++;

3806 argc--;

3807 }

3808 }

3809 else

3810 {

3811 gucsource = PGC_S_CLIENT;

3812 }

3813

3814#ifdef HAVE_INT_OPTERR

3815

3816

3817

3818

3819

3820

3822#endif

3823

3824

3825

3826

3827

3828

3829 while ((flag = getopt(argc, argv, "B:bC:c:D:d:EeFf:h:ijk:lN:nOPp:r:S:sTt:v:W:-:")) != -1)

3830 {

3831 switch (flag)

3832 {

3833 case 'B':

3835 break;

3836

3837 case 'b':

3838

3839 if (secure)

3841 break;

3842

3843 case 'C':

3844

3845 break;

3846

3847 case '-':

3848

3849

3850

3851

3852

3853

3854

3857 (errcode(ERRCODE_SYNTAX_ERROR),

3858 errmsg("--%s must be first argument", optarg)));

3859

3860

3861 case 'c':

3862 {

3865

3868 {

3869 if (flag == '-')

3871 (errcode(ERRCODE_SYNTAX_ERROR),

3872 errmsg("--%s requires a value",

3874 else

3876 (errcode(ERRCODE_SYNTAX_ERROR),

3877 errmsg("-c %s requires a value",

3879 }

3883 break;

3884 }

3885

3886 case 'D':

3887 if (secure)

3889 break;

3890

3891 case 'd':

3893 break;

3894

3895 case 'E':

3896 if (secure)

3898 break;

3899

3900 case 'e':

3902 break;

3903

3904 case 'F':

3906 break;

3907

3908 case 'f':

3910 errs++;

3911 break;

3912

3913 case 'h':

3915 break;

3916

3917 case 'i':

3918 SetConfigOption("listen_addresses", "*", ctx, gucsource);

3919 break;

3920

3921 case 'j':

3922 if (secure)

3924 break;

3925

3926 case 'k':

3928 break;

3929

3930 case 'l':

3932 break;

3933

3934 case 'N':

3936 break;

3937

3938 case 'n':

3939

3940 break;

3941

3942 case 'O':

3943 SetConfigOption("allow_system_table_mods", "true", ctx, gucsource);

3944 break;

3945

3946 case 'P':

3947 SetConfigOption("ignore_system_indexes", "true", ctx, gucsource);

3948 break;

3949

3950 case 'p':

3952 break;

3953

3954 case 'r':

3955

3956 if (secure)

3958 break;

3959

3960 case 'S':

3962 break;

3963

3964 case 's':

3965 SetConfigOption("log_statement_stats", "true", ctx, gucsource);

3966 break;

3967

3968 case 'T':

3969

3970 break;

3971

3972 case 't':

3973 {

3975

3976 if (tmp)

3978 else

3979 errs++;

3980 break;

3981 }

3982

3983 case 'v':

3984

3985

3986

3987

3988

3989

3990

3991

3992 if (secure)

3994 break;

3995

3996 case 'W':

3998 break;

3999

4000 default:

4001 errs++;

4002 break;

4003 }

4004

4005 if (errs)

4006 break;

4007 }

4008

4009

4010

4011

4014

4015 if (errs || argc != optind)

4016 {

4017 if (errs)

4018 optind--;

4019

4020

4023 errcode(ERRCODE_SYNTAX_ERROR),

4024 errmsg("invalid command-line argument for server process: %s", argv[optind]),

4025 errhint("Try \"%s --help\" for more information.", progname));

4026 else

4028 errcode(ERRCODE_SYNTAX_ERROR),

4029 errmsg("%s: invalid command-line argument: %s",

4031 errhint("Try \"%s --help\" for more information.", progname));

4032 }

4033

4034

4035

4036

4037

4039#ifdef HAVE_INT_OPTRESET

4040 optreset = 1;

4041#endif

4042}

4043

4044

4045

4046

4047

4048

4049

4050

4051

4052

4053

4054void

4057{

4058 const char *dbname = NULL;

4059

4061

4062

4064

4065

4066

4067

4069

4070

4071

4072

4074

4075

4077 {

4081 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

4082 errmsg("%s: no database nor user name specified",

4084 }

4085

4086

4089

4090

4091

4092

4093

4096

4097

4098

4099

4101

4102

4104

4105

4106

4107

4109

4110

4112

4113

4114

4115

4116

4118

4119

4121

4122

4123

4124

4126

4127

4128

4129

4130

4131

4133

4134

4135

4136

4137

4139

4140

4141

4142

4143

4145

4146

4147

4148

4149

4151

4152

4153

4154

4155

4157

4158

4159

4160

4161

4163

4164

4165

4166

4167

4169}

4170

4171

4172

4173

4174

4175

4176

4177

4178

4179

4180

4181

4182

4183void

4185{

4186 sigjmp_buf local_sigjmp_buf;

4187

4188

4189 volatile bool send_ready_for_query = true;

4190 volatile bool idle_in_transaction_timeout_enabled = false;

4191 volatile bool idle_session_timeout_enabled = false;

4192

4195

4197

4198

4199

4200

4201

4202

4203

4204

4205

4206

4207

4208

4209

4210

4211

4212

4215 else

4216 {

4219 pqsignal(SIGTERM, die);

4220

4221

4222

4223

4224

4225

4226

4227

4228

4231 else

4234

4235

4236

4237

4238

4239

4240

4245

4246

4247

4248

4249

4250 pqsignal(SIGCHLD, SIG_DFL);

4251

4252 }

4253

4254

4256

4257

4258 sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);

4259

4260

4261

4262

4263

4266 {

4267 int len;

4268

4272 {

4274 (errcode(ERRCODE_INTERNAL_ERROR),

4275 errmsg("could not generate random cancel key")));

4276 }

4278 }

4279

4280

4281

4282

4283

4284

4285

4286

4287

4288

4292 NULL);

4293

4294

4295

4296

4297

4299 {

4302 }

4303

4305

4306

4307

4308

4309

4311

4312

4313

4314

4315

4318

4320

4321

4324

4325

4326

4327

4329 {

4331

4335

4338

4339 }

4340

4341

4343 printf("\nPostgreSQL stand-alone backend %s\n", PG_VERSION);

4344

4345

4346

4347

4348

4349

4350

4352 "MessageContext",

4354

4355

4356

4357

4358

4359

4360

4362 "RowDescriptionContext",

4367

4368

4370

4371

4372

4373

4374

4375

4376

4377

4378

4379

4380

4381

4382

4383

4384

4385

4386

4387

4388

4389

4390

4391

4392

4393 if (sigsetjmp(local_sigjmp_buf, 1) != 0)

4394 {

4395

4396

4397

4398

4399

4400

4401

4402

4403

4405

4406

4408

4409

4410

4411

4412

4413

4414

4415

4416

4417

4418

4419

4422 idle_in_transaction_timeout_enabled = false;

4423 idle_session_timeout_enabled = false;

4424

4425

4427

4428

4430

4431

4433

4434

4435

4436

4437

4439

4440

4441

4442

4443

4445

4446

4447

4448

4450

4453

4455

4456

4457

4458

4459

4460

4461

4462

4465

4466

4468

4470

4471

4472

4473

4474

4477

4478

4479

4480

4481

4482

4485

4486

4488

4489

4490

4491

4492

4493

4494

4495

4496

4499 (errcode(ERRCODE_PROTOCOL_VIOLATION),

4500 errmsg("terminating connection because protocol synchronization was lost")));

4501

4502

4504 }

4505

4506

4508

4510 send_ready_for_query = true;

4511

4512

4513

4514

4515

4516 for (;;)

4517 {

4518 int firstchar;

4520

4521

4522

4523

4524

4526

4527

4528

4529

4530#ifdef USE_VALGRIND

4531 old_valgrind_error_count = VALGRIND_COUNT_ERRORS;

4532#endif

4533

4534

4535

4536

4537

4540

4542

4543

4544

4545

4546

4548

4549

4550

4551

4552

4553

4554

4555

4556

4557

4558

4559

4560

4561

4562

4563

4564

4565 if (send_ready_for_query)

4566 {

4568 {

4571

4572

4575 {

4576 idle_in_transaction_timeout_enabled = true;

4579 }

4580 }

4582 {

4585

4586

4589 {

4590 idle_in_transaction_timeout_enabled = true;

4593 }

4594 }

4595 else

4596 {

4597 long stats_timeout;

4598

4599

4600

4601

4602

4603

4604

4605

4608

4609

4610

4611

4612

4613

4614

4615

4616

4617

4618

4619

4620

4621

4623 if (stats_timeout > 0)

4624 {

4627 stats_timeout);

4628 }

4629 else

4630 {

4631

4634 }

4635

4638

4639

4641 {

4642 idle_session_timeout_enabled = true;

4645 }

4646 }

4647

4648

4650

4651

4652

4653

4654

4655

4659 {

4660 uint64 total_duration,

4661 fork_duration,

4662 auth_duration;

4663

4665

4666 total_duration =

4669 fork_duration =

4672 auth_duration =

4675

4677 errmsg("connection ready: setup total=%.3f ms, fork=%.3f ms, authentication=%.3f ms",

4678 (double) total_duration / NS_PER_US,

4679 (double) fork_duration / NS_PER_US,

4680 (double) auth_duration / NS_PER_US));

4681 }

4682

4684 send_ready_for_query = false;

4685 }

4686

4687

4688

4689

4690

4691

4692

4694

4695

4696

4697

4698 firstchar = ReadCommand(&input_message);

4699

4700

4701

4702

4703

4704

4705

4706

4707

4708 if (idle_in_transaction_timeout_enabled)

4709 {

4711 idle_in_transaction_timeout_enabled = false;

4712 }

4713 if (idle_session_timeout_enabled)

4714 {

4716 idle_session_timeout_enabled = false;

4717 }

4718

4719

4720

4721

4722

4723

4724

4725

4726

4727

4730

4731

4732

4733

4734

4736 {

4739 }

4740

4741

4742

4743

4744

4746 continue;

4747

4748 switch (firstchar)

4749 {

4751 {

4752 const char *query_string;

4753

4754

4756

4759

4761 {

4764 }

4765 else

4767

4769

4770 send_ready_for_query = true;

4771 }

4772 break;

4773

4775 {

4776 const char *stmt_name;

4777 const char *query_string;

4778 int numParams;

4779 Oid *paramTypes = NULL;

4780

4782

4783

4785

4788 numParams = pq_getmsgint(&input_message, 2);

4789 if (numParams > 0)

4790 {

4792 for (int i = 0; i < numParams; i++)

4793 paramTypes[i] = pq_getmsgint(&input_message, 4);

4794 }

4796

4798 paramTypes, numParams);

4799

4801 }

4802 break;

4803

4806

4807

4809

4810

4811

4812

4813

4815

4816

4817 break;

4818

4820 {

4821 const char *portal_name;

4822 int max_rows;

4823

4825

4826

4828

4832

4834

4835

4836 }

4837 break;

4838

4841

4842

4844

4845

4848

4849

4851

4852

4853

4854

4855

4856

4857

4858

4859

4860

4861

4863

4865

4866

4868

4870

4871 send_ready_for_query = true;

4872 break;

4873

4875 {

4876 int close_type;

4877 const char *close_target;

4878

4880

4884

4885 switch (close_type)

4886 {

4887 case 'S':

4888 if (close_target[0] != '\0')

4890 else

4891 {

4892

4894 }

4895 break;

4896 case 'P':

4897 {

4899

4903 }

4904 break;

4905 default:

4907 (errcode(ERRCODE_PROTOCOL_VIOLATION),

4908 errmsg("invalid CLOSE message subtype %d",

4909 close_type)));

4910 break;

4911 }

4912

4915

4917 }

4918 break;

4919

4921 {

4922 int describe_type;

4923 const char *describe_target;

4924

4926

4927

4929

4933

4934 switch (describe_type)

4935 {

4936 case 'S':

4938 break;

4939 case 'P':

4941 break;

4942 default:

4944 (errcode(ERRCODE_PROTOCOL_VIOLATION),

4945 errmsg("invalid DESCRIBE message subtype %d",

4946 describe_type)));

4947 break;

4948 }

4949

4951 }

4952 break;

4953

4958 break;

4959

4962

4963

4964

4965

4966

4967

4971 send_ready_for_query = true;

4972 break;

4973

4974

4975

4976

4977

4978

4979 case EOF:

4980

4981

4983

4984

4985

4987

4988

4989

4990

4991

4994

4995

4996

4997

4998

4999

5000

5001

5003

5007

5008

5009

5010

5011

5012

5013 break;

5014

5015 default:

5017 (errcode(ERRCODE_PROTOCOL_VIOLATION),

5018 errmsg("invalid frontend message type %d",

5019 firstchar)));

5020 }

5021 }

5022}

5023

5024

5025

5026

5027

5028

5029

5030

5031static void

5033{

5035 {

5038 (errcode(ERRCODE_PROTOCOL_VIOLATION),

5039 errmsg("fastpath function calls not supported in a replication connection")));

5040 else

5042 (errcode(ERRCODE_PROTOCOL_VIOLATION),

5043 errmsg("extended query protocol not supported in a replication connection")));

5044 }

5045}

5046

5047

5050

5051void

5053{

5056}

5057

5058void

5060{

5062 struct timeval user,

5063 sys;

5064 struct timeval elapse_t;

5066

5070 memcpy(&sys, &r.ru_stime, sizeof(sys));

5071 if (elapse_t.tv_usec < Save_t.tv_usec)

5072 {

5073 elapse_t.tv_sec--;

5074 elapse_t.tv_usec += 1000000;

5075 }

5077 {

5079 r.ru_utime.tv_usec += 1000000;

5080 }

5082 {

5084 r.ru_stime.tv_usec += 1000000;

5085 }

5086

5087

5088

5089

5090

5092

5095 "!\t%ld.%06ld s user, %ld.%06ld s system, %ld.%06ld s elapsed\n",

5100 (long) (elapse_t.tv_sec - Save_t.tv_sec),

5101 (long) (elapse_t.tv_usec - Save_t.tv_usec));

5103 "!\t[%ld.%06ld s user, %ld.%06ld s system total]\n",

5104 (long) user.tv_sec,

5105 (long) user.tv_usec,

5106 (long) sys.tv_sec,

5107 (long) sys.tv_usec);

5108#ifndef WIN32

5109

5110

5111

5112

5113

5114

5115

5117 "!\t%ld kB max resident size\n",

5119

5120 r.ru_maxrss / 1024

5121#else

5122

5123 r.ru_maxrss

5124#endif

5125 );

5127 "!\t%ld/%ld [%ld/%ld] filesystem blocks in/out\n",

5128 r.ru_inblock - Save_r.ru_inblock,

5129

5130 r.ru_oublock - Save_r.ru_oublock,

5131 r.ru_inblock, r.ru_oublock);

5133 "!\t%ld/%ld [%ld/%ld] page faults/reclaims, %ld [%ld] swaps\n",

5134 r.ru_majflt - Save_r.ru_majflt,

5135 r.ru_minflt - Save_r.ru_minflt,

5136 r.ru_majflt, r.ru_minflt,

5137 r.ru_nswap - Save_r.ru_nswap,

5138 r.ru_nswap);

5140 "!\t%ld [%ld] signals rcvd, %ld/%ld [%ld/%ld] messages rcvd/sent\n",

5141 r.ru_nsignals - Save_r.ru_nsignals,

5142 r.ru_nsignals,

5143 r.ru_msgrcv - Save_r.ru_msgrcv,

5144 r.ru_msgsnd - Save_r.ru_msgsnd,

5145 r.ru_msgrcv, r.ru_msgsnd);

5147 "!\t%ld/%ld [%ld/%ld] voluntary/involuntary context switches\n",

5148 r.ru_nvcsw - Save_r.ru_nvcsw,

5149 r.ru_nivcsw - Save_r.ru_nivcsw,

5150 r.ru_nvcsw, r.ru_nivcsw);

5151#endif

5152

5153

5154 if (str.data[str.len - 1] == '\n')

5155 str.data[--str.len] = '\0';

5156

5160

5162}

5163

5164

5165

5166

5167static void

5169{

5171 long secs;

5172 int usecs;

5173 int msecs;

5174 int hours,

5175 minutes,

5176 seconds;

5177

5180 &secs, &usecs);

5181 msecs = usecs / 1000;

5182

5187

5189 (errmsg("disconnection: session time: %d:%02d:%02d.%03d "

5190 "user=%s database=%s host=%s%s%s",

5191 hours, minutes, seconds, msecs,

5192 port->user_name, port->database_name, port->remote_host,

5193 port->remote_port[0] ? " port=" : "", port->remote_port)));

5194}

5195

5196

5197

5198

5199

5200

5201

5202

5203static void

5205{

5206

5208

5211 {

5214 }

5215 else

5216 {

5219 }

5220}

5221

5222

5223

5224

5225static void

5227{

5230}

Datum querytree(PG_FUNCTION_ARGS)

volatile sig_atomic_t ParallelApplyMessagePending

void ProcessParallelApplyMessages(void)

void ProcessNotifyInterrupt(bool flush)

volatile sig_atomic_t notifyInterruptPending

void ProcessParallelMessages(void)

volatile sig_atomic_t ParallelMessagePending

void DropPreparedStatement(const char *stmt_name, bool showError)

PreparedStatement * FetchPreparedStatement(const char *stmt_name, bool throwError)

void StorePreparedStatement(const char *stmt_name, CachedPlanSource *plansource, bool from_sql)

void elog_node_display(int lev, const char *title, const void *obj, bool pretty)

List * raw_parser(const char *str, RawParseMode mode)

bool IsLogicalWorker(void)

void TimestampDifference(TimestampTz start_time, TimestampTz stop_time, long *secs, int *microsecs)

TimestampTz GetCurrentTimestamp(void)

ConnectionTiming conn_timing

@ LOG_CONNECTION_SETUP_DURATIONS

void pgstat_report_plan_id(uint64 plan_id, bool force)

void pgstat_report_query_id(uint64 query_id, bool force)

void pgstat_report_activity(BackendState state, const char *cmd_str)

@ STATE_IDLEINTRANSACTION_ABORTED

@ STATE_IDLEINTRANSACTION

bool HoldingBufferPinThatDelaysRecovery(void)

#define unconstify(underlying_type, expr)

const char * GetCommandTagNameAndLen(CommandTag commandTag, Size *len)

#define TIMESTAMP_MINUS_INFINITY

void EndCommand(const QueryCompletion *qc, CommandDest dest, bool force_undecorated_output)

DestReceiver * CreateDestReceiver(CommandDest dest)

void BeginCommand(CommandTag commandTag, CommandDest dest)

void ReadyForQuery(CommandDest dest)

void NullCommand(CommandDest dest)

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

int errhidestmt(bool hide_stmt)

void EmitErrorReport(void)

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

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

ErrorContextCallback * error_context_stack

void FlushErrorState(void)

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

int errcode(int sqlerrcode)

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

sigjmp_buf * PG_exception_stack

#define WARNING_CLIENT_ONLY

#define ereport(elevel,...)

bool equal(const void *a, const void *b)

void EventTriggerOnLogin(void)

void HandleFunctionRequest(StringInfo msgBuf)

void set_max_safe_fds(void)

#define palloc_array(type, count)

#define palloc0_array(type, count)

Datum OidReceiveFunctionCall(Oid functionId, StringInfo buf, Oid typioparam, int32 typmod)

Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)

volatile sig_atomic_t IdleStatsUpdateTimeoutPending

volatile sig_atomic_t LogMemoryContextPending

volatile sig_atomic_t ProcSignalBarrierPending

volatile sig_atomic_t InterruptPending

volatile sig_atomic_t IdleSessionTimeoutPending

volatile uint32 QueryCancelHoldoffCount

ProtocolVersion FrontendProtocol

volatile sig_atomic_t IdleInTransactionSessionTimeoutPending

volatile uint32 InterruptHoldoffCount

volatile sig_atomic_t TransactionTimeoutPending

volatile sig_atomic_t ClientConnectionLost

volatile uint32 CritSectionCount

volatile sig_atomic_t QueryCancelPending

uint8 MyCancelKey[MAX_CANCEL_KEY_LENGTH]

TimestampTz MyStartTimestamp

char OutputFileName[MAXPGPATH]

volatile sig_atomic_t ProcDiePending

volatile sig_atomic_t CheckClientConnectionPending

void ProcessConfigFile(GucContext context)

void BeginReportingGUCOptions(void)

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

void * guc_malloc(int elevel, size_t size)

bool SelectConfigFiles(const char *userDoption, const char *progname)

void ParseLongOption(const char *string, char **name, char **value)

void InitializeGUCOptions(void)

void ReportChangedGUCOptions(void)

#define GUC_check_errdetail

int log_parameter_max_length_on_error

int log_min_duration_statement

int log_min_duration_sample

bool Debug_print_rewritten

int log_parameter_max_length

double log_statement_sample_rate

Assert(PointerIsAligned(start, uint64))

#define INJECTION_POINT(name, arg)

volatile sig_atomic_t ConfigReloadPending

void SignalHandlerForConfigReload(SIGNAL_ARGS)

void on_proc_exit(pg_on_exit_callback function, Datum arg)

bool proc_exit_inprogress

void InitializeShmemGUCs(void)

void CreateSharedMemoryAndSemaphores(void)

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

void jit_reset_after_error(void)

void SetLatch(Latch *latch)

bool IsLogicalLauncher(void)

#define PQ_SMALL_MESSAGE_LIMIT

#define PQ_LARGE_MESSAGE_LIMIT

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

static List * new_list(NodeTag type, int min_size)

void list_free(List *list)

LOCALLOCK * GetAwaitedLock(void)

void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)

void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam)

DispatchOption parse_dispatch_option(const char *name)

char * pg_client_to_server(const char *s, int len)

MemoryContext MessageContext

void MemoryContextReset(MemoryContext context)

char * pstrdup(const char *in)

void MemoryContextSetParent(MemoryContext context, MemoryContext new_parent)

void pfree(void *pointer)

MemoryContext TopMemoryContext

char * pnstrdup(const char *in, Size len)

void MemoryContextStats(MemoryContext context)

MemoryContext PostmasterContext

void ProcessLogMemoryContextInterrupt(void)

void MemoryContextDelete(MemoryContext context)

#define AllocSetContextCreate

#define ALLOCSET_DEFAULT_SIZES

#define RESUME_INTERRUPTS()

#define IsExternalConnectionBackend(backend_type)

#define GetProcessingMode()

#define HOLD_CANCEL_INTERRUPTS()

#define INIT_PG_LOAD_SESSION_LIBS

#define AmAutoVacuumWorkerProcess()

#define RESUME_CANCEL_INTERRUPTS()

#define AmBackgroundWorkerProcess()

#define CHECK_FOR_INTERRUPTS()

#define HOLD_INTERRUPTS()

#define SetProcessingMode(mode)

#define AmWalReceiverProcess()

#define AmIoWorkerProcess()

void ChangeToDataDir(void)

void process_shmem_requests(void)

void InitStandaloneProcess(const char *argv0)

void process_shared_preload_libraries(void)

BackendType MyBackendType

void CreateDataDirLockFile(bool amPostmaster)

#define IsA(nodeptr, _type_)

char * nodeToStringWithLocations(const void *obj)

static MemoryContext MemoryContextSwitchTo(MemoryContext context)

ParamListInfo makeParamList(int numParams)

char * BuildParamLogString(ParamListInfo params, char **knownTextValues, int maxlen)

void ParamsErrorCallback(void *arg)

void(* ParserSetupHook)(struct ParseState *pstate, void *arg)

#define CURSOR_OPT_PARALLEL_OK

#define CURSOR_OPT_BINARY

Query * parse_analyze_withcb(RawStmt *parseTree, const char *sourceText, ParserSetupHook parserSetup, void *parserSetupArg, QueryEnvironment *queryEnv)

bool analyze_requires_snapshot(RawStmt *parseTree)

Query * parse_analyze_fixedparams(RawStmt *parseTree, const char *sourceText, const Oid *paramTypes, int numParams, QueryEnvironment *queryEnv)

Query * parse_analyze_varparams(RawStmt *parseTree, const char *sourceText, Oid **paramTypes, int *numParams, QueryEnvironment *queryEnv)

int getopt(int nargc, char *const *nargv, const char *ostr)

PGDLLIMPORT char * optarg

#define lfirst_node(type, lc)

static int list_length(const List *l)

#define linitial_node(type, l)

static ListCell * lnext(const List *l, const ListCell *c)

double pg_prng_double(pg_prng_state *state)

pg_prng_state pg_global_prng_state

static rewind_source * source

#define MAX_MULTIBYTE_CHAR_LEN

#define ERRCODE_T_R_SERIALIZATION_FAILURE

long pgstat_report_stat(bool force)

void pgstat_report_connect(Oid dboid)

void pgstat_report_recovery_conflict(int reason)

SessionEndType pgStatSessionEndCause

void DropCachedPlan(CachedPlanSource *plansource)

void SaveCachedPlan(CachedPlanSource *plansource)

void CompleteCachedPlan(CachedPlanSource *plansource, List *querytree_list, MemoryContext querytree_context, Oid *param_types, int num_params, ParserSetupHook parserSetup, void *parserSetupArg, int cursor_options, bool fixed_result)

CachedPlan * GetCachedPlan(CachedPlanSource *plansource, ParamListInfo boundParams, ResourceOwner owner, QueryEnvironment *queryEnv)

CachedPlanSource * CreateCachedPlan(RawStmt *raw_parse_tree, const char *query_string, CommandTag commandTag)

List * CachedPlanGetTargetList(CachedPlanSource *plansource, QueryEnvironment *queryEnv)

PlannedStmt * planner(Query *parse, const char *query_string, int cursorOptions, ParamListInfo boundParams)

void InitPostmasterChildSlots(void)

QuitSignalReason GetQuitSignalReason(void)

bool pg_strong_random(void *buf, size_t len)

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

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

void PortalDrop(Portal portal, bool isTopCommit)

Portal GetPortalByName(const char *name)

void PortalDefineQuery(Portal portal, const char *prepStmtName, const char *sourceText, CommandTag commandTag, List *stmts, CachedPlan *cplan)

Portal CreatePortal(const char *name, bool allowDup, bool dupSilent)

void PortalErrorCleanup(void)

static int errdetail_recovery_conflict(ProcSignalReason reason)

struct BindParamCbData BindParamCbData

static void disable_statement_timeout(void)

PlannedStmt * pg_plan_query(Query *querytree, const char *query_string, int cursorOptions, ParamListInfo boundParams)

static bool IsTransactionStmtList(List *pstmts)

List * pg_analyze_and_rewrite_withcb(RawStmt *parsetree, const char *query_string, ParserSetupHook parserSetup, void *parserSetupArg, QueryEnvironment *queryEnv)

void assign_transaction_timeout(int newval, void *extra)

List * pg_parse_query(const char *query_string)

static bool check_log_statement(List *stmt_list)

static void exec_describe_statement_message(const char *stmt_name)

void assign_restrict_nonsystem_relation_kind(const char *newval, void *extra)

void process_postgres_switches(int argc, char *argv[], GucContext ctx, const char **dbname)

void quickdie(SIGNAL_ARGS)

static bool IsTransactionExitStmtList(List *pstmts)

static void log_disconnections(int code, Datum arg)

static int errdetail_abort(void)

static void forbidden_in_wal_sender(char firstchar)

static void exec_execute_message(const char *portal_name, long max_rows)

void PostgresSingleUserMain(int argc, char *argv[], const char *username)

List * pg_plan_queries(List *querytrees, const char *query_string, int cursorOptions, ParamListInfo boundParams)

void set_debug_options(int debug_flag, GucContext context, GucSource source)

static bool UseSemiNewlineNewline

static CachedPlanSource * unnamed_stmt_psrc

void FloatExceptionHandler(SIGNAL_ARGS)

int client_connection_check_interval

bool check_log_stats(bool *newval, void **extra, GucSource source)

void StatementCancelHandler(SIGNAL_ARGS)

CommandDest whereToSendOutput

static bool ignore_till_sync

static void finish_xact_command(void)

bool set_plan_disabling_options(const char *arg, GucContext context, GucSource source)

static void enable_statement_timeout(void)

List * pg_analyze_and_rewrite_fixedparams(RawStmt *parsetree, const char *query_string, const Oid *paramTypes, int numParams, QueryEnvironment *queryEnv)

int check_log_duration(char *msec_str, bool was_logged)

static struct timeval Save_t

const char * debug_query_string

static void exec_simple_query(const char *query_string)

const char * get_stats_option_name(const char *arg)

void HandleRecoveryConflictInterrupt(ProcSignalReason reason)

List * pg_rewrite_query(Query *query)

static volatile sig_atomic_t RecoveryConflictPendingReasons[NUM_PROCSIGNALS]

static int errdetail_execute(List *raw_parsetree_list)

void ShowUsage(const char *title)

static void exec_parse_message(const char *query_string, const char *stmt_name, Oid *paramTypes, int numParams)

int restrict_nonsystem_relation_kind

static const char * userDoption

static volatile sig_atomic_t RecoveryConflictPending

static void exec_bind_message(StringInfo input_message)

static bool DoingCommandRead

static int interactive_getc(void)

static int errdetail_params(ParamListInfo params)

static void ProcessRecoveryConflictInterrupts(void)

static int SocketBackend(StringInfo inBuf)

void ProcessClientReadInterrupt(bool blocked)

void ProcessInterrupts(void)

static void bind_param_error_callback(void *arg)

static bool IsTransactionExitStmt(Node *parsetree)

void PostgresMain(const char *dbname, const char *username)

static MemoryContext row_description_context

static int InteractiveBackend(StringInfo inBuf)

static void ProcessRecoveryConflictInterrupt(ProcSignalReason reason)

static struct rusage Save_r

bool check_client_connection_check_interval(int *newval, void **extra, GucSource source)

static StringInfoData row_description_buf

void ProcessClientWriteInterrupt(bool blocked)

static bool doing_extended_query_message

static void start_xact_command(void)

bool check_restrict_nonsystem_relation_kind(char **newval, void **extra, GucSource source)

static void exec_describe_portal_message(const char *portal_name)

List * pg_analyze_and_rewrite_varparams(RawStmt *parsetree, const char *query_string, Oid **paramTypes, int *numParams, QueryEnvironment *queryEnv)

static void drop_unnamed_stmt(void)

#define valgrind_report_error_query(query)

static int ReadCommand(StringInfo inBuf)

bool check_stage_log_stats(bool *newval, void **extra, GucSource source)

void InitializeMaxBackends(void)

void InitializeFastPathLocks(void)

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

bool ClientAuthInProgress

BackgroundWorker * MyBgworkerEntry

int pq_getmessage(StringInfo s, int maxlen)

bool pq_is_reading_msg(void)

bool pq_check_connection(void)

void pq_startmsgread(void)

#define PG_PROTOCOL(m, n)

unsigned int pq_getmsgint(StringInfo msg, int b)

void pq_sendbytes(StringInfo buf, const void *data, int datalen)

void pq_getmsgend(StringInfo msg)

const char * pq_getmsgstring(StringInfo msg)

void pq_putemptymessage(char msgtype)

void pq_endmessage(StringInfo buf)

int pq_getmsgbyte(StringInfo msg)

void pq_beginmessage(StringInfo buf, char msgtype)

const char * pq_getmsgbytes(StringInfo msg, int datalen)

void pq_beginmessage_reuse(StringInfo buf, char msgtype)

void pq_endmessage_reuse(StringInfo buf)

static void pq_sendint32(StringInfo buf, uint32 i)

static void pq_sendint16(StringInfo buf, uint16 i)

void PortalSetResultFormat(Portal portal, int nFormats, int16 *formats)

void PortalStart(Portal portal, ParamListInfo params, int eflags, Snapshot snapshot)

List * FetchPortalTargetList(Portal portal)

bool PortalRun(Portal portal, long count, bool isTopLevel, DestReceiver *dest, DestReceiver *altdest, QueryCompletion *qc)

void SetRemoteDestReceiverParams(DestReceiver *self, Portal portal)

void SendRowDescriptionMessage(StringInfo buf, TupleDesc typeinfo, List *targetlist, int16 *formats)

void ProcessProcSignalBarrier(void)

void procsignal_sigusr1_handler(SIGNAL_ARGS)

@ PROCSIG_RECOVERY_CONFLICT_BUFFERPIN

@ PROCSIG_RECOVERY_CONFLICT_LOCK

@ PROCSIG_RECOVERY_CONFLICT_LOGICALSLOT

@ PROCSIG_RECOVERY_CONFLICT_DATABASE

@ PROCSIG_RECOVERY_CONFLICT_SNAPSHOT

@ PROCSIG_RECOVERY_CONFLICT_LAST

@ PROCSIG_RECOVERY_CONFLICT_FIRST

@ PROCSIG_RECOVERY_CONFLICT_TABLESPACE

@ PROCSIG_RECOVERY_CONFLICT_STARTUP_DEADLOCK

#define MAX_CANCEL_KEY_LENGTH

#define PqMsg_CloseComplete

#define PqMsg_BindComplete

#define PqMsg_ParameterDescription

#define PqMsg_FunctionCall

#define PqMsg_PortalSuspended

#define PqMsg_BackendKeyData

#define PqMsg_ParseComplete

void set_ps_display_with_len(const char *activity, size_t len)

static void set_ps_display(const char *activity)

int getrusage(int who, struct rusage *rusage)

List * QueryRewrite(Query *parsetree)

void ProcessCatchupInterrupt(void)

volatile sig_atomic_t catchupInterruptPending

ReplicationSlot * MyReplicationSlot

void ReplicationSlotRelease(void)

void ReplicationSlotCleanup(bool synced_only)

Snapshot GetTransactionSnapshot(void)

void PushActiveSnapshot(Snapshot snapshot)

bool ActiveSnapshotSet(void)

void InvalidateCatalogSnapshotConditionally(void)

void PopActiveSnapshot(void)

int IdleInTransactionSessionTimeout

int GetStartupBufferPinWaitBufId(void)

void LockErrorCleanup(void)

void CheckDeadLockAlert(void)

void resetStringInfo(StringInfo str)

void appendStringInfo(StringInfo str, const char *fmt,...)

void appendStringInfoString(StringInfo str, const char *s)

void appendStringInfoChar(StringInfo str, char ch)

void initStringInfo(StringInfo str)

static void initReadOnlyStringInfo(StringInfo str, char *data, int len)

void appendStringInfoStringQuoted(StringInfo str, const char *s, int maxlen)

char bgw_type[BGW_MAXLEN]

const char * query_string

struct RawStmt * raw_parse_tree

TimestampTz ready_for_use

TimestampTz socket_create

struct ErrorContextCallback * previous

void(* callback)(void *arg)

bool recoveryConflictPending

ParamExternData params[FLEXIBLE_ARRAY_MEMBER]

MemoryContext portalContext

ParamListInfo portalParams

const char * prepStmtName

CachedPlanSource * plansource

void(* rDestroy)(DestReceiver *self)

#define RESTRICT_RELKIND_FOREIGN_TABLE

#define RESTRICT_RELKIND_VIEW

void enable_timeout_after(TimeoutId id, int delay_ms)

bool get_timeout_active(TimeoutId id)

void disable_all_timeouts(bool keep_indicators)

TimestampTz get_timeout_finish_time(TimeoutId id)

void InitializeTimeouts(void)

void disable_timeout(TimeoutId id, bool keep_indicator)

bool get_timeout_indicator(TimeoutId id, bool reset_indicator)

@ IDLE_IN_TRANSACTION_SESSION_TIMEOUT

@ IDLE_STATS_UPDATE_TIMEOUT

@ CLIENT_CONNECTION_CHECK_TIMEOUT

CommandTag CreateCommandTag(Node *parsetree)

LogStmtLevel GetCommandLogLevel(Node *parsetree)

static uint64 TimestampDifferenceMicroseconds(TimestampTz start_time, TimestampTz stop_time)

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

bool WaitEventSetCanReportClosed(void)

void WalSndErrorCleanup(void)

bool exec_replication_command(const char *cmd_string)

int gettimeofday(struct timeval *tp, void *tzp)

bool IsTransactionOrTransactionBlock(void)

void BeginImplicitTransactionBlock(void)

bool IsTransactionState(void)

void CommandCounterIncrement(void)

void StartTransactionCommand(void)

bool IsAbortedTransactionBlockState(void)

void EndImplicitTransactionBlock(void)

bool IsSubTransaction(void)

void SetCurrentStatementStartTimestamp(void)

TimestampTz GetCurrentStatementStartTimestamp(void)

void CommitTransactionCommand(void)

void AbortCurrentTransaction(void)

#define XACT_FLAGS_PIPELINING

#define XACT_FLAGS_NEEDIMMEDIATECOMMIT

void InitializeWalConsistencyChecking(void)

void LocalProcessControlFile(bool reset)