Closed
Description
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
A simplified case from https://asktug.com/t/topic/662946
> set sql_mode='';
> CREATE TABLE test ( id int(16) NOT NULL AUTO_INCREMENT, PRIMARY KEY (id));
> alter table test add column b longblob not null default '';
-- p.s. Note that `set sql_mode=""` is required or the SQL will get blocked like
> CREATE TABLE test ( id int(16) NOT NULL AUTO_INCREMENT, PRIMARY KEY (id));
> alter table test add column b longblob not null default '';
ERROR 1101 (42000): BLOB/TEXT/JSON column 'b' can't have a default value
Those SQLs will create a table with JSON info as below. Note that the column type of "b" is not null long blob, but its "default"/"origin_default" field is ""
and "type.FLen" is -1
.
{
"cols": [{
"comment": "",
"default": null,
"default_bit": null,
"id": 1,
"name": {
"L": "id",
"O": "id"
},
"offset": 0,
"origin_default": null,
"state": 5,
"type": {
"Charset": "binary",
"Collate": "binary",
"Decimal": 0,
"Elems": null,
"Flag": 515,
"Flen": 16,
"Tp": 3
}
}, {
"comment": "",
"default": "",
"default_bit": null,
"id": 15,
"name": {
"L": "b",
"O": "b"
},
"offset": 12,
"origin_default": "",
"state": 5,
"type": {
"Charset": "binary",
"Collate": "binary",
"Decimal": 0,
"Elems": null,
"Flag": 4225,
"Flen": -1,
"Tp": 251
}
}],
"comment": "",
"id": 330,
"index_info": [],
"is_common_handle": false,
"name": {
"L": "test",
"O": "test"
},
"partition": null,
"pk_is_handle": true,
"schema_version": 465,
"state": 5,
"update_timestamp":999
}
However, if we run CREATE TABLE test ( id int(16) NOT NULL AUTO_INCREMENT, b longblob not null, PRIMARY KEY (id));
in TiDB, we can only get a JSON as below, which "default"/"origin_default" is null
instead of ""
. And this won't make any error.
2. What did you expect to see? (Required)
Table create successfully
3. What did you see instead (Required)
TiFlash crashes with basic_string::_M_replace_aux
4. What is your TiFlash version? (Required)
v5.2.1
Activity