github.com/team-ide/go-dialect@v1.9.20/vitess/sqlparser/ast_clone.go (about)

     1  /*
     2  Copyright 2021 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 AccessMode:
    27  		return in
    28  	case *AddColumns:
    29  		return CloneRefOfAddColumns(in)
    30  	case *AddConstraintDefinition:
    31  		return CloneRefOfAddConstraintDefinition(in)
    32  	case *AddIndexDefinition:
    33  		return CloneRefOfAddIndexDefinition(in)
    34  	case AlgorithmValue:
    35  		return in
    36  	case *AliasedExpr:
    37  		return CloneRefOfAliasedExpr(in)
    38  	case *AliasedTableExpr:
    39  		return CloneRefOfAliasedTableExpr(in)
    40  	case *AlterCharset:
    41  		return CloneRefOfAlterCharset(in)
    42  	case *AlterColumn:
    43  		return CloneRefOfAlterColumn(in)
    44  	case *AlterDatabase:
    45  		return CloneRefOfAlterDatabase(in)
    46  	case *AlterMigration:
    47  		return CloneRefOfAlterMigration(in)
    48  	case *AlterTable:
    49  		return CloneRefOfAlterTable(in)
    50  	case *AlterView:
    51  		return CloneRefOfAlterView(in)
    52  	case *AlterVschema:
    53  		return CloneRefOfAlterVschema(in)
    54  	case *AndExpr:
    55  		return CloneRefOfAndExpr(in)
    56  	case Argument:
    57  		return in
    58  	case *AutoIncSpec:
    59  		return CloneRefOfAutoIncSpec(in)
    60  	case *Begin:
    61  		return CloneRefOfBegin(in)
    62  	case *BetweenExpr:
    63  		return CloneRefOfBetweenExpr(in)
    64  	case *BinaryExpr:
    65  		return CloneRefOfBinaryExpr(in)
    66  	case BoolVal:
    67  		return in
    68  	case *CallProc:
    69  		return CloneRefOfCallProc(in)
    70  	case *CaseExpr:
    71  		return CloneRefOfCaseExpr(in)
    72  	case *ChangeColumn:
    73  		return CloneRefOfChangeColumn(in)
    74  	case *CheckConstraintDefinition:
    75  		return CloneRefOfCheckConstraintDefinition(in)
    76  	case ColIdent:
    77  		return CloneColIdent(in)
    78  	case *ColName:
    79  		return CloneRefOfColName(in)
    80  	case *CollateExpr:
    81  		return CloneRefOfCollateExpr(in)
    82  	case *ColumnDefinition:
    83  		return CloneRefOfColumnDefinition(in)
    84  	case *ColumnType:
    85  		return CloneRefOfColumnType(in)
    86  	case Columns:
    87  		return CloneColumns(in)
    88  	case Comments:
    89  		return CloneComments(in)
    90  	case *Commit:
    91  		return CloneRefOfCommit(in)
    92  	case *CommonTableExpr:
    93  		return CloneRefOfCommonTableExpr(in)
    94  	case *ComparisonExpr:
    95  		return CloneRefOfComparisonExpr(in)
    96  	case *ConstraintDefinition:
    97  		return CloneRefOfConstraintDefinition(in)
    98  	case *ConvertExpr:
    99  		return CloneRefOfConvertExpr(in)
   100  	case *ConvertType:
   101  		return CloneRefOfConvertType(in)
   102  	case *ConvertUsingExpr:
   103  		return CloneRefOfConvertUsingExpr(in)
   104  	case *CreateDatabase:
   105  		return CloneRefOfCreateDatabase(in)
   106  	case *CreateTable:
   107  		return CloneRefOfCreateTable(in)
   108  	case *CreateView:
   109  		return CloneRefOfCreateView(in)
   110  	case *CurTimeFuncExpr:
   111  		return CloneRefOfCurTimeFuncExpr(in)
   112  	case *Default:
   113  		return CloneRefOfDefault(in)
   114  	case *Delete:
   115  		return CloneRefOfDelete(in)
   116  	case *DerivedTable:
   117  		return CloneRefOfDerivedTable(in)
   118  	case *DropColumn:
   119  		return CloneRefOfDropColumn(in)
   120  	case *DropDatabase:
   121  		return CloneRefOfDropDatabase(in)
   122  	case *DropKey:
   123  		return CloneRefOfDropKey(in)
   124  	case *DropTable:
   125  		return CloneRefOfDropTable(in)
   126  	case *DropView:
   127  		return CloneRefOfDropView(in)
   128  	case *ExistsExpr:
   129  		return CloneRefOfExistsExpr(in)
   130  	case *ExplainStmt:
   131  		return CloneRefOfExplainStmt(in)
   132  	case *ExplainTab:
   133  		return CloneRefOfExplainTab(in)
   134  	case *ExprOrColumns:
   135  		return CloneRefOfExprOrColumns(in)
   136  	case Exprs:
   137  		return CloneExprs(in)
   138  	case *ExtractFuncExpr:
   139  		return CloneRefOfExtractFuncExpr(in)
   140  	case *ExtractedSubquery:
   141  		return CloneRefOfExtractedSubquery(in)
   142  	case *Flush:
   143  		return CloneRefOfFlush(in)
   144  	case *Force:
   145  		return CloneRefOfForce(in)
   146  	case *ForeignKeyDefinition:
   147  		return CloneRefOfForeignKeyDefinition(in)
   148  	case *FuncExpr:
   149  		return CloneRefOfFuncExpr(in)
   150  	case GroupBy:
   151  		return CloneGroupBy(in)
   152  	case *GroupConcatExpr:
   153  		return CloneRefOfGroupConcatExpr(in)
   154  	case *IndexDefinition:
   155  		return CloneRefOfIndexDefinition(in)
   156  	case *IndexHints:
   157  		return CloneRefOfIndexHints(in)
   158  	case *IndexInfo:
   159  		return CloneRefOfIndexInfo(in)
   160  	case *Insert:
   161  		return CloneRefOfInsert(in)
   162  	case *IntervalExpr:
   163  		return CloneRefOfIntervalExpr(in)
   164  	case *IntroducerExpr:
   165  		return CloneRefOfIntroducerExpr(in)
   166  	case *IsExpr:
   167  		return CloneRefOfIsExpr(in)
   168  	case IsolationLevel:
   169  		return in
   170  	case *JoinCondition:
   171  		return CloneRefOfJoinCondition(in)
   172  	case *JoinTableExpr:
   173  		return CloneRefOfJoinTableExpr(in)
   174  	case *KeyState:
   175  		return CloneRefOfKeyState(in)
   176  	case *Limit:
   177  		return CloneRefOfLimit(in)
   178  	case ListArg:
   179  		return in
   180  	case *Literal:
   181  		return CloneRefOfLiteral(in)
   182  	case *Load:
   183  		return CloneRefOfLoad(in)
   184  	case *LockOption:
   185  		return CloneRefOfLockOption(in)
   186  	case *LockTables:
   187  		return CloneRefOfLockTables(in)
   188  	case *MatchExpr:
   189  		return CloneRefOfMatchExpr(in)
   190  	case *ModifyColumn:
   191  		return CloneRefOfModifyColumn(in)
   192  	case *Nextval:
   193  		return CloneRefOfNextval(in)
   194  	case *NotExpr:
   195  		return CloneRefOfNotExpr(in)
   196  	case *NullVal:
   197  		return CloneRefOfNullVal(in)
   198  	case OnDup:
   199  		return CloneOnDup(in)
   200  	case *OptLike:
   201  		return CloneRefOfOptLike(in)
   202  	case *OrExpr:
   203  		return CloneRefOfOrExpr(in)
   204  	case *Order:
   205  		return CloneRefOfOrder(in)
   206  	case OrderBy:
   207  		return CloneOrderBy(in)
   208  	case *OrderByOption:
   209  		return CloneRefOfOrderByOption(in)
   210  	case *OtherAdmin:
   211  		return CloneRefOfOtherAdmin(in)
   212  	case *OtherRead:
   213  		return CloneRefOfOtherRead(in)
   214  	case *ParenTableExpr:
   215  		return CloneRefOfParenTableExpr(in)
   216  	case *PartitionDefinition:
   217  		return CloneRefOfPartitionDefinition(in)
   218  	case *PartitionOption:
   219  		return CloneRefOfPartitionOption(in)
   220  	case *PartitionSpec:
   221  		return CloneRefOfPartitionSpec(in)
   222  	case Partitions:
   223  		return ClonePartitions(in)
   224  	case ReferenceAction:
   225  		return in
   226  	case *ReferenceDefinition:
   227  		return CloneRefOfReferenceDefinition(in)
   228  	case *Release:
   229  		return CloneRefOfRelease(in)
   230  	case *RenameIndex:
   231  		return CloneRefOfRenameIndex(in)
   232  	case *RenameTable:
   233  		return CloneRefOfRenameTable(in)
   234  	case *RenameTableName:
   235  		return CloneRefOfRenameTableName(in)
   236  	case *RevertMigration:
   237  		return CloneRefOfRevertMigration(in)
   238  	case *Rollback:
   239  		return CloneRefOfRollback(in)
   240  	case RootNode:
   241  		return CloneRootNode(in)
   242  	case *SRollback:
   243  		return CloneRefOfSRollback(in)
   244  	case *Savepoint:
   245  		return CloneRefOfSavepoint(in)
   246  	case *Select:
   247  		return CloneRefOfSelect(in)
   248  	case SelectExprs:
   249  		return CloneSelectExprs(in)
   250  	case *SelectInto:
   251  		return CloneRefOfSelectInto(in)
   252  	case *Set:
   253  		return CloneRefOfSet(in)
   254  	case *SetExpr:
   255  		return CloneRefOfSetExpr(in)
   256  	case SetExprs:
   257  		return CloneSetExprs(in)
   258  	case *SetTransaction:
   259  		return CloneRefOfSetTransaction(in)
   260  	case *Show:
   261  		return CloneRefOfShow(in)
   262  	case *ShowBasic:
   263  		return CloneRefOfShowBasic(in)
   264  	case *ShowCreate:
   265  		return CloneRefOfShowCreate(in)
   266  	case *ShowFilter:
   267  		return CloneRefOfShowFilter(in)
   268  	case *ShowLegacy:
   269  		return CloneRefOfShowLegacy(in)
   270  	case *ShowMigrationLogs:
   271  		return CloneRefOfShowMigrationLogs(in)
   272  	case *StarExpr:
   273  		return CloneRefOfStarExpr(in)
   274  	case *Stream:
   275  		return CloneRefOfStream(in)
   276  	case *SubPartition:
   277  		return CloneRefOfSubPartition(in)
   278  	case *Subquery:
   279  		return CloneRefOfSubquery(in)
   280  	case *SubstrExpr:
   281  		return CloneRefOfSubstrExpr(in)
   282  	case TableExprs:
   283  		return CloneTableExprs(in)
   284  	case TableIdent:
   285  		return CloneTableIdent(in)
   286  	case TableName:
   287  		return CloneTableName(in)
   288  	case TableNames:
   289  		return CloneTableNames(in)
   290  	case TableOptions:
   291  		return CloneTableOptions(in)
   292  	case *TableSpec:
   293  		return CloneRefOfTableSpec(in)
   294  	case *TablespaceOperation:
   295  		return CloneRefOfTablespaceOperation(in)
   296  	case *TimestampFuncExpr:
   297  		return CloneRefOfTimestampFuncExpr(in)
   298  	case *TruncateTable:
   299  		return CloneRefOfTruncateTable(in)
   300  	case *UnaryExpr:
   301  		return CloneRefOfUnaryExpr(in)
   302  	case *Union:
   303  		return CloneRefOfUnion(in)
   304  	case *UnlockTables:
   305  		return CloneRefOfUnlockTables(in)
   306  	case *Update:
   307  		return CloneRefOfUpdate(in)
   308  	case *UpdateExpr:
   309  		return CloneRefOfUpdateExpr(in)
   310  	case UpdateExprs:
   311  		return CloneUpdateExprs(in)
   312  	case *Use:
   313  		return CloneRefOfUse(in)
   314  	case *VStream:
   315  		return CloneRefOfVStream(in)
   316  	case ValTuple:
   317  		return CloneValTuple(in)
   318  	case *Validation:
   319  		return CloneRefOfValidation(in)
   320  	case Values:
   321  		return CloneValues(in)
   322  	case *ValuesFuncExpr:
   323  		return CloneRefOfValuesFuncExpr(in)
   324  	case VindexParam:
   325  		return CloneVindexParam(in)
   326  	case *VindexSpec:
   327  		return CloneRefOfVindexSpec(in)
   328  	case *When:
   329  		return CloneRefOfWhen(in)
   330  	case *Where:
   331  		return CloneRefOfWhere(in)
   332  	case *With:
   333  		return CloneRefOfWith(in)
   334  	case *XorExpr:
   335  		return CloneRefOfXorExpr(in)
   336  	default:
   337  		// this should never happen
   338  		return nil
   339  	}
   340  }
   341  
   342  // CloneRefOfAddColumns creates a deep clone of the input.
   343  func CloneRefOfAddColumns(n *AddColumns) *AddColumns {
   344  	if n == nil {
   345  		return nil
   346  	}
   347  	out := *n
   348  	out.Columns = CloneSliceOfRefOfColumnDefinition(n.Columns)
   349  	out.After = CloneRefOfColName(n.After)
   350  	return &out
   351  }
   352  
   353  // CloneRefOfAddConstraintDefinition creates a deep clone of the input.
   354  func CloneRefOfAddConstraintDefinition(n *AddConstraintDefinition) *AddConstraintDefinition {
   355  	if n == nil {
   356  		return nil
   357  	}
   358  	out := *n
   359  	out.ConstraintDefinition = CloneRefOfConstraintDefinition(n.ConstraintDefinition)
   360  	return &out
   361  }
   362  
   363  // CloneRefOfAddIndexDefinition creates a deep clone of the input.
   364  func CloneRefOfAddIndexDefinition(n *AddIndexDefinition) *AddIndexDefinition {
   365  	if n == nil {
   366  		return nil
   367  	}
   368  	out := *n
   369  	out.IndexDefinition = CloneRefOfIndexDefinition(n.IndexDefinition)
   370  	return &out
   371  }
   372  
   373  // CloneRefOfAliasedExpr creates a deep clone of the input.
   374  func CloneRefOfAliasedExpr(n *AliasedExpr) *AliasedExpr {
   375  	if n == nil {
   376  		return nil
   377  	}
   378  	out := *n
   379  	out.Expr = CloneExpr(n.Expr)
   380  	out.As = CloneColIdent(n.As)
   381  	return &out
   382  }
   383  
   384  // CloneRefOfAliasedTableExpr creates a deep clone of the input.
   385  func CloneRefOfAliasedTableExpr(n *AliasedTableExpr) *AliasedTableExpr {
   386  	if n == nil {
   387  		return nil
   388  	}
   389  	out := *n
   390  	out.Expr = CloneSimpleTableExpr(n.Expr)
   391  	out.Partitions = ClonePartitions(n.Partitions)
   392  	out.As = CloneTableIdent(n.As)
   393  	out.Hints = CloneRefOfIndexHints(n.Hints)
   394  	out.Columns = CloneColumns(n.Columns)
   395  	return &out
   396  }
   397  
   398  // CloneRefOfAlterCharset creates a deep clone of the input.
   399  func CloneRefOfAlterCharset(n *AlterCharset) *AlterCharset {
   400  	if n == nil {
   401  		return nil
   402  	}
   403  	out := *n
   404  	return &out
   405  }
   406  
   407  // CloneRefOfAlterColumn creates a deep clone of the input.
   408  func CloneRefOfAlterColumn(n *AlterColumn) *AlterColumn {
   409  	if n == nil {
   410  		return nil
   411  	}
   412  	out := *n
   413  	out.Column = CloneRefOfColName(n.Column)
   414  	out.DefaultVal = CloneExpr(n.DefaultVal)
   415  	return &out
   416  }
   417  
   418  // CloneRefOfAlterDatabase creates a deep clone of the input.
   419  func CloneRefOfAlterDatabase(n *AlterDatabase) *AlterDatabase {
   420  	if n == nil {
   421  		return nil
   422  	}
   423  	out := *n
   424  	out.DBName = CloneTableIdent(n.DBName)
   425  	out.AlterOptions = CloneSliceOfCollateAndCharset(n.AlterOptions)
   426  	return &out
   427  }
   428  
   429  // CloneRefOfAlterMigration creates a deep clone of the input.
   430  func CloneRefOfAlterMigration(n *AlterMigration) *AlterMigration {
   431  	if n == nil {
   432  		return nil
   433  	}
   434  	out := *n
   435  	return &out
   436  }
   437  
   438  // CloneRefOfAlterTable creates a deep clone of the input.
   439  func CloneRefOfAlterTable(n *AlterTable) *AlterTable {
   440  	if n == nil {
   441  		return nil
   442  	}
   443  	out := *n
   444  	out.Table = CloneTableName(n.Table)
   445  	out.AlterOptions = CloneSliceOfAlterOption(n.AlterOptions)
   446  	out.PartitionSpec = CloneRefOfPartitionSpec(n.PartitionSpec)
   447  	out.Comments = CloneComments(n.Comments)
   448  	return &out
   449  }
   450  
   451  // CloneRefOfAlterView creates a deep clone of the input.
   452  func CloneRefOfAlterView(n *AlterView) *AlterView {
   453  	if n == nil {
   454  		return nil
   455  	}
   456  	out := *n
   457  	out.ViewName = CloneTableName(n.ViewName)
   458  	out.Columns = CloneColumns(n.Columns)
   459  	out.Select = CloneSelectStatement(n.Select)
   460  	return &out
   461  }
   462  
   463  // CloneRefOfAlterVschema creates a deep clone of the input.
   464  func CloneRefOfAlterVschema(n *AlterVschema) *AlterVschema {
   465  	if n == nil {
   466  		return nil
   467  	}
   468  	out := *n
   469  	out.Table = CloneTableName(n.Table)
   470  	out.VindexSpec = CloneRefOfVindexSpec(n.VindexSpec)
   471  	out.VindexCols = CloneSliceOfColIdent(n.VindexCols)
   472  	out.AutoIncSpec = CloneRefOfAutoIncSpec(n.AutoIncSpec)
   473  	return &out
   474  }
   475  
   476  // CloneRefOfAndExpr creates a deep clone of the input.
   477  func CloneRefOfAndExpr(n *AndExpr) *AndExpr {
   478  	if n == nil {
   479  		return nil
   480  	}
   481  	out := *n
   482  	out.Left = CloneExpr(n.Left)
   483  	out.Right = CloneExpr(n.Right)
   484  	return &out
   485  }
   486  
   487  // CloneRefOfAutoIncSpec creates a deep clone of the input.
   488  func CloneRefOfAutoIncSpec(n *AutoIncSpec) *AutoIncSpec {
   489  	if n == nil {
   490  		return nil
   491  	}
   492  	out := *n
   493  	out.Column = CloneColIdent(n.Column)
   494  	out.Sequence = CloneTableName(n.Sequence)
   495  	return &out
   496  }
   497  
   498  // CloneRefOfBegin creates a deep clone of the input.
   499  func CloneRefOfBegin(n *Begin) *Begin {
   500  	if n == nil {
   501  		return nil
   502  	}
   503  	out := *n
   504  	return &out
   505  }
   506  
   507  // CloneRefOfBetweenExpr creates a deep clone of the input.
   508  func CloneRefOfBetweenExpr(n *BetweenExpr) *BetweenExpr {
   509  	if n == nil {
   510  		return nil
   511  	}
   512  	out := *n
   513  	out.Left = CloneExpr(n.Left)
   514  	out.From = CloneExpr(n.From)
   515  	out.To = CloneExpr(n.To)
   516  	return &out
   517  }
   518  
   519  // CloneRefOfBinaryExpr creates a deep clone of the input.
   520  func CloneRefOfBinaryExpr(n *BinaryExpr) *BinaryExpr {
   521  	if n == nil {
   522  		return nil
   523  	}
   524  	out := *n
   525  	out.Left = CloneExpr(n.Left)
   526  	out.Right = CloneExpr(n.Right)
   527  	return &out
   528  }
   529  
   530  // CloneRefOfCallProc creates a deep clone of the input.
   531  func CloneRefOfCallProc(n *CallProc) *CallProc {
   532  	if n == nil {
   533  		return nil
   534  	}
   535  	out := *n
   536  	out.Name = CloneTableName(n.Name)
   537  	out.Params = CloneExprs(n.Params)
   538  	return &out
   539  }
   540  
   541  // CloneRefOfCaseExpr creates a deep clone of the input.
   542  func CloneRefOfCaseExpr(n *CaseExpr) *CaseExpr {
   543  	if n == nil {
   544  		return nil
   545  	}
   546  	out := *n
   547  	out.Expr = CloneExpr(n.Expr)
   548  	out.Whens = CloneSliceOfRefOfWhen(n.Whens)
   549  	out.Else = CloneExpr(n.Else)
   550  	return &out
   551  }
   552  
   553  // CloneRefOfChangeColumn creates a deep clone of the input.
   554  func CloneRefOfChangeColumn(n *ChangeColumn) *ChangeColumn {
   555  	if n == nil {
   556  		return nil
   557  	}
   558  	out := *n
   559  	out.OldColumn = CloneRefOfColName(n.OldColumn)
   560  	out.NewColDefinition = CloneRefOfColumnDefinition(n.NewColDefinition)
   561  	out.After = CloneRefOfColName(n.After)
   562  	return &out
   563  }
   564  
   565  // CloneRefOfCheckConstraintDefinition creates a deep clone of the input.
   566  func CloneRefOfCheckConstraintDefinition(n *CheckConstraintDefinition) *CheckConstraintDefinition {
   567  	if n == nil {
   568  		return nil
   569  	}
   570  	out := *n
   571  	out.Expr = CloneExpr(n.Expr)
   572  	return &out
   573  }
   574  
   575  // CloneColIdent creates a deep clone of the input.
   576  func CloneColIdent(n ColIdent) ColIdent {
   577  	return *CloneRefOfColIdent(&n)
   578  }
   579  
   580  // CloneRefOfColName creates a deep clone of the input.
   581  func CloneRefOfColName(n *ColName) *ColName {
   582  	return n
   583  }
   584  
   585  // CloneRefOfCollateExpr creates a deep clone of the input.
   586  func CloneRefOfCollateExpr(n *CollateExpr) *CollateExpr {
   587  	if n == nil {
   588  		return nil
   589  	}
   590  	out := *n
   591  	out.Expr = CloneExpr(n.Expr)
   592  	return &out
   593  }
   594  
   595  // CloneRefOfColumnDefinition creates a deep clone of the input.
   596  func CloneRefOfColumnDefinition(n *ColumnDefinition) *ColumnDefinition {
   597  	if n == nil {
   598  		return nil
   599  	}
   600  	out := *n
   601  	out.Name = CloneColIdent(n.Name)
   602  	out.Type = CloneColumnType(n.Type)
   603  	return &out
   604  }
   605  
   606  // CloneRefOfColumnType creates a deep clone of the input.
   607  func CloneRefOfColumnType(n *ColumnType) *ColumnType {
   608  	if n == nil {
   609  		return nil
   610  	}
   611  	out := *n
   612  	out.Options = CloneRefOfColumnTypeOptions(n.Options)
   613  	out.Length = CloneRefOfLiteral(n.Length)
   614  	out.Scale = CloneRefOfLiteral(n.Scale)
   615  	out.EnumValues = CloneSliceOfString(n.EnumValues)
   616  	return &out
   617  }
   618  
   619  // CloneColumns creates a deep clone of the input.
   620  func CloneColumns(n Columns) Columns {
   621  	if n == nil {
   622  		return nil
   623  	}
   624  	res := make(Columns, 0, len(n))
   625  	for _, x := range n {
   626  		res = append(res, CloneColIdent(x))
   627  	}
   628  	return res
   629  }
   630  
   631  // CloneComments creates a deep clone of the input.
   632  func CloneComments(n Comments) Comments {
   633  	if n == nil {
   634  		return nil
   635  	}
   636  	res := make(Comments, 0, len(n))
   637  	for _, x := range n {
   638  		res = append(res, x)
   639  	}
   640  	return res
   641  }
   642  
   643  // CloneRefOfCommit creates a deep clone of the input.
   644  func CloneRefOfCommit(n *Commit) *Commit {
   645  	if n == nil {
   646  		return nil
   647  	}
   648  	out := *n
   649  	return &out
   650  }
   651  
   652  // CloneRefOfCommonTableExpr creates a deep clone of the input.
   653  func CloneRefOfCommonTableExpr(n *CommonTableExpr) *CommonTableExpr {
   654  	if n == nil {
   655  		return nil
   656  	}
   657  	out := *n
   658  	out.TableID = CloneTableIdent(n.TableID)
   659  	out.Columns = CloneColumns(n.Columns)
   660  	out.Subquery = CloneRefOfSubquery(n.Subquery)
   661  	return &out
   662  }
   663  
   664  // CloneRefOfComparisonExpr creates a deep clone of the input.
   665  func CloneRefOfComparisonExpr(n *ComparisonExpr) *ComparisonExpr {
   666  	if n == nil {
   667  		return nil
   668  	}
   669  	out := *n
   670  	out.Left = CloneExpr(n.Left)
   671  	out.Right = CloneExpr(n.Right)
   672  	out.Escape = CloneExpr(n.Escape)
   673  	return &out
   674  }
   675  
   676  // CloneRefOfConstraintDefinition creates a deep clone of the input.
   677  func CloneRefOfConstraintDefinition(n *ConstraintDefinition) *ConstraintDefinition {
   678  	if n == nil {
   679  		return nil
   680  	}
   681  	out := *n
   682  	out.Name = CloneColIdent(n.Name)
   683  	out.Details = CloneConstraintInfo(n.Details)
   684  	return &out
   685  }
   686  
   687  // CloneRefOfConvertExpr creates a deep clone of the input.
   688  func CloneRefOfConvertExpr(n *ConvertExpr) *ConvertExpr {
   689  	if n == nil {
   690  		return nil
   691  	}
   692  	out := *n
   693  	out.Expr = CloneExpr(n.Expr)
   694  	out.Type = CloneRefOfConvertType(n.Type)
   695  	return &out
   696  }
   697  
   698  // CloneRefOfConvertType creates a deep clone of the input.
   699  func CloneRefOfConvertType(n *ConvertType) *ConvertType {
   700  	if n == nil {
   701  		return nil
   702  	}
   703  	out := *n
   704  	out.Length = CloneRefOfLiteral(n.Length)
   705  	out.Scale = CloneRefOfLiteral(n.Scale)
   706  	return &out
   707  }
   708  
   709  // CloneRefOfConvertUsingExpr creates a deep clone of the input.
   710  func CloneRefOfConvertUsingExpr(n *ConvertUsingExpr) *ConvertUsingExpr {
   711  	if n == nil {
   712  		return nil
   713  	}
   714  	out := *n
   715  	out.Expr = CloneExpr(n.Expr)
   716  	return &out
   717  }
   718  
   719  // CloneRefOfCreateDatabase creates a deep clone of the input.
   720  func CloneRefOfCreateDatabase(n *CreateDatabase) *CreateDatabase {
   721  	if n == nil {
   722  		return nil
   723  	}
   724  	out := *n
   725  	out.Comments = CloneComments(n.Comments)
   726  	out.DBName = CloneTableIdent(n.DBName)
   727  	out.CreateOptions = CloneSliceOfCollateAndCharset(n.CreateOptions)
   728  	return &out
   729  }
   730  
   731  // CloneRefOfCreateTable creates a deep clone of the input.
   732  func CloneRefOfCreateTable(n *CreateTable) *CreateTable {
   733  	if n == nil {
   734  		return nil
   735  	}
   736  	out := *n
   737  	out.Table = CloneTableName(n.Table)
   738  	out.TableSpec = CloneRefOfTableSpec(n.TableSpec)
   739  	out.OptLike = CloneRefOfOptLike(n.OptLike)
   740  	out.Comments = CloneComments(n.Comments)
   741  	return &out
   742  }
   743  
   744  // CloneRefOfCreateView creates a deep clone of the input.
   745  func CloneRefOfCreateView(n *CreateView) *CreateView {
   746  	if n == nil {
   747  		return nil
   748  	}
   749  	out := *n
   750  	out.ViewName = CloneTableName(n.ViewName)
   751  	out.Columns = CloneColumns(n.Columns)
   752  	out.Select = CloneSelectStatement(n.Select)
   753  	return &out
   754  }
   755  
   756  // CloneRefOfCurTimeFuncExpr creates a deep clone of the input.
   757  func CloneRefOfCurTimeFuncExpr(n *CurTimeFuncExpr) *CurTimeFuncExpr {
   758  	if n == nil {
   759  		return nil
   760  	}
   761  	out := *n
   762  	out.Name = CloneColIdent(n.Name)
   763  	out.Fsp = CloneExpr(n.Fsp)
   764  	return &out
   765  }
   766  
   767  // CloneRefOfDefault creates a deep clone of the input.
   768  func CloneRefOfDefault(n *Default) *Default {
   769  	if n == nil {
   770  		return nil
   771  	}
   772  	out := *n
   773  	return &out
   774  }
   775  
   776  // CloneRefOfDelete creates a deep clone of the input.
   777  func CloneRefOfDelete(n *Delete) *Delete {
   778  	if n == nil {
   779  		return nil
   780  	}
   781  	out := *n
   782  	out.With = CloneRefOfWith(n.With)
   783  	out.Comments = CloneComments(n.Comments)
   784  	out.Targets = CloneTableNames(n.Targets)
   785  	out.TableExprs = CloneTableExprs(n.TableExprs)
   786  	out.Partitions = ClonePartitions(n.Partitions)
   787  	out.Where = CloneRefOfWhere(n.Where)
   788  	out.OrderBy = CloneOrderBy(n.OrderBy)
   789  	out.Limit = CloneRefOfLimit(n.Limit)
   790  	return &out
   791  }
   792  
   793  // CloneRefOfDerivedTable creates a deep clone of the input.
   794  func CloneRefOfDerivedTable(n *DerivedTable) *DerivedTable {
   795  	if n == nil {
   796  		return nil
   797  	}
   798  	out := *n
   799  	out.Select = CloneSelectStatement(n.Select)
   800  	return &out
   801  }
   802  
   803  // CloneRefOfDropColumn creates a deep clone of the input.
   804  func CloneRefOfDropColumn(n *DropColumn) *DropColumn {
   805  	if n == nil {
   806  		return nil
   807  	}
   808  	out := *n
   809  	out.Name = CloneRefOfColName(n.Name)
   810  	return &out
   811  }
   812  
   813  // CloneRefOfDropDatabase creates a deep clone of the input.
   814  func CloneRefOfDropDatabase(n *DropDatabase) *DropDatabase {
   815  	if n == nil {
   816  		return nil
   817  	}
   818  	out := *n
   819  	out.Comments = CloneComments(n.Comments)
   820  	out.DBName = CloneTableIdent(n.DBName)
   821  	return &out
   822  }
   823  
   824  // CloneRefOfDropKey creates a deep clone of the input.
   825  func CloneRefOfDropKey(n *DropKey) *DropKey {
   826  	if n == nil {
   827  		return nil
   828  	}
   829  	out := *n
   830  	out.Name = CloneColIdent(n.Name)
   831  	return &out
   832  }
   833  
   834  // CloneRefOfDropTable creates a deep clone of the input.
   835  func CloneRefOfDropTable(n *DropTable) *DropTable {
   836  	if n == nil {
   837  		return nil
   838  	}
   839  	out := *n
   840  	out.FromTables = CloneTableNames(n.FromTables)
   841  	out.Comments = CloneComments(n.Comments)
   842  	return &out
   843  }
   844  
   845  // CloneRefOfDropView creates a deep clone of the input.
   846  func CloneRefOfDropView(n *DropView) *DropView {
   847  	if n == nil {
   848  		return nil
   849  	}
   850  	out := *n
   851  	out.FromTables = CloneTableNames(n.FromTables)
   852  	return &out
   853  }
   854  
   855  // CloneRefOfExistsExpr creates a deep clone of the input.
   856  func CloneRefOfExistsExpr(n *ExistsExpr) *ExistsExpr {
   857  	if n == nil {
   858  		return nil
   859  	}
   860  	out := *n
   861  	out.Subquery = CloneRefOfSubquery(n.Subquery)
   862  	return &out
   863  }
   864  
   865  // CloneRefOfExplainStmt creates a deep clone of the input.
   866  func CloneRefOfExplainStmt(n *ExplainStmt) *ExplainStmt {
   867  	if n == nil {
   868  		return nil
   869  	}
   870  	out := *n
   871  	out.Statement = CloneStatement(n.Statement)
   872  	return &out
   873  }
   874  
   875  // CloneRefOfExplainTab creates a deep clone of the input.
   876  func CloneRefOfExplainTab(n *ExplainTab) *ExplainTab {
   877  	if n == nil {
   878  		return nil
   879  	}
   880  	out := *n
   881  	out.Table = CloneTableName(n.Table)
   882  	return &out
   883  }
   884  
   885  // CloneRefOfExprOrColumns creates a deep clone of the input.
   886  func CloneRefOfExprOrColumns(n *ExprOrColumns) *ExprOrColumns {
   887  	if n == nil {
   888  		return nil
   889  	}
   890  	out := *n
   891  	out.Expr = CloneExpr(n.Expr)
   892  	out.ColumnList = CloneColumns(n.ColumnList)
   893  	return &out
   894  }
   895  
   896  // CloneExprs creates a deep clone of the input.
   897  func CloneExprs(n Exprs) Exprs {
   898  	if n == nil {
   899  		return nil
   900  	}
   901  	res := make(Exprs, 0, len(n))
   902  	for _, x := range n {
   903  		res = append(res, CloneExpr(x))
   904  	}
   905  	return res
   906  }
   907  
   908  // CloneRefOfExtractFuncExpr creates a deep clone of the input.
   909  func CloneRefOfExtractFuncExpr(n *ExtractFuncExpr) *ExtractFuncExpr {
   910  	if n == nil {
   911  		return nil
   912  	}
   913  	out := *n
   914  	out.Expr = CloneExpr(n.Expr)
   915  	return &out
   916  }
   917  
   918  // CloneRefOfExtractedSubquery creates a deep clone of the input.
   919  func CloneRefOfExtractedSubquery(n *ExtractedSubquery) *ExtractedSubquery {
   920  	if n == nil {
   921  		return nil
   922  	}
   923  	out := *n
   924  	out.Original = CloneExpr(n.Original)
   925  	out.Subquery = CloneRefOfSubquery(n.Subquery)
   926  	out.OtherSide = CloneExpr(n.OtherSide)
   927  	out.alternative = CloneExpr(n.alternative)
   928  	return &out
   929  }
   930  
   931  // CloneRefOfFlush creates a deep clone of the input.
   932  func CloneRefOfFlush(n *Flush) *Flush {
   933  	if n == nil {
   934  		return nil
   935  	}
   936  	out := *n
   937  	out.FlushOptions = CloneSliceOfString(n.FlushOptions)
   938  	out.TableNames = CloneTableNames(n.TableNames)
   939  	return &out
   940  }
   941  
   942  // CloneRefOfForce creates a deep clone of the input.
   943  func CloneRefOfForce(n *Force) *Force {
   944  	if n == nil {
   945  		return nil
   946  	}
   947  	out := *n
   948  	return &out
   949  }
   950  
   951  // CloneRefOfForeignKeyDefinition creates a deep clone of the input.
   952  func CloneRefOfForeignKeyDefinition(n *ForeignKeyDefinition) *ForeignKeyDefinition {
   953  	if n == nil {
   954  		return nil
   955  	}
   956  	out := *n
   957  	out.Source = CloneColumns(n.Source)
   958  	out.IndexName = CloneColIdent(n.IndexName)
   959  	out.ReferenceDefinition = CloneRefOfReferenceDefinition(n.ReferenceDefinition)
   960  	return &out
   961  }
   962  
   963  // CloneRefOfFuncExpr creates a deep clone of the input.
   964  func CloneRefOfFuncExpr(n *FuncExpr) *FuncExpr {
   965  	if n == nil {
   966  		return nil
   967  	}
   968  	out := *n
   969  	out.Qualifier = CloneTableIdent(n.Qualifier)
   970  	out.Name = CloneColIdent(n.Name)
   971  	out.Exprs = CloneSelectExprs(n.Exprs)
   972  	return &out
   973  }
   974  
   975  // CloneGroupBy creates a deep clone of the input.
   976  func CloneGroupBy(n GroupBy) GroupBy {
   977  	if n == nil {
   978  		return nil
   979  	}
   980  	res := make(GroupBy, 0, len(n))
   981  	for _, x := range n {
   982  		res = append(res, CloneExpr(x))
   983  	}
   984  	return res
   985  }
   986  
   987  // CloneRefOfGroupConcatExpr creates a deep clone of the input.
   988  func CloneRefOfGroupConcatExpr(n *GroupConcatExpr) *GroupConcatExpr {
   989  	if n == nil {
   990  		return nil
   991  	}
   992  	out := *n
   993  	out.Exprs = CloneSelectExprs(n.Exprs)
   994  	out.OrderBy = CloneOrderBy(n.OrderBy)
   995  	out.Limit = CloneRefOfLimit(n.Limit)
   996  	return &out
   997  }
   998  
   999  // CloneRefOfIndexDefinition creates a deep clone of the input.
  1000  func CloneRefOfIndexDefinition(n *IndexDefinition) *IndexDefinition {
  1001  	if n == nil {
  1002  		return nil
  1003  	}
  1004  	out := *n
  1005  	out.Info = CloneRefOfIndexInfo(n.Info)
  1006  	out.Columns = CloneSliceOfRefOfIndexColumn(n.Columns)
  1007  	out.Options = CloneSliceOfRefOfIndexOption(n.Options)
  1008  	return &out
  1009  }
  1010  
  1011  // CloneRefOfIndexHints creates a deep clone of the input.
  1012  func CloneRefOfIndexHints(n *IndexHints) *IndexHints {
  1013  	if n == nil {
  1014  		return nil
  1015  	}
  1016  	out := *n
  1017  	out.Indexes = CloneSliceOfColIdent(n.Indexes)
  1018  	return &out
  1019  }
  1020  
  1021  // CloneRefOfIndexInfo creates a deep clone of the input.
  1022  func CloneRefOfIndexInfo(n *IndexInfo) *IndexInfo {
  1023  	if n == nil {
  1024  		return nil
  1025  	}
  1026  	out := *n
  1027  	out.Name = CloneColIdent(n.Name)
  1028  	out.ConstraintName = CloneColIdent(n.ConstraintName)
  1029  	return &out
  1030  }
  1031  
  1032  // CloneRefOfInsert creates a deep clone of the input.
  1033  func CloneRefOfInsert(n *Insert) *Insert {
  1034  	if n == nil {
  1035  		return nil
  1036  	}
  1037  	out := *n
  1038  	out.Comments = CloneComments(n.Comments)
  1039  	out.Table = CloneTableName(n.Table)
  1040  	out.Partitions = ClonePartitions(n.Partitions)
  1041  	out.Columns = CloneColumns(n.Columns)
  1042  	out.Rows = CloneInsertRows(n.Rows)
  1043  	out.OnDup = CloneOnDup(n.OnDup)
  1044  	return &out
  1045  }
  1046  
  1047  // CloneRefOfIntervalExpr creates a deep clone of the input.
  1048  func CloneRefOfIntervalExpr(n *IntervalExpr) *IntervalExpr {
  1049  	if n == nil {
  1050  		return nil
  1051  	}
  1052  	out := *n
  1053  	out.Expr = CloneExpr(n.Expr)
  1054  	return &out
  1055  }
  1056  
  1057  // CloneRefOfIntroducerExpr creates a deep clone of the input.
  1058  func CloneRefOfIntroducerExpr(n *IntroducerExpr) *IntroducerExpr {
  1059  	if n == nil {
  1060  		return nil
  1061  	}
  1062  	out := *n
  1063  	out.Expr = CloneExpr(n.Expr)
  1064  	return &out
  1065  }
  1066  
  1067  // CloneRefOfIsExpr creates a deep clone of the input.
  1068  func CloneRefOfIsExpr(n *IsExpr) *IsExpr {
  1069  	if n == nil {
  1070  		return nil
  1071  	}
  1072  	out := *n
  1073  	out.Left = CloneExpr(n.Left)
  1074  	return &out
  1075  }
  1076  
  1077  // CloneRefOfJoinCondition creates a deep clone of the input.
  1078  func CloneRefOfJoinCondition(n *JoinCondition) *JoinCondition {
  1079  	if n == nil {
  1080  		return nil
  1081  	}
  1082  	out := *n
  1083  	out.On = CloneExpr(n.On)
  1084  	out.Using = CloneColumns(n.Using)
  1085  	return &out
  1086  }
  1087  
  1088  // CloneRefOfJoinTableExpr creates a deep clone of the input.
  1089  func CloneRefOfJoinTableExpr(n *JoinTableExpr) *JoinTableExpr {
  1090  	if n == nil {
  1091  		return nil
  1092  	}
  1093  	out := *n
  1094  	out.LeftExpr = CloneTableExpr(n.LeftExpr)
  1095  	out.RightExpr = CloneTableExpr(n.RightExpr)
  1096  	out.Condition = CloneRefOfJoinCondition(n.Condition)
  1097  	return &out
  1098  }
  1099  
  1100  // CloneRefOfKeyState creates a deep clone of the input.
  1101  func CloneRefOfKeyState(n *KeyState) *KeyState {
  1102  	if n == nil {
  1103  		return nil
  1104  	}
  1105  	out := *n
  1106  	return &out
  1107  }
  1108  
  1109  // CloneRefOfLimit creates a deep clone of the input.
  1110  func CloneRefOfLimit(n *Limit) *Limit {
  1111  	if n == nil {
  1112  		return nil
  1113  	}
  1114  	out := *n
  1115  	out.Offset = CloneExpr(n.Offset)
  1116  	out.Rowcount = CloneExpr(n.Rowcount)
  1117  	return &out
  1118  }
  1119  
  1120  // CloneRefOfLiteral creates a deep clone of the input.
  1121  func CloneRefOfLiteral(n *Literal) *Literal {
  1122  	if n == nil {
  1123  		return nil
  1124  	}
  1125  	out := *n
  1126  	return &out
  1127  }
  1128  
  1129  // CloneRefOfLoad creates a deep clone of the input.
  1130  func CloneRefOfLoad(n *Load) *Load {
  1131  	if n == nil {
  1132  		return nil
  1133  	}
  1134  	out := *n
  1135  	return &out
  1136  }
  1137  
  1138  // CloneRefOfLockOption creates a deep clone of the input.
  1139  func CloneRefOfLockOption(n *LockOption) *LockOption {
  1140  	if n == nil {
  1141  		return nil
  1142  	}
  1143  	out := *n
  1144  	return &out
  1145  }
  1146  
  1147  // CloneRefOfLockTables creates a deep clone of the input.
  1148  func CloneRefOfLockTables(n *LockTables) *LockTables {
  1149  	if n == nil {
  1150  		return nil
  1151  	}
  1152  	out := *n
  1153  	out.Tables = CloneTableAndLockTypes(n.Tables)
  1154  	return &out
  1155  }
  1156  
  1157  // CloneRefOfMatchExpr creates a deep clone of the input.
  1158  func CloneRefOfMatchExpr(n *MatchExpr) *MatchExpr {
  1159  	if n == nil {
  1160  		return nil
  1161  	}
  1162  	out := *n
  1163  	out.Columns = CloneSelectExprs(n.Columns)
  1164  	out.Expr = CloneExpr(n.Expr)
  1165  	return &out
  1166  }
  1167  
  1168  // CloneRefOfModifyColumn creates a deep clone of the input.
  1169  func CloneRefOfModifyColumn(n *ModifyColumn) *ModifyColumn {
  1170  	if n == nil {
  1171  		return nil
  1172  	}
  1173  	out := *n
  1174  	out.NewColDefinition = CloneRefOfColumnDefinition(n.NewColDefinition)
  1175  	out.After = CloneRefOfColName(n.After)
  1176  	return &out
  1177  }
  1178  
  1179  // CloneRefOfNextval creates a deep clone of the input.
  1180  func CloneRefOfNextval(n *Nextval) *Nextval {
  1181  	if n == nil {
  1182  		return nil
  1183  	}
  1184  	out := *n
  1185  	out.Expr = CloneExpr(n.Expr)
  1186  	return &out
  1187  }
  1188  
  1189  // CloneRefOfNotExpr creates a deep clone of the input.
  1190  func CloneRefOfNotExpr(n *NotExpr) *NotExpr {
  1191  	if n == nil {
  1192  		return nil
  1193  	}
  1194  	out := *n
  1195  	out.Expr = CloneExpr(n.Expr)
  1196  	return &out
  1197  }
  1198  
  1199  // CloneRefOfNullVal creates a deep clone of the input.
  1200  func CloneRefOfNullVal(n *NullVal) *NullVal {
  1201  	if n == nil {
  1202  		return nil
  1203  	}
  1204  	out := *n
  1205  	return &out
  1206  }
  1207  
  1208  // CloneOnDup creates a deep clone of the input.
  1209  func CloneOnDup(n OnDup) OnDup {
  1210  	if n == nil {
  1211  		return nil
  1212  	}
  1213  	res := make(OnDup, 0, len(n))
  1214  	for _, x := range n {
  1215  		res = append(res, CloneRefOfUpdateExpr(x))
  1216  	}
  1217  	return res
  1218  }
  1219  
  1220  // CloneRefOfOptLike creates a deep clone of the input.
  1221  func CloneRefOfOptLike(n *OptLike) *OptLike {
  1222  	if n == nil {
  1223  		return nil
  1224  	}
  1225  	out := *n
  1226  	out.LikeTable = CloneTableName(n.LikeTable)
  1227  	return &out
  1228  }
  1229  
  1230  // CloneRefOfOrExpr creates a deep clone of the input.
  1231  func CloneRefOfOrExpr(n *OrExpr) *OrExpr {
  1232  	if n == nil {
  1233  		return nil
  1234  	}
  1235  	out := *n
  1236  	out.Left = CloneExpr(n.Left)
  1237  	out.Right = CloneExpr(n.Right)
  1238  	return &out
  1239  }
  1240  
  1241  // CloneRefOfOrder creates a deep clone of the input.
  1242  func CloneRefOfOrder(n *Order) *Order {
  1243  	if n == nil {
  1244  		return nil
  1245  	}
  1246  	out := *n
  1247  	out.Expr = CloneExpr(n.Expr)
  1248  	return &out
  1249  }
  1250  
  1251  // CloneOrderBy creates a deep clone of the input.
  1252  func CloneOrderBy(n OrderBy) OrderBy {
  1253  	if n == nil {
  1254  		return nil
  1255  	}
  1256  	res := make(OrderBy, 0, len(n))
  1257  	for _, x := range n {
  1258  		res = append(res, CloneRefOfOrder(x))
  1259  	}
  1260  	return res
  1261  }
  1262  
  1263  // CloneRefOfOrderByOption creates a deep clone of the input.
  1264  func CloneRefOfOrderByOption(n *OrderByOption) *OrderByOption {
  1265  	if n == nil {
  1266  		return nil
  1267  	}
  1268  	out := *n
  1269  	out.Cols = CloneColumns(n.Cols)
  1270  	return &out
  1271  }
  1272  
  1273  // CloneRefOfOtherAdmin creates a deep clone of the input.
  1274  func CloneRefOfOtherAdmin(n *OtherAdmin) *OtherAdmin {
  1275  	if n == nil {
  1276  		return nil
  1277  	}
  1278  	out := *n
  1279  	return &out
  1280  }
  1281  
  1282  // CloneRefOfOtherRead creates a deep clone of the input.
  1283  func CloneRefOfOtherRead(n *OtherRead) *OtherRead {
  1284  	if n == nil {
  1285  		return nil
  1286  	}
  1287  	out := *n
  1288  	return &out
  1289  }
  1290  
  1291  // CloneRefOfParenTableExpr creates a deep clone of the input.
  1292  func CloneRefOfParenTableExpr(n *ParenTableExpr) *ParenTableExpr {
  1293  	if n == nil {
  1294  		return nil
  1295  	}
  1296  	out := *n
  1297  	out.Exprs = CloneTableExprs(n.Exprs)
  1298  	return &out
  1299  }
  1300  
  1301  // CloneRefOfPartitionDefinition creates a deep clone of the input.
  1302  func CloneRefOfPartitionDefinition(n *PartitionDefinition) *PartitionDefinition {
  1303  	if n == nil {
  1304  		return nil
  1305  	}
  1306  	out := *n
  1307  	out.Name = CloneColIdent(n.Name)
  1308  	out.Limit = CloneExpr(n.Limit)
  1309  	return &out
  1310  }
  1311  
  1312  // CloneRefOfPartitionOption creates a deep clone of the input.
  1313  func CloneRefOfPartitionOption(n *PartitionOption) *PartitionOption {
  1314  	if n == nil {
  1315  		return nil
  1316  	}
  1317  	out := *n
  1318  	out.KeyColList = CloneColumns(n.KeyColList)
  1319  	out.ExprOrCol = CloneRefOfExprOrColumns(n.ExprOrCol)
  1320  	out.Expr = CloneExpr(n.Expr)
  1321  	out.SubPartition = CloneRefOfSubPartition(n.SubPartition)
  1322  	out.Definitions = CloneSliceOfRefOfPartitionDefinition(n.Definitions)
  1323  	return &out
  1324  }
  1325  
  1326  // CloneRefOfPartitionSpec creates a deep clone of the input.
  1327  func CloneRefOfPartitionSpec(n *PartitionSpec) *PartitionSpec {
  1328  	if n == nil {
  1329  		return nil
  1330  	}
  1331  	out := *n
  1332  	out.Names = ClonePartitions(n.Names)
  1333  	out.Number = CloneRefOfLiteral(n.Number)
  1334  	out.TableName = CloneTableName(n.TableName)
  1335  	out.Definitions = CloneSliceOfRefOfPartitionDefinition(n.Definitions)
  1336  	return &out
  1337  }
  1338  
  1339  // ClonePartitions creates a deep clone of the input.
  1340  func ClonePartitions(n Partitions) Partitions {
  1341  	if n == nil {
  1342  		return nil
  1343  	}
  1344  	res := make(Partitions, 0, len(n))
  1345  	for _, x := range n {
  1346  		res = append(res, CloneColIdent(x))
  1347  	}
  1348  	return res
  1349  }
  1350  
  1351  // CloneRefOfReferenceDefinition creates a deep clone of the input.
  1352  func CloneRefOfReferenceDefinition(n *ReferenceDefinition) *ReferenceDefinition {
  1353  	if n == nil {
  1354  		return nil
  1355  	}
  1356  	out := *n
  1357  	out.ReferencedTable = CloneTableName(n.ReferencedTable)
  1358  	out.ReferencedColumns = CloneColumns(n.ReferencedColumns)
  1359  	return &out
  1360  }
  1361  
  1362  // CloneRefOfRelease creates a deep clone of the input.
  1363  func CloneRefOfRelease(n *Release) *Release {
  1364  	if n == nil {
  1365  		return nil
  1366  	}
  1367  	out := *n
  1368  	out.Name = CloneColIdent(n.Name)
  1369  	return &out
  1370  }
  1371  
  1372  // CloneRefOfRenameIndex creates a deep clone of the input.
  1373  func CloneRefOfRenameIndex(n *RenameIndex) *RenameIndex {
  1374  	if n == nil {
  1375  		return nil
  1376  	}
  1377  	out := *n
  1378  	out.OldName = CloneColIdent(n.OldName)
  1379  	out.NewName = CloneColIdent(n.NewName)
  1380  	return &out
  1381  }
  1382  
  1383  // CloneRefOfRenameTable creates a deep clone of the input.
  1384  func CloneRefOfRenameTable(n *RenameTable) *RenameTable {
  1385  	if n == nil {
  1386  		return nil
  1387  	}
  1388  	out := *n
  1389  	out.TablePairs = CloneSliceOfRefOfRenameTablePair(n.TablePairs)
  1390  	return &out
  1391  }
  1392  
  1393  // CloneRefOfRenameTableName creates a deep clone of the input.
  1394  func CloneRefOfRenameTableName(n *RenameTableName) *RenameTableName {
  1395  	if n == nil {
  1396  		return nil
  1397  	}
  1398  	out := *n
  1399  	out.Table = CloneTableName(n.Table)
  1400  	return &out
  1401  }
  1402  
  1403  // CloneRefOfRevertMigration creates a deep clone of the input.
  1404  func CloneRefOfRevertMigration(n *RevertMigration) *RevertMigration {
  1405  	if n == nil {
  1406  		return nil
  1407  	}
  1408  	out := *n
  1409  	out.Comments = CloneComments(n.Comments)
  1410  	return &out
  1411  }
  1412  
  1413  // CloneRefOfRollback creates a deep clone of the input.
  1414  func CloneRefOfRollback(n *Rollback) *Rollback {
  1415  	if n == nil {
  1416  		return nil
  1417  	}
  1418  	out := *n
  1419  	return &out
  1420  }
  1421  
  1422  // CloneRootNode creates a deep clone of the input.
  1423  func CloneRootNode(n RootNode) RootNode {
  1424  	return *CloneRefOfRootNode(&n)
  1425  }
  1426  
  1427  // CloneRefOfSRollback creates a deep clone of the input.
  1428  func CloneRefOfSRollback(n *SRollback) *SRollback {
  1429  	if n == nil {
  1430  		return nil
  1431  	}
  1432  	out := *n
  1433  	out.Name = CloneColIdent(n.Name)
  1434  	return &out
  1435  }
  1436  
  1437  // CloneRefOfSavepoint creates a deep clone of the input.
  1438  func CloneRefOfSavepoint(n *Savepoint) *Savepoint {
  1439  	if n == nil {
  1440  		return nil
  1441  	}
  1442  	out := *n
  1443  	out.Name = CloneColIdent(n.Name)
  1444  	return &out
  1445  }
  1446  
  1447  // CloneRefOfSelect creates a deep clone of the input.
  1448  func CloneRefOfSelect(n *Select) *Select {
  1449  	if n == nil {
  1450  		return nil
  1451  	}
  1452  	out := *n
  1453  	out.Cache = CloneRefOfBool(n.Cache)
  1454  	out.From = CloneSliceOfTableExpr(n.From)
  1455  	out.Comments = CloneComments(n.Comments)
  1456  	out.SelectExprs = CloneSelectExprs(n.SelectExprs)
  1457  	out.Where = CloneRefOfWhere(n.Where)
  1458  	out.With = CloneRefOfWith(n.With)
  1459  	out.GroupBy = CloneGroupBy(n.GroupBy)
  1460  	out.Having = CloneRefOfWhere(n.Having)
  1461  	out.OrderBy = CloneOrderBy(n.OrderBy)
  1462  	out.Limit = CloneRefOfLimit(n.Limit)
  1463  	out.Into = CloneRefOfSelectInto(n.Into)
  1464  	return &out
  1465  }
  1466  
  1467  // CloneSelectExprs creates a deep clone of the input.
  1468  func CloneSelectExprs(n SelectExprs) SelectExprs {
  1469  	if n == nil {
  1470  		return nil
  1471  	}
  1472  	res := make(SelectExprs, 0, len(n))
  1473  	for _, x := range n {
  1474  		res = append(res, CloneSelectExpr(x))
  1475  	}
  1476  	return res
  1477  }
  1478  
  1479  // CloneRefOfSelectInto creates a deep clone of the input.
  1480  func CloneRefOfSelectInto(n *SelectInto) *SelectInto {
  1481  	if n == nil {
  1482  		return nil
  1483  	}
  1484  	out := *n
  1485  	return &out
  1486  }
  1487  
  1488  // CloneRefOfSet creates a deep clone of the input.
  1489  func CloneRefOfSet(n *Set) *Set {
  1490  	if n == nil {
  1491  		return nil
  1492  	}
  1493  	out := *n
  1494  	out.Comments = CloneComments(n.Comments)
  1495  	out.Exprs = CloneSetExprs(n.Exprs)
  1496  	return &out
  1497  }
  1498  
  1499  // CloneRefOfSetExpr creates a deep clone of the input.
  1500  func CloneRefOfSetExpr(n *SetExpr) *SetExpr {
  1501  	if n == nil {
  1502  		return nil
  1503  	}
  1504  	out := *n
  1505  	out.Name = CloneColIdent(n.Name)
  1506  	out.Expr = CloneExpr(n.Expr)
  1507  	return &out
  1508  }
  1509  
  1510  // CloneSetExprs creates a deep clone of the input.
  1511  func CloneSetExprs(n SetExprs) SetExprs {
  1512  	if n == nil {
  1513  		return nil
  1514  	}
  1515  	res := make(SetExprs, 0, len(n))
  1516  	for _, x := range n {
  1517  		res = append(res, CloneRefOfSetExpr(x))
  1518  	}
  1519  	return res
  1520  }
  1521  
  1522  // CloneRefOfSetTransaction creates a deep clone of the input.
  1523  func CloneRefOfSetTransaction(n *SetTransaction) *SetTransaction {
  1524  	if n == nil {
  1525  		return nil
  1526  	}
  1527  	out := *n
  1528  	out.SQLNode = CloneSQLNode(n.SQLNode)
  1529  	out.Comments = CloneComments(n.Comments)
  1530  	out.Characteristics = CloneSliceOfCharacteristic(n.Characteristics)
  1531  	return &out
  1532  }
  1533  
  1534  // CloneRefOfShow creates a deep clone of the input.
  1535  func CloneRefOfShow(n *Show) *Show {
  1536  	if n == nil {
  1537  		return nil
  1538  	}
  1539  	out := *n
  1540  	out.Internal = CloneShowInternal(n.Internal)
  1541  	return &out
  1542  }
  1543  
  1544  // CloneRefOfShowBasic creates a deep clone of the input.
  1545  func CloneRefOfShowBasic(n *ShowBasic) *ShowBasic {
  1546  	if n == nil {
  1547  		return nil
  1548  	}
  1549  	out := *n
  1550  	out.Tbl = CloneTableName(n.Tbl)
  1551  	out.DbName = CloneTableIdent(n.DbName)
  1552  	out.Filter = CloneRefOfShowFilter(n.Filter)
  1553  	return &out
  1554  }
  1555  
  1556  // CloneRefOfShowCreate creates a deep clone of the input.
  1557  func CloneRefOfShowCreate(n *ShowCreate) *ShowCreate {
  1558  	if n == nil {
  1559  		return nil
  1560  	}
  1561  	out := *n
  1562  	out.Op = CloneTableName(n.Op)
  1563  	return &out
  1564  }
  1565  
  1566  // CloneRefOfShowFilter creates a deep clone of the input.
  1567  func CloneRefOfShowFilter(n *ShowFilter) *ShowFilter {
  1568  	if n == nil {
  1569  		return nil
  1570  	}
  1571  	out := *n
  1572  	out.Filter = CloneExpr(n.Filter)
  1573  	return &out
  1574  }
  1575  
  1576  // CloneRefOfShowLegacy creates a deep clone of the input.
  1577  func CloneRefOfShowLegacy(n *ShowLegacy) *ShowLegacy {
  1578  	if n == nil {
  1579  		return nil
  1580  	}
  1581  	out := *n
  1582  	out.OnTable = CloneTableName(n.OnTable)
  1583  	out.Table = CloneTableName(n.Table)
  1584  	out.ShowTablesOpt = CloneRefOfShowTablesOpt(n.ShowTablesOpt)
  1585  	out.ShowCollationFilterOpt = CloneExpr(n.ShowCollationFilterOpt)
  1586  	return &out
  1587  }
  1588  
  1589  // CloneRefOfShowMigrationLogs creates a deep clone of the input.
  1590  func CloneRefOfShowMigrationLogs(n *ShowMigrationLogs) *ShowMigrationLogs {
  1591  	if n == nil {
  1592  		return nil
  1593  	}
  1594  	out := *n
  1595  	out.Comments = CloneComments(n.Comments)
  1596  	return &out
  1597  }
  1598  
  1599  // CloneRefOfStarExpr creates a deep clone of the input.
  1600  func CloneRefOfStarExpr(n *StarExpr) *StarExpr {
  1601  	if n == nil {
  1602  		return nil
  1603  	}
  1604  	out := *n
  1605  	out.TableName = CloneTableName(n.TableName)
  1606  	return &out
  1607  }
  1608  
  1609  // CloneRefOfStream creates a deep clone of the input.
  1610  func CloneRefOfStream(n *Stream) *Stream {
  1611  	if n == nil {
  1612  		return nil
  1613  	}
  1614  	out := *n
  1615  	out.Comments = CloneComments(n.Comments)
  1616  	out.SelectExpr = CloneSelectExpr(n.SelectExpr)
  1617  	out.Table = CloneTableName(n.Table)
  1618  	return &out
  1619  }
  1620  
  1621  // CloneRefOfSubPartition creates a deep clone of the input.
  1622  func CloneRefOfSubPartition(n *SubPartition) *SubPartition {
  1623  	if n == nil {
  1624  		return nil
  1625  	}
  1626  	out := *n
  1627  	out.KeyColList = CloneColumns(n.KeyColList)
  1628  	out.Expr = CloneExpr(n.Expr)
  1629  	return &out
  1630  }
  1631  
  1632  // CloneRefOfSubquery creates a deep clone of the input.
  1633  func CloneRefOfSubquery(n *Subquery) *Subquery {
  1634  	if n == nil {
  1635  		return nil
  1636  	}
  1637  	out := *n
  1638  	out.Select = CloneSelectStatement(n.Select)
  1639  	return &out
  1640  }
  1641  
  1642  // CloneRefOfSubstrExpr creates a deep clone of the input.
  1643  func CloneRefOfSubstrExpr(n *SubstrExpr) *SubstrExpr {
  1644  	if n == nil {
  1645  		return nil
  1646  	}
  1647  	out := *n
  1648  	out.Name = CloneExpr(n.Name)
  1649  	out.From = CloneExpr(n.From)
  1650  	out.To = CloneExpr(n.To)
  1651  	return &out
  1652  }
  1653  
  1654  // CloneTableExprs creates a deep clone of the input.
  1655  func CloneTableExprs(n TableExprs) TableExprs {
  1656  	if n == nil {
  1657  		return nil
  1658  	}
  1659  	res := make(TableExprs, 0, len(n))
  1660  	for _, x := range n {
  1661  		res = append(res, CloneTableExpr(x))
  1662  	}
  1663  	return res
  1664  }
  1665  
  1666  // CloneTableIdent creates a deep clone of the input.
  1667  func CloneTableIdent(n TableIdent) TableIdent {
  1668  	return *CloneRefOfTableIdent(&n)
  1669  }
  1670  
  1671  // CloneTableName creates a deep clone of the input.
  1672  func CloneTableName(n TableName) TableName {
  1673  	return *CloneRefOfTableName(&n)
  1674  }
  1675  
  1676  // CloneTableNames creates a deep clone of the input.
  1677  func CloneTableNames(n TableNames) TableNames {
  1678  	if n == nil {
  1679  		return nil
  1680  	}
  1681  	res := make(TableNames, 0, len(n))
  1682  	for _, x := range n {
  1683  		res = append(res, CloneTableName(x))
  1684  	}
  1685  	return res
  1686  }
  1687  
  1688  // CloneTableOptions creates a deep clone of the input.
  1689  func CloneTableOptions(n TableOptions) TableOptions {
  1690  	if n == nil {
  1691  		return nil
  1692  	}
  1693  	res := make(TableOptions, 0, len(n))
  1694  	for _, x := range n {
  1695  		res = append(res, CloneRefOfTableOption(x))
  1696  	}
  1697  	return res
  1698  }
  1699  
  1700  // CloneRefOfTableSpec creates a deep clone of the input.
  1701  func CloneRefOfTableSpec(n *TableSpec) *TableSpec {
  1702  	if n == nil {
  1703  		return nil
  1704  	}
  1705  	out := *n
  1706  	out.Columns = CloneSliceOfRefOfColumnDefinition(n.Columns)
  1707  	out.Indexes = CloneSliceOfRefOfIndexDefinition(n.Indexes)
  1708  	out.Constraints = CloneSliceOfRefOfConstraintDefinition(n.Constraints)
  1709  	out.Options = CloneTableOptions(n.Options)
  1710  	out.PartitionOption = CloneRefOfPartitionOption(n.PartitionOption)
  1711  	return &out
  1712  }
  1713  
  1714  // CloneRefOfTablespaceOperation creates a deep clone of the input.
  1715  func CloneRefOfTablespaceOperation(n *TablespaceOperation) *TablespaceOperation {
  1716  	if n == nil {
  1717  		return nil
  1718  	}
  1719  	out := *n
  1720  	return &out
  1721  }
  1722  
  1723  // CloneRefOfTimestampFuncExpr creates a deep clone of the input.
  1724  func CloneRefOfTimestampFuncExpr(n *TimestampFuncExpr) *TimestampFuncExpr {
  1725  	if n == nil {
  1726  		return nil
  1727  	}
  1728  	out := *n
  1729  	out.Expr1 = CloneExpr(n.Expr1)
  1730  	out.Expr2 = CloneExpr(n.Expr2)
  1731  	return &out
  1732  }
  1733  
  1734  // CloneRefOfTruncateTable creates a deep clone of the input.
  1735  func CloneRefOfTruncateTable(n *TruncateTable) *TruncateTable {
  1736  	if n == nil {
  1737  		return nil
  1738  	}
  1739  	out := *n
  1740  	out.Table = CloneTableName(n.Table)
  1741  	return &out
  1742  }
  1743  
  1744  // CloneRefOfUnaryExpr creates a deep clone of the input.
  1745  func CloneRefOfUnaryExpr(n *UnaryExpr) *UnaryExpr {
  1746  	if n == nil {
  1747  		return nil
  1748  	}
  1749  	out := *n
  1750  	out.Expr = CloneExpr(n.Expr)
  1751  	return &out
  1752  }
  1753  
  1754  // CloneRefOfUnion creates a deep clone of the input.
  1755  func CloneRefOfUnion(n *Union) *Union {
  1756  	if n == nil {
  1757  		return nil
  1758  	}
  1759  	out := *n
  1760  	out.Left = CloneSelectStatement(n.Left)
  1761  	out.Right = CloneSelectStatement(n.Right)
  1762  	out.OrderBy = CloneOrderBy(n.OrderBy)
  1763  	out.With = CloneRefOfWith(n.With)
  1764  	out.Limit = CloneRefOfLimit(n.Limit)
  1765  	out.Into = CloneRefOfSelectInto(n.Into)
  1766  	return &out
  1767  }
  1768  
  1769  // CloneRefOfUnlockTables creates a deep clone of the input.
  1770  func CloneRefOfUnlockTables(n *UnlockTables) *UnlockTables {
  1771  	if n == nil {
  1772  		return nil
  1773  	}
  1774  	out := *n
  1775  	return &out
  1776  }
  1777  
  1778  // CloneRefOfUpdate creates a deep clone of the input.
  1779  func CloneRefOfUpdate(n *Update) *Update {
  1780  	if n == nil {
  1781  		return nil
  1782  	}
  1783  	out := *n
  1784  	out.With = CloneRefOfWith(n.With)
  1785  	out.Comments = CloneComments(n.Comments)
  1786  	out.TableExprs = CloneTableExprs(n.TableExprs)
  1787  	out.Exprs = CloneUpdateExprs(n.Exprs)
  1788  	out.Where = CloneRefOfWhere(n.Where)
  1789  	out.OrderBy = CloneOrderBy(n.OrderBy)
  1790  	out.Limit = CloneRefOfLimit(n.Limit)
  1791  	return &out
  1792  }
  1793  
  1794  // CloneRefOfUpdateExpr creates a deep clone of the input.
  1795  func CloneRefOfUpdateExpr(n *UpdateExpr) *UpdateExpr {
  1796  	if n == nil {
  1797  		return nil
  1798  	}
  1799  	out := *n
  1800  	out.Name = CloneRefOfColName(n.Name)
  1801  	out.Expr = CloneExpr(n.Expr)
  1802  	return &out
  1803  }
  1804  
  1805  // CloneUpdateExprs creates a deep clone of the input.
  1806  func CloneUpdateExprs(n UpdateExprs) UpdateExprs {
  1807  	if n == nil {
  1808  		return nil
  1809  	}
  1810  	res := make(UpdateExprs, 0, len(n))
  1811  	for _, x := range n {
  1812  		res = append(res, CloneRefOfUpdateExpr(x))
  1813  	}
  1814  	return res
  1815  }
  1816  
  1817  // CloneRefOfUse creates a deep clone of the input.
  1818  func CloneRefOfUse(n *Use) *Use {
  1819  	if n == nil {
  1820  		return nil
  1821  	}
  1822  	out := *n
  1823  	out.DBName = CloneTableIdent(n.DBName)
  1824  	return &out
  1825  }
  1826  
  1827  // CloneRefOfVStream creates a deep clone of the input.
  1828  func CloneRefOfVStream(n *VStream) *VStream {
  1829  	if n == nil {
  1830  		return nil
  1831  	}
  1832  	out := *n
  1833  	out.Comments = CloneComments(n.Comments)
  1834  	out.SelectExpr = CloneSelectExpr(n.SelectExpr)
  1835  	out.Table = CloneTableName(n.Table)
  1836  	out.Where = CloneRefOfWhere(n.Where)
  1837  	out.Limit = CloneRefOfLimit(n.Limit)
  1838  	return &out
  1839  }
  1840  
  1841  // CloneValTuple creates a deep clone of the input.
  1842  func CloneValTuple(n ValTuple) ValTuple {
  1843  	if n == nil {
  1844  		return nil
  1845  	}
  1846  	res := make(ValTuple, 0, len(n))
  1847  	for _, x := range n {
  1848  		res = append(res, CloneExpr(x))
  1849  	}
  1850  	return res
  1851  }
  1852  
  1853  // CloneRefOfValidation creates a deep clone of the input.
  1854  func CloneRefOfValidation(n *Validation) *Validation {
  1855  	if n == nil {
  1856  		return nil
  1857  	}
  1858  	out := *n
  1859  	return &out
  1860  }
  1861  
  1862  // CloneValues creates a deep clone of the input.
  1863  func CloneValues(n Values) Values {
  1864  	if n == nil {
  1865  		return nil
  1866  	}
  1867  	res := make(Values, 0, len(n))
  1868  	for _, x := range n {
  1869  		res = append(res, CloneValTuple(x))
  1870  	}
  1871  	return res
  1872  }
  1873  
  1874  // CloneRefOfValuesFuncExpr creates a deep clone of the input.
  1875  func CloneRefOfValuesFuncExpr(n *ValuesFuncExpr) *ValuesFuncExpr {
  1876  	if n == nil {
  1877  		return nil
  1878  	}
  1879  	out := *n
  1880  	out.Name = CloneRefOfColName(n.Name)
  1881  	return &out
  1882  }
  1883  
  1884  // CloneVindexParam creates a deep clone of the input.
  1885  func CloneVindexParam(n VindexParam) VindexParam {
  1886  	return *CloneRefOfVindexParam(&n)
  1887  }
  1888  
  1889  // CloneRefOfVindexSpec creates a deep clone of the input.
  1890  func CloneRefOfVindexSpec(n *VindexSpec) *VindexSpec {
  1891  	if n == nil {
  1892  		return nil
  1893  	}
  1894  	out := *n
  1895  	out.Name = CloneColIdent(n.Name)
  1896  	out.Type = CloneColIdent(n.Type)
  1897  	out.Params = CloneSliceOfVindexParam(n.Params)
  1898  	return &out
  1899  }
  1900  
  1901  // CloneRefOfWhen creates a deep clone of the input.
  1902  func CloneRefOfWhen(n *When) *When {
  1903  	if n == nil {
  1904  		return nil
  1905  	}
  1906  	out := *n
  1907  	out.Cond = CloneExpr(n.Cond)
  1908  	out.Val = CloneExpr(n.Val)
  1909  	return &out
  1910  }
  1911  
  1912  // CloneRefOfWhere creates a deep clone of the input.
  1913  func CloneRefOfWhere(n *Where) *Where {
  1914  	if n == nil {
  1915  		return nil
  1916  	}
  1917  	out := *n
  1918  	out.Expr = CloneExpr(n.Expr)
  1919  	return &out
  1920  }
  1921  
  1922  // CloneRefOfWith creates a deep clone of the input.
  1923  func CloneRefOfWith(n *With) *With {
  1924  	if n == nil {
  1925  		return nil
  1926  	}
  1927  	out := *n
  1928  	out.ctes = CloneSliceOfRefOfCommonTableExpr(n.ctes)
  1929  	return &out
  1930  }
  1931  
  1932  // CloneRefOfXorExpr creates a deep clone of the input.
  1933  func CloneRefOfXorExpr(n *XorExpr) *XorExpr {
  1934  	if n == nil {
  1935  		return nil
  1936  	}
  1937  	out := *n
  1938  	out.Left = CloneExpr(n.Left)
  1939  	out.Right = CloneExpr(n.Right)
  1940  	return &out
  1941  }
  1942  
  1943  // CloneAlterOption creates a deep clone of the input.
  1944  func CloneAlterOption(in AlterOption) AlterOption {
  1945  	if in == nil {
  1946  		return nil
  1947  	}
  1948  	switch in := in.(type) {
  1949  	case *AddColumns:
  1950  		return CloneRefOfAddColumns(in)
  1951  	case *AddConstraintDefinition:
  1952  		return CloneRefOfAddConstraintDefinition(in)
  1953  	case *AddIndexDefinition:
  1954  		return CloneRefOfAddIndexDefinition(in)
  1955  	case AlgorithmValue:
  1956  		return in
  1957  	case *AlterCharset:
  1958  		return CloneRefOfAlterCharset(in)
  1959  	case *AlterColumn:
  1960  		return CloneRefOfAlterColumn(in)
  1961  	case *ChangeColumn:
  1962  		return CloneRefOfChangeColumn(in)
  1963  	case *DropColumn:
  1964  		return CloneRefOfDropColumn(in)
  1965  	case *DropKey:
  1966  		return CloneRefOfDropKey(in)
  1967  	case *Force:
  1968  		return CloneRefOfForce(in)
  1969  	case *KeyState:
  1970  		return CloneRefOfKeyState(in)
  1971  	case *LockOption:
  1972  		return CloneRefOfLockOption(in)
  1973  	case *ModifyColumn:
  1974  		return CloneRefOfModifyColumn(in)
  1975  	case *OrderByOption:
  1976  		return CloneRefOfOrderByOption(in)
  1977  	case *RenameIndex:
  1978  		return CloneRefOfRenameIndex(in)
  1979  	case *RenameTableName:
  1980  		return CloneRefOfRenameTableName(in)
  1981  	case TableOptions:
  1982  		return CloneTableOptions(in)
  1983  	case *TablespaceOperation:
  1984  		return CloneRefOfTablespaceOperation(in)
  1985  	case *Validation:
  1986  		return CloneRefOfValidation(in)
  1987  	default:
  1988  		// this should never happen
  1989  		return nil
  1990  	}
  1991  }
  1992  
  1993  // CloneCharacteristic creates a deep clone of the input.
  1994  func CloneCharacteristic(in Characteristic) Characteristic {
  1995  	if in == nil {
  1996  		return nil
  1997  	}
  1998  	switch in := in.(type) {
  1999  	case AccessMode:
  2000  		return in
  2001  	case IsolationLevel:
  2002  		return in
  2003  	default:
  2004  		// this should never happen
  2005  		return nil
  2006  	}
  2007  }
  2008  
  2009  // CloneColTuple creates a deep clone of the input.
  2010  func CloneColTuple(in ColTuple) ColTuple {
  2011  	if in == nil {
  2012  		return nil
  2013  	}
  2014  	switch in := in.(type) {
  2015  	case ListArg:
  2016  		return in
  2017  	case *Subquery:
  2018  		return CloneRefOfSubquery(in)
  2019  	case ValTuple:
  2020  		return CloneValTuple(in)
  2021  	default:
  2022  		// this should never happen
  2023  		return nil
  2024  	}
  2025  }
  2026  
  2027  // CloneConstraintInfo creates a deep clone of the input.
  2028  func CloneConstraintInfo(in ConstraintInfo) ConstraintInfo {
  2029  	if in == nil {
  2030  		return nil
  2031  	}
  2032  	switch in := in.(type) {
  2033  	case *CheckConstraintDefinition:
  2034  		return CloneRefOfCheckConstraintDefinition(in)
  2035  	case *ForeignKeyDefinition:
  2036  		return CloneRefOfForeignKeyDefinition(in)
  2037  	default:
  2038  		// this should never happen
  2039  		return nil
  2040  	}
  2041  }
  2042  
  2043  // CloneDBDDLStatement creates a deep clone of the input.
  2044  func CloneDBDDLStatement(in DBDDLStatement) DBDDLStatement {
  2045  	if in == nil {
  2046  		return nil
  2047  	}
  2048  	switch in := in.(type) {
  2049  	case *AlterDatabase:
  2050  		return CloneRefOfAlterDatabase(in)
  2051  	case *CreateDatabase:
  2052  		return CloneRefOfCreateDatabase(in)
  2053  	case *DropDatabase:
  2054  		return CloneRefOfDropDatabase(in)
  2055  	default:
  2056  		// this should never happen
  2057  		return nil
  2058  	}
  2059  }
  2060  
  2061  // CloneDDLStatement creates a deep clone of the input.
  2062  func CloneDDLStatement(in DDLStatement) DDLStatement {
  2063  	if in == nil {
  2064  		return nil
  2065  	}
  2066  	switch in := in.(type) {
  2067  	case *AlterTable:
  2068  		return CloneRefOfAlterTable(in)
  2069  	case *AlterView:
  2070  		return CloneRefOfAlterView(in)
  2071  	case *CreateTable:
  2072  		return CloneRefOfCreateTable(in)
  2073  	case *CreateView:
  2074  		return CloneRefOfCreateView(in)
  2075  	case *DropTable:
  2076  		return CloneRefOfDropTable(in)
  2077  	case *DropView:
  2078  		return CloneRefOfDropView(in)
  2079  	case *RenameTable:
  2080  		return CloneRefOfRenameTable(in)
  2081  	case *TruncateTable:
  2082  		return CloneRefOfTruncateTable(in)
  2083  	default:
  2084  		// this should never happen
  2085  		return nil
  2086  	}
  2087  }
  2088  
  2089  // CloneExplain creates a deep clone of the input.
  2090  func CloneExplain(in Explain) Explain {
  2091  	if in == nil {
  2092  		return nil
  2093  	}
  2094  	switch in := in.(type) {
  2095  	case *ExplainStmt:
  2096  		return CloneRefOfExplainStmt(in)
  2097  	case *ExplainTab:
  2098  		return CloneRefOfExplainTab(in)
  2099  	default:
  2100  		// this should never happen
  2101  		return nil
  2102  	}
  2103  }
  2104  
  2105  // CloneExpr creates a deep clone of the input.
  2106  func CloneExpr(in Expr) Expr {
  2107  	if in == nil {
  2108  		return nil
  2109  	}
  2110  	switch in := in.(type) {
  2111  	case *AndExpr:
  2112  		return CloneRefOfAndExpr(in)
  2113  	case Argument:
  2114  		return in
  2115  	case *BetweenExpr:
  2116  		return CloneRefOfBetweenExpr(in)
  2117  	case *BinaryExpr:
  2118  		return CloneRefOfBinaryExpr(in)
  2119  	case BoolVal:
  2120  		return in
  2121  	case *CaseExpr:
  2122  		return CloneRefOfCaseExpr(in)
  2123  	case *ColName:
  2124  		return CloneRefOfColName(in)
  2125  	case *CollateExpr:
  2126  		return CloneRefOfCollateExpr(in)
  2127  	case *ComparisonExpr:
  2128  		return CloneRefOfComparisonExpr(in)
  2129  	case *ConvertExpr:
  2130  		return CloneRefOfConvertExpr(in)
  2131  	case *ConvertUsingExpr:
  2132  		return CloneRefOfConvertUsingExpr(in)
  2133  	case *CurTimeFuncExpr:
  2134  		return CloneRefOfCurTimeFuncExpr(in)
  2135  	case *Default:
  2136  		return CloneRefOfDefault(in)
  2137  	case *ExistsExpr:
  2138  		return CloneRefOfExistsExpr(in)
  2139  	case *ExtractFuncExpr:
  2140  		return CloneRefOfExtractFuncExpr(in)
  2141  	case *ExtractedSubquery:
  2142  		return CloneRefOfExtractedSubquery(in)
  2143  	case *FuncExpr:
  2144  		return CloneRefOfFuncExpr(in)
  2145  	case *GroupConcatExpr:
  2146  		return CloneRefOfGroupConcatExpr(in)
  2147  	case *IntervalExpr:
  2148  		return CloneRefOfIntervalExpr(in)
  2149  	case *IntroducerExpr:
  2150  		return CloneRefOfIntroducerExpr(in)
  2151  	case *IsExpr:
  2152  		return CloneRefOfIsExpr(in)
  2153  	case ListArg:
  2154  		return in
  2155  	case *Literal:
  2156  		return CloneRefOfLiteral(in)
  2157  	case *MatchExpr:
  2158  		return CloneRefOfMatchExpr(in)
  2159  	case *NotExpr:
  2160  		return CloneRefOfNotExpr(in)
  2161  	case *NullVal:
  2162  		return CloneRefOfNullVal(in)
  2163  	case *OrExpr:
  2164  		return CloneRefOfOrExpr(in)
  2165  	case *Subquery:
  2166  		return CloneRefOfSubquery(in)
  2167  	case *SubstrExpr:
  2168  		return CloneRefOfSubstrExpr(in)
  2169  	case *TimestampFuncExpr:
  2170  		return CloneRefOfTimestampFuncExpr(in)
  2171  	case *UnaryExpr:
  2172  		return CloneRefOfUnaryExpr(in)
  2173  	case ValTuple:
  2174  		return CloneValTuple(in)
  2175  	case *ValuesFuncExpr:
  2176  		return CloneRefOfValuesFuncExpr(in)
  2177  	case *XorExpr:
  2178  		return CloneRefOfXorExpr(in)
  2179  	default:
  2180  		// this should never happen
  2181  		return nil
  2182  	}
  2183  }
  2184  
  2185  // CloneInsertRows creates a deep clone of the input.
  2186  func CloneInsertRows(in InsertRows) InsertRows {
  2187  	if in == nil {
  2188  		return nil
  2189  	}
  2190  	switch in := in.(type) {
  2191  	case *Select:
  2192  		return CloneRefOfSelect(in)
  2193  	case *Union:
  2194  		return CloneRefOfUnion(in)
  2195  	case Values:
  2196  		return CloneValues(in)
  2197  	default:
  2198  		// this should never happen
  2199  		return nil
  2200  	}
  2201  }
  2202  
  2203  // CloneSelectExpr creates a deep clone of the input.
  2204  func CloneSelectExpr(in SelectExpr) SelectExpr {
  2205  	if in == nil {
  2206  		return nil
  2207  	}
  2208  	switch in := in.(type) {
  2209  	case *AliasedExpr:
  2210  		return CloneRefOfAliasedExpr(in)
  2211  	case *Nextval:
  2212  		return CloneRefOfNextval(in)
  2213  	case *StarExpr:
  2214  		return CloneRefOfStarExpr(in)
  2215  	default:
  2216  		// this should never happen
  2217  		return nil
  2218  	}
  2219  }
  2220  
  2221  // CloneSelectStatement creates a deep clone of the input.
  2222  func CloneSelectStatement(in SelectStatement) SelectStatement {
  2223  	if in == nil {
  2224  		return nil
  2225  	}
  2226  	switch in := in.(type) {
  2227  	case *Select:
  2228  		return CloneRefOfSelect(in)
  2229  	case *Union:
  2230  		return CloneRefOfUnion(in)
  2231  	default:
  2232  		// this should never happen
  2233  		return nil
  2234  	}
  2235  }
  2236  
  2237  // CloneShowInternal creates a deep clone of the input.
  2238  func CloneShowInternal(in ShowInternal) ShowInternal {
  2239  	if in == nil {
  2240  		return nil
  2241  	}
  2242  	switch in := in.(type) {
  2243  	case *ShowBasic:
  2244  		return CloneRefOfShowBasic(in)
  2245  	case *ShowCreate:
  2246  		return CloneRefOfShowCreate(in)
  2247  	case *ShowLegacy:
  2248  		return CloneRefOfShowLegacy(in)
  2249  	default:
  2250  		// this should never happen
  2251  		return nil
  2252  	}
  2253  }
  2254  
  2255  // CloneSimpleTableExpr creates a deep clone of the input.
  2256  func CloneSimpleTableExpr(in SimpleTableExpr) SimpleTableExpr {
  2257  	if in == nil {
  2258  		return nil
  2259  	}
  2260  	switch in := in.(type) {
  2261  	case *DerivedTable:
  2262  		return CloneRefOfDerivedTable(in)
  2263  	case TableName:
  2264  		return CloneTableName(in)
  2265  	default:
  2266  		// this should never happen
  2267  		return nil
  2268  	}
  2269  }
  2270  
  2271  // CloneStatement creates a deep clone of the input.
  2272  func CloneStatement(in Statement) Statement {
  2273  	if in == nil {
  2274  		return nil
  2275  	}
  2276  	switch in := in.(type) {
  2277  	case *AlterDatabase:
  2278  		return CloneRefOfAlterDatabase(in)
  2279  	case *AlterMigration:
  2280  		return CloneRefOfAlterMigration(in)
  2281  	case *AlterTable:
  2282  		return CloneRefOfAlterTable(in)
  2283  	case *AlterView:
  2284  		return CloneRefOfAlterView(in)
  2285  	case *AlterVschema:
  2286  		return CloneRefOfAlterVschema(in)
  2287  	case *Begin:
  2288  		return CloneRefOfBegin(in)
  2289  	case *CallProc:
  2290  		return CloneRefOfCallProc(in)
  2291  	case *Commit:
  2292  		return CloneRefOfCommit(in)
  2293  	case *CreateDatabase:
  2294  		return CloneRefOfCreateDatabase(in)
  2295  	case *CreateTable:
  2296  		return CloneRefOfCreateTable(in)
  2297  	case *CreateView:
  2298  		return CloneRefOfCreateView(in)
  2299  	case *Delete:
  2300  		return CloneRefOfDelete(in)
  2301  	case *DropDatabase:
  2302  		return CloneRefOfDropDatabase(in)
  2303  	case *DropTable:
  2304  		return CloneRefOfDropTable(in)
  2305  	case *DropView:
  2306  		return CloneRefOfDropView(in)
  2307  	case *ExplainStmt:
  2308  		return CloneRefOfExplainStmt(in)
  2309  	case *ExplainTab:
  2310  		return CloneRefOfExplainTab(in)
  2311  	case *Flush:
  2312  		return CloneRefOfFlush(in)
  2313  	case *Insert:
  2314  		return CloneRefOfInsert(in)
  2315  	case *Load:
  2316  		return CloneRefOfLoad(in)
  2317  	case *LockTables:
  2318  		return CloneRefOfLockTables(in)
  2319  	case *OtherAdmin:
  2320  		return CloneRefOfOtherAdmin(in)
  2321  	case *OtherRead:
  2322  		return CloneRefOfOtherRead(in)
  2323  	case *Release:
  2324  		return CloneRefOfRelease(in)
  2325  	case *RenameTable:
  2326  		return CloneRefOfRenameTable(in)
  2327  	case *RevertMigration:
  2328  		return CloneRefOfRevertMigration(in)
  2329  	case *Rollback:
  2330  		return CloneRefOfRollback(in)
  2331  	case *SRollback:
  2332  		return CloneRefOfSRollback(in)
  2333  	case *Savepoint:
  2334  		return CloneRefOfSavepoint(in)
  2335  	case *Select:
  2336  		return CloneRefOfSelect(in)
  2337  	case *Set:
  2338  		return CloneRefOfSet(in)
  2339  	case *SetTransaction:
  2340  		return CloneRefOfSetTransaction(in)
  2341  	case *Show:
  2342  		return CloneRefOfShow(in)
  2343  	case *ShowMigrationLogs:
  2344  		return CloneRefOfShowMigrationLogs(in)
  2345  	case *Stream:
  2346  		return CloneRefOfStream(in)
  2347  	case *TruncateTable:
  2348  		return CloneRefOfTruncateTable(in)
  2349  	case *Union:
  2350  		return CloneRefOfUnion(in)
  2351  	case *UnlockTables:
  2352  		return CloneRefOfUnlockTables(in)
  2353  	case *Update:
  2354  		return CloneRefOfUpdate(in)
  2355  	case *Use:
  2356  		return CloneRefOfUse(in)
  2357  	case *VStream:
  2358  		return CloneRefOfVStream(in)
  2359  	default:
  2360  		// this should never happen
  2361  		return nil
  2362  	}
  2363  }
  2364  
  2365  // CloneTableExpr creates a deep clone of the input.
  2366  func CloneTableExpr(in TableExpr) TableExpr {
  2367  	if in == nil {
  2368  		return nil
  2369  	}
  2370  	switch in := in.(type) {
  2371  	case *AliasedTableExpr:
  2372  		return CloneRefOfAliasedTableExpr(in)
  2373  	case *JoinTableExpr:
  2374  		return CloneRefOfJoinTableExpr(in)
  2375  	case *ParenTableExpr:
  2376  		return CloneRefOfParenTableExpr(in)
  2377  	default:
  2378  		// this should never happen
  2379  		return nil
  2380  	}
  2381  }
  2382  
  2383  // CloneSliceOfRefOfColumnDefinition creates a deep clone of the input.
  2384  func CloneSliceOfRefOfColumnDefinition(n []*ColumnDefinition) []*ColumnDefinition {
  2385  	if n == nil {
  2386  		return nil
  2387  	}
  2388  	res := make([]*ColumnDefinition, 0, len(n))
  2389  	for _, x := range n {
  2390  		res = append(res, CloneRefOfColumnDefinition(x))
  2391  	}
  2392  	return res
  2393  }
  2394  
  2395  // CloneSliceOfCollateAndCharset creates a deep clone of the input.
  2396  func CloneSliceOfCollateAndCharset(n []CollateAndCharset) []CollateAndCharset {
  2397  	if n == nil {
  2398  		return nil
  2399  	}
  2400  	res := make([]CollateAndCharset, 0, len(n))
  2401  	for _, x := range n {
  2402  		res = append(res, CloneCollateAndCharset(x))
  2403  	}
  2404  	return res
  2405  }
  2406  
  2407  // CloneSliceOfAlterOption creates a deep clone of the input.
  2408  func CloneSliceOfAlterOption(n []AlterOption) []AlterOption {
  2409  	if n == nil {
  2410  		return nil
  2411  	}
  2412  	res := make([]AlterOption, 0, len(n))
  2413  	for _, x := range n {
  2414  		res = append(res, CloneAlterOption(x))
  2415  	}
  2416  	return res
  2417  }
  2418  
  2419  // CloneSliceOfColIdent creates a deep clone of the input.
  2420  func CloneSliceOfColIdent(n []ColIdent) []ColIdent {
  2421  	if n == nil {
  2422  		return nil
  2423  	}
  2424  	res := make([]ColIdent, 0, len(n))
  2425  	for _, x := range n {
  2426  		res = append(res, CloneColIdent(x))
  2427  	}
  2428  	return res
  2429  }
  2430  
  2431  // CloneSliceOfRefOfWhen creates a deep clone of the input.
  2432  func CloneSliceOfRefOfWhen(n []*When) []*When {
  2433  	if n == nil {
  2434  		return nil
  2435  	}
  2436  	res := make([]*When, 0, len(n))
  2437  	for _, x := range n {
  2438  		res = append(res, CloneRefOfWhen(x))
  2439  	}
  2440  	return res
  2441  }
  2442  
  2443  // CloneRefOfColIdent creates a deep clone of the input.
  2444  func CloneRefOfColIdent(n *ColIdent) *ColIdent {
  2445  	if n == nil {
  2446  		return nil
  2447  	}
  2448  	out := *n
  2449  	return &out
  2450  }
  2451  
  2452  // CloneColumnType creates a deep clone of the input.
  2453  func CloneColumnType(n ColumnType) ColumnType {
  2454  	return *CloneRefOfColumnType(&n)
  2455  }
  2456  
  2457  // CloneRefOfColumnTypeOptions creates a deep clone of the input.
  2458  func CloneRefOfColumnTypeOptions(n *ColumnTypeOptions) *ColumnTypeOptions {
  2459  	if n == nil {
  2460  		return nil
  2461  	}
  2462  	out := *n
  2463  	out.Null = CloneRefOfBool(n.Null)
  2464  	out.Default = CloneExpr(n.Default)
  2465  	out.OnUpdate = CloneExpr(n.OnUpdate)
  2466  	out.As = CloneExpr(n.As)
  2467  	out.Comment = CloneRefOfLiteral(n.Comment)
  2468  	out.Reference = CloneRefOfReferenceDefinition(n.Reference)
  2469  	return &out
  2470  }
  2471  
  2472  // CloneSliceOfString creates a deep clone of the input.
  2473  func CloneSliceOfString(n []string) []string {
  2474  	if n == nil {
  2475  		return nil
  2476  	}
  2477  	res := make([]string, 0, len(n))
  2478  	copy(res, n)
  2479  	return res
  2480  }
  2481  
  2482  // CloneSliceOfRefOfIndexColumn creates a deep clone of the input.
  2483  func CloneSliceOfRefOfIndexColumn(n []*IndexColumn) []*IndexColumn {
  2484  	if n == nil {
  2485  		return nil
  2486  	}
  2487  	res := make([]*IndexColumn, 0, len(n))
  2488  	for _, x := range n {
  2489  		res = append(res, CloneRefOfIndexColumn(x))
  2490  	}
  2491  	return res
  2492  }
  2493  
  2494  // CloneSliceOfRefOfIndexOption creates a deep clone of the input.
  2495  func CloneSliceOfRefOfIndexOption(n []*IndexOption) []*IndexOption {
  2496  	if n == nil {
  2497  		return nil
  2498  	}
  2499  	res := make([]*IndexOption, 0, len(n))
  2500  	for _, x := range n {
  2501  		res = append(res, CloneRefOfIndexOption(x))
  2502  	}
  2503  	return res
  2504  }
  2505  
  2506  // CloneTableAndLockTypes creates a deep clone of the input.
  2507  func CloneTableAndLockTypes(n TableAndLockTypes) TableAndLockTypes {
  2508  	if n == nil {
  2509  		return nil
  2510  	}
  2511  	res := make(TableAndLockTypes, 0, len(n))
  2512  	for _, x := range n {
  2513  		res = append(res, CloneRefOfTableAndLockType(x))
  2514  	}
  2515  	return res
  2516  }
  2517  
  2518  // CloneSliceOfRefOfPartitionDefinition creates a deep clone of the input.
  2519  func CloneSliceOfRefOfPartitionDefinition(n []*PartitionDefinition) []*PartitionDefinition {
  2520  	if n == nil {
  2521  		return nil
  2522  	}
  2523  	res := make([]*PartitionDefinition, 0, len(n))
  2524  	for _, x := range n {
  2525  		res = append(res, CloneRefOfPartitionDefinition(x))
  2526  	}
  2527  	return res
  2528  }
  2529  
  2530  // CloneSliceOfRefOfRenameTablePair creates a deep clone of the input.
  2531  func CloneSliceOfRefOfRenameTablePair(n []*RenameTablePair) []*RenameTablePair {
  2532  	if n == nil {
  2533  		return nil
  2534  	}
  2535  	res := make([]*RenameTablePair, 0, len(n))
  2536  	for _, x := range n {
  2537  		res = append(res, CloneRefOfRenameTablePair(x))
  2538  	}
  2539  	return res
  2540  }
  2541  
  2542  // CloneRefOfRootNode creates a deep clone of the input.
  2543  func CloneRefOfRootNode(n *RootNode) *RootNode {
  2544  	if n == nil {
  2545  		return nil
  2546  	}
  2547  	out := *n
  2548  	out.SQLNode = CloneSQLNode(n.SQLNode)
  2549  	return &out
  2550  }
  2551  
  2552  // CloneRefOfBool creates a deep clone of the input.
  2553  func CloneRefOfBool(n *bool) *bool {
  2554  	if n == nil {
  2555  		return nil
  2556  	}
  2557  	out := *n
  2558  	return &out
  2559  }
  2560  
  2561  // CloneSliceOfTableExpr creates a deep clone of the input.
  2562  func CloneSliceOfTableExpr(n []TableExpr) []TableExpr {
  2563  	if n == nil {
  2564  		return nil
  2565  	}
  2566  	res := make([]TableExpr, 0, len(n))
  2567  	for _, x := range n {
  2568  		res = append(res, CloneTableExpr(x))
  2569  	}
  2570  	return res
  2571  }
  2572  
  2573  // CloneSliceOfCharacteristic creates a deep clone of the input.
  2574  func CloneSliceOfCharacteristic(n []Characteristic) []Characteristic {
  2575  	if n == nil {
  2576  		return nil
  2577  	}
  2578  	res := make([]Characteristic, 0, len(n))
  2579  	for _, x := range n {
  2580  		res = append(res, CloneCharacteristic(x))
  2581  	}
  2582  	return res
  2583  }
  2584  
  2585  // CloneRefOfShowTablesOpt creates a deep clone of the input.
  2586  func CloneRefOfShowTablesOpt(n *ShowTablesOpt) *ShowTablesOpt {
  2587  	if n == nil {
  2588  		return nil
  2589  	}
  2590  	out := *n
  2591  	out.Filter = CloneRefOfShowFilter(n.Filter)
  2592  	return &out
  2593  }
  2594  
  2595  // CloneRefOfTableIdent creates a deep clone of the input.
  2596  func CloneRefOfTableIdent(n *TableIdent) *TableIdent {
  2597  	if n == nil {
  2598  		return nil
  2599  	}
  2600  	out := *n
  2601  	return &out
  2602  }
  2603  
  2604  // CloneRefOfTableName creates a deep clone of the input.
  2605  func CloneRefOfTableName(n *TableName) *TableName {
  2606  	if n == nil {
  2607  		return nil
  2608  	}
  2609  	out := *n
  2610  	out.Name = CloneTableIdent(n.Name)
  2611  	out.Qualifier = CloneTableIdent(n.Qualifier)
  2612  	return &out
  2613  }
  2614  
  2615  // CloneRefOfTableOption creates a deep clone of the input.
  2616  func CloneRefOfTableOption(n *TableOption) *TableOption {
  2617  	if n == nil {
  2618  		return nil
  2619  	}
  2620  	out := *n
  2621  	out.Value = CloneRefOfLiteral(n.Value)
  2622  	out.Tables = CloneTableNames(n.Tables)
  2623  	return &out
  2624  }
  2625  
  2626  // CloneSliceOfRefOfIndexDefinition creates a deep clone of the input.
  2627  func CloneSliceOfRefOfIndexDefinition(n []*IndexDefinition) []*IndexDefinition {
  2628  	if n == nil {
  2629  		return nil
  2630  	}
  2631  	res := make([]*IndexDefinition, 0, len(n))
  2632  	for _, x := range n {
  2633  		res = append(res, CloneRefOfIndexDefinition(x))
  2634  	}
  2635  	return res
  2636  }
  2637  
  2638  // CloneSliceOfRefOfConstraintDefinition creates a deep clone of the input.
  2639  func CloneSliceOfRefOfConstraintDefinition(n []*ConstraintDefinition) []*ConstraintDefinition {
  2640  	if n == nil {
  2641  		return nil
  2642  	}
  2643  	res := make([]*ConstraintDefinition, 0, len(n))
  2644  	for _, x := range n {
  2645  		res = append(res, CloneRefOfConstraintDefinition(x))
  2646  	}
  2647  	return res
  2648  }
  2649  
  2650  // CloneRefOfVindexParam creates a deep clone of the input.
  2651  func CloneRefOfVindexParam(n *VindexParam) *VindexParam {
  2652  	if n == nil {
  2653  		return nil
  2654  	}
  2655  	out := *n
  2656  	out.Key = CloneColIdent(n.Key)
  2657  	return &out
  2658  }
  2659  
  2660  // CloneSliceOfVindexParam creates a deep clone of the input.
  2661  func CloneSliceOfVindexParam(n []VindexParam) []VindexParam {
  2662  	if n == nil {
  2663  		return nil
  2664  	}
  2665  	res := make([]VindexParam, 0, len(n))
  2666  	for _, x := range n {
  2667  		res = append(res, CloneVindexParam(x))
  2668  	}
  2669  	return res
  2670  }
  2671  
  2672  // CloneSliceOfRefOfCommonTableExpr creates a deep clone of the input.
  2673  func CloneSliceOfRefOfCommonTableExpr(n []*CommonTableExpr) []*CommonTableExpr {
  2674  	if n == nil {
  2675  		return nil
  2676  	}
  2677  	res := make([]*CommonTableExpr, 0, len(n))
  2678  	for _, x := range n {
  2679  		res = append(res, CloneRefOfCommonTableExpr(x))
  2680  	}
  2681  	return res
  2682  }
  2683  
  2684  // CloneCollateAndCharset creates a deep clone of the input.
  2685  func CloneCollateAndCharset(n CollateAndCharset) CollateAndCharset {
  2686  	return *CloneRefOfCollateAndCharset(&n)
  2687  }
  2688  
  2689  // CloneRefOfIndexColumn creates a deep clone of the input.
  2690  func CloneRefOfIndexColumn(n *IndexColumn) *IndexColumn {
  2691  	if n == nil {
  2692  		return nil
  2693  	}
  2694  	out := *n
  2695  	out.Column = CloneColIdent(n.Column)
  2696  	out.Length = CloneRefOfLiteral(n.Length)
  2697  	return &out
  2698  }
  2699  
  2700  // CloneRefOfIndexOption creates a deep clone of the input.
  2701  func CloneRefOfIndexOption(n *IndexOption) *IndexOption {
  2702  	if n == nil {
  2703  		return nil
  2704  	}
  2705  	out := *n
  2706  	out.Value = CloneRefOfLiteral(n.Value)
  2707  	return &out
  2708  }
  2709  
  2710  // CloneRefOfTableAndLockType creates a deep clone of the input.
  2711  func CloneRefOfTableAndLockType(n *TableAndLockType) *TableAndLockType {
  2712  	if n == nil {
  2713  		return nil
  2714  	}
  2715  	out := *n
  2716  	out.Table = CloneTableExpr(n.Table)
  2717  	return &out
  2718  }
  2719  
  2720  // CloneRefOfRenameTablePair creates a deep clone of the input.
  2721  func CloneRefOfRenameTablePair(n *RenameTablePair) *RenameTablePair {
  2722  	if n == nil {
  2723  		return nil
  2724  	}
  2725  	out := *n
  2726  	out.FromTable = CloneTableName(n.FromTable)
  2727  	out.ToTable = CloneTableName(n.ToTable)
  2728  	return &out
  2729  }
  2730  
  2731  // CloneRefOfCollateAndCharset creates a deep clone of the input.
  2732  func CloneRefOfCollateAndCharset(n *CollateAndCharset) *CollateAndCharset {
  2733  	if n == nil {
  2734  		return nil
  2735  	}
  2736  	out := *n
  2737  	return &out
  2738  }