Skip to main content
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 and 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 for more information.