Skip to content

Cherry pick #107991 to 26.3: validate discriminators in Variant binary bulk deserialization - #117736

Merged
robot-ch-test-poll4 merged 4 commits into
backport/26.3/107991from
cherrypick/26.3/107991
Sep 3, 2026
Merged

robot-ch-test-poll4 merged 4 commits into
backport/26.3/107991from
cherrypick/26.3/107991

Conversation

@robot-ch-test-poll4

Copy link
Copy Markdown
Contributor

Original pull-request #107991

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

uwezkhan and others added 3 commits June 19, 2026 22:20
…ation paths

Extend the discriminator bounds check from `SerializationVariant` to also cover
`ColumnVariant::validateState`, `SerializationVariantElement`, and
`SerializationVariantElementNullMap`. Use `INCORRECT_DATA` for native format
(untrusted input) and `LOGICAL_ERROR` otherwise.

Extract a `checkDiscriminatorValue` helper function to avoid repeating the
check-and-throw pattern at every call site.

Add tests with pregenerated `.native` files containing corrupted discriminators
(both plain and compact granule formats).

Related: #107991
Related: ClickHouse/clickhouse-private#59665

Co-Authored-By: Claude Opus 4.6 <[email protected]>
validate discriminators in Variant binary bulk deserialization
@robot-ch-test-poll4 robot-ch-test-poll4 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Sep 2, 2026
Resolve conflicts for the 26.3 backport of the Variant discriminator
bounds validation.

All conflicts come from the serialization pooling infrastructure
(`getHash`, static `create`, `ISerialization::pooled`, `supportsPooling`,
`allocatedBytes`), which exists on `master` but not on 26.3, where these
serializations are still constructed directly via `std::make_shared` with
public constructors. The resolution keeps 26.3's construction style and
threads `num_variants` through it, dropping the pooling-only declarations
and definitions.

`SerializationVariantElement` and `SerializationVariantElementNullMap`
take `num_variants` as a required constructor argument, since every
construction site in the 26.3 tree passes a real count. A defaulted `0`
would make `checkDiscriminatorValue` reject every non-NULL discriminator.
The subcolumn creators keep their `num_variants_ = 0` defaults as on
`master`.

Related: #117736
Related: #107991

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@robot-ch-test-poll4
robot-ch-test-poll4 merged commit b4afd14 into backport/26.3/107991 Sep 3, 2026
2 checks passed
@robot-ch-test-poll4
robot-ch-test-poll4 deleted the cherrypick/26.3/107991 branch September 3, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants