Skip to main content
Publication date: March 1, 2023

Description

In all versions of CockroachDB from to , altering a non-empty table to add a column with a DEFAULT expression 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 .

Mitigation

We encourage users of CockroachDB to to upgrade to 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 and recreate the column after upgrading. However, if the corrupted column contains data that must not be lost, please contact the support team.

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 to . Please reach out to the support team if more information or assistance is needed.