Commit 224f153
committed
ORCA: Fix use-after-free in flatten_join_alias_var_optimizer
Guard pfree/list_free calls with pointer-equality checks to avoid
freeing live nodes when flatten_join_alias_vars returns the same
pointer unchanged (e.g., outer-reference Vars with varlevelsup > 0).
The unconditional pfree(havingQual) freed the Var node, whose memory
was later reused by palloc for a T_List. copyObjectImpl then copied
the wrong node type into havingQual, causing ORCA to encounter an
unexpected RangeTblEntry and fall back to the Postgres planner.
Applies the same guard pattern to all six fields: targetList,
returningList, havingQual, scatterClause, limitOffset, limitCount.
Reported-in: #16181 parent 021d378 commit 224f153
1 file changed
Lines changed: 13 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5522 | 5522 | | |
5523 | 5523 | | |
5524 | 5524 | | |
5525 | | - | |
| 5525 | + | |
| 5526 | + | |
5526 | 5527 | | |
5527 | 5528 | | |
5528 | | - | |
| 5529 | + | |
5529 | 5530 | | |
5530 | 5531 | | |
5531 | 5532 | | |
5532 | | - | |
| 5533 | + | |
| 5534 | + | |
5533 | 5535 | | |
5534 | 5536 | | |
5535 | 5537 | | |
5536 | 5538 | | |
5537 | 5539 | | |
5538 | 5540 | | |
5539 | | - | |
| 5541 | + | |
| 5542 | + | |
5540 | 5543 | | |
5541 | 5544 | | |
5542 | 5545 | | |
5543 | 5546 | | |
5544 | 5547 | | |
5545 | 5548 | | |
5546 | | - | |
| 5549 | + | |
| 5550 | + | |
5547 | 5551 | | |
5548 | 5552 | | |
5549 | 5553 | | |
5550 | 5554 | | |
5551 | 5555 | | |
5552 | 5556 | | |
5553 | | - | |
| 5557 | + | |
| 5558 | + | |
5554 | 5559 | | |
5555 | 5560 | | |
5556 | 5561 | | |
| |||
5577 | 5582 | | |
5578 | 5583 | | |
5579 | 5584 | | |
5580 | | - | |
| 5585 | + | |
| 5586 | + | |
5581 | 5587 | | |
5582 | 5588 | | |
5583 | 5589 | | |
| |||
0 commit comments