Skip to content

fixing a possible underflow while parsing postgres array values - #104322

Merged
grantholly-clickhouse merged 2 commits into
ClickHouse:masterfrom
grantholly-clickhouse:fix_dimension_underflow_in_postgres_array_parser
May 12, 2026
Merged

grantholly-clickhouse merged 2 commits into
ClickHouse:masterfrom
grantholly-clickhouse:fix_dimension_underflow_in_postgres_array_parser

Conversation

@grantholly-clickhouse

@grantholly-clickhouse grantholly-clickhouse commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fixes a possible underflow in parsing postgres arrays.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

When parsing arrays, we decrement a size_t without checking if it is 0 or not. Now we will throw an exception instead.

Version info

  • Merged into: 26.5.1.576
  • Backported to: 26.4.3.15, 26.3.11.15, 26.2.19.22, 25.8.24.15

@clickhouse-gh

clickhouse-gh Bot commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [7ca9875]

Summary: ✅


AI Review

Summary

This PR fixes a real correctness issue in insertPostgreSQLValue for vtArray: malformed input that emits row_end at dimension 0 now throws BAD_ARGUMENTS instead of underflowing the size_t dimension counter and indexing out of bounds. The accompanying unit and integration tests exercise the malformed-input path and confirm expected exception behavior, so this looks ready to merge.

ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
No large/binary files ✅
Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label May 7, 2026
@clickhouse-gh

clickhouse-gh Bot commented May 12, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.00% 84.10% +0.10%
Functions 91.10% 91.10% +0.00%
Branches 76.50% 76.50% +0.00%

Changed lines: 100.00% (43/43) · Uncovered code

Full report · Diff report

@grantholly-clickhouse
grantholly-clickhouse marked this pull request as ready for review May 12, 2026 14:37
@alexey-milovidov alexey-milovidov self-assigned this May 12, 2026
@grantholly-clickhouse
grantholly-clickhouse added this pull request to the merge queue May 12, 2026
Merged via the queue into ClickHouse:master with commit a0b79a6 May 12, 2026
325 of 326 checks passed
@grantholly-clickhouse
grantholly-clickhouse deleted the fix_dimension_underflow_in_postgres_array_parser branch May 12, 2026 17:48
@clickgapai

Copy link
Copy Markdown
Contributor

Hi — could this be a backport candidate for 26.4, 26.3 (LTS), 26.2, 25.8 (LTS)? No backport label was found, and the affected code appears to exist in those branches based on a file/function presence check.

Affected code: insertPostgreSQLValue array parsing in src/Core/PostgreSQL/insertPostgreSQLValue.cpp — core code present in all supported branches.

Why this might apply: This is a crash/undefined behavior fix in PostgreSQL array parsing. The affected code path in insertPostgreSQLValue predates all supported releases - the PostgreSQL storage integration has existed for years. The bug could cause server crashes when reading malformed data via type mismatch (PostgreSQL text column read as ClickHouse Array).

Caveat: I verified that the modified code exists in those branches, but not whether the bug is actually reachable there — a new caller in master may be what makes this newly observable. If older branches can't reach the affected path, please ignore this; otherwise consider pr-must-backport or a version label like v26.4-must-backport.

@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 12, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label May 12, 2026
robot-clickhouse-ci-1 added a commit that referenced this pull request May 12, 2026
Cherry pick #104322 to 26.2: fixing a possible underflow while parsing postgres array values
robot-clickhouse added a commit that referenced this pull request May 12, 2026
robot-clickhouse-ci-1 added a commit that referenced this pull request May 12, 2026
Cherry pick #104322 to 26.3: fixing a possible underflow while parsing postgres array values
robot-clickhouse added a commit that referenced this pull request May 12, 2026
robot-clickhouse-ci-1 added a commit that referenced this pull request May 12, 2026
Cherry pick #104322 to 26.4: fixing a possible underflow while parsing postgres array values
robot-clickhouse added a commit that referenced this pull request May 12, 2026
grantholly-clickhouse added a commit that referenced this pull request May 13, 2026
Backport #104322 to 26.4: fixing a possible underflow while parsing postgres array values
grantholly-clickhouse added a commit that referenced this pull request May 13, 2026
Backport #104322 to 26.3: fixing a possible underflow while parsing postgres array values
robot-ch-test-poll3 added a commit that referenced this pull request May 13, 2026
Cherry pick #104322 to 25.8: fixing a possible underflow while parsing postgres array values
robot-clickhouse added a commit that referenced this pull request May 13, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label May 13, 2026
grantholly-clickhouse added a commit that referenced this pull request May 13, 2026
Backport #104322 to 26.2: fixing a possible underflow while parsing postgres array values
grantholly-clickhouse added a commit that referenced this pull request May 15, 2026
Backport #104322 to 25.8: fixing a possible underflow while parsing postgres array values
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…4322

Backport ClickHouse#104322 to 26.4: fixing a possible underflow while parsing postgres array values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.2-must-backport v26.3-must-backport v26.4-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants