Skip to content

return wrong results when accessing partition tables with tablesample #52282

@qw4990

Description

@qw4990

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> create table t (a int, b varchar(255), primary key (a)) partition by hash(a) partitions 2;
Query OK, 0 rows affected (0.02 sec)

mysql> insert into t values (1, '1'), (2, '2'), (3, '3');
Query OK, 3 rows affected (0.00 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> set @@tidb_partition_prune_mode='static';
Query OK, 0 rows affected (0.00 sec)

mysql> select * from t tablesample regions();
+---+------+
| a | b    |
+---+------+
| 2 | 2    |
| 1 | 1    |
| 2 | 2    |
| 1 | 1    |
+---+------+
4 rows in set (0.00 sec)

mysql> set @@tidb_partition_prune_mode='dynamic';
Query OK, 0 rows affected, 2 warnings (0.00 sec)

mysql> select * from t tablesample regions();
+---+------+
| a | b    |
+---+------+
| 2 | 2    |
| 1 | 1    |
+---+------+
2 rows in set (0.00 sec)

2. What did you expect to see? (Required)

Return the same result no matter whether it is dynamic or static node

3. What did you see instead (Required)

Dynamic and static mode return different results

4. What is your TiDB version? (Required)

Master

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions