PostgreSQL Source Code: contrib/postgres_fdw/deparse.c Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

35

63

64

65

66

68{

71 Relids relids;

72

74

75

76

77

78

79typedef enum

80{

82

83

86

88

90{

94

95

96

97

99{

103

104

108

109#define REL_ALIAS_PREFIX "r"

110

111#define ADD_REL_QUALIFIER(buf, varno) \

112 appendStringInfo((buf), "%s%d.", REL_ALIAS_PREFIX, (varno))

113#define SUBQUERY_REL_ALIAS_PREFIX "s"

114#define SUBQUERY_COL_ALIAS_PREFIX "c"

115

116

117

118

119

125

126

127

128

133 bool is_returning,

135 bool qualify_col,

136 List **retrieved_attrs);

138 bool is_returning,

139 List **retrieved_attrs,

144 bool trig_after_row,

145 List *withCheckOptionList,

146 List *returningList,

147 List **retrieved_attrs);

181 RelOptInfo *foreignrel, bool use_alias,

182 Index ignore_rel, List **ignore_conds,

183 List **additional_conds,

184 List **params_list);

189 RelOptInfo *foreignrel, bool make_subquery,

190 Index ignore_rel, List **ignore_conds,

191 List **additional_conds, List **params_list);

201

202

203

204

206 int *relno, int *colno);

208 int *relno, int *colno);

209

210

211

212

213

214

215

216

217void

220 List *input_conds,

221 List **remote_conds,

222 List **local_conds)

223{

225

226 *remote_conds = NIL;

227 *local_conds = NIL;

228

229 foreach(lc, input_conds)

230 {

232

234 *remote_conds = lappend(*remote_conds, ri);

235 else

236 *local_conds = lappend(*local_conds, ri);

237 }

238}

239

240

241

242

243bool

247{

251

252

253

254

255

258

259

260

261

262

263

266 else

271 return false;

272

273

274

275

276

278 return false;

279

280

281

282

283

284

285

286

288 return false;

289

290

291 return true;

292}

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311static bool

316{

317 bool check_type = true;

320 Oid collation;

322

323

324 if (node == NULL)

325 return true;

326

327

329

330

333

335 {

336 case T_Var:

337 {

338 Var *var = (Var *) node;

339

340

341

342

343

344

345

346

349 {

350

351

352

353

354

355

356

357

360 return false;

361

362

363 collation = var->varcollid;

365 }

366 else

367 {

368

369 collation = var->varcollid;

371 collation == DEFAULT_COLLATION_OID)

372 {

373

374

375

376

378 }

379 else

380 {

381

382

383

384

386 }

387 }

388 }

389 break;

390 case T_Const:

391 {

393

394

395

396

397

398

399 if (c->constisnull)

400 {

401 switch (c->consttype)

402 {

403 case REGPROCOID:

404 case REGPROCEDUREOID:

406 ProcedureRelationId, fpinfo))

407 return false;

408 break;

409 case REGOPEROID:

410 case REGOPERATOROID:

412 OperatorRelationId, fpinfo))

413 return false;

414 break;

415 case REGCLASSOID:

417 RelationRelationId, fpinfo))

418 return false;

419 break;

420 case REGTYPEOID:

422 TypeRelationId, fpinfo))

423 return false;

424 break;

425 case REGCOLLATIONOID:

427 CollationRelationId, fpinfo))

428 return false;

429 break;

430 case REGCONFIGOID:

431

432

433

434

435

436

437

438

441 TSConfigRelationId, fpinfo))

442 return false;

443 break;

444 case REGDICTIONARYOID:

447 TSDictionaryRelationId, fpinfo))

448 return false;

449 break;

450 case REGNAMESPACEOID:

452 NamespaceRelationId, fpinfo))

453 return false;

454 break;

455 case REGROLEOID:

457 AuthIdRelationId, fpinfo))

458 return false;

459 break;

460 case REGDATABASEOID:

462 DatabaseRelationId, fpinfo))

463 return false;

464 break;

465 }

466 }

467

468

469

470

471

472

473

474 collation = c->constcollid;

476 collation == DEFAULT_COLLATION_OID)

478 else

480 }

481 break;

482 case T_Param:

483 {

485

486

487

488

489

490

491

492

493

494

495

496

497

498

500 return false;

501

502

503

504

507 collation == DEFAULT_COLLATION_OID)

509 else

511 }

512 break;

513 case T_SubscriptingRef:

514 {

516

517

519 return false;

520

521

522

523

524

525

527 glob_cxt, &inner_cxt, case_arg_cxt))

528 return false;

532 glob_cxt, &inner_cxt, case_arg_cxt))

533 return false;

537 glob_cxt, &inner_cxt, case_arg_cxt))

538 return false;

539

540

541

542

543

544

545 collation = sr->refcollid;

549 collation == inner_cxt.collation)

551 else if (collation == DEFAULT_COLLATION_OID)

553 else

555 }

556 break;

557 case T_FuncExpr:

558 {

560

561

562

563

564

565

566 if (is\_shippable(fe->funcid, ProcedureRelationId, fpinfo))

567 return false;

568

569

570

571

573 glob_cxt, &inner_cxt, case_arg_cxt))

574 return false;

575

576

577

578

579

581 ;

583 fe->inputcollid != inner_cxt.collation)

584 return false;

585

586

587

588

589

590

591

592 collation = fe->funccollid;

596 collation == inner_cxt.collation)

598 else if (collation == DEFAULT_COLLATION_OID)

600 else

602 }

603 break;

604 case T_OpExpr:

605 case T_DistinctExpr:

606 {

608

609

610

611

612

613

615 return false;

616

617

618

619

621 glob_cxt, &inner_cxt, case_arg_cxt))

622 return false;

623

624

625

626

627

629 ;

631 oe->inputcollid != inner_cxt.collation)

632 return false;

633

634

635 collation = oe->opcollid;

639 collation == inner_cxt.collation)

641 else if (collation == DEFAULT_COLLATION_OID)

643 else

645 }

646 break;

647 case T_ScalarArrayOpExpr:

648 {

650

651

652

653

655 return false;

656

657

658

659

661 glob_cxt, &inner_cxt, case_arg_cxt))

662 return false;

663

664

665

666

667

669 ;

671 oe->inputcollid != inner_cxt.collation)

672 return false;

673

674

677 }

678 break;

679 case T_RelabelType:

680 {

682

683

684

685

687 glob_cxt, &inner_cxt, case_arg_cxt))

688 return false;

689

690

691

692

693

694 collation = r->resultcollid;

698 collation == inner_cxt.collation)

700 else if (collation == DEFAULT_COLLATION_OID)

702 else

704 }

705 break;

706 case T_ArrayCoerceExpr:

707 {

709

710

711

712

714 glob_cxt, &inner_cxt, case_arg_cxt))

715 return false;

716

717

718

719

720

721

722 collation = e->resultcollid;

726 collation == inner_cxt.collation)

728 else if (collation == DEFAULT_COLLATION_OID)

730 else

732 }

733 break;

734 case T_BoolExpr:

735 {

737

738

739

740

742 glob_cxt, &inner_cxt, case_arg_cxt))

743 return false;

744

745

748 }

749 break;

750 case T_NullTest:

751 {

753

754

755

756

758 glob_cxt, &inner_cxt, case_arg_cxt))

759 return false;

760

761

764 }

765 break;

766 case T_CaseExpr:

767 {

772

773

774

775

776

777

780 if (ce->arg)

781 {

783 glob_cxt, &arg_cxt, case_arg_cxt))

784 return false;

785 }

786

787

788 foreach(lc, ce->args)

789 {

791

792 if (ce->arg)

793 {

794

795

796

797

798

799

800

801

802

803

804

806 List *opArgs;

807

809 return false;

810

811 opArgs = ((OpExpr *) whenExpr)->args;

815 return false;

816 }

817

818

819

820

821

822

826 glob_cxt, &tmp_cxt, &arg_cxt))

827 return false;

828

829

831 glob_cxt, &inner_cxt, case_arg_cxt))

832 return false;

833 }

834

835

837 glob_cxt, &inner_cxt, case_arg_cxt))

838 return false;

839

840

841

842

843

844

845

846

847

848 collation = ce->casecollid;

852 collation == inner_cxt.collation)

854 else if (collation == DEFAULT_COLLATION_OID)

856 else

858 }

859 break;

860 case T_CaseTestExpr:

861 {

863

864

865 if (!case_arg_cxt)

866 return false;

867

868

869

870

871

872

873 collation = c->collation;

877 collation == case_arg_cxt->collation)

879 else if (collation == DEFAULT_COLLATION_OID)

881 else

883 }

884 break;

885 case T_ArrayExpr:

886 {

888

889

890

891

893 glob_cxt, &inner_cxt, case_arg_cxt))

894 return false;

895

896

897

898

899

900 collation = a->array_collid;

904 collation == inner_cxt.collation)

906 else if (collation == DEFAULT_COLLATION_OID)

908 else

910 }

911 break;

912 case T_List:

913 {

916

917

918

919

920 foreach(lc, l)

921 {

923 glob_cxt, &inner_cxt, case_arg_cxt))

924 return false;

925 }

926

927

928

929

930

933

934

935 check_type = false;

936 }

937 break;

938 case T_Aggref:

939 {

942

943

945 return false;

946

947

949 return false;

950

951

953 return false;

954

955

956

957

958

959

960 foreach(lc, agg->args)

961 {

963

964

966 {

968

970 }

971

973 glob_cxt, &inner_cxt, case_arg_cxt))

974 return false;

975 }

976

977

978

979

980

982 {

984 {

986 Oid sortcoltype;

989

995

999 fpinfo))

1000 return false;

1001 }

1002 }

1003

1004

1006 glob_cxt, &inner_cxt, case_arg_cxt))

1007 return false;

1008

1009

1010

1011

1012

1014 ;

1016 agg->inputcollid != inner_cxt.collation)

1017 return false;

1018

1019

1020

1021

1022

1023

1024

1025 collation = agg->aggcollid;

1029 collation == inner_cxt.collation)

1031 else if (collation == DEFAULT_COLLATION_OID)

1033 else

1035 }

1036 break;

1037 default:

1038

1039

1040

1041

1042

1043 return false;

1044 }

1045

1046

1047

1048

1049

1051 return false;

1052

1053

1054

1055

1057 {

1058

1059 outer_cxt->collation = collation;

1061 }

1063 {

1064

1066 {

1068

1069 break;

1071 if (collation != outer_cxt->collation)

1072 {

1073

1074

1075

1076 if (outer_cxt->collation == DEFAULT_COLLATION_OID)

1077 {

1078

1079 outer_cxt->collation = collation;

1080 }

1081 else if (collation != DEFAULT_COLLATION_OID)

1082 {

1083

1084

1085

1086

1087

1089 }

1090 }

1091 break;

1093

1094 break;

1095 }

1096 }

1097

1098

1099 return true;

1100}

1101

1102

1103

1104

1105

1106

1107

1108

1109

1110

1111

1112

1113

1114bool

1118{

1119 if (expr == NULL)

1120 return false;

1121

1123 {

1124 case T_Var:

1125 {

1126

1127 Var *var = (Var *) expr;

1130

1133 else

1134 relids = baserel->relids;

1135

1137 return false;

1138 else

1139 return true;

1140 break;

1141 }

1142 case T_Param:

1143

1144 return true;

1145 default:

1146 break;

1147 }

1148 return false;

1149}

1150

1151

1152

1153

1154

1155bool

1159{

1162

1163

1164

1165

1166

1168 return false;

1169

1170

1172 return false;

1173

1174

1176}

1177

1178

1179

1180

1181

1182

1183

1184

1185

1186

1187

1188

1189static char *

1191{

1193

1196

1198}

1199

1200

1201

1202

1203

1204

1205

1206

1207

1210{

1214

1215

1216

1217

1218

1221

1222

1223

1224

1225

1230 {

1232

1236 }

1237

1238 return tlist;

1239}

1240

1241

1242

1243

1244

1245

1246

1247

1248

1249

1250

1251

1252

1253

1254

1255

1256

1257

1258

1259

1260

1261

1262

1263

1264

1265void

1267 List *tlist, List *remote_conds, List *pathkeys,

1268 bool has_final_sort, bool has_limit, bool is_subquery,

1269 List **retrieved_attrs, List **params_list)

1270{

1273 List *quals;

1274

1275

1276

1277

1278

1280

1281

1287

1288

1289 deparseSelectSql(tlist, is_subquery, retrieved_attrs, &context);

1290

1291

1292

1293

1294

1295

1297 {

1299

1302 }

1303 else

1304 quals = remote_conds;

1305

1306

1308

1310 {

1311

1313

1314

1315 if (remote_conds)

1316 {

1319 }

1320 }

1321

1322

1323 if (pathkeys)

1325

1326

1327 if (has_limit)

1329

1330

1332}

1333

1334

1335

1336

1337

1338

1339

1340

1341

1342

1343

1344

1345

1346

1347static void

1350{

1355

1356

1357

1358

1360

1361 if (is_subquery)

1362 {

1363

1364

1365

1366

1367

1369 }

1371 {

1372

1373

1374

1375

1377 }

1378 else

1379 {

1380

1381

1382

1383

1385

1386

1387

1388

1389

1391

1393 fpinfo->attrs_used, false, retrieved_attrs);

1395 }

1396}

1397

1398

1399

1400

1401

1402

1403

1404

1405static void

1407{

1410 List *additional_conds = NIL;

1411

1412

1415

1416

1420 (Index) 0, NULL, &additional_conds,

1423 if (additional_conds != NIL)

1425}

1426

1427

1428

1429

1430

1431

1432

1433

1434

1435

1436

1437static void

1442 bool is_returning,

1444 bool qualify_col,

1445 List **retrieved_attrs)

1446{

1448 bool have_wholerow;

1449 bool first;

1450 int i;

1451

1452 *retrieved_attrs = NIL;

1453

1454

1456 attrs_used);

1457

1458 first = true;

1459 for (i = 1; i <= tupdesc->natts; i++)

1460 {

1461

1463 continue;

1464

1465 if (have_wholerow ||

1467 attrs_used))

1468 {

1469 if (!first)

1471 else if (is_returning)

1473 first = false;

1474

1476

1477 *retrieved_attrs = lappend_int(*retrieved_attrs, i);

1478 }

1479 }

1480

1481

1482

1483

1484

1486 attrs_used))

1487 {

1488 if (!first)

1490 else if (is_returning)

1492 first = false;

1493

1494 if (qualify_col)

1497

1498 *retrieved_attrs = lappend_int(*retrieved_attrs,

1500 }

1501

1502

1503 if (first && !is_returning)

1505}

1506

1507

1508

1509

1510

1511static void

1513{

1518 int relid = -1;

1519

1521 {

1522

1523

1524

1525

1527 continue;

1528

1529

1530

1531

1532

1533

1534

1535

1536

1537

1538

1539

1543 {

1544

1546

1547

1550 }

1551 else

1552 {

1554

1555 if (rc)

1556 {

1557

1558

1559

1560

1561

1562

1563

1564

1565

1566

1567

1569 {

1571

1572 break;

1576 break;

1580 break;

1581 }

1582

1583

1587 }

1588 }

1589 }

1590}

1591

1592

1593

1594

1595

1596

1597

1598

1599

1600

1601static void

1603{

1604 int nestlevel;

1606 bool is_first = true;

1608

1609

1611

1612 foreach(lc, exprs)

1613 {

1615

1616

1619

1620

1621 if (!is_first)

1623

1627

1628 is_first = false;

1629 }

1630

1632}

1633

1634

1635

1636

1637

1638static void

1640{

1642 bool need_and = false;

1644

1645 if (exprs != NIL || additional_conds != NIL)

1647

1648

1649

1650

1651 if (exprs != NIL)

1652 {

1654 need_and = true;

1655 }

1656

1657

1658

1659

1660

1661 foreach(lc, additional_conds)

1662 {

1663 if (need_and)

1666 need_and = true;

1667 }

1668}

1669

1670

1671const char *

1673{

1674 switch (jointype)

1675 {

1677 return "INNER";

1678

1680 return "LEFT";

1681

1683 return "RIGHT";

1684

1686 return "FULL";

1687

1689 return "SEMI";

1690

1691 default:

1692

1693 elog(ERROR, "unsupported join type %d", jointype);

1694 }

1695

1696

1697 return NULL;

1698}

1699

1700

1701

1702

1703

1704

1705

1706

1707

1708

1709

1710

1711static void

1713 bool is_returning,

1714 List **retrieved_attrs,

1716{

1719 int i = 0;

1720

1721 *retrieved_attrs = NIL;

1722

1723 foreach(lc, tlist)

1724 {

1726

1727 if (i > 0)

1729 else if (is_returning)

1731

1733

1734 *retrieved_attrs = lappend_int(*retrieved_attrs, i + 1);

1735 i++;

1736 }

1737

1738 if (i == 0 && !is_returning)

1740}

1741

1742

1743

1744

1745

1746

1747static void

1749{

1752 bool first;

1754

1755

1757

1758 first = true;

1760 {

1762

1763 if (!first)

1765 first = false;

1766

1768 }

1769

1770

1771 if (first)

1773}

1774

1775

1776

1777

1778

1779

1780

1781

1782

1783

1784

1785

1786

1787

1788

1789

1790

1791static void

1793 bool use_alias, Index ignore_rel, List **ignore_conds,

1794 List **additional_conds, List **params_list)

1795{

1797

1799 {

1804 bool outerrel_is_target = false;

1805 bool innerrel_is_target = false;

1806 List *additional_conds_i = NIL;

1807 List *additional_conds_o = NIL;

1808

1810 {

1811

1812

1813

1814

1815

1816

1817

1818

1819

1820

1821

1823 {

1824 *ignore_conds = list_concat(*ignore_conds,

1827 }

1828

1829

1830

1831

1832 if (outerrel->relid == ignore_rel)

1833 outerrel_is_target = true;

1834 else if (innerrel->relid == ignore_rel)

1835 innerrel_is_target = true;

1836 }

1837

1838

1839 if (!outerrel_is_target)

1840 {

1844 ignore_rel, ignore_conds, &additional_conds_o,

1845 params_list);

1846

1847

1848

1849

1850

1851

1852

1853

1854

1855

1856 if (innerrel_is_target)

1857 {

1861

1862 if (additional_conds_o != NIL)

1863 {

1864 Assert(*additional_conds == NIL);

1865 *additional_conds = additional_conds_o;

1866 }

1867 return;

1868 }

1869 }

1870

1871

1872 if (!innerrel_is_target)

1873 {

1877 ignore_rel, ignore_conds, &additional_conds_i,

1878 params_list);

1879

1880

1881

1882

1883

1884

1885

1886

1887

1889 {

1892

1893

1896 join_sql_i.data);

1897

1900 context.scanrel = foreignrel;

1903

1904

1905

1906

1907

1909

1910

1911

1912

1913

1914 if (additional_conds_i != NIL)

1915 {

1917 additional_conds_i = NIL;

1918 }

1919

1920

1922

1923 *additional_conds = lappend(*additional_conds, str.data);

1924 }

1925

1926

1927

1928

1929

1930 if (outerrel_is_target)

1931 {

1935

1936 if (additional_conds_i != NIL)

1937 {

1938 Assert(*additional_conds == NIL);

1939 *additional_conds = additional_conds_i;

1940 }

1941 return;

1942 }

1943 }

1944

1945

1946 Assert(!outerrel_is_target && !innerrel_is_target);

1947

1948

1949

1950

1951

1952

1954 {

1956 }

1957 else

1958 {

1959

1960

1961

1962

1963

1964

1967

1968

1970 {

1972

1975 context.scanrel = foreignrel;

1978

1982 }

1983 else

1985

1986

1988 }

1989

1990

1991

1992

1993

1994

1995 if (additional_conds_o != NIL)

1996 {

1997 *additional_conds = list_concat(*additional_conds,

1998 additional_conds_o);

2000 }

2001

2002 if (additional_conds_i != NIL)

2003 {

2004 *additional_conds = list_concat(*additional_conds,

2005 additional_conds_i);

2007 }

2008 }

2009 else

2010 {

2012

2013

2014

2015

2016

2018

2020

2021

2022

2023

2024

2025

2026 if (use_alias)

2028

2030 }

2031}

2032

2033

2034

2035

2036

2037

2038static void

2040 bool make_subquery, Index ignore_rel, List **ignore_conds,

2041 List **additional_conds, List **params_list)

2042{

2044

2045

2047

2049

2050

2051 if (make_subquery)

2052 {

2053 List *retrieved_attrs;

2054 int ncols;

2055

2056

2057

2058

2059

2060

2061 Assert(ignore_rel == 0 ||

2063

2064

2068 false, false, true,

2069 &retrieved_attrs, params_list);

2071

2072

2075

2076

2077

2078

2079

2080

2082 if (ncols > 0)

2083 {

2084 int i;

2085

2087 for (i = 1; i <= ncols; i++)

2088 {

2089 if (i > 1)

2091

2093 }

2095 }

2096 }

2097 else

2099 ignore_conds, additional_conds,

2100 params_list);

2101}

2102

2103

2104

2105

2106

2107

2108

2109

2110

2111

2112

2113void

2116 List *targetAttrs, bool doNothing,

2117 List *withCheckOptionList, List *returningList,

2118 List **retrieved_attrs, int *values_end_len)

2119{

2122 bool first;

2124

2127

2128 if (targetAttrs)

2129 {

2131

2132 first = true;

2133 foreach(lc, targetAttrs)

2134 {

2136

2137 if (!first)

2139 first = false;

2140

2142 }

2143

2145

2146 pindex = 1;

2147 first = true;

2148 foreach(lc, targetAttrs)

2149 {

2152

2153 if (!first)

2155 first = false;

2156

2159 else

2160 {

2162 pindex++;

2163 }

2164 }

2165

2167 }

2168 else

2170 *values_end_len = buf->len;

2171

2172 if (doNothing)

2174

2177 withCheckOptionList, returningList, retrieved_attrs);

2178}

2179

2180

2181

2182

2183

2184

2185

2186void

2188 char *orig_query, List *target_attrs,

2189 int values_end_len, int num_params,

2190 int num_rows)

2191{

2193 int i;

2194 int pindex;

2195 bool first;

2197

2198

2199 Assert((values_end_len > 0) && (values_end_len <= strlen(orig_query)));

2200

2201

2203

2204

2205

2206

2207

2208 pindex = num_params + 1;

2209 for (i = 0; i < num_rows; i++)

2210 {

2212

2213 first = true;

2214 foreach(lc, target_attrs)

2215 {

2218

2219 if (!first)

2221 first = false;

2222

2225 else

2226 {

2228 pindex++;

2229 }

2230 }

2231

2233 }

2234

2235

2237}

2238

2239

2240

2241

2242

2243

2244

2245

2246void

2249 List *targetAttrs,

2250 List *withCheckOptionList, List *returningList,

2251 List **retrieved_attrs)

2252{

2255 bool first;

2257

2261

2262 pindex = 2;

2263 first = true;

2264 foreach(lc, targetAttrs)

2265 {

2268

2269 if (!first)

2271 first = false;

2272

2276 else

2277 {

2279 pindex++;

2280 }

2281 }

2283

2286 withCheckOptionList, returningList, retrieved_attrs);

2287}

2288

2289

2290

2291

2292

2293

2294

2295

2296

2297

2298

2299

2300

2301

2302

2303

2304

2305

2306void

2310 List *targetlist,

2311 List *targetAttrs,

2312 List *remote_conds,

2313 List **params_list,

2314 List *returningList,

2315 List **retrieved_attrs)

2316{

2318 int nestlevel;

2319 bool first;

2322 *lc2;

2323 List *additional_conds = NIL;

2324

2325

2328 context.scanrel = foreignrel;

2331

2337

2338

2340

2341 first = true;

2342 forboth(lc, targetlist, lc2, targetAttrs)

2343 {

2346

2347

2348 Assert(!tle->resjunk);

2349

2350 if (!first)

2352 first = false;

2353

2357 }

2358

2360

2362 {

2363 List *ignore_conds = NIL;

2364

2365

2368 &ignore_conds, &additional_conds, params_list);

2369 remote_conds = list_concat(remote_conds, ignore_conds);

2370 }

2371

2373

2374 if (additional_conds != NIL)

2376

2379 &context);

2380 else

2382 NIL, returningList, retrieved_attrs);

2383}

2384

2385

2386

2387

2388

2389

2390

2391

2392void

2395 List *returningList,

2396 List **retrieved_attrs)

2397{

2401

2404 NIL, returningList, retrieved_attrs);

2405}

2406

2407

2408

2409

2410

2411

2412

2413

2414

2415

2416

2417

2418

2419

2420

2421void

2425 List *remote_conds,

2426 List **params_list,

2427 List *returningList,

2428 List **retrieved_attrs)

2429{

2431 List *additional_conds = NIL;

2432

2433

2436 context.scanrel = foreignrel;

2439

2444

2446 {

2447 List *ignore_conds = NIL;

2448

2451 &ignore_conds, &additional_conds, params_list);

2452 remote_conds = list_concat(remote_conds, ignore_conds);

2453 }

2454

2456

2457 if (additional_conds != NIL)

2459

2462 &context);

2463 else

2465 rtindex, rel, false,

2466 NIL, returningList, retrieved_attrs);

2467}

2468

2469

2470

2471

2472static void

2475 bool trig_after_row,

2476 List *withCheckOptionList,

2477 List *returningList,

2478 List **retrieved_attrs)

2479{

2481

2482 if (trig_after_row)

2483 {

2484

2485 attrs_used =

2487 }

2488

2489 if (withCheckOptionList != NIL)

2490 {

2491

2492

2493

2494

2495

2496

2497

2498

2499

2501 &attrs_used);

2502 }

2503

2504 if (returningList != NIL)

2505 {

2506

2507

2508

2509

2511 &attrs_used);

2512 }

2513

2514 if (attrs_used != NULL)

2516 retrieved_attrs);

2517 else

2518 *retrieved_attrs = NIL;

2519}

2520

2521

2522

2523

2524

2525

2526

2527

2528

2529void

2531{

2533

2534

2537

2541}

2542

2543

2544

2545

2546

2547

2548

2549

2550

2551void

2553{

2555

2556

2559

2563}

2564

2565

2566

2567

2568

2569

2570

2571

2572

2573

2574

2575

2576

2577

2578

2579

2580

2581

2582

2583

2584

2585

2586

2587

2588

2589

2590

2591void

2594 List **retrieved_attrs)

2595{

2598 int i;

2599 char *colname;

2602 bool first = true;

2603

2604 *retrieved_attrs = NIL;

2605

2607 for (i = 0; i < tupdesc->natts; i++)

2608 {

2609

2611 continue;

2612

2613 if (!first)

2615 first = false;

2616

2617

2620

2622 {

2624

2625 if (strcmp(def->defname, "column_name") == 0)

2626 {

2628 break;

2629 }

2630 }

2631

2633

2634 *retrieved_attrs = lappend_int(*retrieved_attrs, i + 1);

2635 }

2636

2637

2638 if (first)

2640

2641

2642

2643

2644

2647

2648 switch (sample_method)

2649 {

2651

2652 break;

2653

2656 break;

2657

2659 appendStringInfo(buf, " TABLESAMPLE SYSTEM(%f)", (100.0 * sample_frac));

2660 break;

2661

2663 appendStringInfo(buf, " TABLESAMPLE BERNOULLI(%f)", (100.0 * sample_frac));

2664 break;

2665

2667

2668 elog(ERROR, "unexpected sampling method");

2669 break;

2670 }

2671}

2672

2673

2674

2675

2676void

2680 bool restart_seqs)

2681{

2683

2685

2686 foreach(cell, rels)

2687 {

2689

2692

2694 }

2695

2697 restart_seqs ? "RESTART" : "CONTINUE");

2698

2703}

2704

2705

2706

2707

2708

2709

2710

2711static void

2713 bool qualify_col)

2714{

2715

2717 {

2718 if (qualify_col)

2721 }

2722 else if (varattno < 0)

2723 {

2724

2725

2726

2727

2728

2729

2730 Oid fetchval = 0;

2731

2733 fetchval = rte->relid;

2734

2735 if (qualify_col)

2736 {

2740 }

2741 else

2743 }

2744 else if (varattno == 0)

2745 {

2746

2749

2750

2751 List *retrieved_attrs;

2752

2753

2754

2755

2756

2758

2759

2760

2761

2762

2763

2764

2765

2766

2769

2770

2771

2772

2773

2774

2775

2776 if (qualify_col)

2777 {

2781 }

2782

2785 &retrieved_attrs);

2787

2788

2789 if (qualify_col)

2791

2794 }

2795 else

2796 {

2797 char *colname = NULL;

2800

2801

2803

2804

2805

2806

2807

2810 {

2812

2813 if (strcmp(def->defname, "column_name") == 0)

2814 {

2816 break;

2817 }

2818 }

2819

2820

2821

2822

2823

2824 if (colname == NULL)

2825 colname = get_attname(rte->relid, varattno, false);

2826

2827 if (qualify_col)

2829

2831 }

2832}

2833

2834

2835

2836

2837

2838

2839static void

2841{

2843 const char *nspname = NULL;

2844 const char *relname = NULL;

2846

2847

2849

2850

2851

2852

2853 foreach(lc, table->options)

2854 {

2856

2857 if (strcmp(def->defname, "schema_name") == 0)

2859 else if (strcmp(def->defname, "table_name") == 0)

2861 }

2862

2863

2864

2865

2866

2867 if (nspname == NULL)

2871

2874}

2875

2876

2877

2878

2879void

2881{

2882 const char *valptr;

2883

2884

2885

2886

2887

2888

2889

2890 if (strchr(val, '\\') != NULL)

2893 for (valptr = val; *valptr; valptr++)

2894 {

2895 char ch = *valptr;

2896

2900 }

2902}

2903

2904

2905

2906

2907

2908

2909

2910

2911

2912

2913

2914static void

2916{

2917 if (node == NULL)

2918 return;

2919

2921 {

2922 case T_Var:

2924 break;

2925 case T_Const:

2927 break;

2928 case T_Param:

2930 break;

2931 case T_SubscriptingRef:

2933 break;

2934 case T_FuncExpr:

2936 break;

2937 case T_OpExpr:

2939 break;

2940 case T_DistinctExpr:

2942 break;

2943 case T_ScalarArrayOpExpr:

2945 break;

2946 case T_RelabelType:

2948 break;

2949 case T_ArrayCoerceExpr:

2951 break;

2952 case T_BoolExpr:

2954 break;

2955 case T_NullTest:

2957 break;

2958 case T_CaseExpr:

2960 break;

2961 case T_ArrayExpr:

2963 break;

2964 case T_Aggref:

2966 break;

2967 default:

2968 elog(ERROR, "unsupported expression type for deparse: %d",

2970 break;

2971 }

2972}

2973

2974

2975

2976

2977

2978

2979

2980

2981

2982static void

2984{

2986 int relno;

2987 int colno;

2988

2989

2991

2992

2993

2994

2995

2996

2998 {

3002 return;

3003 }

3004

3008 qualify_col);

3009 else

3010 {

3011

3013 {

3014 int pindex = 0;

3016

3017

3019 {

3020 pindex++;

3022 break;

3023 }

3024 if (lc == NULL)

3025 {

3026

3027 pindex++;

3029 }

3030

3031 printRemoteParam(pindex, node->vartype, node->vartypmod, context);

3032 }

3033 else

3034 {

3036 }

3037 }

3038}

3039

3040

3041

3042

3043

3044

3045

3046

3047

3048

3049

3050

3051

3052

3053static void

3055{

3057 Oid typoutput;

3058 bool typIsVarlena;

3059 char *extval;

3060 bool isfloat = false;

3061 bool isstring = false;

3062 bool needlabel;

3063

3064 if (node->constisnull)

3065 {

3067 if (showtype >= 0)

3070 node->consttypmod));

3071 return;

3072 }

3073

3075 &typoutput, &typIsVarlena);

3077

3079 {

3080 case INT2OID:

3081 case INT4OID:

3082 case INT8OID:

3083 case OIDOID:

3084 case FLOAT4OID:

3085 case FLOAT8OID:

3086 case NUMERICOID:

3087 {

3088

3089

3090

3091

3092 if (strspn(extval, "0123456789+-eE.") == strlen(extval))

3093 {

3094 if (extval[0] == '+' || extval[0] == '-')

3096 else

3098 if (strcspn(extval, "eE.") != strlen(extval))

3099 isfloat = true;

3100 }

3101 else

3103 }

3104 break;

3105 case BITOID:

3106 case VARBITOID:

3108 break;

3109 case BOOLOID:

3110 if (strcmp(extval, "t") == 0)

3112 else

3114 break;

3115 default:

3117 isstring = true;

3118 break;

3119 }

3120

3122

3123 if (showtype == -1)

3124 return;

3125

3126

3127

3128

3129

3130

3131

3132

3134 {

3135 case BOOLOID:

3136 case INT4OID:

3137 case UNKNOWNOID:

3138 needlabel = false;

3139 break;

3140 case NUMERICOID:

3141 needlabel = !isfloat || (node->consttypmod >= 0);

3142 break;

3143 default:

3144 if (showtype == -2)

3145 {

3146

3147 needlabel = !isstring;

3148 }

3149 else

3150 needlabel = true;

3151 break;

3152 }

3153 if (needlabel || showtype > 0)

3156 node->consttypmod));

3157}

3158

3159

3160

3161

3162

3163

3164

3165

3166

3167static void

3169{

3171 {

3172 int pindex = 0;

3174

3175

3177 {

3178 pindex++;

3180 break;

3181 }

3182 if (lc == NULL)

3183 {

3184

3185 pindex++;

3187 }

3188

3190 }

3191 else

3192 {

3194 }

3195}

3196

3197

3198

3199

3200static void

3202{

3206

3207

3209

3210

3211

3212

3213

3214

3215

3218 else

3219 {

3223 }

3224

3225

3228 {

3230 if (lowlist_item)

3231 {

3235 }

3238 }

3239

3241}

3242

3243

3244

3245

3246static void

3248{

3250 bool use_variadic;

3251 bool first;

3253

3254

3255

3256

3257

3259 {

3261 return;

3262 }

3263

3264

3265

3266

3267

3269 {

3270 Oid rettype = node->funcresulttype;

3271 int32 coercedTypmod;

3272

3273

3275

3279 return;

3280 }

3281

3282

3283 use_variadic = node->funcvariadic;

3284

3285

3286

3287

3290

3291

3292 first = true;

3293 foreach(arg, node->args)

3294 {

3295 if (!first)

3297 if (use_variadic && lnext(node->args, arg) == NULL)

3300 first = false;

3301 }

3303}

3304

3305

3306

3307

3308

3309static void

3311{

3315 Expr *right;

3316 bool canSuppressRightConstCast = false;

3317 char oprkind;

3318

3319

3322 elog(ERROR, "cache lookup failed for operator %u", node->opno);

3324 oprkind = form->oprkind;

3325

3326

3329

3331

3332

3334

3335

3336 if (oprkind == 'b')

3337 {

3341 bool canSuppressLeftConstCast = false;

3342

3343

3344

3345

3346

3347

3348

3349

3350

3351

3352

3353

3354

3355

3356

3357

3358

3359

3360

3361

3362

3363

3364

3365

3366

3367

3368

3369 if (leftType == rightType)

3370 {

3375 }

3376

3377 if (canSuppressLeftConstCast)

3379 else

3381

3383 }

3384

3385

3387

3388

3390

3391 if (canSuppressRightConstCast)

3393 else

3395

3397

3399}

3400

3401

3402

3403

3404static bool

3406{

3407

3408

3409

3410

3411

3412

3413

3414

3415

3419

3421 {

3422

3423

3424

3425

3426 Var *var = (Var *) node;

3428

3430 return true;

3431 }

3432

3433 return false;

3434}

3435

3436

3437

3438

3439static void

3441{

3442 char *opname;

3443

3444

3445 opname = NameStr(opform->oprname);

3446

3447

3448 if (opform->oprnamespace != PG_CATALOG_NAMESPACE)

3449 {

3450 const char *opnspname;

3451

3453

3456 }

3457 else

3458 {

3459

3461 }

3462}

3463

3464

3465

3466

3467static void

3469{

3471

3473

3479}

3480

3481

3482

3483

3484

3485static void

3487{

3493

3494

3497 elog(ERROR, "cache lookup failed for operator %u", node->opno);

3499

3500

3502

3503

3505

3506

3510

3511

3514

3515

3518

3520

3521

3523

3525}

3526

3527

3528

3529

3530static void

3532{

3537 node->resulttypmod));

3538}

3539

3540

3541

3542

3543static void

3545{

3547

3548

3549

3550

3551

3555 node->resulttypmod));

3556}

3557

3558

3559

3560

3561static void

3563{

3565 const char *op = NULL;

3566 bool first;

3568

3569 switch (node->boolop)

3570 {

3572 op = "AND";

3573 break;

3575 op = "OR";

3576 break;

3581 return;

3582 }

3583

3585 first = true;

3586 foreach(lc, node->args)

3587 {

3588 if (!first)

3591 first = false;

3592 }

3594}

3595

3596

3597

3598

3599static void

3601{

3603

3606

3607

3608

3609

3610

3611

3612

3614 {

3617 else

3619 }

3620 else

3621 {

3624 else

3626 }

3627}

3628

3629

3630

3631

3632static void

3634{

3637

3639

3640

3641 if (node->arg != NULL)

3642 {

3645 }

3646

3647

3648 foreach(lc, node->args)

3649 {

3651

3652

3654 if (node->arg == NULL)

3656 else

3657 {

3658

3660 context);

3661 }

3662

3663

3666 }

3667

3668

3670 {

3673 }

3674

3675

3677}

3678

3679

3680

3681

3682static void

3684{

3686 bool first = true;

3688

3690 foreach(lc, node->elements)

3691 {

3692 if (!first)

3695 first = false;

3696 }

3698

3699

3700 if (node->elements == NIL)

3703}

3704

3705

3706

3707

3708static void

3710{

3712 bool use_variadic;

3713

3714

3716

3717

3718 use_variadic = node->aggvariadic;

3719

3720

3723

3724

3726

3727 if (AGGKIND_IS_ORDERED_SET(node->aggkind))

3728 {

3729

3731 bool first = true;

3732

3733 Assert(!node->aggvariadic);

3735

3737 {

3738 if (!first)

3740 first = false;

3741

3743 }

3744

3747 }

3748 else

3749 {

3750

3751 if (node->aggstar)

3753 else

3754 {

3756 bool first = true;

3757

3758

3759 foreach(arg, node->args)

3760 {

3763

3764 if (tle->resjunk)

3765 continue;

3766

3767 if (!first)

3769 first = false;

3770

3771

3772 if (use_variadic && lnext(node->args, arg) == NULL)

3774

3776 }

3777 }

3778

3779

3781 {

3784 }

3785 }

3786

3787

3789 {

3792 }

3793

3795}

3796

3797

3798

3799

3800static void

3802{

3805 bool first = true;

3806

3807 foreach(lc, orderList)

3808 {

3810 Node *sortexpr;

3811

3812 if (!first)

3814 first = false;

3815

3816

3818 false, context);

3819

3821 context);

3822 }

3823}

3824

3825

3826

3827

3828

3829static void

3832{

3835

3836

3839

3840 if (sortop == typentry->lt_opr)

3842 else if (sortop == typentry->gt_opr)

3844 else

3845 {

3848

3850

3851

3854 elog(ERROR, "cache lookup failed for operator %u", sortop);

3858 }

3859

3860 if (nulls_first)

3862 else

3864}

3865

3866

3867

3868

3869

3870

3871

3872

3873

3874static void

3877{

3880

3882}

3883

3884

3885

3886

3887

3888

3889

3890

3891

3892

3893

3894

3895

3896

3897

3898

3899

3900static void

3903{

3906

3908}

3909

3910

3911

3912

3913static void

3915{

3919 bool first = true;

3920

3921

3923 return;

3924

3926

3927

3928

3929

3930

3932

3933

3934

3935

3936

3937

3938

3939

3941 {

3943

3944 if (!first)

3946 first = false;

3947

3949 }

3950}

3951

3952

3953

3954

3955

3956

3957

3958

3959

3960

3961static void

3964{

3966 int nestlevel;

3968 bool gotone = false;

3969

3970

3972

3973 foreach(lcell, pathkeys)

3974 {

3977 Expr *em_expr;

3979

3980 if (has_final_sort)

3981 {

3982

3983

3984

3985

3987 pathkey->pk_eclass,

3989 }

3990 else

3992 pathkey->pk_eclass,

3994

3995

3996

3997

3998

3999

4000 if (em == NULL)

4001 elog(ERROR, "could not find pathkey item to sort");

4002

4004

4005

4006

4007

4008

4009

4010

4011

4012

4013

4015 continue;

4016

4017 if (!gotone)

4018 {

4020 gotone = true;

4021 }

4022 else

4024

4025

4026

4027

4028

4029

4035 elog(ERROR, "missing operator %d(%u,%u) in opfamily %u",

4038

4040

4041

4042

4043

4044

4047

4048 }

4050}

4051

4052

4053

4054

4055static void

4057{

4060 int nestlevel;

4061

4062

4064

4065 if (root->parse->limitCount)

4066 {

4069 }

4070 if (root->parse->limitOffset)

4071 {

4074 }

4075

4077}

4078

4079

4080

4081

4082

4083static void

4085{

4090

4093 elog(ERROR, "cache lookup failed for function %u", funcid);

4095

4096

4097 if (procform->pronamespace != PG_CATALOG_NAMESPACE)

4098 {

4099 const char *schemaname;

4100

4103 }

4104

4105

4108

4110}

4111

4112

4113

4114

4115

4116

4117

4118static Node *

4121{

4125

4127 expr = tle->expr;

4128

4129 if (force_colno)

4130 {

4131

4132 Assert(!tle->resjunk);

4134 }

4135 else if (expr && IsA(expr, Const))

4136 {

4137

4138

4139

4140

4141

4143 }

4144 else if (!expr || IsA(expr, Var))

4146 else

4147 {

4148

4152 }

4153

4154 return (Node *) expr;

4155}

4156

4157

4158

4159

4160

4161

4162

4163static bool

4165{

4169

4170

4172

4173

4174

4175

4176

4178 return false;

4179

4180

4181

4182

4183

4185 return false;

4186

4188 {

4189

4190

4191

4192

4194 {

4196 return true;

4197 }

4198

4199

4201 }

4202 else

4203 {

4205

4206

4207

4208

4209

4211 {

4213 return true;

4214 }

4215

4216

4218 }

4219}

4220

4221

4222

4223

4224

4225static void

4227 int *relno, int *colno)

4228{

4230 int i;

4232

4233

4235

4236

4237 i = 1;

4239 {

4241

4242

4243

4244

4245

4246

4247

4248 if (IsA(tlvar, Var) &&

4251 {

4252 *colno = i;

4253 return;

4254 }

4255 i++;

4256 }

4257

4258

4259 elog(ERROR, "unexpected expression in subquery output");

4260}

Bitmapset * bms_make_singleton(int x)

int bms_next_member(const Bitmapset *a, int prevbit)

void bms_free(Bitmapset *a)

bool bms_is_member(int x, const Bitmapset *a)

Bitmapset * bms_add_member(Bitmapset *a, int x)

BMS_Membership bms_membership(const Bitmapset *a)

#define FORMAT_TYPE_TYPEMOD_GIVEN

#define FORMAT_TYPE_FORCE_QUALIFY

#define ESCAPE_STRING_SYNTAX

#define SQL_STR_DOUBLE(ch, escape_backslash)

#define OidIsValid(objectId)

bool contain_mutable_functions(Node *clause)

char * defGetString(DefElem *def)

static void deparseArrayCoerceExpr(ArrayCoerceExpr *node, deparse_expr_cxt *context)

static void deparseRangeTblRef(StringInfo buf, PlannerInfo *root, RelOptInfo *foreignrel, bool make_subquery, Index ignore_rel, List **ignore_conds, List **additional_conds, List **params_list)

static void deparseCaseExpr(CaseExpr *node, deparse_expr_cxt *context)

void deparseAnalyzeSizeSql(StringInfo buf, Relation rel)

static void deparseBoolExpr(BoolExpr *node, deparse_expr_cxt *context)

static void appendGroupByClause(List *tlist, deparse_expr_cxt *context)

static void deparseTargetList(StringInfo buf, RangeTblEntry *rte, Index rtindex, Relation rel, bool is_returning, Bitmapset *attrs_used, bool qualify_col, List **retrieved_attrs)

#define SUBQUERY_REL_ALIAS_PREFIX

static void deparseFromExpr(List *quals, deparse_expr_cxt *context)

static Node * deparseSortGroupClause(Index ref, List *tlist, bool force_colno, deparse_expr_cxt *context)

static void deparseLockingClause(deparse_expr_cxt *context)

const char * get_jointype_name(JoinType jointype)

void deparseAnalyzeInfoSql(StringInfo buf, Relation rel)

static void deparseAggref(Aggref *node, deparse_expr_cxt *context)

static void appendOrderBySuffix(Oid sortop, Oid sortcoltype, bool nulls_first, deparse_expr_cxt *context)

void deparseDirectDeleteSql(StringInfo buf, PlannerInfo *root, Index rtindex, Relation rel, RelOptInfo *foreignrel, List *remote_conds, List **params_list, List *returningList, List **retrieved_attrs)

void deparseDirectUpdateSql(StringInfo buf, PlannerInfo *root, Index rtindex, Relation rel, RelOptInfo *foreignrel, List *targetlist, List *targetAttrs, List *remote_conds, List **params_list, List *returningList, List **retrieved_attrs)

struct deparse_expr_cxt deparse_expr_cxt

static void get_relation_column_alias_ids(Var *node, RelOptInfo *foreignrel, int *relno, int *colno)

static void printRemoteParam(int paramindex, Oid paramtype, int32 paramtypmod, deparse_expr_cxt *context)

static bool is_subquery_var(Var *node, RelOptInfo *foreignrel, int *relno, int *colno)

bool is_foreign_param(PlannerInfo *root, RelOptInfo *baserel, Expr *expr)

static void printRemotePlaceholder(Oid paramtype, int32 paramtypmod, deparse_expr_cxt *context)

static void appendOrderByClause(List *pathkeys, bool has_final_sort, deparse_expr_cxt *context)

static bool foreign_expr_walker(Node *node, foreign_glob_cxt *glob_cxt, foreign_loc_cxt *outer_cxt, foreign_loc_cxt *case_arg_cxt)

static void deparseColumnRef(StringInfo buf, int varno, int varattno, RangeTblEntry *rte, bool qualify_col)

static void deparseRelabelType(RelabelType *node, deparse_expr_cxt *context)

static void deparseNullTest(NullTest *node, deparse_expr_cxt *context)

static void deparseOperatorName(StringInfo buf, Form_pg_operator opform)

static void deparseOpExpr(OpExpr *node, deparse_expr_cxt *context)

static void deparseConst(Const *node, deparse_expr_cxt *context, int showtype)

static bool isPlainForeignVar(Expr *node, deparse_expr_cxt *context)

static void deparseDistinctExpr(DistinctExpr *node, deparse_expr_cxt *context)

void deparseSelectStmtForRel(StringInfo buf, PlannerInfo *root, RelOptInfo *rel, List *tlist, List *remote_conds, List *pathkeys, bool has_final_sort, bool has_limit, bool is_subquery, List **retrieved_attrs, List **params_list)

static void deparseFuncExpr(FuncExpr *node, deparse_expr_cxt *context)

void deparseStringLiteral(StringInfo buf, const char *val)

void rebuildInsertSql(StringInfo buf, Relation rel, char *orig_query, List *target_attrs, int values_end_len, int num_params, int num_rows)

struct foreign_glob_cxt foreign_glob_cxt

static void deparseArrayExpr(ArrayExpr *node, deparse_expr_cxt *context)

void deparseInsertSql(StringInfo buf, RangeTblEntry *rte, Index rtindex, Relation rel, List *targetAttrs, bool doNothing, List *withCheckOptionList, List *returningList, List **retrieved_attrs, int *values_end_len)

static void deparseReturningList(StringInfo buf, RangeTblEntry *rte, Index rtindex, Relation rel, bool trig_after_row, List *withCheckOptionList, List *returningList, List **retrieved_attrs)

void deparseUpdateSql(StringInfo buf, RangeTblEntry *rte, Index rtindex, Relation rel, List *targetAttrs, List *withCheckOptionList, List *returningList, List **retrieved_attrs)

static void deparseVar(Var *node, deparse_expr_cxt *context)

static void appendFunctionName(Oid funcid, deparse_expr_cxt *context)

static void appendConditions(List *exprs, deparse_expr_cxt *context)

struct foreign_loc_cxt foreign_loc_cxt

void deparseDeleteSql(StringInfo buf, RangeTblEntry *rte, Index rtindex, Relation rel, List *returningList, List **retrieved_attrs)

void deparseAnalyzeSql(StringInfo buf, Relation rel, PgFdwSamplingMethod sample_method, double sample_frac, List **retrieved_attrs)

static void deparseSubscriptingRef(SubscriptingRef *node, deparse_expr_cxt *context)

static void deparseRelation(StringInfo buf, Relation rel)

static void deparseExplicitTargetList(List *tlist, bool is_returning, List **retrieved_attrs, deparse_expr_cxt *context)

static char * deparse_type_name(Oid type_oid, int32 typemod)

#define ADD_REL_QUALIFIER(buf, varno)

static void appendLimitClause(deparse_expr_cxt *context)

static void deparseExpr(Expr *node, deparse_expr_cxt *context)

bool is_foreign_expr(PlannerInfo *root, RelOptInfo *baserel, Expr *expr)

static void deparseFromExprForRel(StringInfo buf, PlannerInfo *root, RelOptInfo *foreignrel, bool use_alias, Index ignore_rel, List **ignore_conds, List **additional_conds, List **params_list)

#define SUBQUERY_COL_ALIAS_PREFIX

void classifyConditions(PlannerInfo *root, RelOptInfo *baserel, List *input_conds, List **remote_conds, List **local_conds)

static void deparseScalarArrayOpExpr(ScalarArrayOpExpr *node, deparse_expr_cxt *context)

static void appendWhereClause(List *exprs, List *additional_conds, deparse_expr_cxt *context)

void deparseTruncateSql(StringInfo buf, List *rels, DropBehavior behavior, bool restart_seqs)

static void deparseSubqueryTargetList(deparse_expr_cxt *context)

bool is_foreign_pathkey(PlannerInfo *root, RelOptInfo *baserel, PathKey *pathkey)

static void deparseSelectSql(List *tlist, bool is_subquery, List **retrieved_attrs, deparse_expr_cxt *context)

static void deparseParam(Param *node, deparse_expr_cxt *context)

List * build_tlist_to_deparse(RelOptInfo *foreignrel)

static void appendAggOrderBy(List *orderList, List *targetList, deparse_expr_cxt *context)

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

char * OidOutputFunctionCall(Oid functionId, Datum val)

ForeignTable * GetForeignTable(Oid relid)

List * GetForeignColumnOptions(Oid relid, AttrNumber attnum)

char * format_type_extended(Oid type_oid, int32 typemod, bits16 flags)

Assert(PointerIsAligned(start, uint64))

#define HeapTupleIsValid(tuple)

static void * GETSTRUCT(const HeapTupleData *tuple)

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

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

List * list_concat(List *list1, const List *list2)

List * lappend_int(List *list, int datum)

void list_free(List *list)

void list_free_deep(List *list)

bool type_is_rowtype(Oid typid)

Oid get_opfamily_member_for_cmptype(Oid opfamily, Oid lefttype, Oid righttype, CompareType cmptype)

void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)

char * get_attname(Oid relid, AttrNumber attnum, bool missing_ok)

char * get_namespace_name(Oid nspid)

void pfree(void *pointer)

Oid exprType(const Node *expr)

bool exprIsLengthCoercion(const Node *expr, int32 *coercedTypmod)

Node * strip_implicit_coercions(Node *node)

#define IsA(nodeptr, _type_)

#define castNode(_type_, nodeptr)

#define PVC_RECURSE_PLACEHOLDERS

#define IS_SIMPLE_REL(rel)

#define planner_rt_fetch(rti, root)

#define IS_UPPER_REL(rel)

#define lfirst_node(type, lc)

static int list_length(const List *l)

#define forboth(cell1, list1, cell2, list2)

static ListCell * list_head(const List *l)

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

static const struct lconv_member_info table[]

FormData_pg_operator * Form_pg_operator

FormData_pg_proc * Form_pg_proc

static char buf[DEFAULT_XLOG_SEG_SIZE]

static Oid DatumGetObjectId(Datum X)

static Datum ObjectIdGetDatum(Oid X)

void reset_transmission_modes(int nestlevel)

int set_transmission_modes(void)

EquivalenceMember * find_em_for_rel_target(PlannerInfo *root, EquivalenceClass *ec, RelOptInfo *rel)

EquivalenceMember * find_em_for_rel(PlannerInfo *root, EquivalenceClass *ec, RelOptInfo *rel)

bool is_shippable(Oid objectId, Oid classId, PgFdwRelationInfo *fpinfo)

bool is_builtin(Oid objectId)

@ ANALYZE_SAMPLE_BERNOULLI

PlanRowMark * get_plan_rowmark(List *rowmarks, Index rtindex)

#define IS_SPECIAL_VARNO(varno)

#define RelationGetRelid(relation)

#define RelationGetDescr(relation)

#define RelationGetRelationName(relation)

#define RelationGetNamespace(relation)

const char * quote_identifier(const char *ident)

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

void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)

void appendStringInfoString(StringInfo str, const char *s)

void appendStringInfoChar(StringInfo str, char ch)

void initStringInfo(StringInfo str)

NullTestType nulltesttype

bool make_outerrel_subquery

Relids lower_subquery_rels

bool make_innerrel_subquery

LockClauseStrength strength

struct PathTarget * reltarget

bool trig_update_after_row

bool trig_insert_after_row

bool trig_delete_after_row

#define FirstLowInvalidHeapAttributeNumber

#define TableOidAttributeNumber

#define SelfItemPointerAttributeNumber

void ReleaseSysCache(HeapTuple tuple)

HeapTuple SearchSysCache1(int cacheId, Datum key1)

void table_close(Relation relation, LOCKMODE lockmode)

Relation table_open(Oid relationId, LOCKMODE lockmode)

TargetEntry * get_sortgroupref_tle(Index sortref, List *targetList)

List * add_to_flat_tlist(List *tlist, List *exprs)

#define FirstNormalObjectId

static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)

static CompactAttribute * TupleDescCompactAttr(TupleDesc tupdesc, int i)

TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)

List * pull_var_clause(Node *node, int flags)

void pull_varattnos(Node *node, Index varno, Bitmapset **varattnos)