You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
mysql> create table test_t1 (a int, b int) partition by range (b) (partition p0 values less than (10), partition p1 values less than (maxvalue));
mysql> alter table test_t1 add index p_a (a);
mysql> select * from information_schema.tikv_region_status where TABLE_NAME = 'test_t1'\G
Create a partitioned table with 2 partitions. every partition is a physical table.
Then create a index,the index is a local index(not global) of the partition.
use tableId、p0_id、p1_id as the physical table id of table test_t1、p0、p1.
partition p0 index key-value, the table id part of index key prefix should include p0_id, not tableId.
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
Create a partitioned table with 2 partitions. every partition is a physical table.
Then create a index,the index is a local index(not global) of the partition.
use tableId、p0_id、p1_id as the physical table id of table test_t1、p0、p1.
partition p0 index key-value, the table id part of index key prefix should include p0_id, not tableId.
tidb/store/helper/helper.go
Line 729 in 6d6e9c4
function GetTablesInfoWithKeyRange get error index key range.
the index range of partition table is wrong.
2. What did you expect to see? (Required)
mysql> create table test_t1 (a int, b int) partition by range (b) (partition p0 values less than (10), partition p1 values less than (maxvalue));
Query OK, 0 rows affected (0.12 sec)
mysql> show create table test_t1\G
*************************** 1. row ***************************
Table: test_t1
Create Table: CREATE TABLE
test_t1
(a
int(11) DEFAULT NULL,b
int(11) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY RANGE (
b
)(PARTITION
p0
VALUES LESS THAN (10),PARTITION
p1
VALUES LESS THAN (MAXVALUE))1 row in set (0.00 sec)
mysql> alter table test_t1 add index p_a (a);
Query OK, 0 rows affected (2.89 sec)
mysql> select * from information_schema.tikv_region_status where TABLE_NAME = 'test_t1'\G
*************************** 1. row ***************************
REGION_ID: 2
START_KEY: 7480000000000000FFBF00000000000000F8
END_KEY:
TABLE_ID: 189
DB_NAME: test
TABLE_NAME: test_t1
IS_INDEX: 1
INDEX_ID: 1
INDEX_NAME: p_a
EPOCH_CONF_VER: 1
EPOCH_VERSION: 79
WRITTEN_BYTES: 0
READ_BYTES: 4020450
APPROXIMATE_SIZE: 2
APPROXIMATE_KEYS: 7297
REPLICATIONSTATUS_STATE: NULL
REPLICATIONSTATUS_STATEID: NULL
*************************** 2. row ***************************
REGION_ID: 2
START_KEY: 7480000000000000FFBF00000000000000F8
END_KEY:
TABLE_ID: 189
DB_NAME: test
TABLE_NAME: test_t1
IS_INDEX: 0
INDEX_ID: NULL
INDEX_NAME: NULL
EPOCH_CONF_VER: 1
EPOCH_VERSION: 79
WRITTEN_BYTES: 0
READ_BYTES: 4020450
APPROXIMATE_SIZE: 2
APPROXIMATE_KEYS: 7297
REPLICATIONSTATUS_STATE: NULL
REPLICATIONSTATUS_STATEID: NULL
*************************** 3. row ***************************
REGION_ID: 5019
START_KEY: 7480000000000000FFBE00000000000000F8
END_KEY: 7480000000000000FFBF00000000000000F8
TABLE_ID: 189
DB_NAME: test
TABLE_NAME: test_t1
IS_INDEX: 1
INDEX_ID: 1
INDEX_NAME: p_a
EPOCH_CONF_VER: 1
EPOCH_VERSION: 79
WRITTEN_BYTES: 39
READ_BYTES: 0
APPROXIMATE_SIZE: 1
APPROXIMATE_KEYS: 0
REPLICATIONSTATUS_STATE: NULL
REPLICATIONSTATUS_STATEID: NULL
*************************** 4. row ***************************
REGION_ID: 5019
START_KEY: 7480000000000000FFBE00000000000000F8
END_KEY: 7480000000000000FFBF00000000000000F8
TABLE_ID: 189
DB_NAME: test
TABLE_NAME: test_t1
IS_INDEX: 0
INDEX_ID: NULL
INDEX_NAME: NULL
EPOCH_CONF_VER: 1
EPOCH_VERSION: 79
WRITTEN_BYTES: 39
READ_BYTES: 0
APPROXIMATE_SIZE: 1
APPROXIMATE_KEYS: 0
REPLICATIONSTATUS_STATE: NULL
REPLICATIONSTATUS_STATEID: NULL
4 rows in set (0.01 sec)
3. What did you see instead (Required)
mysql> create table test_t1 (a int, b int) partition by range (b) (partition p0 values less than (10), partition p1 values less than (maxvalue));
Query OK, 0 rows affected (0.12 sec)
mysql> show create table test_t1\G
*************************** 1. row ***************************
Table: test_t1
Create Table: CREATE TABLE
test_t1
(a
int(11) DEFAULT NULL,b
int(11) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY RANGE (
b
)(PARTITION
p0
VALUES LESS THAN (10),PARTITION
p1
VALUES LESS THAN (MAXVALUE))1 row in set (0.00 sec)
mysql> alter table test_t1 add index p_a (a);
Query OK, 0 rows affected (2.85 sec)
mysql> select * from information_schema.tikv_region_status where TABLE_NAME = 'test_t1'\G
*************************** 1. row ***************************
REGION_ID: 2
START_KEY: 7480000000000000FFCB00000000000000F8
END_KEY:
TABLE_ID: 201
DB_NAME: test
TABLE_NAME: test_t1
IS_INDEX: 0
INDEX_ID: NULL
INDEX_NAME: NULL
EPOCH_CONF_VER: 1
EPOCH_VERSION: 83
WRITTEN_BYTES: 219
READ_BYTES: 3572525
APPROXIMATE_SIZE: 2
APPROXIMATE_KEYS: 7929
REPLICATIONSTATUS_STATE: NULL
REPLICATIONSTATUS_STATEID: NULL
*************************** 2. row ***************************
REGION_ID: 5027
START_KEY: 7480000000000000FFCA00000000000000F8
END_KEY: 7480000000000000FFCB00000000000000F8
TABLE_ID: 201
DB_NAME: test
TABLE_NAME: test_t1
IS_INDEX: 0
INDEX_ID: NULL
INDEX_NAME: NULL
EPOCH_CONF_VER: 1
EPOCH_VERSION: 83
WRITTEN_BYTES: 39
READ_BYTES: 0
APPROXIMATE_SIZE: 1
APPROXIMATE_KEYS: 0
REPLICATIONSTATUS_STATE: NULL
REPLICATIONSTATUS_STATEID: NULL
*************************** 3. row ***************************
REGION_ID: 5025
START_KEY: 7480000000000000FFC500000000000000F8
END_KEY: 7480000000000000FFCA00000000000000F8
TABLE_ID: 201
DB_NAME: test
TABLE_NAME: test_t1
IS_INDEX: 1
INDEX_ID: 1
INDEX_NAME: p_a
EPOCH_CONF_VER: 1
EPOCH_VERSION: 82
WRITTEN_BYTES: 39
READ_BYTES: 0
APPROXIMATE_SIZE: 1
APPROXIMATE_KEYS: 0
REPLICATIONSTATUS_STATE: NULL
REPLICATIONSTATUS_STATEID: NULL
3 rows in set (0.01 sec)
4. What is your TiDB version? (Required)
mysql> SELECT tidb_version();
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v5.5.0-alpha-2416-g6d6e9c4-dirty
Edition: Community
Git Commit Hash: 6d6e9c4
Git Branch: master
UTC Build Time: 2022-10-29 12:44:07
GoVersion: go1.19.2
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.07 sec)
The text was updated successfully, but these errors were encountered: