forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit62f3409
committed
Build in some knowledge about foreign-key relationships in the catalogs.
This follows in the spirit of commitdfb75e4, which created primarykey and uniqueness constraints to improve the visibility of constraintsimposed on the system catalogs. While our catalogs contain manyforeign-key-like relationships, they don't quite follow SQL semantics,in that the convention for an omitted reference is to write zero notNULL. Plus, we have some cases in which there are arrays each of whoseelements is supposed to be an FK reference; SQL has no way to model that.So we can't create actual foreign key constraints to describe thesituation. Nonetheless, we can collect and use knowledge about theserelationships.This patch therefore adds annotations to the catalog header files todeclare foreign-key relationships. (The BKI_LOOKUP annotations coversimple cases, but we weren't previously distinguishing which suchcolumns are allowed to contain zeroes; we also need new markings formulti-column FK references.) Then, Catalog.pm and genbki.pl aretaught to collect this information into a table in a new generatedheader "system_fk_info.h". The only user of that at the moment isa new SQL function pg_get_catalog_foreign_keys(), which exposes thetable to SQL. The oidjoins regression test is rewritten to usepg_get_catalog_foreign_keys() to find out which columns to check.Aside from removing the need for manual maintenance of that testscript, this allows it to cover numerous relationships that were notchecked by the old implementation based on findoidjoins. (As of thiscommit, 217 relationships are checked by the test, versus 181 before.)Discussion:https://postgr.es/m/3240355.1612129197@sss.pgh.pa.us1 parent4793314 commit62f3409
File tree
78 files changed
+901
-2402
lines changed- doc/src/sgml
- src
- backend
- catalog
- utils/adt
- include
- catalog
- test/regress
- expected
- sql
- tools/msvc
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
78 files changed
+901
-2402
lines changedLines changed: 23 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
474 | 474 |
| |
475 | 475 |
| |
476 | 476 |
| |
477 |
| - | |
478 |
| - | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
479 | 482 |
| |
480 | 483 |
| |
| 484 | + | |
| 485 | + | |
481 | 486 |
| |
482 | 487 |
| |
483 | 488 |
| |
| |||
554 | 559 |
| |
555 | 560 |
| |
556 | 561 |
| |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
557 | 578 |
| |
558 | 579 |
| |
559 | 580 |
| |
|
Lines changed: 32 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
22789 | 22789 |
| |
22790 | 22790 |
| |
22791 | 22791 |
| |
| 22792 | + | |
| 22793 | + | |
| 22794 | + | |
| 22795 | + | |
| 22796 | + | |
| 22797 | + | |
| 22798 | + | |
| 22799 | + | |
| 22800 | + | |
| 22801 | + | |
| 22802 | + | |
| 22803 | + | |
| 22804 | + | |
| 22805 | + | |
| 22806 | + | |
| 22807 | + | |
| 22808 | + | |
| 22809 | + | |
| 22810 | + | |
| 22811 | + | |
| 22812 | + | |
| 22813 | + | |
| 22814 | + | |
| 22815 | + | |
| 22816 | + | |
| 22817 | + | |
| 22818 | + | |
| 22819 | + | |
| 22820 | + | |
| 22821 | + | |
| 22822 | + | |
| 22823 | + | |
22792 | 22824 |
| |
22793 | 22825 |
| |
22794 | 22826 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 | 2 |
| |
| 3 | + | |
3 | 4 |
| |
4 | 5 |
| |
5 | 6 |
|
Lines changed: 26 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
105 | 105 |
| |
106 | 106 |
| |
107 | 107 |
| |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
108 | 119 |
| |
109 | 120 |
| |
110 | 121 |
| |
| |||
197 | 208 |
| |
198 | 209 |
| |
199 | 210 |
| |
200 |
| - | |
| 211 | + | |
201 | 212 |
| |
202 |
| - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
203 | 227 |
| |
204 | 228 |
| |
205 | 229 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
70 | 70 |
| |
71 | 71 |
| |
72 | 72 |
| |
73 |
| - | |
| 73 | + | |
74 | 74 |
| |
75 | 75 |
| |
76 | 76 |
| |
|
Lines changed: 106 additions & 17 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
213 | 213 |
| |
214 | 214 |
| |
215 | 215 |
| |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
216 | 222 |
| |
217 | 223 |
| |
218 | 224 |
| |
| |||
234 | 240 |
| |
235 | 241 |
| |
236 | 242 |
| |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
237 | 249 |
| |
238 | 250 |
| |
239 | 251 |
| |
| |||
376 | 388 |
| |
377 | 389 |
| |
378 | 390 |
| |
| 391 | + | |
379 | 392 |
| |
380 | 393 |
| |
381 | 394 |
| |
| 395 | + | |
382 | 396 |
| |
383 | 397 |
| |
384 | 398 |
| |
| |||
400 | 414 |
| |
401 | 415 |
| |
402 | 416 |
| |
| 417 | + | |
| 418 | + | |
| 419 | + | |
403 | 420 |
| |
404 | 421 |
| |
405 | 422 |
| |
| |||
554 | 571 |
| |
555 | 572 |
| |
556 | 573 |
| |
557 |
| - | |
558 |
| - | |
559 |
| - | |
560 |
| - | |
561 |
| - | |
562 | 574 |
| |
563 | 575 |
| |
564 | 576 |
| |
565 | 577 |
| |
566 | 578 |
| |
567 | 579 |
| |
568 |
| - | |
| 580 | + | |
| 581 | + | |
569 | 582 |
| |
570 | 583 |
| |
571 | 584 |
| |
| |||
575 | 588 |
| |
576 | 589 |
| |
577 | 590 |
| |
578 |
| - | |
579 |
| - | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
580 | 594 |
| |
581 | 595 |
| |
582 | 596 |
| |
| |||
586 | 600 |
| |
587 | 601 |
| |
588 | 602 |
| |
589 |
| - | |
590 |
| - | |
| 603 | + | |
| 604 | + | |
591 | 605 |
| |
592 | 606 |
| |
593 | 607 |
| |
594 | 608 |
| |
595 | 609 |
| |
596 | 610 |
| |
597 | 611 |
| |
598 |
| - | |
599 |
| - | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
600 | 615 |
| |
601 | 616 |
| |
602 | 617 |
| |
| |||
706 | 721 |
| |
707 | 722 |
| |
708 | 723 |
| |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
709 | 786 |
| |
710 | 787 |
| |
711 | 788 |
| |
| 789 | + | |
712 | 790 |
| |
713 | 791 |
| |
714 | 792 |
| |
715 | 793 |
| |
716 | 794 |
| |
| 795 | + | |
717 | 796 |
| |
718 | 797 |
| |
719 | 798 |
| |
| |||
948 | 1027 |
| |
949 | 1028 |
| |
950 | 1029 |
| |
951 |
| - | |
| 1030 | + | |
| 1031 | + | |
952 | 1032 |
| |
953 | 1033 |
| |
954 | 1034 |
| |
| |||
961 | 1041 |
| |
962 | 1042 |
| |
963 | 1043 |
| |
964 |
| - | |
965 |
| - | |
966 |
| - | |
967 |
| - | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
968 | 1057 |
| |
969 | 1058 |
| |
970 | 1059 |
| |
|
0 commit comments
Comments
(0)