Skip to content

ALTER COLUMN ... SET NOT NULL fails on text columns with a secondary index #3217

Description

@zachmu

ALTER TABLE ... ALTER COLUMN ... SET NOT NULL fails on a text column that has a secondary index, with a MySQL-dialect error:

CREATE TABLE t1 (pk integer PRIMARY KEY, value text);
CREATE INDEX t1_value_idx ON t1 (value);
INSERT INTO t1 VALUES (1, 'one');

ALTER TABLE t1 ALTER COLUMN value SET NOT NULL;
ERROR: blob/text column 'value' used in key specification without a key length

The statement works when the column has no secondary index. The error comes from GMS's ValidateModifyColumn, which applies MySQL's key-prefix-length rule to text/blob columns on any column modification; Postgres text columns are indexable without a key length, so the rule shouldn't apply to Doltgres.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions