Skip to content

Conversation

zhangyue-hashdata
Copy link
Contributor

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

Additional Context

CI Skip Instructions


Copy link
Contributor

@my-ship-it my-ship-it left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants