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

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: March 1, 2023

## Description

In all versions of CockroachDB from <InternalLink version="releases" path="v22.2">v22.2.0-alpha.1</InternalLink> to <InternalLink version="releases" path="v22.2">v22.2.3</InternalLink>, altering a non-empty table to [add a column](https://www.cockroachlabs.com/docs/v22.2/alter-table#add-column) with a [`DEFAULT` expression](https://www.cockroachlabs.com/docs/v22.2/default-value) in which the type of the expression does not match the type of the new column could cause the column to become corrupted. For example, `ALTER TABLE t ADD COLUMN c DECIMAL DEFAULT pi();`. This happens because the `DEFAULT` expression is not cast to the correct type when the column is backfilled for the existing rows in the table. As a result, a later attempt to read the data in that column could cause the decoding logic to panic and crash the node.

## Statement

This is resolved in CockroachDB by a fix that casts the `DEFAULT` expression to the correct type when backfilling a new column.

The fix has been applied to the maintenance release of CockroachDB <InternalLink version="releases" path="v22.2">v22.2.5</InternalLink>.

## Mitigation

We encourage users of CockroachDB <InternalLink version="releases" path="v22.2">v22.2.0-alpha.1</InternalLink> to <InternalLink version="releases" path="v22.2">v22.2.3</InternalLink> to upgrade to <InternalLink version="releases" path="v22.2">v22.2.5</InternalLink> or a later version.

If you discover that you have a table with a column that has become corrupted due to this issue, the best mitigation is to [drop](https://www.cockroachlabs.com/docs/v22.2/alter-table#drop-column) and recreate the column after upgrading. However, if the corrupted column contains data that must not be lost, please contact the [support team](https://support.cockroachlabs.com/).

## Impact

A column added to an existing non-empty table with a `DEFAULT` expression in which the type of the expression does not exactly match the type of the column could become corrupted. This causes attempts to access data in the table to panic and crash the node. Versions affected include CockroachDB <InternalLink version="releases" path="v22.2">v22.2.0-alpha.1</InternalLink> to <InternalLink version="releases" path="v22.2">v22.2.3</InternalLink>.

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