-
Notifications
You must be signed in to change notification settings - Fork 489
Closed
Labels
Description
Bug Report
Please answer these questions before submitting your issue. Thanks!
- What did you do?
If possible, provide a recipe for reproducing the error.
create table t(a int);
-- SQL_1
SELECT t1.a AS a FROM (SELECT a FROM t) AS t1;
-- SQL_2
SELECT t1.a AS a FROM ((SELECT a FROM t) AS t1);
- What did you expect to see?
As MySQL, there should be no syntax error for SQL_1 and SQL_2.
- What did you see instead?
SQL_1 successes, while SQL_2 fails.
- What version of TiDB SQL Parser are you using?
I tried to change the SetOprStmt1 in line 8021 back to SelectStmt, the above problem can be fixed, but there would be some test failures for set operations.
8010 TableFactor:
8011 TableName PartitionNameListOpt TableAsNameOpt IndexHintListOpt TableSampleOpt
8012 {
8013 tn := $1.(*ast.TableName)
8014 tn.PartitionNames = $2.([]model.CIStr)
8015 tn.IndexHints = $4.([]*ast.IndexHint)
8016 if $5 != nil {
8017 tn.TableSample = $5.(*ast.TableSample)
8018 }
8019 $$ = &ast.TableSource{Source: tn, AsName: $3.(model.CIStr)}
8020 }
8021 | '(' SetOprStmt1 ')' TableAsNameOpt
8022 {
8023 if st, isSel := $2.(*ast.SelectStmt); isSel {
8024 endOffset := parser.endOffset(&yyS[yypt-1])
8025 parser.setLastSelectFieldText(st, endOffset)
8026 }
8027 $$ = &ast.TableSource{Source: $2.(ast.ResultSetNode), AsName: $4.(model.CIStr)}
8028 }
8029 | '(' TableRefs ')'
8030 {
8031 $$ = $2
8032 }
Reactions are currently unavailable