PostgreSQL Source Code: src/backend/catalog/dependency.c Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

16

84#include "utils/fmgroids.h"

87

88

89

90

91

92

93

94typedef struct

95{

96 int flags;

99

100

101#define DEPFLAG_ORIGINAL 0x0001

102#define DEPFLAG_NORMAL 0x0002

103#define DEPFLAG_AUTO 0x0004

104#define DEPFLAG_INTERNAL 0x0008

105#define DEPFLAG_PARTITION 0x0010

106#define DEPFLAG_EXTENSION 0x0020

107#define DEPFLAG_REVERSE 0x0040

108#define DEPFLAG_IS_PART 0x0080

109#define DEPFLAG_SUBOBJECT 0x0100

110

111

112

114{

117 int numrefs;

118 int maxrefs;

119};

120

121

122

123

125{

127 int flags;

130

131

132typedef struct

133{

135 int subflags;

137

138

139typedef struct

140{

142 List *rtables;

144

145

147 int objflags,

178

179

180

181

182

183

184static void

187{

188 int i;

189

190

191

192

194 {

195 for (i = 0; i < targetObjects->numrefs; i++)

196 {

199 bool original = false;

200 bool normal = false;

201

203 original = true;

205 normal = true;

207 normal = true;

208

210 {

212 }

213 }

214 }

215

216

217

218

219

220 for (i = 0; i < targetObjects->numrefs; i++)

221 {

224

227 continue;

228

230 }

231}

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272void

275{

278

279

280

281

282

284

285

286

287

288

290

291

292

293

294

296

300 NULL,

301 targetObjects,

302 NULL,

303 &depRel);

304

305

306

307

309 behavior,

311 object);

312

313

315

316

318

320}

321

322

323

324

325

326

327

328

329

330

331void

334{

337 int i;

338

339

340 if (objects->numrefs <= 0)

341 return;

342

343

344

345

346

348

349

350

351

352

353

354

355

356

358

359 for (i = 0; i < objects->numrefs; i++)

360 {

362

363

364

365

366

368

372 NULL,

373 targetObjects,

374 objects,

375 &depRel);

376 }

377

378

379

380

381

382

383

385 behavior,

387 (objects->numrefs == 1 ? objects->refs : NULL));

388

389

391

392

394

396}

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431static void

433 int objflags,

439{

441 int nkeys;

448 int numDependentObjects;

449 int maxDependentObjects;

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

470 return;

471

472

473

474

475

477

478

479

480

481

482

483

484

485

486

488 return;

489

490

491

492

493

496 (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),

497 errmsg("cannot drop %s because it is required by the database system",

499

500

501

502

503

504

505

506

507

508

509

511 Anum_pg_depend_classid,

515 Anum_pg_depend_objid,

519 {

520

522 Anum_pg_depend_objsubid,

525 nkeys = 3;

526 }

527 else

528 {

529

530 nkeys = 2;

531 }

532

534 NULL, nkeys, key);

535

536

537 memset(&owningObject, 0, sizeof(owningObject));

538 memset(&partitionObject, 0, sizeof(partitionObject));

539

541 {

543

544 otherObject.classId = foundDep->refclassid;

545 otherObject.objectId = foundDep->refobjid;

546 otherObject.objectSubId = foundDep->refobjsubid;

547

548

549

550

551

552

553

554

558 continue;

559

560 switch (foundDep->deptype)

561 {

565

566 break;

567

569

570

571

572

573

574

575

577 break;

578

579

580

581

582

583

584

585

586

588 otherObject.classId == ExtensionRelationId &&

590 break;

591

592

593

594

596

597

598

599

600

601

602

603

604

605

606

607

608

609

610

611

612

613

614 if (stack == NULL)

615 {

616 if (pendingObjects &&

618 {

620

622 return;

623 }

624

625

626

627

628

629

630

631

632

633

634

637 owningObject = otherObject;

638 break;

639 }

640

641

642

643

644

645

646

647

648

650 break;

651

652

653

654

655

656

657

658

659

660

661

664

665

666

667

668

669

670

672 {

675 return;

676 }

677

678

679

680

681

682

684

685

686

687

688

689

690

691

692

693

694

695

699 stack,

700 targetObjects,

701 pendingObjects,

702 depRel);

703

704

705

706

707

708

709

710

711

712

713

714

715

716

717

718

719

721 targetObjects))

722 elog(ERROR, "deletion of owning object %s failed to delete %s",

725

726

727 return;

728

730

731

732

733

734

735

737

738

739

740

741

742

743 partitionObject = otherObject;

744 break;

745

747

748

749

750

751

753 partitionObject = otherObject;

754

755

756

757

758

759

761 break;

762

763 default:

764 elog(ERROR, "unrecognized dependency type '%c' for %s",

766 break;

767 }

768 }

769

771

772

773

774

775

776

777

779 {

780 char *otherObjDesc;

781

784 else

786

788 (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),

789 errmsg("cannot drop %s because %s requires it",

791 errhint("You can drop %s instead.", otherObjDesc)));

792 }

793

794

795

796

797

798

799

800

801

802 maxDependentObjects = 128;

805 numDependentObjects = 0;

806

808 Anum_pg_depend_refclassid,

812 Anum_pg_depend_refobjid,

816 {

818 Anum_pg_depend_refobjsubid,

821 nkeys = 3;

822 }

823 else

824 nkeys = 2;

825

827 NULL, nkeys, key);

828

830 {

832 int subflags;

833

834 otherObject.classId = foundDep->classid;

835 otherObject.objectId = foundDep->objid;

836 otherObject.objectSubId = foundDep->objsubid;

837

838

839

840

841

842

846 continue;

847

848

849

850

852

853

854

855

856

857

858

859

861 {

862

864

865 continue;

866 }

867

868

869

870

871

872 switch (foundDep->deptype)

873 {

876 break;

880 break;

883 break;

887 break;

890 break;

891 default:

892 elog(ERROR, "unrecognized dependency type '%c' for %s",

894 subflags = 0;

895 break;

896 }

897

898

899 if (numDependentObjects >= maxDependentObjects)

900 {

901

902 maxDependentObjects *= 2;

906 }

907

908 dependentObjects[numDependentObjects].obj = otherObject;

909 dependentObjects[numDependentObjects].subflags = subflags;

910 numDependentObjects++;

911 }

912

914

915

916

917

918

919

920 if (numDependentObjects > 1)

921 qsort(dependentObjects, numDependentObjects,

924

925

926

927

928

929 mystack.object = object;

930 mystack.flags = objflags;

931 mystack.next = stack;

932

933 for (int i = 0; i < numDependentObjects; i++)

934 {

936

940 &mystack,

941 targetObjects,

942 pendingObjects,

943 depRel);

944 }

945

946 pfree(dependentObjects);

947

948

949

950

951

952

953

954

955

958 extra.dependee = partitionObject;

959 else if (stack)

961 else

964}

965

966

967

968

969

970

971

972

973

974

975

976

977

978

979static void

984{

986 bool ok = true;

989 int numReportedClient = 0;

990 int numNotReportedClient = 0;

991 int i;

992

993

994

995

996

997

998

999

1000

1001

1002

1003 for (i = 0; i < targetObjects->numrefs; i++)

1004 {

1006

1009 {

1012 false);

1013

1015 (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),

1016 errmsg("cannot drop %s because %s requires it",

1018 errhint("You can drop %s instead.", otherObjDesc)));

1019 }

1020 }

1021

1022

1023

1024

1025

1026

1029 return;

1030

1031

1032

1033

1034

1035

1036#define MAX_REPORTED_DEPS 100

1037

1040

1041

1042

1043

1044

1045 for (i = targetObjects->numrefs - 1; i >= 0; i--)

1046 {

1049 char *objDesc;

1050

1051

1053 continue;

1054

1055

1057 continue;

1058

1060

1061

1062 if (objDesc == NULL)

1063 continue;

1064

1065

1066

1067

1068

1069

1074 {

1075

1076

1077

1078

1079

1080

1083 objDesc)));

1084 }

1086 {

1088 false);

1089

1090 if (otherDesc)

1091 {

1093 {

1094

1095 if (clientdetail.len != 0)

1098 objDesc, otherDesc);

1099 numReportedClient++;

1100 }

1101 else

1102 numNotReportedClient++;

1103

1104 if (logdetail.len != 0)

1107 objDesc, otherDesc);

1108 pfree(otherDesc);

1109 }

1110 else

1111 numNotReportedClient++;

1112 ok = false;

1113 }

1114 else

1115 {

1117 {

1118

1119 if (clientdetail.len != 0)

1122 objDesc);

1123 numReportedClient++;

1124 }

1125 else

1126 numNotReportedClient++;

1127

1128 if (logdetail.len != 0)

1131 objDesc);

1132 }

1133

1135 }

1136

1137 if (numNotReportedClient > 0)

1139 "(see server log for list)",

1140 "\nand %d other objects "

1141 "(see server log for list)",

1142 numNotReportedClient),

1143 numNotReportedClient);

1144

1145 if (!ok)

1146 {

1147 if (origObject)

1149 (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),

1150 errmsg("cannot drop %s because other objects depend on it",

1154 errhint("Use DROP ... CASCADE to drop the dependent objects too.")));

1155 else

1157 (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),

1158 errmsg("cannot drop desired object(s) because other objects depend on them"),

1161 errhint("Use DROP ... CASCADE to drop the dependent objects too.")));

1162 }

1163 else if (numReportedClient > 1)

1164 {

1166 (errmsg_plural("drop cascades to %d other object",

1167 "drop cascades to %d other objects",

1168 numReportedClient + numNotReportedClient,

1169 numReportedClient + numNotReportedClient),

1172 }

1173 else if (numReportedClient == 1)

1174 {

1175

1178 }

1179

1182}

1183

1184

1185

1186

1187

1188static void

1190{

1191 int cacheId;

1194

1196

1198

1199

1200

1201

1202 if (cacheId >= 0)

1203 {

1206 elog(ERROR, "cache lookup failed for %s %u",

1208

1210

1212 }

1213 else

1214 {

1217

1222

1224 NULL, 1, skey);

1225

1226

1229 elog(ERROR, "could not find tuple for %s %u",

1231

1233

1235 }

1236

1238}

1239

1240

1241

1242

1243

1244

1245static void

1247{

1249 int nkeys;

1252

1253

1256

1257

1258

1259

1260

1261

1264

1265

1266

1267

1268

1269

1270

1271

1272

1273

1275

1276

1277

1278

1281

1282

1283

1284

1285

1286

1287

1288

1290 Anum_pg_depend_classid,

1294 Anum_pg_depend_objid,

1298 {

1300 Anum_pg_depend_objsubid,

1303 nkeys = 3;

1304 }

1305 else

1306 nkeys = 2;

1307

1309 NULL, nkeys, key);

1310

1312 {

1314 }

1315

1317

1318

1319

1320

1321

1324

1325

1326

1327

1328

1329

1330

1331

1332

1336

1337

1338

1339

1340

1342

1343

1344

1345

1346}

1347

1348

1349

1350

1351static void

1353{

1355 {

1356 case RelationRelationId:

1357 {

1359

1360 if (relKind == RELKIND_INDEX ||

1361 relKind == RELKIND_PARTITIONED_INDEX)

1362 {

1365

1368 }

1369 else

1370 {

1374 else

1376 }

1377

1378

1379

1380

1381

1382 if (relKind == RELKIND_SEQUENCE)

1384 break;

1385 }

1386

1387 case ProcedureRelationId:

1389 break;

1390

1391 case TypeRelationId:

1393 break;

1394

1395 case ConstraintRelationId:

1397 break;

1398

1399 case AttrDefaultRelationId:

1401 break;

1402

1403 case LargeObjectRelationId:

1405 break;

1406

1407 case OperatorRelationId:

1409 break;

1410

1411 case RewriteRelationId:

1413 break;

1414

1415 case TriggerRelationId:

1417 break;

1418

1419 case StatisticExtRelationId:

1421 break;

1422

1423 case TSConfigRelationId:

1425 break;

1426

1427 case ExtensionRelationId:

1429 break;

1430

1431 case PolicyRelationId:

1433 break;

1434

1435 case PublicationNamespaceRelationId:

1437 break;

1438

1439 case PublicationRelRelationId:

1441 break;

1442

1443 case PublicationRelationId:

1445 break;

1446

1447 case CastRelationId:

1448 case CollationRelationId:

1449 case ConversionRelationId:

1450 case LanguageRelationId:

1451 case OperatorClassRelationId:

1452 case OperatorFamilyRelationId:

1453 case AccessMethodRelationId:

1454 case AccessMethodOperatorRelationId:

1455 case AccessMethodProcedureRelationId:

1456 case NamespaceRelationId:

1457 case TSParserRelationId:

1458 case TSDictionaryRelationId:

1459 case TSTemplateRelationId:

1460 case ForeignDataWrapperRelationId:

1461 case ForeignServerRelationId:

1462 case UserMappingRelationId:

1463 case DefaultAclRelationId:

1464 case EventTriggerRelationId:

1465 case TransformRelationId:

1466 case AuthMemRelationId:

1468 break;

1469

1470

1471

1472

1473 case AuthIdRelationId:

1474 case DatabaseRelationId:

1475 case TableSpaceRelationId:

1476 case SubscriptionRelationId:

1477 case ParameterAclRelationId:

1478 elog(ERROR, "global objects cannot be deleted by doDeletion");

1479 break;

1480

1481 default:

1483 }

1484}

1485

1486

1487

1488

1489

1490

1491

1492

1493

1494

1495void

1497{

1499 {

1500

1501

1502

1503

1504

1505

1508 else

1510 }

1514 else

1515 {

1516

1519 }

1520}

1521

1522

1523

1524

1525

1526

1527void

1529{

1532 else

1533

1536}

1537

1538

1539

1540

1541

1542

1543

1544

1545

1546

1547

1548

1549

1550

1551

1552void

1556{

1558

1560

1561

1563

1564

1566

1567

1569

1570

1573 behavior);

1574

1576}

1577

1578

1579

1580

1581

1582

1583

1584

1585

1586

1587

1588

1589

1590

1591

1592

1593

1594

1595void

1600 bool reverse_self)

1601{

1604

1606

1607

1608 rte.type = T_RangeTblEntry;

1610 rte.relid = relId;

1611 rte.relkind = RELKIND_RELATION;

1613

1615

1616

1618

1619

1621

1622

1623 if ((behavior != self_behavior || reverse_self) &&

1625 {

1628 int oldref,

1629 outrefs;

1630

1632

1634 outrefs = 0;

1635 for (oldref = 0; oldref < context.addrs->numrefs; oldref++)

1636 {

1638

1639 if (thisobj->classId == RelationRelationId &&

1641 {

1642

1644 }

1645 else

1646 {

1647

1648 *outobj = *thisobj;

1649 outobj++;

1650 outrefs++;

1651 }

1652 }

1654

1655

1656 if (!reverse_self)

1659 self_behavior);

1660 else

1661 {

1662

1663 int selfref;

1664

1665 for (selfref = 0; selfref < self_addrs->numrefs; selfref++)

1666 {

1668

1670 }

1671 }

1672

1674 }

1675

1676

1679 behavior);

1680

1682}

1683

1684

1685

1686

1687

1688

1689

1690

1691

1692

1693

1694

1695

1696

1697static bool

1700{

1701 if (node == NULL)

1702 return false;

1704 {

1705 Var *var = (Var *) node;

1706 List *rtable;

1708

1709

1716

1717

1718

1719

1720

1721

1722

1723

1724

1725

1726

1727

1729 return false;

1731 {

1732

1734 context->addrs);

1735 }

1737 {

1738

1739

1741 }

1742

1743

1744

1745

1746

1747

1748

1749

1750

1751 return false;

1752 }

1754 {

1756 Oid objoid;

1757

1758

1760 context->addrs);

1761

1762

1763

1764

1765

1766

1767

1769 con->constcollid != DEFAULT_COLLATION_OID)

1771 context->addrs);

1772

1773

1774

1775

1776

1777

1778

1779 if (!con->constisnull)

1780 {

1782 {

1783 case REGPROCOID:

1784 case REGPROCEDUREOID:

1789 context->addrs);

1790 break;

1791 case REGOPEROID:

1792 case REGOPERATOROID:

1797 context->addrs);

1798 break;

1799 case REGCLASSOID:

1804 context->addrs);

1805 break;

1806 case REGTYPEOID:

1811 context->addrs);

1812 break;

1813 case REGCOLLATIONOID:

1818 context->addrs);

1819 break;

1820 case REGCONFIGOID:

1825 context->addrs);

1826 break;

1827 case REGDICTIONARYOID:

1832 context->addrs);

1833 break;

1834

1835 case REGNAMESPACEOID:

1840 context->addrs);

1841 break;

1842

1843

1844

1845

1846

1847 case REGROLEOID:

1849 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),

1850 errmsg("constant of the type %s cannot be used here",

1851 "regrole")));

1852 break;

1853 }

1854 }

1855 return false;

1856 }

1858 {

1860

1861

1863 context->addrs);

1864

1865 if (OidIsValid(param->paramcollid) &&

1866 param->paramcollid != DEFAULT_COLLATION_OID)

1868 context->addrs);

1869 }

1871 {

1873

1875 context->addrs);

1876

1877 }

1879 {

1881

1883 context->addrs);

1884

1885 }

1887 {

1889

1891 context->addrs);

1892

1893 }

1895 {

1897

1899 context->addrs);

1900

1901 }

1903 {

1905

1907 context->addrs);

1908

1909 }

1911 {

1913

1915 context->addrs);

1916

1917 }

1919 {

1921

1923 context->addrs);

1924

1925 }

1927 {

1929

1930

1931

1932

1933

1934

1935

1936 if (sbsref->refrestype != sbsref->refcontainertype &&

1937 sbsref->refrestype != sbsref->refelemtype)

1939 context->addrs);

1940

1941 }

1943 {

1944

1945 elog(ERROR, "already-planned subqueries not supported");

1946 }

1948 {

1952

1953

1954

1955

1956

1957

1958

1959

1960

1961

1964 context->addrs);

1965 else

1967 context->addrs);

1968

1969 if (OidIsValid(fselect->resultcollid) &&

1970 fselect->resultcollid != DEFAULT_COLLATION_OID)

1972 context->addrs);

1973 }

1975 {

1978

1979

1981 {

1983

1984 foreach(l, fstore->fieldnums)

1986 context->addrs);

1987 }

1988 else

1990 context->addrs);

1991 }

1993 {

1995

1996

1998 context->addrs);

1999

2000 if (OidIsValid(relab->resultcollid) &&

2001 relab->resultcollid != DEFAULT_COLLATION_OID)

2003 context->addrs);

2004 }

2006 {

2008

2009

2011 context->addrs);

2012

2013 if (OidIsValid(iocoerce->resultcollid) &&

2014 iocoerce->resultcollid != DEFAULT_COLLATION_OID)

2016 context->addrs);

2017 }

2019 {

2021

2022

2024 context->addrs);

2025

2026 if (OidIsValid(acoerce->resultcollid) &&

2027 acoerce->resultcollid != DEFAULT_COLLATION_OID)

2029 context->addrs);

2030

2031 }

2033 {

2035

2036

2038 context->addrs);

2039 }

2041 {

2043

2045 context->addrs);

2046 }

2048 {

2050

2052 context->addrs);

2053 }

2055 {

2058

2059 foreach(l, rcexpr->opnos)

2060 {

2062 context->addrs);

2063 }

2064 foreach(l, rcexpr->opfamilies)

2065 {

2067 context->addrs);

2068 }

2069

2070 }

2072 {

2074

2076 context->addrs);

2077 }

2079 {

2081

2083 context->addrs);

2084 }

2086 {

2088

2091 context->addrs);

2092

2093 }

2095 {

2097

2099 context->addrs);

2102 context->addrs);

2103 return false;

2104 }

2106 {

2108

2109 if (OidIsValid(wc->startInRangeFunc))

2111 context->addrs);

2114 context->addrs);

2116 wc->inRangeColl != DEFAULT_COLLATION_OID)

2118 context->addrs);

2119

2120 }

2122 {

2124

2127 context->addrs);

2130 context->addrs);

2133 context->addrs);

2134

2135 }

2137 {

2138

2141 bool result;

2142

2143

2144

2145

2146

2147

2148

2149

2150

2151

2152

2153

2154

2155

2156

2157

2158

2159 foreach(lc, query->rtable)

2160 {

2162

2164 {

2167 context->addrs);

2168 break;

2170

2171

2172

2173

2174

2175

2176

2177

2178

2179

2180

2181

2182

2183

2185 for (int i = 0; i < rte->joinmergedcols; i++)

2186 {

2187 Node *aliasvar = list_nth(rte->joinaliasvars, i);

2188

2189 if (IsA(aliasvar, Var))

2191 }

2193 break;

2195

2196

2197

2198

2199

2200

2201

2202

2204 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),

2205 errmsg("transition table \"%s\" cannot be referenced in a persistent object",

2206 rte->eref->aliasname)));

2207 break;

2208 default:

2209

2210 break;

2211 }

2212 }

2213

2214

2215

2216

2217

2218

2219

2220

2223 {

2225

2226 if (query->resultRelation <= 0 ||

2228 elog(ERROR, "invalid resultRelation %d",

2229 query->resultRelation);

2230 rte = rt_fetch(query->resultRelation, query->rtable);

2232 {

2234 {

2236

2237 if (tle->resjunk)

2238 continue;

2240 context->addrs);

2241 }

2242 }

2243 }

2244

2245

2246

2247

2248 foreach(lc, query->constraintDeps)

2249 {

2251 context->addrs);

2252 }

2253

2254

2258 context,

2262 return result;

2263 }

2265 {

2267

2268

2270

2271 }

2273 {

2276

2277

2278

2279

2280

2281

2282 foreach(ct, rtfunc->funccoltypes)

2283 {

2285 context->addrs);

2286 }

2287 foreach(ct, rtfunc->funccolcollations)

2288 {

2290

2293 context->addrs);

2294 }

2295 }

2297 {

2300

2301

2302

2303

2304 foreach(ct, tf->coltypes)

2305 {

2307 context->addrs);

2308 }

2309 foreach(ct, tf->colcollations)

2310 {

2312

2315 context->addrs);

2316 }

2317 }

2319 {

2321

2323 context->addrs);

2324

2325 }

2326

2328 context);

2329}

2330

2331

2332

2333

2334

2335static void

2338{

2339 int atts_done = 0;

2341

2342

2343

2344

2345

2346

2347

2349 {

2351

2352 if (attnum > atts_done &&

2353 attnum <= atts_done + rtfunc->funccolcount)

2354 {

2356

2357

2358 if (rtfunc->funccolnames != NIL)

2359 tupdesc = NULL;

2360 else

2362 if (tupdesc && tupdesc->tdtypeid != RECORDOID)

2363 {

2364

2365

2366

2367

2369

2370 Assert(attnum - atts_done <= tupdesc->natts);

2371 if (OidIsValid(reltype))

2374 context->addrs);

2375 return;

2376 }

2377

2378 return;

2379 }

2380 atts_done += rtfunc->funccolcount;

2381 }

2382

2383

2385 return;

2386

2387

2389 (errcode(ERRCODE_UNDEFINED_COLUMN),

2390 errmsg("column %d of relation \"%s\" does not exist",

2391 attnum, rte->eref->aliasname)));

2392}

2393

2394

2395

2396

2397static void

2399{

2401 int oldref,

2402 newrefs;

2403

2404

2405

2406

2407

2408

2410

2411 if (addrs->numrefs <= 1)

2412 return;

2413

2414

2417

2418

2419 priorobj = addrs->refs;

2420 newrefs = 1;

2421 for (oldref = 1; oldref < addrs->numrefs; oldref++)

2422 {

2424

2427 {

2429 continue;

2430

2431

2432

2433

2434

2435

2436

2437

2439 {

2440

2442 continue;

2443 }

2444 }

2445

2446 priorobj++;

2447 *priorobj = *thisobj;

2448 newrefs++;

2449 }

2450

2451 addrs->numrefs = newrefs;

2452}

2453

2454

2455

2456

2457static int

2459{

2462

2463

2464

2465

2466

2467

2469 return -1;

2471 return 1;

2472

2473

2474

2475

2476

2478 return -1;

2480 return 1;

2481

2482

2483

2484

2485

2486

2487

2488

2490 return -1;

2492 return 1;

2493 return 0;

2494}

2495

2496

2497

2498

2499

2500

2503{

2505

2507

2512 addrs->extras = NULL;

2513

2514 return addrs;

2515}

2516

2517

2518

2519

2520static void

2523{

2525

2526

2528 {

2533 }

2534

2536 item->classId = classId;

2540}

2541

2542

2543

2544

2545

2546

2547void

2550{

2552

2553

2555 {

2560 }

2561

2565}

2566

2567

2568

2569

2570

2571

2572static void

2576{

2579

2580

2584

2585

2587 {

2593 }

2594

2598 *itemextra = *extra;

2600}

2601

2602

2603

2604

2605

2606

2607bool

2610{

2611 int i;

2612

2613 for (i = addrs->numrefs - 1; i >= 0; i--)

2614 {

2616

2619 {

2622 return true;

2623 }

2624 }

2625

2626 return false;

2627}

2628

2629

2630

2631

2632

2633static bool

2637{

2638 bool result = false;

2639 int i;

2640

2641 for (i = addrs->numrefs - 1; i >= 0; i--)

2642 {

2644

2647 {

2649 {

2651

2653 result = true;

2654 }

2656 {

2657

2658

2659

2660

2661

2662

2663

2664 result = true;

2665 }

2667 {

2668

2669

2670

2671

2672

2673

2674

2675

2676

2677

2678

2679

2680

2681

2682

2683

2684

2685

2686

2687

2688

2689

2690

2691

2693

2696 }

2697 }

2698 }

2699

2700 return result;

2701}

2702

2703

2704

2705

2706static bool

2710{

2711 bool result = false;

2713

2714 for (stackptr = stack; stackptr; stackptr = stackptr->next)

2715 {

2717

2720 {

2722 {

2724 result = true;

2725 }

2727 {

2728

2729

2730

2731

2732

2733

2734 result = true;

2735 }

2737 {

2738

2739

2740

2741

2742

2745 }

2746 }

2747 }

2748

2749 return result;

2750}

2751

2752

2753

2754

2755

2756void

2760{

2764 behavior);

2765}

2766

2767

2768

2769

2770

2771

2772

2773

2774

2775void

2777{

2782}

2783

2784

2785

2786

2787void

2789{

2794}

2795

2796

2797

2798

2799static void

2801{

2804 int nkeys;

2807

2809

2811 Anum_pg_init_privs_objoid,

2815 Anum_pg_init_privs_classoid,

2819 {

2821 Anum_pg_init_privs_objsubid,

2824 nkeys = 3;

2825 }

2826 else

2827 nkeys = 2;

2828

2830 NULL, nkeys, key);

2831

2834

2836

2838}

#define InvalidAttrNumber

#define ngettext(s, p, n)

#define OidIsValid(objectId)

bool IsPinnedObject(Oid classId, Oid objectId)

void DeleteSequenceTuple(Oid relid)

static bool object_address_present_add_flags(const ObjectAddress *object, int flags, ObjectAddresses *addrs)

#define DEPFLAG_PARTITION

void performMultipleDeletions(const ObjectAddresses *objects, DropBehavior behavior, int flags)

struct ObjectAddressStack ObjectAddressStack

static void add_exact_object_address_extra(const ObjectAddress *object, const ObjectAddressExtra *extra, ObjectAddresses *addrs)

void record_object_address_dependencies(const ObjectAddress *depender, ObjectAddresses *referenced, DependencyType behavior)

static void DropObjectById(const ObjectAddress *object)

static int object_address_comparator(const void *a, const void *b)

void sort_object_addresses(ObjectAddresses *addrs)

static void doDeletion(const ObjectAddress *object, int flags)

static bool stack_address_present_add_flags(const ObjectAddress *object, int flags, ObjectAddressStack *stack)

static void add_object_address(Oid classId, Oid objectId, int32 subId, ObjectAddresses *addrs)

static bool find_expr_references_walker(Node *node, find_expr_references_context *context)

static void eliminate_duplicate_dependencies(ObjectAddresses *addrs)

void AcquireDeletionLock(const ObjectAddress *object, int flags)

void performDeletion(const ObjectAddress *object, DropBehavior behavior, int flags)

static void deleteOneObject(const ObjectAddress *object, Relation *depRel, int32 flags)

static void DeleteInitPrivs(const ObjectAddress *object)

#define MAX_REPORTED_DEPS

static void process_function_rte_ref(RangeTblEntry *rte, AttrNumber attnum, find_expr_references_context *context)

static void reportDependentObjects(const ObjectAddresses *targetObjects, DropBehavior behavior, int flags, const ObjectAddress *origObject)

void ReleaseDeletionLock(const ObjectAddress *object)

void recordDependencyOnSingleRelExpr(const ObjectAddress *depender, Node *expr, Oid relId, DependencyType behavior, DependencyType self_behavior, bool reverse_self)

void recordDependencyOnExpr(const ObjectAddress *depender, Node *expr, List *rtable, DependencyType behavior)

static void findDependentObjects(const ObjectAddress *object, int objflags, int flags, ObjectAddressStack *stack, ObjectAddresses *targetObjects, const ObjectAddresses *pendingObjects, Relation *depRel)

bool object_address_present(const ObjectAddress *object, const ObjectAddresses *addrs)

void add_exact_object_address(const ObjectAddress *object, ObjectAddresses *addrs)

ObjectAddresses * new_object_addresses(void)

#define DEPFLAG_SUBOBJECT

#define DEPFLAG_EXTENSION

static void deleteObjectsInList(ObjectAddresses *targetObjects, Relation *depRel, int flags)

void free_object_addresses(ObjectAddresses *addrs)

#define PERFORM_DELETION_CONCURRENTLY

#define PERFORM_DELETION_SKIP_EXTENSIONS

@ DEPENDENCY_AUTO_EXTENSION

@ DEPENDENCY_PARTITION_PRI

@ DEPENDENCY_PARTITION_SEC

#define PERFORM_DELETION_CONCURRENT_LOCK

#define PERFORM_DELETION_QUIETLY

#define PERFORM_DELETION_SKIP_ORIGINAL

#define PERFORM_DELETION_INTERNAL

int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)

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

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

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

bool message_level_is_interesting(int elevel)

int errcode(int sqlerrcode)

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

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

#define ereport(elevel,...)

void EventTriggerSQLDropAddObject(const ObjectAddress *object, bool original, bool normal)

bool trackDroppedObjectsNeeded(void)

bool EventTriggerSupportsObject(const ObjectAddress *object)

Oid CurrentExtensionObject

void RemoveExtensionById(Oid extId)

TupleDesc get_expr_result_tupdesc(Node *expr, bool noError)

void RemoveFunctionById(Oid funcOid)

void systable_endscan(SysScanDesc sysscan)

bool systable_recheck_tuple(SysScanDesc sysscan, HeapTuple tup)

HeapTuple systable_getnext(SysScanDesc sysscan)

SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)

Assert(PointerIsAligned(start, uint64))

void RemoveAttributeById(Oid relid, AttrNumber attnum)

void heap_drop_with_catalog(Oid relid)

#define HeapTupleIsValid(tuple)

static void * GETSTRUCT(const HeapTupleData *tuple)

void index_drop(Oid indexId, bool concurrent, bool concurrent_lock_mode)

void CatalogTupleDelete(Relation heapRel, ItemPointer tid)

List * list_delete_first(List *list)

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

void LockSharedObject(Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)

void UnlockRelationOid(Oid relid, LOCKMODE lockmode)

void LockDatabaseObject(Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)

void LockRelationOid(Oid relid, LOCKMODE lockmode)

void UnlockDatabaseObject(Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)

#define AccessExclusiveLock

#define ShareUpdateExclusiveLock

char get_rel_relkind(Oid relid)

Oid get_typ_typrelid(Oid typid)

Oid getBaseType(Oid typid)

void * repalloc(void *pointer, Size size)

void pfree(void *pointer)

Oid exprType(const Node *expr)

#define query_tree_walker(q, w, c, f)

#define QTW_EXAMINE_SORTGROUP

#define expression_tree_walker(n, w, c)

#define QTW_IGNORE_JOINALIASES

#define IsA(nodeptr, _type_)

#define InvokeObjectDropHookArg(classId, objectId, subId, dropflags)

AttrNumber get_object_attnum_oid(Oid class_id)

const char * get_object_class_descr(Oid class_id)

char * getObjectDescription(const ObjectAddress *object, bool missing_ok)

int get_object_catcache_oid(Oid class_id)

Oid get_object_oid_index(Oid class_id)

void RemoveOperatorById(Oid operOid)

#define rt_fetch(rangetable_index, rangetable)

void RemoveAttrDefaultById(Oid attrdefId)

void RemoveConstraintById(Oid conId)

void recordMultipleDependencies(const ObjectAddress *depender, const ObjectAddress *referenced, int nreferenced, DependencyType behavior)

void recordDependencyOn(const ObjectAddress *depender, const ObjectAddress *referenced, DependencyType behavior)

FormData_pg_depend * Form_pg_depend

void LargeObjectDrop(Oid loid)

static int list_length(const List *l)

static void * list_nth(const List *list, int n)

void deleteSharedDependencyRecordsFor(Oid classId, Oid objectId, int32 objectSubId)

void RemovePolicyById(Oid policy_id)

#define qsort(a, b, c, d)

static Oid DatumGetObjectId(Datum X)

static Datum ObjectIdGetDatum(Oid X)

static Datum Int32GetDatum(int32 X)

void RemovePublicationSchemaById(Oid psoid)

void RemovePublicationById(Oid pubid)

void RemovePublicationRelById(Oid proid)

void RemoveRewriteRuleById(Oid ruleOid)

void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)

void DeleteSecurityLabel(const ObjectAddress *object)

void check_stack_depth(void)

void RemoveStatisticsById(Oid statsOid)

#define BTEqualStrategyNumber

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

void appendStringInfoChar(StringInfo str, char ch)

void initStringInfo(StringInfo str)

const ObjectAddress * object

struct ObjectAddressStack * next

ObjectAddressExtra * extras

void ReleaseSysCache(HeapTuple tuple)

HeapTuple SearchSysCache1(int cacheId, Datum key1)

#define SearchSysCacheExists1(cacheId, key1)

void table_close(Relation relation, LOCKMODE lockmode)

Relation table_open(Oid relationId, LOCKMODE lockmode)

void RemoveTriggerById(Oid trigOid)

void RemoveTSConfigurationById(Oid cfgId)

void RemoveTypeById(Oid typeOid)

void CommandCounterIncrement(void)