[Bug](array_type) Forbid adding array key columns #12479
mysql> desc array_test; +-----------+----------------+------+-------+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+----------------+------+-------+---------+-------+ | id | INT | Yes | true | NULL | | | c_array | ARRAY<INT(11)> | Yes | false | NULL | NONE | +-----------+----------------+------+-------+---------+-------+ Before: mysql> ALTER TABLE array_test ADD COLUMN add_arr_key array<int> key NULL DEFAULT NULL; Query OK, 0 rows affected (0.00 sec) After: mysql> ALTER TABLE array_test ADD COLUMN c_array array<int> key NULL DEFAULT NULL; ERROR 1105 (HY000): errCode = 2, detailMessage = Array can only be used in the non-key column of the duplicate table at present. mysql> ALTER TABLE array_test MODIFY COLUMN c_array array<int> key NULL DEFAULT NULL; ERROR 1105 (HY000): errCode = 2, detailMessage = Array can only be used in the non-key column of the duplicate table at present.
This commit is contained in:
@ -265,6 +265,10 @@ public class ColumnDef {
|
||||
}
|
||||
|
||||
if (type.getPrimitiveType() == PrimitiveType.ARRAY) {
|
||||
if (isKey()) {
|
||||
throw new AnalysisException("Array can only be used in the non-key column of"
|
||||
+ " the duplicate table at present.");
|
||||
}
|
||||
if (defaultValue.isSet && defaultValue != DefaultValue.NULL_DEFAULT_VALUE) {
|
||||
throw new AnalysisException("Array type column default value only support null");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user