Skip to content

fix: cap internal planner-statistics blob types at the preview size (#106) - #109

Merged
aesslinger merged 1 commit into
mainfrom
fix/106-binary-blob-wrapper-truncation
Sep 16, 2026
Merged

aesslinger merged 1 commit into
mainfrom
fix/106-binary-blob-wrapper-truncation

Conversation

@aesslinger

Copy link
Copy Markdown
Collaborator

Summary

Fixes #106 (filed as a follow-up while working on #87).

Test plan

  • TDD: added internal_statistics_blob_types_truncate_a_large_buffer_to_the_preview_cap to extract_tests.rs — a synthetic 20 KB buffer, since real pg_statistic_ext_data values are typically well under 10 KB in practice (confirmed live below). Confirmed the new test fails against the pre-fix code (20480 vs expected 10240) before the fix, passes after.
  • The existing internal_statistics_blob_types_decode_and_accept_correctly test (small, live-captured buffers) continues to pass unchanged, since those values are far under the cap.
  • cargo test --lib — 321 passed
  • cargo clippy --all-targets -- -D warnings — clean
  • cargo fmt --all -- --check — clean
  • Verified live against a real PostgreSQL instance: ran an actual CREATE STATISTICS ... ON a, b, c and confirmed the real pg_statistic_ext_data.stxdndistinct value (78 bytes) still decodes correctly through the fixed macro with no error — since real values are typically small, this confirms no regression on the common path while the unit test covers the large-value truncation the issue is actually about.

…106)

extract.rs's binary_blob_wrapper! macro -- used for PgMcvList,
PgDependencies, PgNdistinct, and the two BRIN summary types -- had its
own independently-drifted copy of the untruncated BLOB: encoding that
#87 fixed for ordinary BYTEA columns. Its doc comment even claimed this
matched the builtin, but the builtin's equivalent macro
(binary_wrapper! in extract/advanced_types.rs) actually calls the
builtin's own encode_blob (the truncated encoder), not an untruncated
one -- so the plugin had drifted into a second, separate divergence.

Switched the macro to use the shared crate::utils::blob::encode_blob
(added in #87) instead of inlining its own base64 encoding, and
corrected the stale doc comment.

TDD: added internal_statistics_blob_types_truncate_a_large_buffer_to_the_preview_cap
in extract_tests.rs (a synthetic 20 KB buffer, since real
pg_statistic_ext_data values are typically well under 10 KB in
practice -- confirmed live against a real CREATE STATISTICS run, which
produced a 78-byte value, far too small to exercise truncation).
Confirmed the new test fails against the pre-fix code (20480 vs
expected 10240) before the fix, passes after. The existing
internal_statistics_blob_types_decode_and_accept_correctly test (small,
live-captured buffers) continues to pass unchanged, since those values
are far under the cap.

Verified live against a real PostgreSQL instance: a genuine
pg_statistic_ext_data.stxdndistinct value (from an actual CREATE
STATISTICS ... ON a, b, c run) still decodes correctly through the
fixed macro with no error.
@aesslinger aesslinger added the prerelease:rc Version suggestion targets a release candidate label Sep 16, 2026
@github-actions

Copy link
Copy Markdown

Version suggestion

Based on this PR's title (fix) and the prerelease:rc label:

Current 1.0.0-rc.3
Suggested next tag v1.0.0-rc.4

This is informational only — no tag or release is created automatically yet.

@aesslinger aesslinger self-assigned this Sep 16, 2026
@aesslinger
aesslinger merged commit d2160de into main Sep 16, 2026
14 checks passed
@aesslinger
aesslinger deleted the fix/106-binary-blob-wrapper-truncation branch September 16, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

prerelease:rc Version suggestion targets a release candidate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

extract.rs's binary_blob_wrapper! macro is untruncated for internal planner-statistics types (builtin's binary_wrapper! uses truncated encode_blob)

1 participant