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

     1  /*
     2  Copyright 2019 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  
    17  package sqlparser
    18  
    19  /*
    20  This is the Vitess AST. This file should only contain pure struct declarations,
    21  or methods used to mark a struct as implementing an interface. All other methods
    22  related to these structs live in ast_funcs.go
    23  */
    24  
    25  // SQLNode defines the interface for all nodes
    26  // generated by the parser.
    27  type SQLNode interface {
    28  	Format(buf *TrackedBuffer)
    29  	formatFast(buf *TrackedBuffer)
    30  }
    31  
    32  // Statements
    33  type (
    34  	// Statement represents a statement.
    35  	Statement interface {
    36  		iStatement()
    37  		SQLNode
    38  	}
    39  
    40  	Commented interface {
    41  		SetComments(comments Comments)
    42  		GetParsedComments() *ParsedComments
    43  	}
    44  
    45  	// SupportOptimizerHint represents a statement that accepts optimizer hints.
    46  	SupportOptimizerHint interface {
    47  		iSupportOptimizerHint()
    48  		Commented
    49  	}
    50  
    51  	// SelectStatement any SELECT statement.
    52  	SelectStatement interface {
    53  		Statement
    54  		InsertRows
    55  		iSelectStatement()
    56  		AddOrder(*Order)
    57  		SetOrderBy(OrderBy)
    58  		GetOrderBy() OrderBy
    59  		GetLimit() *Limit
    60  		SetLimit(*Limit)
    61  		SetLock(lock Lock)
    62  		SetInto(into *SelectInto)
    63  		SetWith(with *With)
    64  		MakeDistinct()
    65  		GetColumnCount() int
    66  		GetColumns() SelectExprs
    67  		Commented
    68  	}
    69  
    70  	// DDLStatement represents any DDL Statement
    71  	DDLStatement interface {
    72  		iDDLStatement()
    73  		IsFullyParsed() bool
    74  		IsTemporary() bool
    75  		GetTable() TableName
    76  		GetAction() DDLAction
    77  		GetOptLike() *OptLike
    78  		GetIfExists() bool
    79  		GetIfNotExists() bool
    80  		GetIsReplace() bool
    81  		GetTableSpec() *TableSpec
    82  		GetFromTables() TableNames
    83  		GetToTables() TableNames
    84  		AffectedTables() TableNames
    85  		SetTable(qualifier string, name string)
    86  		SetFromTables(tables TableNames)
    87  		SetFullyParsed(fullyParsed bool)
    88  		Commented
    89  		Statement
    90  	}
    91  
    92  	// DBDDLStatement represents any DBDDL Statement
    93  	DBDDLStatement interface {
    94  		iDBDDLStatement()
    95  		IsFullyParsed() bool
    96  		GetDatabaseName() string
    97  		SetFullyParsed(bool)
    98  		Statement
    99  	}
   100  
   101  	// AlterOption is an interface that represents the various options in ALTER TABLE statements
   102  	AlterOption interface {
   103  		iAlterOption()
   104  		SQLNode
   105  	}
   106  
   107  	// Explain is an interface that represents the Explain statements
   108  	Explain interface {
   109  		Statement
   110  		iExplain()
   111  	}
   112  
   113  	// AddConstraintDefinition represents a ADD CONSTRAINT alter option
   114  	AddConstraintDefinition struct {
   115  		ConstraintDefinition *ConstraintDefinition
   116  	}
   117  
   118  	// AddIndexDefinition represents a ADD INDEX alter option
   119  	AddIndexDefinition struct {
   120  		IndexDefinition *IndexDefinition
   121  	}
   122  
   123  	// AddColumns represents a ADD COLUMN alter option
   124  	AddColumns struct {
   125  		Columns []*ColumnDefinition
   126  		First   bool
   127  		After   *ColName
   128  	}
   129  
   130  	// AlgorithmValue is the algorithm specified in the alter table command
   131  	AlgorithmValue string
   132  
   133  	// AlterColumn is used to add or drop defaults & visibility to columns in alter table command
   134  	AlterColumn struct {
   135  		Column      *ColName
   136  		DropDefault bool
   137  		DefaultVal  Expr
   138  		Invisible   *bool
   139  	}
   140  
   141  	// With contains the lists of common table expression and specifies if it is recursive or not
   142  	With struct {
   143  		Ctes      []*CommonTableExpr
   144  		Recursive bool
   145  	}
   146  
   147  	// CommonTableExpr is the structure for supporting common table expressions
   148  	CommonTableExpr struct {
   149  		ID       IdentifierCS
   150  		Columns  Columns
   151  		Subquery *Subquery
   152  	}
   153  	// ChangeColumn is used to change the column definition, can also rename the column in alter table command
   154  	ChangeColumn struct {
   155  		OldColumn        *ColName
   156  		NewColDefinition *ColumnDefinition
   157  		First            bool
   158  		After            *ColName
   159  	}
   160  
   161  	// ModifyColumn is used to change the column definition in alter table command
   162  	ModifyColumn struct {
   163  		NewColDefinition *ColumnDefinition
   164  		First            bool
   165  		After            *ColName
   166  	}
   167  
   168  	// RenameColumn is used to change the column definition in alter table command
   169  	RenameColumn struct {
   170  		OldName *ColName
   171  		NewName *ColName
   172  	}
   173  
   174  	// AlterCharset is used to set the default or change the character set and collation in alter table command
   175  	AlterCharset struct {
   176  		CharacterSet string
   177  		Collate      string
   178  	}
   179  
   180  	// AlterCheck represents the `ALTER CHECK` part in an `ALTER TABLE ALTER CHECK` command.
   181  	AlterCheck struct {
   182  		Name     IdentifierCI
   183  		Enforced bool
   184  	}
   185  
   186  	// AlterIndex represents the `ALTER INDEX` part in an `ALTER TABLE ALTER INDEX` command.
   187  	AlterIndex struct {
   188  		Name      IdentifierCI
   189  		Invisible bool
   190  	}
   191  
   192  	// KeyState is used to disable or enable the keys in an alter table statement
   193  	KeyState struct {
   194  		Enable bool
   195  	}
   196  
   197  	// TablespaceOperation is used to discard or import the tablespace in an alter table statement
   198  	TablespaceOperation struct {
   199  		Import bool
   200  	}
   201  
   202  	// DropColumn is used to drop a column in an alter table statement
   203  	DropColumn struct {
   204  		Name *ColName
   205  	}
   206  
   207  	// DropKeyType is an enum that represents the type of key being dropped in an alter table statement
   208  	DropKeyType int8
   209  
   210  	// DropKey is used to drop a key in an alter table statement
   211  	DropKey struct {
   212  		Type DropKeyType
   213  		Name IdentifierCI
   214  	}
   215  
   216  	// Force is used to specify force alter option in an alter table statement
   217  	Force struct{}
   218  
   219  	// LockOptionType is an enum for LockOption.Type
   220  	LockOptionType int8
   221  
   222  	// LockOption is used to specify the type of lock to use in an alter table statement
   223  	LockOption struct {
   224  		Type LockOptionType
   225  	}
   226  
   227  	// OrderByOption clause is used to specify the order by in an alter table statement
   228  	OrderByOption struct {
   229  		Cols Columns
   230  	}
   231  
   232  	// RenameTableName clause is used to rename the table in an alter table statement
   233  	RenameTableName struct {
   234  		Table TableName
   235  	}
   236  
   237  	// RenameIndex clause is used to rename indexes in an alter table statement
   238  	RenameIndex struct {
   239  		OldName IdentifierCI
   240  		NewName IdentifierCI
   241  	}
   242  
   243  	// Validation clause is used to specify whether to use validation or not
   244  	Validation struct {
   245  		With bool
   246  	}
   247  
   248  	// Select represents a SELECT statement.
   249  	Select struct {
   250  		Cache            *bool // a reference here so it can be nil
   251  		Distinct         bool
   252  		StraightJoinHint bool
   253  		SQLCalcFoundRows bool
   254  		// The From field must be the first AST element of this struct so the rewriter sees it first
   255  		From        []TableExpr
   256  		Comments    *ParsedComments
   257  		SelectExprs SelectExprs
   258  		Where       *Where
   259  		With        *With
   260  		GroupBy     GroupBy
   261  		Having      *Where
   262  		Windows     NamedWindows
   263  		OrderBy     OrderBy
   264  		Limit       *Limit
   265  		Lock        Lock
   266  		Into        *SelectInto
   267  	}
   268  
   269  	// SelectInto is a struct that represent the INTO part of a select query
   270  	SelectInto struct {
   271  		Type         SelectIntoType
   272  		FileName     string
   273  		Charset      ColumnCharset
   274  		FormatOption string
   275  		ExportOption string
   276  		Manifest     string
   277  		Overwrite    string
   278  	}
   279  
   280  	// SelectIntoType is an enum for SelectInto.Type
   281  	SelectIntoType int8
   282  
   283  	// Lock is an enum for the type of lock in the statement
   284  	Lock int8
   285  
   286  	// Union represents a UNION statement.
   287  	Union struct {
   288  		Left     SelectStatement
   289  		Right    SelectStatement
   290  		Distinct bool
   291  		OrderBy  OrderBy
   292  		With     *With
   293  		Limit    *Limit
   294  		Lock     Lock
   295  		Into     *SelectInto
   296  	}
   297  
   298  	// VStream represents a VSTREAM statement.
   299  	VStream struct {
   300  		Comments   *ParsedComments
   301  		SelectExpr SelectExpr
   302  		Table      TableName
   303  		Where      *Where
   304  		Limit      *Limit
   305  	}
   306  
   307  	// Stream represents a SELECT statement.
   308  	Stream struct {
   309  		Comments   *ParsedComments
   310  		SelectExpr SelectExpr
   311  		Table      TableName
   312  	}
   313  
   314  	// Insert represents an INSERT or REPLACE statement.
   315  	// Per the MySQL docs, http://dev.mysql.com/doc/refman/5.7/en/replace.html
   316  	// Replace is the counterpart to `INSERT IGNORE`, and works exactly like a
   317  	// normal INSERT except if the row exists. In that case it first deletes
   318  	// the row and re-inserts with new values. For that reason we keep it as an Insert struct.
   319  	// Replaces are currently disallowed in sharded schemas because
   320  	// of the implications the deletion part may have on vindexes.
   321  	// If you add fields here, consider adding them to calls to validateUnshardedRoute.
   322  	Insert struct {
   323  		Action     InsertAction
   324  		Comments   *ParsedComments
   325  		Ignore     Ignore
   326  		Table      TableName
   327  		Partitions Partitions
   328  		Columns    Columns
   329  		Rows       InsertRows
   330  		OnDup      OnDup
   331  	}
   332  
   333  	// Ignore represents whether ignore was specified or not
   334  	Ignore bool
   335  
   336  	// InsertAction is the action for insert.
   337  	InsertAction int8
   338  
   339  	// Update represents an UPDATE statement.
   340  	// If you add fields here, consider adding them to calls to validateUnshardedRoute.
   341  	Update struct {
   342  		With       *With
   343  		Comments   *ParsedComments
   344  		Ignore     Ignore
   345  		TableExprs TableExprs
   346  		Exprs      UpdateExprs
   347  		Where      *Where
   348  		OrderBy    OrderBy
   349  		Limit      *Limit
   350  	}
   351  
   352  	// Delete represents a DELETE statement.
   353  	// If you add fields here, consider adding them to calls to validateUnshardedRoute.
   354  	Delete struct {
   355  		With       *With
   356  		Ignore     Ignore
   357  		Comments   *ParsedComments
   358  		Targets    TableNames
   359  		TableExprs TableExprs
   360  		Partitions Partitions
   361  		Where      *Where
   362  		OrderBy    OrderBy
   363  		Limit      *Limit
   364  	}
   365  
   366  	// Set represents a SET statement.
   367  	Set struct {
   368  		Comments *ParsedComments
   369  		Exprs    SetExprs
   370  	}
   371  
   372  	// DropDatabase represents a DROP database statement.
   373  	DropDatabase struct {
   374  		Comments *ParsedComments
   375  		DBName   IdentifierCS
   376  		IfExists bool
   377  	}
   378  
   379  	// DatabaseOptionType is an enum for create database options
   380  	DatabaseOptionType int8
   381  
   382  	// DatabaseOption is a struct that stores Collation or Character Set value
   383  	DatabaseOption struct {
   384  		Type      DatabaseOptionType
   385  		IsDefault bool
   386  		Value     string
   387  	}
   388  
   389  	// CreateDatabase represents a CREATE database statement.
   390  	CreateDatabase struct {
   391  		Comments      *ParsedComments
   392  		DBName        IdentifierCS
   393  		IfNotExists   bool
   394  		CreateOptions []DatabaseOption
   395  		FullyParsed   bool
   396  	}
   397  
   398  	// AlterDatabase represents a ALTER database statement.
   399  	AlterDatabase struct {
   400  		DBName              IdentifierCS
   401  		UpdateDataDirectory bool
   402  		AlterOptions        []DatabaseOption
   403  		FullyParsed         bool
   404  	}
   405  
   406  	// Flush represents a FLUSH statement.
   407  	Flush struct {
   408  		IsLocal      bool
   409  		FlushOptions []string
   410  		TableNames   TableNames
   411  		WithLock     bool
   412  		ForExport    bool
   413  	}
   414  
   415  	// RenameTablePair represents the name of the original table and what it is going to be set in a RENAME TABLE statement.
   416  	RenameTablePair struct {
   417  		FromTable TableName
   418  		ToTable   TableName
   419  	}
   420  
   421  	// RenameTable represents a RENAME TABLE statement.
   422  	RenameTable struct {
   423  		TablePairs []*RenameTablePair
   424  	}
   425  
   426  	// TruncateTable represents a TRUNCATE TABLE statement.
   427  	TruncateTable struct {
   428  		Table TableName
   429  	}
   430  
   431  	// AlterVschema represents a ALTER VSCHEMA statement.
   432  	AlterVschema struct {
   433  		Action DDLAction
   434  		Table  TableName
   435  
   436  		// VindexSpec is set for CreateVindexDDLAction, DropVindexDDLAction, AddColVindexDDLAction, DropColVindexDDLAction.
   437  		VindexSpec *VindexSpec
   438  
   439  		// VindexCols is set for AddColVindexDDLAction.
   440  		VindexCols []IdentifierCI
   441  
   442  		// AutoIncSpec is set for AddAutoIncDDLAction.
   443  		AutoIncSpec *AutoIncSpec
   444  	}
   445  
   446  	// ShowMigrationLogs represents a SHOW VITESS_MIGRATION '<uuid>' LOGS statement
   447  	ShowMigrationLogs struct {
   448  		UUID     string
   449  		Comments *ParsedComments
   450  	}
   451  
   452  	// ShowThrottledApps represents a SHOW VITESS_THROTTLED_APPS statement
   453  	ShowThrottledApps struct {
   454  		Comments Comments
   455  	}
   456  
   457  	// ShowThrottlerStatus represents a SHOW VITESS_THROTTLED_APPS statement
   458  	ShowThrottlerStatus struct {
   459  		Comments Comments
   460  	}
   461  
   462  	// RevertMigration represents a REVERT VITESS_MIGRATION statement
   463  	RevertMigration struct {
   464  		UUID     string
   465  		Comments *ParsedComments
   466  	}
   467  
   468  	// AlterMigrationType represents the type of operation in an ALTER VITESS_MIGRATION statement
   469  	AlterMigrationType int8
   470  
   471  	// AlterMigration represents a ALTER VITESS_MIGRATION statement
   472  	AlterMigration struct {
   473  		Type   AlterMigrationType
   474  		UUID   string
   475  		Expire string
   476  		Ratio  *Literal
   477  		Shards string
   478  	}
   479  
   480  	// AlterTable represents a ALTER TABLE statement.
   481  	AlterTable struct {
   482  		Table           TableName
   483  		AlterOptions    []AlterOption
   484  		PartitionSpec   *PartitionSpec
   485  		PartitionOption *PartitionOption
   486  		Comments        *ParsedComments
   487  		FullyParsed     bool
   488  	}
   489  
   490  	// DropTable represents a DROP TABLE statement.
   491  	DropTable struct {
   492  		Temp       bool
   493  		FromTables TableNames
   494  		// The following fields are set if a DDL was fully analyzed.
   495  		IfExists bool
   496  		Comments *ParsedComments
   497  	}
   498  
   499  	// DropView represents a DROP VIEW statement.
   500  	DropView struct {
   501  		FromTables TableNames
   502  		IfExists   bool
   503  		Comments   *ParsedComments
   504  	}
   505  
   506  	// CreateTable represents a CREATE TABLE statement.
   507  	CreateTable struct {
   508  		Temp        bool
   509  		Table       TableName
   510  		IfNotExists bool
   511  		TableSpec   *TableSpec
   512  		OptLike     *OptLike
   513  		Comments    *ParsedComments
   514  		FullyParsed bool
   515  	}
   516  
   517  	// CreateView represents a CREATE VIEW query
   518  	CreateView struct {
   519  		ViewName    TableName
   520  		Algorithm   string
   521  		Definer     *Definer
   522  		Security    string
   523  		Columns     Columns
   524  		Select      SelectStatement
   525  		CheckOption string
   526  		IsReplace   bool
   527  		Comments    *ParsedComments
   528  	}
   529  
   530  	// AlterView represents a ALTER VIEW query
   531  	AlterView struct {
   532  		ViewName    TableName
   533  		Algorithm   string
   534  		Definer     *Definer
   535  		Security    string
   536  		Columns     Columns
   537  		Select      SelectStatement
   538  		CheckOption string
   539  		Comments    *ParsedComments
   540  	}
   541  
   542  	// Definer stores the user for AlterView and CreateView definers
   543  	Definer struct {
   544  		Name    string
   545  		Address string
   546  	}
   547  
   548  	// DDLAction is an enum for DDL.Action
   549  	DDLAction int8
   550  
   551  	// Load represents a LOAD statement
   552  	Load struct {
   553  	}
   554  
   555  	// Show represents a show statement.
   556  	Show struct {
   557  		Internal ShowInternal
   558  	}
   559  
   560  	// Use represents a use statement.
   561  	Use struct {
   562  		DBName IdentifierCS
   563  	}
   564  
   565  	// TxAccessMode is an enum for Transaction Access Mode
   566  	TxAccessMode int8
   567  
   568  	// Begin represents a Begin statement.
   569  	Begin struct {
   570  		TxAccessModes []TxAccessMode
   571  	}
   572  
   573  	// Commit represents a Commit statement.
   574  	Commit struct{}
   575  
   576  	// Rollback represents a Rollback statement.
   577  	Rollback struct{}
   578  
   579  	// SRollback represents a rollback to savepoint statement.
   580  	SRollback struct {
   581  		Name IdentifierCI
   582  	}
   583  
   584  	// Savepoint represents a savepoint statement.
   585  	Savepoint struct {
   586  		Name IdentifierCI
   587  	}
   588  
   589  	// Release represents a release savepoint statement.
   590  	Release struct {
   591  		Name IdentifierCI
   592  	}
   593  
   594  	// CallProc represents a CALL statement
   595  	CallProc struct {
   596  		Name   TableName
   597  		Params Exprs
   598  	}
   599  
   600  	// LockType is an enum for Lock Types
   601  	LockType int8
   602  
   603  	// TableAndLockType contains table and lock association
   604  	TableAndLockType struct {
   605  		Table TableExpr
   606  		Lock  LockType
   607  	}
   608  
   609  	// TableAndLockTypes is a slice of TableAndLockType
   610  	TableAndLockTypes []*TableAndLockType
   611  
   612  	// LockTables represents the lock statement
   613  	LockTables struct {
   614  		Tables TableAndLockTypes
   615  	}
   616  
   617  	// UnlockTables represents the unlock statement
   618  	UnlockTables struct{}
   619  
   620  	// ExplainType is an enum for ExplainStmt.Type
   621  	ExplainType int8
   622  
   623  	// ExplainStmt represents an Explain statement
   624  	ExplainStmt struct {
   625  		Type      ExplainType
   626  		Statement Statement
   627  		Comments  *ParsedComments
   628  	}
   629  
   630  	// VExplainType is an enum for VExplainStmt.Type
   631  	VExplainType int8
   632  
   633  	// VExplainStmt represents an VtExplain statement
   634  	VExplainStmt struct {
   635  		Type      VExplainType
   636  		Statement Statement
   637  		Comments  *ParsedComments
   638  	}
   639  
   640  	// ExplainTab represents the Explain table
   641  	ExplainTab struct {
   642  		Table TableName
   643  		Wild  string
   644  	}
   645  
   646  	// PrepareStmt represents a Prepare Statement
   647  	// More info available on https://dev.mysql.com/doc/refman/8.0/en/sql-prepared-statements.html
   648  	PrepareStmt struct {
   649  		Name      IdentifierCI
   650  		Statement Expr
   651  		Comments  *ParsedComments
   652  	}
   653  
   654  	// ExecuteStmt represents an Execute Statement
   655  	// More info available on https://dev.mysql.com/doc/refman/8.0/en/execute.html
   656  	ExecuteStmt struct {
   657  		Name      IdentifierCI
   658  		Comments  *ParsedComments
   659  		Arguments []*Variable
   660  	}
   661  
   662  	// DeallocateStmt represents a Deallocate Statement
   663  	// More info available on https://dev.mysql.com/doc/refman/8.0/en/deallocate-prepare.html
   664  	DeallocateStmt struct {
   665  		Type     DeallocateStmtType
   666  		Comments *ParsedComments
   667  		Name     IdentifierCI
   668  	}
   669  
   670  	// DeallocateStmtType is an enum to get types of deallocate
   671  	DeallocateStmtType int8
   672  
   673  	// IntervalTypes is an enum to get types of intervals
   674  	IntervalTypes int8
   675  
   676  	// OtherRead represents a DESCRIBE, or EXPLAIN statement.
   677  	// It should be used only as an indicator. It does not contain
   678  	// the full AST for the statement.
   679  	OtherRead struct{}
   680  
   681  	// OtherAdmin represents a misc statement that relies on ADMIN privileges,
   682  	// such as REPAIR, OPTIMIZE, or TRUNCATE statement.
   683  	// It should be used only as an indicator. It does not contain
   684  	// the full AST for the statement.
   685  	OtherAdmin struct{}
   686  
   687  	// CommentOnly represents a query which only has comments
   688  	CommentOnly struct {
   689  		Comments []string
   690  	}
   691  )
   692  
   693  func (*Union) iStatement()               {}
   694  func (*Select) iStatement()              {}
   695  func (*Stream) iStatement()              {}
   696  func (*VStream) iStatement()             {}
   697  func (*Insert) iStatement()              {}
   698  func (*Update) iStatement()              {}
   699  func (*Delete) iStatement()              {}
   700  func (*Set) iStatement()                 {}
   701  func (*DropDatabase) iStatement()        {}
   702  func (*Flush) iStatement()               {}
   703  func (*Show) iStatement()                {}
   704  func (*Use) iStatement()                 {}
   705  func (*Begin) iStatement()               {}
   706  func (*Commit) iStatement()              {}
   707  func (*Rollback) iStatement()            {}
   708  func (*SRollback) iStatement()           {}
   709  func (*Savepoint) iStatement()           {}
   710  func (*Release) iStatement()             {}
   711  func (*OtherRead) iStatement()           {}
   712  func (*OtherAdmin) iStatement()          {}
   713  func (*CommentOnly) iStatement()         {}
   714  func (*Select) iSelectStatement()        {}
   715  func (*Union) iSelectStatement()         {}
   716  func (*Load) iStatement()                {}
   717  func (*CreateDatabase) iStatement()      {}
   718  func (*AlterDatabase) iStatement()       {}
   719  func (*CreateTable) iStatement()         {}
   720  func (*CreateView) iStatement()          {}
   721  func (*AlterView) iStatement()           {}
   722  func (*LockTables) iStatement()          {}
   723  func (*UnlockTables) iStatement()        {}
   724  func (*AlterTable) iStatement()          {}
   725  func (*AlterVschema) iStatement()        {}
   726  func (*AlterMigration) iStatement()      {}
   727  func (*RevertMigration) iStatement()     {}
   728  func (*ShowMigrationLogs) iStatement()   {}
   729  func (*ShowThrottledApps) iStatement()   {}
   730  func (*ShowThrottlerStatus) iStatement() {}
   731  func (*DropTable) iStatement()           {}
   732  func (*DropView) iStatement()            {}
   733  func (*TruncateTable) iStatement()       {}
   734  func (*RenameTable) iStatement()         {}
   735  func (*CallProc) iStatement()            {}
   736  func (*ExplainStmt) iStatement()         {}
   737  func (*VExplainStmt) iStatement()        {}
   738  func (*ExplainTab) iStatement()          {}
   739  func (*PrepareStmt) iStatement()         {}
   740  func (*ExecuteStmt) iStatement()         {}
   741  func (*DeallocateStmt) iStatement()      {}
   742  
   743  func (*CreateView) iDDLStatement()    {}
   744  func (*AlterView) iDDLStatement()     {}
   745  func (*CreateTable) iDDLStatement()   {}
   746  func (*DropTable) iDDLStatement()     {}
   747  func (*DropView) iDDLStatement()      {}
   748  func (*AlterTable) iDDLStatement()    {}
   749  func (*TruncateTable) iDDLStatement() {}
   750  func (*RenameTable) iDDLStatement()   {}
   751  
   752  func (*AddConstraintDefinition) iAlterOption() {}
   753  func (*AddIndexDefinition) iAlterOption()      {}
   754  func (*AddColumns) iAlterOption()              {}
   755  func (AlgorithmValue) iAlterOption()           {}
   756  func (*AlterColumn) iAlterOption()             {}
   757  func (*AlterCheck) iAlterOption()              {}
   758  func (*AlterIndex) iAlterOption()              {}
   759  func (*ChangeColumn) iAlterOption()            {}
   760  func (*ModifyColumn) iAlterOption()            {}
   761  func (*RenameColumn) iAlterOption()            {}
   762  func (*AlterCharset) iAlterOption()            {}
   763  func (*KeyState) iAlterOption()                {}
   764  func (*TablespaceOperation) iAlterOption()     {}
   765  func (*DropColumn) iAlterOption()              {}
   766  func (*DropKey) iAlterOption()                 {}
   767  func (*Force) iAlterOption()                   {}
   768  func (*LockOption) iAlterOption()              {}
   769  func (*OrderByOption) iAlterOption()           {}
   770  func (*RenameTableName) iAlterOption()         {}
   771  func (*RenameIndex) iAlterOption()             {}
   772  func (*Validation) iAlterOption()              {}
   773  func (TableOptions) iAlterOption()             {}
   774  
   775  func (*ExplainStmt) iExplain() {}
   776  func (*ExplainTab) iExplain()  {}
   777  
   778  func (*Delete) iSupportOptimizerHint()  {}
   779  func (*Insert) iSupportOptimizerHint()  {}
   780  func (*Stream) iSupportOptimizerHint()  {}
   781  func (*Update) iSupportOptimizerHint()  {}
   782  func (*VStream) iSupportOptimizerHint() {}
   783  func (*Select) iSupportOptimizerHint()  {}
   784  func (*Union) iSupportOptimizerHint()   {}
   785  
   786  // IsFullyParsed implements the DDLStatement interface
   787  func (*TruncateTable) IsFullyParsed() bool {
   788  	return true
   789  }
   790  
   791  // SetFullyParsed implements the DDLStatement interface
   792  func (*TruncateTable) SetFullyParsed(bool) {}
   793  
   794  // IsFullyParsed implements the DDLStatement interface
   795  func (*RenameTable) IsFullyParsed() bool {
   796  	return true
   797  }
   798  
   799  // SetFullyParsed implements the DDLStatement interface
   800  func (node *RenameTable) SetFullyParsed(fullyParsed bool) {}
   801  
   802  // IsFullyParsed implements the DDLStatement interface
   803  func (node *CreateTable) IsFullyParsed() bool {
   804  	return node.FullyParsed
   805  }
   806  
   807  // SetFullyParsed implements the DDLStatement interface
   808  func (node *CreateTable) SetFullyParsed(fullyParsed bool) {
   809  	node.FullyParsed = fullyParsed
   810  }
   811  
   812  // IsFullyParsed implements the DDLStatement interface
   813  func (node *AlterTable) IsFullyParsed() bool {
   814  	return node.FullyParsed
   815  }
   816  
   817  // SetFullyParsed implements the DDLStatement interface
   818  func (node *AlterTable) SetFullyParsed(fullyParsed bool) {
   819  	node.FullyParsed = fullyParsed
   820  }
   821  
   822  // IsFullyParsed implements the DDLStatement interface
   823  func (node *CreateView) IsFullyParsed() bool {
   824  	return true
   825  }
   826  
   827  // SetFullyParsed implements the DDLStatement interface
   828  func (node *CreateView) SetFullyParsed(fullyParsed bool) {}
   829  
   830  // IsFullyParsed implements the DDLStatement interface
   831  func (node *DropView) IsFullyParsed() bool {
   832  	return true
   833  }
   834  
   835  // SetFullyParsed implements the DDLStatement interface
   836  func (node *DropView) SetFullyParsed(fullyParsed bool) {}
   837  
   838  // IsFullyParsed implements the DDLStatement interface
   839  func (node *DropTable) IsFullyParsed() bool {
   840  	return true
   841  }
   842  
   843  // SetFullyParsed implements the DDLStatement interface
   844  func (node *DropTable) SetFullyParsed(fullyParsed bool) {}
   845  
   846  // IsFullyParsed implements the DDLStatement interface
   847  func (node *AlterView) IsFullyParsed() bool {
   848  	return true
   849  }
   850  
   851  // SetFullyParsed implements the DDLStatement interface
   852  func (node *AlterView) SetFullyParsed(fullyParsed bool) {}
   853  
   854  // IsTemporary implements the DDLStatement interface
   855  func (*TruncateTable) IsTemporary() bool {
   856  	return false
   857  }
   858  
   859  // IsTemporary implements the DDLStatement interface
   860  func (*RenameTable) IsTemporary() bool {
   861  	return false
   862  }
   863  
   864  // IsTemporary implements the DDLStatement interface
   865  func (node *CreateTable) IsTemporary() bool {
   866  	return node.Temp
   867  }
   868  
   869  // IsTemporary implements the DDLStatement interface
   870  func (node *AlterTable) IsTemporary() bool {
   871  	return false
   872  }
   873  
   874  // IsTemporary implements the DDLStatement interface
   875  func (node *CreateView) IsTemporary() bool {
   876  	return false
   877  }
   878  
   879  // IsTemporary implements the DDLStatement interface
   880  func (node *DropView) IsTemporary() bool {
   881  	return false
   882  }
   883  
   884  // IsTemporary implements the DDLStatement interface
   885  func (node *DropTable) IsTemporary() bool {
   886  	return node.Temp
   887  }
   888  
   889  // IsTemporary implements the DDLStatement interface
   890  func (node *AlterView) IsTemporary() bool {
   891  	return false
   892  }
   893  
   894  // GetTable implements the DDLStatement interface
   895  func (node *TruncateTable) GetTable() TableName {
   896  	return node.Table
   897  }
   898  
   899  // GetTable implements the DDLStatement interface
   900  func (node *CreateTable) GetTable() TableName {
   901  	return node.Table
   902  }
   903  
   904  // GetTable implements the DDLStatement interface
   905  func (node *AlterTable) GetTable() TableName {
   906  	return node.Table
   907  }
   908  
   909  // GetTable implements the DDLStatement interface
   910  func (node *CreateView) GetTable() TableName {
   911  	return node.ViewName
   912  }
   913  
   914  // GetTable implements the DDLStatement interface
   915  func (node *AlterView) GetTable() TableName {
   916  	return node.ViewName
   917  }
   918  
   919  // GetTable implements the DDLStatement interface
   920  func (node *DropView) GetTable() TableName {
   921  	return TableName{}
   922  }
   923  
   924  // GetTable implements the DDLStatement interface
   925  func (node *DropTable) GetTable() TableName {
   926  	return TableName{}
   927  }
   928  
   929  // GetTable implements the DDLStatement interface
   930  func (node *RenameTable) GetTable() TableName {
   931  	return TableName{}
   932  }
   933  
   934  // GetAction implements the DDLStatement interface
   935  func (node *TruncateTable) GetAction() DDLAction {
   936  	return TruncateDDLAction
   937  }
   938  
   939  // GetAction implements the DDLStatement interface
   940  func (node *AlterTable) GetAction() DDLAction {
   941  	return AlterDDLAction
   942  }
   943  
   944  // GetAction implements the DDLStatement interface
   945  func (node *CreateTable) GetAction() DDLAction {
   946  	return CreateDDLAction
   947  }
   948  
   949  // GetAction implements the DDLStatement interface
   950  func (node *CreateView) GetAction() DDLAction {
   951  	return CreateDDLAction
   952  }
   953  
   954  // GetAction implements the DDLStatement interface
   955  func (node *AlterView) GetAction() DDLAction {
   956  	return AlterDDLAction
   957  }
   958  
   959  // GetAction implements the DDLStatement interface
   960  func (node *RenameTable) GetAction() DDLAction {
   961  	return RenameDDLAction
   962  }
   963  
   964  // GetAction implements the DDLStatement interface
   965  func (node *DropTable) GetAction() DDLAction {
   966  	return DropDDLAction
   967  }
   968  
   969  // GetAction implements the DDLStatement interface
   970  func (node *DropView) GetAction() DDLAction {
   971  	return DropDDLAction
   972  }
   973  
   974  // GetOptLike implements the DDLStatement interface
   975  func (node *CreateTable) GetOptLike() *OptLike {
   976  	return node.OptLike
   977  }
   978  
   979  // GetOptLike implements the DDLStatement interface
   980  func (node *TruncateTable) GetOptLike() *OptLike {
   981  	return nil
   982  }
   983  
   984  // GetOptLike implements the DDLStatement interface
   985  func (node *RenameTable) GetOptLike() *OptLike {
   986  	return nil
   987  }
   988  
   989  // GetOptLike implements the DDLStatement interface
   990  func (node *AlterTable) GetOptLike() *OptLike {
   991  	return nil
   992  }
   993  
   994  // GetOptLike implements the DDLStatement interface
   995  func (node *CreateView) GetOptLike() *OptLike {
   996  	return nil
   997  }
   998  
   999  // GetOptLike implements the DDLStatement interface
  1000  func (node *AlterView) GetOptLike() *OptLike {
  1001  	return nil
  1002  }
  1003  
  1004  // GetOptLike implements the DDLStatement interface
  1005  func (node *DropTable) GetOptLike() *OptLike {
  1006  	return nil
  1007  }
  1008  
  1009  // GetOptLike implements the DDLStatement interface
  1010  func (node *DropView) GetOptLike() *OptLike {
  1011  	return nil
  1012  }
  1013  
  1014  // GetIfExists implements the DDLStatement interface
  1015  func (node *RenameTable) GetIfExists() bool {
  1016  	return false
  1017  }
  1018  
  1019  // GetIfExists implements the DDLStatement interface
  1020  func (node *CreateTable) GetIfExists() bool {
  1021  	return false
  1022  }
  1023  
  1024  // GetIfExists implements the DDLStatement interface
  1025  func (node *TruncateTable) GetIfExists() bool {
  1026  	return false
  1027  }
  1028  
  1029  // GetIfExists implements the DDLStatement interface
  1030  func (node *AlterTable) GetIfExists() bool {
  1031  	return false
  1032  }
  1033  
  1034  // GetIfExists implements the DDLStatement interface
  1035  func (node *CreateView) GetIfExists() bool {
  1036  	return false
  1037  }
  1038  
  1039  // GetIfExists implements the DDLStatement interface
  1040  func (node *AlterView) GetIfExists() bool {
  1041  	return false
  1042  }
  1043  
  1044  // GetIfExists implements the DDLStatement interface
  1045  func (node *DropTable) GetIfExists() bool {
  1046  	return node.IfExists
  1047  }
  1048  
  1049  // GetIfExists implements the DDLStatement interface
  1050  func (node *DropView) GetIfExists() bool {
  1051  	return node.IfExists
  1052  }
  1053  
  1054  // GetIfNotExists implements the DDLStatement interface
  1055  func (node *RenameTable) GetIfNotExists() bool {
  1056  	return false
  1057  }
  1058  
  1059  // GetIfNotExists implements the DDLStatement interface
  1060  func (node *CreateTable) GetIfNotExists() bool {
  1061  	return node.IfNotExists
  1062  }
  1063  
  1064  // GetIfNotExists implements the DDLStatement interface
  1065  func (node *TruncateTable) GetIfNotExists() bool {
  1066  	return false
  1067  }
  1068  
  1069  // GetIfNotExists implements the DDLStatement interface
  1070  func (node *AlterTable) GetIfNotExists() bool {
  1071  	return false
  1072  }
  1073  
  1074  // GetIfNotExists implements the DDLStatement interface
  1075  func (node *CreateView) GetIfNotExists() bool {
  1076  	return false
  1077  }
  1078  
  1079  // GetIfNotExists implements the DDLStatement interface
  1080  func (node *AlterView) GetIfNotExists() bool {
  1081  	return false
  1082  }
  1083  
  1084  // GetIfNotExists implements the DDLStatement interface
  1085  func (node *DropTable) GetIfNotExists() bool {
  1086  	return false
  1087  }
  1088  
  1089  // GetIfNotExists implements the DDLStatement interface
  1090  func (node *DropView) GetIfNotExists() bool {
  1091  	return false
  1092  }
  1093  
  1094  // GetIsReplace implements the DDLStatement interface
  1095  func (node *RenameTable) GetIsReplace() bool {
  1096  	return false
  1097  }
  1098  
  1099  // GetIsReplace implements the DDLStatement interface
  1100  func (node *CreateTable) GetIsReplace() bool {
  1101  	return false
  1102  }
  1103  
  1104  // GetIsReplace implements the DDLStatement interface
  1105  func (node *TruncateTable) GetIsReplace() bool {
  1106  	return false
  1107  }
  1108  
  1109  // GetIsReplace implements the DDLStatement interface
  1110  func (node *AlterTable) GetIsReplace() bool {
  1111  	return false
  1112  }
  1113  
  1114  // GetIsReplace implements the DDLStatement interface
  1115  func (node *CreateView) GetIsReplace() bool {
  1116  	return node.IsReplace
  1117  }
  1118  
  1119  // GetIsReplace implements the DDLStatement interface
  1120  func (node *AlterView) GetIsReplace() bool {
  1121  	return false
  1122  }
  1123  
  1124  // GetIsReplace implements the DDLStatement interface
  1125  func (node *DropTable) GetIsReplace() bool {
  1126  	return false
  1127  }
  1128  
  1129  // GetIsReplace implements the DDLStatement interface
  1130  func (node *DropView) GetIsReplace() bool {
  1131  	return false
  1132  }
  1133  
  1134  // GetTableSpec implements the DDLStatement interface
  1135  func (node *CreateTable) GetTableSpec() *TableSpec {
  1136  	return node.TableSpec
  1137  }
  1138  
  1139  // GetTableSpec implements the DDLStatement interface
  1140  func (node *RenameTable) GetTableSpec() *TableSpec {
  1141  	return nil
  1142  }
  1143  
  1144  // GetTableSpec implements the DDLStatement interface
  1145  func (node *TruncateTable) GetTableSpec() *TableSpec {
  1146  	return nil
  1147  }
  1148  
  1149  // GetTableSpec implements the DDLStatement interface
  1150  func (node *AlterTable) GetTableSpec() *TableSpec {
  1151  	return nil
  1152  }
  1153  
  1154  // GetTableSpec implements the DDLStatement interface
  1155  func (node *CreateView) GetTableSpec() *TableSpec {
  1156  	return nil
  1157  }
  1158  
  1159  // GetTableSpec implements the DDLStatement interface
  1160  func (node *AlterView) GetTableSpec() *TableSpec {
  1161  	return nil
  1162  }
  1163  
  1164  // GetTableSpec implements the DDLStatement interface
  1165  func (node *DropTable) GetTableSpec() *TableSpec {
  1166  	return nil
  1167  }
  1168  
  1169  // GetTableSpec implements the DDLStatement interface
  1170  func (node *DropView) GetTableSpec() *TableSpec {
  1171  	return nil
  1172  }
  1173  
  1174  // GetFromTables implements the DDLStatement interface
  1175  func (node *RenameTable) GetFromTables() TableNames {
  1176  	var fromTables TableNames
  1177  	for _, pair := range node.TablePairs {
  1178  		fromTables = append(fromTables, pair.FromTable)
  1179  	}
  1180  	return fromTables
  1181  }
  1182  
  1183  // GetFromTables implements the DDLStatement interface
  1184  func (node *TruncateTable) GetFromTables() TableNames {
  1185  	return nil
  1186  }
  1187  
  1188  // GetFromTables implements the DDLStatement interface
  1189  func (node *AlterTable) GetFromTables() TableNames {
  1190  	return nil
  1191  }
  1192  
  1193  // GetFromTables implements the DDLStatement interface
  1194  func (node *CreateTable) GetFromTables() TableNames {
  1195  	return nil
  1196  }
  1197  
  1198  // GetFromTables implements the DDLStatement interface
  1199  func (node *CreateView) GetFromTables() TableNames {
  1200  	return nil
  1201  }
  1202  
  1203  // GetFromTables implements the DDLStatement interface
  1204  func (node *DropTable) GetFromTables() TableNames {
  1205  	return node.FromTables
  1206  }
  1207  
  1208  // GetFromTables implements the DDLStatement interface
  1209  func (node *DropView) GetFromTables() TableNames {
  1210  	return node.FromTables
  1211  }
  1212  
  1213  // GetFromTables implements the DDLStatement interface
  1214  func (node *AlterView) GetFromTables() TableNames {
  1215  	return nil
  1216  }
  1217  
  1218  // SetFromTables implements DDLStatement.
  1219  func (node *RenameTable) SetFromTables(tables TableNames) {
  1220  	if len(node.TablePairs) != len(tables) {
  1221  		return
  1222  	}
  1223  	for i := range node.TablePairs {
  1224  		node.TablePairs[i].FromTable = tables[i]
  1225  	}
  1226  }
  1227  
  1228  // SetFromTables implements DDLStatement.
  1229  func (node *TruncateTable) SetFromTables(tables TableNames) {
  1230  	// irrelevant
  1231  }
  1232  
  1233  // SetFromTables implements DDLStatement.
  1234  func (node *AlterTable) SetFromTables(tables TableNames) {
  1235  	// irrelevant
  1236  }
  1237  
  1238  // SetFromTables implements DDLStatement.
  1239  func (node *CreateTable) SetFromTables(tables TableNames) {
  1240  	// irrelevant
  1241  }
  1242  
  1243  // SetFromTables implements DDLStatement.
  1244  func (node *CreateView) SetFromTables(tables TableNames) {
  1245  	// irrelevant
  1246  }
  1247  
  1248  // SetFromTables implements DDLStatement.
  1249  func (node *DropTable) SetFromTables(tables TableNames) {
  1250  	node.FromTables = tables
  1251  }
  1252  
  1253  // SetFromTables implements DDLStatement.
  1254  func (node *DropView) SetFromTables(tables TableNames) {
  1255  	node.FromTables = tables
  1256  }
  1257  
  1258  // SetFromTables implements DDLStatement.
  1259  func (node *AlterView) SetFromTables(tables TableNames) {
  1260  	// irrelevant
  1261  }
  1262  
  1263  // SetComments implements Commented interface.
  1264  func (node *RenameTable) SetComments(comments Comments) {
  1265  	// irrelevant
  1266  }
  1267  
  1268  // SetComments implements Commented interface.
  1269  func (node *TruncateTable) SetComments(comments Comments) {
  1270  	// irrelevant
  1271  }
  1272  
  1273  // SetComments implements Commented interface.
  1274  func (node *AlterTable) SetComments(comments Comments) {
  1275  	node.Comments = comments.Parsed()
  1276  }
  1277  
  1278  // SetComments implements Commented interface.
  1279  func (node *ExplainStmt) SetComments(comments Comments) {
  1280  	node.Comments = comments.Parsed()
  1281  }
  1282  
  1283  // SetComments implements Commented interface.
  1284  func (node *VExplainStmt) SetComments(comments Comments) {
  1285  	node.Comments = comments.Parsed()
  1286  }
  1287  
  1288  // SetComments implements Commented interface.
  1289  func (node *CreateTable) SetComments(comments Comments) {
  1290  	node.Comments = comments.Parsed()
  1291  }
  1292  
  1293  // SetComments implements Commented interface.
  1294  func (node *CreateView) SetComments(comments Comments) {
  1295  	node.Comments = comments.Parsed()
  1296  }
  1297  
  1298  // SetComments implements Commented interface.
  1299  func (node *DropTable) SetComments(comments Comments) {
  1300  	node.Comments = comments.Parsed()
  1301  }
  1302  
  1303  // SetComments implements Commented interface.
  1304  func (node *DropView) SetComments(comments Comments) {
  1305  	node.Comments = comments.Parsed()
  1306  }
  1307  
  1308  // SetComments implements Commented interface.
  1309  func (node *AlterView) SetComments(comments Comments) {
  1310  	node.Comments = comments.Parsed()
  1311  }
  1312  
  1313  // SetComments for RevertMigration, does not implement DDLStatement
  1314  func (node *RevertMigration) SetComments(comments Comments) {
  1315  	node.Comments = comments.Parsed()
  1316  }
  1317  
  1318  // SetComments for Delete
  1319  func (node *Delete) SetComments(comments Comments) {
  1320  	node.Comments = comments.Parsed()
  1321  }
  1322  
  1323  // SetComments for Insert
  1324  func (node *Insert) SetComments(comments Comments) {
  1325  	node.Comments = comments.Parsed()
  1326  }
  1327  
  1328  // SetComments for Stream
  1329  func (node *Stream) SetComments(comments Comments) {
  1330  	node.Comments = comments.Parsed()
  1331  }
  1332  
  1333  // SetComments for Update
  1334  func (node *Update) SetComments(comments Comments) {
  1335  	node.Comments = comments.Parsed()
  1336  }
  1337  
  1338  // SetComments for VStream
  1339  func (node *VStream) SetComments(comments Comments) {
  1340  	node.Comments = comments.Parsed()
  1341  }
  1342  
  1343  // GetParsedComments implements Commented interface.
  1344  func (node *RenameTable) GetParsedComments() *ParsedComments {
  1345  	// irrelevant
  1346  	return nil
  1347  }
  1348  
  1349  // GetParsedComments implements Commented interface.
  1350  func (node *TruncateTable) GetParsedComments() *ParsedComments {
  1351  	// irrelevant
  1352  	return nil
  1353  }
  1354  
  1355  // GetParsedComments implements Commented interface.
  1356  func (node *AlterTable) GetParsedComments() *ParsedComments {
  1357  	return node.Comments
  1358  }
  1359  
  1360  // GetParsedComments implements Commented interface.
  1361  func (node *ExplainStmt) GetParsedComments() *ParsedComments {
  1362  	return node.Comments
  1363  }
  1364  
  1365  // GetParsedComments implements Commented interface.
  1366  func (node *VExplainStmt) GetParsedComments() *ParsedComments {
  1367  	return node.Comments
  1368  }
  1369  
  1370  // GetParsedComments implements Commented interface.
  1371  func (node *CreateTable) GetParsedComments() *ParsedComments {
  1372  	return node.Comments
  1373  }
  1374  
  1375  // GetParsedComments implements Commented interface.
  1376  func (node *CreateView) GetParsedComments() *ParsedComments {
  1377  	return node.Comments
  1378  }
  1379  
  1380  // GetParsedComments implements Commented interface.
  1381  func (node *DropTable) GetParsedComments() *ParsedComments {
  1382  	return node.Comments
  1383  }
  1384  
  1385  // GetParsedComments implements Commented interface.
  1386  func (node *DropView) GetParsedComments() *ParsedComments {
  1387  	return node.Comments
  1388  }
  1389  
  1390  // GetParsedComments implements Commented interface.
  1391  func (node *AlterView) GetParsedComments() *ParsedComments {
  1392  	return node.Comments
  1393  }
  1394  
  1395  // GetParsedComments implements SupportOptimizerHint.
  1396  func (node *Delete) GetParsedComments() *ParsedComments {
  1397  	return node.Comments
  1398  }
  1399  
  1400  // GetParsedComments implements Insert.
  1401  func (node *Insert) GetParsedComments() *ParsedComments {
  1402  	return node.Comments
  1403  }
  1404  
  1405  // GetParsedComments implements Stream.
  1406  func (node *Stream) GetParsedComments() *ParsedComments {
  1407  	return node.Comments
  1408  }
  1409  
  1410  // GetParsedComments implements Update.
  1411  func (node *Update) GetParsedComments() *ParsedComments {
  1412  	return node.Comments
  1413  }
  1414  
  1415  // GetParsedComments implements VStream.
  1416  func (node *VStream) GetParsedComments() *ParsedComments {
  1417  	return node.Comments
  1418  }
  1419  
  1420  // GetToTables implements the DDLStatement interface
  1421  func (node *RenameTable) GetToTables() TableNames {
  1422  	var toTables TableNames
  1423  	for _, pair := range node.TablePairs {
  1424  		toTables = append(toTables, pair.ToTable)
  1425  	}
  1426  	return toTables
  1427  }
  1428  
  1429  // GetToTables implements the DDLStatement interface
  1430  func (node *TruncateTable) GetToTables() TableNames {
  1431  	return nil
  1432  }
  1433  
  1434  // GetToTables implements the DDLStatement interface
  1435  func (node *AlterTable) GetToTables() TableNames {
  1436  	for _, option := range node.AlterOptions {
  1437  		switch altOption := option.(type) {
  1438  		case *RenameTableName:
  1439  			return TableNames{altOption.Table}
  1440  		}
  1441  	}
  1442  	return nil
  1443  }
  1444  
  1445  // GetToTables implements the DDLStatement interface
  1446  func (node *CreateView) GetToTables() TableNames {
  1447  	return nil
  1448  }
  1449  
  1450  // GetToTables implements the DDLStatement interface
  1451  func (node *AlterView) GetToTables() TableNames {
  1452  	return nil
  1453  }
  1454  
  1455  // GetToTables implements the DDLStatement interface
  1456  func (node *CreateTable) GetToTables() TableNames {
  1457  	return nil
  1458  }
  1459  
  1460  // GetToTables implements the DDLStatement interface
  1461  func (node *DropTable) GetToTables() TableNames {
  1462  	return nil
  1463  }
  1464  
  1465  // GetToTables implements the DDLStatement interface
  1466  func (node *DropView) GetToTables() TableNames {
  1467  	return nil
  1468  }
  1469  
  1470  // AffectedTables returns the list table names affected by the DDLStatement.
  1471  func (node *RenameTable) AffectedTables() TableNames {
  1472  	list := make(TableNames, 0, 2*len(node.TablePairs))
  1473  	for _, pair := range node.TablePairs {
  1474  		list = append(list, pair.FromTable)
  1475  		list = append(list, pair.ToTable)
  1476  	}
  1477  	return list
  1478  }
  1479  
  1480  // AffectedTables returns the list table names affected by the DDLStatement.
  1481  func (node *AlterTable) AffectedTables() TableNames {
  1482  	affectedTables := TableNames{node.Table}
  1483  	for _, option := range node.AlterOptions {
  1484  		switch altOption := option.(type) {
  1485  		case *RenameTableName:
  1486  			affectedTables = append(affectedTables, altOption.Table)
  1487  		}
  1488  	}
  1489  	return affectedTables
  1490  }
  1491  
  1492  // AffectedTables implements DDLStatement.
  1493  func (node *TruncateTable) AffectedTables() TableNames {
  1494  	return TableNames{node.Table}
  1495  }
  1496  
  1497  // AffectedTables implements DDLStatement.
  1498  func (node *CreateTable) AffectedTables() TableNames {
  1499  	return TableNames{node.Table}
  1500  }
  1501  
  1502  // AffectedTables implements DDLStatement.
  1503  func (node *CreateView) AffectedTables() TableNames {
  1504  	return TableNames{node.ViewName}
  1505  }
  1506  
  1507  // AffectedTables implements DDLStatement.
  1508  func (node *AlterView) AffectedTables() TableNames {
  1509  	return TableNames{node.ViewName}
  1510  }
  1511  
  1512  // AffectedTables returns the list table names affected by the DDLStatement.
  1513  func (node *DropTable) AffectedTables() TableNames {
  1514  	return node.FromTables
  1515  }
  1516  
  1517  // AffectedTables returns the list table names affected by the DDLStatement.
  1518  func (node *DropView) AffectedTables() TableNames {
  1519  	return node.FromTables
  1520  }
  1521  
  1522  // SetTable implements DDLStatement.
  1523  func (node *TruncateTable) SetTable(qualifier string, name string) {
  1524  	node.Table.Qualifier = NewIdentifierCS(qualifier)
  1525  	node.Table.Name = NewIdentifierCS(name)
  1526  }
  1527  
  1528  // SetTable implements DDLStatement.
  1529  func (node *AlterTable) SetTable(qualifier string, name string) {
  1530  	node.Table.Qualifier = NewIdentifierCS(qualifier)
  1531  	node.Table.Name = NewIdentifierCS(name)
  1532  }
  1533  
  1534  // SetTable implements DDLStatement.
  1535  func (node *CreateTable) SetTable(qualifier string, name string) {
  1536  	node.Table.Qualifier = NewIdentifierCS(qualifier)
  1537  	node.Table.Name = NewIdentifierCS(name)
  1538  }
  1539  
  1540  // SetTable implements DDLStatement.
  1541  func (node *CreateView) SetTable(qualifier string, name string) {
  1542  	node.ViewName.Qualifier = NewIdentifierCS(qualifier)
  1543  	node.ViewName.Name = NewIdentifierCS(name)
  1544  }
  1545  
  1546  // SetTable implements DDLStatement.
  1547  func (node *AlterView) SetTable(qualifier string, name string) {
  1548  	node.ViewName.Qualifier = NewIdentifierCS(qualifier)
  1549  	node.ViewName.Name = NewIdentifierCS(name)
  1550  }
  1551  
  1552  // SetTable implements DDLStatement.
  1553  func (node *RenameTable) SetTable(qualifier string, name string) {}
  1554  
  1555  // SetTable implements DDLStatement.
  1556  func (node *DropTable) SetTable(qualifier string, name string) {}
  1557  
  1558  // SetTable implements DDLStatement.
  1559  func (node *DropView) SetTable(qualifier string, name string) {}
  1560  
  1561  func (*DropDatabase) iDBDDLStatement()   {}
  1562  func (*CreateDatabase) iDBDDLStatement() {}
  1563  func (*AlterDatabase) iDBDDLStatement()  {}
  1564  
  1565  // IsFullyParsed implements the DBDDLStatement interface
  1566  func (node *DropDatabase) IsFullyParsed() bool {
  1567  	return true
  1568  }
  1569  
  1570  // SetFullyParsed implements the DBDDLStatement interface
  1571  func (node *DropDatabase) SetFullyParsed(fullyParsed bool) {}
  1572  
  1573  // IsFullyParsed implements the DBDDLStatement interface
  1574  func (node *CreateDatabase) IsFullyParsed() bool {
  1575  	return node.FullyParsed
  1576  }
  1577  
  1578  // SetFullyParsed implements the DBDDLStatement interface
  1579  func (node *CreateDatabase) SetFullyParsed(fullyParsed bool) {
  1580  	node.FullyParsed = fullyParsed
  1581  }
  1582  
  1583  // IsFullyParsed implements the DBDDLStatement interface
  1584  func (node *AlterDatabase) IsFullyParsed() bool {
  1585  	return node.FullyParsed
  1586  }
  1587  
  1588  // SetFullyParsed implements the DBDDLStatement interface
  1589  func (node *AlterDatabase) SetFullyParsed(fullyParsed bool) {
  1590  	node.FullyParsed = fullyParsed
  1591  }
  1592  
  1593  // GetDatabaseName implements the DBDDLStatement interface
  1594  func (node *DropDatabase) GetDatabaseName() string {
  1595  	return node.DBName.String()
  1596  }
  1597  
  1598  // GetDatabaseName implements the DBDDLStatement interface
  1599  func (node *CreateDatabase) GetDatabaseName() string {
  1600  	return node.DBName.String()
  1601  }
  1602  
  1603  // GetDatabaseName implements the DBDDLStatement interface
  1604  func (node *AlterDatabase) GetDatabaseName() string {
  1605  	return node.DBName.String()
  1606  }
  1607  
  1608  type (
  1609  
  1610  	// ShowInternal will represent all the show statement types.
  1611  	ShowInternal interface {
  1612  		isShowInternal()
  1613  		SQLNode
  1614  	}
  1615  
  1616  	// ShowCommandType represents the show statement type.
  1617  	ShowCommandType int8
  1618  
  1619  	// ShowBasic is of ShowInternal type, holds Simple SHOW queries with a filter.
  1620  	ShowBasic struct {
  1621  		Command ShowCommandType
  1622  		Full    bool
  1623  		Tbl     TableName
  1624  		DbName  IdentifierCS
  1625  		Filter  *ShowFilter
  1626  	}
  1627  
  1628  	// ShowCreate is of ShowInternal type, holds SHOW CREATE queries.
  1629  	ShowCreate struct {
  1630  		Command ShowCommandType
  1631  		Op      TableName
  1632  	}
  1633  
  1634  	// ShowOther is of ShowInternal type, holds show queries that is not handled specially.
  1635  	ShowOther struct {
  1636  		Command string
  1637  	}
  1638  )
  1639  
  1640  func (*ShowBasic) isShowInternal()  {}
  1641  func (*ShowCreate) isShowInternal() {}
  1642  func (*ShowOther) isShowInternal()  {}
  1643  
  1644  // InsertRows represents the rows for an INSERT statement.
  1645  type InsertRows interface {
  1646  	iInsertRows()
  1647  	SQLNode
  1648  }
  1649  
  1650  func (*Select) iInsertRows() {}
  1651  func (*Union) iInsertRows()  {}
  1652  func (Values) iInsertRows()  {}
  1653  
  1654  // OptLike works for create table xxx like xxx
  1655  type OptLike struct {
  1656  	LikeTable TableName
  1657  }
  1658  
  1659  // PartitionSpec describe partition actions (for alter statements)
  1660  type PartitionSpec struct {
  1661  	Action            PartitionSpecAction
  1662  	Names             Partitions
  1663  	Number            *Literal
  1664  	IsAll             bool
  1665  	TableName         TableName
  1666  	WithoutValidation bool
  1667  	Definitions       []*PartitionDefinition
  1668  }
  1669  
  1670  // PartitionSpecAction is an enum for PartitionSpec.Action
  1671  type PartitionSpecAction int8
  1672  
  1673  // PartitionDefinition describes a very minimal partition definition
  1674  type PartitionDefinition struct {
  1675  	Name    IdentifierCI
  1676  	Options *PartitionDefinitionOptions
  1677  }
  1678  
  1679  type PartitionDefinitionOptions struct {
  1680  	ValueRange              *PartitionValueRange
  1681  	Comment                 *Literal
  1682  	Engine                  *PartitionEngine
  1683  	DataDirectory           *Literal
  1684  	IndexDirectory          *Literal
  1685  	MaxRows                 *int
  1686  	MinRows                 *int
  1687  	TableSpace              string
  1688  	SubPartitionDefinitions SubPartitionDefinitions
  1689  }
  1690  
  1691  // Subpartition Definition Corresponds to the subpartition_definition option of partition_definition
  1692  type SubPartitionDefinition struct {
  1693  	Name    IdentifierCI
  1694  	Options *SubPartitionDefinitionOptions
  1695  }
  1696  
  1697  // This is a list of SubPartitionDefinition
  1698  type SubPartitionDefinitions []*SubPartitionDefinition
  1699  
  1700  // Different options/attributes that can be provided to a subpartition_definition.
  1701  type SubPartitionDefinitionOptions struct {
  1702  	Comment        *Literal
  1703  	Engine         *PartitionEngine
  1704  	DataDirectory  *Literal
  1705  	IndexDirectory *Literal
  1706  	MaxRows        *int
  1707  	MinRows        *int
  1708  	TableSpace     string
  1709  }
  1710  
  1711  // PartitionValueRangeType is an enum for PartitionValueRange.Type
  1712  type PartitionValueRangeType int8
  1713  
  1714  type PartitionValueRange struct {
  1715  	Type     PartitionValueRangeType
  1716  	Range    ValTuple
  1717  	Maxvalue bool
  1718  }
  1719  
  1720  type PartitionEngine struct {
  1721  	Storage bool
  1722  	Name    string
  1723  }
  1724  
  1725  // PartitionByType is an enum storing how we are partitioning a table
  1726  type PartitionByType int8
  1727  
  1728  // PartitionOption describes partitioning control (for create table statements)
  1729  type PartitionOption struct {
  1730  	Type         PartitionByType
  1731  	IsLinear     bool
  1732  	KeyAlgorithm int
  1733  	ColList      Columns
  1734  	Expr         Expr
  1735  	Partitions   int
  1736  	SubPartition *SubPartition
  1737  	Definitions  []*PartitionDefinition
  1738  }
  1739  
  1740  // SubPartition describes subpartitions control
  1741  type SubPartition struct {
  1742  	Type          PartitionByType
  1743  	IsLinear      bool
  1744  	KeyAlgorithm  int
  1745  	ColList       Columns
  1746  	Expr          Expr
  1747  	SubPartitions int
  1748  }
  1749  
  1750  // TableOptions specifies a list of table options
  1751  type TableOptions []*TableOption
  1752  
  1753  // TableSpec describes the structure of a table from a CREATE TABLE statement
  1754  type TableSpec struct {
  1755  	Columns         []*ColumnDefinition
  1756  	Indexes         []*IndexDefinition
  1757  	Constraints     []*ConstraintDefinition
  1758  	Options         TableOptions
  1759  	PartitionOption *PartitionOption
  1760  }
  1761  
  1762  // ColumnDefinition describes a column in a CREATE TABLE statement
  1763  type ColumnDefinition struct {
  1764  	Name IdentifierCI
  1765  	Type *ColumnType
  1766  }
  1767  
  1768  // ColumnType represents a sql type in a CREATE TABLE statement
  1769  // All optional fields are nil if not specified
  1770  type ColumnType struct {
  1771  	// The base type string
  1772  	Type string
  1773  
  1774  	// Generic field options.
  1775  	Options *ColumnTypeOptions
  1776  
  1777  	// Numeric field options
  1778  	Length   *Literal
  1779  	Unsigned bool
  1780  	Zerofill bool
  1781  	Scale    *Literal
  1782  
  1783  	// Text field options
  1784  	Charset ColumnCharset
  1785  
  1786  	// Enum values
  1787  	EnumValues []string
  1788  }
  1789  
  1790  // ColumnCharset exists because in the type definition it's possible
  1791  // to add the binary marker for a character set, so we need to track
  1792  // when this happens. We can't at the point of where we parse things
  1793  // backfill this with an existing collation. Firstly because we don't
  1794  // have access to that during parsing, but more importantly because
  1795  // it would generate syntax that is invalid.
  1796  //
  1797  // Not in all cases where a binary marker is allowed, a collation is
  1798  // allowed. See https://dev.mysql.com/doc/refman/8.0/en/cast-functions.html
  1799  // specifically under Character Set Conversions.
  1800  type ColumnCharset struct {
  1801  	Name   string
  1802  	Binary bool
  1803  }
  1804  
  1805  // ColumnStorage is an enum that defines the type of storage.
  1806  type ColumnStorage int
  1807  
  1808  // ColumnFormat is an enum that defines the type of storage.
  1809  type ColumnFormat int
  1810  
  1811  // ColumnTypeOptions are generic field options for a column type
  1812  type ColumnTypeOptions struct {
  1813  	/* We need Null to be *bool to distinguish 3 cases -
  1814  	1. When Not Null is specified (Null = false)
  1815  	2. When Null is specified (Null = true)
  1816  	3. When nothing is specified (Null = nil)
  1817  	The complexity arises from the fact that we do not know whether the column will be nullable or not if nothing is specified.
  1818  	Therefore we do not know whether the column is nullable or not in case 3.
  1819  	*/
  1820  	Null          *bool
  1821  	Autoincrement bool
  1822  	Default       Expr
  1823  	OnUpdate      Expr
  1824  	As            Expr
  1825  	Comment       *Literal
  1826  	Storage       ColumnStorage
  1827  	Collate       string
  1828  	// Reference stores a foreign key constraint for the given column
  1829  	Reference *ReferenceDefinition
  1830  
  1831  	// Key specification
  1832  	KeyOpt ColumnKeyOption
  1833  
  1834  	// Stores the tri state of having either VISIBLE, INVISIBLE or nothing specified
  1835  	// on the column. In case of nothing, this is nil, when VISIBLE is set it's false
  1836  	// and only when INVISIBLE is set does the pointer value return true.
  1837  	Invisible *bool
  1838  
  1839  	// Storage format for this specific column. This is NDB specific, but the parser
  1840  	// still allows for it and ignores it for other storage engines. So we also should
  1841  	// parse it but it's then not used anywhere.
  1842  	Format ColumnFormat
  1843  
  1844  	// EngineAttribute is a new attribute not used for anything yet, but accepted
  1845  	// since 8.0.23 in the MySQL parser.
  1846  	EngineAttribute *Literal
  1847  
  1848  	// SecondaryEngineAttribute is a new attribute not used for anything yet, but accepted
  1849  	// since 8.0.23 in the MySQL parser.
  1850  	SecondaryEngineAttribute *Literal
  1851  
  1852  	// SRID is an attribute that indiciates the spatial reference system.
  1853  	//
  1854  	// https://dev.mysql.com/doc/refman/8.0/en/spatial-type-overview.html
  1855  	SRID *Literal
  1856  }
  1857  
  1858  // IndexDefinition describes an index in a CREATE TABLE statement
  1859  type IndexDefinition struct {
  1860  	Info    *IndexInfo
  1861  	Columns []*IndexColumn
  1862  	Options []*IndexOption
  1863  }
  1864  
  1865  // IndexInfo describes the name and type of an index in a CREATE TABLE statement
  1866  type IndexInfo struct {
  1867  	Type           string
  1868  	Name           IdentifierCI
  1869  	ConstraintName IdentifierCI
  1870  	Primary        bool
  1871  	Spatial        bool
  1872  	Fulltext       bool
  1873  	Unique         bool
  1874  }
  1875  
  1876  // VindexSpec defines a vindex for a CREATE VINDEX or DROP VINDEX statement
  1877  type VindexSpec struct {
  1878  	Name   IdentifierCI
  1879  	Type   IdentifierCI
  1880  	Params []VindexParam
  1881  }
  1882  
  1883  // AutoIncSpec defines and autoincrement value for a ADD AUTO_INCREMENT statement
  1884  type AutoIncSpec struct {
  1885  	Column   IdentifierCI
  1886  	Sequence TableName
  1887  }
  1888  
  1889  // VindexParam defines a key/value parameter for a CREATE VINDEX statement
  1890  type VindexParam struct {
  1891  	Key IdentifierCI
  1892  	Val string
  1893  }
  1894  
  1895  // ConstraintDefinition describes a constraint in a CREATE TABLE statement
  1896  type ConstraintDefinition struct {
  1897  	Name    IdentifierCI
  1898  	Details ConstraintInfo
  1899  }
  1900  
  1901  type (
  1902  	// ConstraintInfo details a constraint in a CREATE TABLE statement
  1903  	ConstraintInfo interface {
  1904  		SQLNode
  1905  		iConstraintInfo()
  1906  	}
  1907  
  1908  	// ForeignKeyDefinition describes a foreign key in a CREATE TABLE statement
  1909  	ForeignKeyDefinition struct {
  1910  		Source              Columns
  1911  		IndexName           IdentifierCI
  1912  		ReferenceDefinition *ReferenceDefinition
  1913  	}
  1914  
  1915  	// ReferenceDefinition describes the referenced tables and columns that the foreign key references
  1916  	ReferenceDefinition struct {
  1917  		ReferencedTable   TableName
  1918  		ReferencedColumns Columns
  1919  		Match             MatchAction
  1920  		OnDelete          ReferenceAction
  1921  		OnUpdate          ReferenceAction
  1922  	}
  1923  
  1924  	// CheckConstraintDefinition describes a check constraint in a CREATE TABLE statement
  1925  	CheckConstraintDefinition struct {
  1926  		Expr     Expr
  1927  		Enforced bool
  1928  	}
  1929  )
  1930  
  1931  // ShowFilter is show tables filter
  1932  type ShowFilter struct {
  1933  	Like   string
  1934  	Filter Expr
  1935  }
  1936  
  1937  // Comments represents a list of comments.
  1938  type Comments []string
  1939  
  1940  func (c Comments) Parsed() *ParsedComments {
  1941  	if len(c) == 0 {
  1942  		return nil
  1943  	}
  1944  	return &ParsedComments{comments: c}
  1945  }
  1946  
  1947  type ParsedComments struct {
  1948  	comments    Comments
  1949  	_directives *CommentDirectives
  1950  }
  1951  
  1952  // SelectExprs represents SELECT expressions.
  1953  type SelectExprs []SelectExpr
  1954  
  1955  type (
  1956  	// SelectExpr represents a SELECT expression.
  1957  	SelectExpr interface {
  1958  		iSelectExpr()
  1959  		SQLNode
  1960  	}
  1961  
  1962  	// StarExpr defines a '*' or 'table.*' expression.
  1963  	StarExpr struct {
  1964  		TableName TableName
  1965  	}
  1966  
  1967  	// AliasedExpr defines an aliased SELECT expression.
  1968  	AliasedExpr struct {
  1969  		Expr Expr
  1970  		As   IdentifierCI
  1971  	}
  1972  
  1973  	// Nextval defines the NEXT VALUE expression.
  1974  	Nextval struct {
  1975  		Expr Expr
  1976  	}
  1977  )
  1978  
  1979  func (*StarExpr) iSelectExpr()    {}
  1980  func (*AliasedExpr) iSelectExpr() {}
  1981  func (*Nextval) iSelectExpr()     {}
  1982  
  1983  // Columns represents an insert column list.
  1984  type Columns []IdentifierCI
  1985  
  1986  // Partitions is a type alias for Columns so we can handle printing efficiently
  1987  type Partitions Columns
  1988  
  1989  // TableExprs represents a list of table expressions.
  1990  type TableExprs []TableExpr
  1991  
  1992  type (
  1993  	// TableExpr represents a table expression.
  1994  	TableExpr interface {
  1995  		iTableExpr()
  1996  		SQLNode
  1997  	}
  1998  
  1999  	// AliasedTableExpr represents a table expression
  2000  	// coupled with an optional alias or index hint.
  2001  	// If As is empty, no alias was used.
  2002  	AliasedTableExpr struct {
  2003  		Expr       SimpleTableExpr
  2004  		Partitions Partitions
  2005  		As         IdentifierCS
  2006  		Hints      IndexHints
  2007  		Columns    Columns
  2008  	}
  2009  
  2010  	// JoinTableExpr represents a TableExpr that's a JOIN operation.
  2011  	JoinTableExpr struct {
  2012  		LeftExpr  TableExpr
  2013  		Join      JoinType
  2014  		RightExpr TableExpr
  2015  		Condition *JoinCondition
  2016  	}
  2017  
  2018  	// JoinType represents the type of Join for JoinTableExpr
  2019  	JoinType int8
  2020  
  2021  	// ParenTableExpr represents a parenthesized list of TableExpr.
  2022  	ParenTableExpr struct {
  2023  		Exprs TableExprs
  2024  	}
  2025  )
  2026  
  2027  func (*AliasedTableExpr) iTableExpr() {}
  2028  func (*ParenTableExpr) iTableExpr()   {}
  2029  func (*JoinTableExpr) iTableExpr()    {}
  2030  func (*JSONTableExpr) iTableExpr()    {}
  2031  
  2032  type (
  2033  	// SimpleTableExpr represents a simple table expression.
  2034  	SimpleTableExpr interface {
  2035  		iSimpleTableExpr()
  2036  		SQLNode
  2037  	}
  2038  
  2039  	// TableName represents a table  name.
  2040  	// Qualifier, if specified, represents a database or keyspace.
  2041  	// TableName is a value struct whose fields are case sensitive.
  2042  	// This means two TableName vars can be compared for equality
  2043  	// and a TableName can also be used as key in a map.
  2044  	TableName struct {
  2045  		Name, Qualifier IdentifierCS
  2046  	}
  2047  
  2048  	// Subquery represents a subquery used as an value expression.
  2049  	Subquery struct {
  2050  		Select SelectStatement
  2051  	}
  2052  
  2053  	// DerivedTable represents a subquery used as a table expression.
  2054  	DerivedTable struct {
  2055  		Lateral bool
  2056  		Select  SelectStatement
  2057  	}
  2058  )
  2059  
  2060  func (TableName) iSimpleTableExpr()     {}
  2061  func (*DerivedTable) iSimpleTableExpr() {}
  2062  
  2063  // TableNames is a list of TableName.
  2064  type TableNames []TableName
  2065  
  2066  // JoinCondition represents the join conditions (either a ON or USING clause)
  2067  // of a JoinTableExpr.
  2068  type JoinCondition struct {
  2069  	On    Expr
  2070  	Using Columns
  2071  }
  2072  
  2073  // IndexHint represents an index hint.
  2074  // More information available on https://dev.mysql.com/doc/refman/8.0/en/index-hints.html
  2075  type IndexHint struct {
  2076  	Type    IndexHintType
  2077  	ForType IndexHintForType
  2078  	Indexes []IdentifierCI
  2079  }
  2080  
  2081  // IndexHints represents a list of index hints.
  2082  type IndexHints []*IndexHint
  2083  
  2084  // IndexHintType is an enum for IndexHint.Type
  2085  type IndexHintType int8
  2086  
  2087  // IndexHintForType is an enum for FOR specified in an IndexHint
  2088  type IndexHintForType int8
  2089  
  2090  // Where represents a WHERE or HAVING clause.
  2091  type Where struct {
  2092  	Type WhereType
  2093  	Expr Expr
  2094  }
  2095  
  2096  // WhereType is an enum for Where.Type
  2097  type WhereType int8
  2098  
  2099  // TrimFuncExpr represents a TRIM function
  2100  // More information available on https://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_trim
  2101  type TrimFuncExpr struct {
  2102  	TrimFuncType TrimFuncType
  2103  	Type         TrimType
  2104  	TrimArg      Expr
  2105  	StringArg    Expr
  2106  }
  2107  
  2108  // TrimFuncType is an enum to get types of TrimFunc.
  2109  // TrimFunc stand for one of the following: LTRIM, RTRIM, TRIM
  2110  type TrimFuncType int8
  2111  
  2112  // TrimType is an enum to get types of Trim
  2113  type TrimType int8
  2114  
  2115  // Types for window functions
  2116  type (
  2117  
  2118  	// WindowSpecification represents window_spec
  2119  	// More information available here: https://dev.mysql.com/doc/refman/8.0/en/window-functions-usage.html
  2120  	WindowSpecification struct {
  2121  		Name            IdentifierCI
  2122  		PartitionClause Exprs
  2123  		OrderClause     OrderBy
  2124  		FrameClause     *FrameClause
  2125  	}
  2126  
  2127  	WindowDefinition struct {
  2128  		Name       IdentifierCI
  2129  		WindowSpec *WindowSpecification
  2130  	}
  2131  
  2132  	WindowDefinitions []*WindowDefinition
  2133  
  2134  	NamedWindow struct {
  2135  		Windows WindowDefinitions
  2136  	}
  2137  
  2138  	NamedWindows []*NamedWindow
  2139  
  2140  	// FrameClause represents frame_clause
  2141  	// More information available here: https://dev.mysql.com/doc/refman/8.0/en/window-functions-frames.html
  2142  	FrameClause struct {
  2143  		Unit  FrameUnitType
  2144  		Start *FramePoint
  2145  		End   *FramePoint
  2146  	}
  2147  
  2148  	// FramePoint refers to frame_start/frame_end
  2149  	// More information available here: https://dev.mysql.com/doc/refman/8.0/en/window-functions-frames.html
  2150  	FramePoint struct {
  2151  		Type FramePointType
  2152  		Expr Expr
  2153  	}
  2154  
  2155  	// OverClause refers to over_clause
  2156  	// More information available here: https://dev.mysql.com/doc/refman/8.0/en/window-functions-usage.html
  2157  	OverClause struct {
  2158  		WindowName IdentifierCI
  2159  		WindowSpec *WindowSpecification
  2160  	}
  2161  
  2162  	// FrameUnitType is an enum to get types of Unit used in FrameClause.
  2163  	FrameUnitType int8
  2164  
  2165  	// FrameUnitType is an enum to get types of FramePoint.
  2166  	FramePointType int8
  2167  
  2168  	// NullTreatmentClause refers to null_treatment
  2169  	// According to SQL Docs:  Some window functions permit a null_treatment clause that specifies how to handle NULL values when calculating results.
  2170  	// This clause is optional. It is part of the SQL standard, but the MySQL implementation permits only RESPECT NULLS (which is also the default).
  2171  	// This means that NULL values are considered when calculating results. IGNORE NULLS is parsed, but produces an error.
  2172  	NullTreatmentClause struct {
  2173  		Type NullTreatmentType
  2174  	}
  2175  
  2176  	// NullTreatmentType is an enum to get types for NullTreatmentClause
  2177  	NullTreatmentType int8
  2178  
  2179  	// FromFirstLastClause refers to from_first_last
  2180  	// According to SQL Docs:  from_first_last is part of the SQL standard, but the MySQL implementation permits only FROM FIRST (which is also the default).
  2181  	// This means that calculations begin at the first row of the window.
  2182  	// FROM LAST is parsed, but produces an error.
  2183  	// To obtain the same effect as FROM LAST (begin calculations at the last row of the window), use ORDER BY to sort in reverse order.
  2184  	FromFirstLastClause struct {
  2185  		Type FromFirstLastType
  2186  	}
  2187  
  2188  	// FromFirstLastType is an enum to get types for FromFirstLastClause
  2189  	FromFirstLastType int8
  2190  )
  2191  
  2192  // *********** Expressions
  2193  type (
  2194  	// Expr represents an expression.
  2195  	Expr interface {
  2196  		iExpr()
  2197  		SQLNode
  2198  	}
  2199  
  2200  	Callable interface {
  2201  		iCallable()
  2202  		Expr
  2203  	}
  2204  
  2205  	// AndExpr represents an AND expression.
  2206  	AndExpr struct {
  2207  		Left, Right Expr
  2208  	}
  2209  
  2210  	// OrExpr represents an OR expression.
  2211  	OrExpr struct {
  2212  		Left, Right Expr
  2213  	}
  2214  
  2215  	// XorExpr represents an XOR expression.
  2216  	XorExpr struct {
  2217  		Left, Right Expr
  2218  	}
  2219  
  2220  	// NotExpr represents a NOT expression.
  2221  	NotExpr struct {
  2222  		Expr Expr
  2223  	}
  2224  
  2225  	// ComparisonExpr represents a two-value comparison expression.
  2226  	ComparisonExpr struct {
  2227  		Operator    ComparisonExprOperator
  2228  		Left, Right Expr
  2229  		Escape      Expr
  2230  	}
  2231  
  2232  	// ComparisonExprOperator is an enum for ComparisonExpr.Operator
  2233  	ComparisonExprOperator int8
  2234  
  2235  	// BetweenExpr represents a BETWEEN or a NOT BETWEEN expression.
  2236  	BetweenExpr struct {
  2237  		IsBetween bool
  2238  		Left      Expr
  2239  		From, To  Expr
  2240  	}
  2241  
  2242  	// RangeCondOperator is an enum for RangeCond.Operator
  2243  	RangeCondOperator int8
  2244  
  2245  	// IsExpr represents an IS ... or an IS NOT ... expression.
  2246  	IsExpr struct {
  2247  		Left  Expr
  2248  		Right IsExprOperator
  2249  	}
  2250  
  2251  	// IsExprOperator is an enum for IsExpr.Operator
  2252  	IsExprOperator int8
  2253  
  2254  	// ExistsExpr represents an EXISTS expression.
  2255  	ExistsExpr struct {
  2256  		Subquery *Subquery
  2257  	}
  2258  
  2259  	// Literal represents a fixed value.
  2260  	Literal struct {
  2261  		Type ValType
  2262  		Val  string
  2263  	}
  2264  
  2265  	// Argument represents bindvariable expression
  2266  	Argument string
  2267  
  2268  	// NullVal represents a NULL value.
  2269  	NullVal struct{}
  2270  
  2271  	// BoolVal is true or false.
  2272  	BoolVal bool
  2273  
  2274  	// ColName represents a column name.
  2275  	ColName struct {
  2276  		// Metadata is not populated by the parser.
  2277  		// It's a placeholder for analyzers to store
  2278  		// additional data, typically info about which
  2279  		// table or column this node references.
  2280  		Metadata  any
  2281  		Name      IdentifierCI
  2282  		Qualifier TableName
  2283  	}
  2284  
  2285  	// Scope is an enum for scope of query
  2286  	Scope int8
  2287  
  2288  	Variable struct {
  2289  		Scope Scope
  2290  		Name  IdentifierCI
  2291  	}
  2292  
  2293  	// ColTuple represents a list of column values.
  2294  	// It can be ValTuple, Subquery, ListArg.
  2295  	ColTuple interface {
  2296  		iColTuple()
  2297  		Expr
  2298  	}
  2299  
  2300  	// ListArg represents a named list argument.
  2301  	ListArg string
  2302  
  2303  	// ValTuple represents a tuple of actual values.
  2304  	ValTuple Exprs
  2305  
  2306  	// BinaryExpr represents a binary value expression.
  2307  	BinaryExpr struct {
  2308  		Operator    BinaryExprOperator
  2309  		Left, Right Expr
  2310  	}
  2311  
  2312  	// BinaryExprOperator is an enum for BinaryExpr.Operator
  2313  	BinaryExprOperator int8
  2314  
  2315  	// UnaryExpr represents a unary value expression.
  2316  	UnaryExpr struct {
  2317  		Operator UnaryExprOperator
  2318  		Expr     Expr
  2319  	}
  2320  
  2321  	// UnaryExprOperator is an enum for UnaryExpr.Operator
  2322  	UnaryExprOperator int8
  2323  
  2324  	// IntroducerExpr represents a unary value expression.
  2325  	IntroducerExpr struct {
  2326  		CharacterSet string
  2327  		Expr         Expr
  2328  	}
  2329  
  2330  	// IntervalExpr represents a date-time INTERVAL expression.
  2331  	IntervalExpr struct {
  2332  		Expr Expr
  2333  		Unit string
  2334  	}
  2335  
  2336  	// TimestampFuncExpr represents the function and arguments for TIMESTAMP{ADD,DIFF} functions.
  2337  	TimestampFuncExpr struct {
  2338  		Name  string
  2339  		Expr1 Expr
  2340  		Expr2 Expr
  2341  		Unit  string
  2342  	}
  2343  
  2344  	// ExtractFuncExpr represents the function and arguments for EXTRACT(YEAR FROM '2019-07-02') type functions.
  2345  	ExtractFuncExpr struct {
  2346  		IntervalTypes IntervalTypes
  2347  		Expr          Expr
  2348  	}
  2349  
  2350  	// CollateExpr represents dynamic collate operator.
  2351  	CollateExpr struct {
  2352  		Expr      Expr
  2353  		Collation string
  2354  	}
  2355  
  2356  	// WeightStringFuncExpr represents the function and arguments for WEIGHT_STRING('string' AS [CHAR|BINARY](n))
  2357  	WeightStringFuncExpr struct {
  2358  		Expr Expr
  2359  		As   *ConvertType
  2360  	}
  2361  
  2362  	// FuncExpr represents a function call.
  2363  	FuncExpr struct {
  2364  		Qualifier IdentifierCS
  2365  		Name      IdentifierCI
  2366  		Exprs     SelectExprs
  2367  	}
  2368  
  2369  	// ValuesFuncExpr represents a function call.
  2370  	ValuesFuncExpr struct {
  2371  		Name *ColName
  2372  	}
  2373  
  2374  	// SubstrExpr represents a calls to
  2375  	// - SubstrExpr(expression, expression, expression)
  2376  	// - SubstrExpr(expression, expression)
  2377  	// - SubstrExpr(expression FROM expression)
  2378  	// - SubstrExpr(expression FROM expression FOR expression)
  2379  	SubstrExpr struct {
  2380  		Name Expr
  2381  		From Expr
  2382  		To   Expr
  2383  	}
  2384  
  2385  	// CastExpr represents a call to CAST(expr AS type)
  2386  	// This is separate from CONVERT(expr, type) since there are
  2387  	// places such as in CREATE TABLE statements where they
  2388  	// are treated differently.
  2389  	CastExpr struct {
  2390  		Expr  Expr
  2391  		Type  *ConvertType
  2392  		Array bool
  2393  	}
  2394  
  2395  	// ConvertExpr represents a call to CONVERT(expr, type)
  2396  	ConvertExpr struct {
  2397  		Expr Expr
  2398  		Type *ConvertType
  2399  	}
  2400  
  2401  	// ConvertUsingExpr represents a call to CONVERT(expr USING charset).
  2402  	ConvertUsingExpr struct {
  2403  		Expr Expr
  2404  		Type string
  2405  	}
  2406  
  2407  	// MatchExpr represents a call to the MATCH function
  2408  	MatchExpr struct {
  2409  		Columns []*ColName
  2410  		Expr    Expr
  2411  		Option  MatchExprOption
  2412  	}
  2413  
  2414  	// MatchExprOption is an enum for MatchExpr.Option
  2415  	MatchExprOption int8
  2416  
  2417  	// CaseExpr represents a CASE expression.
  2418  	CaseExpr struct {
  2419  		Expr  Expr
  2420  		Whens []*When
  2421  		Else  Expr
  2422  	}
  2423  
  2424  	// InsertExpr represents an INSERT expression
  2425  	InsertExpr struct {
  2426  		Str    Expr
  2427  		Pos    Expr
  2428  		Len    Expr
  2429  		NewStr Expr
  2430  	}
  2431  
  2432  	// IntervalFuncExpr represents an INTERVAL function expression
  2433  	IntervalFuncExpr struct {
  2434  		Expr  Expr
  2435  		Exprs Exprs
  2436  	}
  2437  
  2438  	// LocateExpr represents a LOCATE function expression
  2439  	LocateExpr struct {
  2440  		SubStr Expr
  2441  		Str    Expr
  2442  		Pos    Expr
  2443  	}
  2444  
  2445  	// CharExpr represents a CHAR function expression
  2446  	CharExpr struct {
  2447  		Exprs   Exprs
  2448  		Charset string
  2449  	}
  2450  
  2451  	// Default represents a DEFAULT expression.
  2452  	Default struct {
  2453  		ColName string
  2454  	}
  2455  
  2456  	// When represents a WHEN sub-expression.
  2457  	When struct {
  2458  		Cond Expr
  2459  		Val  Expr
  2460  	}
  2461  
  2462  	// CurTimeFuncExpr represents the function and arguments for CURRENT DATE/TIME functions
  2463  	// supported functions are documented in the grammar
  2464  	CurTimeFuncExpr struct {
  2465  		Name IdentifierCI
  2466  		Fsp  Expr // fractional seconds precision, integer from 0 to 6 or an Argument
  2467  	}
  2468  
  2469  	// ExtractedSubquery is a subquery that has been extracted from the original AST
  2470  	// This is a struct that the parser will never produce - it's written and read by the gen4 planner
  2471  	// CAUTION: you should only change argName and hasValuesArg through the setter methods
  2472  	ExtractedSubquery struct {
  2473  		Original     Expr // original expression that was replaced by this ExtractedSubquery
  2474  		OpCode       int  // this should really be engine.PulloutOpCode, but we cannot depend on engine :(
  2475  		Subquery     *Subquery
  2476  		OtherSide    Expr // represents the side of the comparison, this field will be nil if Original is not a comparison
  2477  		NeedsRewrite bool // tells whether we need to rewrite this subquery to Original or not
  2478  
  2479  		hasValuesArg string
  2480  		argName      string
  2481  		alternative  Expr // this is what will be used to Format this struct
  2482  	}
  2483  
  2484  	// JSONPrettyExpr represents the function and argument for JSON_PRETTY()
  2485  	// https://dev.mysql.com/doc/refman/8.0/en/json-utility-functions.html#function_json-pretty
  2486  	JSONPrettyExpr struct {
  2487  		JSONVal Expr
  2488  	}
  2489  
  2490  	// JSONStorageFreeExpr represents the function and argument for JSON_STORAGE_FREE()
  2491  	// https://dev.mysql.com/doc/refman/8.0/en/json-utility-functions.html#function_json-storage-free
  2492  	JSONStorageFreeExpr struct {
  2493  		JSONVal Expr
  2494  	}
  2495  
  2496  	// JSONStorageSizeExpr represents the function and argument for JSON_STORAGE_SIZE()
  2497  	// https://dev.mysql.com/doc/refman/8.0/en/json-utility-functions.html#function_json-storage-size
  2498  	JSONStorageSizeExpr struct {
  2499  		JSONVal Expr
  2500  	}
  2501  
  2502  	// Offset is an AST type that is used during planning and never produced by the parser
  2503  	// it is the column offset from the incoming result stream
  2504  	Offset struct {
  2505  		V        int
  2506  		Original string
  2507  	}
  2508  
  2509  	// JSONArrayExpr represents JSON_ARRAY()
  2510  	// More information on https://dev.mysql.com/doc/refman/8.0/en/json-creation-functions.html#function_json-array
  2511  	JSONArrayExpr struct {
  2512  		Params Exprs
  2513  	}
  2514  
  2515  	// JSONObjectExpr represents JSON_OBJECT()
  2516  	// More information on https://dev.mysql.com/doc/refman/8.0/en/json-creation-functions.html#function_json-object
  2517  	JSONObjectExpr struct {
  2518  		Params []*JSONObjectParam
  2519  	}
  2520  
  2521  	// JSONObjectParam defines a key/value parameter for a JSON_OBJECT expression
  2522  	JSONObjectParam struct {
  2523  		Key   Expr
  2524  		Value Expr
  2525  	}
  2526  
  2527  	// JSONQuoteExpr represents JSON_QUOTE()
  2528  	// More information https://dev.mysql.com/doc/refman/8.0/en/json-creation-functions.html#function_json-quote
  2529  	JSONQuoteExpr struct {
  2530  		StringArg Expr
  2531  	}
  2532  
  2533  	// JSONTableExpr describes the components of JSON_TABLE()
  2534  	// For more information, postVisit https://dev.mysql.com/doc/refman/8.0/en/json-table-functions.html#function_json-table
  2535  	JSONTableExpr struct {
  2536  		Expr    Expr
  2537  		Alias   IdentifierCS
  2538  		Filter  Expr
  2539  		Columns []*JtColumnDefinition
  2540  	}
  2541  
  2542  	// JtOnResponseType describes the type of column: default, error or null
  2543  	JtOnResponseType int
  2544  
  2545  	// JtColumnDefinition represents the structure of column definition in JSON_TABLE
  2546  	JtColumnDefinition struct {
  2547  		JtOrdinal    *JtOrdinalColDef
  2548  		JtPath       *JtPathColDef
  2549  		JtNestedPath *JtNestedPathColDef
  2550  	}
  2551  
  2552  	// JtOrdinalColDef is a type of column definition similar to using AUTO_INCREMENT with a column
  2553  	JtOrdinalColDef struct {
  2554  		Name IdentifierCI
  2555  	}
  2556  
  2557  	// JtPathColDef is a type of column definition specifying the path in JSON structure to extract values
  2558  	JtPathColDef struct {
  2559  		Name            IdentifierCI
  2560  		Type            *ColumnType
  2561  		JtColExists     bool
  2562  		Path            Expr
  2563  		EmptyOnResponse *JtOnResponse
  2564  		ErrorOnResponse *JtOnResponse
  2565  	}
  2566  
  2567  	// JtNestedPathColDef is type of column definition with nested column definitions
  2568  	JtNestedPathColDef struct {
  2569  		Path    Expr
  2570  		Columns []*JtColumnDefinition
  2571  	}
  2572  
  2573  	// JtOnResponse specifies for a column the JtOnResponseType along with the expression for default and error
  2574  	JtOnResponse struct {
  2575  		ResponseType JtOnResponseType
  2576  		Expr         Expr
  2577  	}
  2578  
  2579  	// JSONContainsExpr represents the function and arguments for JSON_CONTAINS()
  2580  	// For more information, see https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-contains
  2581  	JSONContainsExpr struct {
  2582  		Target    Expr
  2583  		Candidate Expr
  2584  		PathList  []Expr
  2585  	}
  2586  
  2587  	// JSONContainsPathExpr represents the function and arguments for JSON_CONTAINS_PATH()
  2588  	// For more information, see https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-contains-path
  2589  	JSONContainsPathExpr struct {
  2590  		JSONDoc  Expr
  2591  		OneOrAll Expr
  2592  		PathList []Expr
  2593  	}
  2594  
  2595  	// JSONContainsPathType is an enum to get types of Trim
  2596  	JSONContainsPathType int8
  2597  
  2598  	// JSONExtractExpr represents the function and arguments for JSON_EXTRACT()
  2599  	// For more information, see https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-extract
  2600  	JSONExtractExpr struct {
  2601  		JSONDoc  Expr
  2602  		PathList []Expr
  2603  	}
  2604  
  2605  	// JSONKeysExpr represents the function and arguments for JSON_KEYS()
  2606  	// For more information, see https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-keys
  2607  	JSONKeysExpr struct {
  2608  		JSONDoc Expr
  2609  		Path    Expr
  2610  	}
  2611  
  2612  	// JSONOverlapsExpr represents the function and arguments for JSON_OVERLAPS()
  2613  	// For more information, see https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-overlaps
  2614  	JSONOverlapsExpr struct {
  2615  		JSONDoc1 Expr
  2616  		JSONDoc2 Expr
  2617  	}
  2618  
  2619  	// JSONSearchExpr represents the function and arguments for JSON_SEARCH()
  2620  	// For more information, see https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-search
  2621  	JSONSearchExpr struct {
  2622  		JSONDoc    Expr
  2623  		OneOrAll   Expr
  2624  		SearchStr  Expr
  2625  		EscapeChar Expr
  2626  		PathList   []Expr
  2627  	}
  2628  
  2629  	// JSONValueExpr represents the function and arguments for JSON_VALUE()
  2630  	// For more information, see https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-value
  2631  	JSONValueExpr struct {
  2632  		JSONDoc         Expr
  2633  		Path            Expr
  2634  		ReturningType   *ConvertType
  2635  		EmptyOnResponse *JtOnResponse
  2636  		ErrorOnResponse *JtOnResponse
  2637  	}
  2638  
  2639  	// MemberOf represents the function and arguments for MEMBER OF()
  2640  	// For more information, see https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#operator_member-of
  2641  	MemberOfExpr struct {
  2642  		Value   Expr
  2643  		JSONArr Expr
  2644  	}
  2645  
  2646  	// JSONSchemaValidFuncExpr represents the structure of JSON_SCHEMA_VALID()
  2647  	// More information available on https://dev.mysql.com/doc/refman/8.0/en/json-validation-functions.html#function_json-schema-valid
  2648  	JSONSchemaValidFuncExpr struct {
  2649  		Schema   Expr
  2650  		Document Expr
  2651  	}
  2652  
  2653  	// JSONSchemaValidationReportFuncExpr represents the structure of JSON_SCHEMA_VALIDATION_REPORT()
  2654  	// More information available on https://dev.mysql.com/doc/refman/8.0/en/json-validation-functions.html#function_json-schema-validation-report
  2655  	JSONSchemaValidationReportFuncExpr struct {
  2656  		Schema   Expr
  2657  		Document Expr
  2658  	}
  2659  
  2660  	// JSONAttributesExpr represents the argument and function for functions returning JSON value attributes
  2661  	// More information available on https://dev.mysql.com/doc/refman/8.0/en/json-attribute-functions.html
  2662  	JSONAttributesExpr struct {
  2663  		Type    JSONAttributeType
  2664  		JSONDoc Expr
  2665  		Path    Expr
  2666  	}
  2667  
  2668  	// JSONAttributeType is an enum to get types of TrimFunc.
  2669  	// TrimFunc stand for one of the following: JSON_DEPTH JSON_TYPE JSON_VALID ENUM
  2670  	JSONAttributeType int8
  2671  
  2672  	JSONValueModifierExpr struct {
  2673  		Type    JSONValueModifierType
  2674  		JSONDoc Expr
  2675  		Params  []*JSONObjectParam
  2676  	}
  2677  
  2678  	// JSONValueModifierType is an enum to get types of TrimFunc.
  2679  	// TrimFunc stand for one of the following: JSON_DEPTH JSON_TYPE JSON_VALID ENUM
  2680  	JSONValueModifierType int8
  2681  
  2682  	// JSONValueMergeExpr represents the json value modifier functions which merges documents.
  2683  	// Functions falling under this class: JSON_MERGE, JSON_MERGE_PATCH, JSON_MERGE_PRESERVE
  2684  	JSONValueMergeExpr struct {
  2685  		Type        JSONValueMergeType
  2686  		JSONDoc     Expr
  2687  		JSONDocList Exprs
  2688  	}
  2689  
  2690  	// JSONValueModifierType is an enum to get types of TrimFunc.
  2691  	// TrimFunc stand for one of the following: JSON_DEPTH JSON_TYPE JSON_VALID ENUM
  2692  	JSONValueMergeType int8
  2693  
  2694  	// JSONRemoveExpr represents the JSON_REMOVE()
  2695  	// For more information, postVisit https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-remove
  2696  	JSONRemoveExpr struct {
  2697  		JSONDoc  Expr
  2698  		PathList Exprs
  2699  	}
  2700  
  2701  	// JSONRemoveExpr represents the JSON_UNQUOTE()
  2702  	// For more information, postVisit https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-unquote
  2703  	JSONUnquoteExpr struct {
  2704  		JSONValue Expr
  2705  	}
  2706  
  2707  	//PointExpr represents POINT(x,y) expression
  2708  	PointExpr struct {
  2709  		XCordinate Expr
  2710  		YCordinate Expr
  2711  	}
  2712  
  2713  	//LineString represents LineString(POINT(x,y), POINT(x,y), ..) expression
  2714  	LineStringExpr struct {
  2715  		PointParams Exprs
  2716  	}
  2717  
  2718  	AggrFunc interface {
  2719  		Expr
  2720  		AggrName() string
  2721  		GetArg() Expr
  2722  		IsDistinct() bool
  2723  		GetArgs() Exprs
  2724  	}
  2725  
  2726  	Count struct {
  2727  		Args     Exprs
  2728  		Distinct bool
  2729  	}
  2730  
  2731  	CountStar struct {
  2732  	}
  2733  
  2734  	Avg struct {
  2735  		Arg      Expr
  2736  		Distinct bool
  2737  	}
  2738  
  2739  	Max struct {
  2740  		Arg      Expr
  2741  		Distinct bool
  2742  	}
  2743  
  2744  	Min struct {
  2745  		Arg      Expr
  2746  		Distinct bool
  2747  	}
  2748  
  2749  	Sum struct {
  2750  		Arg      Expr
  2751  		Distinct bool
  2752  	}
  2753  
  2754  	BitAnd struct {
  2755  		Arg Expr
  2756  	}
  2757  
  2758  	BitOr struct {
  2759  		Arg Expr
  2760  	}
  2761  
  2762  	BitXor struct {
  2763  		Arg Expr
  2764  	}
  2765  
  2766  	Std struct {
  2767  		Arg Expr
  2768  	}
  2769  
  2770  	StdDev struct {
  2771  		Arg Expr
  2772  	}
  2773  
  2774  	StdPop struct {
  2775  		Arg Expr
  2776  	}
  2777  
  2778  	StdSamp struct {
  2779  		Arg Expr
  2780  	}
  2781  
  2782  	VarPop struct {
  2783  		Arg Expr
  2784  	}
  2785  
  2786  	VarSamp struct {
  2787  		Arg Expr
  2788  	}
  2789  
  2790  	Variance struct {
  2791  		Arg Expr
  2792  	}
  2793  
  2794  	// GroupConcatExpr represents a call to GROUP_CONCAT
  2795  	GroupConcatExpr struct {
  2796  		Distinct  bool
  2797  		Exprs     Exprs
  2798  		OrderBy   OrderBy
  2799  		Separator string
  2800  		Limit     *Limit
  2801  	}
  2802  
  2803  	// RegexpInstrExpr represents REGEXP_INSTR()
  2804  	// For more information, postVisit https://dev.mysql.com/doc/refman/8.0/en/regexp.html#function_regexp-instr
  2805  	RegexpInstrExpr struct {
  2806  		Expr         Expr
  2807  		Pattern      Expr
  2808  		Position     Expr
  2809  		Occurrence   Expr
  2810  		ReturnOption Expr
  2811  		MatchType    Expr
  2812  	}
  2813  
  2814  	// RegexpLikeExpr represents REGEXP_LIKE()
  2815  	// For more information, postVisit https://dev.mysql.com/doc/refman/8.0/en/regexp.html#function_regexp-like
  2816  	RegexpLikeExpr struct {
  2817  		Expr      Expr
  2818  		Pattern   Expr
  2819  		MatchType Expr
  2820  	}
  2821  
  2822  	// RegexpReplaceExpr represents REGEXP_REPLACE()
  2823  	// For more information, postVisit https://dev.mysql.com/doc/refman/8.0/en/regexp.html#function_regexp-replace
  2824  	RegexpReplaceExpr struct {
  2825  		Expr       Expr
  2826  		Pattern    Expr
  2827  		Repl       Expr
  2828  		Occurrence Expr
  2829  		Position   Expr
  2830  		MatchType  Expr
  2831  	}
  2832  
  2833  	// RegexpSubstrExpr represents REGEXP_SUBSTR()
  2834  	// For more information, postVisit https://dev.mysql.com/doc/refman/8.0/en/regexp.html#function_regexp-substr
  2835  	RegexpSubstrExpr struct {
  2836  		Expr       Expr
  2837  		Pattern    Expr
  2838  		Occurrence Expr
  2839  		Position   Expr
  2840  		MatchType  Expr
  2841  	}
  2842  
  2843  	// ArgumentLessWindowExpr stands for the following window_functions: CUME_DIST, DENSE_RANK, PERCENT_RANK, RANK, ROW_NUMBER
  2844  	// These functions do not take any argument.
  2845  	ArgumentLessWindowExpr struct {
  2846  		Type       ArgumentLessWindowExprType
  2847  		OverClause *OverClause
  2848  	}
  2849  
  2850  	// ArgumentLessWindowExprType is an enum to get types of ArgumentLessWindowExpr.
  2851  	ArgumentLessWindowExprType int8
  2852  
  2853  	// FirstOrLastValueExpr stands for the following window_functions: FIRST_VALUE, LAST_VALUE
  2854  	FirstOrLastValueExpr struct {
  2855  		Type                FirstOrLastValueExprType
  2856  		Expr                Expr
  2857  		NullTreatmentClause *NullTreatmentClause
  2858  		OverClause          *OverClause
  2859  	}
  2860  
  2861  	// FirstOrLastValueExprType is an enum to get types of FirstOrLastValueExpr.
  2862  	FirstOrLastValueExprType int8
  2863  
  2864  	// NtileExpr stands for the NTILE()
  2865  	NtileExpr struct {
  2866  		N          Expr
  2867  		OverClause *OverClause
  2868  	}
  2869  
  2870  	// NTHValueExpr stands for the NTH_VALUE()
  2871  	NTHValueExpr struct {
  2872  		Expr                Expr
  2873  		N                   Expr
  2874  		OverClause          *OverClause
  2875  		FromFirstLastClause *FromFirstLastClause
  2876  		NullTreatmentClause *NullTreatmentClause
  2877  	}
  2878  
  2879  	// LagLeadExpr stand for the following: LAG, LEAD
  2880  	LagLeadExpr struct {
  2881  		Type                LagLeadExprType
  2882  		Expr                Expr
  2883  		N                   Expr
  2884  		Default             Expr
  2885  		OverClause          *OverClause
  2886  		NullTreatmentClause *NullTreatmentClause
  2887  	}
  2888  
  2889  	// LagLeadExprType is an enum to get types of LagLeadExpr.
  2890  	LagLeadExprType int8
  2891  
  2892  	// ExtractValueExpr stands for EXTRACTVALUE() XML function
  2893  	// Extract a value from an XML string using XPath notation
  2894  	// For more details, postVisit https://dev.mysql.com/doc/refman/8.0/en/xml-functions.html#function_extractvalue
  2895  	ExtractValueExpr struct {
  2896  		Fragment  Expr
  2897  		XPathExpr Expr
  2898  	}
  2899  
  2900  	// UpdateXMLExpr stands for UpdateXML() XML function
  2901  	// Return replaced XML fragment
  2902  	// For more details, postVisit https://dev.mysql.com/doc/refman/8.0/en/xml-functions.html#function_updatexml
  2903  	UpdateXMLExpr struct {
  2904  		Target    Expr
  2905  		XPathExpr Expr
  2906  		NewXML    Expr
  2907  	}
  2908  
  2909  	// LockingFuncType is an enum that get types of LockingFunc
  2910  	LockingFuncType int8
  2911  
  2912  	// LockingFunc represents the advisory lock functions.
  2913  	LockingFunc struct {
  2914  		Type    LockingFuncType
  2915  		Name    Expr
  2916  		Timeout Expr
  2917  	}
  2918  
  2919  	// PerformanceSchemaType is an enum that get types of LockingFunc
  2920  	PerformanceSchemaType int8
  2921  
  2922  	// PerformanceSchemaFuncExpr stands for Performance Schema Functions
  2923  	// Argument has different meanings for different types
  2924  	// For FORMAT_BYTES, it means count
  2925  	// For FORMAT_PICO_TIME, it means time_val
  2926  	// For PS_THREAD_ID it means connection_id
  2927  	// For more details, postVisit https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html
  2928  	PerformanceSchemaFuncExpr struct {
  2929  		Type     PerformanceSchemaType
  2930  		Argument Expr
  2931  	}
  2932  
  2933  	// GTIDType is an enum that get types of GTIDFunc
  2934  	GTIDType int8
  2935  
  2936  	// GTIDFuncExpr stands for GTID Functions
  2937  	// Set1 Acts as gtid_set for WAIT_FOR_EXECUTED_GTID_SET() and WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS()
  2938  	// For more details, postVisit https://dev.mysql.com/doc/refman/8.0/en/gtid-functions.html
  2939  	GTIDFuncExpr struct {
  2940  		Type    GTIDType
  2941  		Set1    Expr
  2942  		Set2    Expr
  2943  		Timeout Expr
  2944  		Channel Expr
  2945  	}
  2946  )
  2947  
  2948  // iExpr ensures that only expressions nodes can be assigned to a Expr
  2949  func (*AndExpr) iExpr()                            {}
  2950  func (*OrExpr) iExpr()                             {}
  2951  func (*XorExpr) iExpr()                            {}
  2952  func (*NotExpr) iExpr()                            {}
  2953  func (*ComparisonExpr) iExpr()                     {}
  2954  func (*BetweenExpr) iExpr()                        {}
  2955  func (*IsExpr) iExpr()                             {}
  2956  func (*ExistsExpr) iExpr()                         {}
  2957  func (*Literal) iExpr()                            {}
  2958  func (Argument) iExpr()                            {}
  2959  func (*NullVal) iExpr()                            {}
  2960  func (BoolVal) iExpr()                             {}
  2961  func (*ColName) iExpr()                            {}
  2962  func (ValTuple) iExpr()                            {}
  2963  func (*Subquery) iExpr()                           {}
  2964  func (ListArg) iExpr()                             {}
  2965  func (*BinaryExpr) iExpr()                         {}
  2966  func (*UnaryExpr) iExpr()                          {}
  2967  func (*IntroducerExpr) iExpr()                     {}
  2968  func (*IntervalExpr) iExpr()                       {}
  2969  func (*CollateExpr) iExpr()                        {}
  2970  func (*FuncExpr) iExpr()                           {}
  2971  func (*TimestampFuncExpr) iExpr()                  {}
  2972  func (*ExtractFuncExpr) iExpr()                    {}
  2973  func (*WeightStringFuncExpr) iExpr()               {}
  2974  func (*CurTimeFuncExpr) iExpr()                    {}
  2975  func (*CaseExpr) iExpr()                           {}
  2976  func (*ValuesFuncExpr) iExpr()                     {}
  2977  func (*CastExpr) iExpr()                           {}
  2978  func (*ConvertExpr) iExpr()                        {}
  2979  func (*SubstrExpr) iExpr()                         {}
  2980  func (*InsertExpr) iExpr()                         {}
  2981  func (*IntervalFuncExpr) iExpr()                   {}
  2982  func (*LocateExpr) iExpr()                         {}
  2983  func (*CharExpr) iExpr()                           {}
  2984  func (*ConvertUsingExpr) iExpr()                   {}
  2985  func (*MatchExpr) iExpr()                          {}
  2986  func (*Default) iExpr()                            {}
  2987  func (*ExtractedSubquery) iExpr()                  {}
  2988  func (*TrimFuncExpr) iExpr()                       {}
  2989  func (*JSONSchemaValidFuncExpr) iExpr()            {}
  2990  func (*JSONSchemaValidationReportFuncExpr) iExpr() {}
  2991  func (*Offset) iExpr()                             {}
  2992  func (*JSONPrettyExpr) iExpr()                     {}
  2993  func (*JSONStorageFreeExpr) iExpr()                {}
  2994  func (*JSONStorageSizeExpr) iExpr()                {}
  2995  func (*JSONContainsExpr) iExpr()                   {}
  2996  func (*JSONContainsPathExpr) iExpr()               {}
  2997  func (*JSONExtractExpr) iExpr()                    {}
  2998  func (*JSONKeysExpr) iExpr()                       {}
  2999  func (*JSONOverlapsExpr) iExpr()                   {}
  3000  func (*JSONSearchExpr) iExpr()                     {}
  3001  func (*JSONValueExpr) iExpr()                      {}
  3002  func (*JSONArrayExpr) iExpr()                      {}
  3003  func (*JSONObjectExpr) iExpr()                     {}
  3004  func (*JSONQuoteExpr) iExpr()                      {}
  3005  func (*JSONAttributesExpr) iExpr()                 {}
  3006  func (*JSONValueModifierExpr) iExpr()              {}
  3007  func (*JSONValueMergeExpr) iExpr()                 {}
  3008  func (*JSONRemoveExpr) iExpr()                     {}
  3009  func (*JSONUnquoteExpr) iExpr()                    {}
  3010  func (*MemberOfExpr) iExpr()                       {}
  3011  func (*RegexpInstrExpr) iExpr()                    {}
  3012  func (*RegexpLikeExpr) iExpr()                     {}
  3013  func (*RegexpReplaceExpr) iExpr()                  {}
  3014  func (*RegexpSubstrExpr) iExpr()                   {}
  3015  func (*ArgumentLessWindowExpr) iExpr()             {}
  3016  func (*FirstOrLastValueExpr) iExpr()               {}
  3017  func (*NtileExpr) iExpr()                          {}
  3018  func (*NTHValueExpr) iExpr()                       {}
  3019  func (*LagLeadExpr) iExpr()                        {}
  3020  func (*NamedWindow) iExpr()                        {}
  3021  func (*ExtractValueExpr) iExpr()                   {}
  3022  func (*UpdateXMLExpr) iExpr()                      {}
  3023  func (*LockingFunc) iExpr()                        {}
  3024  func (*PerformanceSchemaFuncExpr) iExpr()          {}
  3025  func (*GTIDFuncExpr) iExpr()                       {}
  3026  func (*Sum) iExpr()                                {}
  3027  func (*Min) iExpr()                                {}
  3028  func (*Max) iExpr()                                {}
  3029  func (*Avg) iExpr()                                {}
  3030  func (*CountStar) iExpr()                          {}
  3031  func (*Count) iExpr()                              {}
  3032  func (*GroupConcatExpr) iExpr()                    {}
  3033  func (*BitAnd) iExpr()                             {}
  3034  func (*BitOr) iExpr()                              {}
  3035  func (*BitXor) iExpr()                             {}
  3036  func (*Std) iExpr()                                {}
  3037  func (*StdDev) iExpr()                             {}
  3038  func (*StdPop) iExpr()                             {}
  3039  func (*StdSamp) iExpr()                            {}
  3040  func (*VarPop) iExpr()                             {}
  3041  func (*VarSamp) iExpr()                            {}
  3042  func (*Variance) iExpr()                           {}
  3043  func (*Variable) iExpr()                           {}
  3044  func (*PointExpr) iExpr()                          {}
  3045  func (*LineStringExpr) iExpr()                     {}
  3046  
  3047  // iCallable marks all expressions that represent function calls
  3048  func (*FuncExpr) iCallable()                           {}
  3049  func (*TimestampFuncExpr) iCallable()                  {}
  3050  func (*ExtractFuncExpr) iCallable()                    {}
  3051  func (*WeightStringFuncExpr) iCallable()               {}
  3052  func (*CurTimeFuncExpr) iCallable()                    {}
  3053  func (*ValuesFuncExpr) iCallable()                     {}
  3054  func (*ConvertExpr) iCallable()                        {}
  3055  func (*TrimFuncExpr) iCallable()                       {}
  3056  func (*SubstrExpr) iCallable()                         {}
  3057  func (*InsertExpr) iCallable()                         {}
  3058  func (*IntervalFuncExpr) iCallable()                   {}
  3059  func (*LocateExpr) iCallable()                         {}
  3060  func (*CharExpr) iCallable()                           {}
  3061  func (*ConvertUsingExpr) iCallable()                   {}
  3062  func (*MatchExpr) iCallable()                          {}
  3063  func (*GroupConcatExpr) iCallable()                    {}
  3064  func (*JSONSchemaValidFuncExpr) iCallable()            {}
  3065  func (*JSONSchemaValidationReportFuncExpr) iCallable() {}
  3066  func (*JSONPrettyExpr) iCallable()                     {}
  3067  func (*JSONStorageFreeExpr) iCallable()                {}
  3068  func (*JSONStorageSizeExpr) iCallable()                {}
  3069  func (*JSONArrayExpr) iCallable()                      {}
  3070  func (*JSONObjectExpr) iCallable()                     {}
  3071  func (*JSONQuoteExpr) iCallable()                      {}
  3072  func (*JSONContainsExpr) iCallable()                   {}
  3073  func (*JSONContainsPathExpr) iCallable()               {}
  3074  func (*JSONExtractExpr) iCallable()                    {}
  3075  func (*JSONKeysExpr) iCallable()                       {}
  3076  func (*JSONValueExpr) iCallable()                      {}
  3077  func (*JSONSearchExpr) iCallable()                     {}
  3078  func (*JSONOverlapsExpr) iCallable()                   {}
  3079  func (*JSONAttributesExpr) iCallable()                 {}
  3080  func (*JSONValueModifierExpr) iCallable()              {}
  3081  func (*JSONValueMergeExpr) iCallable()                 {}
  3082  func (*JSONRemoveExpr) iCallable()                     {}
  3083  func (*JSONUnquoteExpr) iCallable()                    {}
  3084  func (*MemberOfExpr) iCallable()                       {}
  3085  func (*RegexpInstrExpr) iCallable()                    {}
  3086  func (*RegexpLikeExpr) iCallable()                     {}
  3087  func (*RegexpReplaceExpr) iCallable()                  {}
  3088  func (*RegexpSubstrExpr) iCallable()                   {}
  3089  func (*ArgumentLessWindowExpr) iCallable()             {}
  3090  func (*FirstOrLastValueExpr) iCallable()               {}
  3091  func (*NtileExpr) iCallable()                          {}
  3092  func (*NTHValueExpr) iCallable()                       {}
  3093  func (*LagLeadExpr) iCallable()                        {}
  3094  func (*NamedWindow) iCallable()                        {}
  3095  func (*ExtractValueExpr) iCallable()                   {}
  3096  func (*UpdateXMLExpr) iCallable()                      {}
  3097  func (*PerformanceSchemaFuncExpr) iCallable()          {}
  3098  func (*GTIDFuncExpr) iCallable()                       {}
  3099  func (*PointExpr) iCallable()                          {}
  3100  func (*LineStringExpr) iCallable()                     {}
  3101  
  3102  func (*Sum) iCallable()       {}
  3103  func (*Min) iCallable()       {}
  3104  func (*Max) iCallable()       {}
  3105  func (*Avg) iCallable()       {}
  3106  func (*CountStar) iCallable() {}
  3107  func (*Count) iCallable()     {}
  3108  
  3109  func (sum *Sum) GetArg() Expr                   { return sum.Arg }
  3110  func (min *Min) GetArg() Expr                   { return min.Arg }
  3111  func (max *Max) GetArg() Expr                   { return max.Arg }
  3112  func (avg *Avg) GetArg() Expr                   { return avg.Arg }
  3113  func (*CountStar) GetArg() Expr                 { return nil }
  3114  func (count *Count) GetArg() Expr               { return count.Args[0] }
  3115  func (grpConcat *GroupConcatExpr) GetArg() Expr { return grpConcat.Exprs[0] }
  3116  func (bAnd *BitAnd) GetArg() Expr               { return bAnd.Arg }
  3117  func (bOr *BitOr) GetArg() Expr                 { return bOr.Arg }
  3118  func (bXor *BitXor) GetArg() Expr               { return bXor.Arg }
  3119  func (std *Std) GetArg() Expr                   { return std.Arg }
  3120  func (stdD *StdDev) GetArg() Expr               { return stdD.Arg }
  3121  func (stdP *StdPop) GetArg() Expr               { return stdP.Arg }
  3122  func (stdS *StdSamp) GetArg() Expr              { return stdS.Arg }
  3123  func (varP *VarPop) GetArg() Expr               { return varP.Arg }
  3124  func (varS *VarSamp) GetArg() Expr              { return varS.Arg }
  3125  func (variance *Variance) GetArg() Expr         { return variance.Arg }
  3126  
  3127  func (sum *Sum) GetArgs() Exprs                   { return Exprs{sum.Arg} }
  3128  func (min *Min) GetArgs() Exprs                   { return Exprs{min.Arg} }
  3129  func (max *Max) GetArgs() Exprs                   { return Exprs{max.Arg} }
  3130  func (avg *Avg) GetArgs() Exprs                   { return Exprs{avg.Arg} }
  3131  func (*CountStar) GetArgs() Exprs                 { return nil }
  3132  func (count *Count) GetArgs() Exprs               { return count.Args }
  3133  func (grpConcat *GroupConcatExpr) GetArgs() Exprs { return grpConcat.Exprs }
  3134  func (bAnd *BitAnd) GetArgs() Exprs               { return Exprs{bAnd.Arg} }
  3135  func (bOr *BitOr) GetArgs() Exprs                 { return Exprs{bOr.Arg} }
  3136  func (bXor *BitXor) GetArgs() Exprs               { return Exprs{bXor.Arg} }
  3137  func (std *Std) GetArgs() Exprs                   { return Exprs{std.Arg} }
  3138  func (stdD *StdDev) GetArgs() Exprs               { return Exprs{stdD.Arg} }
  3139  func (stdP *StdPop) GetArgs() Exprs               { return Exprs{stdP.Arg} }
  3140  func (stdS *StdSamp) GetArgs() Exprs              { return Exprs{stdS.Arg} }
  3141  func (varP *VarPop) GetArgs() Exprs               { return Exprs{varP.Arg} }
  3142  func (varS *VarSamp) GetArgs() Exprs              { return Exprs{varS.Arg} }
  3143  func (variance *Variance) GetArgs() Exprs         { return Exprs{variance.Arg} }
  3144  
  3145  func (sum *Sum) IsDistinct() bool                   { return sum.Distinct }
  3146  func (min *Min) IsDistinct() bool                   { return min.Distinct }
  3147  func (max *Max) IsDistinct() bool                   { return max.Distinct }
  3148  func (avg *Avg) IsDistinct() bool                   { return avg.Distinct }
  3149  func (cStar *CountStar) IsDistinct() bool           { return false }
  3150  func (count *Count) IsDistinct() bool               { return count.Distinct }
  3151  func (grpConcat *GroupConcatExpr) IsDistinct() bool { return grpConcat.Distinct }
  3152  func (bAnd *BitAnd) IsDistinct() bool               { return false }
  3153  func (bOr *BitOr) IsDistinct() bool                 { return false }
  3154  func (bXor *BitXor) IsDistinct() bool               { return false }
  3155  func (std *Std) IsDistinct() bool                   { return false }
  3156  func (stdD *StdDev) IsDistinct() bool               { return false }
  3157  func (stdP *StdPop) IsDistinct() bool               { return false }
  3158  func (stdS *StdSamp) IsDistinct() bool              { return false }
  3159  func (varP *VarPop) IsDistinct() bool               { return false }
  3160  func (varS *VarSamp) IsDistinct() bool              { return false }
  3161  func (variance *Variance) IsDistinct() bool         { return false }
  3162  
  3163  func (sum *Sum) AggrName() string                   { return "sum" }
  3164  func (min *Min) AggrName() string                   { return "min" }
  3165  func (max *Max) AggrName() string                   { return "max" }
  3166  func (avg *Avg) AggrName() string                   { return "avg" }
  3167  func (cStar *CountStar) AggrName() string           { return "count" }
  3168  func (count *Count) AggrName() string               { return "count" }
  3169  func (grpConcat *GroupConcatExpr) AggrName() string { return "group_concat" }
  3170  func (bAnd *BitAnd) AggrName() string               { return "bit_and" }
  3171  func (bOr *BitOr) AggrName() string                 { return "bit_or" }
  3172  func (bXor *BitXor) AggrName() string               { return "bit_xor" }
  3173  func (std *Std) AggrName() string                   { return "std" }
  3174  func (stdD *StdDev) AggrName() string               { return "stddev" }
  3175  func (stdP *StdPop) AggrName() string               { return "stddev_pop" }
  3176  func (stdS *StdSamp) AggrName() string              { return "stddev_samp" }
  3177  func (varP *VarPop) AggrName() string               { return "var_pop" }
  3178  func (varS *VarSamp) AggrName() string              { return "var_samp" }
  3179  func (variance *Variance) AggrName() string         { return "variance" }
  3180  
  3181  // Exprs represents a list of value expressions.
  3182  // It's not a valid expression because it's not parenthesized.
  3183  type Exprs []Expr
  3184  
  3185  func (ValTuple) iColTuple()  {}
  3186  func (*Subquery) iColTuple() {}
  3187  func (ListArg) iColTuple()   {}
  3188  
  3189  // ConvertType represents the type in call to CONVERT(expr, type)
  3190  type ConvertType struct {
  3191  	Type    string
  3192  	Length  *Literal
  3193  	Scale   *Literal
  3194  	Charset ColumnCharset
  3195  }
  3196  
  3197  // GroupBy represents a GROUP BY clause.
  3198  type GroupBy []Expr
  3199  
  3200  // OrderBy represents an ORDER By clause.
  3201  type OrderBy []*Order
  3202  
  3203  // Order represents an ordering expression.
  3204  type Order struct {
  3205  	Expr      Expr
  3206  	Direction OrderDirection
  3207  }
  3208  
  3209  // OrderDirection is an enum for the direction in which to order - asc or desc.
  3210  type OrderDirection int8
  3211  
  3212  // Limit represents a LIMIT clause.
  3213  type Limit struct {
  3214  	Offset, Rowcount Expr
  3215  }
  3216  
  3217  // Values represents a VALUES clause.
  3218  type Values []ValTuple
  3219  
  3220  // UpdateExprs represents a list of update expressions.
  3221  type UpdateExprs []*UpdateExpr
  3222  
  3223  // UpdateExpr represents an update expression.
  3224  type UpdateExpr struct {
  3225  	Name *ColName
  3226  	Expr Expr
  3227  }
  3228  
  3229  // SetExprs represents a list of set expressions.
  3230  type SetExprs []*SetExpr
  3231  
  3232  // SetExpr represents a set expression.
  3233  type SetExpr struct {
  3234  	Var  *Variable
  3235  	Expr Expr
  3236  }
  3237  
  3238  // OnDup represents an ON DUPLICATE KEY clause.
  3239  type OnDup UpdateExprs
  3240  
  3241  // IdentifierCI is a case insensitive SQL identifier. It will be escaped with
  3242  // backquotes if necessary.
  3243  type IdentifierCI struct {
  3244  	// This artifact prevents this struct from being compared
  3245  	// with itself. It consumes no space as long as it's not the
  3246  	// last field in the struct.
  3247  	_            [0]struct{ _ []byte }
  3248  	val, lowered string
  3249  }
  3250  
  3251  // IdentifierCS is a case sensitive SQL identifier. It will be escaped with
  3252  // backquotes if necessary.
  3253  type IdentifierCS struct {
  3254  	v string
  3255  }