forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit1d92a0c
committed
Redesign the partition dependency mechanism.
The original setup for dependencies of partitioned objects hadserious problems:1. It did not verify that a drop cascading to a partition-child objectalso cascaded to at least one of the object's partition parents. Now,normally a child object would share all its dependencies with one oranother parent (e.g. a child index's opclass dependencies would be sharedwith the parent index), so that this oversight is usually harmless.But if some dependency failed to fit this pattern, the child could bedropped while all its parents remain, creating a logically brokensituation. (It's easy to construct artificial cases that break it,such as attaching an unrelated extension dependency to the child objectand then dropping the extension. I'm not sure if any less-artificialcases exist.)2. Management of partition dependencies during ATTACH/DETACH PARTITIONwas complicated and buggy; for example, after detaching a partitiontable it was possible to create cases where a formerly-child indexshould be dropped and was not, because the correct set of dependencieshad not been reconstructed.Less seriously, because multiple partition relationships wererepresented identically in pg_depend, there was an order-of-traversaldependency on which partition parent was cited in error messages.We also had some pre-existing order-of-traversal hazards for errormessages related to internal and extension dependencies. This iscosmetic to users but causes testing problems.Tofix#1, add a check at the end of the partition tree traversalto ensure that at least one partition parent got deleted. Tofix#2,establish a new policy that partition dependencies are in addition to,not instead of, a child object's usual dependencies; in this wayATTACH/DETACH PARTITION need not cope with adding or removing theusual dependencies.To fix the cosmetic problem, distinguish between primary and secondarypartition dependency entries in pg_depend, by giving them differentdeptypes. (They behave identically except for having differentpriorities for being cited in error messages.) This means that theformer 'I' dependency type is replaced with new 'P' and 'S' types.This also fixes a longstanding bug that after handling an internaldependency by recursing to the owning object, findDependentObjectsdid not verify that the current target was now scheduled for deletion,and did not apply the current recursion level's objflags to it.Perhaps that should be back-patched; but in the back branches itwould only matter if some concurrent transaction had removed theinternal-linkage pg_depend entry before the recursive call found it,or the recursive call somehow failed to find it, both of which seemunlikely.Catversion bump because the contents of pg_depend change forpartitioning relationships.Patch HEAD only. It's annoying that we're not fixing#2 in v11,but there seems no practical way to do so given that the problemis exactly a poor choice of what entries to put in pg_depend.We can't really fix that while staying compatible with what'sin pg_depend in existing v11 installations.Discussion:https://postgr.es/m/CAH2-Wzkypv1R+teZrr71U23J578NnTBt2X8+Y=Odr4pOdW1rXg@mail.gmail.com1 parentc603b39 commit1d92a0c
File tree
12 files changed
+361
-180
lines changed- doc/src/sgml
- src
- backend
- catalog
- commands
- include/catalog
- test/regress
- expected
- sql
12 files changed
+361
-180
lines changedLines changed: 70 additions & 30 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2970 | 2970 |
| |
2971 | 2971 |
| |
2972 | 2972 |
| |
2973 |
| - | |
| 2973 | + | |
2974 | 2974 |
| |
2975 | 2975 |
| |
2976 | 2976 |
| |
| |||
2982 | 2982 |
| |
2983 | 2983 |
| |
2984 | 2984 |
| |
2985 |
| - | |
2986 |
| - | |
2987 |
| - | |
2988 |
| - | |
2989 |
| - | |
2990 |
| - | |
2991 |
| - | |
2992 |
| - | |
2993 |
| - | |
| 2985 | + | |
| 2986 | + | |
| 2987 | + | |
| 2988 | + | |
| 2989 | + | |
| 2990 | + | |
| 2991 | + | |
| 2992 | + | |
| 2993 | + | |
| 2994 | + | |
| 2995 | + | |
| 2996 | + | |
| 2997 | + | |
| 2998 | + | |
| 2999 | + | |
2994 | 3000 |
| |
2995 | 3001 |
| |
2996 | 3002 |
| |
2997 | 3003 |
| |
2998 | 3004 |
| |
2999 |
| - | |
| 3005 | + | |
| 3006 | + | |
3000 | 3007 |
| |
3001 | 3008 |
| |
3002 | 3009 |
| |
3003 | 3010 |
| |
3004 |
| - | |
3005 |
| - | |
3006 |
| - | |
3007 |
| - | |
3008 |
| - | |
3009 |
| - | |
3010 |
| - | |
| 3011 | + | |
| 3012 | + | |
| 3013 | + | |
| 3014 | + | |
| 3015 | + | |
| 3016 | + | |
| 3017 | + | |
| 3018 | + | |
| 3019 | + | |
| 3020 | + | |
| 3021 | + | |
| 3022 | + | |
| 3023 | + | |
| 3024 | + | |
| 3025 | + | |
| 3026 | + | |
| 3027 | + | |
3011 | 3028 |
| |
3012 |
| - | |
3013 |
| - | |
3014 |
| - | |
3015 |
| - | |
3016 |
| - | |
| 3029 | + | |
| 3030 | + | |
| 3031 | + | |
| 3032 | + | |
| 3033 | + | |
| 3034 | + | |
| 3035 | + | |
| 3036 | + | |
| 3037 | + | |
| 3038 | + | |
| 3039 | + | |
3017 | 3040 |
| |
3018 | 3041 |
| |
3019 | 3042 |
| |
| |||
3026 | 3049 |
| |
3027 | 3050 |
| |
3028 | 3051 |
| |
3029 |
| - | |
3030 |
| - | |
3031 |
| - | |
| 3052 | + | |
| 3053 | + | |
| 3054 | + | |
| 3055 | + | |
3032 | 3056 |
| |
3033 | 3057 |
| |
3034 | 3058 |
| |
| |||
3038 | 3062 |
| |
3039 | 3063 |
| |
3040 | 3064 |
| |
3041 |
| - | |
3042 |
| - | |
3043 |
| - | |
3044 |
| - | |
| 3065 | + | |
| 3066 | + | |
| 3067 | + | |
| 3068 | + | |
| 3069 | + | |
| 3070 | + | |
| 3071 | + | |
3045 | 3072 |
| |
3046 | 3073 |
| |
3047 | 3074 |
| |
| |||
3063 | 3090 |
| |
3064 | 3091 |
| |
3065 | 3092 |
| |
| 3093 | + | |
| 3094 | + | |
| 3095 | + | |
| 3096 | + | |
| 3097 | + | |
| 3098 | + | |
| 3099 | + | |
| 3100 | + | |
| 3101 | + | |
| 3102 | + | |
| 3103 | + | |
| 3104 | + | |
| 3105 | + | |
3066 | 3106 |
| |
3067 | 3107 |
| |
3068 | 3108 |
| |
|
0 commit comments
Comments
(0)