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
85#include "utils/fmgroids.h"
88
89
90
91
92
93
94
95typedef struct
96{
100
101
102#define DEPFLAG_ORIGINAL 0x0001
103#define DEPFLAG_NORMAL 0x0002
104#define DEPFLAG_AUTO 0x0004
105#define DEPFLAG_INTERNAL 0x0008
106#define DEPFLAG_PARTITION 0x0010
107#define DEPFLAG_EXTENSION 0x0020
108#define DEPFLAG_REVERSE 0x0040
109#define DEPFLAG_IS_PART 0x0080
110#define DEPFLAG_SUBOBJECT 0x0100
111
112
113
115{
120};
121
122
123
124
126{
131
132
133typedef struct
134{
138
139
140typedef struct
141{
145
146
148 int objflags,
179
180
181
182
183
184
185static void
188{
189 int i;
190
191
192
193
195 {
196 for (i = 0; i < targetObjects->numrefs; i++)
197 {
200 bool original = false;
201 bool normal = false;
202
204 original = true;
206 normal = true;
208 normal = true;
209
211 {
213 }
214 }
215 }
216
217
218
219
220
221 for (i = 0; i < targetObjects->numrefs; i++)
222 {
225
228 continue;
229
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
272
273void
276{
279
280
281
282
283
285
286
287
288
289
291
292
293
294
295
297
301 NULL,
302 targetObjects,
303 NULL,
304 &depRel);
305
306
307
308
310 behavior,
312 object);
313
314
316
317
319
321}
322
323
324
325
326
327
328
329
330
331
332void
335{
338
340
342
344
345
346
347
348
350
354 NULL,
355 targetObjects,
356 NULL,
357 &depRel);
358
359
360
361
363 behavior,
365 object);
366
367
369
371}
372
373
374
375
376
377
378
379
380
381
382void
385{
388 int i;
389
390
391 if (objects->numrefs <= 0)
392 return;
393
394
395
396
397
399
400
401
402
403
404
405
406
407
409
410 for (i = 0; i < objects->numrefs; i++)
411 {
413
414
415
416
417
419
423 NULL,
424 targetObjects,
425 objects,
426 &depRel);
427 }
428
429
430
431
432
433
434
436 behavior,
438 (objects->numrefs == 1 ? objects->refs : NULL));
439
440
442
443
445
447}
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482static void
484 int objflags,
490{
492 int nkeys;
499 int numDependentObjects;
500 int maxDependentObjects;
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
521 return;
522
523
524
525
526
528
529
530
531
532
533
534
535
536
537
539 return;
540
541
542
543
544
547 (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),
548 errmsg("cannot drop %s because it is required by the database system",
550
551
552
553
554
555
556
557
558
559
560
562 Anum_pg_depend_classid,
566 Anum_pg_depend_objid,
570 {
571
573 Anum_pg_depend_objsubid,
576 nkeys = 3;
577 }
578 else
579 {
580
581 nkeys = 2;
582 }
583
585 NULL, nkeys, key);
586
587
588 memset(&owningObject, 0, sizeof(owningObject));
589 memset(&partitionObject, 0, sizeof(partitionObject));
590
592 {
594
595 otherObject.classId = foundDep->refclassid;
596 otherObject.objectId = foundDep->refobjid;
597 otherObject.objectSubId = foundDep->refobjsubid;
598
599
600
601
602
603
604
605
609 continue;
610
611 switch (foundDep->deptype)
612 {
616
617 break;
618
620
621
622
623
624
625
626
628 break;
629
630
631
632
633
634
635
636
637
639 otherObject.classId == ExtensionRelationId &&
641 break;
642
643
644
645
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665 if (stack == NULL)
666 {
667 if (pendingObjects &&
669 {
671
673 return;
674 }
675
676
677
678
679
680
681
682
683
684
685
688 owningObject = otherObject;
689 break;
690 }
691
692
693
694
695
696
697
698
699
701 break;
702
703
704
705
706
707
708
709
710
711
712
715
716
717
718
719
720
721
723 {
726 return;
727 }
728
729
730
731
732
733
735
736
737
738
739
740
741
742
743
744
745
746
750 stack,
751 targetObjects,
752 pendingObjects,
753 depRel);
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
772 targetObjects))
773 elog(ERROR, "deletion of owning object %s failed to delete %s",
776
777
778 return;
779
781
782
783
784
785
786
788
789
790
791
792
793
794 partitionObject = otherObject;
795 break;
796
798
799
800
801
802
804 partitionObject = otherObject;
805
806
807
808
809
810
812 break;
813
814 default:
815 elog(ERROR, "unrecognized dependency type '%c' for %s",
817 break;
818 }
819 }
820
822
823
824
825
826
827
828
830 {
831 char *otherObjDesc;
832
835 else
837
839 (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),
840 errmsg("cannot drop %s because %s requires it",
842 errhint("You can drop %s instead.", otherObjDesc)));
843 }
844
845
846
847
848
849
850
851
852
853 maxDependentObjects = 128;
855 numDependentObjects = 0;
856
858 Anum_pg_depend_refclassid,
862 Anum_pg_depend_refobjid,
866 {
868 Anum_pg_depend_refobjsubid,
871 nkeys = 3;
872 }
873 else
874 nkeys = 2;
875
877 NULL, nkeys, key);
878
880 {
882 int subflags;
883
884 otherObject.classId = foundDep->classid;
885 otherObject.objectId = foundDep->objid;
886 otherObject.objectSubId = foundDep->objsubid;
887
888
889
890
891
892
896 continue;
897
898
899
900
902
903
904
905
906
907
908
909
911 {
912
914
915 continue;
916 }
917
918
919
920
921
922 switch (foundDep->deptype)
923 {
926 break;
930 break;
933 break;
937 break;
940 break;
941 default:
942 elog(ERROR, "unrecognized dependency type '%c' for %s",
944 subflags = 0;
945 break;
946 }
947
948
949 if (numDependentObjects >= maxDependentObjects)
950 {
951
952 maxDependentObjects *= 2;
956 }
957
958 dependentObjects[numDependentObjects].obj = otherObject;
959 dependentObjects[numDependentObjects].subflags = subflags;
960 numDependentObjects++;
961 }
962
964
965
966
967
968
969
970 if (numDependentObjects > 1)
971 qsort(dependentObjects, numDependentObjects,
974
975
976
977
978
980 mystack.flags = objflags;
981 mystack.next = stack;
982
983 for (int i = 0; i < numDependentObjects; i++)
984 {
986
990 &mystack,
991 targetObjects,
992 pendingObjects,
993 depRel);
994 }
995
996 pfree(dependentObjects);
997
998
999
1000
1001
1002
1003
1004
1005
1008 extra.dependee = partitionObject;
1009 else if (stack)
1011 else
1014}
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029static void
1034{
1036 bool ok = true;
1039 int numReportedClient = 0;
1040 int numNotReportedClient = 0;
1041 int i;
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053 for (i = 0; i < targetObjects->numrefs; i++)
1054 {
1056
1059 {
1062 false);
1063
1065 (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),
1066 errmsg("cannot drop %s because %s requires it",
1068 errhint("You can drop %s instead.", otherObjDesc)));
1069 }
1070 }
1071
1072
1073
1074
1075
1076
1079 return;
1080
1081
1082
1083
1084
1085
1086#define MAX_REPORTED_DEPS 100
1087
1090
1091
1092
1093
1094
1095 for (i = targetObjects->numrefs - 1; i >= 0; i--)
1096 {
1099 char *objDesc;
1100
1101
1103 continue;
1104
1105
1107 continue;
1108
1110
1111
1112 if (objDesc == NULL)
1113 continue;
1114
1115
1116
1117
1118
1119
1124 {
1125
1126
1127
1128
1129
1130
1133 objDesc)));
1134 }
1136 {
1138 false);
1139
1140 if (otherDesc)
1141 {
1143 {
1144
1145 if (clientdetail.len != 0)
1148 objDesc, otherDesc);
1149 numReportedClient++;
1150 }
1151 else
1152 numNotReportedClient++;
1153
1154 if (logdetail.len != 0)
1157 objDesc, otherDesc);
1158 pfree(otherDesc);
1159 }
1160 else
1161 numNotReportedClient++;
1162 ok = false;
1163 }
1164 else
1165 {
1167 {
1168
1169 if (clientdetail.len != 0)
1172 objDesc);
1173 numReportedClient++;
1174 }
1175 else
1176 numNotReportedClient++;
1177
1178 if (logdetail.len != 0)
1181 objDesc);
1182 }
1183
1185 }
1186
1187 if (numNotReportedClient > 0)
1189 "(see server log for list)",
1190 "\nand %d other objects "
1191 "(see server log for list)",
1192 numNotReportedClient),
1193 numNotReportedClient);
1194
1195 if (!ok)
1196 {
1197 if (origObject)
1199 (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),
1200 errmsg("cannot drop %s because other objects depend on it",
1204 errhint("Use DROP ... CASCADE to drop the dependent objects too.")));
1205 else
1207 (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),
1208 errmsg("cannot drop desired object(s) because other objects depend on them"),
1211 errhint("Use DROP ... CASCADE to drop the dependent objects too.")));
1212 }
1213 else if (numReportedClient > 1)
1214 {
1216 (errmsg_plural("drop cascades to %d other object",
1217 "drop cascades to %d other objects",
1218 numReportedClient + numNotReportedClient,
1219 numReportedClient + numNotReportedClient),
1222 }
1223 else if (numReportedClient == 1)
1224 {
1225
1228 }
1229
1232}
1233
1234
1235
1236
1237
1238static void
1240{
1241 int cacheId;
1244
1246
1248
1249
1250
1251
1252 if (cacheId >= 0)
1253 {
1256 elog(ERROR, "cache lookup failed for %s %u",
1258
1260
1262 }
1263 else
1264 {
1267
1272
1274 NULL, 1, skey);
1275
1276
1279 elog(ERROR, "could not find tuple for %s %u",
1281
1283
1285 }
1286
1288}
1289
1290
1291
1292
1293
1294
1295static void
1297{
1299 int nkeys;
1302
1303
1306
1307
1308
1309
1310
1311
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1325
1326
1327
1328
1331
1332
1333
1334
1335
1336
1337
1338
1340 Anum_pg_depend_classid,
1344 Anum_pg_depend_objid,
1348 {
1350 Anum_pg_depend_objsubid,
1353 nkeys = 3;
1354 }
1355 else
1356 nkeys = 2;
1357
1359 NULL, nkeys, key);
1360
1362 {
1364 }
1365
1367
1368
1369
1370
1371
1374
1375
1376
1377
1378
1379
1380
1381
1382
1386
1387
1388
1389
1390
1392
1393
1394
1395
1396}
1397
1398
1399
1400
1401static void
1403{
1405 {
1406 case RelationRelationId:
1407 {
1409
1410 if (relKind == RELKIND_INDEX ||
1411 relKind == RELKIND_PARTITIONED_INDEX)
1412 {
1415
1418 }
1419 else
1420 {
1424 else
1426 }
1427
1428
1429
1430
1431
1432 if (relKind == RELKIND_SEQUENCE)
1434 break;
1435 }
1436
1437 case ProcedureRelationId:
1439 break;
1440
1441 case TypeRelationId:
1443 break;
1444
1445 case ConstraintRelationId:
1447 break;
1448
1449 case AttrDefaultRelationId:
1451 break;
1452
1453 case LargeObjectRelationId:
1455 break;
1456
1457 case OperatorRelationId:
1459 break;
1460
1461 case RewriteRelationId:
1463 break;
1464
1465 case TriggerRelationId:
1467 break;
1468
1469 case StatisticExtRelationId:
1471 break;
1472
1473 case TSConfigRelationId:
1475 break;
1476
1477 case ExtensionRelationId:
1479 break;
1480
1481 case PolicyRelationId:
1483 break;
1484
1485 case PublicationNamespaceRelationId:
1487 break;
1488
1489 case PublicationRelRelationId:
1491 break;
1492
1493 case PublicationRelationId:
1495 break;
1496
1497 case CastRelationId:
1498 case CollationRelationId:
1499 case ConversionRelationId:
1500 case LanguageRelationId:
1501 case OperatorClassRelationId:
1502 case OperatorFamilyRelationId:
1503 case AccessMethodRelationId:
1504 case AccessMethodOperatorRelationId:
1505 case AccessMethodProcedureRelationId:
1506 case NamespaceRelationId:
1507 case TSParserRelationId:
1508 case TSDictionaryRelationId:
1509 case TSTemplateRelationId:
1510 case ForeignDataWrapperRelationId:
1511 case ForeignServerRelationId:
1512 case UserMappingRelationId:
1513 case DefaultAclRelationId:
1514 case EventTriggerRelationId:
1515 case TransformRelationId:
1516 case AuthMemRelationId:
1518 break;
1519
1520
1521
1522
1523 case AuthIdRelationId:
1524 case DatabaseRelationId:
1525 case TableSpaceRelationId:
1526 case SubscriptionRelationId:
1527 case ParameterAclRelationId:
1528 elog(ERROR, "global objects cannot be deleted by doDeletion");
1529 break;
1530
1531 default:
1533 }
1534}
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545void
1547{
1549 {
1550
1551
1552
1553
1554
1555
1558 else
1560 }
1564 else
1565 {
1566
1569 }
1570}
1571
1572
1573
1574
1575
1576
1577void
1579{
1582 else
1583
1586}
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602void
1606{
1608
1610
1611
1613
1614
1616
1617
1620 behavior);
1621
1623}
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645void
1648{
1650
1651 context.addrs = addrs;
1652
1653
1655
1656
1658}
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677void
1682 bool reverse_self)
1683{
1686
1688
1689
1690 rte.type = T_RangeTblEntry;
1692 rte.relid = relId;
1693 rte.relkind = RELKIND_RELATION;
1695
1697
1698
1700
1701
1703
1704
1705 if ((behavior != self_behavior || reverse_self) &&
1707 {
1710 int oldref,
1711 outrefs;
1712
1714
1716 outrefs = 0;
1717 for (oldref = 0; oldref < context.addrs->numrefs; oldref++)
1718 {
1720
1721 if (thisobj->classId == RelationRelationId &&
1723 {
1724
1726 }
1727 else
1728 {
1729
1730 *outobj = *thisobj;
1731 outobj++;
1732 outrefs++;
1733 }
1734 }
1736
1737
1738 if (!reverse_self)
1741 self_behavior);
1742 else
1743 {
1744
1745 int selfref;
1746
1747 for (selfref = 0; selfref < self_addrs->numrefs; selfref++)
1748 {
1750
1752 }
1753 }
1754
1756 }
1757
1758
1761 behavior);
1762
1764}
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779static bool
1782{
1783 if (node == NULL)
1784 return false;
1786 {
1788 List *rtable;
1790
1791
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1811 return false;
1813 {
1814
1816 context->addrs);
1817 }
1819 {
1820
1821
1823 }
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833 return false;
1834 }
1836 {
1838 Oid objoid;
1839
1840
1842 context->addrs);
1843
1844
1845
1846
1847
1848
1849
1851 con->constcollid != DEFAULT_COLLATION_OID)
1853 context->addrs);
1854
1855
1856
1857
1858
1859
1860
1861 if (!con->constisnull)
1862 {
1864 {
1865 case REGPROCOID:
1866 case REGPROCEDUREOID:
1871 context->addrs);
1872 break;
1873 case REGOPEROID:
1874 case REGOPERATOROID:
1879 context->addrs);
1880 break;
1881 case REGCLASSOID:
1886 context->addrs);
1887 break;
1888 case REGTYPEOID:
1893 context->addrs);
1894 break;
1895 case REGCOLLATIONOID:
1900 context->addrs);
1901 break;
1902 case REGCONFIGOID:
1907 context->addrs);
1908 break;
1909 case REGDICTIONARYOID:
1914 context->addrs);
1915 break;
1916
1917 case REGNAMESPACEOID:
1922 context->addrs);
1923 break;
1924
1925
1926
1927
1928
1929 case REGROLEOID:
1931 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1932 errmsg("constant of the type %s cannot be used here",
1933 "regrole")));
1934 break;
1935
1936
1937
1938
1939
1940 case REGDATABASEOID:
1942 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1943 errmsg("constant of the type %s cannot be used here",
1944 "regdatabase")));
1945 break;
1946 }
1947 }
1948 return false;
1949 }
1951 {
1953
1954
1956 context->addrs);
1957
1959 param->paramcollid != DEFAULT_COLLATION_OID)
1961 context->addrs);
1962 }
1964 {
1966
1968 context->addrs);
1969
1970 }
1972 {
1974
1976 context->addrs);
1977
1978 }
1980 {
1982
1984 context->addrs);
1985
1986 }
1988 {
1990
1992 context->addrs);
1993
1994 }
1996 {
1998
2000 context->addrs);
2001
2002 }
2004 {
2006
2008 context->addrs);
2009
2010 }
2012 {
2014
2016 context->addrs);
2017
2018 }
2020 {
2022
2023
2024
2025
2026
2027
2028
2029 if (sbsref->refrestype != sbsref->refcontainertype &&
2030 sbsref->refrestype != sbsref->refelemtype)
2032 context->addrs);
2033
2034 }
2036 {
2037
2038 elog(ERROR, "already-planned subqueries not supported");
2039 }
2041 {
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2057 context->addrs);
2058 else
2060 context->addrs);
2061
2062 if (OidIsValid(fselect->resultcollid) &&
2063 fselect->resultcollid != DEFAULT_COLLATION_OID)
2065 context->addrs);
2066 }
2068 {
2071
2072
2074 {
2076
2077 foreach(l, fstore->fieldnums)
2079 context->addrs);
2080 }
2081 else
2083 context->addrs);
2084 }
2086 {
2088
2089
2091 context->addrs);
2092
2093 if (OidIsValid(relab->resultcollid) &&
2094 relab->resultcollid != DEFAULT_COLLATION_OID)
2096 context->addrs);
2097 }
2099 {
2101
2102
2104 context->addrs);
2105
2106 if (OidIsValid(iocoerce->resultcollid) &&
2107 iocoerce->resultcollid != DEFAULT_COLLATION_OID)
2109 context->addrs);
2110 }
2112 {
2114
2115
2117 context->addrs);
2118
2119 if (OidIsValid(acoerce->resultcollid) &&
2120 acoerce->resultcollid != DEFAULT_COLLATION_OID)
2122 context->addrs);
2123
2124 }
2126 {
2128
2129
2131 context->addrs);
2132 }
2134 {
2136
2138 context->addrs);
2139 }
2141 {
2143
2145 context->addrs);
2146 }
2148 {
2151
2152 foreach(l, rcexpr->opnos)
2153 {
2155 context->addrs);
2156 }
2157 foreach(l, rcexpr->opfamilies)
2158 {
2160 context->addrs);
2161 }
2162
2163 }
2165 {
2167
2169 context->addrs);
2170 }
2172 {
2174
2176 context->addrs);
2177 }
2179 {
2181
2184 context->addrs);
2185
2186 }
2188 {
2190
2192 context->addrs);
2195 context->addrs);
2196 return false;
2197 }
2199 {
2201
2202 if (OidIsValid(wc->startInRangeFunc))
2204 context->addrs);
2207 context->addrs);
2209 wc->inRangeColl != DEFAULT_COLLATION_OID)
2211 context->addrs);
2212
2213 }
2215 {
2217
2220 context->addrs);
2223 context->addrs);
2226 context->addrs);
2227
2228 }
2230 {
2231
2234 bool result;
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252 foreach(lc, query->rtable)
2253 {
2255
2257 {
2260 context->addrs);
2261 break;
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2278 for (int i = 0; i < rte->joinmergedcols; i++)
2279 {
2280 Node *aliasvar = list_nth(rte->joinaliasvars, i);
2281
2282 if ((aliasvar, Var))
2284 }
2286 break;
2288
2289
2290
2291
2292
2293
2294
2295
2297 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2298 errmsg("transition table \"%s\" cannot be referenced in a persistent object",
2299 rte->eref->aliasname)));
2300 break;
2301 default:
2302
2303 break;
2304 }
2305 }
2306
2307
2308
2309
2310
2311
2312
2313
2316 {
2318
2319 if (query->resultRelation <= 0 ||
2321 elog(ERROR, "invalid resultRelation %d",
2322 query->resultRelation);
2323 rte = rt_fetch(query->resultRelation, query->rtable);
2325 {
2327 {
2329
2330 if (tle->resjunk)
2331 continue;
2333 context->addrs);
2334 }
2335 }
2336 }
2337
2338
2339
2340
2341 foreach(lc, query->constraintDeps)
2342 {
2344 context->addrs);
2345 }
2346
2347
2351 context,
2355 return result;
2356 }
2358 {
2360
2361
2363
2364 }
2366 {
2369
2370
2371
2372
2373
2374
2375 foreach(ct, rtfunc->funccoltypes)
2376 {
2378 context->addrs);
2379 }
2380 foreach(ct, rtfunc->funccolcollations)
2381 {
2383
2386 context->addrs);
2387 }
2388 }
2390 {
2393
2394
2395
2396
2397 foreach(ct, tf->coltypes)
2398 {
2400 context->addrs);
2401 }
2402 foreach(ct, tf->colcollations)
2403 {
2405
2408 context->addrs);
2409 }
2410 }
2412 {
2414
2416 context->addrs);
2417
2418 }
2419
2421 context);
2422}
2423
2424
2425
2426
2427
2428static void
2431{
2432 int atts_done = 0;
2434
2435
2436
2437
2438
2439
2440
2442 {
2444
2445 if (attnum > atts_done &&
2446 attnum <= atts_done + rtfunc->funccolcount)
2447 {
2449
2450
2451 if (rtfunc->funccolnames != NIL)
2452 tupdesc = NULL;
2453 else
2455 if (tupdesc && tupdesc->tdtypeid != RECORDOID)
2456 {
2457
2458
2459
2460
2462
2463 Assert(attnum - atts_done <= tupdesc->natts);
2464 if (OidIsValid(reltype))
2467 context->addrs);
2468 return;
2469 }
2470
2471 return;
2472 }
2473 atts_done += rtfunc->funccolcount;
2474 }
2475
2476
2478 return;
2479
2480
2482 (errcode(ERRCODE_UNDEFINED_COLUMN),
2483 errmsg("column %d of relation \"%s\" does not exist",
2484 attnum, rte->eref->aliasname)));
2485}
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502bool
2505{
2506 for (int i = 0; i < addrs->numrefs; i++)
2507 {
2509 Oid objnamespace;
2510
2511
2512
2513
2514
2516
2517
2518
2519
2520
2523 {
2524 *foundobj = *thisobj;
2525 return true;
2526 }
2527 }
2528 return false;
2529}
2530
2531
2532
2533
2534
2535
2536
2537bool
2539{
2540 bool result;
2542
2544
2545
2547
2548
2550
2552
2553 return result;
2554}
2555
2556
2557
2558
2559static void
2561{
2563 int oldref,
2564 newrefs;
2565
2566
2567
2568
2569
2570
2572
2573 if (addrs->numrefs <= 1)
2574 return;
2575
2576
2579
2580
2581 priorobj = addrs->refs;
2582 newrefs = 1;
2583 for (oldref = 1; oldref < addrs->numrefs; oldref++)
2584 {
2586
2589 {
2591 continue;
2592
2593
2594
2595
2596
2597
2598
2599
2601 {
2602
2604 continue;
2605 }
2606 }
2607
2608 priorobj++;
2609 *priorobj = *thisobj;
2610 newrefs++;
2611 }
2612
2613 addrs->numrefs = newrefs;
2614}
2615
2616
2617
2618
2619static int
2621{
2624
2625
2626
2627
2628
2629
2631 return -1;
2633 return 1;
2634
2635
2636
2637
2638
2640 return -1;
2642 return 1;
2643
2644
2645
2646
2647
2648
2649
2650
2652 return -1;
2654 return 1;
2655 return 0;
2656}
2657
2658
2659
2660
2661
2662
2665{
2667
2669
2673 addrs->extras = NULL;
2674
2675 return addrs;
2676}
2677
2678
2679
2680
2681static void
2684{
2686
2687
2689 {
2694 }
2695
2697 item->classId = classId;
2701}
2702
2703
2704
2705
2706
2707
2708void
2711{
2713
2714
2716 {
2721 }
2722
2726}
2727
2728
2729
2730
2731
2732
2733static void
2737{
2740
2741
2745
2746
2748 {
2754 }
2755
2759 *itemextra = *extra;
2761}
2762
2763
2764
2765
2766
2767
2768bool
2771{
2772 int i;
2773
2774 for (i = addrs->numrefs - 1; i >= 0; i--)
2775 {
2777
2780 {
2783 return true;
2784 }
2785 }
2786
2787 return false;
2788}
2789
2790
2791
2792
2793
2794static bool
2798{
2799 bool result = false;
2800 int i;
2801
2802 for (i = addrs->numrefs - 1; i >= 0; i--)
2803 {
2805
2808 {
2810 {
2812
2814 result = true;
2815 }
2817 {
2818
2819
2820
2821
2822
2823
2824
2825 result = true;
2826 }
2828 {
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2854
2857 }
2858 }
2859 }
2860
2861 return result;
2862}
2863
2864
2865
2866
2867static bool
2871{
2872 bool result = false;
2874
2875 for (stackptr = stack; stackptr; stackptr = stackptr->next)
2876 {
2878
2881 {
2883 {
2885 result = true;
2886 }
2888 {
2889
2890
2891
2892
2893
2894
2895 result = true;
2896 }
2898 {
2899
2900
2901
2902
2903
2906 }
2907 }
2908 }
2909
2910 return result;
2911}
2912
2913
2914
2915
2916
2917void
2921{
2925 behavior);
2926}
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936void
2938{
2943}
2944
2945
2946
2947
2948void
2950{
2955}
2956
2957
2958
2959
2960static void
2962{
2965 int nkeys;
2968
2970
2972 Anum_pg_init_privs_objoid,
2976 Anum_pg_init_privs_classoid,
2980 {
2982 Anum_pg_init_privs_objsubid,
2985 nkeys = 3;
2986 }
2987 else
2988 nkeys = 2;
2989
2991 NULL, nkeys, key);
2992
2995
2997
2999}
#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)
void performDeletionCheck(const ObjectAddress *object, DropBehavior behavior, int flags)
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)
bool query_uses_temp_object(Query *query, ObjectAddress *temp_object)
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)
void collectDependenciesOfExpr(ObjectAddresses *addrs, Node *expr, List *rtable)
bool object_address_present(const ObjectAddress *object, const ObjectAddresses *addrs)
bool find_temp_object(const ObjectAddresses *addrs, bool local_temp_okay, ObjectAddress *foundobj)
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)
#define palloc_object(type)
#define palloc_array(type, count)
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, const ItemPointerData *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)
bool isTempNamespace(Oid namespaceId)
bool isAnyTempNamespace(Oid namespaceId)
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)
Oid get_object_namespace(const ObjectAddress *address)
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)