Skip to content

schemachanger: ADD COLUMN AS (NULL) virtual not null incorrectly succeeds #87457

@Xiang-Gu

Description

@Xiang-Gu

In the new schema changer, the following ADD COLUMN incorrectly succeeds:

SET use_declarative_schema_changer = 'unsafe_always';
CREATE TABLE t (i INT PRIMARY KEY);
INSERT INTO t VALUES (1);
ALTER TABLE t ADD COLUMN j INT AS (NULL::INT) VIRTUAL NOT NULL;

The expected behavior, as the old schema changer will give us, is

ERROR: validation of NOT NULL constraint failed: validation of CHECK "j IS NOT NULL" failed on row: i=1, j=NULL
SQLSTATE: 23514

Jira issue: CRDB-19354

Metadata

Metadata

Assignees

Labels

C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.GA-blockerT-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)branch-release-22.2Used to mark GA and release blockers, technical advisories, and bugs for 22.2

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions