From eeeb53ac6757ebef6e6881eccd8acb9885cdf230 Mon Sep 17 00:00:00 2001 From: Jason Mo Date: Fri, 29 Dec 2023 10:15:39 +0800 Subject: [PATCH] parser: fix limit lost in SetOprStmt --- pkg/parser/parser.go | 36 ++++++++++++++++++++++++++++++------ pkg/parser/parser.y | 36 ++++++++++++++++++++++++++++++------ 2 files changed, 60 insertions(+), 12 deletions(-) diff --git a/pkg/parser/parser.go b/pkg/parser/parser.go index 76a1f7134f5be..89db7b3b6385c 100644 --- a/pkg/parser/parser.go +++ b/pkg/parser/parser.go @@ -19931,6 +19931,8 @@ yynewstate: } var setOprList2 []ast.Node var with2 *ast.WithClause + var limit2 *ast.Limit + var orderBy2 *ast.OrderByClause switch x := yyS[yypt-1].expr.(*ast.SubqueryExpr).Query.(type) { case *ast.SelectStmt: setOprList2 = []ast.Node{x} @@ -19938,8 +19940,10 @@ yynewstate: case *ast.SetOprStmt: setOprList2 = x.SelectList.Selects with2 = x.With + limit2 = x.Limit + orderBy2 = x.OrderBy } - nextSetOprList := &ast.SetOprSelectList{Selects: setOprList2, With: with2} + nextSetOprList := &ast.SetOprSelectList{Selects: setOprList2, With: with2, Limit: limit2, OrderBy: orderBy2} nextSetOprList.AfterSetOperator = yyS[yypt-2].item.(*ast.SetOprType) setOprList := append(setOprList1, nextSetOprList) setOpr := &ast.SetOprStmt{SelectList: &ast.SetOprSelectList{Selects: setOprList}} @@ -19955,6 +19959,8 @@ yynewstate: } var setOprList2 []ast.Node var with2 *ast.WithClause + var limit2 *ast.Limit + var orderBy2 *ast.OrderByClause switch x := yyS[yypt-1].expr.(*ast.SubqueryExpr).Query.(type) { case *ast.SelectStmt: setOprList2 = []ast.Node{x} @@ -19962,8 +19968,10 @@ yynewstate: case *ast.SetOprStmt: setOprList2 = x.SelectList.Selects with2 = x.With + limit2 = x.Limit + orderBy2 = x.OrderBy } - nextSetOprList := &ast.SetOprSelectList{Selects: setOprList2, With: with2} + nextSetOprList := &ast.SetOprSelectList{Selects: setOprList2, With: with2, Limit: limit2, OrderBy: orderBy2} nextSetOprList.AfterSetOperator = yyS[yypt-2].item.(*ast.SetOprType) setOprList := append(setOprList1, nextSetOprList) setOpr := &ast.SetOprStmt{SelectList: &ast.SetOprSelectList{Selects: setOprList}} @@ -19979,6 +19987,8 @@ yynewstate: } var setOprList2 []ast.Node var with2 *ast.WithClause + var limit2 *ast.Limit + var orderBy2 *ast.OrderByClause switch x := yyS[yypt-2].expr.(*ast.SubqueryExpr).Query.(type) { case *ast.SelectStmt: setOprList2 = []ast.Node{x} @@ -19986,8 +19996,10 @@ yynewstate: case *ast.SetOprStmt: setOprList2 = x.SelectList.Selects with2 = x.With + limit2 = x.Limit + orderBy2 = x.OrderBy } - nextSetOprList := &ast.SetOprSelectList{Selects: setOprList2, With: with2} + nextSetOprList := &ast.SetOprSelectList{Selects: setOprList2, With: with2, Limit: limit2, OrderBy: orderBy2} nextSetOprList.AfterSetOperator = yyS[yypt-3].item.(*ast.SetOprType) setOprList := append(setOprList1, nextSetOprList) setOpr := &ast.SetOprStmt{SelectList: &ast.SetOprSelectList{Selects: setOprList}} @@ -19999,6 +20011,8 @@ yynewstate: { var setOprList []ast.Node var with *ast.WithClause + var limit *ast.Limit + var orderBy *ast.OrderByClause switch x := yyS[yypt-1].expr.(*ast.SubqueryExpr).Query.(type) { case *ast.SelectStmt: setOprList = []ast.Node{x} @@ -20006,8 +20020,10 @@ yynewstate: case *ast.SetOprStmt: setOprList = x.SelectList.Selects with = x.With + limit = x.Limit + orderBy = x.OrderBy } - setOpr := &ast.SetOprStmt{SelectList: &ast.SetOprSelectList{Selects: setOprList}, With: with} + setOpr := &ast.SetOprStmt{SelectList: &ast.SetOprSelectList{Selects: setOprList}, With: with, Limit: limit, OrderBy: orderBy} setOpr.OrderBy = yyS[yypt-0].item.(*ast.OrderByClause) parser.yyVAL.statement = setOpr } @@ -20015,6 +20031,8 @@ yynewstate: { var setOprList []ast.Node var with *ast.WithClause + var limit *ast.Limit + var orderBy *ast.OrderByClause switch x := yyS[yypt-1].expr.(*ast.SubqueryExpr).Query.(type) { case *ast.SelectStmt: setOprList = []ast.Node{x} @@ -20022,8 +20040,10 @@ yynewstate: case *ast.SetOprStmt: setOprList = x.SelectList.Selects with = x.With + limit = x.Limit + orderBy = x.OrderBy } - setOpr := &ast.SetOprStmt{SelectList: &ast.SetOprSelectList{Selects: setOprList}, With: with} + setOpr := &ast.SetOprStmt{SelectList: &ast.SetOprSelectList{Selects: setOprList}, With: with, Limit: limit, OrderBy: orderBy} setOpr.Limit = yyS[yypt-0].item.(*ast.Limit) parser.yyVAL.statement = setOpr } @@ -20031,6 +20051,8 @@ yynewstate: { var setOprList []ast.Node var with *ast.WithClause + var limit *ast.Limit + var orderBy *ast.OrderByClause switch x := yyS[yypt-2].expr.(*ast.SubqueryExpr).Query.(type) { case *ast.SelectStmt: setOprList = []ast.Node{x} @@ -20038,8 +20060,10 @@ yynewstate: case *ast.SetOprStmt: setOprList = x.SelectList.Selects with = x.With + limit = x.Limit + orderBy = x.OrderBy } - setOpr := &ast.SetOprStmt{SelectList: &ast.SetOprSelectList{Selects: setOprList}, With: with} + setOpr := &ast.SetOprStmt{SelectList: &ast.SetOprSelectList{Selects: setOprList}, With: with, Limit: limit, OrderBy: orderBy} setOpr.OrderBy = yyS[yypt-1].item.(*ast.OrderByClause) setOpr.Limit = yyS[yypt-0].item.(*ast.Limit) parser.yyVAL.statement = setOpr diff --git a/pkg/parser/parser.y b/pkg/parser/parser.y index ef5bebda7edf1..84e09d386df9f 100644 --- a/pkg/parser/parser.y +++ b/pkg/parser/parser.y @@ -10260,6 +10260,8 @@ SetOprStmtWithLimitOrderBy: } var setOprList2 []ast.Node var with2 *ast.WithClause + var limit2 *ast.Limit + var orderBy2 *ast.OrderByClause switch x := $3.(*ast.SubqueryExpr).Query.(type) { case *ast.SelectStmt: setOprList2 = []ast.Node{x} @@ -10267,8 +10269,10 @@ SetOprStmtWithLimitOrderBy: case *ast.SetOprStmt: setOprList2 = x.SelectList.Selects with2 = x.With + limit2 = x.Limit + orderBy2 = x.OrderBy } - nextSetOprList := &ast.SetOprSelectList{Selects: setOprList2, With: with2} + nextSetOprList := &ast.SetOprSelectList{Selects: setOprList2, With: with2, Limit: limit2, OrderBy: orderBy2} nextSetOprList.AfterSetOperator = $2.(*ast.SetOprType) setOprList := append(setOprList1, nextSetOprList) setOpr := &ast.SetOprStmt{SelectList: &ast.SetOprSelectList{Selects: setOprList}} @@ -10284,6 +10288,8 @@ SetOprStmtWithLimitOrderBy: } var setOprList2 []ast.Node var with2 *ast.WithClause + var limit2 *ast.Limit + var orderBy2 *ast.OrderByClause switch x := $3.(*ast.SubqueryExpr).Query.(type) { case *ast.SelectStmt: setOprList2 = []ast.Node{x} @@ -10291,8 +10297,10 @@ SetOprStmtWithLimitOrderBy: case *ast.SetOprStmt: setOprList2 = x.SelectList.Selects with2 = x.With + limit2 = x.Limit + orderBy2 = x.OrderBy } - nextSetOprList := &ast.SetOprSelectList{Selects: setOprList2, With: with2} + nextSetOprList := &ast.SetOprSelectList{Selects: setOprList2, With: with2, Limit: limit2, OrderBy: orderBy2} nextSetOprList.AfterSetOperator = $2.(*ast.SetOprType) setOprList := append(setOprList1, nextSetOprList) setOpr := &ast.SetOprStmt{SelectList: &ast.SetOprSelectList{Selects: setOprList}} @@ -10308,6 +10316,8 @@ SetOprStmtWithLimitOrderBy: } var setOprList2 []ast.Node var with2 *ast.WithClause + var limit2 *ast.Limit + var orderBy2 *ast.OrderByClause switch x := $3.(*ast.SubqueryExpr).Query.(type) { case *ast.SelectStmt: setOprList2 = []ast.Node{x} @@ -10315,8 +10325,10 @@ SetOprStmtWithLimitOrderBy: case *ast.SetOprStmt: setOprList2 = x.SelectList.Selects with2 = x.With + limit2 = x.Limit + orderBy2 = x.OrderBy } - nextSetOprList := &ast.SetOprSelectList{Selects: setOprList2, With: with2} + nextSetOprList := &ast.SetOprSelectList{Selects: setOprList2, With: with2, Limit: limit2, OrderBy: orderBy2} nextSetOprList.AfterSetOperator = $2.(*ast.SetOprType) setOprList := append(setOprList1, nextSetOprList) setOpr := &ast.SetOprStmt{SelectList: &ast.SetOprSelectList{Selects: setOprList}} @@ -10328,6 +10340,8 @@ SetOprStmtWithLimitOrderBy: { var setOprList []ast.Node var with *ast.WithClause + var limit *ast.Limit + var orderBy *ast.OrderByClause switch x := $1.(*ast.SubqueryExpr).Query.(type) { case *ast.SelectStmt: setOprList = []ast.Node{x} @@ -10335,8 +10349,10 @@ SetOprStmtWithLimitOrderBy: case *ast.SetOprStmt: setOprList = x.SelectList.Selects with = x.With + limit = x.Limit + orderBy = x.OrderBy } - setOpr := &ast.SetOprStmt{SelectList: &ast.SetOprSelectList{Selects: setOprList}, With: with} + setOpr := &ast.SetOprStmt{SelectList: &ast.SetOprSelectList{Selects: setOprList}, With: with, Limit: limit, OrderBy: orderBy} setOpr.OrderBy = $2.(*ast.OrderByClause) $$ = setOpr } @@ -10344,6 +10360,8 @@ SetOprStmtWithLimitOrderBy: { var setOprList []ast.Node var with *ast.WithClause + var limit *ast.Limit + var orderBy *ast.OrderByClause switch x := $1.(*ast.SubqueryExpr).Query.(type) { case *ast.SelectStmt: setOprList = []ast.Node{x} @@ -10351,8 +10369,10 @@ SetOprStmtWithLimitOrderBy: case *ast.SetOprStmt: setOprList = x.SelectList.Selects with = x.With + limit = x.Limit + orderBy = x.OrderBy } - setOpr := &ast.SetOprStmt{SelectList: &ast.SetOprSelectList{Selects: setOprList}, With: with} + setOpr := &ast.SetOprStmt{SelectList: &ast.SetOprSelectList{Selects: setOprList}, With: with, Limit: limit, OrderBy: orderBy} setOpr.Limit = $2.(*ast.Limit) $$ = setOpr } @@ -10360,6 +10380,8 @@ SetOprStmtWithLimitOrderBy: { var setOprList []ast.Node var with *ast.WithClause + var limit *ast.Limit + var orderBy *ast.OrderByClause switch x := $1.(*ast.SubqueryExpr).Query.(type) { case *ast.SelectStmt: setOprList = []ast.Node{x} @@ -10367,8 +10389,10 @@ SetOprStmtWithLimitOrderBy: case *ast.SetOprStmt: setOprList = x.SelectList.Selects with = x.With + limit = x.Limit + orderBy = x.OrderBy } - setOpr := &ast.SetOprStmt{SelectList: &ast.SetOprSelectList{Selects: setOprList}, With: with} + setOpr := &ast.SetOprStmt{SelectList: &ast.SetOprSelectList{Selects: setOprList}, With: with, Limit: limit, OrderBy: orderBy} setOpr.OrderBy = $2.(*ast.OrderByClause) setOpr.Limit = $3.(*ast.Limit) $$ = setOpr