- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit319a810
committed
Fix dependency handling of partitions and inheritance for ON COMMIT
This commit fixes a set of issues with ON COMMIT actions when used onpartitioned tables and tables with inheritance children:- Applying ON COMMIT DROP on a partitioned table with partitions or on atable with inheritance children caused a failure at commit time, withcomplains about the children being already dropped as all relations aredropped one at the same time.- Applying ON COMMIT DELETE on a partition relying on a partitionedtable which uses ON COMMIT DROP would cause the partition truncation tofail as the parent is removed first.The solution to the first problem is to handle the removal of all thedependencies in one go instead of dropping relations one-by-one, basedon a suggestion from Álvaro Herrera. So instead all the relation OIDsto remove are gathered and then processed in one round of multipledeletions.The solution to the second problem is to reorder the actions, withtruncation happening first and relation drop done after. Even if itmeans that a partition could be first truncated, then immediatelydropped if its partitioned table is dropped, this has the merit to keepthe code simple as there is no need to do existence checks on therelations to drop.Contrary to a manual TRUNCATE on a partitioned table, ON COMMIT DELETEdoes not cascade to its partitions. The ON COMMIT action defined oneach partition gets the priority.Author: Michael PaquierReviewed-by: Amit Langote, Álvaro Herrera, Robert HaasDiscussion:https://postgr.es/m/68f17907-ec98-1192-f99f-8011400517f5@lab.ntt.co.jpBackpatch-through: 101 parent3d360e2 commit319a810
File tree
4 files changed
+203
-25
lines changed- doc/src/sgml/ref
- src
- backend/commands
- test/regress
- expected
- sql
4 files changed
+203
-25
lines changedLines changed: 5 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1215 | 1215 |
| |
1216 | 1216 |
| |
1217 | 1217 |
| |
1218 |
| - | |
| 1218 | + | |
| 1219 | + | |
1219 | 1220 |
| |
1220 | 1221 |
| |
1221 | 1222 |
| |
| |||
1225 | 1226 |
| |
1226 | 1227 |
| |
1227 | 1228 |
| |
1228 |
| - | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
1229 | 1232 |
| |
1230 | 1233 |
| |
1231 | 1234 |
| |
|
Lines changed: 54 additions & 23 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
13293 | 13293 |
| |
13294 | 13294 |
| |
13295 | 13295 |
| |
| 13296 | + | |
13296 | 13297 |
| |
13297 | 13298 |
| |
13298 | 13299 |
| |
| |||
13319 | 13320 |
| |
13320 | 13321 |
| |
13321 | 13322 |
| |
13322 |
| - | |
13323 |
| - | |
13324 |
| - | |
13325 |
| - | |
13326 |
| - | |
13327 |
| - | |
13328 |
| - | |
13329 |
| - | |
13330 |
| - | |
13331 |
| - | |
13332 |
| - | |
13333 |
| - | |
13334 |
| - | |
13335 |
| - | |
13336 |
| - | |
13337 |
| - | |
13338 |
| - | |
13339 |
| - | |
13340 |
| - | |
13341 |
| - | |
13342 |
| - | |
13343 |
| - | |
13344 |
| - | |
| 13323 | + | |
| 13324 | + | |
13345 | 13325 |
| |
13346 | 13326 |
| |
| 13327 | + | |
| 13328 | + | |
| 13329 | + | |
| 13330 | + | |
| 13331 | + | |
| 13332 | + | |
| 13333 | + | |
| 13334 | + | |
| 13335 | + | |
13347 | 13336 |
| |
13348 | 13337 |
| |
13349 | 13338 |
| |
13350 | 13339 |
| |
13351 | 13340 |
| |
| 13341 | + | |
| 13342 | + | |
| 13343 | + | |
| 13344 | + | |
| 13345 | + | |
| 13346 | + | |
| 13347 | + | |
| 13348 | + | |
| 13349 | + | |
| 13350 | + | |
| 13351 | + | |
| 13352 | + | |
| 13353 | + | |
| 13354 | + | |
| 13355 | + | |
| 13356 | + | |
| 13357 | + | |
| 13358 | + | |
| 13359 | + | |
| 13360 | + | |
| 13361 | + | |
| 13362 | + | |
| 13363 | + | |
| 13364 | + | |
| 13365 | + | |
| 13366 | + | |
| 13367 | + | |
| 13368 | + | |
| 13369 | + | |
| 13370 | + | |
| 13371 | + | |
| 13372 | + | |
| 13373 | + | |
| 13374 | + | |
| 13375 | + | |
| 13376 | + | |
| 13377 | + | |
| 13378 | + | |
| 13379 | + | |
| 13380 | + | |
| 13381 | + | |
| 13382 | + | |
13352 | 13383 |
| |
13353 | 13384 |
| |
13354 | 13385 |
| |
|
Lines changed: 85 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
216 | 216 |
| |
217 | 217 |
| |
218 | 218 |
| |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 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 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + |
Lines changed: 59 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
165 | 165 |
| |
166 | 166 |
| |
167 | 167 |
| |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + |
0 commit comments
Comments
(0)