pingcap / pingcap/tidb

got incorrect result while using cross join

Open
#33,143 1 comment 0 reactions 0 assignees View on GitHub
affects-4.0 affects-5.0 affects-5.1 affects-5.2 affects-5.3 affects-5.4 affects-6.0 severity/minor sig/execution 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)

```
--------------------
SELECT SUM(t.ROWN+t2.ROWN) FROM(
SELECT
@ROWN := @ROWN + 1 AS ROWN
FROM
(
SELECT 0 UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9
) t,
( SELECT @ROWN :=- 1 ) r
) t
JOIN(
SELECT
@ROWN := @ROWN + 1 AS ROWN
FROM
(
SELECT 0 UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9
) t,
( SELECT @ROWN :=- 1 ) r
) t2
--------------------
```

### 2. What did you expect to see? (Required)
the result should be 1900
### 3. What did you see instead (Required)
got different result(like 1540,1710,1900...) while running many times
### 4. What is your TiDB version? (Required)

Release Version: v5.3.0
Edition: Community
Git Commit Hash: 4a1b2e9fe5b5afb1068c56de47adb07098d768d6
Git Branch: heads/refs/tags/v5.3.0
UTC Build Time: 2021-11-24 13:32:39
GoVersion: go1.16.4
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.