parser: support plan change capture collect stmt (#41478)

ref pingcap/tidb#41130
This commit is contained in:
Song Gao
2023-02-20 10:31:05 +08:00
committed by GitHub
parent 60dda6976e
commit 301a024ebc
8 changed files with 370 additions and 234 deletions

View File

@ -66,6 +66,7 @@ go_library(
"parallel_apply.go",
"partition_table.go",
"pipelined_window.go",
"plan_change_capture.go",
"plan_replayer.go",
"point_get.go",
"prepared.go",

View File

@ -1017,6 +1017,25 @@ func (b *executorBuilder) buildIndexAdvise(v *plannercore.IndexAdvise) Executor
return e
}
func (b *executorBuilder) buildPlanChangeCapture(v *plannercore.PlanChangeCapture) Executor {
e := &PlanChangeCaptureExec{
baseExecutor: newBaseExecutor(b.ctx, v.Schema(), v.ID()),
}
begin, err := time.Parse("2006-01-02 15:04:05", v.Begin)
if err != nil {
e.err = err
return e
}
end, err := time.Parse("2006-01-02 15:04:05", v.End)
if err != nil {
e.err = err
return e
}
e.Begin = begin
e.End = end
return e
}
func (b *executorBuilder) buildPlanReplayer(v *plannercore.PlanReplayer) Executor {
if v.Load {
e := &PlanReplayerLoadExec{

View File

@ -0,0 +1,42 @@
// Copyright 2023 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package executor
import (
"context"
"time"
"github.com/pingcap/tidb/util/chunk"
)
var _ Executor = &PlanChangeCaptureExec{}
// PlanChangeCaptureExec indicates PlanChangeCaptureExec
type PlanChangeCaptureExec struct {
baseExecutor
Begin time.Time
End time.Time
err error
}
// Next Implements Executor
func (e *PlanChangeCaptureExec) Next(ctx context.Context, req *chunk.Chunk) error {
req.GrowAndReset(e.maxChunkSize)
if e.err != nil {
return e.err
}
return nil
}

View File

@ -259,6 +259,32 @@ func (n *ExplainStmt) Accept(v Visitor) (Node, bool) {
return v.Leave(n)
}
// PlanChangeCaptureStmt is a statement to dump or load information for recreating plans
type PlanChangeCaptureStmt struct {
stmtNode
Begin string
End string
}
// Restore implements Node interface.
func (n *PlanChangeCaptureStmt) Restore(ctx *format.RestoreCtx) error {
ctx.WriteKeyWord("PLAN CHANGE CAPTURE ")
ctx.WriteString(n.Begin)
ctx.WriteKeyWord(" ")
ctx.WriteString(n.End)
return nil
}
// Accept implements Node Accept interface.
func (n *PlanChangeCaptureStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
if skipChildren {
return v.Leave(newNode)
}
n = newNode.(*PlanChangeCaptureStmt)
return v.Leave(n)
}
// PlanReplayerStmt is a statement to dump or load information for recreating plans
type PlanReplayerStmt struct {
stmtNode

View File

@ -1544,8 +1544,8 @@ var (
58369: 686, // Identifier (510x)
58449: 687, // NotKeywordToken (510x)
57529: 688, // sql (510x)
58681: 689, // TiDBKeyword (510x)
58691: 690, // UnReservedKeyword (510x)
58682: 689, // TiDBKeyword (510x)
58692: 690, // UnReservedKeyword (510x)
57411: 691, // drop (505x)
57376: 692, // cascade (504x)
57506: 693, // read (504x)
@ -1587,11 +1587,11 @@ var (
57543: 729, // tinyblobType (495x)
57544: 730, // tinyIntType (495x)
57545: 731, // tinytextType (495x)
58646: 732, // SubSelect (224x)
58701: 733, // UserVariable (182x)
58621: 734, // SimpleIdent (181x)
58647: 732, // SubSelect (224x)
58702: 733, // UserVariable (182x)
58622: 734, // SimpleIdent (181x)
58422: 735, // Literal (180x)
58636: 736, // StringLiteral (180x)
58637: 736, // StringLiteral (180x)
58446: 737, // NextValueForSequence (178x)
58346: 738, // FunctionCallGeneric (177x)
58347: 739, // FunctionCallKeyword (177x)
@ -1602,21 +1602,21 @@ var (
58352: 744, // FunctionNameDatetimePrecision (177x)
58353: 745, // FunctionNameOptionalBraces (177x)
58354: 746, // FunctionNameSequence (177x)
58620: 747, // SimpleExpr (177x)
58647: 748, // SumExpr (177x)
58649: 749, // SystemVariable (177x)
58712: 750, // Variable (177x)
58735: 751, // WindowFuncCall (177x)
58621: 747, // SimpleExpr (177x)
58648: 748, // SumExpr (177x)
58650: 749, // SystemVariable (177x)
58713: 750, // Variable (177x)
58736: 751, // WindowFuncCall (177x)
58189: 752, // BitExpr (163x)
58523: 753, // PredicateExpr (132x)
58524: 753, // PredicateExpr (132x)
58192: 754, // BoolPri (129x)
58310: 755, // Expression (129x)
58444: 756, // NUM (108x)
58750: 757, // logAnd (97x)
58751: 758, // logOr (97x)
58751: 757, // logAnd (97x)
58752: 758, // logOr (97x)
58300: 759, // EqOpt (80x)
58659: 760, // TableName (78x)
58637: 761, // StringName (56x)
58660: 760, // TableName (78x)
58638: 761, // StringName (56x)
57403: 762, // deleteKwd (53x)
58413: 763, // LengthNum (47x)
57553: 764, // unsigned (47x)
@ -1625,43 +1625,43 @@ var (
58214: 767, // ColumnName (41x)
57407: 768, // distinct (36x)
57408: 769, // distinctRow (36x)
58740: 770, // WindowingClause (35x)
58574: 771, // SelectStmt (34x)
58575: 772, // SelectStmtBasic (34x)
58577: 773, // SelectStmtFromDualTable (34x)
58578: 774, // SelectStmtFromTable (34x)
58595: 775, // SetOprClause (34x)
58741: 770, // WindowingClause (35x)
58575: 771, // SelectStmt (34x)
58576: 772, // SelectStmtBasic (34x)
58578: 773, // SelectStmtFromDualTable (34x)
58579: 774, // SelectStmtFromTable (34x)
58596: 775, // SetOprClause (34x)
57402: 776, // delayed (33x)
57433: 777, // highPriority (33x)
57475: 778, // lowPriority (33x)
58596: 779, // SetOprClauseList (33x)
58599: 780, // SetOprStmtWithLimitOrderBy (33x)
58600: 781, // SetOprStmtWoutLimitOrderBy (33x)
58741: 782, // WithClause (31x)
58587: 783, // SelectStmtWithClause (30x)
58598: 784, // SetOprStmt (30x)
58597: 779, // SetOprClauseList (33x)
58600: 780, // SetOprStmtWithLimitOrderBy (33x)
58601: 781, // SetOprStmtWoutLimitOrderBy (33x)
58742: 782, // WithClause (31x)
58588: 783, // SelectStmtWithClause (30x)
58599: 784, // SetOprStmt (30x)
58401: 785, // Int64Num (28x)
57355: 786, // hintComment (27x)
58321: 787, // FieldLen (25x)
58489: 788, // OptWindowingClause (24x)
58695: 789, // UpdateStmtNoWith (24x)
58696: 789, // UpdateStmtNoWith (24x)
58273: 790, // DeleteWithoutUsingStmt (23x)
58495: 791, // OrderBy (23x)
58581: 792, // SelectStmtLimit (23x)
58582: 792, // SelectStmtLimit (23x)
57530: 793, // sqlBigResult (23x)
57531: 794, // sqlCalcFoundRows (23x)
57532: 795, // sqlSmallResult (23x)
58398: 796, // InsertIntoStmt (21x)
58545: 797, // ReplaceIntoStmt (21x)
58694: 798, // UpdateStmt (21x)
58546: 797, // ReplaceIntoStmt (21x)
58695: 798, // UpdateStmt (21x)
58203: 799, // CharsetKw (20x)
58703: 800, // Username (20x)
58704: 800, // Username (20x)
58370: 801, // IfExists (19x)
58311: 802, // ExpressionList (18x)
58272: 803, // DeleteWithUsingStmt (17x)
57494: 804, // optionally (17x)
58518: 805, // PlacementPolicyOption (17x)
58660: 806, // TableNameList (17x)
58661: 806, // TableNameList (17x)
58371: 807, // IfNotExists (16x)
57541: 808, // terminated (16x)
58271: 809, // DeleteFromStmt (15x)
@ -1670,21 +1670,21 @@ var (
58507: 812, // PartitionNameList (15x)
58277: 813, // DistinctOpt (14x)
58474: 814, // OptFieldLen (14x)
58683: 815, // TimestampUnit (14x)
58725: 816, // WhereClause (14x)
58726: 817, // WhereClauseOptional (14x)
58684: 815, // TimestampUnit (14x)
58726: 816, // WhereClause (14x)
58727: 817, // WhereClauseOptional (14x)
58268: 818, // DefaultKwdOpt (13x)
57415: 819, // escaped (13x)
58309: 820, // ExprOrDefault (12x)
58407: 821, // JoinTable (12x)
58468: 822, // OptBinary (12x)
57511: 823, // release (12x)
58564: 824, // RolenameComposed (12x)
58656: 825, // TableFactor (12x)
58669: 826, // TableRef (12x)
58565: 824, // RolenameComposed (12x)
58657: 825, // TableFactor (12x)
58670: 826, // TableRef (12x)
58161: 827, // AnalyzeOptionListOpt (11x)
58341: 828, // FromOrIn (11x)
58682: 829, // TimeUnit (11x)
58683: 829, // TimeUnit (11x)
58157: 830, // AlterTableStmt (10x)
58204: 831, // CharsetName (10x)
58215: 832, // ColumnNameList (10x)
@ -1694,13 +1694,13 @@ var (
57485: 836, // noWriteToBinLog (10x)
58496: 837, // OrderByOptional (10x)
58498: 838, // PartDefOption (10x)
58619: 839, // SignedNum (10x)
58620: 839, // SignedNum (10x)
58195: 840, // BuggyDefaultFalseDistinctOpt (9x)
58267: 841, // DefaultFalseDistinctOpt (9x)
58408: 842, // JoinType (9x)
58458: 843, // NumLiteral (9x)
58563: 844, // Rolename (9x)
58558: 845, // RoleNameString (9x)
58564: 844, // Rolename (9x)
58559: 845, // RoleNameString (9x)
58256: 846, // CrossOpt (8x)
58301: 847, // EqOrAssignmentEq (8x)
58308: 848, // ExplainableStmt (8x)
@ -1708,20 +1708,20 @@ var (
58392: 850, // IndexPartSpecification (8x)
58409: 851, // KeyOrIndex (8x)
58447: 852, // NoWriteToBinLogAliasOpt (8x)
58582: 853, // SelectStmtLimitOpt (8x)
58715: 854, // VariableName (8x)
58583: 853, // SelectStmtLimitOpt (8x)
58716: 854, // VariableName (8x)
58142: 855, // AllOrPartitionNameList (7x)
58239: 856, // ConstraintKeywordOpt (7x)
58263: 857, // DatabaseSym (7x)
58327: 858, // FieldsOrColumns (7x)
58339: 859, // ForceOpt (7x)
58393: 860, // IndexPartSpecificationList (7x)
58527: 861, // Priority (7x)
58568: 862, // RowFormat (7x)
58571: 863, // RowValue (7x)
58593: 864, // SetExpr (7x)
58605: 865, // ShowDatabaseNameOpt (7x)
58666: 866, // TableOption (7x)
58528: 861, // Priority (7x)
58569: 862, // RowFormat (7x)
58572: 863, // RowValue (7x)
58594: 864, // SetExpr (7x)
58606: 865, // ShowDatabaseNameOpt (7x)
58667: 866, // TableOption (7x)
57566: 867, // varying (7x)
58162: 868, // AnalyzeTableStmt (6x)
58184: 869, // BeginTransactionStmt (6x)
@ -1740,15 +1740,15 @@ var (
58426: 882, // LoadDataStmt (6x)
58427: 883, // LoadDataWithFormatStmt (6x)
58508: 884, // PartitionNameListOpt (6x)
58540: 885, // ReleaseSavepointStmt (6x)
58565: 886, // RolenameList (6x)
58567: 887, // RollbackStmt (6x)
58572: 888, // SavepointStmt (6x)
58603: 889, // SetStmt (6x)
58541: 885, // ReleaseSavepointStmt (6x)
58566: 886, // RolenameList (6x)
58568: 887, // RollbackStmt (6x)
58573: 888, // SavepointStmt (6x)
58604: 889, // SetStmt (6x)
57526: 890, // show (6x)
58664: 891, // TableOptimizerHints (6x)
58704: 892, // UsernameList (6x)
58742: 893, // WithClustered (6x)
58665: 891, // TableOptimizerHints (6x)
58705: 892, // UsernameList (6x)
58743: 893, // WithClustered (6x)
58140: 894, // AlgorithmClause (5x)
58197: 895, // ByItem (5x)
58208: 896, // CollationName (5x)
@ -1766,13 +1766,13 @@ var (
58431: 908, // LockClause (5x)
58470: 909, // OptCharsetWithOptBinary (5x)
58481: 910, // OptNullTreatment (5x)
58521: 911, // PolicyName (5x)
58528: 912, // PriorityOpt (5x)
58550: 913, // ResourceGroupName (5x)
58573: 914, // SelectLockOpt (5x)
58580: 915, // SelectStmtIntoOption (5x)
58670: 916, // TableRefs (5x)
58697: 917, // UserSpec (5x)
58522: 911, // PolicyName (5x)
58529: 912, // PriorityOpt (5x)
58551: 913, // ResourceGroupName (5x)
58574: 914, // SelectLockOpt (5x)
58581: 915, // SelectStmtIntoOption (5x)
58671: 916, // TableRefs (5x)
58698: 917, // UserSpec (5x)
58168: 918, // Assignment (4x)
58174: 919, // AuthString (4x)
58176: 920, // BRIEBooleanOptionName (4x)
@ -1791,22 +1791,22 @@ var (
57493: 933, // option (4x)
58486: 934, // OptWild (4x)
57497: 935, // outer (4x)
58522: 936, // Precision (4x)
58536: 937, // ReferDef (4x)
58554: 938, // RestrictOrCascadeOpt (4x)
58570: 939, // RowStmt (4x)
58588: 940, // SequenceOption (4x)
58523: 936, // Precision (4x)
58537: 937, // ReferDef (4x)
58555: 938, // RestrictOrCascadeOpt (4x)
58571: 939, // RowStmt (4x)
58589: 940, // SequenceOption (4x)
57535: 941, // statsExtended (4x)
58651: 942, // TableAsName (4x)
58652: 943, // TableAsNameOpt (4x)
58663: 944, // TableNameOptWild (4x)
58665: 945, // TableOptimizerHintsOpt (4x)
58667: 946, // TableOptionList (4x)
58678: 947, // TextString (4x)
58685: 948, // TraceableStmt (4x)
58686: 949, // TransactionChar (4x)
58698: 950, // UserSpecList (4x)
58736: 951, // WindowName (4x)
58652: 942, // TableAsName (4x)
58653: 943, // TableAsNameOpt (4x)
58664: 944, // TableNameOptWild (4x)
58666: 945, // TableOptimizerHintsOpt (4x)
58668: 946, // TableOptionList (4x)
58679: 947, // TextString (4x)
58686: 948, // TraceableStmt (4x)
58687: 949, // TransactionChar (4x)
58699: 950, // UserSpecList (4x)
58737: 951, // WindowName (4x)
58165: 952, // AsOfClause (3x)
58169: 953, // AssignmentList (3x)
58171: 954, // AttributesOpt (3x)
@ -1839,30 +1839,30 @@ var (
58499: 981, // PartDefOptionList (3x)
58501: 982, // PartitionDefinition (3x)
58512: 983, // PasswordOrLockOption (3x)
58520: 984, // PluginNameList (3x)
58526: 985, // PrimaryOpt (3x)
58529: 986, // PrivElem (3x)
58531: 987, // PrivType (3x)
58521: 984, // PluginNameList (3x)
58527: 985, // PrimaryOpt (3x)
58530: 986, // PrivElem (3x)
58532: 987, // PrivType (3x)
57503: 988, // procedure (3x)
58546: 989, // RequireClause (3x)
58547: 990, // RequireClauseOpt (3x)
58549: 991, // RequireListElement (3x)
58566: 992, // RolenameWithoutIdent (3x)
58559: 993, // RoleOrPrivElem (3x)
58579: 994, // SelectStmtGroup (3x)
58597: 995, // SetOprOpt (3x)
58650: 996, // TableAliasRefList (3x)
58653: 997, // TableElement (3x)
58662: 998, // TableNameListOpt2 (3x)
58687: 999, // TransactionChars (3x)
58547: 989, // RequireClause (3x)
58548: 990, // RequireClauseOpt (3x)
58550: 991, // RequireListElement (3x)
58567: 992, // RolenameWithoutIdent (3x)
58560: 993, // RoleOrPrivElem (3x)
58580: 994, // SelectStmtGroup (3x)
58598: 995, // SetOprOpt (3x)
58651: 996, // TableAliasRefList (3x)
58654: 997, // TableElement (3x)
58663: 998, // TableNameListOpt2 (3x)
58688: 999, // TransactionChars (3x)
57548: 1000, // trigger (3x)
57552: 1001, // unlock (3x)
57555: 1002, // usage (3x)
58708: 1003, // ValuesList (3x)
58710: 1004, // ValuesStmtList (3x)
58706: 1005, // ValueSym (3x)
58713: 1006, // VariableAssignment (3x)
58733: 1007, // WindowFrameStart (3x)
58709: 1003, // ValuesList (3x)
58711: 1004, // ValuesStmtList (3x)
58707: 1005, // ValueSym (3x)
58714: 1006, // VariableAssignment (3x)
58734: 1007, // WindowFrameStart (3x)
58138: 1008, // AdminStmt (2x)
58141: 1009, // AllColumnsOrPredicateColumnsOpt (2x)
58143: 1010, // AlterDatabaseStmt (2x)
@ -1996,70 +1996,70 @@ var (
58513: 1138, // PasswordOrLockOptionList (2x)
58514: 1139, // PasswordOrLockOptions (2x)
58517: 1140, // PlacementOptionList (2x)
58519: 1141, // PlanReplayerStmt (2x)
58525: 1142, // PreparedStmt (2x)
58530: 1143, // PrivLevel (2x)
58533: 1144, // PurgeImportStmt (2x)
58534: 1145, // QuickOptional (2x)
58535: 1146, // RecoverTableStmt (2x)
58537: 1147, // ReferOpt (2x)
58539: 1148, // RegexpSym (2x)
58541: 1149, // RenameTableStmt (2x)
58542: 1150, // RenameUserStmt (2x)
58544: 1151, // RepeatableOpt (2x)
58551: 1152, // ResourceGroupNameOption (2x)
58552: 1153, // ResourceGroupOptionList (2x)
58553: 1154, // RestartStmt (2x)
58555: 1155, // ResumeImportStmt (2x)
58520: 1141, // PlanReplayerStmt (2x)
58526: 1142, // PreparedStmt (2x)
58531: 1143, // PrivLevel (2x)
58534: 1144, // PurgeImportStmt (2x)
58535: 1145, // QuickOptional (2x)
58536: 1146, // RecoverTableStmt (2x)
58538: 1147, // ReferOpt (2x)
58540: 1148, // RegexpSym (2x)
58542: 1149, // RenameTableStmt (2x)
58543: 1150, // RenameUserStmt (2x)
58545: 1151, // RepeatableOpt (2x)
58552: 1152, // ResourceGroupNameOption (2x)
58553: 1153, // ResourceGroupOptionList (2x)
58554: 1154, // RestartStmt (2x)
58556: 1155, // ResumeImportStmt (2x)
57517: 1156, // revoke (2x)
58556: 1157, // RevokeRoleStmt (2x)
58557: 1158, // RevokeStmt (2x)
58560: 1159, // RoleOrPrivElemList (2x)
58561: 1160, // RoleSpec (2x)
58583: 1161, // SelectStmtOpt (2x)
58586: 1162, // SelectStmtSQLCache (2x)
58590: 1163, // SetBindingStmt (2x)
58591: 1164, // SetDefaultRoleOpt (2x)
58592: 1165, // SetDefaultRoleStmt (2x)
58602: 1166, // SetRoleStmt (2x)
58606: 1167, // ShowImportStmt (2x)
58611: 1168, // ShowProfileType (2x)
58614: 1169, // ShowStmt (2x)
58615: 1170, // ShowTableAliasOpt (2x)
58617: 1171, // ShutdownStmt (2x)
58618: 1172, // SignedLiteral (2x)
58622: 1173, // SplitOption (2x)
58623: 1174, // SplitRegionStmt (2x)
58627: 1175, // Statement (2x)
58630: 1176, // StatsOptionsOpt (2x)
58631: 1177, // StatsPersistentVal (2x)
58632: 1178, // StatsType (2x)
58633: 1179, // StopImportStmt (2x)
58640: 1180, // SubPartDefinition (2x)
58643: 1181, // SubPartitionMethod (2x)
58648: 1182, // Symbol (2x)
58654: 1183, // TableElementList (2x)
58657: 1184, // TableLock (2x)
58661: 1185, // TableNameListOpt (2x)
58668: 1186, // TableOrTables (2x)
58677: 1187, // TablesTerminalSym (2x)
58675: 1188, // TableToTable (2x)
58679: 1189, // TextStringList (2x)
58684: 1190, // TraceStmt (2x)
58689: 1191, // TruncateTableStmt (2x)
58692: 1192, // UnlockStatsStmt (2x)
58693: 1193, // UnlockTablesStmt (2x)
58699: 1194, // UserToUser (2x)
58696: 1195, // UseStmt (2x)
58711: 1196, // Varchar (2x)
58714: 1197, // VariableAssignmentList (2x)
58723: 1198, // WhenClause (2x)
58728: 1199, // WindowDefinition (2x)
58731: 1200, // WindowFrameBound (2x)
58738: 1201, // WindowSpec (2x)
58743: 1202, // WithGrantOptionOpt (2x)
58744: 1203, // WithList (2x)
58748: 1204, // Writeable (2x)
58557: 1157, // RevokeRoleStmt (2x)
58558: 1158, // RevokeStmt (2x)
58561: 1159, // RoleOrPrivElemList (2x)
58562: 1160, // RoleSpec (2x)
58584: 1161, // SelectStmtOpt (2x)
58587: 1162, // SelectStmtSQLCache (2x)
58591: 1163, // SetBindingStmt (2x)
58592: 1164, // SetDefaultRoleOpt (2x)
58593: 1165, // SetDefaultRoleStmt (2x)
58603: 1166, // SetRoleStmt (2x)
58607: 1167, // ShowImportStmt (2x)
58612: 1168, // ShowProfileType (2x)
58615: 1169, // ShowStmt (2x)
58616: 1170, // ShowTableAliasOpt (2x)
58618: 1171, // ShutdownStmt (2x)
58619: 1172, // SignedLiteral (2x)
58623: 1173, // SplitOption (2x)
58624: 1174, // SplitRegionStmt (2x)
58628: 1175, // Statement (2x)
58631: 1176, // StatsOptionsOpt (2x)
58632: 1177, // StatsPersistentVal (2x)
58633: 1178, // StatsType (2x)
58634: 1179, // StopImportStmt (2x)
58641: 1180, // SubPartDefinition (2x)
58644: 1181, // SubPartitionMethod (2x)
58649: 1182, // Symbol (2x)
58655: 1183, // TableElementList (2x)
58658: 1184, // TableLock (2x)
58662: 1185, // TableNameListOpt (2x)
58669: 1186, // TableOrTables (2x)
58678: 1187, // TablesTerminalSym (2x)
58676: 1188, // TableToTable (2x)
58680: 1189, // TextStringList (2x)
58685: 1190, // TraceStmt (2x)
58690: 1191, // TruncateTableStmt (2x)
58693: 1192, // UnlockStatsStmt (2x)
58694: 1193, // UnlockTablesStmt (2x)
58700: 1194, // UserToUser (2x)
58697: 1195, // UseStmt (2x)
58712: 1196, // Varchar (2x)
58715: 1197, // VariableAssignmentList (2x)
58724: 1198, // WhenClause (2x)
58729: 1199, // WindowDefinition (2x)
58732: 1200, // WindowFrameBound (2x)
58739: 1201, // WindowSpec (2x)
58744: 1202, // WithGrantOptionOpt (2x)
58745: 1203, // WithList (2x)
58749: 1204, // Writeable (2x)
58137: 1205, // AdminShowSlow (1x)
58139: 1206, // AdminStmtLimitOpt (1x)
58147: 1207, // AlterOrderList (1x)
@ -2173,81 +2173,81 @@ var (
58515: 1315, // PerDB (1x)
58516: 1316, // PerTable (1x)
57501: 1317, // precisionType (1x)
58524: 1318, // PrepareSQL (1x)
58532: 1319, // ProcedureCall (1x)
58525: 1318, // PrepareSQL (1x)
58533: 1319, // ProcedureCall (1x)
57508: 1320, // recursive (1x)
58538: 1321, // RegexpOrNotOp (1x)
58543: 1322, // ReorganizePartitionRuleOpt (1x)
58548: 1323, // RequireList (1x)
58562: 1324, // RoleSpecList (1x)
58569: 1325, // RowOrRows (1x)
58576: 1326, // SelectStmtFieldList (1x)
58584: 1327, // SelectStmtOpts (1x)
58585: 1328, // SelectStmtOptsList (1x)
58589: 1329, // SequenceOptionList (1x)
58594: 1330, // SetOpr (1x)
58601: 1331, // SetRoleOpt (1x)
58604: 1332, // ShardableStmt (1x)
58607: 1333, // ShowIndexKwd (1x)
58608: 1334, // ShowLikeOrWhereOpt (1x)
58609: 1335, // ShowPlacementTarget (1x)
58610: 1336, // ShowProfileArgsOpt (1x)
58612: 1337, // ShowProfileTypes (1x)
58613: 1338, // ShowProfileTypesOpt (1x)
58616: 1339, // ShowTargetFilterable (1x)
58539: 1321, // RegexpOrNotOp (1x)
58544: 1322, // ReorganizePartitionRuleOpt (1x)
58549: 1323, // RequireList (1x)
58563: 1324, // RoleSpecList (1x)
58570: 1325, // RowOrRows (1x)
58577: 1326, // SelectStmtFieldList (1x)
58585: 1327, // SelectStmtOpts (1x)
58586: 1328, // SelectStmtOptsList (1x)
58590: 1329, // SequenceOptionList (1x)
58595: 1330, // SetOpr (1x)
58602: 1331, // SetRoleOpt (1x)
58605: 1332, // ShardableStmt (1x)
58608: 1333, // ShowIndexKwd (1x)
58609: 1334, // ShowLikeOrWhereOpt (1x)
58610: 1335, // ShowPlacementTarget (1x)
58611: 1336, // ShowProfileArgsOpt (1x)
58613: 1337, // ShowProfileTypes (1x)
58614: 1338, // ShowProfileTypesOpt (1x)
58617: 1339, // ShowTargetFilterable (1x)
57528: 1340, // spatial (1x)
58624: 1341, // SplitSyntaxOption (1x)
58625: 1341, // SplitSyntaxOption (1x)
57533: 1342, // ssl (1x)
58625: 1343, // Start (1x)
58626: 1344, // Starting (1x)
58626: 1343, // Start (1x)
58627: 1344, // Starting (1x)
57534: 1345, // starting (1x)
58628: 1346, // StatementList (1x)
58629: 1347, // StatementScope (1x)
58634: 1348, // StorageMedia (1x)
58629: 1346, // StatementList (1x)
58630: 1347, // StatementScope (1x)
58635: 1348, // StorageMedia (1x)
57540: 1349, // stored (1x)
58635: 1350, // StringList (1x)
58638: 1351, // StringNameOrBRIEOptionKeyword (1x)
58639: 1352, // StringType (1x)
58641: 1353, // SubPartDefinitionList (1x)
58642: 1354, // SubPartDefinitionListOpt (1x)
58644: 1355, // SubPartitionNumOpt (1x)
58645: 1356, // SubPartitionOpt (1x)
58655: 1357, // TableElementListOpt (1x)
58658: 1358, // TableLockList (1x)
58671: 1359, // TableRefsClause (1x)
58672: 1360, // TableSampleMethodOpt (1x)
58673: 1361, // TableSampleOpt (1x)
58674: 1362, // TableSampleUnitOpt (1x)
58676: 1363, // TableToTableList (1x)
58680: 1364, // TextType (1x)
58636: 1350, // StringList (1x)
58639: 1351, // StringNameOrBRIEOptionKeyword (1x)
58640: 1352, // StringType (1x)
58642: 1353, // SubPartDefinitionList (1x)
58643: 1354, // SubPartDefinitionListOpt (1x)
58645: 1355, // SubPartitionNumOpt (1x)
58646: 1356, // SubPartitionOpt (1x)
58656: 1357, // TableElementListOpt (1x)
58659: 1358, // TableLockList (1x)
58672: 1359, // TableRefsClause (1x)
58673: 1360, // TableSampleMethodOpt (1x)
58674: 1361, // TableSampleOpt (1x)
58675: 1362, // TableSampleUnitOpt (1x)
58677: 1363, // TableToTableList (1x)
58681: 1364, // TextType (1x)
57547: 1365, // trailing (1x)
58688: 1366, // TrimDirection (1x)
58690: 1367, // Type (1x)
58700: 1368, // UserToUserList (1x)
58702: 1369, // UserVariableList (1x)
58705: 1370, // UsingRoles (1x)
58707: 1371, // Values (1x)
58709: 1372, // ValuesOpt (1x)
58716: 1373, // ViewAlgorithm (1x)
58717: 1374, // ViewCheckOption (1x)
58718: 1375, // ViewDefiner (1x)
58719: 1376, // ViewFieldList (1x)
58720: 1377, // ViewName (1x)
58721: 1378, // ViewSQLSecurity (1x)
58689: 1366, // TrimDirection (1x)
58691: 1367, // Type (1x)
58701: 1368, // UserToUserList (1x)
58703: 1369, // UserVariableList (1x)
58706: 1370, // UsingRoles (1x)
58708: 1371, // Values (1x)
58710: 1372, // ValuesOpt (1x)
58717: 1373, // ViewAlgorithm (1x)
58718: 1374, // ViewCheckOption (1x)
58719: 1375, // ViewDefiner (1x)
58720: 1376, // ViewFieldList (1x)
58721: 1377, // ViewName (1x)
58722: 1378, // ViewSQLSecurity (1x)
57567: 1379, // virtual (1x)
58722: 1380, // VirtualOrStored (1x)
58724: 1381, // WhenClauseList (1x)
58727: 1382, // WindowClauseOptional (1x)
58729: 1383, // WindowDefinitionList (1x)
58730: 1384, // WindowFrameBetween (1x)
58732: 1385, // WindowFrameExtent (1x)
58734: 1386, // WindowFrameUnits (1x)
58737: 1387, // WindowNameOrSpec (1x)
58739: 1388, // WindowSpecDetails (1x)
58745: 1389, // WithReadLockOpt (1x)
58746: 1390, // WithValidation (1x)
58747: 1391, // WithValidationOpt (1x)
58749: 1392, // Year (1x)
58723: 1380, // VirtualOrStored (1x)
58725: 1381, // WhenClauseList (1x)
58728: 1382, // WindowClauseOptional (1x)
58730: 1383, // WindowDefinitionList (1x)
58731: 1384, // WindowFrameBetween (1x)
58733: 1385, // WindowFrameExtent (1x)
58735: 1386, // WindowFrameUnits (1x)
58738: 1387, // WindowNameOrSpec (1x)
58740: 1388, // WindowSpecDetails (1x)
58746: 1389, // WithReadLockOpt (1x)
58747: 1390, // WithValidation (1x)
58748: 1391, // WithValidationOpt (1x)
58750: 1392, // Year (1x)
58136: 1393, // $default (0x)
58097: 1394, // andnot (0x)
58170: 1395, // AssignmentListOpt (0x)
@ -2282,7 +2282,8 @@ var (
57358: 1424, // odbcDateType (0x)
57360: 1425, // odbcTimestampType (0x)
57359: 1426, // odbcTimeType (0x)
58127: 1427, // tableRefPriority (0x)
58519: 1427, // PlanChangeCaptureStmt (0x)
58127: 1428, // tableRefPriority (0x)
}
yySymNames = []string{
@ -3713,6 +3714,7 @@ var (
"odbcDateType",
"odbcTimestampType",
"odbcTimeType",
"PlanChangeCaptureStmt",
"tableRefPriority",
}
@ -6336,6 +6338,7 @@ var (
{1141, 4},
{1141, 5},
{1141, 6},
{1427, 5},
}
yyXErrors = map[yyXError]string{}
@ -22734,6 +22737,15 @@ yynewstate:
Limit: nil,
}
parser.yyVAL.statement = x
}
case 2619:
{
x := &ast.PlanChangeCaptureStmt{
Begin: yyS[yypt-1].ident,
End: yyS[yypt-0].ident,
}
parser.yyVAL.statement = x
}

View File

@ -943,6 +943,7 @@ import (
UnlockStatsStmt "Unlock statistic statement"
LockTablesStmt "Lock tables statement"
NonTransactionalDMLStmt "Non-transactional DML statement"
PlanChangeCaptureStmt "Plan Change Capture Statement"
PlanReplayerStmt "Plan replayer statement"
PreparedStmt "PreparedStmt"
PurgeImportStmt "PURGE IMPORT statement that removes a IMPORT task record"
@ -14730,6 +14731,23 @@ PlanReplayerStmt:
Limit: nil,
}
$$ = x
}
/********************************************************************
*
* Plan Chnage Capture Statement
*
* PLAN REPLAYER Change 'begin_time' 'end_time'
*******************************************************************/
PlanChangeCaptureStmt:
"PLAN" "CHANGE" "CAPTURE" stringLit stringLit
{
x := &ast.PlanChangeCaptureStmt{
Begin: $4,
End: $5,
}
$$ = x
}
%%

View File

@ -587,6 +587,13 @@ type UnlockStats struct {
Tables []*ast.TableName
}
// PlanChangeCapture represents a plan change capture stmt
type PlanChangeCapture struct {
baseSchemaProducer
Begin string
End string
}
// PlanReplayer represents a plan replayer plan.
type PlanReplayer struct {
baseSchemaProducer

View File

@ -804,6 +804,8 @@ func (b *PlanBuilder) Build(ctx context.Context, node ast.Node) (Plan, error) {
return b.buildUnlockStats(x), nil
case *ast.IndexAdviseStmt:
return b.buildIndexAdvise(x), nil
case *ast.PlanChangeCaptureStmt:
return b.buildPlanChangeCapture(x), nil
case *ast.PlanReplayerStmt:
return b.buildPlanReplayer(x), nil
case *ast.PrepareStmt:
@ -5196,6 +5198,15 @@ func buildShowSchema(s *ast.ShowStmt, isView bool, isSequence bool) (schema *exp
return
}
func (b *PlanBuilder) buildPlanChangeCapture(pc *ast.PlanChangeCaptureStmt) Plan {
p := &PlanChangeCapture{Begin: pc.Begin, End: pc.End}
schema := newColumnsWithNames(1)
schema.Append(buildColumnWithName("", "File_token", mysql.TypeVarchar, 128))
p.SetSchema(schema.col2Schema())
p.names = schema.names
return p
}
func (b *PlanBuilder) buildPlanReplayer(pc *ast.PlanReplayerStmt) Plan {
p := &PlanReplayer{ExecStmt: pc.Stmt, Analyze: pc.Analyze, Load: pc.Load, File: pc.File,
Capture: pc.Capture, Remove: pc.Remove, SQLDigest: pc.SQLDigest, PlanDigest: pc.PlanDigest}