pingcap / pingcap/tidb

query result of union statement is not stable

Open
#34,859 0 comments 0 reactions 0 assignees View on GitHub
type/compatibility
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)

```sql
SELECT 1 AS col1, 2 AS col2 UNION SELECT 3, 4;
```

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

A stable result, like MySQL result is always:

```sql
test> SELECT 1 AS col1, 2 AS col2 UNION SELECT 3, 4;
+------+------+
| col1 | col2 |
+------+------+
| 1 | 2 |
| 3 | 4 |
+------+------+
2 rows in set
```

### 3. What did you see instead (Required)

unstable result:

```
test> SELECT 1 AS col1, 2 AS col2 UNION SELECT 3, 4;
+------+------+
| col1 | col2 |
+------+------+
| 1 | 2 |
| 3 | 4 |
+------+------+
2 rows in set
Time: 0.005s
test> SELECT 1 AS col1, 2 AS col2 UNION SELECT 3, 4;
+------+------+
| col1 | col2 |
+------+------+
| 3 | 4 |
| 1 | 2 |
+------+------+
2 rows in set
Time: 0.005s
```

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

```sql
***************************[ 1. row ]***************************
tidb_version() | Release Version: v6.1.0-alpha-432-gd75b06ec97
Edition: Community
Git Commit Hash: d75b06ec97e54ef9f5a15630e7dfee30d22f047e
Git Branch: master
UTC Build Time: 2022-05-17 07:29:42
GoVersion: go1.18
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
```

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.