forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd8c05af
committed
Fix pg_dump's handling of circular dependencies in views.
pg_dump's traditional solution for breaking a circular dependency involvinga view was to create the view with CREATE TABLE and then later issue CREATERULE "_RETURN" ... to convert the table to a view, relying on the backend'svery very ancient code that supports making views that way. We've wantedto get rid of that kluge for a long time, but the thing that finallymotivates doing something about it is the recognition that this methodfails with the --clean option, because it leads to issuing DROP RULE"_RETURN" followed by DROP TABLE --- and the backend won't let you drop aview's _RETURN rule.Instead, let's break circular dependencies by initially creating the viewusing CREATE VIEW AS SELECT NULL::columntype AS columnname, ... (so thatit has the right column names and types to support external references,but no dependencies beyond the column data types), and then later dumpingthe ON SELECT rule using the spelling CREATE OR REPLACE VIEW. This methodwasn't available when this code was originally written, but it's beenpossible since PG 7.3, so it seems fine to start relying on it now.To solve the --clean problem, make the dropStmt for an ON SELECT rulebe CREATE OR REPLACE VIEW with the same dummy target list as above.In this way, during the DROP phase, we first reduce the view to haveno extra dependencies, and then we can drop it entirely when we'vegotten rid of whatever had a circular dependency on it.(Note: this should work adequately well with the --if-exists option, sincethe CREATE OR REPLACE VIEW will go through whether the view exists or not.It could fail if the view exists with a conflicting column set, but wedon't really support --clean against a non-matching database anyway.)This allows cleaning up some other kluges inside pg_dump, notably thatwe don't need a notion of reloptions attached to a rule anymore.Although this is a bug fix, commit to HEAD only for now. The problem'sexisted for a long time and we've had relatively few complaints, so itdoesn't really seem worth taking risks to fix it in the back branches.We might revisit that choice if no problems emerge.Discussion: <19092.1479325184@sss.pgh.pa.us>1 parentac88898 commitd8c05af
3 files changed
+140
-59
lines changedLines changed: 136 additions & 45 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5486 | 5486 |
| |
5487 | 5487 |
| |
5488 | 5488 |
| |
5489 |
| - | |
| 5489 | + | |
5490 | 5490 |
| |
5491 | 5491 |
| |
5492 | 5492 |
| |
| |||
6207 | 6207 |
| |
6208 | 6208 |
| |
6209 | 6209 |
| |
6210 |
| - | |
6211 |
| - | |
6212 |
| - | |
6213 |
| - | |
6214 |
| - | |
6215 |
| - | |
6216 |
| - | |
6217 |
| - | |
6218 |
| - | |
6219 |
| - | |
6220 | 6210 |
| |
6221 | 6211 |
| |
6222 | 6212 |
| |
| |||
13977 | 13967 |
| |
13978 | 13968 |
| |
13979 | 13969 |
| |
| 13970 | + | |
| 13971 | + | |
| 13972 | + | |
| 13973 | + | |
| 13974 | + | |
| 13975 | + | |
| 13976 | + | |
| 13977 | + | |
| 13978 | + | |
| 13979 | + | |
| 13980 | + | |
| 13981 | + | |
| 13982 | + | |
| 13983 | + | |
| 13984 | + | |
| 13985 | + | |
| 13986 | + | |
| 13987 | + | |
| 13988 | + | |
| 13989 | + | |
| 13990 | + | |
| 13991 | + | |
| 13992 | + | |
| 13993 | + | |
| 13994 | + | |
| 13995 | + | |
| 13996 | + | |
| 13997 | + | |
| 13998 | + | |
| 13999 | + | |
| 14000 | + | |
| 14001 | + | |
| 14002 | + | |
| 14003 | + | |
| 14004 | + | |
| 14005 | + | |
| 14006 | + | |
| 14007 | + | |
| 14008 | + | |
| 14009 | + | |
| 14010 | + | |
| 14011 | + | |
| 14012 | + | |
| 14013 | + | |
| 14014 | + | |
| 14015 | + | |
| 14016 | + | |
| 14017 | + | |
13980 | 14018 |
| |
13981 | 14019 |
| |
13982 | 14020 |
| |
| |||
14010 | 14048 |
| |
14011 | 14049 |
| |
14012 | 14050 |
| |
| 14051 | + | |
| 14052 | + | |
| 14053 | + | |
| 14054 | + | |
14013 | 14055 |
| |
14014 | 14056 |
| |
14015 | 14057 |
| |
| |||
14026 | 14068 |
| |
14027 | 14069 |
| |
14028 | 14070 |
| |
14029 |
| - | |
| 14071 | + | |
| 14072 | + | |
| 14073 | + | |
14030 | 14074 |
| |
14031 |
| - | |
14032 |
| - | |
14033 |
| - | |
| 14075 | + | |
| 14076 | + | |
| 14077 | + | |
| 14078 | + | |
| 14079 | + | |
| 14080 | + | |
| 14081 | + | |
14034 | 14082 |
| |
14035 |
| - | |
14036 | 14083 |
| |
14037 | 14084 |
| |
14038 | 14085 |
| |
14039 |
| - | |
| 14086 | + | |
14040 | 14087 |
| |
14041 | 14088 |
| |
14042 | 14089 |
| |
| |||
15648 | 15695 |
| |
15649 | 15696 |
| |
15650 | 15697 |
| |
| 15698 | + | |
15651 | 15699 |
| |
15652 | 15700 |
| |
15653 | 15701 |
| |
| |||
15666 | 15714 |
| |
15667 | 15715 |
| |
15668 | 15716 |
| |
| 15717 | + | |
| 15718 | + | |
| 15719 | + | |
| 15720 | + | |
| 15721 | + | |
| 15722 | + | |
15669 | 15723 |
| |
15670 | 15724 |
| |
15671 | 15725 |
| |
| |||
15676 | 15730 |
| |
15677 | 15731 |
| |
15678 | 15732 |
| |
15679 |
| - | |
15680 |
| - | |
15681 |
| - | |
15682 |
| - | |
15683 |
| - | |
15684 |
| - | |
15685 |
| - | |
| 15733 | + | |
15686 | 15734 |
| |
15687 |
| - | |
15688 |
| - | |
15689 |
| - | |
| 15735 | + | |
| 15736 | + | |
| 15737 | + | |
| 15738 | + | |
| 15739 | + | |
| 15740 | + | |
| 15741 | + | |
| 15742 | + | |
| 15743 | + | |
| 15744 | + | |
| 15745 | + | |
| 15746 | + | |
| 15747 | + | |
| 15748 | + | |
| 15749 | + | |
| 15750 | + | |
| 15751 | + | |
| 15752 | + | |
| 15753 | + | |
| 15754 | + | |
| 15755 | + | |
15690 | 15756 |
| |
| 15757 | + | |
| 15758 | + | |
| 15759 | + | |
| 15760 | + | |
| 15761 | + | |
| 15762 | + | |
| 15763 | + | |
| 15764 | + | |
| 15765 | + | |
| 15766 | + | |
| 15767 | + | |
| 15768 | + | |
| 15769 | + | |
| 15770 | + | |
| 15771 | + | |
15691 | 15772 |
| |
15692 |
| - | |
| 15773 | + | |
| 15774 | + | |
| 15775 | + | |
| 15776 | + | |
15693 | 15777 |
| |
15694 | 15778 |
| |
15695 | 15779 |
| |
| |||
15716 | 15800 |
| |
15717 | 15801 |
| |
15718 | 15802 |
| |
15719 |
| - | |
| 15803 | + | |
15720 | 15804 |
| |
15721 |
| - | |
| 15805 | + | |
15722 | 15806 |
| |
15723 |
| - | |
| 15807 | + | |
| 15808 | + | |
| 15809 | + | |
| 15810 | + | |
| 15811 | + | |
| 15812 | + | |
| 15813 | + | |
| 15814 | + | |
| 15815 | + | |
| 15816 | + | |
| 15817 | + | |
| 15818 | + | |
| 15819 | + | |
| 15820 | + | |
| 15821 | + | |
| 15822 | + | |
| 15823 | + | |
| 15824 | + | |
| 15825 | + | |
| 15826 | + | |
| 15827 | + | |
| 15828 | + | |
15724 | 15829 |
| |
15725 |
| - | |
15726 |
| - | |
15727 | 15830 |
| |
15728 |
| - | |
15729 |
| - | |
15730 |
| - | |
15731 |
| - | |
15732 |
| - | |
15733 |
| - | |
15734 |
| - | |
15735 |
| - | |
15736 |
| - | |
15737 |
| - | |
15738 | 15831 |
| |
15739 | 15832 |
| |
15740 | 15833 |
| |
| |||
15761 | 15854 |
| |
15762 | 15855 |
| |
15763 | 15856 |
| |
15764 |
| - | |
15765 |
| - | |
15766 | 15857 |
| |
15767 | 15858 |
| |
15768 | 15859 |
| |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
287 | 287 |
| |
288 | 288 |
| |
289 | 289 |
| |
| 290 | + | |
290 | 291 |
| |
291 | 292 |
| |
292 | 293 |
| |
| |||
364 | 365 |
| |
365 | 366 |
| |
366 | 367 |
| |
367 |
| - | |
368 |
| - | |
369 | 368 |
| |
370 | 369 |
| |
371 | 370 |
| |
|
Lines changed: 3 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
786 | 786 |
| |
787 | 787 |
| |
788 | 788 |
| |
| 789 | + | |
789 | 790 |
| |
790 | 791 |
| |
791 | 792 |
| |
| |||
805 | 806 |
| |
806 | 807 |
| |
807 | 808 |
| |
808 |
| - | |
809 | 809 |
| |
810 | 810 |
| |
811 | 811 |
| |
812 |
| - | |
813 |
| - | |
| 812 | + | |
| 813 | + | |
814 | 814 |
| |
815 | 815 |
| |
816 |
| - | |
817 |
| - | |
818 |
| - | |
819 |
| - | |
820 |
| - | |
821 |
| - | |
822 | 816 |
| |
823 | 817 |
| |
824 | 818 |
| |
825 | 819 |
| |
826 |
| - | |
827 |
| - | |
828 |
| - | |
829 | 820 |
| |
830 | 821 |
| |
831 | 822 |
| |
|
0 commit comments
Comments
(0)