[fix](type compatibility) fix unsigned int type compatibility problem (#17427)
Fix unsigned int type compatibility value scope problem. When defining columns, map UNSIGNED INT to BIGINT for compatibility. The problems are as follows: It is not consistent with this doc image We support the unsigned int type to be compatible with mysql types, but the unsigned int type is created as the int at the time of definition. This will cause numerical overflow.
This commit is contained in:
@ -5744,6 +5744,9 @@ type ::=
|
||||
{: RESULT = Type.SMALLINT; :}
|
||||
| opt_signed_unsigned KW_INT opt_field_length
|
||||
{: RESULT = Type.INT; :}
|
||||
// This is just for MySQL compatibility now.
|
||||
| KW_UNSIGNED KW_INT opt_field_length
|
||||
{: RESULT = Type.BIGINT; :}
|
||||
| KW_BIGINT opt_field_length
|
||||
{: RESULT = Type.BIGINT; :}
|
||||
| KW_LARGEINT opt_field_length
|
||||
@ -5848,8 +5851,6 @@ opt_signed_unsigned ::=
|
||||
{: RESULT = true; :}
|
||||
| KW_SIGNED
|
||||
{: RESULT = true; :}
|
||||
| KW_UNSIGNED
|
||||
{: RESULT = false; :}
|
||||
;
|
||||
|
||||
type_def ::=
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
-- This file is automatically generated. You should know what you did if you want to edit this
|
||||
-- !desc_tb --
|
||||
user_id LARGEINT No true \N
|
||||
city VARCHAR(20) Yes true \N
|
||||
value1 BIGINT Yes false \N REPLACE
|
||||
|
||||
-- !select_tb --
|
||||
1 Beijing 21474836478
|
||||
|
||||
-- !desc_tb --
|
||||
user_id LARGEINT No true \N
|
||||
city VARCHAR(20) Yes true \N
|
||||
value1 BIGINT Yes false \N REPLACE
|
||||
value2 BIGINT Yes false \N REPLACE
|
||||
|
||||
-- !select_tb --
|
||||
1 Beijing 21474836478 \N
|
||||
2 Beijing 21474836478 21474836478
|
||||
@ -0,0 +1,55 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
suite("test_unsigned_int_compatibility") {
|
||||
def tableName = "test_unsigned_int_compatibility"
|
||||
|
||||
sql """DROP TABLE IF EXISTS ${tableName}"""
|
||||
sql """
|
||||
CREATE TABLE IF NOT EXISTS ${tableName} (
|
||||
`user_id` LARGEINT NOT NULL COMMENT "用户id",
|
||||
`city` VARCHAR(20) COMMENT "用户所在城市",
|
||||
`value1` UNSIGNED INT COMMENT "value2"
|
||||
)
|
||||
UNIQUE KEY(`user_id`, `city`)
|
||||
DISTRIBUTED BY HASH(`user_id`)
|
||||
PROPERTIES (
|
||||
"replication_num" = "1" ,
|
||||
"light_schema_change" = "true"
|
||||
);
|
||||
"""
|
||||
qt_desc_tb "DESC ${tableName}"
|
||||
|
||||
sql """
|
||||
INSERT INTO ${tableName} VALUES
|
||||
(1, 'Beijing', 21474836478);
|
||||
"""
|
||||
qt_select_tb "SELECT * FROM ${tableName}"
|
||||
|
||||
sql """
|
||||
ALTER table ${tableName} ADD COLUMN value2 UNSIGNED INT;
|
||||
"""
|
||||
qt_desc_tb "DESC ${tableName}"
|
||||
|
||||
sql """
|
||||
INSERT INTO ${tableName} VALUES
|
||||
(2, 'Beijing', 21474836478, 21474836478);
|
||||
"""
|
||||
qt_select_tb "SELECT * FROM ${tableName} order by user_id"
|
||||
|
||||
sql "DROP TABLE ${tableName}"
|
||||
}
|
||||
Reference in New Issue
Block a user