学习auto_random的时候,在实验环境创建一个表rd。
创建表语句
mysql> show create table rd \G
*************************** 1. row ***************************
Table: rd
Create Table: CREATE TABLE `rd` (
`id` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,
`name` char(4) DEFAULT NULL,
PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![auto_rand_base] AUTO_RANDOM_BASE=60001 */
1 row in set (0.00 sec)
在tidb-server中对表做如下操作
mysql> select tidb_row_id_sharding_info from information_schema.tables where table_name='rd' and table_schema='test';
+---------------------------+
| tidb_row_id_sharding_info |
+---------------------------+
| PK_AUTO_RANDOM_BITS=5 |
+---------------------------+
1 row in set (0.01 sec)
mysql> insert into rd(name) values ('Jac'),('Hua');
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
mysql> select * from rd;
+----+------+
| id | name |
+----+------+
| 1 | Jac |
| 2 | Hua |
+----+------+
2 rows in set (0.01 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
通过mysql图形客户端连接至另一个tidb-server,插入以下两行
insert into rd(name) values ('Vim'),('Tom');
commit;
返回原来的tidb-server
mysql> select * from rd;
+---------------------+------+
| id | name |
+---------------------+------+
| 1 | Jac |
| 2 | Hua |
| 6052837899185976625 | Vim |
| 6052837899185976626 | Tom |
+---------------------+------+
4 rows in set (0.00 sec)
mysql> insert into rd(name) values ('Coo'),('Jim');
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> select * from rd;
+---------------------+------+
| id | name |
+---------------------+------+
| 1 | Jac |
| 2 | Hua |
| 5764607523034234883 | Coo |
| 5764607523034234884 | Jim |
| 6052837899185976625 | Vim |
| 6052837899185976626 | Tom |
+---------------------+------+
6 rows in set (0.00 sec)
疑问
前面两行为什么是数字1 和 2 ???
bug???