Commit 7feb5b7
committed
ORCA: guard RetrieveExtStatsInfo against dropped statistics OID
When a DROP STATISTICS (or ALTER TABLE DROP COLUMN) drops a statistics
object within the same transaction, the relation's rd_statlist can still
contain a stale StatisticExtInfo entry whose backing pg_statistic_ext row
is already gone. RetrieveExtStatsInfo iterated over that list and called
gpdb::GetExtStatsName(info->statOid) without checking for a NULL return.
GetExtStatsName returns NULL for a missing OID. Passing NULL straight
into CDXLUtils::CreateDynamicStringFromCharArray triggers an assertion
failure in debug builds and undefined behaviour (corrupt memory) in
release builds, which in turn caused seemingly unrelated crashes later
in the same query — most visibly a SIGSEGV inside CMDKey::UlHashMDKey
called from Ptabdesc → RetrieveType when optimising an INSERT.
Fix: skip any StatisticExtInfo entry whose name cannot be resolved,
consistent with the same guard added to RetrieveExtStats in the
previous commit.1 parent 03d2338 commit 7feb5b7
1 file changed
Lines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
573 | 573 | | |
574 | 574 | | |
575 | 575 | | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
576 | 584 | | |
577 | 585 | | |
578 | | - | |
| 586 | + | |
579 | 587 | | |
580 | 588 | | |
581 | 589 | | |
| |||
0 commit comments