Skip to content

Incorrect default value for bit type column #17641

@zanmato1984

Description

@zanmato1984

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> create table t(i int);
Query OK, 0 rows affected (0.10 sec)

mysql> insert into t values(1);
Query OK, 1 row affected (0.02 sec)

mysql> alter table t add column b bit(1) default b'0';
Query OK, 0 rows affected (0.28 sec)

mysql> select b from t;
+------------+
| b          |
+------------+
| 0x00       |
+------------+
1 row in set (0.00 sec)

mysql> alter table t modify column b bit(1) default b'1';
Query OK, 0 rows affected (0.09 sec)

mysql> select b from t;
+------------+
| b          |
+------------+
| 0x01       |
+------------+
1 row in set (0.01 sec)

2. What did you expect to see? (Required)

Second select should see 0x00 still.

3. What did you see instead (Required)

Second select outputs 0x01.

4. Affected version (Required)

v3.0.0, v3.1.0, v4.0.0

5. Root Cause Analysis

Filling default value for missing bit column of rows doesn't regard origin default value.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions