Commit dd82ba3
committed
Fix assertion failure in getNdvBySegHeapTuple for empty partitions.
When merging leaf partition statistics for a partitioned table,
getNdvBySegHeapTuple could hit Assert(valuetype == FLOAT8OID) if a
partition had relTuples == 0 and its pg_statistic entry lacked a valid
STATISTIC_KIND_NDV_BY_SEGMENTS slot (or the slot had an unexpected
element type).
The original guard condition only handled two cases:
1. Non-empty partition with NDV value == 0
2. Non-empty partition without NDV_BY_SEGMENTS
It missed the case where an empty partition (relTuples == 0) has a
pg_statistic entry but no valid FLOAT8OID NDV_BY_SEGMENTS slot,
causing the code to fall through to the assertion.
Fix by checking valuetype != FLOAT8OID upfront: skip empty partitions
gracefully, and mark non-empty partitions as invalid.
Authored-by: Zhang Wenchao zwcpostgres@gmail.com1 parent 7e867f6 commit dd82ba3
1 file changed
Lines changed: 23 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
759 | 759 | | |
760 | 760 | | |
761 | 761 | | |
762 | | - | |
763 | | - | |
764 | | - | |
765 | | - | |
766 | | - | |
767 | | - | |
768 | | - | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
769 | 778 | | |
770 | 779 | | |
771 | | - | |
772 | 780 | | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
773 | 788 | | |
774 | 789 | | |
775 | 790 | | |
| |||
0 commit comments