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

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: May 23, 2022

## Description

In all versions of CockroachDB from v21.2.0 to v21.2.10, and from v22.1.0-alpha.1 to v22.1.0, executing a prepared [`SELECT`](https://www.cockroachlabs.com/docs/v22.1/select-clause) query with a casted placeholder value in a constant filter could produce incorrect results if the casted type did not match the filtered column type.

For example, executing a prepared statement of the form `SELECT... FROM... WHERE col = $1::type...`, where `type` did not match the type of column `col`, could return fewer results than expected.

## Statement

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

## Mitigation

Users of CockroachDB are encouraged to upgrade to a maintenance version with the fix applied: v21.2.11 or v22.1.1.

To avoid this problem on affected versions, users should change any placeholder casts that filter a column in their prepared statements to match the type of the filtered column.

For example, in the prepared statement `SELECT * FROM my_tab WHERE a = $1::INT8;`, if column `a` has type `DECIMAL`, the prepared statement should be changed to `SELECT * FROM my_tab WHERE a = $1::DECIMAL;` to avoid this issue.

## Impact

Versions affected include v21.2.0 to v21.2.10, and v22.1.0-alpha.1 to v22.1.0.

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