V7.5.1 AUTO_RANDOM(5, 54) ID Length Restriction Invalidated

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: v7.5.1 AUTO_RANDOM(5, 54) id长度限制失效

| username: foxchan

[TiDB Usage Environment] Production Environment
[TiDB Version] 7.5.1
[Encountered Issue: Problem Phenomenon and Impact]
Setting the id length for a new table according to the official documentation

Table creation SQL

CREATE TABLE middle_data_salesman (
id bigint(11) NOT NULL /*T![auto_rand] AUTO_RANDOM(5, 54) */ COMMENT ‘Primary key id’,
promote_platform_type int(5) NOT NULL COMMENT ‘Third-party promotion platform type: 1 Douyin, 2 Youzan, 3 Kuaishou, 6 Video Account’,
relate_institution_id varchar(100) NOT NULL COMMENT ‘Third-party institution ID.’,
relate_institution_name varchar(100) DEFAULT NULL COMMENT ‘Third-party institution name.’,
role_type varchar(50) DEFAULT NULL COMMENT ‘Third-party role: leader is the group leader backend, mcn is the MCN backend, dk is the Douke backend, shop is the merchant backend, salesman is the influencer backend.’,
module_type varchar(50) DEFAULT NULL COMMENT ‘Module type: main is the main domain (most modules), finance is the financial domain (financial module).’,
task_type int(5) NOT NULL COMMENT ‘Task type: 1 influencer public pool, 2 group leader public pool, 3 merchant public pool, 4 MCN, 10000 general task’,
task_fast_flag int(5) NOT NULL COMMENT ‘Task mode: 1 normal, 2 key, 3 real-time’,
task_param text NOT NULL COMMENT ‘Task parameters: influencer public pool is Douyin ID, general task is URL + header + post parameters’,
task_status int(5) NOT NULL DEFAULT ‘0’ COMMENT ‘Task status: 0 not executed, 1 executing, 2 completed, 3 abandoned (timeout)’,
get_task_time datetime DEFAULT NULL COMMENT ‘Task acquisition time’,
finish_task_time datetime DEFAULT NULL COMMENT ‘Task completion time’,
task_result longtext DEFAULT NULL COMMENT ‘Task content’,
create_time datetime NOT NULL COMMENT ‘Creation time’,
PRIMARY KEY (id) /*T![clustered_index] CLUSTERED */,
KEY idx_task_create_time (create_time),
KEY idx_tastat (task_status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![auto_rand_base] AUTO_RANDOM_BASE=150001 */ COMMENT=‘Data module_crawler task table’

Result
image

| username: 小龙虾爱大龙虾 | Original post link

Just like in MySQL, the M in bigint(M) represents the display width and does not affect the range of values for the type.


Reference: 数值类型 | PingCAP 文档中心

| username: zhaokede | Original post link

AUTO_RANDOM is an 8-byte bigint integer.

| username: yiduoyunQ | Original post link

There is no problem with 15 digits in the screenshot.

| username: foxchan | Original post link

The table was placed incorrectly, so I edited the question content again.

| username: 濱崎悟空 | Original post link

auto_random is bigint

| username: Kongdom | Original post link

:thinking: According to the official documentation, the result here is not as expected, it might be a bug.