> ## 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 78681

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 11, 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 present if all of the following conditions are true:

1. The query contains a semi-join with an equality filter, such as queries in the form: `SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t2 WHERE t1.a = t2.a)`.
2. The inner table has an index containing the column in the equality filter, like `t2.a` in the example query above.
3. The index contains one or more columns that prefix the equality column.
4. The prefix columns are constrained to a set of constant values via the query filter or a [`CHECK` constraint](https://www.cockroachlabs.com/docs/v21.2/check), for example via an `IN` operator. In the case of a `CHECK` constraint, the columns must be `NOT NULL`.

## Statement

The fix has been applied to maintenance versions 21.1.17 and 21.2.8 of CockroachDB.

## Mitigation

Users of CockroachDB are encouraged to upgrade to a maintenance version with the fix applied: <InternalLink version="releases" path="v21.1">v21.1.17</InternalLink> and <InternalLink version="releases" path="v21.2">v21.2.8</InternalLink>.

## Impact

Versions affected include v21.1.0 to v21.1.16, v21.2.0 to v21.2.7, and v22.1.0-alpha.1 to v22.1.0-alpha.5.

Please reach out to the [support team](https://support.cockroachlabs.com/) if more information or assistance is needed.
