cloudberry
cloudberry copied to clipboard
Fix incorrect column number in funcTupleDesc initialization.
In process_sample_rows(), when initializing funcTupleDesc for table columns, the column number should start from NUM_SAMPLE_FIXED_COLS + 1 (5) instead of 4.
The first 4 columns (1-4) are reserved for fixed columns:
- Column 1: totalrows (FLOAT8OID)
- Column 2: totaldeadrows (FLOAT8OID)
- Column 3: oversized_cols_length (FLOAT8ARRAYOID)
- Column 4: NDV array (FLOAT8ARRAYOID)
Table columns should start from column 5, so the correct formula is: (AttrNumber) NUM_SAMPLE_FIXED_COLS + 1 + index
This bug is harmless because funcTupleDesc's column type information is not actually used in subsequent processing - only the column count (natts) is used. The actual type information is obtained dynamically via lookup_rowtype_tupdesc(). However, it's still worth fixing for code correctness and maintainability.
Fixes #ISSUE_Number
What does this PR do?
Type of Change
- [ ] Bug fix (non-breaking change)
- [ ] New feature (non-breaking change)
- [ ] Breaking change (fix or feature with breaking changes)
- [ ] Documentation update
Breaking Changes
Test Plan
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Passed
make installcheck - [ ] Passed
make -C src/test installcheck-cbdb-parallel
Impact
Performance:
User-facing changes:
Dependencies:
Checklist
- [ ] Followed contribution guide
- [ ] Added/updated documentation
- [ ] Reviewed code for security implications
- [ ] Requested review from cloudberry committers