forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit9b35ddc
committed
Partial fix for dropped columns in functions returning composite.
When a view has a function-returning-composite in FROM, and there aresome dropped columns in the underlying composite type, ruleutils.cprinted junk in the column alias list for the reconstructed FROM entry.Before 9.3, this was prevented by doing get_rte_attribute_is_droppedtests while printing the column alias list; but that solution is notcurrently available to us for reasons I'll explain below. Instead,check for empty-string entries in the alias list, which can only existif that column position had been dropped at the time the view was made.(The parser fills in empty strings to preserve the invariant that thealiases correspond to physical column positions.)While this is sufficient to handle the case of columns dropped beforethe view was made, we have still got issues with columns dropped afterthe view was made. In particular, the view could contain Vars thatexplicitly reference such columns! The dependency machinery reallyought to refuse the column drop attempt in such cases, as it would dowhen trying to drop a table column that's explicitly referenced inviews. However, we currently neglect to store dependencies on columnsof composite types, and fixing that is likely to be too big to beback-patchable (not to mention that existing views in existing databaseswould not have the needed pg_depend entries anyway). So I'll leave thatfor a separate patch.Pre-9.3, ruleutils would print such Vars normally (with their originalcolumn names) even though it suppressed their entries in the RTE'scolumn alias list. This is certainly bogus, since the printed viewdefinition would fail to reload, but at least it didn't crash. However,as of 9.3 the printed column alias list is tightly tied to the namesprinted for Vars; so we can't treat columns as dropped for one purposeand not dropped for the other. This is why we can't just put back theget_rte_attribute_is_dropped test: it results in an assertion failureif the view in fact contains any Vars referencing the dropped column.Once we've got dependencies preventing such cases, we'll probably wantto do it that way instead of relying on the empty-string test used here.This fix turned up a very ancient bug in outfuncs/readfuncs, namelythat T_String nodes containing empty strings were not dumped/reloadedcorrectly: the node was printed as "<>" which is read as a stringvalue of <>. Since (per SQL) we disallow empty-string identifiers,such nodes don't occur normally, which is why we'd not noticed.(Such nodes aren't used for literal constants, just identifiers.)Per report from Marc Schablewski. Back-patch to 9.3 which is wherethe rule printing behavior changed. The dangling-variable case isbroken all the way back, but that's not what his complaint is about.1 parent85f9573 commit9b35ddc
File tree
4 files changed
+103
-2
lines changed- src
- backend
- nodes
- utils/adt
- test/regress
- expected
- sql
4 files changed
+103
-2
lines changedLines changed: 7 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2505 | 2505 |
| |
2506 | 2506 |
| |
2507 | 2507 |
| |
| 2508 | + | |
| 2509 | + | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
2508 | 2513 |
| |
2509 |
| - | |
| 2514 | + | |
| 2515 | + | |
2510 | 2516 |
| |
2511 | 2517 |
| |
2512 | 2518 |
| |
|
Lines changed: 10 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3086 | 3086 |
| |
3087 | 3087 |
| |
3088 | 3088 |
| |
3089 |
| - | |
| 3089 | + | |
| 3090 | + | |
| 3091 | + | |
| 3092 | + | |
| 3093 | + | |
| 3094 | + | |
| 3095 | + | |
| 3096 | + | |
| 3097 | + | |
| 3098 | + | |
3090 | 3099 |
| |
3091 | 3100 |
| |
3092 | 3101 |
| |
|
Lines changed: 52 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1332 | 1332 |
| |
1333 | 1333 |
| |
1334 | 1334 |
| |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
1335 | 1387 |
| |
1336 | 1388 |
| |
1337 | 1389 |
| |
|
Lines changed: 34 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
435 | 435 |
| |
436 | 436 |
| |
437 | 437 |
| |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
438 | 472 |
| |
439 | 473 |
| |
440 | 474 |
| |
|
0 commit comments
Comments
(0)