github.com/vedadiyan/sqlparser@v1.0.0/pkg/sqlparser/ast_clone.go (about)

     1  /*
     2  Copyright 2023 The Vitess Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  // Code generated by ASTHelperGen. DO NOT EDIT.
    17  
    18  package sqlparser
    19  
    20  // CloneSQLNode creates a deep clone of the input.
    21  func CloneSQLNode(in SQLNode) SQLNode {
    22  	if in == nil {
    23  		return nil
    24  	}
    25  	switch in := in.(type) {
    26  	case *AddColumns:
    27  		return CloneRefOfAddColumns(in)
    28  	case *AddConstraintDefinition:
    29  		return CloneRefOfAddConstraintDefinition(in)
    30  	case *AddIndexDefinition:
    31  		return CloneRefOfAddIndexDefinition(in)
    32  	case AlgorithmValue:
    33  		return in
    34  	case *AliasedExpr:
    35  		return CloneRefOfAliasedExpr(in)
    36  	case *AliasedTableExpr:
    37  		return CloneRefOfAliasedTableExpr(in)
    38  	case *AlterCharset:
    39  		return CloneRefOfAlterCharset(in)
    40  	case *AlterCheck:
    41  		return CloneRefOfAlterCheck(in)
    42  	case *AlterColumn:
    43  		return CloneRefOfAlterColumn(in)
    44  	case *AlterDatabase:
    45  		return CloneRefOfAlterDatabase(in)
    46  	case *AlterIndex:
    47  		return CloneRefOfAlterIndex(in)
    48  	case *AlterMigration:
    49  		return CloneRefOfAlterMigration(in)
    50  	case *AlterTable:
    51  		return CloneRefOfAlterTable(in)
    52  	case *AlterView:
    53  		return CloneRefOfAlterView(in)
    54  	case *AlterVschema:
    55  		return CloneRefOfAlterVschema(in)
    56  	case *AndExpr:
    57  		return CloneRefOfAndExpr(in)
    58  	case Argument:
    59  		return in
    60  	case *ArgumentLessWindowExpr:
    61  		return CloneRefOfArgumentLessWindowExpr(in)
    62  	case *AutoIncSpec:
    63  		return CloneRefOfAutoIncSpec(in)
    64  	case *Avg:
    65  		return CloneRefOfAvg(in)
    66  	case *Begin:
    67  		return CloneRefOfBegin(in)
    68  	case *BetweenExpr:
    69  		return CloneRefOfBetweenExpr(in)
    70  	case *BinaryExpr:
    71  		return CloneRefOfBinaryExpr(in)
    72  	case *BitAnd:
    73  		return CloneRefOfBitAnd(in)
    74  	case *BitOr:
    75  		return CloneRefOfBitOr(in)
    76  	case *BitXor:
    77  		return CloneRefOfBitXor(in)
    78  	case BoolVal:
    79  		return in
    80  	case *CallProc:
    81  		return CloneRefOfCallProc(in)
    82  	case *CaseExpr:
    83  		return CloneRefOfCaseExpr(in)
    84  	case *CastExpr:
    85  		return CloneRefOfCastExpr(in)
    86  	case *ChangeColumn:
    87  		return CloneRefOfChangeColumn(in)
    88  	case *CharExpr:
    89  		return CloneRefOfCharExpr(in)
    90  	case *CheckConstraintDefinition:
    91  		return CloneRefOfCheckConstraintDefinition(in)
    92  	case *ColName:
    93  		return CloneRefOfColName(in)
    94  	case *CollateExpr:
    95  		return CloneRefOfCollateExpr(in)
    96  	case *ColumnDefinition:
    97  		return CloneRefOfColumnDefinition(in)
    98  	case *ColumnType:
    99  		return CloneRefOfColumnType(in)
   100  	case Columns:
   101  		return CloneColumns(in)
   102  	case *CommentOnly:
   103  		return CloneRefOfCommentOnly(in)
   104  	case *Commit:
   105  		return CloneRefOfCommit(in)
   106  	case *CommonTableExpr:
   107  		return CloneRefOfCommonTableExpr(in)
   108  	case *ComparisonExpr:
   109  		return CloneRefOfComparisonExpr(in)
   110  	case *ConstraintDefinition:
   111  		return CloneRefOfConstraintDefinition(in)
   112  	case *ConvertExpr:
   113  		return CloneRefOfConvertExpr(in)
   114  	case *ConvertType:
   115  		return CloneRefOfConvertType(in)
   116  	case *ConvertUsingExpr:
   117  		return CloneRefOfConvertUsingExpr(in)
   118  	case *Count:
   119  		return CloneRefOfCount(in)
   120  	case *CountStar:
   121  		return CloneRefOfCountStar(in)
   122  	case *CreateDatabase:
   123  		return CloneRefOfCreateDatabase(in)
   124  	case *CreateTable:
   125  		return CloneRefOfCreateTable(in)
   126  	case *CreateView:
   127  		return CloneRefOfCreateView(in)
   128  	case *CurTimeFuncExpr:
   129  		return CloneRefOfCurTimeFuncExpr(in)
   130  	case *DeallocateStmt:
   131  		return CloneRefOfDeallocateStmt(in)
   132  	case *Default:
   133  		return CloneRefOfDefault(in)
   134  	case *Definer:
   135  		return CloneRefOfDefiner(in)
   136  	case *Delete:
   137  		return CloneRefOfDelete(in)
   138  	case *DerivedTable:
   139  		return CloneRefOfDerivedTable(in)
   140  	case *DropColumn:
   141  		return CloneRefOfDropColumn(in)
   142  	case *DropDatabase:
   143  		return CloneRefOfDropDatabase(in)
   144  	case *DropKey:
   145  		return CloneRefOfDropKey(in)
   146  	case *DropTable:
   147  		return CloneRefOfDropTable(in)
   148  	case *DropView:
   149  		return CloneRefOfDropView(in)
   150  	case *ExecuteStmt:
   151  		return CloneRefOfExecuteStmt(in)
   152  	case *ExistsExpr:
   153  		return CloneRefOfExistsExpr(in)
   154  	case *ExplainStmt:
   155  		return CloneRefOfExplainStmt(in)
   156  	case *ExplainTab:
   157  		return CloneRefOfExplainTab(in)
   158  	case Exprs:
   159  		return CloneExprs(in)
   160  	case *ExtractFuncExpr:
   161  		return CloneRefOfExtractFuncExpr(in)
   162  	case *ExtractValueExpr:
   163  		return CloneRefOfExtractValueExpr(in)
   164  	case *ExtractedSubquery:
   165  		return CloneRefOfExtractedSubquery(in)
   166  	case *FirstOrLastValueExpr:
   167  		return CloneRefOfFirstOrLastValueExpr(in)
   168  	case *Flush:
   169  		return CloneRefOfFlush(in)
   170  	case *Force:
   171  		return CloneRefOfForce(in)
   172  	case *ForeignKeyDefinition:
   173  		return CloneRefOfForeignKeyDefinition(in)
   174  	case *FrameClause:
   175  		return CloneRefOfFrameClause(in)
   176  	case *FramePoint:
   177  		return CloneRefOfFramePoint(in)
   178  	case *FromFirstLastClause:
   179  		return CloneRefOfFromFirstLastClause(in)
   180  	case *FuncExpr:
   181  		return CloneRefOfFuncExpr(in)
   182  	case *GTIDFuncExpr:
   183  		return CloneRefOfGTIDFuncExpr(in)
   184  	case GroupBy:
   185  		return CloneGroupBy(in)
   186  	case *GroupConcatExpr:
   187  		return CloneRefOfGroupConcatExpr(in)
   188  	case IdentifierCI:
   189  		return CloneIdentifierCI(in)
   190  	case IdentifierCS:
   191  		return CloneIdentifierCS(in)
   192  	case *IndexDefinition:
   193  		return CloneRefOfIndexDefinition(in)
   194  	case *IndexHint:
   195  		return CloneRefOfIndexHint(in)
   196  	case IndexHints:
   197  		return CloneIndexHints(in)
   198  	case *IndexInfo:
   199  		return CloneRefOfIndexInfo(in)
   200  	case *Insert:
   201  		return CloneRefOfInsert(in)
   202  	case *InsertExpr:
   203  		return CloneRefOfInsertExpr(in)
   204  	case *IntervalExpr:
   205  		return CloneRefOfIntervalExpr(in)
   206  	case *IntervalFuncExpr:
   207  		return CloneRefOfIntervalFuncExpr(in)
   208  	case *IntroducerExpr:
   209  		return CloneRefOfIntroducerExpr(in)
   210  	case *IsExpr:
   211  		return CloneRefOfIsExpr(in)
   212  	case *JSONArrayExpr:
   213  		return CloneRefOfJSONArrayExpr(in)
   214  	case *JSONAttributesExpr:
   215  		return CloneRefOfJSONAttributesExpr(in)
   216  	case *JSONContainsExpr:
   217  		return CloneRefOfJSONContainsExpr(in)
   218  	case *JSONContainsPathExpr:
   219  		return CloneRefOfJSONContainsPathExpr(in)
   220  	case *JSONExtractExpr:
   221  		return CloneRefOfJSONExtractExpr(in)
   222  	case *JSONKeysExpr:
   223  		return CloneRefOfJSONKeysExpr(in)
   224  	case *JSONObjectExpr:
   225  		return CloneRefOfJSONObjectExpr(in)
   226  	case *JSONObjectParam:
   227  		return CloneRefOfJSONObjectParam(in)
   228  	case *JSONOverlapsExpr:
   229  		return CloneRefOfJSONOverlapsExpr(in)
   230  	case *JSONPrettyExpr:
   231  		return CloneRefOfJSONPrettyExpr(in)
   232  	case *JSONQuoteExpr:
   233  		return CloneRefOfJSONQuoteExpr(in)
   234  	case *JSONRemoveExpr:
   235  		return CloneRefOfJSONRemoveExpr(in)
   236  	case *JSONSchemaValidFuncExpr:
   237  		return CloneRefOfJSONSchemaValidFuncExpr(in)
   238  	case *JSONSchemaValidationReportFuncExpr:
   239  		return CloneRefOfJSONSchemaValidationReportFuncExpr(in)
   240  	case *JSONSearchExpr:
   241  		return CloneRefOfJSONSearchExpr(in)
   242  	case *JSONStorageFreeExpr:
   243  		return CloneRefOfJSONStorageFreeExpr(in)
   244  	case *JSONStorageSizeExpr:
   245  		return CloneRefOfJSONStorageSizeExpr(in)
   246  	case *JSONTableExpr:
   247  		return CloneRefOfJSONTableExpr(in)
   248  	case *JSONUnquoteExpr:
   249  		return CloneRefOfJSONUnquoteExpr(in)
   250  	case *JSONValueExpr:
   251  		return CloneRefOfJSONValueExpr(in)
   252  	case *JSONValueMergeExpr:
   253  		return CloneRefOfJSONValueMergeExpr(in)
   254  	case *JSONValueModifierExpr:
   255  		return CloneRefOfJSONValueModifierExpr(in)
   256  	case *JoinCondition:
   257  		return CloneRefOfJoinCondition(in)
   258  	case *JoinTableExpr:
   259  		return CloneRefOfJoinTableExpr(in)
   260  	case *JtColumnDefinition:
   261  		return CloneRefOfJtColumnDefinition(in)
   262  	case *JtOnResponse:
   263  		return CloneRefOfJtOnResponse(in)
   264  	case *KeyState:
   265  		return CloneRefOfKeyState(in)
   266  	case *LagLeadExpr:
   267  		return CloneRefOfLagLeadExpr(in)
   268  	case *Limit:
   269  		return CloneRefOfLimit(in)
   270  	case *LineStringExpr:
   271  		return CloneRefOfLineStringExpr(in)
   272  	case ListArg:
   273  		return in
   274  	case *Literal:
   275  		return CloneRefOfLiteral(in)
   276  	case *Load:
   277  		return CloneRefOfLoad(in)
   278  	case *LocateExpr:
   279  		return CloneRefOfLocateExpr(in)
   280  	case *LockOption:
   281  		return CloneRefOfLockOption(in)
   282  	case *LockTables:
   283  		return CloneRefOfLockTables(in)
   284  	case *LockingFunc:
   285  		return CloneRefOfLockingFunc(in)
   286  	case MatchAction:
   287  		return in
   288  	case *MatchExpr:
   289  		return CloneRefOfMatchExpr(in)
   290  	case *Max:
   291  		return CloneRefOfMax(in)
   292  	case *MemberOfExpr:
   293  		return CloneRefOfMemberOfExpr(in)
   294  	case *Min:
   295  		return CloneRefOfMin(in)
   296  	case *ModifyColumn:
   297  		return CloneRefOfModifyColumn(in)
   298  	case *NTHValueExpr:
   299  		return CloneRefOfNTHValueExpr(in)
   300  	case *NamedWindow:
   301  		return CloneRefOfNamedWindow(in)
   302  	case NamedWindows:
   303  		return CloneNamedWindows(in)
   304  	case *Nextval:
   305  		return CloneRefOfNextval(in)
   306  	case *NotExpr:
   307  		return CloneRefOfNotExpr(in)
   308  	case *NtileExpr:
   309  		return CloneRefOfNtileExpr(in)
   310  	case *NullTreatmentClause:
   311  		return CloneRefOfNullTreatmentClause(in)
   312  	case *NullVal:
   313  		return CloneRefOfNullVal(in)
   314  	case *Offset:
   315  		return CloneRefOfOffset(in)
   316  	case OnDup:
   317  		return CloneOnDup(in)
   318  	case *OptLike:
   319  		return CloneRefOfOptLike(in)
   320  	case *OrExpr:
   321  		return CloneRefOfOrExpr(in)
   322  	case *Order:
   323  		return CloneRefOfOrder(in)
   324  	case OrderBy:
   325  		return CloneOrderBy(in)
   326  	case *OrderByOption:
   327  		return CloneRefOfOrderByOption(in)
   328  	case *OtherAdmin:
   329  		return CloneRefOfOtherAdmin(in)
   330  	case *OtherRead:
   331  		return CloneRefOfOtherRead(in)
   332  	case *OverClause:
   333  		return CloneRefOfOverClause(in)
   334  	case *ParenTableExpr:
   335  		return CloneRefOfParenTableExpr(in)
   336  	case *ParsedComments:
   337  		return CloneRefOfParsedComments(in)
   338  	case *PartitionDefinition:
   339  		return CloneRefOfPartitionDefinition(in)
   340  	case *PartitionDefinitionOptions:
   341  		return CloneRefOfPartitionDefinitionOptions(in)
   342  	case *PartitionEngine:
   343  		return CloneRefOfPartitionEngine(in)
   344  	case *PartitionOption:
   345  		return CloneRefOfPartitionOption(in)
   346  	case *PartitionSpec:
   347  		return CloneRefOfPartitionSpec(in)
   348  	case *PartitionValueRange:
   349  		return CloneRefOfPartitionValueRange(in)
   350  	case Partitions:
   351  		return ClonePartitions(in)
   352  	case *PerformanceSchemaFuncExpr:
   353  		return CloneRefOfPerformanceSchemaFuncExpr(in)
   354  	case *PointExpr:
   355  		return CloneRefOfPointExpr(in)
   356  	case *PrepareStmt:
   357  		return CloneRefOfPrepareStmt(in)
   358  	case ReferenceAction:
   359  		return in
   360  	case *ReferenceDefinition:
   361  		return CloneRefOfReferenceDefinition(in)
   362  	case *RegexpInstrExpr:
   363  		return CloneRefOfRegexpInstrExpr(in)
   364  	case *RegexpLikeExpr:
   365  		return CloneRefOfRegexpLikeExpr(in)
   366  	case *RegexpReplaceExpr:
   367  		return CloneRefOfRegexpReplaceExpr(in)
   368  	case *RegexpSubstrExpr:
   369  		return CloneRefOfRegexpSubstrExpr(in)
   370  	case *Release:
   371  		return CloneRefOfRelease(in)
   372  	case *RenameColumn:
   373  		return CloneRefOfRenameColumn(in)
   374  	case *RenameIndex:
   375  		return CloneRefOfRenameIndex(in)
   376  	case *RenameTable:
   377  		return CloneRefOfRenameTable(in)
   378  	case *RenameTableName:
   379  		return CloneRefOfRenameTableName(in)
   380  	case *RevertMigration:
   381  		return CloneRefOfRevertMigration(in)
   382  	case *Rollback:
   383  		return CloneRefOfRollback(in)
   384  	case RootNode:
   385  		return CloneRootNode(in)
   386  	case *SRollback:
   387  		return CloneRefOfSRollback(in)
   388  	case *Savepoint:
   389  		return CloneRefOfSavepoint(in)
   390  	case *Select:
   391  		return CloneRefOfSelect(in)
   392  	case SelectExprs:
   393  		return CloneSelectExprs(in)
   394  	case *SelectInto:
   395  		return CloneRefOfSelectInto(in)
   396  	case *Set:
   397  		return CloneRefOfSet(in)
   398  	case *SetExpr:
   399  		return CloneRefOfSetExpr(in)
   400  	case SetExprs:
   401  		return CloneSetExprs(in)
   402  	case *Show:
   403  		return CloneRefOfShow(in)
   404  	case *ShowBasic:
   405  		return CloneRefOfShowBasic(in)
   406  	case *ShowCreate:
   407  		return CloneRefOfShowCreate(in)
   408  	case *ShowFilter:
   409  		return CloneRefOfShowFilter(in)
   410  	case *ShowMigrationLogs:
   411  		return CloneRefOfShowMigrationLogs(in)
   412  	case *ShowOther:
   413  		return CloneRefOfShowOther(in)
   414  	case *ShowThrottledApps:
   415  		return CloneRefOfShowThrottledApps(in)
   416  	case *ShowThrottlerStatus:
   417  		return CloneRefOfShowThrottlerStatus(in)
   418  	case *StarExpr:
   419  		return CloneRefOfStarExpr(in)
   420  	case *Std:
   421  		return CloneRefOfStd(in)
   422  	case *StdDev:
   423  		return CloneRefOfStdDev(in)
   424  	case *StdPop:
   425  		return CloneRefOfStdPop(in)
   426  	case *StdSamp:
   427  		return CloneRefOfStdSamp(in)
   428  	case *Stream:
   429  		return CloneRefOfStream(in)
   430  	case *SubPartition:
   431  		return CloneRefOfSubPartition(in)
   432  	case *SubPartitionDefinition:
   433  		return CloneRefOfSubPartitionDefinition(in)
   434  	case *SubPartitionDefinitionOptions:
   435  		return CloneRefOfSubPartitionDefinitionOptions(in)
   436  	case SubPartitionDefinitions:
   437  		return CloneSubPartitionDefinitions(in)
   438  	case *Subquery:
   439  		return CloneRefOfSubquery(in)
   440  	case *SubstrExpr:
   441  		return CloneRefOfSubstrExpr(in)
   442  	case *Sum:
   443  		return CloneRefOfSum(in)
   444  	case TableExprs:
   445  		return CloneTableExprs(in)
   446  	case TableName:
   447  		return CloneTableName(in)
   448  	case TableNames:
   449  		return CloneTableNames(in)
   450  	case TableOptions:
   451  		return CloneTableOptions(in)
   452  	case *TableSpec:
   453  		return CloneRefOfTableSpec(in)
   454  	case *TablespaceOperation:
   455  		return CloneRefOfTablespaceOperation(in)
   456  	case *TimestampFuncExpr:
   457  		return CloneRefOfTimestampFuncExpr(in)
   458  	case *TrimFuncExpr:
   459  		return CloneRefOfTrimFuncExpr(in)
   460  	case *TruncateTable:
   461  		return CloneRefOfTruncateTable(in)
   462  	case *UnaryExpr:
   463  		return CloneRefOfUnaryExpr(in)
   464  	case *Union:
   465  		return CloneRefOfUnion(in)
   466  	case *UnlockTables:
   467  		return CloneRefOfUnlockTables(in)
   468  	case *Update:
   469  		return CloneRefOfUpdate(in)
   470  	case *UpdateExpr:
   471  		return CloneRefOfUpdateExpr(in)
   472  	case UpdateExprs:
   473  		return CloneUpdateExprs(in)
   474  	case *UpdateXMLExpr:
   475  		return CloneRefOfUpdateXMLExpr(in)
   476  	case *Use:
   477  		return CloneRefOfUse(in)
   478  	case *VExplainStmt:
   479  		return CloneRefOfVExplainStmt(in)
   480  	case *VStream:
   481  		return CloneRefOfVStream(in)
   482  	case ValTuple:
   483  		return CloneValTuple(in)
   484  	case *Validation:
   485  		return CloneRefOfValidation(in)
   486  	case Values:
   487  		return CloneValues(in)
   488  	case *ValuesFuncExpr:
   489  		return CloneRefOfValuesFuncExpr(in)
   490  	case *VarPop:
   491  		return CloneRefOfVarPop(in)
   492  	case *VarSamp:
   493  		return CloneRefOfVarSamp(in)
   494  	case *Variable:
   495  		return CloneRefOfVariable(in)
   496  	case *Variance:
   497  		return CloneRefOfVariance(in)
   498  	case VindexParam:
   499  		return CloneVindexParam(in)
   500  	case *VindexSpec:
   501  		return CloneRefOfVindexSpec(in)
   502  	case *WeightStringFuncExpr:
   503  		return CloneRefOfWeightStringFuncExpr(in)
   504  	case *When:
   505  		return CloneRefOfWhen(in)
   506  	case *Where:
   507  		return CloneRefOfWhere(in)
   508  	case *WindowDefinition:
   509  		return CloneRefOfWindowDefinition(in)
   510  	case WindowDefinitions:
   511  		return CloneWindowDefinitions(in)
   512  	case *WindowSpecification:
   513  		return CloneRefOfWindowSpecification(in)
   514  	case *With:
   515  		return CloneRefOfWith(in)
   516  	case *XorExpr:
   517  		return CloneRefOfXorExpr(in)
   518  	default:
   519  		// this should never happen
   520  		return nil
   521  	}
   522  }
   523  
   524  // CloneRefOfAddColumns creates a deep clone of the input.
   525  func CloneRefOfAddColumns(n *AddColumns) *AddColumns {
   526  	if n == nil {
   527  		return nil
   528  	}
   529  	out := *n
   530  	out.Columns = CloneSliceOfRefOfColumnDefinition(n.Columns)
   531  	out.After = CloneRefOfColName(n.After)
   532  	return &out
   533  }
   534  
   535  // CloneRefOfAddConstraintDefinition creates a deep clone of the input.
   536  func CloneRefOfAddConstraintDefinition(n *AddConstraintDefinition) *AddConstraintDefinition {
   537  	if n == nil {
   538  		return nil
   539  	}
   540  	out := *n
   541  	out.ConstraintDefinition = CloneRefOfConstraintDefinition(n.ConstraintDefinition)
   542  	return &out
   543  }
   544  
   545  // CloneRefOfAddIndexDefinition creates a deep clone of the input.
   546  func CloneRefOfAddIndexDefinition(n *AddIndexDefinition) *AddIndexDefinition {
   547  	if n == nil {
   548  		return nil
   549  	}
   550  	out := *n
   551  	out.IndexDefinition = CloneRefOfIndexDefinition(n.IndexDefinition)
   552  	return &out
   553  }
   554  
   555  // CloneRefOfAliasedExpr creates a deep clone of the input.
   556  func CloneRefOfAliasedExpr(n *AliasedExpr) *AliasedExpr {
   557  	if n == nil {
   558  		return nil
   559  	}
   560  	out := *n
   561  	out.Expr = CloneExpr(n.Expr)
   562  	out.As = CloneIdentifierCI(n.As)
   563  	return &out
   564  }
   565  
   566  // CloneRefOfAliasedTableExpr creates a deep clone of the input.
   567  func CloneRefOfAliasedTableExpr(n *AliasedTableExpr) *AliasedTableExpr {
   568  	if n == nil {
   569  		return nil
   570  	}
   571  	out := *n
   572  	out.Expr = CloneSimpleTableExpr(n.Expr)
   573  	out.Partitions = ClonePartitions(n.Partitions)
   574  	out.As = CloneIdentifierCS(n.As)
   575  	out.Hints = CloneIndexHints(n.Hints)
   576  	out.Columns = CloneColumns(n.Columns)
   577  	return &out
   578  }
   579  
   580  // CloneRefOfAlterCharset creates a deep clone of the input.
   581  func CloneRefOfAlterCharset(n *AlterCharset) *AlterCharset {
   582  	if n == nil {
   583  		return nil
   584  	}
   585  	out := *n
   586  	return &out
   587  }
   588  
   589  // CloneRefOfAlterCheck creates a deep clone of the input.
   590  func CloneRefOfAlterCheck(n *AlterCheck) *AlterCheck {
   591  	if n == nil {
   592  		return nil
   593  	}
   594  	out := *n
   595  	out.Name = CloneIdentifierCI(n.Name)
   596  	return &out
   597  }
   598  
   599  // CloneRefOfAlterColumn creates a deep clone of the input.
   600  func CloneRefOfAlterColumn(n *AlterColumn) *AlterColumn {
   601  	if n == nil {
   602  		return nil
   603  	}
   604  	out := *n
   605  	out.Column = CloneRefOfColName(n.Column)
   606  	out.DefaultVal = CloneExpr(n.DefaultVal)
   607  	out.Invisible = CloneRefOfBool(n.Invisible)
   608  	return &out
   609  }
   610  
   611  // CloneRefOfAlterDatabase creates a deep clone of the input.
   612  func CloneRefOfAlterDatabase(n *AlterDatabase) *AlterDatabase {
   613  	if n == nil {
   614  		return nil
   615  	}
   616  	out := *n
   617  	out.DBName = CloneIdentifierCS(n.DBName)
   618  	out.AlterOptions = CloneSliceOfDatabaseOption(n.AlterOptions)
   619  	return &out
   620  }
   621  
   622  // CloneRefOfAlterIndex creates a deep clone of the input.
   623  func CloneRefOfAlterIndex(n *AlterIndex) *AlterIndex {
   624  	if n == nil {
   625  		return nil
   626  	}
   627  	out := *n
   628  	out.Name = CloneIdentifierCI(n.Name)
   629  	return &out
   630  }
   631  
   632  // CloneRefOfAlterMigration creates a deep clone of the input.
   633  func CloneRefOfAlterMigration(n *AlterMigration) *AlterMigration {
   634  	if n == nil {
   635  		return nil
   636  	}
   637  	out := *n
   638  	out.Ratio = CloneRefOfLiteral(n.Ratio)
   639  	return &out
   640  }
   641  
   642  // CloneRefOfAlterTable creates a deep clone of the input.
   643  func CloneRefOfAlterTable(n *AlterTable) *AlterTable {
   644  	if n == nil {
   645  		return nil
   646  	}
   647  	out := *n
   648  	out.Table = CloneTableName(n.Table)
   649  	out.AlterOptions = CloneSliceOfAlterOption(n.AlterOptions)
   650  	out.PartitionSpec = CloneRefOfPartitionSpec(n.PartitionSpec)
   651  	out.PartitionOption = CloneRefOfPartitionOption(n.PartitionOption)
   652  	out.Comments = CloneRefOfParsedComments(n.Comments)
   653  	return &out
   654  }
   655  
   656  // CloneRefOfAlterView creates a deep clone of the input.
   657  func CloneRefOfAlterView(n *AlterView) *AlterView {
   658  	if n == nil {
   659  		return nil
   660  	}
   661  	out := *n
   662  	out.ViewName = CloneTableName(n.ViewName)
   663  	out.Definer = CloneRefOfDefiner(n.Definer)
   664  	out.Columns = CloneColumns(n.Columns)
   665  	out.Select = CloneSelectStatement(n.Select)
   666  	out.Comments = CloneRefOfParsedComments(n.Comments)
   667  	return &out
   668  }
   669  
   670  // CloneRefOfAlterVschema creates a deep clone of the input.
   671  func CloneRefOfAlterVschema(n *AlterVschema) *AlterVschema {
   672  	if n == nil {
   673  		return nil
   674  	}
   675  	out := *n
   676  	out.Table = CloneTableName(n.Table)
   677  	out.VindexSpec = CloneRefOfVindexSpec(n.VindexSpec)
   678  	out.VindexCols = CloneSliceOfIdentifierCI(n.VindexCols)
   679  	out.AutoIncSpec = CloneRefOfAutoIncSpec(n.AutoIncSpec)
   680  	return &out
   681  }
   682  
   683  // CloneRefOfAndExpr creates a deep clone of the input.
   684  func CloneRefOfAndExpr(n *AndExpr) *AndExpr {
   685  	if n == nil {
   686  		return nil
   687  	}
   688  	out := *n
   689  	out.Left = CloneExpr(n.Left)
   690  	out.Right = CloneExpr(n.Right)
   691  	return &out
   692  }
   693  
   694  // CloneRefOfArgumentLessWindowExpr creates a deep clone of the input.
   695  func CloneRefOfArgumentLessWindowExpr(n *ArgumentLessWindowExpr) *ArgumentLessWindowExpr {
   696  	if n == nil {
   697  		return nil
   698  	}
   699  	out := *n
   700  	out.OverClause = CloneRefOfOverClause(n.OverClause)
   701  	return &out
   702  }
   703  
   704  // CloneRefOfAutoIncSpec creates a deep clone of the input.
   705  func CloneRefOfAutoIncSpec(n *AutoIncSpec) *AutoIncSpec {
   706  	if n == nil {
   707  		return nil
   708  	}
   709  	out := *n
   710  	out.Column = CloneIdentifierCI(n.Column)
   711  	out.Sequence = CloneTableName(n.Sequence)
   712  	return &out
   713  }
   714  
   715  // CloneRefOfAvg creates a deep clone of the input.
   716  func CloneRefOfAvg(n *Avg) *Avg {
   717  	if n == nil {
   718  		return nil
   719  	}
   720  	out := *n
   721  	out.Arg = CloneExpr(n.Arg)
   722  	return &out
   723  }
   724  
   725  // CloneRefOfBegin creates a deep clone of the input.
   726  func CloneRefOfBegin(n *Begin) *Begin {
   727  	if n == nil {
   728  		return nil
   729  	}
   730  	out := *n
   731  	out.TxAccessModes = CloneSliceOfTxAccessMode(n.TxAccessModes)
   732  	return &out
   733  }
   734  
   735  // CloneRefOfBetweenExpr creates a deep clone of the input.
   736  func CloneRefOfBetweenExpr(n *BetweenExpr) *BetweenExpr {
   737  	if n == nil {
   738  		return nil
   739  	}
   740  	out := *n
   741  	out.Left = CloneExpr(n.Left)
   742  	out.From = CloneExpr(n.From)
   743  	out.To = CloneExpr(n.To)
   744  	return &out
   745  }
   746  
   747  // CloneRefOfBinaryExpr creates a deep clone of the input.
   748  func CloneRefOfBinaryExpr(n *BinaryExpr) *BinaryExpr {
   749  	if n == nil {
   750  		return nil
   751  	}
   752  	out := *n
   753  	out.Left = CloneExpr(n.Left)
   754  	out.Right = CloneExpr(n.Right)
   755  	return &out
   756  }
   757  
   758  // CloneRefOfBitAnd creates a deep clone of the input.
   759  func CloneRefOfBitAnd(n *BitAnd) *BitAnd {
   760  	if n == nil {
   761  		return nil
   762  	}
   763  	out := *n
   764  	out.Arg = CloneExpr(n.Arg)
   765  	return &out
   766  }
   767  
   768  // CloneRefOfBitOr creates a deep clone of the input.
   769  func CloneRefOfBitOr(n *BitOr) *BitOr {
   770  	if n == nil {
   771  		return nil
   772  	}
   773  	out := *n
   774  	out.Arg = CloneExpr(n.Arg)
   775  	return &out
   776  }
   777  
   778  // CloneRefOfBitXor creates a deep clone of the input.
   779  func CloneRefOfBitXor(n *BitXor) *BitXor {
   780  	if n == nil {
   781  		return nil
   782  	}
   783  	out := *n
   784  	out.Arg = CloneExpr(n.Arg)
   785  	return &out
   786  }
   787  
   788  // CloneRefOfCallProc creates a deep clone of the input.
   789  func CloneRefOfCallProc(n *CallProc) *CallProc {
   790  	if n == nil {
   791  		return nil
   792  	}
   793  	out := *n
   794  	out.Name = CloneTableName(n.Name)
   795  	out.Params = CloneExprs(n.Params)
   796  	return &out
   797  }
   798  
   799  // CloneRefOfCaseExpr creates a deep clone of the input.
   800  func CloneRefOfCaseExpr(n *CaseExpr) *CaseExpr {
   801  	if n == nil {
   802  		return nil
   803  	}
   804  	out := *n
   805  	out.Expr = CloneExpr(n.Expr)
   806  	out.Whens = CloneSliceOfRefOfWhen(n.Whens)
   807  	out.Else = CloneExpr(n.Else)
   808  	return &out
   809  }
   810  
   811  // CloneRefOfCastExpr creates a deep clone of the input.
   812  func CloneRefOfCastExpr(n *CastExpr) *CastExpr {
   813  	if n == nil {
   814  		return nil
   815  	}
   816  	out := *n
   817  	out.Expr = CloneExpr(n.Expr)
   818  	out.Type = CloneRefOfConvertType(n.Type)
   819  	return &out
   820  }
   821  
   822  // CloneRefOfChangeColumn creates a deep clone of the input.
   823  func CloneRefOfChangeColumn(n *ChangeColumn) *ChangeColumn {
   824  	if n == nil {
   825  		return nil
   826  	}
   827  	out := *n
   828  	out.OldColumn = CloneRefOfColName(n.OldColumn)
   829  	out.NewColDefinition = CloneRefOfColumnDefinition(n.NewColDefinition)
   830  	out.After = CloneRefOfColName(n.After)
   831  	return &out
   832  }
   833  
   834  // CloneRefOfCharExpr creates a deep clone of the input.
   835  func CloneRefOfCharExpr(n *CharExpr) *CharExpr {
   836  	if n == nil {
   837  		return nil
   838  	}
   839  	out := *n
   840  	out.Exprs = CloneExprs(n.Exprs)
   841  	return &out
   842  }
   843  
   844  // CloneRefOfCheckConstraintDefinition creates a deep clone of the input.
   845  func CloneRefOfCheckConstraintDefinition(n *CheckConstraintDefinition) *CheckConstraintDefinition {
   846  	if n == nil {
   847  		return nil
   848  	}
   849  	out := *n
   850  	out.Expr = CloneExpr(n.Expr)
   851  	return &out
   852  }
   853  
   854  // CloneRefOfColName creates a deep clone of the input.
   855  func CloneRefOfColName(n *ColName) *ColName {
   856  	return n
   857  }
   858  
   859  // CloneRefOfCollateExpr creates a deep clone of the input.
   860  func CloneRefOfCollateExpr(n *CollateExpr) *CollateExpr {
   861  	if n == nil {
   862  		return nil
   863  	}
   864  	out := *n
   865  	out.Expr = CloneExpr(n.Expr)
   866  	return &out
   867  }
   868  
   869  // CloneRefOfColumnDefinition creates a deep clone of the input.
   870  func CloneRefOfColumnDefinition(n *ColumnDefinition) *ColumnDefinition {
   871  	if n == nil {
   872  		return nil
   873  	}
   874  	out := *n
   875  	out.Name = CloneIdentifierCI(n.Name)
   876  	out.Type = CloneRefOfColumnType(n.Type)
   877  	return &out
   878  }
   879  
   880  // CloneRefOfColumnType creates a deep clone of the input.
   881  func CloneRefOfColumnType(n *ColumnType) *ColumnType {
   882  	if n == nil {
   883  		return nil
   884  	}
   885  	out := *n
   886  	out.Options = CloneRefOfColumnTypeOptions(n.Options)
   887  	out.Length = CloneRefOfLiteral(n.Length)
   888  	out.Scale = CloneRefOfLiteral(n.Scale)
   889  	out.Charset = CloneColumnCharset(n.Charset)
   890  	out.EnumValues = CloneSliceOfString(n.EnumValues)
   891  	return &out
   892  }
   893  
   894  // CloneColumns creates a deep clone of the input.
   895  func CloneColumns(n Columns) Columns {
   896  	if n == nil {
   897  		return nil
   898  	}
   899  	res := make(Columns, len(n))
   900  	for i, x := range n {
   901  		res[i] = CloneIdentifierCI(x)
   902  	}
   903  	return res
   904  }
   905  
   906  // CloneRefOfCommentOnly creates a deep clone of the input.
   907  func CloneRefOfCommentOnly(n *CommentOnly) *CommentOnly {
   908  	if n == nil {
   909  		return nil
   910  	}
   911  	out := *n
   912  	out.Comments = CloneSliceOfString(n.Comments)
   913  	return &out
   914  }
   915  
   916  // CloneRefOfCommit creates a deep clone of the input.
   917  func CloneRefOfCommit(n *Commit) *Commit {
   918  	if n == nil {
   919  		return nil
   920  	}
   921  	out := *n
   922  	return &out
   923  }
   924  
   925  // CloneRefOfCommonTableExpr creates a deep clone of the input.
   926  func CloneRefOfCommonTableExpr(n *CommonTableExpr) *CommonTableExpr {
   927  	if n == nil {
   928  		return nil
   929  	}
   930  	out := *n
   931  	out.ID = CloneIdentifierCS(n.ID)
   932  	out.Columns = CloneColumns(n.Columns)
   933  	out.Subquery = CloneRefOfSubquery(n.Subquery)
   934  	return &out
   935  }
   936  
   937  // CloneRefOfComparisonExpr creates a deep clone of the input.
   938  func CloneRefOfComparisonExpr(n *ComparisonExpr) *ComparisonExpr {
   939  	if n == nil {
   940  		return nil
   941  	}
   942  	out := *n
   943  	out.Left = CloneExpr(n.Left)
   944  	out.Right = CloneExpr(n.Right)
   945  	out.Escape = CloneExpr(n.Escape)
   946  	return &out
   947  }
   948  
   949  // CloneRefOfConstraintDefinition creates a deep clone of the input.
   950  func CloneRefOfConstraintDefinition(n *ConstraintDefinition) *ConstraintDefinition {
   951  	if n == nil {
   952  		return nil
   953  	}
   954  	out := *n
   955  	out.Name = CloneIdentifierCI(n.Name)
   956  	out.Details = CloneConstraintInfo(n.Details)
   957  	return &out
   958  }
   959  
   960  // CloneRefOfConvertExpr creates a deep clone of the input.
   961  func CloneRefOfConvertExpr(n *ConvertExpr) *ConvertExpr {
   962  	if n == nil {
   963  		return nil
   964  	}
   965  	out := *n
   966  	out.Expr = CloneExpr(n.Expr)
   967  	out.Type = CloneRefOfConvertType(n.Type)
   968  	return &out
   969  }
   970  
   971  // CloneRefOfConvertType creates a deep clone of the input.
   972  func CloneRefOfConvertType(n *ConvertType) *ConvertType {
   973  	if n == nil {
   974  		return nil
   975  	}
   976  	out := *n
   977  	out.Length = CloneRefOfLiteral(n.Length)
   978  	out.Scale = CloneRefOfLiteral(n.Scale)
   979  	out.Charset = CloneColumnCharset(n.Charset)
   980  	return &out
   981  }
   982  
   983  // CloneRefOfConvertUsingExpr creates a deep clone of the input.
   984  func CloneRefOfConvertUsingExpr(n *ConvertUsingExpr) *ConvertUsingExpr {
   985  	if n == nil {
   986  		return nil
   987  	}
   988  	out := *n
   989  	out.Expr = CloneExpr(n.Expr)
   990  	return &out
   991  }
   992  
   993  // CloneRefOfCount creates a deep clone of the input.
   994  func CloneRefOfCount(n *Count) *Count {
   995  	if n == nil {
   996  		return nil
   997  	}
   998  	out := *n
   999  	out.Args = CloneExprs(n.Args)
  1000  	return &out
  1001  }
  1002  
  1003  // CloneRefOfCountStar creates a deep clone of the input.
  1004  func CloneRefOfCountStar(n *CountStar) *CountStar {
  1005  	if n == nil {
  1006  		return nil
  1007  	}
  1008  	out := *n
  1009  	return &out
  1010  }
  1011  
  1012  // CloneRefOfCreateDatabase creates a deep clone of the input.
  1013  func CloneRefOfCreateDatabase(n *CreateDatabase) *CreateDatabase {
  1014  	if n == nil {
  1015  		return nil
  1016  	}
  1017  	out := *n
  1018  	out.Comments = CloneRefOfParsedComments(n.Comments)
  1019  	out.DBName = CloneIdentifierCS(n.DBName)
  1020  	out.CreateOptions = CloneSliceOfDatabaseOption(n.CreateOptions)
  1021  	return &out
  1022  }
  1023  
  1024  // CloneRefOfCreateTable creates a deep clone of the input.
  1025  func CloneRefOfCreateTable(n *CreateTable) *CreateTable {
  1026  	if n == nil {
  1027  		return nil
  1028  	}
  1029  	out := *n
  1030  	out.Table = CloneTableName(n.Table)
  1031  	out.TableSpec = CloneRefOfTableSpec(n.TableSpec)
  1032  	out.OptLike = CloneRefOfOptLike(n.OptLike)
  1033  	out.Comments = CloneRefOfParsedComments(n.Comments)
  1034  	return &out
  1035  }
  1036  
  1037  // CloneRefOfCreateView creates a deep clone of the input.
  1038  func CloneRefOfCreateView(n *CreateView) *CreateView {
  1039  	if n == nil {
  1040  		return nil
  1041  	}
  1042  	out := *n
  1043  	out.ViewName = CloneTableName(n.ViewName)
  1044  	out.Definer = CloneRefOfDefiner(n.Definer)
  1045  	out.Columns = CloneColumns(n.Columns)
  1046  	out.Select = CloneSelectStatement(n.Select)
  1047  	out.Comments = CloneRefOfParsedComments(n.Comments)
  1048  	return &out
  1049  }
  1050  
  1051  // CloneRefOfCurTimeFuncExpr creates a deep clone of the input.
  1052  func CloneRefOfCurTimeFuncExpr(n *CurTimeFuncExpr) *CurTimeFuncExpr {
  1053  	if n == nil {
  1054  		return nil
  1055  	}
  1056  	out := *n
  1057  	out.Name = CloneIdentifierCI(n.Name)
  1058  	out.Fsp = CloneExpr(n.Fsp)
  1059  	return &out
  1060  }
  1061  
  1062  // CloneRefOfDeallocateStmt creates a deep clone of the input.
  1063  func CloneRefOfDeallocateStmt(n *DeallocateStmt) *DeallocateStmt {
  1064  	if n == nil {
  1065  		return nil
  1066  	}
  1067  	out := *n
  1068  	out.Comments = CloneRefOfParsedComments(n.Comments)
  1069  	out.Name = CloneIdentifierCI(n.Name)
  1070  	return &out
  1071  }
  1072  
  1073  // CloneRefOfDefault creates a deep clone of the input.
  1074  func CloneRefOfDefault(n *Default) *Default {
  1075  	if n == nil {
  1076  		return nil
  1077  	}
  1078  	out := *n
  1079  	return &out
  1080  }
  1081  
  1082  // CloneRefOfDefiner creates a deep clone of the input.
  1083  func CloneRefOfDefiner(n *Definer) *Definer {
  1084  	if n == nil {
  1085  		return nil
  1086  	}
  1087  	out := *n
  1088  	return &out
  1089  }
  1090  
  1091  // CloneRefOfDelete creates a deep clone of the input.
  1092  func CloneRefOfDelete(n *Delete) *Delete {
  1093  	if n == nil {
  1094  		return nil
  1095  	}
  1096  	out := *n
  1097  	out.With = CloneRefOfWith(n.With)
  1098  	out.Comments = CloneRefOfParsedComments(n.Comments)
  1099  	out.Targets = CloneTableNames(n.Targets)
  1100  	out.TableExprs = CloneTableExprs(n.TableExprs)
  1101  	out.Partitions = ClonePartitions(n.Partitions)
  1102  	out.Where = CloneRefOfWhere(n.Where)
  1103  	out.OrderBy = CloneOrderBy(n.OrderBy)
  1104  	out.Limit = CloneRefOfLimit(n.Limit)
  1105  	return &out
  1106  }
  1107  
  1108  // CloneRefOfDerivedTable creates a deep clone of the input.
  1109  func CloneRefOfDerivedTable(n *DerivedTable) *DerivedTable {
  1110  	if n == nil {
  1111  		return nil
  1112  	}
  1113  	out := *n
  1114  	out.Select = CloneSelectStatement(n.Select)
  1115  	return &out
  1116  }
  1117  
  1118  // CloneRefOfDropColumn creates a deep clone of the input.
  1119  func CloneRefOfDropColumn(n *DropColumn) *DropColumn {
  1120  	if n == nil {
  1121  		return nil
  1122  	}
  1123  	out := *n
  1124  	out.Name = CloneRefOfColName(n.Name)
  1125  	return &out
  1126  }
  1127  
  1128  // CloneRefOfDropDatabase creates a deep clone of the input.
  1129  func CloneRefOfDropDatabase(n *DropDatabase) *DropDatabase {
  1130  	if n == nil {
  1131  		return nil
  1132  	}
  1133  	out := *n
  1134  	out.Comments = CloneRefOfParsedComments(n.Comments)
  1135  	out.DBName = CloneIdentifierCS(n.DBName)
  1136  	return &out
  1137  }
  1138  
  1139  // CloneRefOfDropKey creates a deep clone of the input.
  1140  func CloneRefOfDropKey(n *DropKey) *DropKey {
  1141  	if n == nil {
  1142  		return nil
  1143  	}
  1144  	out := *n
  1145  	out.Name = CloneIdentifierCI(n.Name)
  1146  	return &out
  1147  }
  1148  
  1149  // CloneRefOfDropTable creates a deep clone of the input.
  1150  func CloneRefOfDropTable(n *DropTable) *DropTable {
  1151  	if n == nil {
  1152  		return nil
  1153  	}
  1154  	out := *n
  1155  	out.FromTables = CloneTableNames(n.FromTables)
  1156  	out.Comments = CloneRefOfParsedComments(n.Comments)
  1157  	return &out
  1158  }
  1159  
  1160  // CloneRefOfDropView creates a deep clone of the input.
  1161  func CloneRefOfDropView(n *DropView) *DropView {
  1162  	if n == nil {
  1163  		return nil
  1164  	}
  1165  	out := *n
  1166  	out.FromTables = CloneTableNames(n.FromTables)
  1167  	out.Comments = CloneRefOfParsedComments(n.Comments)
  1168  	return &out
  1169  }
  1170  
  1171  // CloneRefOfExecuteStmt creates a deep clone of the input.
  1172  func CloneRefOfExecuteStmt(n *ExecuteStmt) *ExecuteStmt {
  1173  	if n == nil {
  1174  		return nil
  1175  	}
  1176  	out := *n
  1177  	out.Name = CloneIdentifierCI(n.Name)
  1178  	out.Comments = CloneRefOfParsedComments(n.Comments)
  1179  	out.Arguments = CloneSliceOfRefOfVariable(n.Arguments)
  1180  	return &out
  1181  }
  1182  
  1183  // CloneRefOfExistsExpr creates a deep clone of the input.
  1184  func CloneRefOfExistsExpr(n *ExistsExpr) *ExistsExpr {
  1185  	if n == nil {
  1186  		return nil
  1187  	}
  1188  	out := *n
  1189  	out.Subquery = CloneRefOfSubquery(n.Subquery)
  1190  	return &out
  1191  }
  1192  
  1193  // CloneRefOfExplainStmt creates a deep clone of the input.
  1194  func CloneRefOfExplainStmt(n *ExplainStmt) *ExplainStmt {
  1195  	if n == nil {
  1196  		return nil
  1197  	}
  1198  	out := *n
  1199  	out.Statement = CloneStatement(n.Statement)
  1200  	out.Comments = CloneRefOfParsedComments(n.Comments)
  1201  	return &out
  1202  }
  1203  
  1204  // CloneRefOfExplainTab creates a deep clone of the input.
  1205  func CloneRefOfExplainTab(n *ExplainTab) *ExplainTab {
  1206  	if n == nil {
  1207  		return nil
  1208  	}
  1209  	out := *n
  1210  	out.Table = CloneTableName(n.Table)
  1211  	return &out
  1212  }
  1213  
  1214  // CloneExprs creates a deep clone of the input.
  1215  func CloneExprs(n Exprs) Exprs {
  1216  	if n == nil {
  1217  		return nil
  1218  	}
  1219  	res := make(Exprs, len(n))
  1220  	for i, x := range n {
  1221  		res[i] = CloneExpr(x)
  1222  	}
  1223  	return res
  1224  }
  1225  
  1226  // CloneRefOfExtractFuncExpr creates a deep clone of the input.
  1227  func CloneRefOfExtractFuncExpr(n *ExtractFuncExpr) *ExtractFuncExpr {
  1228  	if n == nil {
  1229  		return nil
  1230  	}
  1231  	out := *n
  1232  	out.Expr = CloneExpr(n.Expr)
  1233  	return &out
  1234  }
  1235  
  1236  // CloneRefOfExtractValueExpr creates a deep clone of the input.
  1237  func CloneRefOfExtractValueExpr(n *ExtractValueExpr) *ExtractValueExpr {
  1238  	if n == nil {
  1239  		return nil
  1240  	}
  1241  	out := *n
  1242  	out.Fragment = CloneExpr(n.Fragment)
  1243  	out.XPathExpr = CloneExpr(n.XPathExpr)
  1244  	return &out
  1245  }
  1246  
  1247  // CloneRefOfExtractedSubquery creates a deep clone of the input.
  1248  func CloneRefOfExtractedSubquery(n *ExtractedSubquery) *ExtractedSubquery {
  1249  	if n == nil {
  1250  		return nil
  1251  	}
  1252  	out := *n
  1253  	out.Original = CloneExpr(n.Original)
  1254  	out.Subquery = CloneRefOfSubquery(n.Subquery)
  1255  	out.OtherSide = CloneExpr(n.OtherSide)
  1256  	out.alternative = CloneExpr(n.alternative)
  1257  	return &out
  1258  }
  1259  
  1260  // CloneRefOfFirstOrLastValueExpr creates a deep clone of the input.
  1261  func CloneRefOfFirstOrLastValueExpr(n *FirstOrLastValueExpr) *FirstOrLastValueExpr {
  1262  	if n == nil {
  1263  		return nil
  1264  	}
  1265  	out := *n
  1266  	out.Expr = CloneExpr(n.Expr)
  1267  	out.NullTreatmentClause = CloneRefOfNullTreatmentClause(n.NullTreatmentClause)
  1268  	out.OverClause = CloneRefOfOverClause(n.OverClause)
  1269  	return &out
  1270  }
  1271  
  1272  // CloneRefOfFlush creates a deep clone of the input.
  1273  func CloneRefOfFlush(n *Flush) *Flush {
  1274  	if n == nil {
  1275  		return nil
  1276  	}
  1277  	out := *n
  1278  	out.FlushOptions = CloneSliceOfString(n.FlushOptions)
  1279  	out.TableNames = CloneTableNames(n.TableNames)
  1280  	return &out
  1281  }
  1282  
  1283  // CloneRefOfForce creates a deep clone of the input.
  1284  func CloneRefOfForce(n *Force) *Force {
  1285  	if n == nil {
  1286  		return nil
  1287  	}
  1288  	out := *n
  1289  	return &out
  1290  }
  1291  
  1292  // CloneRefOfForeignKeyDefinition creates a deep clone of the input.
  1293  func CloneRefOfForeignKeyDefinition(n *ForeignKeyDefinition) *ForeignKeyDefinition {
  1294  	if n == nil {
  1295  		return nil
  1296  	}
  1297  	out := *n
  1298  	out.Source = CloneColumns(n.Source)
  1299  	out.IndexName = CloneIdentifierCI(n.IndexName)
  1300  	out.ReferenceDefinition = CloneRefOfReferenceDefinition(n.ReferenceDefinition)
  1301  	return &out
  1302  }
  1303  
  1304  // CloneRefOfFrameClause creates a deep clone of the input.
  1305  func CloneRefOfFrameClause(n *FrameClause) *FrameClause {
  1306  	if n == nil {
  1307  		return nil
  1308  	}
  1309  	out := *n
  1310  	out.Start = CloneRefOfFramePoint(n.Start)
  1311  	out.End = CloneRefOfFramePoint(n.End)
  1312  	return &out
  1313  }
  1314  
  1315  // CloneRefOfFramePoint creates a deep clone of the input.
  1316  func CloneRefOfFramePoint(n *FramePoint) *FramePoint {
  1317  	if n == nil {
  1318  		return nil
  1319  	}
  1320  	out := *n
  1321  	out.Expr = CloneExpr(n.Expr)
  1322  	return &out
  1323  }
  1324  
  1325  // CloneRefOfFromFirstLastClause creates a deep clone of the input.
  1326  func CloneRefOfFromFirstLastClause(n *FromFirstLastClause) *FromFirstLastClause {
  1327  	if n == nil {
  1328  		return nil
  1329  	}
  1330  	out := *n
  1331  	return &out
  1332  }
  1333  
  1334  // CloneRefOfFuncExpr creates a deep clone of the input.
  1335  func CloneRefOfFuncExpr(n *FuncExpr) *FuncExpr {
  1336  	if n == nil {
  1337  		return nil
  1338  	}
  1339  	out := *n
  1340  	out.Qualifier = CloneIdentifierCS(n.Qualifier)
  1341  	out.Name = CloneIdentifierCI(n.Name)
  1342  	out.Exprs = CloneSelectExprs(n.Exprs)
  1343  	return &out
  1344  }
  1345  
  1346  // CloneRefOfGTIDFuncExpr creates a deep clone of the input.
  1347  func CloneRefOfGTIDFuncExpr(n *GTIDFuncExpr) *GTIDFuncExpr {
  1348  	if n == nil {
  1349  		return nil
  1350  	}
  1351  	out := *n
  1352  	out.Set1 = CloneExpr(n.Set1)
  1353  	out.Set2 = CloneExpr(n.Set2)
  1354  	out.Timeout = CloneExpr(n.Timeout)
  1355  	out.Channel = CloneExpr(n.Channel)
  1356  	return &out
  1357  }
  1358  
  1359  // CloneGroupBy creates a deep clone of the input.
  1360  func CloneGroupBy(n GroupBy) GroupBy {
  1361  	if n == nil {
  1362  		return nil
  1363  	}
  1364  	res := make(GroupBy, len(n))
  1365  	for i, x := range n {
  1366  		res[i] = CloneExpr(x)
  1367  	}
  1368  	return res
  1369  }
  1370  
  1371  // CloneRefOfGroupConcatExpr creates a deep clone of the input.
  1372  func CloneRefOfGroupConcatExpr(n *GroupConcatExpr) *GroupConcatExpr {
  1373  	if n == nil {
  1374  		return nil
  1375  	}
  1376  	out := *n
  1377  	out.Exprs = CloneExprs(n.Exprs)
  1378  	out.OrderBy = CloneOrderBy(n.OrderBy)
  1379  	out.Limit = CloneRefOfLimit(n.Limit)
  1380  	return &out
  1381  }
  1382  
  1383  // CloneIdentifierCI creates a deep clone of the input.
  1384  func CloneIdentifierCI(n IdentifierCI) IdentifierCI {
  1385  	return *CloneRefOfIdentifierCI(&n)
  1386  }
  1387  
  1388  // CloneIdentifierCS creates a deep clone of the input.
  1389  func CloneIdentifierCS(n IdentifierCS) IdentifierCS {
  1390  	return *CloneRefOfIdentifierCS(&n)
  1391  }
  1392  
  1393  // CloneRefOfIndexDefinition creates a deep clone of the input.
  1394  func CloneRefOfIndexDefinition(n *IndexDefinition) *IndexDefinition {
  1395  	if n == nil {
  1396  		return nil
  1397  	}
  1398  	out := *n
  1399  	out.Info = CloneRefOfIndexInfo(n.Info)
  1400  	out.Columns = CloneSliceOfRefOfIndexColumn(n.Columns)
  1401  	out.Options = CloneSliceOfRefOfIndexOption(n.Options)
  1402  	return &out
  1403  }
  1404  
  1405  // CloneRefOfIndexHint creates a deep clone of the input.
  1406  func CloneRefOfIndexHint(n *IndexHint) *IndexHint {
  1407  	if n == nil {
  1408  		return nil
  1409  	}
  1410  	out := *n
  1411  	out.Indexes = CloneSliceOfIdentifierCI(n.Indexes)
  1412  	return &out
  1413  }
  1414  
  1415  // CloneIndexHints creates a deep clone of the input.
  1416  func CloneIndexHints(n IndexHints) IndexHints {
  1417  	if n == nil {
  1418  		return nil
  1419  	}
  1420  	res := make(IndexHints, len(n))
  1421  	for i, x := range n {
  1422  		res[i] = CloneRefOfIndexHint(x)
  1423  	}
  1424  	return res
  1425  }
  1426  
  1427  // CloneRefOfIndexInfo creates a deep clone of the input.
  1428  func CloneRefOfIndexInfo(n *IndexInfo) *IndexInfo {
  1429  	if n == nil {
  1430  		return nil
  1431  	}
  1432  	out := *n
  1433  	out.Name = CloneIdentifierCI(n.Name)
  1434  	out.ConstraintName = CloneIdentifierCI(n.ConstraintName)
  1435  	return &out
  1436  }
  1437  
  1438  // CloneRefOfInsert creates a deep clone of the input.
  1439  func CloneRefOfInsert(n *Insert) *Insert {
  1440  	if n == nil {
  1441  		return nil
  1442  	}
  1443  	out := *n
  1444  	out.Comments = CloneRefOfParsedComments(n.Comments)
  1445  	out.Table = CloneTableName(n.Table)
  1446  	out.Partitions = ClonePartitions(n.Partitions)
  1447  	out.Columns = CloneColumns(n.Columns)
  1448  	out.Rows = CloneInsertRows(n.Rows)
  1449  	out.OnDup = CloneOnDup(n.OnDup)
  1450  	return &out
  1451  }
  1452  
  1453  // CloneRefOfInsertExpr creates a deep clone of the input.
  1454  func CloneRefOfInsertExpr(n *InsertExpr) *InsertExpr {
  1455  	if n == nil {
  1456  		return nil
  1457  	}
  1458  	out := *n
  1459  	out.Str = CloneExpr(n.Str)
  1460  	out.Pos = CloneExpr(n.Pos)
  1461  	out.Len = CloneExpr(n.Len)
  1462  	out.NewStr = CloneExpr(n.NewStr)
  1463  	return &out
  1464  }
  1465  
  1466  // CloneRefOfIntervalExpr creates a deep clone of the input.
  1467  func CloneRefOfIntervalExpr(n *IntervalExpr) *IntervalExpr {
  1468  	if n == nil {
  1469  		return nil
  1470  	}
  1471  	out := *n
  1472  	out.Expr = CloneExpr(n.Expr)
  1473  	return &out
  1474  }
  1475  
  1476  // CloneRefOfIntervalFuncExpr creates a deep clone of the input.
  1477  func CloneRefOfIntervalFuncExpr(n *IntervalFuncExpr) *IntervalFuncExpr {
  1478  	if n == nil {
  1479  		return nil
  1480  	}
  1481  	out := *n
  1482  	out.Expr = CloneExpr(n.Expr)
  1483  	out.Exprs = CloneExprs(n.Exprs)
  1484  	return &out
  1485  }
  1486  
  1487  // CloneRefOfIntroducerExpr creates a deep clone of the input.
  1488  func CloneRefOfIntroducerExpr(n *IntroducerExpr) *IntroducerExpr {
  1489  	if n == nil {
  1490  		return nil
  1491  	}
  1492  	out := *n
  1493  	out.Expr = CloneExpr(n.Expr)
  1494  	return &out
  1495  }
  1496  
  1497  // CloneRefOfIsExpr creates a deep clone of the input.
  1498  func CloneRefOfIsExpr(n *IsExpr) *IsExpr {
  1499  	if n == nil {
  1500  		return nil
  1501  	}
  1502  	out := *n
  1503  	out.Left = CloneExpr(n.Left)
  1504  	return &out
  1505  }
  1506  
  1507  // CloneRefOfJSONArrayExpr creates a deep clone of the input.
  1508  func CloneRefOfJSONArrayExpr(n *JSONArrayExpr) *JSONArrayExpr {
  1509  	if n == nil {
  1510  		return nil
  1511  	}
  1512  	out := *n
  1513  	out.Params = CloneExprs(n.Params)
  1514  	return &out
  1515  }
  1516  
  1517  // CloneRefOfJSONAttributesExpr creates a deep clone of the input.
  1518  func CloneRefOfJSONAttributesExpr(n *JSONAttributesExpr) *JSONAttributesExpr {
  1519  	if n == nil {
  1520  		return nil
  1521  	}
  1522  	out := *n
  1523  	out.JSONDoc = CloneExpr(n.JSONDoc)
  1524  	out.Path = CloneExpr(n.Path)
  1525  	return &out
  1526  }
  1527  
  1528  // CloneRefOfJSONContainsExpr creates a deep clone of the input.
  1529  func CloneRefOfJSONContainsExpr(n *JSONContainsExpr) *JSONContainsExpr {
  1530  	if n == nil {
  1531  		return nil
  1532  	}
  1533  	out := *n
  1534  	out.Target = CloneExpr(n.Target)
  1535  	out.Candidate = CloneExpr(n.Candidate)
  1536  	out.PathList = CloneSliceOfExpr(n.PathList)
  1537  	return &out
  1538  }
  1539  
  1540  // CloneRefOfJSONContainsPathExpr creates a deep clone of the input.
  1541  func CloneRefOfJSONContainsPathExpr(n *JSONContainsPathExpr) *JSONContainsPathExpr {
  1542  	if n == nil {
  1543  		return nil
  1544  	}
  1545  	out := *n
  1546  	out.JSONDoc = CloneExpr(n.JSONDoc)
  1547  	out.OneOrAll = CloneExpr(n.OneOrAll)
  1548  	out.PathList = CloneSliceOfExpr(n.PathList)
  1549  	return &out
  1550  }
  1551  
  1552  // CloneRefOfJSONExtractExpr creates a deep clone of the input.
  1553  func CloneRefOfJSONExtractExpr(n *JSONExtractExpr) *JSONExtractExpr {
  1554  	if n == nil {
  1555  		return nil
  1556  	}
  1557  	out := *n
  1558  	out.JSONDoc = CloneExpr(n.JSONDoc)
  1559  	out.PathList = CloneSliceOfExpr(n.PathList)
  1560  	return &out
  1561  }
  1562  
  1563  // CloneRefOfJSONKeysExpr creates a deep clone of the input.
  1564  func CloneRefOfJSONKeysExpr(n *JSONKeysExpr) *JSONKeysExpr {
  1565  	if n == nil {
  1566  		return nil
  1567  	}
  1568  	out := *n
  1569  	out.JSONDoc = CloneExpr(n.JSONDoc)
  1570  	out.Path = CloneExpr(n.Path)
  1571  	return &out
  1572  }
  1573  
  1574  // CloneRefOfJSONObjectExpr creates a deep clone of the input.
  1575  func CloneRefOfJSONObjectExpr(n *JSONObjectExpr) *JSONObjectExpr {
  1576  	if n == nil {
  1577  		return nil
  1578  	}
  1579  	out := *n
  1580  	out.Params = CloneSliceOfRefOfJSONObjectParam(n.Params)
  1581  	return &out
  1582  }
  1583  
  1584  // CloneRefOfJSONObjectParam creates a deep clone of the input.
  1585  func CloneRefOfJSONObjectParam(n *JSONObjectParam) *JSONObjectParam {
  1586  	if n == nil {
  1587  		return nil
  1588  	}
  1589  	out := *n
  1590  	out.Key = CloneExpr(n.Key)
  1591  	out.Value = CloneExpr(n.Value)
  1592  	return &out
  1593  }
  1594  
  1595  // CloneRefOfJSONOverlapsExpr creates a deep clone of the input.
  1596  func CloneRefOfJSONOverlapsExpr(n *JSONOverlapsExpr) *JSONOverlapsExpr {
  1597  	if n == nil {
  1598  		return nil
  1599  	}
  1600  	out := *n
  1601  	out.JSONDoc1 = CloneExpr(n.JSONDoc1)
  1602  	out.JSONDoc2 = CloneExpr(n.JSONDoc2)
  1603  	return &out
  1604  }
  1605  
  1606  // CloneRefOfJSONPrettyExpr creates a deep clone of the input.
  1607  func CloneRefOfJSONPrettyExpr(n *JSONPrettyExpr) *JSONPrettyExpr {
  1608  	if n == nil {
  1609  		return nil
  1610  	}
  1611  	out := *n
  1612  	out.JSONVal = CloneExpr(n.JSONVal)
  1613  	return &out
  1614  }
  1615  
  1616  // CloneRefOfJSONQuoteExpr creates a deep clone of the input.
  1617  func CloneRefOfJSONQuoteExpr(n *JSONQuoteExpr) *JSONQuoteExpr {
  1618  	if n == nil {
  1619  		return nil
  1620  	}
  1621  	out := *n
  1622  	out.StringArg = CloneExpr(n.StringArg)
  1623  	return &out
  1624  }
  1625  
  1626  // CloneRefOfJSONRemoveExpr creates a deep clone of the input.
  1627  func CloneRefOfJSONRemoveExpr(n *JSONRemoveExpr) *JSONRemoveExpr {
  1628  	if n == nil {
  1629  		return nil
  1630  	}
  1631  	out := *n
  1632  	out.JSONDoc = CloneExpr(n.JSONDoc)
  1633  	out.PathList = CloneExprs(n.PathList)
  1634  	return &out
  1635  }
  1636  
  1637  // CloneRefOfJSONSchemaValidFuncExpr creates a deep clone of the input.
  1638  func CloneRefOfJSONSchemaValidFuncExpr(n *JSONSchemaValidFuncExpr) *JSONSchemaValidFuncExpr {
  1639  	if n == nil {
  1640  		return nil
  1641  	}
  1642  	out := *n
  1643  	out.Schema = CloneExpr(n.Schema)
  1644  	out.Document = CloneExpr(n.Document)
  1645  	return &out
  1646  }
  1647  
  1648  // CloneRefOfJSONSchemaValidationReportFuncExpr creates a deep clone of the input.
  1649  func CloneRefOfJSONSchemaValidationReportFuncExpr(n *JSONSchemaValidationReportFuncExpr) *JSONSchemaValidationReportFuncExpr {
  1650  	if n == nil {
  1651  		return nil
  1652  	}
  1653  	out := *n
  1654  	out.Schema = CloneExpr(n.Schema)
  1655  	out.Document = CloneExpr(n.Document)
  1656  	return &out
  1657  }
  1658  
  1659  // CloneRefOfJSONSearchExpr creates a deep clone of the input.
  1660  func CloneRefOfJSONSearchExpr(n *JSONSearchExpr) *JSONSearchExpr {
  1661  	if n == nil {
  1662  		return nil
  1663  	}
  1664  	out := *n
  1665  	out.JSONDoc = CloneExpr(n.JSONDoc)
  1666  	out.OneOrAll = CloneExpr(n.OneOrAll)
  1667  	out.SearchStr = CloneExpr(n.SearchStr)
  1668  	out.EscapeChar = CloneExpr(n.EscapeChar)
  1669  	out.PathList = CloneSliceOfExpr(n.PathList)
  1670  	return &out
  1671  }
  1672  
  1673  // CloneRefOfJSONStorageFreeExpr creates a deep clone of the input.
  1674  func CloneRefOfJSONStorageFreeExpr(n *JSONStorageFreeExpr) *JSONStorageFreeExpr {
  1675  	if n == nil {
  1676  		return nil
  1677  	}
  1678  	out := *n
  1679  	out.JSONVal = CloneExpr(n.JSONVal)
  1680  	return &out
  1681  }
  1682  
  1683  // CloneRefOfJSONStorageSizeExpr creates a deep clone of the input.
  1684  func CloneRefOfJSONStorageSizeExpr(n *JSONStorageSizeExpr) *JSONStorageSizeExpr {
  1685  	if n == nil {
  1686  		return nil
  1687  	}
  1688  	out := *n
  1689  	out.JSONVal = CloneExpr(n.JSONVal)
  1690  	return &out
  1691  }
  1692  
  1693  // CloneRefOfJSONTableExpr creates a deep clone of the input.
  1694  func CloneRefOfJSONTableExpr(n *JSONTableExpr) *JSONTableExpr {
  1695  	if n == nil {
  1696  		return nil
  1697  	}
  1698  	out := *n
  1699  	out.Expr = CloneExpr(n.Expr)
  1700  	out.Alias = CloneIdentifierCS(n.Alias)
  1701  	out.Filter = CloneExpr(n.Filter)
  1702  	out.Columns = CloneSliceOfRefOfJtColumnDefinition(n.Columns)
  1703  	return &out
  1704  }
  1705  
  1706  // CloneRefOfJSONUnquoteExpr creates a deep clone of the input.
  1707  func CloneRefOfJSONUnquoteExpr(n *JSONUnquoteExpr) *JSONUnquoteExpr {
  1708  	if n == nil {
  1709  		return nil
  1710  	}
  1711  	out := *n
  1712  	out.JSONValue = CloneExpr(n.JSONValue)
  1713  	return &out
  1714  }
  1715  
  1716  // CloneRefOfJSONValueExpr creates a deep clone of the input.
  1717  func CloneRefOfJSONValueExpr(n *JSONValueExpr) *JSONValueExpr {
  1718  	if n == nil {
  1719  		return nil
  1720  	}
  1721  	out := *n
  1722  	out.JSONDoc = CloneExpr(n.JSONDoc)
  1723  	out.Path = CloneExpr(n.Path)
  1724  	out.ReturningType = CloneRefOfConvertType(n.ReturningType)
  1725  	out.EmptyOnResponse = CloneRefOfJtOnResponse(n.EmptyOnResponse)
  1726  	out.ErrorOnResponse = CloneRefOfJtOnResponse(n.ErrorOnResponse)
  1727  	return &out
  1728  }
  1729  
  1730  // CloneRefOfJSONValueMergeExpr creates a deep clone of the input.
  1731  func CloneRefOfJSONValueMergeExpr(n *JSONValueMergeExpr) *JSONValueMergeExpr {
  1732  	if n == nil {
  1733  		return nil
  1734  	}
  1735  	out := *n
  1736  	out.JSONDoc = CloneExpr(n.JSONDoc)
  1737  	out.JSONDocList = CloneExprs(n.JSONDocList)
  1738  	return &out
  1739  }
  1740  
  1741  // CloneRefOfJSONValueModifierExpr creates a deep clone of the input.
  1742  func CloneRefOfJSONValueModifierExpr(n *JSONValueModifierExpr) *JSONValueModifierExpr {
  1743  	if n == nil {
  1744  		return nil
  1745  	}
  1746  	out := *n
  1747  	out.JSONDoc = CloneExpr(n.JSONDoc)
  1748  	out.Params = CloneSliceOfRefOfJSONObjectParam(n.Params)
  1749  	return &out
  1750  }
  1751  
  1752  // CloneRefOfJoinCondition creates a deep clone of the input.
  1753  func CloneRefOfJoinCondition(n *JoinCondition) *JoinCondition {
  1754  	if n == nil {
  1755  		return nil
  1756  	}
  1757  	out := *n
  1758  	out.On = CloneExpr(n.On)
  1759  	out.Using = CloneColumns(n.Using)
  1760  	return &out
  1761  }
  1762  
  1763  // CloneRefOfJoinTableExpr creates a deep clone of the input.
  1764  func CloneRefOfJoinTableExpr(n *JoinTableExpr) *JoinTableExpr {
  1765  	if n == nil {
  1766  		return nil
  1767  	}
  1768  	out := *n
  1769  	out.LeftExpr = CloneTableExpr(n.LeftExpr)
  1770  	out.RightExpr = CloneTableExpr(n.RightExpr)
  1771  	out.Condition = CloneRefOfJoinCondition(n.Condition)
  1772  	return &out
  1773  }
  1774  
  1775  // CloneRefOfJtColumnDefinition creates a deep clone of the input.
  1776  func CloneRefOfJtColumnDefinition(n *JtColumnDefinition) *JtColumnDefinition {
  1777  	if n == nil {
  1778  		return nil
  1779  	}
  1780  	out := *n
  1781  	out.JtOrdinal = CloneRefOfJtOrdinalColDef(n.JtOrdinal)
  1782  	out.JtPath = CloneRefOfJtPathColDef(n.JtPath)
  1783  	out.JtNestedPath = CloneRefOfJtNestedPathColDef(n.JtNestedPath)
  1784  	return &out
  1785  }
  1786  
  1787  // CloneRefOfJtOnResponse creates a deep clone of the input.
  1788  func CloneRefOfJtOnResponse(n *JtOnResponse) *JtOnResponse {
  1789  	if n == nil {
  1790  		return nil
  1791  	}
  1792  	out := *n
  1793  	out.Expr = CloneExpr(n.Expr)
  1794  	return &out
  1795  }
  1796  
  1797  // CloneRefOfKeyState creates a deep clone of the input.
  1798  func CloneRefOfKeyState(n *KeyState) *KeyState {
  1799  	if n == nil {
  1800  		return nil
  1801  	}
  1802  	out := *n
  1803  	return &out
  1804  }
  1805  
  1806  // CloneRefOfLagLeadExpr creates a deep clone of the input.
  1807  func CloneRefOfLagLeadExpr(n *LagLeadExpr) *LagLeadExpr {
  1808  	if n == nil {
  1809  		return nil
  1810  	}
  1811  	out := *n
  1812  	out.Expr = CloneExpr(n.Expr)
  1813  	out.N = CloneExpr(n.N)
  1814  	out.Default = CloneExpr(n.Default)
  1815  	out.OverClause = CloneRefOfOverClause(n.OverClause)
  1816  	out.NullTreatmentClause = CloneRefOfNullTreatmentClause(n.NullTreatmentClause)
  1817  	return &out
  1818  }
  1819  
  1820  // CloneRefOfLimit creates a deep clone of the input.
  1821  func CloneRefOfLimit(n *Limit) *Limit {
  1822  	if n == nil {
  1823  		return nil
  1824  	}
  1825  	out := *n
  1826  	out.Offset = CloneExpr(n.Offset)
  1827  	out.Rowcount = CloneExpr(n.Rowcount)
  1828  	return &out
  1829  }
  1830  
  1831  // CloneRefOfLineStringExpr creates a deep clone of the input.
  1832  func CloneRefOfLineStringExpr(n *LineStringExpr) *LineStringExpr {
  1833  	if n == nil {
  1834  		return nil
  1835  	}
  1836  	out := *n
  1837  	out.PointParams = CloneExprs(n.PointParams)
  1838  	return &out
  1839  }
  1840  
  1841  // CloneRefOfLiteral creates a deep clone of the input.
  1842  func CloneRefOfLiteral(n *Literal) *Literal {
  1843  	if n == nil {
  1844  		return nil
  1845  	}
  1846  	out := *n
  1847  	return &out
  1848  }
  1849  
  1850  // CloneRefOfLoad creates a deep clone of the input.
  1851  func CloneRefOfLoad(n *Load) *Load {
  1852  	if n == nil {
  1853  		return nil
  1854  	}
  1855  	out := *n
  1856  	return &out
  1857  }
  1858  
  1859  // CloneRefOfLocateExpr creates a deep clone of the input.
  1860  func CloneRefOfLocateExpr(n *LocateExpr) *LocateExpr {
  1861  	if n == nil {
  1862  		return nil
  1863  	}
  1864  	out := *n
  1865  	out.SubStr = CloneExpr(n.SubStr)
  1866  	out.Str = CloneExpr(n.Str)
  1867  	out.Pos = CloneExpr(n.Pos)
  1868  	return &out
  1869  }
  1870  
  1871  // CloneRefOfLockOption creates a deep clone of the input.
  1872  func CloneRefOfLockOption(n *LockOption) *LockOption {
  1873  	if n == nil {
  1874  		return nil
  1875  	}
  1876  	out := *n
  1877  	return &out
  1878  }
  1879  
  1880  // CloneRefOfLockTables creates a deep clone of the input.
  1881  func CloneRefOfLockTables(n *LockTables) *LockTables {
  1882  	if n == nil {
  1883  		return nil
  1884  	}
  1885  	out := *n
  1886  	out.Tables = CloneTableAndLockTypes(n.Tables)
  1887  	return &out
  1888  }
  1889  
  1890  // CloneRefOfLockingFunc creates a deep clone of the input.
  1891  func CloneRefOfLockingFunc(n *LockingFunc) *LockingFunc {
  1892  	if n == nil {
  1893  		return nil
  1894  	}
  1895  	out := *n
  1896  	out.Name = CloneExpr(n.Name)
  1897  	out.Timeout = CloneExpr(n.Timeout)
  1898  	return &out
  1899  }
  1900  
  1901  // CloneRefOfMatchExpr creates a deep clone of the input.
  1902  func CloneRefOfMatchExpr(n *MatchExpr) *MatchExpr {
  1903  	if n == nil {
  1904  		return nil
  1905  	}
  1906  	out := *n
  1907  	out.Columns = CloneSliceOfRefOfColName(n.Columns)
  1908  	out.Expr = CloneExpr(n.Expr)
  1909  	return &out
  1910  }
  1911  
  1912  // CloneRefOfMax creates a deep clone of the input.
  1913  func CloneRefOfMax(n *Max) *Max {
  1914  	if n == nil {
  1915  		return nil
  1916  	}
  1917  	out := *n
  1918  	out.Arg = CloneExpr(n.Arg)
  1919  	return &out
  1920  }
  1921  
  1922  // CloneRefOfMemberOfExpr creates a deep clone of the input.
  1923  func CloneRefOfMemberOfExpr(n *MemberOfExpr) *MemberOfExpr {
  1924  	if n == nil {
  1925  		return nil
  1926  	}
  1927  	out := *n
  1928  	out.Value = CloneExpr(n.Value)
  1929  	out.JSONArr = CloneExpr(n.JSONArr)
  1930  	return &out
  1931  }
  1932  
  1933  // CloneRefOfMin creates a deep clone of the input.
  1934  func CloneRefOfMin(n *Min) *Min {
  1935  	if n == nil {
  1936  		return nil
  1937  	}
  1938  	out := *n
  1939  	out.Arg = CloneExpr(n.Arg)
  1940  	return &out
  1941  }
  1942  
  1943  // CloneRefOfModifyColumn creates a deep clone of the input.
  1944  func CloneRefOfModifyColumn(n *ModifyColumn) *ModifyColumn {
  1945  	if n == nil {
  1946  		return nil
  1947  	}
  1948  	out := *n
  1949  	out.NewColDefinition = CloneRefOfColumnDefinition(n.NewColDefinition)
  1950  	out.After = CloneRefOfColName(n.After)
  1951  	return &out
  1952  }
  1953  
  1954  // CloneRefOfNTHValueExpr creates a deep clone of the input.
  1955  func CloneRefOfNTHValueExpr(n *NTHValueExpr) *NTHValueExpr {
  1956  	if n == nil {
  1957  		return nil
  1958  	}
  1959  	out := *n
  1960  	out.Expr = CloneExpr(n.Expr)
  1961  	out.N = CloneExpr(n.N)
  1962  	out.OverClause = CloneRefOfOverClause(n.OverClause)
  1963  	out.FromFirstLastClause = CloneRefOfFromFirstLastClause(n.FromFirstLastClause)
  1964  	out.NullTreatmentClause = CloneRefOfNullTreatmentClause(n.NullTreatmentClause)
  1965  	return &out
  1966  }
  1967  
  1968  // CloneRefOfNamedWindow creates a deep clone of the input.
  1969  func CloneRefOfNamedWindow(n *NamedWindow) *NamedWindow {
  1970  	if n == nil {
  1971  		return nil
  1972  	}
  1973  	out := *n
  1974  	out.Windows = CloneWindowDefinitions(n.Windows)
  1975  	return &out
  1976  }
  1977  
  1978  // CloneNamedWindows creates a deep clone of the input.
  1979  func CloneNamedWindows(n NamedWindows) NamedWindows {
  1980  	if n == nil {
  1981  		return nil
  1982  	}
  1983  	res := make(NamedWindows, len(n))
  1984  	for i, x := range n {
  1985  		res[i] = CloneRefOfNamedWindow(x)
  1986  	}
  1987  	return res
  1988  }
  1989  
  1990  // CloneRefOfNextval creates a deep clone of the input.
  1991  func CloneRefOfNextval(n *Nextval) *Nextval {
  1992  	if n == nil {
  1993  		return nil
  1994  	}
  1995  	out := *n
  1996  	out.Expr = CloneExpr(n.Expr)
  1997  	return &out
  1998  }
  1999  
  2000  // CloneRefOfNotExpr creates a deep clone of the input.
  2001  func CloneRefOfNotExpr(n *NotExpr) *NotExpr {
  2002  	if n == nil {
  2003  		return nil
  2004  	}
  2005  	out := *n
  2006  	out.Expr = CloneExpr(n.Expr)
  2007  	return &out
  2008  }
  2009  
  2010  // CloneRefOfNtileExpr creates a deep clone of the input.
  2011  func CloneRefOfNtileExpr(n *NtileExpr) *NtileExpr {
  2012  	if n == nil {
  2013  		return nil
  2014  	}
  2015  	out := *n
  2016  	out.N = CloneExpr(n.N)
  2017  	out.OverClause = CloneRefOfOverClause(n.OverClause)
  2018  	return &out
  2019  }
  2020  
  2021  // CloneRefOfNullTreatmentClause creates a deep clone of the input.
  2022  func CloneRefOfNullTreatmentClause(n *NullTreatmentClause) *NullTreatmentClause {
  2023  	if n == nil {
  2024  		return nil
  2025  	}
  2026  	out := *n
  2027  	return &out
  2028  }
  2029  
  2030  // CloneRefOfNullVal creates a deep clone of the input.
  2031  func CloneRefOfNullVal(n *NullVal) *NullVal {
  2032  	if n == nil {
  2033  		return nil
  2034  	}
  2035  	out := *n
  2036  	return &out
  2037  }
  2038  
  2039  // CloneRefOfOffset creates a deep clone of the input.
  2040  func CloneRefOfOffset(n *Offset) *Offset {
  2041  	if n == nil {
  2042  		return nil
  2043  	}
  2044  	out := *n
  2045  	return &out
  2046  }
  2047  
  2048  // CloneOnDup creates a deep clone of the input.
  2049  func CloneOnDup(n OnDup) OnDup {
  2050  	if n == nil {
  2051  		return nil
  2052  	}
  2053  	res := make(OnDup, len(n))
  2054  	for i, x := range n {
  2055  		res[i] = CloneRefOfUpdateExpr(x)
  2056  	}
  2057  	return res
  2058  }
  2059  
  2060  // CloneRefOfOptLike creates a deep clone of the input.
  2061  func CloneRefOfOptLike(n *OptLike) *OptLike {
  2062  	if n == nil {
  2063  		return nil
  2064  	}
  2065  	out := *n
  2066  	out.LikeTable = CloneTableName(n.LikeTable)
  2067  	return &out
  2068  }
  2069  
  2070  // CloneRefOfOrExpr creates a deep clone of the input.
  2071  func CloneRefOfOrExpr(n *OrExpr) *OrExpr {
  2072  	if n == nil {
  2073  		return nil
  2074  	}
  2075  	out := *n
  2076  	out.Left = CloneExpr(n.Left)
  2077  	out.Right = CloneExpr(n.Right)
  2078  	return &out
  2079  }
  2080  
  2081  // CloneRefOfOrder creates a deep clone of the input.
  2082  func CloneRefOfOrder(n *Order) *Order {
  2083  	if n == nil {
  2084  		return nil
  2085  	}
  2086  	out := *n
  2087  	out.Expr = CloneExpr(n.Expr)
  2088  	return &out
  2089  }
  2090  
  2091  // CloneOrderBy creates a deep clone of the input.
  2092  func CloneOrderBy(n OrderBy) OrderBy {
  2093  	if n == nil {
  2094  		return nil
  2095  	}
  2096  	res := make(OrderBy, len(n))
  2097  	for i, x := range n {
  2098  		res[i] = CloneRefOfOrder(x)
  2099  	}
  2100  	return res
  2101  }
  2102  
  2103  // CloneRefOfOrderByOption creates a deep clone of the input.
  2104  func CloneRefOfOrderByOption(n *OrderByOption) *OrderByOption {
  2105  	if n == nil {
  2106  		return nil
  2107  	}
  2108  	out := *n
  2109  	out.Cols = CloneColumns(n.Cols)
  2110  	return &out
  2111  }
  2112  
  2113  // CloneRefOfOtherAdmin creates a deep clone of the input.
  2114  func CloneRefOfOtherAdmin(n *OtherAdmin) *OtherAdmin {
  2115  	if n == nil {
  2116  		return nil
  2117  	}
  2118  	out := *n
  2119  	return &out
  2120  }
  2121  
  2122  // CloneRefOfOtherRead creates a deep clone of the input.
  2123  func CloneRefOfOtherRead(n *OtherRead) *OtherRead {
  2124  	if n == nil {
  2125  		return nil
  2126  	}
  2127  	out := *n
  2128  	return &out
  2129  }
  2130  
  2131  // CloneRefOfOverClause creates a deep clone of the input.
  2132  func CloneRefOfOverClause(n *OverClause) *OverClause {
  2133  	if n == nil {
  2134  		return nil
  2135  	}
  2136  	out := *n
  2137  	out.WindowName = CloneIdentifierCI(n.WindowName)
  2138  	out.WindowSpec = CloneRefOfWindowSpecification(n.WindowSpec)
  2139  	return &out
  2140  }
  2141  
  2142  // CloneRefOfParenTableExpr creates a deep clone of the input.
  2143  func CloneRefOfParenTableExpr(n *ParenTableExpr) *ParenTableExpr {
  2144  	if n == nil {
  2145  		return nil
  2146  	}
  2147  	out := *n
  2148  	out.Exprs = CloneTableExprs(n.Exprs)
  2149  	return &out
  2150  }
  2151  
  2152  // CloneRefOfParsedComments creates a deep clone of the input.
  2153  func CloneRefOfParsedComments(n *ParsedComments) *ParsedComments {
  2154  	if n == nil {
  2155  		return nil
  2156  	}
  2157  	out := *n
  2158  	out.comments = CloneComments(n.comments)
  2159  	return &out
  2160  }
  2161  
  2162  // CloneRefOfPartitionDefinition creates a deep clone of the input.
  2163  func CloneRefOfPartitionDefinition(n *PartitionDefinition) *PartitionDefinition {
  2164  	if n == nil {
  2165  		return nil
  2166  	}
  2167  	out := *n
  2168  	out.Name = CloneIdentifierCI(n.Name)
  2169  	out.Options = CloneRefOfPartitionDefinitionOptions(n.Options)
  2170  	return &out
  2171  }
  2172  
  2173  // CloneRefOfPartitionDefinitionOptions creates a deep clone of the input.
  2174  func CloneRefOfPartitionDefinitionOptions(n *PartitionDefinitionOptions) *PartitionDefinitionOptions {
  2175  	if n == nil {
  2176  		return nil
  2177  	}
  2178  	out := *n
  2179  	out.ValueRange = CloneRefOfPartitionValueRange(n.ValueRange)
  2180  	out.Comment = CloneRefOfLiteral(n.Comment)
  2181  	out.Engine = CloneRefOfPartitionEngine(n.Engine)
  2182  	out.DataDirectory = CloneRefOfLiteral(n.DataDirectory)
  2183  	out.IndexDirectory = CloneRefOfLiteral(n.IndexDirectory)
  2184  	out.MaxRows = CloneRefOfInt(n.MaxRows)
  2185  	out.MinRows = CloneRefOfInt(n.MinRows)
  2186  	out.SubPartitionDefinitions = CloneSubPartitionDefinitions(n.SubPartitionDefinitions)
  2187  	return &out
  2188  }
  2189  
  2190  // CloneRefOfPartitionEngine creates a deep clone of the input.
  2191  func CloneRefOfPartitionEngine(n *PartitionEngine) *PartitionEngine {
  2192  	if n == nil {
  2193  		return nil
  2194  	}
  2195  	out := *n
  2196  	return &out
  2197  }
  2198  
  2199  // CloneRefOfPartitionOption creates a deep clone of the input.
  2200  func CloneRefOfPartitionOption(n *PartitionOption) *PartitionOption {
  2201  	if n == nil {
  2202  		return nil
  2203  	}
  2204  	out := *n
  2205  	out.ColList = CloneColumns(n.ColList)
  2206  	out.Expr = CloneExpr(n.Expr)
  2207  	out.SubPartition = CloneRefOfSubPartition(n.SubPartition)
  2208  	out.Definitions = CloneSliceOfRefOfPartitionDefinition(n.Definitions)
  2209  	return &out
  2210  }
  2211  
  2212  // CloneRefOfPartitionSpec creates a deep clone of the input.
  2213  func CloneRefOfPartitionSpec(n *PartitionSpec) *PartitionSpec {
  2214  	if n == nil {
  2215  		return nil
  2216  	}
  2217  	out := *n
  2218  	out.Names = ClonePartitions(n.Names)
  2219  	out.Number = CloneRefOfLiteral(n.Number)
  2220  	out.TableName = CloneTableName(n.TableName)
  2221  	out.Definitions = CloneSliceOfRefOfPartitionDefinition(n.Definitions)
  2222  	return &out
  2223  }
  2224  
  2225  // CloneRefOfPartitionValueRange creates a deep clone of the input.
  2226  func CloneRefOfPartitionValueRange(n *PartitionValueRange) *PartitionValueRange {
  2227  	if n == nil {
  2228  		return nil
  2229  	}
  2230  	out := *n
  2231  	out.Range = CloneValTuple(n.Range)
  2232  	return &out
  2233  }
  2234  
  2235  // ClonePartitions creates a deep clone of the input.
  2236  func ClonePartitions(n Partitions) Partitions {
  2237  	if n == nil {
  2238  		return nil
  2239  	}
  2240  	res := make(Partitions, len(n))
  2241  	for i, x := range n {
  2242  		res[i] = CloneIdentifierCI(x)
  2243  	}
  2244  	return res
  2245  }
  2246  
  2247  // CloneRefOfPerformanceSchemaFuncExpr creates a deep clone of the input.
  2248  func CloneRefOfPerformanceSchemaFuncExpr(n *PerformanceSchemaFuncExpr) *PerformanceSchemaFuncExpr {
  2249  	if n == nil {
  2250  		return nil
  2251  	}
  2252  	out := *n
  2253  	out.Argument = CloneExpr(n.Argument)
  2254  	return &out
  2255  }
  2256  
  2257  // CloneRefOfPointExpr creates a deep clone of the input.
  2258  func CloneRefOfPointExpr(n *PointExpr) *PointExpr {
  2259  	if n == nil {
  2260  		return nil
  2261  	}
  2262  	out := *n
  2263  	out.XCordinate = CloneExpr(n.XCordinate)
  2264  	out.YCordinate = CloneExpr(n.YCordinate)
  2265  	return &out
  2266  }
  2267  
  2268  // CloneRefOfPrepareStmt creates a deep clone of the input.
  2269  func CloneRefOfPrepareStmt(n *PrepareStmt) *PrepareStmt {
  2270  	if n == nil {
  2271  		return nil
  2272  	}
  2273  	out := *n
  2274  	out.Name = CloneIdentifierCI(n.Name)
  2275  	out.Statement = CloneExpr(n.Statement)
  2276  	out.Comments = CloneRefOfParsedComments(n.Comments)
  2277  	return &out
  2278  }
  2279  
  2280  // CloneRefOfReferenceDefinition creates a deep clone of the input.
  2281  func CloneRefOfReferenceDefinition(n *ReferenceDefinition) *ReferenceDefinition {
  2282  	if n == nil {
  2283  		return nil
  2284  	}
  2285  	out := *n
  2286  	out.ReferencedTable = CloneTableName(n.ReferencedTable)
  2287  	out.ReferencedColumns = CloneColumns(n.ReferencedColumns)
  2288  	return &out
  2289  }
  2290  
  2291  // CloneRefOfRegexpInstrExpr creates a deep clone of the input.
  2292  func CloneRefOfRegexpInstrExpr(n *RegexpInstrExpr) *RegexpInstrExpr {
  2293  	if n == nil {
  2294  		return nil
  2295  	}
  2296  	out := *n
  2297  	out.Expr = CloneExpr(n.Expr)
  2298  	out.Pattern = CloneExpr(n.Pattern)
  2299  	out.Position = CloneExpr(n.Position)
  2300  	out.Occurrence = CloneExpr(n.Occurrence)
  2301  	out.ReturnOption = CloneExpr(n.ReturnOption)
  2302  	out.MatchType = CloneExpr(n.MatchType)
  2303  	return &out
  2304  }
  2305  
  2306  // CloneRefOfRegexpLikeExpr creates a deep clone of the input.
  2307  func CloneRefOfRegexpLikeExpr(n *RegexpLikeExpr) *RegexpLikeExpr {
  2308  	if n == nil {
  2309  		return nil
  2310  	}
  2311  	out := *n
  2312  	out.Expr = CloneExpr(n.Expr)
  2313  	out.Pattern = CloneExpr(n.Pattern)
  2314  	out.MatchType = CloneExpr(n.MatchType)
  2315  	return &out
  2316  }
  2317  
  2318  // CloneRefOfRegexpReplaceExpr creates a deep clone of the input.
  2319  func CloneRefOfRegexpReplaceExpr(n *RegexpReplaceExpr) *RegexpReplaceExpr {
  2320  	if n == nil {
  2321  		return nil
  2322  	}
  2323  	out := *n
  2324  	out.Expr = CloneExpr(n.Expr)
  2325  	out.Pattern = CloneExpr(n.Pattern)
  2326  	out.Repl = CloneExpr(n.Repl)
  2327  	out.Occurrence = CloneExpr(n.Occurrence)
  2328  	out.Position = CloneExpr(n.Position)
  2329  	out.MatchType = CloneExpr(n.MatchType)
  2330  	return &out
  2331  }
  2332  
  2333  // CloneRefOfRegexpSubstrExpr creates a deep clone of the input.
  2334  func CloneRefOfRegexpSubstrExpr(n *RegexpSubstrExpr) *RegexpSubstrExpr {
  2335  	if n == nil {
  2336  		return nil
  2337  	}
  2338  	out := *n
  2339  	out.Expr = CloneExpr(n.Expr)
  2340  	out.Pattern = CloneExpr(n.Pattern)
  2341  	out.Occurrence = CloneExpr(n.Occurrence)
  2342  	out.Position = CloneExpr(n.Position)
  2343  	out.MatchType = CloneExpr(n.MatchType)
  2344  	return &out
  2345  }
  2346  
  2347  // CloneRefOfRelease creates a deep clone of the input.
  2348  func CloneRefOfRelease(n *Release) *Release {
  2349  	if n == nil {
  2350  		return nil
  2351  	}
  2352  	out := *n
  2353  	out.Name = CloneIdentifierCI(n.Name)
  2354  	return &out
  2355  }
  2356  
  2357  // CloneRefOfRenameColumn creates a deep clone of the input.
  2358  func CloneRefOfRenameColumn(n *RenameColumn) *RenameColumn {
  2359  	if n == nil {
  2360  		return nil
  2361  	}
  2362  	out := *n
  2363  	out.OldName = CloneRefOfColName(n.OldName)
  2364  	out.NewName = CloneRefOfColName(n.NewName)
  2365  	return &out
  2366  }
  2367  
  2368  // CloneRefOfRenameIndex creates a deep clone of the input.
  2369  func CloneRefOfRenameIndex(n *RenameIndex) *RenameIndex {
  2370  	if n == nil {
  2371  		return nil
  2372  	}
  2373  	out := *n
  2374  	out.OldName = CloneIdentifierCI(n.OldName)
  2375  	out.NewName = CloneIdentifierCI(n.NewName)
  2376  	return &out
  2377  }
  2378  
  2379  // CloneRefOfRenameTable creates a deep clone of the input.
  2380  func CloneRefOfRenameTable(n *RenameTable) *RenameTable {
  2381  	if n == nil {
  2382  		return nil
  2383  	}
  2384  	out := *n
  2385  	out.TablePairs = CloneSliceOfRefOfRenameTablePair(n.TablePairs)
  2386  	return &out
  2387  }
  2388  
  2389  // CloneRefOfRenameTableName creates a deep clone of the input.
  2390  func CloneRefOfRenameTableName(n *RenameTableName) *RenameTableName {
  2391  	if n == nil {
  2392  		return nil
  2393  	}
  2394  	out := *n
  2395  	out.Table = CloneTableName(n.Table)
  2396  	return &out
  2397  }
  2398  
  2399  // CloneRefOfRevertMigration creates a deep clone of the input.
  2400  func CloneRefOfRevertMigration(n *RevertMigration) *RevertMigration {
  2401  	if n == nil {
  2402  		return nil
  2403  	}
  2404  	out := *n
  2405  	out.Comments = CloneRefOfParsedComments(n.Comments)
  2406  	return &out
  2407  }
  2408  
  2409  // CloneRefOfRollback creates a deep clone of the input.
  2410  func CloneRefOfRollback(n *Rollback) *Rollback {
  2411  	if n == nil {
  2412  		return nil
  2413  	}
  2414  	out := *n
  2415  	return &out
  2416  }
  2417  
  2418  // CloneRootNode creates a deep clone of the input.
  2419  func CloneRootNode(n RootNode) RootNode {
  2420  	return *CloneRefOfRootNode(&n)
  2421  }
  2422  
  2423  // CloneRefOfSRollback creates a deep clone of the input.
  2424  func CloneRefOfSRollback(n *SRollback) *SRollback {
  2425  	if n == nil {
  2426  		return nil
  2427  	}
  2428  	out := *n
  2429  	out.Name = CloneIdentifierCI(n.Name)
  2430  	return &out
  2431  }
  2432  
  2433  // CloneRefOfSavepoint creates a deep clone of the input.
  2434  func CloneRefOfSavepoint(n *Savepoint) *Savepoint {
  2435  	if n == nil {
  2436  		return nil
  2437  	}
  2438  	out := *n
  2439  	out.Name = CloneIdentifierCI(n.Name)
  2440  	return &out
  2441  }
  2442  
  2443  // CloneRefOfSelect creates a deep clone of the input.
  2444  func CloneRefOfSelect(n *Select) *Select {
  2445  	if n == nil {
  2446  		return nil
  2447  	}
  2448  	out := *n
  2449  	out.Cache = CloneRefOfBool(n.Cache)
  2450  	out.From = CloneSliceOfTableExpr(n.From)
  2451  	out.Comments = CloneRefOfParsedComments(n.Comments)
  2452  	out.SelectExprs = CloneSelectExprs(n.SelectExprs)
  2453  	out.Where = CloneRefOfWhere(n.Where)
  2454  	out.With = CloneRefOfWith(n.With)
  2455  	out.GroupBy = CloneGroupBy(n.GroupBy)
  2456  	out.Having = CloneRefOfWhere(n.Having)
  2457  	out.Windows = CloneNamedWindows(n.Windows)
  2458  	out.OrderBy = CloneOrderBy(n.OrderBy)
  2459  	out.Limit = CloneRefOfLimit(n.Limit)
  2460  	out.Into = CloneRefOfSelectInto(n.Into)
  2461  	return &out
  2462  }
  2463  
  2464  // CloneSelectExprs creates a deep clone of the input.
  2465  func CloneSelectExprs(n SelectExprs) SelectExprs {
  2466  	if n == nil {
  2467  		return nil
  2468  	}
  2469  	res := make(SelectExprs, len(n))
  2470  	for i, x := range n {
  2471  		res[i] = CloneSelectExpr(x)
  2472  	}
  2473  	return res
  2474  }
  2475  
  2476  // CloneRefOfSelectInto creates a deep clone of the input.
  2477  func CloneRefOfSelectInto(n *SelectInto) *SelectInto {
  2478  	if n == nil {
  2479  		return nil
  2480  	}
  2481  	out := *n
  2482  	out.Charset = CloneColumnCharset(n.Charset)
  2483  	return &out
  2484  }
  2485  
  2486  // CloneRefOfSet creates a deep clone of the input.
  2487  func CloneRefOfSet(n *Set) *Set {
  2488  	if n == nil {
  2489  		return nil
  2490  	}
  2491  	out := *n
  2492  	out.Comments = CloneRefOfParsedComments(n.Comments)
  2493  	out.Exprs = CloneSetExprs(n.Exprs)
  2494  	return &out
  2495  }
  2496  
  2497  // CloneRefOfSetExpr creates a deep clone of the input.
  2498  func CloneRefOfSetExpr(n *SetExpr) *SetExpr {
  2499  	if n == nil {
  2500  		return nil
  2501  	}
  2502  	out := *n
  2503  	out.Var = CloneRefOfVariable(n.Var)
  2504  	out.Expr = CloneExpr(n.Expr)
  2505  	return &out
  2506  }
  2507  
  2508  // CloneSetExprs creates a deep clone of the input.
  2509  func CloneSetExprs(n SetExprs) SetExprs {
  2510  	if n == nil {
  2511  		return nil
  2512  	}
  2513  	res := make(SetExprs, len(n))
  2514  	for i, x := range n {
  2515  		res[i] = CloneRefOfSetExpr(x)
  2516  	}
  2517  	return res
  2518  }
  2519  
  2520  // CloneRefOfShow creates a deep clone of the input.
  2521  func CloneRefOfShow(n *Show) *Show {
  2522  	if n == nil {
  2523  		return nil
  2524  	}
  2525  	out := *n
  2526  	out.Internal = CloneShowInternal(n.Internal)
  2527  	return &out
  2528  }
  2529  
  2530  // CloneRefOfShowBasic creates a deep clone of the input.
  2531  func CloneRefOfShowBasic(n *ShowBasic) *ShowBasic {
  2532  	if n == nil {
  2533  		return nil
  2534  	}
  2535  	out := *n
  2536  	out.Tbl = CloneTableName(n.Tbl)
  2537  	out.DbName = CloneIdentifierCS(n.DbName)
  2538  	out.Filter = CloneRefOfShowFilter(n.Filter)
  2539  	return &out
  2540  }
  2541  
  2542  // CloneRefOfShowCreate creates a deep clone of the input.
  2543  func CloneRefOfShowCreate(n *ShowCreate) *ShowCreate {
  2544  	if n == nil {
  2545  		return nil
  2546  	}
  2547  	out := *n
  2548  	out.Op = CloneTableName(n.Op)
  2549  	return &out
  2550  }
  2551  
  2552  // CloneRefOfShowFilter creates a deep clone of the input.
  2553  func CloneRefOfShowFilter(n *ShowFilter) *ShowFilter {
  2554  	if n == nil {
  2555  		return nil
  2556  	}
  2557  	out := *n
  2558  	out.Filter = CloneExpr(n.Filter)
  2559  	return &out
  2560  }
  2561  
  2562  // CloneRefOfShowMigrationLogs creates a deep clone of the input.
  2563  func CloneRefOfShowMigrationLogs(n *ShowMigrationLogs) *ShowMigrationLogs {
  2564  	if n == nil {
  2565  		return nil
  2566  	}
  2567  	out := *n
  2568  	out.Comments = CloneRefOfParsedComments(n.Comments)
  2569  	return &out
  2570  }
  2571  
  2572  // CloneRefOfShowOther creates a deep clone of the input.
  2573  func CloneRefOfShowOther(n *ShowOther) *ShowOther {
  2574  	if n == nil {
  2575  		return nil
  2576  	}
  2577  	out := *n
  2578  	return &out
  2579  }
  2580  
  2581  // CloneRefOfShowThrottledApps creates a deep clone of the input.
  2582  func CloneRefOfShowThrottledApps(n *ShowThrottledApps) *ShowThrottledApps {
  2583  	if n == nil {
  2584  		return nil
  2585  	}
  2586  	out := *n
  2587  	out.Comments = CloneComments(n.Comments)
  2588  	return &out
  2589  }
  2590  
  2591  // CloneRefOfShowThrottlerStatus creates a deep clone of the input.
  2592  func CloneRefOfShowThrottlerStatus(n *ShowThrottlerStatus) *ShowThrottlerStatus {
  2593  	if n == nil {
  2594  		return nil
  2595  	}
  2596  	out := *n
  2597  	out.Comments = CloneComments(n.Comments)
  2598  	return &out
  2599  }
  2600  
  2601  // CloneRefOfStarExpr creates a deep clone of the input.
  2602  func CloneRefOfStarExpr(n *StarExpr) *StarExpr {
  2603  	if n == nil {
  2604  		return nil
  2605  	}
  2606  	out := *n
  2607  	out.TableName = CloneTableName(n.TableName)
  2608  	return &out
  2609  }
  2610  
  2611  // CloneRefOfStd creates a deep clone of the input.
  2612  func CloneRefOfStd(n *Std) *Std {
  2613  	if n == nil {
  2614  		return nil
  2615  	}
  2616  	out := *n
  2617  	out.Arg = CloneExpr(n.Arg)
  2618  	return &out
  2619  }
  2620  
  2621  // CloneRefOfStdDev creates a deep clone of the input.
  2622  func CloneRefOfStdDev(n *StdDev) *StdDev {
  2623  	if n == nil {
  2624  		return nil
  2625  	}
  2626  	out := *n
  2627  	out.Arg = CloneExpr(n.Arg)
  2628  	return &out
  2629  }
  2630  
  2631  // CloneRefOfStdPop creates a deep clone of the input.
  2632  func CloneRefOfStdPop(n *StdPop) *StdPop {
  2633  	if n == nil {
  2634  		return nil
  2635  	}
  2636  	out := *n
  2637  	out.Arg = CloneExpr(n.Arg)
  2638  	return &out
  2639  }
  2640  
  2641  // CloneRefOfStdSamp creates a deep clone of the input.
  2642  func CloneRefOfStdSamp(n *StdSamp) *StdSamp {
  2643  	if n == nil {
  2644  		return nil
  2645  	}
  2646  	out := *n
  2647  	out.Arg = CloneExpr(n.Arg)
  2648  	return &out
  2649  }
  2650  
  2651  // CloneRefOfStream creates a deep clone of the input.
  2652  func CloneRefOfStream(n *Stream) *Stream {
  2653  	if n == nil {
  2654  		return nil
  2655  	}
  2656  	out := *n
  2657  	out.Comments = CloneRefOfParsedComments(n.Comments)
  2658  	out.SelectExpr = CloneSelectExpr(n.SelectExpr)
  2659  	out.Table = CloneTableName(n.Table)
  2660  	return &out
  2661  }
  2662  
  2663  // CloneRefOfSubPartition creates a deep clone of the input.
  2664  func CloneRefOfSubPartition(n *SubPartition) *SubPartition {
  2665  	if n == nil {
  2666  		return nil
  2667  	}
  2668  	out := *n
  2669  	out.ColList = CloneColumns(n.ColList)
  2670  	out.Expr = CloneExpr(n.Expr)
  2671  	return &out
  2672  }
  2673  
  2674  // CloneRefOfSubPartitionDefinition creates a deep clone of the input.
  2675  func CloneRefOfSubPartitionDefinition(n *SubPartitionDefinition) *SubPartitionDefinition {
  2676  	if n == nil {
  2677  		return nil
  2678  	}
  2679  	out := *n
  2680  	out.Name = CloneIdentifierCI(n.Name)
  2681  	out.Options = CloneRefOfSubPartitionDefinitionOptions(n.Options)
  2682  	return &out
  2683  }
  2684  
  2685  // CloneRefOfSubPartitionDefinitionOptions creates a deep clone of the input.
  2686  func CloneRefOfSubPartitionDefinitionOptions(n *SubPartitionDefinitionOptions) *SubPartitionDefinitionOptions {
  2687  	if n == nil {
  2688  		return nil
  2689  	}
  2690  	out := *n
  2691  	out.Comment = CloneRefOfLiteral(n.Comment)
  2692  	out.Engine = CloneRefOfPartitionEngine(n.Engine)
  2693  	out.DataDirectory = CloneRefOfLiteral(n.DataDirectory)
  2694  	out.IndexDirectory = CloneRefOfLiteral(n.IndexDirectory)
  2695  	out.MaxRows = CloneRefOfInt(n.MaxRows)
  2696  	out.MinRows = CloneRefOfInt(n.MinRows)
  2697  	return &out
  2698  }
  2699  
  2700  // CloneSubPartitionDefinitions creates a deep clone of the input.
  2701  func CloneSubPartitionDefinitions(n SubPartitionDefinitions) SubPartitionDefinitions {
  2702  	if n == nil {
  2703  		return nil
  2704  	}
  2705  	res := make(SubPartitionDefinitions, len(n))
  2706  	for i, x := range n {
  2707  		res[i] = CloneRefOfSubPartitionDefinition(x)
  2708  	}
  2709  	return res
  2710  }
  2711  
  2712  // CloneRefOfSubquery creates a deep clone of the input.
  2713  func CloneRefOfSubquery(n *Subquery) *Subquery {
  2714  	if n == nil {
  2715  		return nil
  2716  	}
  2717  	out := *n
  2718  	out.Select = CloneSelectStatement(n.Select)
  2719  	return &out
  2720  }
  2721  
  2722  // CloneRefOfSubstrExpr creates a deep clone of the input.
  2723  func CloneRefOfSubstrExpr(n *SubstrExpr) *SubstrExpr {
  2724  	if n == nil {
  2725  		return nil
  2726  	}
  2727  	out := *n
  2728  	out.Name = CloneExpr(n.Name)
  2729  	out.From = CloneExpr(n.From)
  2730  	out.To = CloneExpr(n.To)
  2731  	return &out
  2732  }
  2733  
  2734  // CloneRefOfSum creates a deep clone of the input.
  2735  func CloneRefOfSum(n *Sum) *Sum {
  2736  	if n == nil {
  2737  		return nil
  2738  	}
  2739  	out := *n
  2740  	out.Arg = CloneExpr(n.Arg)
  2741  	return &out
  2742  }
  2743  
  2744  // CloneTableExprs creates a deep clone of the input.
  2745  func CloneTableExprs(n TableExprs) TableExprs {
  2746  	if n == nil {
  2747  		return nil
  2748  	}
  2749  	res := make(TableExprs, len(n))
  2750  	for i, x := range n {
  2751  		res[i] = CloneTableExpr(x)
  2752  	}
  2753  	return res
  2754  }
  2755  
  2756  // CloneTableName creates a deep clone of the input.
  2757  func CloneTableName(n TableName) TableName {
  2758  	return *CloneRefOfTableName(&n)
  2759  }
  2760  
  2761  // CloneTableNames creates a deep clone of the input.
  2762  func CloneTableNames(n TableNames) TableNames {
  2763  	if n == nil {
  2764  		return nil
  2765  	}
  2766  	res := make(TableNames, len(n))
  2767  	for i, x := range n {
  2768  		res[i] = CloneTableName(x)
  2769  	}
  2770  	return res
  2771  }
  2772  
  2773  // CloneTableOptions creates a deep clone of the input.
  2774  func CloneTableOptions(n TableOptions) TableOptions {
  2775  	if n == nil {
  2776  		return nil
  2777  	}
  2778  	res := make(TableOptions, len(n))
  2779  	for i, x := range n {
  2780  		res[i] = CloneRefOfTableOption(x)
  2781  	}
  2782  	return res
  2783  }
  2784  
  2785  // CloneRefOfTableSpec creates a deep clone of the input.
  2786  func CloneRefOfTableSpec(n *TableSpec) *TableSpec {
  2787  	if n == nil {
  2788  		return nil
  2789  	}
  2790  	out := *n
  2791  	out.Columns = CloneSliceOfRefOfColumnDefinition(n.Columns)
  2792  	out.Indexes = CloneSliceOfRefOfIndexDefinition(n.Indexes)
  2793  	out.Constraints = CloneSliceOfRefOfConstraintDefinition(n.Constraints)
  2794  	out.Options = CloneTableOptions(n.Options)
  2795  	out.PartitionOption = CloneRefOfPartitionOption(n.PartitionOption)
  2796  	return &out
  2797  }
  2798  
  2799  // CloneRefOfTablespaceOperation creates a deep clone of the input.
  2800  func CloneRefOfTablespaceOperation(n *TablespaceOperation) *TablespaceOperation {
  2801  	if n == nil {
  2802  		return nil
  2803  	}
  2804  	out := *n
  2805  	return &out
  2806  }
  2807  
  2808  // CloneRefOfTimestampFuncExpr creates a deep clone of the input.
  2809  func CloneRefOfTimestampFuncExpr(n *TimestampFuncExpr) *TimestampFuncExpr {
  2810  	if n == nil {
  2811  		return nil
  2812  	}
  2813  	out := *n
  2814  	out.Expr1 = CloneExpr(n.Expr1)
  2815  	out.Expr2 = CloneExpr(n.Expr2)
  2816  	return &out
  2817  }
  2818  
  2819  // CloneRefOfTrimFuncExpr creates a deep clone of the input.
  2820  func CloneRefOfTrimFuncExpr(n *TrimFuncExpr) *TrimFuncExpr {
  2821  	if n == nil {
  2822  		return nil
  2823  	}
  2824  	out := *n
  2825  	out.TrimArg = CloneExpr(n.TrimArg)
  2826  	out.StringArg = CloneExpr(n.StringArg)
  2827  	return &out
  2828  }
  2829  
  2830  // CloneRefOfTruncateTable creates a deep clone of the input.
  2831  func CloneRefOfTruncateTable(n *TruncateTable) *TruncateTable {
  2832  	if n == nil {
  2833  		return nil
  2834  	}
  2835  	out := *n
  2836  	out.Table = CloneTableName(n.Table)
  2837  	return &out
  2838  }
  2839  
  2840  // CloneRefOfUnaryExpr creates a deep clone of the input.
  2841  func CloneRefOfUnaryExpr(n *UnaryExpr) *UnaryExpr {
  2842  	if n == nil {
  2843  		return nil
  2844  	}
  2845  	out := *n
  2846  	out.Expr = CloneExpr(n.Expr)
  2847  	return &out
  2848  }
  2849  
  2850  // CloneRefOfUnion creates a deep clone of the input.
  2851  func CloneRefOfUnion(n *Union) *Union {
  2852  	if n == nil {
  2853  		return nil
  2854  	}
  2855  	out := *n
  2856  	out.Left = CloneSelectStatement(n.Left)
  2857  	out.Right = CloneSelectStatement(n.Right)
  2858  	out.OrderBy = CloneOrderBy(n.OrderBy)
  2859  	out.With = CloneRefOfWith(n.With)
  2860  	out.Limit = CloneRefOfLimit(n.Limit)
  2861  	out.Into = CloneRefOfSelectInto(n.Into)
  2862  	return &out
  2863  }
  2864  
  2865  // CloneRefOfUnlockTables creates a deep clone of the input.
  2866  func CloneRefOfUnlockTables(n *UnlockTables) *UnlockTables {
  2867  	if n == nil {
  2868  		return nil
  2869  	}
  2870  	out := *n
  2871  	return &out
  2872  }
  2873  
  2874  // CloneRefOfUpdate creates a deep clone of the input.
  2875  func CloneRefOfUpdate(n *Update) *Update {
  2876  	if n == nil {
  2877  		return nil
  2878  	}
  2879  	out := *n
  2880  	out.With = CloneRefOfWith(n.With)
  2881  	out.Comments = CloneRefOfParsedComments(n.Comments)
  2882  	out.TableExprs = CloneTableExprs(n.TableExprs)
  2883  	out.Exprs = CloneUpdateExprs(n.Exprs)
  2884  	out.Where = CloneRefOfWhere(n.Where)
  2885  	out.OrderBy = CloneOrderBy(n.OrderBy)
  2886  	out.Limit = CloneRefOfLimit(n.Limit)
  2887  	return &out
  2888  }
  2889  
  2890  // CloneRefOfUpdateExpr creates a deep clone of the input.
  2891  func CloneRefOfUpdateExpr(n *UpdateExpr) *UpdateExpr {
  2892  	if n == nil {
  2893  		return nil
  2894  	}
  2895  	out := *n
  2896  	out.Name = CloneRefOfColName(n.Name)
  2897  	out.Expr = CloneExpr(n.Expr)
  2898  	return &out
  2899  }
  2900  
  2901  // CloneUpdateExprs creates a deep clone of the input.
  2902  func CloneUpdateExprs(n UpdateExprs) UpdateExprs {
  2903  	if n == nil {
  2904  		return nil
  2905  	}
  2906  	res := make(UpdateExprs, len(n))
  2907  	for i, x := range n {
  2908  		res[i] = CloneRefOfUpdateExpr(x)
  2909  	}
  2910  	return res
  2911  }
  2912  
  2913  // CloneRefOfUpdateXMLExpr creates a deep clone of the input.
  2914  func CloneRefOfUpdateXMLExpr(n *UpdateXMLExpr) *UpdateXMLExpr {
  2915  	if n == nil {
  2916  		return nil
  2917  	}
  2918  	out := *n
  2919  	out.Target = CloneExpr(n.Target)
  2920  	out.XPathExpr = CloneExpr(n.XPathExpr)
  2921  	out.NewXML = CloneExpr(n.NewXML)
  2922  	return &out
  2923  }
  2924  
  2925  // CloneRefOfUse creates a deep clone of the input.
  2926  func CloneRefOfUse(n *Use) *Use {
  2927  	if n == nil {
  2928  		return nil
  2929  	}
  2930  	out := *n
  2931  	out.DBName = CloneIdentifierCS(n.DBName)
  2932  	return &out
  2933  }
  2934  
  2935  // CloneRefOfVExplainStmt creates a deep clone of the input.
  2936  func CloneRefOfVExplainStmt(n *VExplainStmt) *VExplainStmt {
  2937  	if n == nil {
  2938  		return nil
  2939  	}
  2940  	out := *n
  2941  	out.Statement = CloneStatement(n.Statement)
  2942  	out.Comments = CloneRefOfParsedComments(n.Comments)
  2943  	return &out
  2944  }
  2945  
  2946  // CloneRefOfVStream creates a deep clone of the input.
  2947  func CloneRefOfVStream(n *VStream) *VStream {
  2948  	if n == nil {
  2949  		return nil
  2950  	}
  2951  	out := *n
  2952  	out.Comments = CloneRefOfParsedComments(n.Comments)
  2953  	out.SelectExpr = CloneSelectExpr(n.SelectExpr)
  2954  	out.Table = CloneTableName(n.Table)
  2955  	out.Where = CloneRefOfWhere(n.Where)
  2956  	out.Limit = CloneRefOfLimit(n.Limit)
  2957  	return &out
  2958  }
  2959  
  2960  // CloneValTuple creates a deep clone of the input.
  2961  func CloneValTuple(n ValTuple) ValTuple {
  2962  	if n == nil {
  2963  		return nil
  2964  	}
  2965  	res := make(ValTuple, len(n))
  2966  	for i, x := range n {
  2967  		res[i] = CloneExpr(x)
  2968  	}
  2969  	return res
  2970  }
  2971  
  2972  // CloneRefOfValidation creates a deep clone of the input.
  2973  func CloneRefOfValidation(n *Validation) *Validation {
  2974  	if n == nil {
  2975  		return nil
  2976  	}
  2977  	out := *n
  2978  	return &out
  2979  }
  2980  
  2981  // CloneValues creates a deep clone of the input.
  2982  func CloneValues(n Values) Values {
  2983  	if n == nil {
  2984  		return nil
  2985  	}
  2986  	res := make(Values, len(n))
  2987  	for i, x := range n {
  2988  		res[i] = CloneValTuple(x)
  2989  	}
  2990  	return res
  2991  }
  2992  
  2993  // CloneRefOfValuesFuncExpr creates a deep clone of the input.
  2994  func CloneRefOfValuesFuncExpr(n *ValuesFuncExpr) *ValuesFuncExpr {
  2995  	if n == nil {
  2996  		return nil
  2997  	}
  2998  	out := *n
  2999  	out.Name = CloneRefOfColName(n.Name)
  3000  	return &out
  3001  }
  3002  
  3003  // CloneRefOfVarPop creates a deep clone of the input.
  3004  func CloneRefOfVarPop(n *VarPop) *VarPop {
  3005  	if n == nil {
  3006  		return nil
  3007  	}
  3008  	out := *n
  3009  	out.Arg = CloneExpr(n.Arg)
  3010  	return &out
  3011  }
  3012  
  3013  // CloneRefOfVarSamp creates a deep clone of the input.
  3014  func CloneRefOfVarSamp(n *VarSamp) *VarSamp {
  3015  	if n == nil {
  3016  		return nil
  3017  	}
  3018  	out := *n
  3019  	out.Arg = CloneExpr(n.Arg)
  3020  	return &out
  3021  }
  3022  
  3023  // CloneRefOfVariable creates a deep clone of the input.
  3024  func CloneRefOfVariable(n *Variable) *Variable {
  3025  	if n == nil {
  3026  		return nil
  3027  	}
  3028  	out := *n
  3029  	out.Name = CloneIdentifierCI(n.Name)
  3030  	return &out
  3031  }
  3032  
  3033  // CloneRefOfVariance creates a deep clone of the input.
  3034  func CloneRefOfVariance(n *Variance) *Variance {
  3035  	if n == nil {
  3036  		return nil
  3037  	}
  3038  	out := *n
  3039  	out.Arg = CloneExpr(n.Arg)
  3040  	return &out
  3041  }
  3042  
  3043  // CloneVindexParam creates a deep clone of the input.
  3044  func CloneVindexParam(n VindexParam) VindexParam {
  3045  	return *CloneRefOfVindexParam(&n)
  3046  }
  3047  
  3048  // CloneRefOfVindexSpec creates a deep clone of the input.
  3049  func CloneRefOfVindexSpec(n *VindexSpec) *VindexSpec {
  3050  	if n == nil {
  3051  		return nil
  3052  	}
  3053  	out := *n
  3054  	out.Name = CloneIdentifierCI(n.Name)
  3055  	out.Type = CloneIdentifierCI(n.Type)
  3056  	out.Params = CloneSliceOfVindexParam(n.Params)
  3057  	return &out
  3058  }
  3059  
  3060  // CloneRefOfWeightStringFuncExpr creates a deep clone of the input.
  3061  func CloneRefOfWeightStringFuncExpr(n *WeightStringFuncExpr) *WeightStringFuncExpr {
  3062  	if n == nil {
  3063  		return nil
  3064  	}
  3065  	out := *n
  3066  	out.Expr = CloneExpr(n.Expr)
  3067  	out.As = CloneRefOfConvertType(n.As)
  3068  	return &out
  3069  }
  3070  
  3071  // CloneRefOfWhen creates a deep clone of the input.
  3072  func CloneRefOfWhen(n *When) *When {
  3073  	if n == nil {
  3074  		return nil
  3075  	}
  3076  	out := *n
  3077  	out.Cond = CloneExpr(n.Cond)
  3078  	out.Val = CloneExpr(n.Val)
  3079  	return &out
  3080  }
  3081  
  3082  // CloneRefOfWhere creates a deep clone of the input.
  3083  func CloneRefOfWhere(n *Where) *Where {
  3084  	if n == nil {
  3085  		return nil
  3086  	}
  3087  	out := *n
  3088  	out.Expr = CloneExpr(n.Expr)
  3089  	return &out
  3090  }
  3091  
  3092  // CloneRefOfWindowDefinition creates a deep clone of the input.
  3093  func CloneRefOfWindowDefinition(n *WindowDefinition) *WindowDefinition {
  3094  	if n == nil {
  3095  		return nil
  3096  	}
  3097  	out := *n
  3098  	out.Name = CloneIdentifierCI(n.Name)
  3099  	out.WindowSpec = CloneRefOfWindowSpecification(n.WindowSpec)
  3100  	return &out
  3101  }
  3102  
  3103  // CloneWindowDefinitions creates a deep clone of the input.
  3104  func CloneWindowDefinitions(n WindowDefinitions) WindowDefinitions {
  3105  	if n == nil {
  3106  		return nil
  3107  	}
  3108  	res := make(WindowDefinitions, len(n))
  3109  	for i, x := range n {
  3110  		res[i] = CloneRefOfWindowDefinition(x)
  3111  	}
  3112  	return res
  3113  }
  3114  
  3115  // CloneRefOfWindowSpecification creates a deep clone of the input.
  3116  func CloneRefOfWindowSpecification(n *WindowSpecification) *WindowSpecification {
  3117  	if n == nil {
  3118  		return nil
  3119  	}
  3120  	out := *n
  3121  	out.Name = CloneIdentifierCI(n.Name)
  3122  	out.PartitionClause = CloneExprs(n.PartitionClause)
  3123  	out.OrderClause = CloneOrderBy(n.OrderClause)
  3124  	out.FrameClause = CloneRefOfFrameClause(n.FrameClause)
  3125  	return &out
  3126  }
  3127  
  3128  // CloneRefOfWith creates a deep clone of the input.
  3129  func CloneRefOfWith(n *With) *With {
  3130  	if n == nil {
  3131  		return nil
  3132  	}
  3133  	out := *n
  3134  	out.Ctes = CloneSliceOfRefOfCommonTableExpr(n.Ctes)
  3135  	return &out
  3136  }
  3137  
  3138  // CloneRefOfXorExpr creates a deep clone of the input.
  3139  func CloneRefOfXorExpr(n *XorExpr) *XorExpr {
  3140  	if n == nil {
  3141  		return nil
  3142  	}
  3143  	out := *n
  3144  	out.Left = CloneExpr(n.Left)
  3145  	out.Right = CloneExpr(n.Right)
  3146  	return &out
  3147  }
  3148  
  3149  // CloneAggrFunc creates a deep clone of the input.
  3150  func CloneAggrFunc(in AggrFunc) AggrFunc {
  3151  	if in == nil {
  3152  		return nil
  3153  	}
  3154  	switch in := in.(type) {
  3155  	case *Avg:
  3156  		return CloneRefOfAvg(in)
  3157  	case *BitAnd:
  3158  		return CloneRefOfBitAnd(in)
  3159  	case *BitOr:
  3160  		return CloneRefOfBitOr(in)
  3161  	case *BitXor:
  3162  		return CloneRefOfBitXor(in)
  3163  	case *Count:
  3164  		return CloneRefOfCount(in)
  3165  	case *CountStar:
  3166  		return CloneRefOfCountStar(in)
  3167  	case *GroupConcatExpr:
  3168  		return CloneRefOfGroupConcatExpr(in)
  3169  	case *Max:
  3170  		return CloneRefOfMax(in)
  3171  	case *Min:
  3172  		return CloneRefOfMin(in)
  3173  	case *Std:
  3174  		return CloneRefOfStd(in)
  3175  	case *StdDev:
  3176  		return CloneRefOfStdDev(in)
  3177  	case *StdPop:
  3178  		return CloneRefOfStdPop(in)
  3179  	case *StdSamp:
  3180  		return CloneRefOfStdSamp(in)
  3181  	case *Sum:
  3182  		return CloneRefOfSum(in)
  3183  	case *VarPop:
  3184  		return CloneRefOfVarPop(in)
  3185  	case *VarSamp:
  3186  		return CloneRefOfVarSamp(in)
  3187  	case *Variance:
  3188  		return CloneRefOfVariance(in)
  3189  	default:
  3190  		// this should never happen
  3191  		return nil
  3192  	}
  3193  }
  3194  
  3195  // CloneAlterOption creates a deep clone of the input.
  3196  func CloneAlterOption(in AlterOption) AlterOption {
  3197  	if in == nil {
  3198  		return nil
  3199  	}
  3200  	switch in := in.(type) {
  3201  	case *AddColumns:
  3202  		return CloneRefOfAddColumns(in)
  3203  	case *AddConstraintDefinition:
  3204  		return CloneRefOfAddConstraintDefinition(in)
  3205  	case *AddIndexDefinition:
  3206  		return CloneRefOfAddIndexDefinition(in)
  3207  	case AlgorithmValue:
  3208  		return in
  3209  	case *AlterCharset:
  3210  		return CloneRefOfAlterCharset(in)
  3211  	case *AlterCheck:
  3212  		return CloneRefOfAlterCheck(in)
  3213  	case *AlterColumn:
  3214  		return CloneRefOfAlterColumn(in)
  3215  	case *AlterIndex:
  3216  		return CloneRefOfAlterIndex(in)
  3217  	case *ChangeColumn:
  3218  		return CloneRefOfChangeColumn(in)
  3219  	case *DropColumn:
  3220  		return CloneRefOfDropColumn(in)
  3221  	case *DropKey:
  3222  		return CloneRefOfDropKey(in)
  3223  	case *Force:
  3224  		return CloneRefOfForce(in)
  3225  	case *KeyState:
  3226  		return CloneRefOfKeyState(in)
  3227  	case *LockOption:
  3228  		return CloneRefOfLockOption(in)
  3229  	case *ModifyColumn:
  3230  		return CloneRefOfModifyColumn(in)
  3231  	case *OrderByOption:
  3232  		return CloneRefOfOrderByOption(in)
  3233  	case *RenameColumn:
  3234  		return CloneRefOfRenameColumn(in)
  3235  	case *RenameIndex:
  3236  		return CloneRefOfRenameIndex(in)
  3237  	case *RenameTableName:
  3238  		return CloneRefOfRenameTableName(in)
  3239  	case TableOptions:
  3240  		return CloneTableOptions(in)
  3241  	case *TablespaceOperation:
  3242  		return CloneRefOfTablespaceOperation(in)
  3243  	case *Validation:
  3244  		return CloneRefOfValidation(in)
  3245  	default:
  3246  		// this should never happen
  3247  		return nil
  3248  	}
  3249  }
  3250  
  3251  // CloneCallable creates a deep clone of the input.
  3252  func CloneCallable(in Callable) Callable {
  3253  	if in == nil {
  3254  		return nil
  3255  	}
  3256  	switch in := in.(type) {
  3257  	case *ArgumentLessWindowExpr:
  3258  		return CloneRefOfArgumentLessWindowExpr(in)
  3259  	case *Avg:
  3260  		return CloneRefOfAvg(in)
  3261  	case *CharExpr:
  3262  		return CloneRefOfCharExpr(in)
  3263  	case *ConvertExpr:
  3264  		return CloneRefOfConvertExpr(in)
  3265  	case *ConvertUsingExpr:
  3266  		return CloneRefOfConvertUsingExpr(in)
  3267  	case *Count:
  3268  		return CloneRefOfCount(in)
  3269  	case *CountStar:
  3270  		return CloneRefOfCountStar(in)
  3271  	case *CurTimeFuncExpr:
  3272  		return CloneRefOfCurTimeFuncExpr(in)
  3273  	case *ExtractFuncExpr:
  3274  		return CloneRefOfExtractFuncExpr(in)
  3275  	case *ExtractValueExpr:
  3276  		return CloneRefOfExtractValueExpr(in)
  3277  	case *FirstOrLastValueExpr:
  3278  		return CloneRefOfFirstOrLastValueExpr(in)
  3279  	case *FuncExpr:
  3280  		return CloneRefOfFuncExpr(in)
  3281  	case *GTIDFuncExpr:
  3282  		return CloneRefOfGTIDFuncExpr(in)
  3283  	case *GroupConcatExpr:
  3284  		return CloneRefOfGroupConcatExpr(in)
  3285  	case *InsertExpr:
  3286  		return CloneRefOfInsertExpr(in)
  3287  	case *IntervalFuncExpr:
  3288  		return CloneRefOfIntervalFuncExpr(in)
  3289  	case *JSONArrayExpr:
  3290  		return CloneRefOfJSONArrayExpr(in)
  3291  	case *JSONAttributesExpr:
  3292  		return CloneRefOfJSONAttributesExpr(in)
  3293  	case *JSONContainsExpr:
  3294  		return CloneRefOfJSONContainsExpr(in)
  3295  	case *JSONContainsPathExpr:
  3296  		return CloneRefOfJSONContainsPathExpr(in)
  3297  	case *JSONExtractExpr:
  3298  		return CloneRefOfJSONExtractExpr(in)
  3299  	case *JSONKeysExpr:
  3300  		return CloneRefOfJSONKeysExpr(in)
  3301  	case *JSONObjectExpr:
  3302  		return CloneRefOfJSONObjectExpr(in)
  3303  	case *JSONOverlapsExpr:
  3304  		return CloneRefOfJSONOverlapsExpr(in)
  3305  	case *JSONPrettyExpr:
  3306  		return CloneRefOfJSONPrettyExpr(in)
  3307  	case *JSONQuoteExpr:
  3308  		return CloneRefOfJSONQuoteExpr(in)
  3309  	case *JSONRemoveExpr:
  3310  		return CloneRefOfJSONRemoveExpr(in)
  3311  	case *JSONSchemaValidFuncExpr:
  3312  		return CloneRefOfJSONSchemaValidFuncExpr(in)
  3313  	case *JSONSchemaValidationReportFuncExpr:
  3314  		return CloneRefOfJSONSchemaValidationReportFuncExpr(in)
  3315  	case *JSONSearchExpr:
  3316  		return CloneRefOfJSONSearchExpr(in)
  3317  	case *JSONStorageFreeExpr:
  3318  		return CloneRefOfJSONStorageFreeExpr(in)
  3319  	case *JSONStorageSizeExpr:
  3320  		return CloneRefOfJSONStorageSizeExpr(in)
  3321  	case *JSONUnquoteExpr:
  3322  		return CloneRefOfJSONUnquoteExpr(in)
  3323  	case *JSONValueExpr:
  3324  		return CloneRefOfJSONValueExpr(in)
  3325  	case *JSONValueMergeExpr:
  3326  		return CloneRefOfJSONValueMergeExpr(in)
  3327  	case *JSONValueModifierExpr:
  3328  		return CloneRefOfJSONValueModifierExpr(in)
  3329  	case *LagLeadExpr:
  3330  		return CloneRefOfLagLeadExpr(in)
  3331  	case *LineStringExpr:
  3332  		return CloneRefOfLineStringExpr(in)
  3333  	case *LocateExpr:
  3334  		return CloneRefOfLocateExpr(in)
  3335  	case *MatchExpr:
  3336  		return CloneRefOfMatchExpr(in)
  3337  	case *Max:
  3338  		return CloneRefOfMax(in)
  3339  	case *MemberOfExpr:
  3340  		return CloneRefOfMemberOfExpr(in)
  3341  	case *Min:
  3342  		return CloneRefOfMin(in)
  3343  	case *NTHValueExpr:
  3344  		return CloneRefOfNTHValueExpr(in)
  3345  	case *NamedWindow:
  3346  		return CloneRefOfNamedWindow(in)
  3347  	case *NtileExpr:
  3348  		return CloneRefOfNtileExpr(in)
  3349  	case *PerformanceSchemaFuncExpr:
  3350  		return CloneRefOfPerformanceSchemaFuncExpr(in)
  3351  	case *PointExpr:
  3352  		return CloneRefOfPointExpr(in)
  3353  	case *RegexpInstrExpr:
  3354  		return CloneRefOfRegexpInstrExpr(in)
  3355  	case *RegexpLikeExpr:
  3356  		return CloneRefOfRegexpLikeExpr(in)
  3357  	case *RegexpReplaceExpr:
  3358  		return CloneRefOfRegexpReplaceExpr(in)
  3359  	case *RegexpSubstrExpr:
  3360  		return CloneRefOfRegexpSubstrExpr(in)
  3361  	case *SubstrExpr:
  3362  		return CloneRefOfSubstrExpr(in)
  3363  	case *Sum:
  3364  		return CloneRefOfSum(in)
  3365  	case *TimestampFuncExpr:
  3366  		return CloneRefOfTimestampFuncExpr(in)
  3367  	case *TrimFuncExpr:
  3368  		return CloneRefOfTrimFuncExpr(in)
  3369  	case *UpdateXMLExpr:
  3370  		return CloneRefOfUpdateXMLExpr(in)
  3371  	case *ValuesFuncExpr:
  3372  		return CloneRefOfValuesFuncExpr(in)
  3373  	case *WeightStringFuncExpr:
  3374  		return CloneRefOfWeightStringFuncExpr(in)
  3375  	default:
  3376  		// this should never happen
  3377  		return nil
  3378  	}
  3379  }
  3380  
  3381  // CloneColTuple creates a deep clone of the input.
  3382  func CloneColTuple(in ColTuple) ColTuple {
  3383  	if in == nil {
  3384  		return nil
  3385  	}
  3386  	switch in := in.(type) {
  3387  	case ListArg:
  3388  		return in
  3389  	case *Subquery:
  3390  		return CloneRefOfSubquery(in)
  3391  	case ValTuple:
  3392  		return CloneValTuple(in)
  3393  	default:
  3394  		// this should never happen
  3395  		return nil
  3396  	}
  3397  }
  3398  
  3399  // CloneConstraintInfo creates a deep clone of the input.
  3400  func CloneConstraintInfo(in ConstraintInfo) ConstraintInfo {
  3401  	if in == nil {
  3402  		return nil
  3403  	}
  3404  	switch in := in.(type) {
  3405  	case *CheckConstraintDefinition:
  3406  		return CloneRefOfCheckConstraintDefinition(in)
  3407  	case *ForeignKeyDefinition:
  3408  		return CloneRefOfForeignKeyDefinition(in)
  3409  	default:
  3410  		// this should never happen
  3411  		return nil
  3412  	}
  3413  }
  3414  
  3415  // CloneDBDDLStatement creates a deep clone of the input.
  3416  func CloneDBDDLStatement(in DBDDLStatement) DBDDLStatement {
  3417  	if in == nil {
  3418  		return nil
  3419  	}
  3420  	switch in := in.(type) {
  3421  	case *AlterDatabase:
  3422  		return CloneRefOfAlterDatabase(in)
  3423  	case *CreateDatabase:
  3424  		return CloneRefOfCreateDatabase(in)
  3425  	case *DropDatabase:
  3426  		return CloneRefOfDropDatabase(in)
  3427  	default:
  3428  		// this should never happen
  3429  		return nil
  3430  	}
  3431  }
  3432  
  3433  // CloneDDLStatement creates a deep clone of the input.
  3434  func CloneDDLStatement(in DDLStatement) DDLStatement {
  3435  	if in == nil {
  3436  		return nil
  3437  	}
  3438  	switch in := in.(type) {
  3439  	case *AlterTable:
  3440  		return CloneRefOfAlterTable(in)
  3441  	case *AlterView:
  3442  		return CloneRefOfAlterView(in)
  3443  	case *CreateTable:
  3444  		return CloneRefOfCreateTable(in)
  3445  	case *CreateView:
  3446  		return CloneRefOfCreateView(in)
  3447  	case *DropTable:
  3448  		return CloneRefOfDropTable(in)
  3449  	case *DropView:
  3450  		return CloneRefOfDropView(in)
  3451  	case *RenameTable:
  3452  		return CloneRefOfRenameTable(in)
  3453  	case *TruncateTable:
  3454  		return CloneRefOfTruncateTable(in)
  3455  	default:
  3456  		// this should never happen
  3457  		return nil
  3458  	}
  3459  }
  3460  
  3461  // CloneExplain creates a deep clone of the input.
  3462  func CloneExplain(in Explain) Explain {
  3463  	if in == nil {
  3464  		return nil
  3465  	}
  3466  	switch in := in.(type) {
  3467  	case *ExplainStmt:
  3468  		return CloneRefOfExplainStmt(in)
  3469  	case *ExplainTab:
  3470  		return CloneRefOfExplainTab(in)
  3471  	default:
  3472  		// this should never happen
  3473  		return nil
  3474  	}
  3475  }
  3476  
  3477  // CloneExpr creates a deep clone of the input.
  3478  func CloneExpr(in Expr) Expr {
  3479  	if in == nil {
  3480  		return nil
  3481  	}
  3482  	switch in := in.(type) {
  3483  	case *AndExpr:
  3484  		return CloneRefOfAndExpr(in)
  3485  	case Argument:
  3486  		return in
  3487  	case *ArgumentLessWindowExpr:
  3488  		return CloneRefOfArgumentLessWindowExpr(in)
  3489  	case *Avg:
  3490  		return CloneRefOfAvg(in)
  3491  	case *BetweenExpr:
  3492  		return CloneRefOfBetweenExpr(in)
  3493  	case *BinaryExpr:
  3494  		return CloneRefOfBinaryExpr(in)
  3495  	case *BitAnd:
  3496  		return CloneRefOfBitAnd(in)
  3497  	case *BitOr:
  3498  		return CloneRefOfBitOr(in)
  3499  	case *BitXor:
  3500  		return CloneRefOfBitXor(in)
  3501  	case BoolVal:
  3502  		return in
  3503  	case *CaseExpr:
  3504  		return CloneRefOfCaseExpr(in)
  3505  	case *CastExpr:
  3506  		return CloneRefOfCastExpr(in)
  3507  	case *CharExpr:
  3508  		return CloneRefOfCharExpr(in)
  3509  	case *ColName:
  3510  		return CloneRefOfColName(in)
  3511  	case *CollateExpr:
  3512  		return CloneRefOfCollateExpr(in)
  3513  	case *ComparisonExpr:
  3514  		return CloneRefOfComparisonExpr(in)
  3515  	case *ConvertExpr:
  3516  		return CloneRefOfConvertExpr(in)
  3517  	case *ConvertUsingExpr:
  3518  		return CloneRefOfConvertUsingExpr(in)
  3519  	case *Count:
  3520  		return CloneRefOfCount(in)
  3521  	case *CountStar:
  3522  		return CloneRefOfCountStar(in)
  3523  	case *CurTimeFuncExpr:
  3524  		return CloneRefOfCurTimeFuncExpr(in)
  3525  	case *Default:
  3526  		return CloneRefOfDefault(in)
  3527  	case *ExistsExpr:
  3528  		return CloneRefOfExistsExpr(in)
  3529  	case *ExtractFuncExpr:
  3530  		return CloneRefOfExtractFuncExpr(in)
  3531  	case *ExtractValueExpr:
  3532  		return CloneRefOfExtractValueExpr(in)
  3533  	case *ExtractedSubquery:
  3534  		return CloneRefOfExtractedSubquery(in)
  3535  	case *FirstOrLastValueExpr:
  3536  		return CloneRefOfFirstOrLastValueExpr(in)
  3537  	case *FuncExpr:
  3538  		return CloneRefOfFuncExpr(in)
  3539  	case *GTIDFuncExpr:
  3540  		return CloneRefOfGTIDFuncExpr(in)
  3541  	case *GroupConcatExpr:
  3542  		return CloneRefOfGroupConcatExpr(in)
  3543  	case *InsertExpr:
  3544  		return CloneRefOfInsertExpr(in)
  3545  	case *IntervalExpr:
  3546  		return CloneRefOfIntervalExpr(in)
  3547  	case *IntervalFuncExpr:
  3548  		return CloneRefOfIntervalFuncExpr(in)
  3549  	case *IntroducerExpr:
  3550  		return CloneRefOfIntroducerExpr(in)
  3551  	case *IsExpr:
  3552  		return CloneRefOfIsExpr(in)
  3553  	case *JSONArrayExpr:
  3554  		return CloneRefOfJSONArrayExpr(in)
  3555  	case *JSONAttributesExpr:
  3556  		return CloneRefOfJSONAttributesExpr(in)
  3557  	case *JSONContainsExpr:
  3558  		return CloneRefOfJSONContainsExpr(in)
  3559  	case *JSONContainsPathExpr:
  3560  		return CloneRefOfJSONContainsPathExpr(in)
  3561  	case *JSONExtractExpr:
  3562  		return CloneRefOfJSONExtractExpr(in)
  3563  	case *JSONKeysExpr:
  3564  		return CloneRefOfJSONKeysExpr(in)
  3565  	case *JSONObjectExpr:
  3566  		return CloneRefOfJSONObjectExpr(in)
  3567  	case *JSONOverlapsExpr:
  3568  		return CloneRefOfJSONOverlapsExpr(in)
  3569  	case *JSONPrettyExpr:
  3570  		return CloneRefOfJSONPrettyExpr(in)
  3571  	case *JSONQuoteExpr:
  3572  		return CloneRefOfJSONQuoteExpr(in)
  3573  	case *JSONRemoveExpr:
  3574  		return CloneRefOfJSONRemoveExpr(in)
  3575  	case *JSONSchemaValidFuncExpr:
  3576  		return CloneRefOfJSONSchemaValidFuncExpr(in)
  3577  	case *JSONSchemaValidationReportFuncExpr:
  3578  		return CloneRefOfJSONSchemaValidationReportFuncExpr(in)
  3579  	case *JSONSearchExpr:
  3580  		return CloneRefOfJSONSearchExpr(in)
  3581  	case *JSONStorageFreeExpr:
  3582  		return CloneRefOfJSONStorageFreeExpr(in)
  3583  	case *JSONStorageSizeExpr:
  3584  		return CloneRefOfJSONStorageSizeExpr(in)
  3585  	case *JSONUnquoteExpr:
  3586  		return CloneRefOfJSONUnquoteExpr(in)
  3587  	case *JSONValueExpr:
  3588  		return CloneRefOfJSONValueExpr(in)
  3589  	case *JSONValueMergeExpr:
  3590  		return CloneRefOfJSONValueMergeExpr(in)
  3591  	case *JSONValueModifierExpr:
  3592  		return CloneRefOfJSONValueModifierExpr(in)
  3593  	case *LagLeadExpr:
  3594  		return CloneRefOfLagLeadExpr(in)
  3595  	case *LineStringExpr:
  3596  		return CloneRefOfLineStringExpr(in)
  3597  	case ListArg:
  3598  		return in
  3599  	case *Literal:
  3600  		return CloneRefOfLiteral(in)
  3601  	case *LocateExpr:
  3602  		return CloneRefOfLocateExpr(in)
  3603  	case *LockingFunc:
  3604  		return CloneRefOfLockingFunc(in)
  3605  	case *MatchExpr:
  3606  		return CloneRefOfMatchExpr(in)
  3607  	case *Max:
  3608  		return CloneRefOfMax(in)
  3609  	case *MemberOfExpr:
  3610  		return CloneRefOfMemberOfExpr(in)
  3611  	case *Min:
  3612  		return CloneRefOfMin(in)
  3613  	case *NTHValueExpr:
  3614  		return CloneRefOfNTHValueExpr(in)
  3615  	case *NamedWindow:
  3616  		return CloneRefOfNamedWindow(in)
  3617  	case *NotExpr:
  3618  		return CloneRefOfNotExpr(in)
  3619  	case *NtileExpr:
  3620  		return CloneRefOfNtileExpr(in)
  3621  	case *NullVal:
  3622  		return CloneRefOfNullVal(in)
  3623  	case *Offset:
  3624  		return CloneRefOfOffset(in)
  3625  	case *OrExpr:
  3626  		return CloneRefOfOrExpr(in)
  3627  	case *PerformanceSchemaFuncExpr:
  3628  		return CloneRefOfPerformanceSchemaFuncExpr(in)
  3629  	case *PointExpr:
  3630  		return CloneRefOfPointExpr(in)
  3631  	case *RegexpInstrExpr:
  3632  		return CloneRefOfRegexpInstrExpr(in)
  3633  	case *RegexpLikeExpr:
  3634  		return CloneRefOfRegexpLikeExpr(in)
  3635  	case *RegexpReplaceExpr:
  3636  		return CloneRefOfRegexpReplaceExpr(in)
  3637  	case *RegexpSubstrExpr:
  3638  		return CloneRefOfRegexpSubstrExpr(in)
  3639  	case *Std:
  3640  		return CloneRefOfStd(in)
  3641  	case *StdDev:
  3642  		return CloneRefOfStdDev(in)
  3643  	case *StdPop:
  3644  		return CloneRefOfStdPop(in)
  3645  	case *StdSamp:
  3646  		return CloneRefOfStdSamp(in)
  3647  	case *Subquery:
  3648  		return CloneRefOfSubquery(in)
  3649  	case *SubstrExpr:
  3650  		return CloneRefOfSubstrExpr(in)
  3651  	case *Sum:
  3652  		return CloneRefOfSum(in)
  3653  	case *TimestampFuncExpr:
  3654  		return CloneRefOfTimestampFuncExpr(in)
  3655  	case *TrimFuncExpr:
  3656  		return CloneRefOfTrimFuncExpr(in)
  3657  	case *UnaryExpr:
  3658  		return CloneRefOfUnaryExpr(in)
  3659  	case *UpdateXMLExpr:
  3660  		return CloneRefOfUpdateXMLExpr(in)
  3661  	case ValTuple:
  3662  		return CloneValTuple(in)
  3663  	case *ValuesFuncExpr:
  3664  		return CloneRefOfValuesFuncExpr(in)
  3665  	case *VarPop:
  3666  		return CloneRefOfVarPop(in)
  3667  	case *VarSamp:
  3668  		return CloneRefOfVarSamp(in)
  3669  	case *Variable:
  3670  		return CloneRefOfVariable(in)
  3671  	case *Variance:
  3672  		return CloneRefOfVariance(in)
  3673  	case *WeightStringFuncExpr:
  3674  		return CloneRefOfWeightStringFuncExpr(in)
  3675  	case *XorExpr:
  3676  		return CloneRefOfXorExpr(in)
  3677  	default:
  3678  		// this should never happen
  3679  		return nil
  3680  	}
  3681  }
  3682  
  3683  // CloneInsertRows creates a deep clone of the input.
  3684  func CloneInsertRows(in InsertRows) InsertRows {
  3685  	if in == nil {
  3686  		return nil
  3687  	}
  3688  	switch in := in.(type) {
  3689  	case *Select:
  3690  		return CloneRefOfSelect(in)
  3691  	case *Union:
  3692  		return CloneRefOfUnion(in)
  3693  	case Values:
  3694  		return CloneValues(in)
  3695  	default:
  3696  		// this should never happen
  3697  		return nil
  3698  	}
  3699  }
  3700  
  3701  // CloneSelectExpr creates a deep clone of the input.
  3702  func CloneSelectExpr(in SelectExpr) SelectExpr {
  3703  	if in == nil {
  3704  		return nil
  3705  	}
  3706  	switch in := in.(type) {
  3707  	case *AliasedExpr:
  3708  		return CloneRefOfAliasedExpr(in)
  3709  	case *Nextval:
  3710  		return CloneRefOfNextval(in)
  3711  	case *StarExpr:
  3712  		return CloneRefOfStarExpr(in)
  3713  	default:
  3714  		// this should never happen
  3715  		return nil
  3716  	}
  3717  }
  3718  
  3719  // CloneSelectStatement creates a deep clone of the input.
  3720  func CloneSelectStatement(in SelectStatement) SelectStatement {
  3721  	if in == nil {
  3722  		return nil
  3723  	}
  3724  	switch in := in.(type) {
  3725  	case *Select:
  3726  		return CloneRefOfSelect(in)
  3727  	case *Union:
  3728  		return CloneRefOfUnion(in)
  3729  	default:
  3730  		// this should never happen
  3731  		return nil
  3732  	}
  3733  }
  3734  
  3735  // CloneShowInternal creates a deep clone of the input.
  3736  func CloneShowInternal(in ShowInternal) ShowInternal {
  3737  	if in == nil {
  3738  		return nil
  3739  	}
  3740  	switch in := in.(type) {
  3741  	case *ShowBasic:
  3742  		return CloneRefOfShowBasic(in)
  3743  	case *ShowCreate:
  3744  		return CloneRefOfShowCreate(in)
  3745  	case *ShowOther:
  3746  		return CloneRefOfShowOther(in)
  3747  	default:
  3748  		// this should never happen
  3749  		return nil
  3750  	}
  3751  }
  3752  
  3753  // CloneSimpleTableExpr creates a deep clone of the input.
  3754  func CloneSimpleTableExpr(in SimpleTableExpr) SimpleTableExpr {
  3755  	if in == nil {
  3756  		return nil
  3757  	}
  3758  	switch in := in.(type) {
  3759  	case *DerivedTable:
  3760  		return CloneRefOfDerivedTable(in)
  3761  	case TableName:
  3762  		return CloneTableName(in)
  3763  	default:
  3764  		// this should never happen
  3765  		return nil
  3766  	}
  3767  }
  3768  
  3769  // CloneStatement creates a deep clone of the input.
  3770  func CloneStatement(in Statement) Statement {
  3771  	if in == nil {
  3772  		return nil
  3773  	}
  3774  	switch in := in.(type) {
  3775  	case *AlterDatabase:
  3776  		return CloneRefOfAlterDatabase(in)
  3777  	case *AlterMigration:
  3778  		return CloneRefOfAlterMigration(in)
  3779  	case *AlterTable:
  3780  		return CloneRefOfAlterTable(in)
  3781  	case *AlterView:
  3782  		return CloneRefOfAlterView(in)
  3783  	case *AlterVschema:
  3784  		return CloneRefOfAlterVschema(in)
  3785  	case *Begin:
  3786  		return CloneRefOfBegin(in)
  3787  	case *CallProc:
  3788  		return CloneRefOfCallProc(in)
  3789  	case *CommentOnly:
  3790  		return CloneRefOfCommentOnly(in)
  3791  	case *Commit:
  3792  		return CloneRefOfCommit(in)
  3793  	case *CreateDatabase:
  3794  		return CloneRefOfCreateDatabase(in)
  3795  	case *CreateTable:
  3796  		return CloneRefOfCreateTable(in)
  3797  	case *CreateView:
  3798  		return CloneRefOfCreateView(in)
  3799  	case *DeallocateStmt:
  3800  		return CloneRefOfDeallocateStmt(in)
  3801  	case *Delete:
  3802  		return CloneRefOfDelete(in)
  3803  	case *DropDatabase:
  3804  		return CloneRefOfDropDatabase(in)
  3805  	case *DropTable:
  3806  		return CloneRefOfDropTable(in)
  3807  	case *DropView:
  3808  		return CloneRefOfDropView(in)
  3809  	case *ExecuteStmt:
  3810  		return CloneRefOfExecuteStmt(in)
  3811  	case *ExplainStmt:
  3812  		return CloneRefOfExplainStmt(in)
  3813  	case *ExplainTab:
  3814  		return CloneRefOfExplainTab(in)
  3815  	case *Flush:
  3816  		return CloneRefOfFlush(in)
  3817  	case *Insert:
  3818  		return CloneRefOfInsert(in)
  3819  	case *Load:
  3820  		return CloneRefOfLoad(in)
  3821  	case *LockTables:
  3822  		return CloneRefOfLockTables(in)
  3823  	case *OtherAdmin:
  3824  		return CloneRefOfOtherAdmin(in)
  3825  	case *OtherRead:
  3826  		return CloneRefOfOtherRead(in)
  3827  	case *PrepareStmt:
  3828  		return CloneRefOfPrepareStmt(in)
  3829  	case *Release:
  3830  		return CloneRefOfRelease(in)
  3831  	case *RenameTable:
  3832  		return CloneRefOfRenameTable(in)
  3833  	case *RevertMigration:
  3834  		return CloneRefOfRevertMigration(in)
  3835  	case *Rollback:
  3836  		return CloneRefOfRollback(in)
  3837  	case *SRollback:
  3838  		return CloneRefOfSRollback(in)
  3839  	case *Savepoint:
  3840  		return CloneRefOfSavepoint(in)
  3841  	case *Select:
  3842  		return CloneRefOfSelect(in)
  3843  	case *Set:
  3844  		return CloneRefOfSet(in)
  3845  	case *Show:
  3846  		return CloneRefOfShow(in)
  3847  	case *ShowMigrationLogs:
  3848  		return CloneRefOfShowMigrationLogs(in)
  3849  	case *ShowThrottledApps:
  3850  		return CloneRefOfShowThrottledApps(in)
  3851  	case *ShowThrottlerStatus:
  3852  		return CloneRefOfShowThrottlerStatus(in)
  3853  	case *Stream:
  3854  		return CloneRefOfStream(in)
  3855  	case *TruncateTable:
  3856  		return CloneRefOfTruncateTable(in)
  3857  	case *Union:
  3858  		return CloneRefOfUnion(in)
  3859  	case *UnlockTables:
  3860  		return CloneRefOfUnlockTables(in)
  3861  	case *Update:
  3862  		return CloneRefOfUpdate(in)
  3863  	case *Use:
  3864  		return CloneRefOfUse(in)
  3865  	case *VExplainStmt:
  3866  		return CloneRefOfVExplainStmt(in)
  3867  	case *VStream:
  3868  		return CloneRefOfVStream(in)
  3869  	default:
  3870  		// this should never happen
  3871  		return nil
  3872  	}
  3873  }
  3874  
  3875  // CloneTableExpr creates a deep clone of the input.
  3876  func CloneTableExpr(in TableExpr) TableExpr {
  3877  	if in == nil {
  3878  		return nil
  3879  	}
  3880  	switch in := in.(type) {
  3881  	case *AliasedTableExpr:
  3882  		return CloneRefOfAliasedTableExpr(in)
  3883  	case *JSONTableExpr:
  3884  		return CloneRefOfJSONTableExpr(in)
  3885  	case *JoinTableExpr:
  3886  		return CloneRefOfJoinTableExpr(in)
  3887  	case *ParenTableExpr:
  3888  		return CloneRefOfParenTableExpr(in)
  3889  	default:
  3890  		// this should never happen
  3891  		return nil
  3892  	}
  3893  }
  3894  
  3895  // CloneSliceOfRefOfColumnDefinition creates a deep clone of the input.
  3896  func CloneSliceOfRefOfColumnDefinition(n []*ColumnDefinition) []*ColumnDefinition {
  3897  	if n == nil {
  3898  		return nil
  3899  	}
  3900  	res := make([]*ColumnDefinition, len(n))
  3901  	for i, x := range n {
  3902  		res[i] = CloneRefOfColumnDefinition(x)
  3903  	}
  3904  	return res
  3905  }
  3906  
  3907  // CloneRefOfBool creates a deep clone of the input.
  3908  func CloneRefOfBool(n *bool) *bool {
  3909  	if n == nil {
  3910  		return nil
  3911  	}
  3912  	out := *n
  3913  	return &out
  3914  }
  3915  
  3916  // CloneSliceOfDatabaseOption creates a deep clone of the input.
  3917  func CloneSliceOfDatabaseOption(n []DatabaseOption) []DatabaseOption {
  3918  	if n == nil {
  3919  		return nil
  3920  	}
  3921  	res := make([]DatabaseOption, len(n))
  3922  	for i, x := range n {
  3923  		res[i] = CloneDatabaseOption(x)
  3924  	}
  3925  	return res
  3926  }
  3927  
  3928  // CloneSliceOfAlterOption creates a deep clone of the input.
  3929  func CloneSliceOfAlterOption(n []AlterOption) []AlterOption {
  3930  	if n == nil {
  3931  		return nil
  3932  	}
  3933  	res := make([]AlterOption, len(n))
  3934  	for i, x := range n {
  3935  		res[i] = CloneAlterOption(x)
  3936  	}
  3937  	return res
  3938  }
  3939  
  3940  // CloneSliceOfIdentifierCI creates a deep clone of the input.
  3941  func CloneSliceOfIdentifierCI(n []IdentifierCI) []IdentifierCI {
  3942  	if n == nil {
  3943  		return nil
  3944  	}
  3945  	res := make([]IdentifierCI, len(n))
  3946  	for i, x := range n {
  3947  		res[i] = CloneIdentifierCI(x)
  3948  	}
  3949  	return res
  3950  }
  3951  
  3952  // CloneSliceOfTxAccessMode creates a deep clone of the input.
  3953  func CloneSliceOfTxAccessMode(n []TxAccessMode) []TxAccessMode {
  3954  	if n == nil {
  3955  		return nil
  3956  	}
  3957  	res := make([]TxAccessMode, len(n))
  3958  	copy(res, n)
  3959  	return res
  3960  }
  3961  
  3962  // CloneSliceOfRefOfWhen creates a deep clone of the input.
  3963  func CloneSliceOfRefOfWhen(n []*When) []*When {
  3964  	if n == nil {
  3965  		return nil
  3966  	}
  3967  	res := make([]*When, len(n))
  3968  	for i, x := range n {
  3969  		res[i] = CloneRefOfWhen(x)
  3970  	}
  3971  	return res
  3972  }
  3973  
  3974  // CloneRefOfColumnTypeOptions creates a deep clone of the input.
  3975  func CloneRefOfColumnTypeOptions(n *ColumnTypeOptions) *ColumnTypeOptions {
  3976  	if n == nil {
  3977  		return nil
  3978  	}
  3979  	out := *n
  3980  	out.Null = CloneRefOfBool(n.Null)
  3981  	out.Default = CloneExpr(n.Default)
  3982  	out.OnUpdate = CloneExpr(n.OnUpdate)
  3983  	out.As = CloneExpr(n.As)
  3984  	out.Comment = CloneRefOfLiteral(n.Comment)
  3985  	out.Reference = CloneRefOfReferenceDefinition(n.Reference)
  3986  	out.Invisible = CloneRefOfBool(n.Invisible)
  3987  	out.EngineAttribute = CloneRefOfLiteral(n.EngineAttribute)
  3988  	out.SecondaryEngineAttribute = CloneRefOfLiteral(n.SecondaryEngineAttribute)
  3989  	out.SRID = CloneRefOfLiteral(n.SRID)
  3990  	return &out
  3991  }
  3992  
  3993  // CloneColumnCharset creates a deep clone of the input.
  3994  func CloneColumnCharset(n ColumnCharset) ColumnCharset {
  3995  	return *CloneRefOfColumnCharset(&n)
  3996  }
  3997  
  3998  // CloneSliceOfString creates a deep clone of the input.
  3999  func CloneSliceOfString(n []string) []string {
  4000  	if n == nil {
  4001  		return nil
  4002  	}
  4003  	res := make([]string, len(n))
  4004  	copy(res, n)
  4005  	return res
  4006  }
  4007  
  4008  // CloneSliceOfRefOfVariable creates a deep clone of the input.
  4009  func CloneSliceOfRefOfVariable(n []*Variable) []*Variable {
  4010  	if n == nil {
  4011  		return nil
  4012  	}
  4013  	res := make([]*Variable, len(n))
  4014  	for i, x := range n {
  4015  		res[i] = CloneRefOfVariable(x)
  4016  	}
  4017  	return res
  4018  }
  4019  
  4020  // CloneRefOfIdentifierCI creates a deep clone of the input.
  4021  func CloneRefOfIdentifierCI(n *IdentifierCI) *IdentifierCI {
  4022  	if n == nil {
  4023  		return nil
  4024  	}
  4025  	out := *n
  4026  	return &out
  4027  }
  4028  
  4029  // CloneRefOfIdentifierCS creates a deep clone of the input.
  4030  func CloneRefOfIdentifierCS(n *IdentifierCS) *IdentifierCS {
  4031  	if n == nil {
  4032  		return nil
  4033  	}
  4034  	out := *n
  4035  	return &out
  4036  }
  4037  
  4038  // CloneSliceOfRefOfIndexColumn creates a deep clone of the input.
  4039  func CloneSliceOfRefOfIndexColumn(n []*IndexColumn) []*IndexColumn {
  4040  	if n == nil {
  4041  		return nil
  4042  	}
  4043  	res := make([]*IndexColumn, len(n))
  4044  	for i, x := range n {
  4045  		res[i] = CloneRefOfIndexColumn(x)
  4046  	}
  4047  	return res
  4048  }
  4049  
  4050  // CloneSliceOfRefOfIndexOption creates a deep clone of the input.
  4051  func CloneSliceOfRefOfIndexOption(n []*IndexOption) []*IndexOption {
  4052  	if n == nil {
  4053  		return nil
  4054  	}
  4055  	res := make([]*IndexOption, len(n))
  4056  	for i, x := range n {
  4057  		res[i] = CloneRefOfIndexOption(x)
  4058  	}
  4059  	return res
  4060  }
  4061  
  4062  // CloneSliceOfExpr creates a deep clone of the input.
  4063  func CloneSliceOfExpr(n []Expr) []Expr {
  4064  	if n == nil {
  4065  		return nil
  4066  	}
  4067  	res := make([]Expr, len(n))
  4068  	for i, x := range n {
  4069  		res[i] = CloneExpr(x)
  4070  	}
  4071  	return res
  4072  }
  4073  
  4074  // CloneSliceOfRefOfJSONObjectParam creates a deep clone of the input.
  4075  func CloneSliceOfRefOfJSONObjectParam(n []*JSONObjectParam) []*JSONObjectParam {
  4076  	if n == nil {
  4077  		return nil
  4078  	}
  4079  	res := make([]*JSONObjectParam, len(n))
  4080  	for i, x := range n {
  4081  		res[i] = CloneRefOfJSONObjectParam(x)
  4082  	}
  4083  	return res
  4084  }
  4085  
  4086  // CloneSliceOfRefOfJtColumnDefinition creates a deep clone of the input.
  4087  func CloneSliceOfRefOfJtColumnDefinition(n []*JtColumnDefinition) []*JtColumnDefinition {
  4088  	if n == nil {
  4089  		return nil
  4090  	}
  4091  	res := make([]*JtColumnDefinition, len(n))
  4092  	for i, x := range n {
  4093  		res[i] = CloneRefOfJtColumnDefinition(x)
  4094  	}
  4095  	return res
  4096  }
  4097  
  4098  // CloneRefOfJtOrdinalColDef creates a deep clone of the input.
  4099  func CloneRefOfJtOrdinalColDef(n *JtOrdinalColDef) *JtOrdinalColDef {
  4100  	if n == nil {
  4101  		return nil
  4102  	}
  4103  	out := *n
  4104  	out.Name = CloneIdentifierCI(n.Name)
  4105  	return &out
  4106  }
  4107  
  4108  // CloneRefOfJtPathColDef creates a deep clone of the input.
  4109  func CloneRefOfJtPathColDef(n *JtPathColDef) *JtPathColDef {
  4110  	if n == nil {
  4111  		return nil
  4112  	}
  4113  	out := *n
  4114  	out.Name = CloneIdentifierCI(n.Name)
  4115  	out.Type = CloneRefOfColumnType(n.Type)
  4116  	out.Path = CloneExpr(n.Path)
  4117  	out.EmptyOnResponse = CloneRefOfJtOnResponse(n.EmptyOnResponse)
  4118  	out.ErrorOnResponse = CloneRefOfJtOnResponse(n.ErrorOnResponse)
  4119  	return &out
  4120  }
  4121  
  4122  // CloneRefOfJtNestedPathColDef creates a deep clone of the input.
  4123  func CloneRefOfJtNestedPathColDef(n *JtNestedPathColDef) *JtNestedPathColDef {
  4124  	if n == nil {
  4125  		return nil
  4126  	}
  4127  	out := *n
  4128  	out.Path = CloneExpr(n.Path)
  4129  	out.Columns = CloneSliceOfRefOfJtColumnDefinition(n.Columns)
  4130  	return &out
  4131  }
  4132  
  4133  // CloneTableAndLockTypes creates a deep clone of the input.
  4134  func CloneTableAndLockTypes(n TableAndLockTypes) TableAndLockTypes {
  4135  	if n == nil {
  4136  		return nil
  4137  	}
  4138  	res := make(TableAndLockTypes, len(n))
  4139  	for i, x := range n {
  4140  		res[i] = CloneRefOfTableAndLockType(x)
  4141  	}
  4142  	return res
  4143  }
  4144  
  4145  // CloneSliceOfRefOfColName creates a deep clone of the input.
  4146  func CloneSliceOfRefOfColName(n []*ColName) []*ColName {
  4147  	if n == nil {
  4148  		return nil
  4149  	}
  4150  	res := make([]*ColName, len(n))
  4151  	for i, x := range n {
  4152  		res[i] = CloneRefOfColName(x)
  4153  	}
  4154  	return res
  4155  }
  4156  
  4157  // CloneComments creates a deep clone of the input.
  4158  func CloneComments(n Comments) Comments {
  4159  	if n == nil {
  4160  		return nil
  4161  	}
  4162  	res := make(Comments, len(n))
  4163  	for i, x := range n {
  4164  		res[i] = x
  4165  	}
  4166  	return res
  4167  }
  4168  
  4169  // CloneRefOfInt creates a deep clone of the input.
  4170  func CloneRefOfInt(n *int) *int {
  4171  	if n == nil {
  4172  		return nil
  4173  	}
  4174  	out := *n
  4175  	return &out
  4176  }
  4177  
  4178  // CloneSliceOfRefOfPartitionDefinition creates a deep clone of the input.
  4179  func CloneSliceOfRefOfPartitionDefinition(n []*PartitionDefinition) []*PartitionDefinition {
  4180  	if n == nil {
  4181  		return nil
  4182  	}
  4183  	res := make([]*PartitionDefinition, len(n))
  4184  	for i, x := range n {
  4185  		res[i] = CloneRefOfPartitionDefinition(x)
  4186  	}
  4187  	return res
  4188  }
  4189  
  4190  // CloneSliceOfRefOfRenameTablePair creates a deep clone of the input.
  4191  func CloneSliceOfRefOfRenameTablePair(n []*RenameTablePair) []*RenameTablePair {
  4192  	if n == nil {
  4193  		return nil
  4194  	}
  4195  	res := make([]*RenameTablePair, len(n))
  4196  	for i, x := range n {
  4197  		res[i] = CloneRefOfRenameTablePair(x)
  4198  	}
  4199  	return res
  4200  }
  4201  
  4202  // CloneRefOfRootNode creates a deep clone of the input.
  4203  func CloneRefOfRootNode(n *RootNode) *RootNode {
  4204  	if n == nil {
  4205  		return nil
  4206  	}
  4207  	out := *n
  4208  	out.SQLNode = CloneSQLNode(n.SQLNode)
  4209  	return &out
  4210  }
  4211  
  4212  // CloneSliceOfTableExpr creates a deep clone of the input.
  4213  func CloneSliceOfTableExpr(n []TableExpr) []TableExpr {
  4214  	if n == nil {
  4215  		return nil
  4216  	}
  4217  	res := make([]TableExpr, len(n))
  4218  	for i, x := range n {
  4219  		res[i] = CloneTableExpr(x)
  4220  	}
  4221  	return res
  4222  }
  4223  
  4224  // CloneRefOfTableName creates a deep clone of the input.
  4225  func CloneRefOfTableName(n *TableName) *TableName {
  4226  	if n == nil {
  4227  		return nil
  4228  	}
  4229  	out := *n
  4230  	out.Name = CloneIdentifierCS(n.Name)
  4231  	out.Qualifier = CloneIdentifierCS(n.Qualifier)
  4232  	return &out
  4233  }
  4234  
  4235  // CloneRefOfTableOption creates a deep clone of the input.
  4236  func CloneRefOfTableOption(n *TableOption) *TableOption {
  4237  	if n == nil {
  4238  		return nil
  4239  	}
  4240  	out := *n
  4241  	out.Value = CloneRefOfLiteral(n.Value)
  4242  	out.Tables = CloneTableNames(n.Tables)
  4243  	return &out
  4244  }
  4245  
  4246  // CloneSliceOfRefOfIndexDefinition creates a deep clone of the input.
  4247  func CloneSliceOfRefOfIndexDefinition(n []*IndexDefinition) []*IndexDefinition {
  4248  	if n == nil {
  4249  		return nil
  4250  	}
  4251  	res := make([]*IndexDefinition, len(n))
  4252  	for i, x := range n {
  4253  		res[i] = CloneRefOfIndexDefinition(x)
  4254  	}
  4255  	return res
  4256  }
  4257  
  4258  // CloneSliceOfRefOfConstraintDefinition creates a deep clone of the input.
  4259  func CloneSliceOfRefOfConstraintDefinition(n []*ConstraintDefinition) []*ConstraintDefinition {
  4260  	if n == nil {
  4261  		return nil
  4262  	}
  4263  	res := make([]*ConstraintDefinition, len(n))
  4264  	for i, x := range n {
  4265  		res[i] = CloneRefOfConstraintDefinition(x)
  4266  	}
  4267  	return res
  4268  }
  4269  
  4270  // CloneRefOfVindexParam creates a deep clone of the input.
  4271  func CloneRefOfVindexParam(n *VindexParam) *VindexParam {
  4272  	if n == nil {
  4273  		return nil
  4274  	}
  4275  	out := *n
  4276  	out.Key = CloneIdentifierCI(n.Key)
  4277  	return &out
  4278  }
  4279  
  4280  // CloneSliceOfVindexParam creates a deep clone of the input.
  4281  func CloneSliceOfVindexParam(n []VindexParam) []VindexParam {
  4282  	if n == nil {
  4283  		return nil
  4284  	}
  4285  	res := make([]VindexParam, len(n))
  4286  	for i, x := range n {
  4287  		res[i] = CloneVindexParam(x)
  4288  	}
  4289  	return res
  4290  }
  4291  
  4292  // CloneSliceOfRefOfCommonTableExpr creates a deep clone of the input.
  4293  func CloneSliceOfRefOfCommonTableExpr(n []*CommonTableExpr) []*CommonTableExpr {
  4294  	if n == nil {
  4295  		return nil
  4296  	}
  4297  	res := make([]*CommonTableExpr, len(n))
  4298  	for i, x := range n {
  4299  		res[i] = CloneRefOfCommonTableExpr(x)
  4300  	}
  4301  	return res
  4302  }
  4303  
  4304  // CloneDatabaseOption creates a deep clone of the input.
  4305  func CloneDatabaseOption(n DatabaseOption) DatabaseOption {
  4306  	return *CloneRefOfDatabaseOption(&n)
  4307  }
  4308  
  4309  // CloneRefOfColumnCharset creates a deep clone of the input.
  4310  func CloneRefOfColumnCharset(n *ColumnCharset) *ColumnCharset {
  4311  	if n == nil {
  4312  		return nil
  4313  	}
  4314  	out := *n
  4315  	return &out
  4316  }
  4317  
  4318  // CloneRefOfIndexColumn creates a deep clone of the input.
  4319  func CloneRefOfIndexColumn(n *IndexColumn) *IndexColumn {
  4320  	if n == nil {
  4321  		return nil
  4322  	}
  4323  	out := *n
  4324  	out.Column = CloneIdentifierCI(n.Column)
  4325  	out.Length = CloneRefOfLiteral(n.Length)
  4326  	out.Expression = CloneExpr(n.Expression)
  4327  	return &out
  4328  }
  4329  
  4330  // CloneRefOfIndexOption creates a deep clone of the input.
  4331  func CloneRefOfIndexOption(n *IndexOption) *IndexOption {
  4332  	if n == nil {
  4333  		return nil
  4334  	}
  4335  	out := *n
  4336  	out.Value = CloneRefOfLiteral(n.Value)
  4337  	return &out
  4338  }
  4339  
  4340  // CloneRefOfTableAndLockType creates a deep clone of the input.
  4341  func CloneRefOfTableAndLockType(n *TableAndLockType) *TableAndLockType {
  4342  	if n == nil {
  4343  		return nil
  4344  	}
  4345  	out := *n
  4346  	out.Table = CloneTableExpr(n.Table)
  4347  	return &out
  4348  }
  4349  
  4350  // CloneRefOfRenameTablePair creates a deep clone of the input.
  4351  func CloneRefOfRenameTablePair(n *RenameTablePair) *RenameTablePair {
  4352  	if n == nil {
  4353  		return nil
  4354  	}
  4355  	out := *n
  4356  	out.FromTable = CloneTableName(n.FromTable)
  4357  	out.ToTable = CloneTableName(n.ToTable)
  4358  	return &out
  4359  }
  4360  
  4361  // CloneRefOfDatabaseOption creates a deep clone of the input.
  4362  func CloneRefOfDatabaseOption(n *DatabaseOption) *DatabaseOption {
  4363  	if n == nil {
  4364  		return nil
  4365  	}
  4366  	out := *n
  4367  	return &out
  4368  }