Commit 493a8a4
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 8ecc326 commit 493a8a4
1 file changed
Lines changed: 28 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
759 | 759 | | |
760 | 760 | | |
761 | 761 | | |
762 | | - | |
763 | | - | |
764 | | - | |
765 | | - | |
766 | | - | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
767 | 784 | | |
768 | 785 | | |
769 | 786 | | |
770 | 787 | | |
771 | | - | |
772 | | - | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
773 | 794 | | |
774 | 795 | | |
775 | 796 | | |
| |||
0 commit comments