Skip to content

Conversation

@mgartner
Copy link
Collaborator

@mgartner mgartner commented Dec 9, 2025

Backport 1/3 commits from #159001.

/cc @cockroachdb/release


opt: fix placeholder scan NULL semantics

Fixes #158945

Release note (bug fix): A bug has been fixed which could cause incorrect
results. The bug has existed since v21.2. From v21.2 up to v25.3, the
bug only presented when all of the following were true:

  • The query was run with an explicit or implicit prepared statement.
  • The query had an equality filter on a placeholder and a UNIQUE
    column.
  • The column contained NULL values.
  • The placeholder was assigned to NULL during execution.
    In this case, the query could return rows in which the column's value is
    NULL, which violates SQL NULL-equality semantics. The correct result set
    should always be empty.
    Starting in v25.4, the requirements were loosened slightly. It was no
    longer necessary for the column to be UNIQUE. The bug could reproduce if
    the column was included in any index.

Release justification: Low-risk bug fix.

Fixes cockroachdb#158945

Release note (bug fix): A bug has been fixed which could cause incorrect
results. The bug has existed since v21.2. From v21.2 up to v25.3, the
bug only presented when all of the following were true:
  - The query was run with an explicit or implicit prepared statement.
  - The query had an equality filter on a placeholder and a UNIQUE
    column.
  - The column contained NULL values.
  - The placeholder was assigned to NULL during execution.
In this case, the query could return rows in which the column's value is
NULL, which violates SQL NULL-equality semantics. The correct result set
should always be empty.
Starting in v25.4, the requirements were loosened slightly. It was no
longer necessary for the column to be UNIQUE. The bug could reproduce if
the column was included in any index.
@mgartner mgartner requested a review from a team as a code owner December 9, 2025 18:35
@mgartner mgartner requested review from ZhouXing19 and removed request for a team December 9, 2025 18:35
@blathers-crl
Copy link

blathers-crl bot commented Dec 9, 2025

Thanks for opening a backport.

Before merging, please confirm that the change does not break backwards compatibility and otherwise complies with the backport policy. Include a brief release justification in the PR description explaining why the backport is appropriate. All backports must be reviewed by the TL for the owning area. While the stricter LTS policy does not yet apply, please exercise judgment and consider gating non-critical changes behind a disabled-by-default feature flag when appropriate.

@blathers-crl blathers-crl bot added backport Label PR's that are backports to older release branches T-sql-queries SQL Queries Team labels Dec 9, 2025
@mgartner mgartner requested a review from a team December 9, 2025 18:35
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@mgartner mgartner requested a review from michae2 December 9, 2025 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Label PR's that are backports to older release branches T-sql-queries SQL Queries Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants