forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitc1d1e84
committed
Fix ruleutils issues with dropped cols in functions-returning-composite.
Due to lack of concern for the case in the dependency code, it'spossible to drop a column of a composite type even though storedqueries have references to the dropped column via functions-in-FROMthat return the composite type. There are "soft" references,namely FROM-clause aliases for such columns, and "hard" references,that is actual Vars referring to them. The right fix for hardreferences is to add dependencies preventing the drop; somethingwe've known for many years and not done (and this commit still doesn'taddress it). A "soft" reference shouldn't prevent a drop though.We've been around on this before (cf.9b35ddc,2c4debb), butnobody had noticed that the current behavior can result in dump/reloadfailures, because ruleutils.c can print more column aliases than theunderlying composite type now has. So we need to rejigger thecolumn-alias-handling code to treat such columns as dropped and notprint aliases for them.Rather than writing new code for this, I used expandRTE() which alreadyknows how to figure out which function result columns are dropped.I'd initially thought maybe we could use expandRTE() in all cases, butthat fails for EXPLAIN's purposes, because the planner strips a lot ofRTE infrastructure that expandRTE() needs. So this patch just uses itfor unplanned function RTEs and otherwise does things the old way.If there is a hard reference (Var), then removing the column aliascauses us to fail to print the Var, since there's no longer a nameto print. Failing seems less desirable than printing a made-upname, so I made it print "?dropped?column?" instead.Per report from Timo Stolz. Back-patch to all supported branches.Discussion:https://postgr.es/m/5c91267e-3b6d-5795-189c-d15a55d61dbb@nullachtvierzehn.de1 parentc69616c commitc1d1e84
File tree
4 files changed
+68
-22
lines changed- src
- backend
- parser
- utils/adt
- test/regress
- expected
- sql
4 files changed
+68
-22
lines changedLines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3183 | 3183 |
| |
3184 | 3184 |
| |
3185 | 3185 |
| |
| 3186 | + | |
| 3187 | + | |
| 3188 | + | |
3186 | 3189 |
| |
3187 | 3190 |
| |
3188 | 3191 |
| |
|
Lines changed: 44 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
53 | 53 |
| |
54 | 54 |
| |
55 | 55 |
| |
| 56 | + | |
56 | 57 |
| |
57 | 58 |
| |
58 | 59 |
| |
| |||
4326 | 4327 |
| |
4327 | 4328 |
| |
4328 | 4329 |
| |
4329 |
| - | |
4330 |
| - | |
4331 |
| - | |
| 4330 | + | |
| 4331 | + | |
| 4332 | + | |
4332 | 4333 |
| |
4333 | 4334 |
| |
4334 | 4335 |
| |
| |||
4355 | 4356 |
| |
4356 | 4357 |
| |
4357 | 4358 |
| |
4358 |
| - | |
| 4359 | + | |
| 4360 | + | |
4359 | 4361 |
| |
4360 | 4362 |
| |
4361 |
| - | |
| 4363 | + | |
| 4364 | + | |
| 4365 | + | |
| 4366 | + | |
| 4367 | + | |
| 4368 | + | |
| 4369 | + | |
| 4370 | + | |
| 4371 | + | |
| 4372 | + | |
| 4373 | + | |
| 4374 | + | |
| 4375 | + | |
| 4376 | + | |
| 4377 | + | |
| 4378 | + | |
| 4379 | + | |
| 4380 | + | |
| 4381 | + | |
| 4382 | + | |
| 4383 | + | |
| 4384 | + | |
| 4385 | + | |
| 4386 | + | |
| 4387 | + | |
4362 | 4388 |
| |
4363 | 4389 |
| |
4364 | 4390 |
| |
4365 |
| - | |
| 4391 | + | |
4366 | 4392 |
| |
4367 | 4393 |
| |
4368 |
| - | |
4369 |
| - | |
4370 |
| - | |
| 4394 | + | |
| 4395 | + | |
4371 | 4396 |
| |
4372 | 4397 |
| |
4373 | 4398 |
| |
| |||
7304 | 7329 |
| |
7305 | 7330 |
| |
7306 | 7331 |
| |
7307 |
| - | |
7308 |
| - | |
7309 |
| - | |
| 7332 | + | |
| 7333 | + | |
| 7334 | + | |
| 7335 | + | |
| 7336 | + | |
| 7337 | + | |
| 7338 | + | |
| 7339 | + | |
| 7340 | + | |
| 7341 | + | |
7310 | 7342 |
| |
7311 | 7343 |
| |
7312 | 7344 |
| |
|
Lines changed: 17 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1600 | 1600 |
| |
1601 | 1601 |
| |
1602 | 1602 |
| |
1603 |
| - | |
| 1603 | + | |
1604 | 1604 |
| |
1605 |
| - | |
1606 |
| - | |
1607 |
| - | |
1608 |
| - | |
1609 |
| - | |
1610 |
| - | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
1611 | 1611 |
| |
1612 | 1612 |
| |
1613 |
| - | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
1614 | 1623 |
| |
1615 | 1624 |
| |
1616 | 1625 |
| |
|
Lines changed: 4 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
580 | 580 |
| |
581 | 581 |
| |
582 | 582 |
| |
583 |
| - | |
| 583 | + | |
584 | 584 |
| |
585 |
| - | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
586 | 588 |
| |
587 | 589 |
| |
588 | 590 |
| |
|
0 commit comments
Comments
(0)