pingcap / pingcap/tidb

TiDB should not allow to analyze different partitions of a table with different analyze versions

Open
#51,181 0 comments 0 reactions 1 assignee Claimed by @0xPoe View on GitHub
component/statistics severity/moderate sig/planner type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)

1. Create a partitioned table:
```sql
CREATE TABLE employees (
id INT NOT NULL,
fname VARCHAR(30),
lname VARCHAR(30),
hired DATE NOT NULL DEFAULT '1970-01-01',
separated DATE DEFAULT '9999-12-31',
job_code INT,
store_id INT NOT NULL
) PARTITION BY RANGE (id) (
PARTITION p0 VALUES LESS THAN (1000),
PARTITION p1 VALUES LESS THAN (2000),
PARTITION p2 VALUES LESS THAN (3000),
PARTITION p3 VALUES LESS THAN MAXVALUE
);
INSERT INTO employees (id, fname, lname, hired, store_id)
VALUES (100, 'John', 'Doe', '2024-02-19', 1);
INSERT INTO employees (id, fname, lname, hired, store_id)
VALUES (2000, 'Alice', 'Smith', '2024-02-19', 2);
```

2. Analyze them in different sessions:
```sql
set @@session.tidb_analyze_version=2;
analyze table employees partition p0;
```

3. Another session:

```sql
set @@session.tidb_analyze_version=1;
analyze table employees partition p2;
```

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

An error to tell users this won't work.

### 3. What did you see instead (Required)
Analyzed the table with different versions:
![img_v3_0287_2637a833-8fd7-46ae-a945-1d746cdb41cg](https://github.com/pingcap/tidb/assets/29879298/0cdef7b9-126e-47c9-afbc-130f675a6286)
![img_v3_0287_62bb3a4e-bc24-4bdd-92bd-aaad82197e8g](https://github.com/pingcap/tidb/assets/29879298/4e54e866-09b9-4b5f-b197-16bcc2f60a04)

### 4. What is your TiDB version? (Required)

master

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.