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

84

85

86

87

88

90

91

93

94

96

98

99

101

102

104

105

107

108

109

110

111

112

113

115{

117 int paramno;

118 const char *paramval;

120

121

122

123

124

125

126

127

128

129

131

132

133

134

135

136

138

139

140

141

142

145

146

147

148

149

150

152

153

154static const char *userDoption = NULL;

155static bool EchoQuery = false;

157

158

161

162

165

166

167

168

169

189

190

191

192

193

194

195#ifdef USE_VALGRIND

196

197static unsigned int old_valgrind_error_count;

198

199

200

201

202

203

204static void

206{

207 unsigned int valgrind_error_count = VALGRIND_COUNT_ERRORS;

208

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

210 query != NULL)

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

212 valgrind_error_count - old_valgrind_error_count,

213 query);

214}

215

216#else

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

218#endif

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236static int

238{

239 int c;

240

241

242

243

246

248

249

250

251

253 {

254 if (c == '\n')

255 {

257 {

258

259

260

261

262 if (inBuf->len > 1 &&

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

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

265 {

266

267 break;

268 }

269 }

270 else

271 {

272

273

274

275

276 if (inBuf->len > 0 &&

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

278 {

279

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

281

282 continue;

283 }

284 else

285 {

286

288 break;

289 }

290 }

291 }

292

293

295 }

296

297

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

299 return EOF;

300

301

302

303

304

305

307

308

309

310

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

314

316}

317

318

319

320

321

322

323

324static int

326{

327 int c;

328

329

330

331

332

333

334

336

337 c = getc(stdin);

338

340

341 return c;

342}

343

344

345

346

347

348

349

350

351

352static int

354{

355 int qtype;

356 int maxmsglen;

357

358

359

360

364

365 if (qtype == EOF)

366 {

369 (errcode(ERRCODE_CONNECTION_FAILURE),

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

371 else

372 {

373

374

375

376

377

380 (errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST),

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

382 }

383 return qtype;

384 }

385

386

387

388

389

390

391

392

393

394

395

396 switch (qtype)

397 {

401 break;

402

406 break;

407

412 break;

413

418 break;

419

426 break;

427

430

432

434 break;

435

439 break;

440

445 break;

446

447 default:

448

449

450

451

452

453

455 (errcode(ERRCODE_PROTOCOL_VIOLATION),

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

457 maxmsglen = 0;

458 break;

459 }

460

461

462

463

464

465

467 return EOF;

469

470 return qtype;

471}

472

473

474

475

476

477

478

479

480static int

482{

483 int result;

484

487 else

489 return result;

490}

491

492

493

494

495

496

497

498

499

500

501void

503{

504 int save_errno = errno;

505

507 {

508

510

511

514

515

518 }

520 {

521

522

523

524

525

526

527

528

529 if (blocked)

531 else

533 }

534

535 errno = save_errno;

536}

537

538

539

540

541

542

543

544

545

546

547void

549{

550 int save_errno = errno;

551

553 {

554

555

556

557

558

559

560

561

562

563 if (blocked)

564 {

565

566

567

568

570 {

571

572

573

574

575

576

579

581 }

582 }

583 else

585 }

586

587 errno = save_errno;

588}

589

590

591

592

593

594

595

596

597

598

599

600

601

602

605{

606 List *raw_parsetree_list;

607

608 TRACE_POSTGRESQL_QUERY_PARSE_START(query_string);

609

612

614

617

618#ifdef DEBUG_NODE_TESTS_ENABLED

619

620

621 if (Debug_copy_parse_plan_trees)

622 {

624

625

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

628 else

629 raw_parsetree_list = new_list;

630 }

631

632

633

634

635

636 if (Debug_write_read_parse_plan_trees)

637 {

640

642

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

645 else

646 raw_parsetree_list = new_list;

647 }

648

649#endif

650

651 TRACE_POSTGRESQL_QUERY_PARSE_DONE(query_string);

652

656

657 return raw_parsetree_list;

658}

659

660

661

662

663

664

665

666

667

668

671 const char *query_string,

672 const Oid *paramTypes,

673 int numParams,

675{

677 List *querytree_list;

678

679 TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);

680

681

682

683

686

688 queryEnv);

689

691 ShowUsage("PARSE ANALYSIS STATISTICS");

692

693

694

695

697

698 TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);

699

700 return querytree_list;

701}

702

703

704

705

706

707

710 const char *query_string,

711 Oid **paramTypes,

712 int *numParams,

714{

716 List *querytree_list;

717

718 TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);

719

720

721

722

725

727 queryEnv);

728

729

730

731

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

733 {

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

735

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

738 (errcode(ERRCODE_INDETERMINATE_DATATYPE),

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

740 i + 1)));

741 }

742

744 ShowUsage("PARSE ANALYSIS STATISTICS");

745

746

747

748

750

751 TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);

752

753 return querytree_list;

754}

755

756

757

758

759

760

761

764 const char *query_string,

766 void *parserSetupArg,

768{

770 List *querytree_list;

771

772 TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);

773

774

775

776

779

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

781 queryEnv);

782

784 ShowUsage("PARSE ANALYSIS STATISTICS");

785

786

787

788

790

791 TRACE_POSTGRESQL_QUERY_REWRITE_DONE(query_string);

792

793 return querytree_list;

794}

795

796

797

798

799

800

801

804{

805 List *querytree_list;

806

810

813

815 {

816

818 }

819 else

820 {

821

823 }

824

826 ShowUsage("REWRITER STATISTICS");

827

828#ifdef DEBUG_NODE_TESTS_ENABLED

829

830

831 if (Debug_copy_parse_plan_trees)

832 {

834

836

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

839 else

841 }

842

843

844 if (Debug_write_read_parse_plan_trees)

845 {

848

849 foreach(lc, querytree_list)

850 {

853 Query *new_query = stringToNodeWithLocations(str);

854

855

856

857

858

859 new_query->queryId = curr_query->queryId;

860

863 }

864

865

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

868 else

870 }

871

872#endif

873

877

878 return querytree_list;

879}

880

881

882

883

884

885

889{

891

892

894 return NULL;

895

896

898

899 TRACE_POSTGRESQL_QUERY_PLAN_START();

900

903

904

906

909

910#ifdef DEBUG_NODE_TESTS_ENABLED

911

912

913 if (Debug_copy_parse_plan_trees)

914 {

916

917

918

919

920

921#ifdef NOT_USED

922

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

925 else

926#endif

927 plan = new_plan;

928 }

929

930

931 if (Debug_write_read_parse_plan_trees)

932 {

933 char *str;

935

937 new_plan = stringToNodeWithLocations(str);

939

940

941

942

943

944#ifdef NOT_USED

945

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

948 else

949#endif

950 plan = new_plan;

951 }

952

953#endif

954

955

956

957

960

961 TRACE_POSTGRESQL_QUERY_PLAN_DONE();

962

964}

965

966

967

968

969

970

971

972

973

977{

980

981 foreach(query_list, querytrees)

982 {

985

987 {

988

991 stmt->canSetTag = query->canSetTag;

994 stmt->stmt_len = query->stmt_len;

995 stmt->queryId = query->queryId;

997 }

998 else

999 {

1001 boundParams, NULL);

1002 }

1003

1005 }

1006

1007 return stmt_list;

1008}

1009

1010

1011

1012

1013

1014

1015

1016static void

1018{

1021 List *parsetree_list;

1024 bool was_logged = false;

1025 bool use_implicit_block;

1026 char msec_str[32];

1027

1028

1029

1030

1032

1034

1035 TRACE_POSTGRESQL_QUERY_START(query_string);

1036

1037

1038

1039

1040

1041 if (save_log_statement_stats)

1043

1044

1045

1046

1047

1048

1049

1050

1052

1053

1054

1055

1056

1057

1058

1060

1061

1062

1063

1065

1066

1067

1068

1069

1071

1072

1074 {

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

1079 was_logged = true;

1080 }

1081

1082

1083

1084

1086

1087

1088

1089

1090

1091

1092

1093

1094

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

1096

1097

1098

1099

1100 foreach(parsetree_item, parsetree_list)

1101 {

1103 bool snapshot_set = false;

1107 List *querytree_list,

1108 *plantree_list;

1112 const char *cmdtagname;

1113 size_t cmdtaglen;

1114

1117

1118

1119

1120

1121

1122

1123

1126

1128

1130

1131

1132

1133

1134

1135

1136

1137

1138

1142 (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),

1143 errmsg("current transaction is aborted, "

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

1146

1147

1149

1150

1151

1152

1153

1154

1155

1156

1157 if (use_implicit_block)

1159

1160

1162

1163

1164

1165

1167 {

1169 snapshot_set = true;

1170 }

1171

1172

1173

1174

1175

1176

1177

1178

1179

1180

1181

1182

1183

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

1185 {

1186 per_parsetree_context =

1188 "per-parsetree message context",

1191 }

1192 else

1194

1196 NULL, 0, NULL);

1197

1198 plantree_list = pg_plan_queries(querytree_list, query_string,

1200

1201

1202

1203

1204

1205

1206

1207

1208

1209

1210

1211 if (snapshot_set)

1213

1214

1216

1217

1218

1219

1220

1222

1223 portal->visible = false;

1224

1225

1226

1227

1228

1229

1231 NULL,

1232 query_string,

1233 commandTag,

1234 plantree_list,

1235 NULL);

1236

1237

1238

1239

1241

1242

1243

1244

1245

1246

1247

1248 format = 0;

1250 {

1252

1254 {

1256

1259 format = 1;

1260 }

1261 }

1263

1264

1265

1266

1270

1271

1272

1273

1275

1276

1277

1278

1281 true,

1282 receiver,

1283 receiver,

1284 &qc);

1285

1286 receiver->rDestroy(receiver);

1287

1289

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

1291 {

1292

1293

1294

1295

1296

1297

1298

1299

1300

1301 if (use_implicit_block)

1304 }

1306 {

1307

1308

1309

1310

1312 }

1313 else

1314 {

1315

1316

1317

1318

1319

1321

1322

1323

1324

1325

1327

1328

1329

1330

1331

1332

1334 }

1335

1336

1337

1338

1339

1340

1341

1343

1344

1345 if (per_parsetree_context)

1347 }

1348

1349

1350

1351

1352

1353

1355

1356

1357

1358

1359 if (!parsetree_list)

1361

1362

1363

1364

1366 {

1367 case 1:

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

1371 break;

1372 case 2:

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

1375 msec_str, query_string),

1378 break;

1379 }

1380

1381 if (save_log_statement_stats)

1383

1384 TRACE_POSTGRESQL_QUERY_DONE(query_string);

1385

1387}

1388

1389

1390

1391

1392

1393

1394static void

1396 const char *stmt_name,

1397 Oid *paramTypes,

1398 int numParams)

1399{

1402 List *parsetree_list;

1403 RawStmt *raw_parse_tree;

1404 List *querytree_list;

1406 bool is_named;

1408 char msec_str[32];

1409

1410

1411

1412

1414

1416

1418

1419 if (save_log_statement_stats)

1421

1424 *stmt_name ? stmt_name : "",

1425 query_string)));

1426

1427

1428

1429

1430

1431

1432

1434

1435

1436

1437

1438

1439

1440

1441

1442

1443

1444

1445

1446

1447

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

1449 if (is_named)

1450 {

1451

1453 }

1454 else

1455 {

1456

1458

1459 unnamed_stmt_context =

1461 "unnamed prepared statement",

1464 }

1465

1466

1467

1468

1469

1471

1472

1473

1474

1475

1476

1479 (errcode(ERRCODE_SYNTAX_ERROR),

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

1481

1482 if (parsetree_list != NIL)

1483 {

1484 bool snapshot_set = false;

1485

1487

1488

1489

1490

1491

1492

1493

1494

1495

1499 (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),

1500 errmsg("current transaction is aborted, "

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

1503

1504

1505

1506

1507

1510

1511

1512

1513

1515 {

1517 snapshot_set = true;

1518 }

1519

1520

1521

1522

1523

1524

1526 query_string,

1527 &paramTypes,

1528 &numParams,

1529 NULL);

1530

1531

1532 if (snapshot_set)

1534 }

1535 else

1536 {

1537

1538 raw_parse_tree = NULL;

1540 CMDTAG_UNKNOWN);

1541 querytree_list = NIL;

1542 }

1543

1544

1545

1546

1547

1548

1549

1550 if (unnamed_stmt_context)

1552

1553

1555 querytree_list,

1556 unnamed_stmt_context,

1557 paramTypes,

1558 numParams,

1559 NULL,

1560 NULL,

1562 true);

1563

1564

1566

1567 if (is_named)

1568 {

1569

1570

1571

1573 }

1574 else

1575 {

1576

1577

1578

1581 }

1582

1584

1585

1586

1587

1588

1589

1591

1592

1593

1594

1597

1598

1599

1600

1602 {

1603 case 1:

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

1607 break;

1608 case 2:

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

1611 msec_str,

1612 *stmt_name ? stmt_name : "",

1613 query_string),

1615 break;

1616 }

1617

1618 if (save_log_statement_stats)

1619 ShowUsage("PARSE MESSAGE STATISTICS");

1620

1622}

1623

1624

1625

1626

1627

1628

1629static void

1631{

1632 const char *portal_name;

1633 const char *stmt_name;

1634 int numPFormats;

1635 int16 *pformats = NULL;

1636 int numParams;

1637 int numRFormats;

1638 int16 *rformats = NULL;

1642 char *query_string;

1643 char *saved_stmt_name;

1647 bool snapshot_set = false;

1648 char msec_str[32];

1652

1653

1656

1659 *portal_name ? portal_name : "",

1660 *stmt_name ? stmt_name : "")));

1661

1662

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

1664 {

1666

1669 }

1670 else

1671 {

1672

1674 if (!psrc)

1676 (errcode(ERRCODE_UNDEFINED_PSTATEMENT),

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

1678 }

1679

1680

1681

1682

1684

1686

1688 {

1690

1691 if (query->queryId != INT64CONST(0))

1692 {

1694 break;

1695 }

1696 }

1697

1699

1700 if (save_log_statement_stats)

1702

1703

1704

1705

1706

1707

1708

1710

1711

1713

1714

1715 numPFormats = pq_getmsgint(input_message, 2);

1716 if (numPFormats > 0)

1717 {

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

1721 }

1722

1723

1725

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

1728 (errcode(ERRCODE_PROTOCOL_VIOLATION),

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

1730 numPFormats, numParams)));

1731

1734 (errcode(ERRCODE_PROTOCOL_VIOLATION),

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

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

1737

1738

1739

1740

1741

1742

1743

1744

1745

1749 numParams != 0))

1751 (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),

1752 errmsg("current transaction is aborted, "

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

1755

1756

1757

1758

1759

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

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

1762 else

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

1764

1765

1766

1767

1768

1769

1770

1772

1773

1775

1776

1777 if (stmt_name[0])

1778 saved_stmt_name = pstrdup(stmt_name);

1779 else

1780 saved_stmt_name = NULL;

1781

1782

1783

1784

1785

1786

1787

1788

1789 if (numParams > 0 ||

1792 {

1794 snapshot_set = true;

1795 }

1796

1797

1798

1799

1800 if (numParams > 0)

1801 {

1802 char **knownTextValues = NULL;

1804

1805

1806

1807

1808

1810 one_param_data.paramno = -1;

1811 one_param_data.paramval = NULL;

1814 params_errcxt.arg = &one_param_data;

1816

1818

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

1820 {

1824 bool isNull;

1826 char csave;

1828

1829 one_param_data.paramno = paramno;

1830 one_param_data.paramval = NULL;

1831

1833 isNull = (plength == -1);

1834

1835 if (!isNull)

1836 {

1837 char *pvalue;

1838

1839

1840

1841

1842

1843

1844

1845

1847 csave = pvalue[plength];

1848 pvalue[plength] = '\0';

1850 }

1851 else

1852 {

1853 pbuf.data = NULL;

1854 csave = 0;

1855 }

1856

1857 if (numPFormats > 1)

1858 pformat = pformats[paramno];

1859 else if (numPFormats > 0)

1860 pformat = pformats[0];

1861 else

1862 pformat = 0;

1863

1864 if (pformat == 0)

1865 {

1866 Oid typinput;

1867 Oid typioparam;

1868 char *pstring;

1869

1871

1872

1873

1874

1875

1876 if (isNull)

1877 pstring = NULL;

1878 else

1880

1881

1882 one_param_data.paramval = pstring;

1883

1885

1886 one_param_data.paramval = NULL;

1887

1888

1889

1890

1891

1892

1893 if (pstring)

1894 {

1896 {

1898

1900

1901 if (knownTextValues == NULL)

1902 knownTextValues = palloc0_array(char *, numParams);

1903

1905 knownTextValues[paramno] = pstrdup(pstring);

1906 else

1907 {

1908

1909

1910

1911

1912

1913

1914

1915 knownTextValues[paramno] =

1919 }

1920

1922 }

1923 if (pstring != pbuf.data)

1925 }

1926 }

1927 else if (pformat == 1)

1928 {

1929 Oid typreceive;

1930 Oid typioparam;

1932

1933

1934

1935

1937

1938 if (isNull)

1939 bufptr = NULL;

1940 else

1941 bufptr = &pbuf;

1942

1944

1945

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

1948 (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),

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

1950 paramno + 1)));

1951 }

1952 else

1953 {

1955 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

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

1957 pformat)));

1958 pval = 0;

1959 }

1960

1961

1962 if (!isNull)

1963 pbuf.data[plength] = csave;

1964

1967

1968

1969

1970

1971

1974 }

1975

1976

1978

1979

1980

1981

1982

1983

1987 knownTextValues,

1989 }

1990 else

1991 params = NULL;

1992

1993

1995

1996

1997

1998

1999

2001 params_data.params = params;

2004 params_errcxt.arg = &params_data;

2006

2007

2008 numRFormats = pq_getmsgint(input_message, 2);

2009 if (numRFormats > 0)

2010 {

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

2014 }

2015

2017

2018

2019

2020

2021

2022

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

2024

2025

2026

2027

2028

2029

2030

2032 saved_stmt_name,

2033 query_string,

2036 cplan);

2037

2038

2039 foreach(lc, portal->stmts)

2040 {

2042

2044 {

2046 break;

2047 }

2048 }

2049

2050

2051 if (snapshot_set)

2053

2054

2055

2056

2058

2059

2060

2061

2063

2064

2065

2066

2067

2069

2070

2071

2072

2075

2076

2077

2078

2080 {

2081 case 1:

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

2085 break;

2086 case 2:

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

2089 msec_str,

2090 *stmt_name ? stmt_name : "",

2091 *portal_name ? "/" : "",

2092 *portal_name ? portal_name : "",

2096 break;

2097 }

2098

2099 if (save_log_statement_stats)

2100 ShowUsage("BIND MESSAGE STATISTICS");

2101

2103

2105}

2106

2107

2108

2109

2110

2111

2112static void

2114{

2118 bool completed;

2120 const char *sourceText;

2121 const char *prepStmtName;

2124 bool is_xact_command;

2125 bool execute_is_fetch;

2126 bool was_logged = false;

2127 char msec_str[32];

2130 const char *cmdtagname;

2131 size_t cmdtaglen;

2133

2134

2138

2142 (errcode(ERRCODE_UNDEFINED_CURSOR),

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

2144

2145

2146

2147

2148

2149 if (portal->commandTag == CMDTAG_UNKNOWN)

2150 {

2153 return;

2154 }

2155

2156

2158

2159

2160

2161

2162

2163

2164

2168 else

2169 prepStmtName = "";

2171

2172

2173

2174

2176

2178

2179 foreach(lc, portal->stmts)

2180 {

2182

2184 {

2186 break;

2187 }

2188 }

2189

2190 foreach(lc, portal->stmts)

2191 {

2193

2195 {

2197 break;

2198 }

2199 }

2200

2202

2204

2205 if (save_log_statement_stats)

2207

2209

2210

2211

2212

2213

2217

2218

2219

2220

2221

2223

2224

2225

2226

2227

2228

2229

2230 execute_is_fetch = !portal->atStart;

2231

2232

2234 {

2236 (errmsg("%s %s%s%s: %s",

2237 execute_is_fetch ?

2238 _("execute fetch from") :

2239 _("execute"),

2240 prepStmtName,

2241 *portal_name ? "/" : "",

2242 *portal_name ? portal_name : "",

2243 sourceText),

2246 was_logged = true;

2247 }

2248

2249

2250

2251

2252

2256 (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),

2257 errmsg("current transaction is aborted, "

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

2260

2261

2263

2264

2265

2266

2267

2269 params_data.params = portalParams;

2272 params_errcxt.arg = &params_data;

2274

2275 if (max_rows <= 0)

2277

2279 max_rows,

2280 true,

2281 receiver,

2282 receiver,

2283 &qc);

2284

2285 receiver->rDestroy(receiver);

2286

2287

2289

2290 if (completed)

2291 {

2293 {

2294

2295

2296

2297

2298

2299

2300

2301

2303

2304

2305

2306

2307

2308

2309 portalParams = NULL;

2310 }

2311 else

2312 {

2313

2314

2315

2316

2318

2319

2320

2321

2322

2324

2325

2326

2327

2328

2330 }

2331

2332

2334 }

2335 else

2336 {

2337

2340

2341

2342

2343

2344

2346 }

2347

2348

2349

2350

2352 {

2353 case 1:

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

2357 break;

2358 case 2:

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

2361 msec_str,

2362 execute_is_fetch ?

2363 _("execute fetch from") :

2364 _("execute"),

2365 prepStmtName,

2366 *portal_name ? "/" : "",

2367 *portal_name ? portal_name : "",

2368 sourceText),

2371 break;

2372 }

2373

2374 if (save_log_statement_stats)

2375 ShowUsage("EXECUTE MESSAGE STATISTICS");

2376

2378

2380}

2381

2382

2383

2384

2385

2386

2387

2388

2389static bool

2391{

2393

2395 return false;

2397 return true;

2398

2399

2400 foreach(stmt_item, stmt_list)

2401 {

2403

2405 return true;

2406 }

2407

2408 return false;

2409}

2410

2411

2412

2413

2414

2415

2416

2417

2418

2419

2420

2421

2422

2423

2424

2425

2426

2427

2428int

2430{

2433 {

2434 long secs;

2435 int usecs;

2436 int msecs;

2437 bool exceeded_duration;

2438 bool exceeded_sample_duration;

2439 bool in_sample = false;

2440

2443 &secs, &usecs);

2444 msecs = usecs / 1000;

2445

2446

2447

2448

2449

2450

2455

2460

2461

2462

2463

2464

2465

2466 if (exceeded_sample_duration)

2470

2472 {

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

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

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

2476 return 2;

2477 else

2478 return 1;

2479 }

2480 }

2481

2482 return 0;

2483}

2484

2485

2486

2487

2488

2489

2490

2491static int

2493{

2495

2496 foreach(parsetree_item, raw_parsetree_list)

2497 {

2499

2501 {

2504

2506 if (pstmt)

2507 {

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

2509 return 0;

2510 }

2511 }

2512 }

2513

2514 return 0;

2515}

2516

2517

2518

2519

2520

2521

2522

2523

2524static int

2526{

2528 {

2529 char *str;

2530

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

2534 }

2535

2536 return 0;

2537}

2538

2539

2540

2541

2542

2543

2544static int

2546{

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

2549

2550 return 0;

2551}

2552

2553

2554

2555

2556

2557

2558static int

2560{

2561 switch (reason)

2562 {

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

2565 break;

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

2568 break;

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

2571 break;

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

2574 break;

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

2577 break;

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

2580 break;

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

2583 break;

2584 default:

2585 break;

2586

2587 }

2588

2589 return 0;

2590}

2591

2592

2593

2594

2595

2596

2597static void

2599{

2602 char *quotedval;

2603

2604 if (data->paramno < 0)

2605 return;

2606

2607

2608 if (data->paramval)

2609 {

2613 quotedval = buf.data;

2614 }

2615 else

2616 quotedval = NULL;

2617

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

2619 {

2620 if (quotedval)

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

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

2623 else

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

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

2626 }

2627 else

2628 {

2629 if (quotedval)

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

2631 data->paramno + 1, quotedval);

2632 else

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

2634 data->paramno + 1);

2635 }

2636

2637 if (quotedval)

2638 pfree(quotedval);

2639}

2640

2641

2642

2643

2644

2645

2646static void

2648{

2650

2651

2652

2653

2654

2656

2657

2659

2660

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

2662 {

2664

2667 }

2668 else

2669 {

2670

2672 if (!psrc)

2674 (errcode(ERRCODE_UNDEFINED_PSTATEMENT),

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

2676 }

2677

2678

2680

2681

2682

2683

2684

2685

2686

2687

2688

2689

2693 (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),

2694 errmsg("current transaction is aborted, "

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

2697

2699 return;

2700

2701

2702

2703

2706

2708 {

2710

2712 }

2714

2715

2716

2717

2719 {

2720 List *tlist;

2721

2722

2724

2727 tlist,

2728 NULL);

2729 }

2730 else

2732}

2733

2734

2735

2736

2737

2738

2739static void

2741{

2743

2744

2745

2746

2747

2749

2750

2752

2756 (errcode(ERRCODE_UNDEFINED_CURSOR),

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

2758

2759

2760

2761

2762

2763

2764

2765

2766

2770 (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),

2771 errmsg("current transaction is aborted, "

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

2774

2776 return;

2777

2783 else

2785}

2786

2787

2788

2789

2790

2791static void

2793{

2795 {

2797

2799 }

2801 {

2802

2803

2804

2805

2806

2807

2808

2810 }

2811

2812

2813

2814

2815

2816

2817

2818

2820

2821

2828}

2829

2830static void

2832{

2833

2835

2837 {

2839

2840#ifdef MEMORY_CONTEXT_CHECKING

2841

2842

2844#endif

2845

2846#ifdef SHOW_MEMORY_STATS

2847

2849#endif

2850

2852 }

2853}

2854

2855

2856

2857

2858

2859

2860

2861

2862static bool

2864{

2866 {

2868

2873 return true;

2874 }

2875 return false;

2876}

2877

2878

2879static bool

2881{

2883 {

2885

2888 return true;

2889 }

2890 return false;

2891}

2892

2893

2894static bool

2896{

2898 {

2900

2903 return true;

2904 }

2905 return false;

2906}

2907

2908

2909static void

2911{

2912

2914 {

2916

2919 }

2920}

2921

2922

2923

2924

2925

2926

2927

2928

2929

2930

2931

2932

2933

2934void

2936{

2937 sigaddset(&BlockSig, SIGQUIT);

2938 sigprocmask(SIG_SETMASK, &BlockSig, NULL);

2939

2940

2941

2942

2943

2944

2946

2947

2948

2949

2950

2951

2952

2955

2956

2957

2958

2959

2960

2961

2962

2963

2964

2965

2966

2967

2968

2969

2970

2971

2973

2974

2975

2976

2977

2978

2979

2980

2981

2983 {

2985

2987 (errcode(ERRCODE_ADMIN_SHUTDOWN),

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

2989 break;

2991

2993 (errcode(ERRCODE_CRASH_SHUTDOWN),

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

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

2996 " the current transaction and exit, because another"

2997 " server process exited abnormally and possibly corrupted"

2998 " shared memory."),

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

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

3001 break;

3003

3005 (errcode(ERRCODE_ADMIN_SHUTDOWN),

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

3007 break;

3008 }

3009

3010

3011

3012

3013

3014

3015

3016

3017

3018

3019

3020

3021

3022

3023

3024 _exit(2);

3025}

3026

3027

3028

3029

3030

3031void

3033{

3034

3036 {

3039 }

3040

3041

3043

3044

3046

3047

3048

3049

3050

3051

3052

3055}

3056

3057

3058

3059

3060

3061void

3063{

3064

3065

3066

3068 {

3071 }

3072

3073

3075}

3076

3077

3078void

3080{

3081

3083 (errcode(ERRCODE_FLOATING_POINT_EXCEPTION),

3084 errmsg("floating-point exception"),

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

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

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

3088}

3089

3090

3091

3092

3093

3094void

3096{

3100

3101}

3102

3103

3104

3105

3106static void

3108{

3109 switch (reason)

3110 {

3112

3113

3114

3115

3117 return;

3118

3119

3120

3121

3123

3124

3125

3126

3127

3128

3129

3130

3131

3132

3133

3135 {

3139 return;

3140 }

3141

3143

3144

3145

3146

3150

3151

3152

3153

3155 return;

3156

3157

3158

3160

3161

3162

3163

3164

3165

3166

3167

3168

3169

3170

3171

3172

3173

3174

3175

3176

3177

3178

3179

3180

3181

3182

3183

3184

3185

3188 {

3189

3190

3191

3192

3193

3195 return;

3196

3197

3198

3199

3200

3201

3202

3203

3205 {

3206

3208 {

3209

3210

3211

3212

3216 return;

3217 }

3218

3219

3220

3221

3222

3223

3224

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

3231 break;

3232 }

3233 }

3234

3235

3236

3237

3239

3240

3241

3242

3243

3244

3248 ERRCODE_DATABASE_DROPPED :

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

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

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

3254 break;

3255

3256 default:

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

3258 }

3259}

3260

3261

3262

3263

3264static void

3266{

3267

3268

3269

3270

3271

3275

3277

3280 reason++)

3281 {

3283 {

3286 }

3287 }

3288}

3289

3290

3291

3292

3293

3294

3295

3296

3297

3298

3299

3300

3301

3302

3303void

3305{

3306

3308 return;

3310

3312 {

3316

3321 (errcode(ERRCODE_QUERY_CANCELED),

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

3325 (errcode(ERRCODE_ADMIN_SHUTDOWN),

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

3329 (errcode(ERRCODE_ADMIN_SHUTDOWN),

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

3332 {

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

3335

3336

3337

3338

3339

3341 }

3344 (errcode(ERRCODE_ADMIN_SHUTDOWN),

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

3348 (errcode(ERRCODE_ADMIN_SHUTDOWN),

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

3352 {

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

3355

3357 }

3358 else

3360 (errcode(ERRCODE_ADMIN_SHUTDOWN),

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

3362 }

3363

3365 {

3367

3368

3369

3370

3371

3372

3373

3375 {

3378 else

3381 }

3382 }

3383

3385 {

3386 QueryCancelPending = false;

3388

3391 (errcode(ERRCODE_CONNECTION_FAILURE),

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

3393 }

3394

3395

3396

3397

3398

3399

3400

3401

3402

3404 {

3405

3406

3407

3408

3409

3410

3411

3412

3414 }

3416 {

3417 bool lock_timeout_occurred;

3418 bool stmt_timeout_occurred;

3419

3421

3422

3423

3424

3425

3428

3429

3430

3431

3432

3433

3434

3435 if (lock_timeout_occurred && stmt_timeout_occurred &&

3437 lock_timeout_occurred = false;

3438

3439 if (lock_timeout_occurred)

3440 {

3443 (errcode(ERRCODE_LOCK_NOT_AVAILABLE),

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

3445 }

3446 if (stmt_timeout_occurred)

3447 {

3450 (errcode(ERRCODE_QUERY_CANCELED),

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

3452 }

3454 {

3457 (errcode(ERRCODE_QUERY_CANCELED),

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

3459 }

3460

3461

3462

3463

3464

3465

3467 {

3470 (errcode(ERRCODE_QUERY_CANCELED),

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

3472 }

3473 }

3474

3477

3479 {

3480

3481

3482

3483

3484

3485

3488 {

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

3491 (errcode(ERRCODE_IDLE_IN_TRANSACTION_SESSION_TIMEOUT),

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

3493 }

3494 }

3495

3497 {

3498

3501 {

3504 (errcode(ERRCODE_TRANSACTION_TIMEOUT),

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

3506 }

3507 }

3508

3510 {

3511

3514 {

3517 (errcode(ERRCODE_IDLE_SESSION_TIMEOUT),

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

3519 }

3520 }

3521

3522

3523

3524

3525

3528 {

3531 }

3532

3535

3538

3541

3544}

3545

3546

3547

3548

3549bool

3551{

3553 {

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

3555 return false;

3556 }

3557 return true;

3558}

3559

3560

3561

3562

3563

3564

3565

3566

3567

3568

3569

3570bool

3572{

3574 {

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

3576 return false;

3577 }

3578 return true;

3579}

3580

3581

3582

3583

3584bool

3586{

3589 {

3591 "\"log_parser_stats\", \"log_planner_stats\", "

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

3593 return false;

3594 }

3595 return true;

3596}

3597

3598

3599void

3601{

3603 {

3604

3605

3606

3607

3612 }

3613}

3614

3615

3616

3617

3618bool

3620{

3621 char *rawstring;

3622 List *elemlist;

3624 int flags = 0;

3625

3626

3628

3630 {

3631

3633 pfree(rawstring);

3635 return false;

3636 }

3637

3638 foreach(l, elemlist)

3639 {

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

3641

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

3646 else

3647 {

3649 pfree(rawstring);

3651 return false;

3652 }

3653 }

3654

3655 pfree(rawstring);

3657

3658

3660 if (!*extra)

3661 return false;

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

3663

3664 return true;

3665}

3666

3667

3668

3669

3670void

3672{

3673 int *flags = (int *) extra;

3674

3676}

3677

3678

3679

3680

3681

3682

3683

3684void

3686{

3687 if (debug_flag > 0)

3688 {

3689 char debugstr[64];

3690

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

3693 }

3694 else

3696

3698 {

3701 }

3702 if (debug_flag >= 2)

3704 if (debug_flag >= 3)

3705 {

3708 }

3709 if (debug_flag >= 4)

3711 if (debug_flag >= 5)

3713}

3714

3715

3716bool

3718{

3719 const char *tmp = NULL;

3720

3721 switch (arg[0])

3722 {

3723 case 's':

3724 tmp = "enable_seqscan";

3725 break;

3726 case 'i':

3727 tmp = "enable_indexscan";

3728 break;

3729 case 'o':

3730 tmp = "enable_indexonlyscan";

3731 break;

3732 case 'b':

3733 tmp = "enable_bitmapscan";

3734 break;

3735 case 't':

3736 tmp = "enable_tidscan";

3737 break;

3738 case 'n':

3739 tmp = "enable_nestloop";

3740 break;

3741 case 'm':

3742 tmp = "enable_mergejoin";

3743 break;

3744 case 'h':

3745 tmp = "enable_hashjoin";

3746 break;

3747 }

3748 if (tmp)

3749 {

3751 return true;

3752 }

3753 else

3754 return false;

3755}

3756

3757

3758const char *

3760{

3761 switch (arg[0])

3762 {

3763 case 'p':

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

3765 return "log_parser_stats";

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

3767 return "log_planner_stats";

3768 break;

3769

3770 case 'e':

3771 return "log_executor_stats";

3772 break;

3773 }

3774

3775 return NULL;

3776}

3777

3778

3779

3780

3781

3782

3783

3784

3785

3786

3787

3788

3789

3790

3791

3792

3793

3794

3795

3796

3797

3798void

3800 const char **dbname)

3801{

3803 int errs = 0;

3806

3807 if (secure)

3808 {

3809 gucsource = PGC_S_ARGV;

3810

3811

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

3813 {

3814 argv++;

3815 argc--;

3816 }

3817 }

3818 else

3819 {

3820 gucsource = PGC_S_CLIENT;

3821 }

3822

3823#ifdef HAVE_INT_OPTERR

3824

3825

3826

3827

3828

3829

3831#endif

3832

3833

3834

3835

3836

3837

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

3839 {

3840 switch (flag)

3841 {

3842 case 'B':

3844 break;

3845

3846 case 'b':

3847

3848 if (secure)

3850 break;

3851

3852 case 'C':

3853

3854 break;

3855

3856 case '-':

3857

3858

3859

3860

3861

3862

3863

3866 (errcode(ERRCODE_SYNTAX_ERROR),

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

3868

3869

3870 case 'c':

3871 {

3874

3877 {

3878 if (flag == '-')

3880 (errcode(ERRCODE_SYNTAX_ERROR),

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

3883 else

3885 (errcode(ERRCODE_SYNTAX_ERROR),

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

3888 }

3892 break;

3893 }

3894

3895 case 'D':

3896 if (secure)

3898 break;

3899

3900 case 'd':

3902 break;

3903

3904 case 'E':

3905 if (secure)

3907 break;

3908

3909 case 'e':

3911 break;

3912

3913 case 'F':

3915 break;

3916

3917 case 'f':

3919 errs++;

3920 break;

3921

3922 case 'h':

3924 break;

3925

3926 case 'i':

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

3928 break;

3929

3930 case 'j':

3931 if (secure)

3933 break;

3934

3935 case 'k':

3937 break;

3938

3939 case 'l':

3941 break;

3942

3943 case 'N':

3945 break;

3946

3947 case 'n':

3948

3949 break;

3950

3951 case 'O':

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

3953 break;

3954

3955 case 'P':

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

3957 break;

3958

3959 case 'p':

3961 break;

3962

3963 case 'r':

3964

3965 if (secure)

3967 break;

3968

3969 case 'S':

3971 break;

3972

3973 case 's':

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

3975 break;

3976

3977 case 'T':

3978

3979 break;

3980

3981 case 't':

3982 {

3984

3985 if (tmp)

3987 else

3988 errs++;

3989 break;

3990 }

3991

3992 case 'v':

3993

3994

3995

3996

3997

3998

3999

4000

4001 if (secure)

4003 break;

4004

4005 case 'W':

4007 break;

4008

4009 default:

4010 errs++;

4011 break;

4012 }

4013

4014 if (errs)

4015 break;

4016 }

4017

4018

4019

4020

4023

4024 if (errs || argc != optind)

4025 {

4026 if (errs)

4027 optind--;

4028

4029

4032 errcode(ERRCODE_SYNTAX_ERROR),

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

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

4035 else

4037 errcode(ERRCODE_SYNTAX_ERROR),

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

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

4041 }

4042

4043

4044

4045

4046

4048#ifdef HAVE_INT_OPTRESET

4049 optreset = 1;

4050#endif

4051}

4052

4053

4054

4055

4056

4057

4058

4059

4060

4061

4062

4063void

4066{

4067 const char *dbname = NULL;

4068

4070

4071

4073

4074

4075

4076

4078

4079

4080

4081

4083

4084

4086 {

4090 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),

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

4093 }

4094

4095

4098

4099

4100

4101

4102

4105

4106

4107

4108

4110

4111

4113

4114

4115

4116

4118

4119

4121

4122

4123

4124

4125

4127

4128

4130

4131

4132

4133

4135

4136

4137

4138

4139

4140

4142

4143

4144

4145

4146

4148

4149

4150

4151

4152

4154

4155

4156

4157

4158

4160

4161

4162

4163

4164

4166

4167

4168

4169

4170

4172

4173

4174

4175

4176

4178}

4179

4180

4181

4182

4183

4184

4185

4186

4187

4188

4189

4190

4191

4192void

4194{

4195 sigjmp_buf local_sigjmp_buf;

4196

4197

4198 volatile bool send_ready_for_query = true;

4199 volatile bool idle_in_transaction_timeout_enabled = false;

4200 volatile bool idle_session_timeout_enabled = false;

4201

4204

4206

4207

4208

4209

4210

4211

4212

4213

4214

4215

4216

4217

4218

4219

4220

4221

4224 else

4225 {

4228 pqsignal(SIGTERM, die);

4229

4230

4231

4232

4233

4234

4235

4236

4237

4240 else

4243

4244

4245

4246

4247

4248

4249

4254

4255

4256

4257

4258

4259 pqsignal(SIGCHLD, SIG_DFL);

4260

4261 }

4262

4263

4265

4266

4267 sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);

4268

4269

4270

4271

4272

4275 {

4276 int len;

4277

4281 {

4283 (errcode(ERRCODE_INTERNAL_ERROR),

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

4285 }

4287 }

4288

4289

4290

4291

4292

4293

4294

4295

4296

4297

4301 NULL);

4302

4303

4304

4305

4306

4308 {

4311 }

4312

4314

4315

4316

4317

4318

4320

4321

4322

4323

4324

4327

4329

4330

4333

4334

4335

4336

4338 {

4340

4344

4347

4348 }

4349

4350

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

4353

4354

4355

4356

4357

4358

4359

4361 "MessageContext",

4363

4364

4365

4366

4367

4368

4369

4371 "RowDescriptionContext",

4376

4377

4379

4380

4381

4382

4383

4384

4385

4386

4387

4388

4389

4390

4391

4392

4393

4394

4395

4396

4397

4398

4399

4400

4401

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

4403 {

4404

4405

4406

4407

4408

4409

4410

4411

4412

4414

4415

4417

4418

4419

4420

4421

4422

4423

4424

4425

4426

4427

4428

4431 idle_in_transaction_timeout_enabled = false;

4432 idle_session_timeout_enabled = false;

4433

4434

4436

4437

4439

4440

4442

4443

4444

4445

4446

4448

4449

4450

4451

4452

4454

4455

4456

4457

4459

4462

4464

4465

4466

4467

4468

4469

4470

4471

4474

4475

4477

4479

4480

4481

4482

4483

4486

4487

4488

4489

4490

4491

4494

4495

4497

4498

4499

4500

4501

4502

4503

4504

4505

4508 (errcode(ERRCODE_PROTOCOL_VIOLATION),

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

4510

4511

4513 }

4514

4515

4517

4519 send_ready_for_query = true;

4520

4521

4522

4523

4524

4525 for (;;)

4526 {

4527 int firstchar;

4529

4530

4531

4532

4533

4535

4536

4537

4538

4539#ifdef USE_VALGRIND

4540 old_valgrind_error_count = VALGRIND_COUNT_ERRORS;

4541#endif

4542

4543

4544

4545

4546

4549

4551

4552

4553

4554

4555

4557

4558

4559

4560

4561

4562

4563

4564

4565

4566

4567

4568

4569

4570

4571

4572

4573

4574 if (send_ready_for_query)

4575 {

4577 {

4580

4581

4584 {

4585 idle_in_transaction_timeout_enabled = true;

4588 }

4589 }

4591 {

4594

4595

4598 {

4599 idle_in_transaction_timeout_enabled = true;

4602 }

4603 }

4604 else

4605 {

4606 long stats_timeout;

4607

4608

4609

4610

4611

4612

4613

4614

4617

4618

4619

4620

4621

4622

4623

4624

4625

4626

4627

4628

4629

4630

4632 if (stats_timeout > 0)

4633 {

4636 stats_timeout);

4637 }

4638 else

4639 {

4640

4643 }

4644

4647

4648

4650 {

4651 idle_session_timeout_enabled = true;

4654 }

4655 }

4656

4657

4659

4660

4661

4662

4663

4664

4668 {

4669 uint64 total_duration,

4670 fork_duration,

4671 auth_duration;

4672

4674

4675 total_duration =

4678 fork_duration =

4681 auth_duration =

4684

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

4687 (double) total_duration / NS_PER_US,

4688 (double) fork_duration / NS_PER_US,

4689 (double) auth_duration / NS_PER_US));

4690 }

4691

4693 send_ready_for_query = false;

4694 }

4695

4696

4697

4698

4699

4700

4701

4703

4704

4705

4706

4707 firstchar = ReadCommand(&input_message);

4708

4709

4710

4711

4712

4713

4714

4715

4716

4717 if (idle_in_transaction_timeout_enabled)

4718 {

4720 idle_in_transaction_timeout_enabled = false;

4721 }

4722 if (idle_session_timeout_enabled)

4723 {

4725 idle_session_timeout_enabled = false;

4726 }

4727

4728

4729

4730

4731

4732

4733

4734

4735

4736

4739

4740

4741

4742

4743

4745 {

4748 }

4749

4750

4751

4752

4753

4755 continue;

4756

4757 switch (firstchar)

4758 {

4760 {

4761 const char *query_string;

4762

4763

4765

4768

4770 {

4773 }

4774 else

4776

4778

4779 send_ready_for_query = true;

4780 }

4781 break;

4782

4784 {

4785 const char *stmt_name;

4786 const char *query_string;

4787 int numParams;

4788 Oid *paramTypes = NULL;

4789

4791

4792

4794

4797 numParams = pq_getmsgint(&input_message, 2);

4798 if (numParams > 0)

4799 {

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

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

4803 }

4805

4807 paramTypes, numParams);

4808

4810 }

4811 break;

4812

4815

4816

4818

4819

4820

4821

4822

4824

4825

4826 break;

4827

4829 {

4830 const char *portal_name;

4831 int max_rows;

4832

4834

4835

4837

4841

4843

4844

4845 }

4846 break;

4847

4850

4851

4853

4854

4857

4858

4860

4861

4862

4863

4864

4865

4866

4867

4868

4869

4870

4872

4874

4875

4877

4879

4880 send_ready_for_query = true;

4881 break;

4882

4884 {

4885 int close_type;

4886 const char *close_target;

4887

4889

4893

4894 switch (close_type)

4895 {

4896 case 'S':

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

4899 else

4900 {

4901

4903 }

4904 break;

4905 case 'P':

4906 {

4908

4912 }

4913 break;

4914 default:

4916 (errcode(ERRCODE_PROTOCOL_VIOLATION),

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

4918 close_type)));

4919 break;

4920 }

4921

4924

4926 }

4927 break;

4928

4930 {

4931 int describe_type;

4932 const char *describe_target;

4933

4935

4936

4938

4942

4943 switch (describe_type)

4944 {

4945 case 'S':

4947 break;

4948 case 'P':

4950 break;

4951 default:

4953 (errcode(ERRCODE_PROTOCOL_VIOLATION),

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

4955 describe_type)));

4956 break;

4957 }

4958

4960 }

4961 break;

4962

4967 break;

4968

4971

4972

4973

4974

4975

4976

4980 send_ready_for_query = true;

4981 break;

4982

4983

4984

4985

4986

4987

4988 case EOF:

4989

4990

4992

4993

4994

4996

4997

4998

4999

5000

5003

5004

5005

5006

5007

5008

5009

5010

5012

5016

5017

5018

5019

5020

5021

5022 break;

5023

5024 default:

5026 (errcode(ERRCODE_PROTOCOL_VIOLATION),

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

5028 firstchar)));

5029 }

5030 }

5031}

5032

5033

5034

5035

5036

5037

5038

5039

5040static void

5042{

5044 {

5047 (errcode(ERRCODE_PROTOCOL_VIOLATION),

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

5049 else

5051 (errcode(ERRCODE_PROTOCOL_VIOLATION),

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

5053 }

5054}

5055

5056

5059

5060void

5062{

5065}

5066

5067void

5069{

5071 struct timeval user,

5072 sys;

5073 struct timeval elapse_t;

5075

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

5080 if (elapse_t.tv_usec < Save_t.tv_usec)

5081 {

5082 elapse_t.tv_sec--;

5083 elapse_t.tv_usec += 1000000;

5084 }

5086 {

5088 r.ru_utime.tv_usec += 1000000;

5089 }

5091 {

5093 r.ru_stime.tv_usec += 1000000;

5094 }

5095

5096

5097

5098

5099

5101

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

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

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

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

5113 (long) user.tv_sec,

5114 (long) user.tv_usec,

5115 (long) sys.tv_sec,

5116 (long) sys.tv_usec);

5117#ifndef WIN32

5118

5119

5120

5121

5122

5123

5124

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

5128

5129 r.ru_maxrss / 1024

5130#else

5131

5132 r.ru_maxrss

5133#endif

5134 );

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

5137 r.ru_inblock - Save_r.ru_inblock,

5138

5139 r.ru_oublock - Save_r.ru_oublock,

5140 r.ru_inblock, r.ru_oublock);

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

5143 r.ru_majflt - Save_r.ru_majflt,

5144 r.ru_minflt - Save_r.ru_minflt,

5145 r.ru_majflt, r.ru_minflt,

5146 r.ru_nswap - Save_r.ru_nswap,

5147 r.ru_nswap);

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

5150 r.ru_nsignals - Save_r.ru_nsignals,

5151 r.ru_nsignals,

5152 r.ru_msgrcv - Save_r.ru_msgrcv,

5153 r.ru_msgsnd - Save_r.ru_msgsnd,

5154 r.ru_msgrcv, r.ru_msgsnd);

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

5157 r.ru_nvcsw - Save_r.ru_nvcsw,

5158 r.ru_nivcsw - Save_r.ru_nivcsw,

5159 r.ru_nvcsw, r.ru_nivcsw);

5160#endif

5161

5162

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

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

5165

5169

5171}

5172

5173

5174

5175

5176static void

5178{

5180 long secs;

5181 int usecs;

5182 int msecs;

5183 int hours,

5184 minutes,

5185 seconds;

5186

5189 &secs, &usecs);

5190 msecs = usecs / 1000;

5191

5196

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

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

5200 hours, minutes, seconds, msecs,

5201 port->user_name, port->database_name, port->remote_host,

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

5203}

5204

5205

5206

5207

5208

5209

5210

5211

5212static void

5214{

5215

5217

5220 {

5223 }

5224 else

5225 {

5228 }

5229}

5230

5231

5232

5233

5234static void

5236{

5239}

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_query_id(int64 query_id, bool force)

void pgstat_report_activity(BackendState state, const char *cmd_str)

void pgstat_report_plan_id(int64 plan_id, bool force)

@ 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

bool Debug_print_raw_parse

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)(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

static char buf[DEFAULT_XLOG_SEG_SIZE]

#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, ExplainState *es)

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)

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)

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

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

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)