> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cockroachlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Technical Advisory 79384

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

Publication date: April 14, 2022

## Description

The optimizer has been found to create logically incorrect query plans in some cases, which can cause incorrect query results. The bug can only occur in queries with an inner join, e.g., `t1 JOIN t2`, if all of the following are true:

* The join contains an equality condition between columns of both tables, e.g., `t1.a = t2.a`.
* A query filter or `CHECK` constraint constrains a column to a set of specific values, e.g., `t2.b IN (1, 2, 3)`. In the case of a `CHECK` constraint, the column must be `NOT NULL`.
* A query filter or `CHECK` constraint constrains a column to a range, e.g., `t2.c > 0`. In the case of a `CHECK` constraint, the column must be `NOT NULL`.
* An index contains a column from each of the criteria above, e.g., `INDEX t2(a, b, c)`.

## Statement

The fix has been applied to maintenance versions <InternalLink version="releases" path="v21.1">v21.1.18</InternalLink> and <InternalLink version="releases" path="v21.2">v21.2.9</InternalLink> of CockroachDB.

## Mitigation

Users of CockroachDB are encouraged to upgrade to a maintenance version with the fix applied: v21.1.18 and v21.2.9.

## Impact

Versions affected include v21.1.0 to v21.1.17, v21.2.0 to v21.2.8, and v22.1.0-alpha.1 to v22.1.0-beta.1.

Please reach out to the [support team](https://support.cockroachlabs.com/) for more information.
