github.com/team-ide/go-dialect@v1.9.20/vitess/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  	// SelectStatement any SELECT statement.
    41  	SelectStatement interface {
    42  		Statement
    43  		iSelectStatement()
    44  		iInsertRows()
    45  		AddOrder(*Order)
    46  		SetOrderBy(OrderBy)
    47  		SetLimit(*Limit)
    48  		SetLock(lock Lock)
    49  		SetInto(into *SelectInto)
    50  		SetWith(with *With)
    51  		MakeDistinct()
    52  		GetColumnCount() int
    53  		SetComments(comments Comments)
    54  		GetComments() Comments
    55  	}
    56  
    57  	// DDLStatement represents any DDL Statement
    58  	DDLStatement interface {
    59  		iDDLStatement()
    60  		IsFullyParsed() bool
    61  		IsTemporary() bool
    62  		GetTable() TableName
    63  		GetAction() DDLAction
    64  		GetOptLike() *OptLike
    65  		GetIfExists() bool
    66  		GetIfNotExists() bool
    67  		GetTableSpec() *TableSpec
    68  		GetFromTables() TableNames
    69  		GetToTables() TableNames
    70  		AffectedTables() TableNames
    71  		SetTable(qualifier string, name string)
    72  		SetFromTables(tables TableNames)
    73  		SetComments(comments Comments)
    74  		GetComments() Comments
    75  		SetFullyParsed(fullyParsed bool)
    76  		Statement
    77  	}
    78  
    79  	// DBDDLStatement represents any DBDDL Statement
    80  	DBDDLStatement interface {
    81  		iDBDDLStatement()
    82  		IsFullyParsed() bool
    83  		GetDatabaseName() string
    84  		SetFullyParsed(bool)
    85  		Statement
    86  	}
    87  
    88  	// AlterOption is an interface that represents the various options in ALTER TABLE statements
    89  	AlterOption interface {
    90  		iAlterOption()
    91  		SQLNode
    92  	}
    93  
    94  	// Explain is an interface that represents the Explain statements
    95  	Explain interface {
    96  		Statement
    97  		iExplain()
    98  	}
    99  
   100  	// AddConstraintDefinition represents a ADD CONSTRAINT alter option
   101  	AddConstraintDefinition struct {
   102  		ConstraintDefinition *ConstraintDefinition
   103  	}
   104  
   105  	// AddIndexDefinition represents a ADD INDEX alter option
   106  	AddIndexDefinition struct {
   107  		IndexDefinition *IndexDefinition
   108  	}
   109  
   110  	// AddColumns represents a ADD COLUMN alter option
   111  	AddColumns struct {
   112  		Columns []*ColumnDefinition
   113  		First   bool
   114  		After   *ColName
   115  	}
   116  
   117  	// AlgorithmValue is the algorithm specified in the alter table command
   118  	AlgorithmValue string
   119  
   120  	// AlterColumn is used to add or drop defaults to columns in alter table command
   121  	AlterColumn struct {
   122  		Column      *ColName
   123  		DropDefault bool
   124  		DefaultVal  Expr
   125  	}
   126  
   127  	// With contains the lists of common table expression and specifies if it is recursive or not
   128  	With struct {
   129  		ctes      []*CommonTableExpr
   130  		Recursive bool
   131  	}
   132  
   133  	// CommonTableExpr is the structure for supporting common table expressions
   134  	CommonTableExpr struct {
   135  		TableID  TableIdent
   136  		Columns  Columns
   137  		Subquery *Subquery
   138  	}
   139  	// ChangeColumn is used to change the column definition, can also rename the column in alter table command
   140  	ChangeColumn struct {
   141  		OldColumn        *ColName
   142  		NewColDefinition *ColumnDefinition
   143  		First            bool
   144  		After            *ColName
   145  	}
   146  
   147  	// ModifyColumn is used to change the column definition in alter table command
   148  	ModifyColumn struct {
   149  		NewColDefinition *ColumnDefinition
   150  		First            bool
   151  		After            *ColName
   152  	}
   153  
   154  	// AlterCharset is used to set the default or change the character set and collation in alter table command
   155  	AlterCharset struct {
   156  		CharacterSet string
   157  		Collate      string
   158  	}
   159  
   160  	// KeyState is used to disable or enable the keys in an alter table statement
   161  	KeyState struct {
   162  		Enable bool
   163  	}
   164  
   165  	// TablespaceOperation is used to discard or import the tablespace in an alter table statement
   166  	TablespaceOperation struct {
   167  		Import bool
   168  	}
   169  
   170  	// DropColumn is used to drop a column in an alter table statement
   171  	DropColumn struct {
   172  		Name *ColName
   173  	}
   174  
   175  	// DropKeyType is an enum that represents the type of key being dropped in an alter table statement
   176  	DropKeyType int8
   177  
   178  	// DropKey is used to drop a key in an alter table statement
   179  	DropKey struct {
   180  		Type DropKeyType
   181  		Name ColIdent
   182  	}
   183  
   184  	// Force is used to specify force alter option in an alter table statement
   185  	Force struct{}
   186  
   187  	// LockOptionType is an enum for LockOption.Type
   188  	LockOptionType int8
   189  
   190  	// LockOption is used to specify the type of lock to use in an alter table statement
   191  	LockOption struct {
   192  		Type LockOptionType
   193  	}
   194  
   195  	// OrderByOption clause is used to specify the order by in an alter table statement
   196  	OrderByOption struct {
   197  		Cols Columns
   198  	}
   199  
   200  	// RenameTableName clause is used to rename the table in an alter table statement
   201  	RenameTableName struct {
   202  		Table TableName
   203  	}
   204  
   205  	// RenameIndex clause is used to rename indexes in an alter table statement
   206  	RenameIndex struct {
   207  		OldName ColIdent
   208  		NewName ColIdent
   209  	}
   210  
   211  	// Validation clause is used to specify whether to use validation or not
   212  	Validation struct {
   213  		With bool
   214  	}
   215  
   216  	// Select represents a SELECT statement.
   217  	Select struct {
   218  		Cache            *bool // a reference here so it can be nil
   219  		Distinct         bool
   220  		StraightJoinHint bool
   221  		SQLCalcFoundRows bool
   222  		// The From field must be the first AST element of this struct so the rewriter sees it first
   223  		From        []TableExpr
   224  		Comments    Comments
   225  		SelectExprs SelectExprs
   226  		Where       *Where
   227  		With        *With
   228  		GroupBy     GroupBy
   229  		Having      *Where
   230  		OrderBy     OrderBy
   231  		Limit       *Limit
   232  		Lock        Lock
   233  		Into        *SelectInto
   234  	}
   235  
   236  	// SelectInto is a struct that represent the INTO part of a select query
   237  	SelectInto struct {
   238  		Type         SelectIntoType
   239  		FileName     string
   240  		Charset      string
   241  		FormatOption string
   242  		ExportOption string
   243  		Manifest     string
   244  		Overwrite    string
   245  	}
   246  
   247  	// SelectIntoType is an enum for SelectInto.Type
   248  	SelectIntoType int8
   249  
   250  	// Lock is an enum for the type of lock in the statement
   251  	Lock int8
   252  
   253  	// Union represents a UNION statement.
   254  	Union struct {
   255  		Left     SelectStatement
   256  		Right    SelectStatement
   257  		Distinct bool
   258  		OrderBy  OrderBy
   259  		With     *With
   260  		Limit    *Limit
   261  		Lock     Lock
   262  		Into     *SelectInto
   263  	}
   264  
   265  	// VStream represents a VSTREAM statement.
   266  	VStream struct {
   267  		Comments   Comments
   268  		SelectExpr SelectExpr
   269  		Table      TableName
   270  		Where      *Where
   271  		Limit      *Limit
   272  	}
   273  
   274  	// Stream represents a SELECT statement.
   275  	Stream struct {
   276  		Comments   Comments
   277  		SelectExpr SelectExpr
   278  		Table      TableName
   279  	}
   280  
   281  	// Insert represents an INSERT or REPLACE statement.
   282  	// Per the MySQL docs, http://dev.mysql.com/doc/refman/5.7/en/replace.html
   283  	// Replace is the counterpart to `INSERT IGNORE`, and works exactly like a
   284  	// normal INSERT except if the row exists. In that case it first deletes
   285  	// the row and re-inserts with new values. For that reason we keep it as an Insert struct.
   286  	// Replaces are currently disallowed in sharded schemas because
   287  	// of the implications the deletion part may have on vindexes.
   288  	// If you add fields here, consider adding them to calls to validateUnshardedRoute.
   289  	Insert struct {
   290  		Action     InsertAction
   291  		Comments   Comments
   292  		Ignore     Ignore
   293  		Table      TableName
   294  		Partitions Partitions
   295  		Columns    Columns
   296  		Rows       InsertRows
   297  		OnDup      OnDup
   298  	}
   299  
   300  	// Ignore represents whether ignore was specified or not
   301  	Ignore bool
   302  
   303  	// InsertAction is the action for insert.
   304  	InsertAction int8
   305  
   306  	// Update represents an UPDATE statement.
   307  	// If you add fields here, consider adding them to calls to validateUnshardedRoute.
   308  	Update struct {
   309  		With       *With
   310  		Comments   Comments
   311  		Ignore     Ignore
   312  		TableExprs TableExprs
   313  		Exprs      UpdateExprs
   314  		Where      *Where
   315  		OrderBy    OrderBy
   316  		Limit      *Limit
   317  	}
   318  
   319  	// Delete represents a DELETE statement.
   320  	// If you add fields here, consider adding them to calls to validateUnshardedRoute.
   321  	Delete struct {
   322  		With       *With
   323  		Ignore     Ignore
   324  		Comments   Comments
   325  		Targets    TableNames
   326  		TableExprs TableExprs
   327  		Partitions Partitions
   328  		Where      *Where
   329  		OrderBy    OrderBy
   330  		Limit      *Limit
   331  	}
   332  
   333  	// Set represents a SET statement.
   334  	Set struct {
   335  		Comments Comments
   336  		Exprs    SetExprs
   337  	}
   338  
   339  	// SetTransaction represents a SET TRANSACTION statement.
   340  	SetTransaction struct {
   341  		SQLNode
   342  		Comments        Comments
   343  		Scope           Scope
   344  		Characteristics []Characteristic
   345  	}
   346  
   347  	// Scope is an enum for scope of query
   348  	Scope int8
   349  
   350  	// Characteristic is a transaction related change
   351  	Characteristic interface {
   352  		SQLNode
   353  		iChar()
   354  	}
   355  
   356  	// IsolationLevel is an enum for isolation levels
   357  	IsolationLevel int8
   358  
   359  	// AccessMode is enum for the mode - ReadOnly or ReadWrite
   360  	AccessMode int8
   361  
   362  	// DropDatabase represents a DROP database statement.
   363  	DropDatabase struct {
   364  		Comments Comments
   365  		DBName   TableIdent
   366  		IfExists bool
   367  	}
   368  
   369  	// CollateAndCharsetType is an enum for CollateAndCharset.Type
   370  	CollateAndCharsetType int8
   371  
   372  	// CollateAndCharset is a struct that stores Collation or Character Set value
   373  	CollateAndCharset struct {
   374  		Type      CollateAndCharsetType
   375  		IsDefault bool
   376  		Value     string
   377  	}
   378  
   379  	// CreateDatabase represents a CREATE database statement.
   380  	CreateDatabase struct {
   381  		Comments      Comments
   382  		DBName        TableIdent
   383  		IfNotExists   bool
   384  		CreateOptions []CollateAndCharset
   385  		FullyParsed   bool
   386  	}
   387  
   388  	// AlterDatabase represents a ALTER database statement.
   389  	AlterDatabase struct {
   390  		DBName              TableIdent
   391  		UpdateDataDirectory bool
   392  		AlterOptions        []CollateAndCharset
   393  		FullyParsed         bool
   394  	}
   395  
   396  	// Flush represents a FLUSH statement.
   397  	Flush struct {
   398  		IsLocal      bool
   399  		FlushOptions []string
   400  		TableNames   TableNames
   401  		WithLock     bool
   402  		ForExport    bool
   403  	}
   404  
   405  	// RenameTablePair represents the name of the original table and what it is going to be set in a RENAME TABLE statement.
   406  	RenameTablePair struct {
   407  		FromTable TableName
   408  		ToTable   TableName
   409  	}
   410  
   411  	// RenameTable represents a RENAME TABLE statement.
   412  	RenameTable struct {
   413  		TablePairs []*RenameTablePair
   414  	}
   415  
   416  	// TruncateTable represents a TRUNCATE TABLE statement.
   417  	TruncateTable struct {
   418  		Table TableName
   419  	}
   420  
   421  	// AlterVschema represents a ALTER VSCHEMA statement.
   422  	AlterVschema struct {
   423  		Action DDLAction
   424  		Table  TableName
   425  
   426  		// VindexSpec is set for CreateVindexDDLAction, DropVindexDDLAction, AddColVindexDDLAction, DropColVindexDDLAction.
   427  		VindexSpec *VindexSpec
   428  
   429  		// VindexCols is set for AddColVindexDDLAction.
   430  		VindexCols []ColIdent
   431  
   432  		// AutoIncSpec is set for AddAutoIncDDLAction.
   433  		AutoIncSpec *AutoIncSpec
   434  	}
   435  
   436  	// ShowMigrationLogs represents a SHOW VITESS_MIGRATION '<uuid>' LOGS statement
   437  	ShowMigrationLogs struct {
   438  		UUID     string
   439  		Comments Comments
   440  	}
   441  
   442  	// RevertMigration represents a REVERT VITESS_MIGRATION statement
   443  	RevertMigration struct {
   444  		UUID     string
   445  		Comments Comments
   446  	}
   447  
   448  	// AlterMigrationType represents the type of operation in an ALTER VITESS_MIGRATION statement
   449  	AlterMigrationType int8
   450  
   451  	// AlterMigration represents a ALTER VITESS_MIGRATION statement
   452  	AlterMigration struct {
   453  		Type AlterMigrationType
   454  		UUID string
   455  	}
   456  
   457  	// AlterTable represents a ALTER TABLE statement.
   458  	AlterTable struct {
   459  		Table         TableName
   460  		AlterOptions  []AlterOption
   461  		PartitionSpec *PartitionSpec
   462  		Comments      Comments
   463  		FullyParsed   bool
   464  	}
   465  
   466  	// DropTable represents a DROP TABLE statement.
   467  	DropTable struct {
   468  		Temp       bool
   469  		FromTables TableNames
   470  		// The following fields are set if a DDL was fully analyzed.
   471  		IfExists bool
   472  		Comments Comments
   473  	}
   474  
   475  	// DropView represents a DROP VIEW statement.
   476  	DropView struct {
   477  		FromTables TableNames
   478  		IfExists   bool
   479  	}
   480  
   481  	// CreateTable represents a CREATE TABLE statement.
   482  	CreateTable struct {
   483  		Temp        bool
   484  		Table       TableName
   485  		IfNotExists bool
   486  		TableSpec   *TableSpec
   487  		OptLike     *OptLike
   488  		Comments    Comments
   489  		FullyParsed bool
   490  	}
   491  
   492  	// CreateView represents a CREATE VIEW query
   493  	CreateView struct {
   494  		ViewName    TableName
   495  		Algorithm   string
   496  		Definer     string
   497  		Security    string
   498  		Columns     Columns
   499  		Select      SelectStatement
   500  		CheckOption string
   501  		IsReplace   bool
   502  	}
   503  
   504  	// AlterView represents a ALTER VIEW query
   505  	AlterView struct {
   506  		ViewName    TableName
   507  		Algorithm   string
   508  		Definer     string
   509  		Security    string
   510  		Columns     Columns
   511  		Select      SelectStatement
   512  		CheckOption string
   513  	}
   514  
   515  	// DDLAction is an enum for DDL.Action
   516  	DDLAction int8
   517  
   518  	// Load represents a LOAD statement
   519  	Load struct {
   520  	}
   521  
   522  	// Show represents a show statement.
   523  	Show struct {
   524  		Internal ShowInternal
   525  	}
   526  
   527  	// Use represents a use statement.
   528  	Use struct {
   529  		DBName TableIdent
   530  	}
   531  
   532  	// Begin represents a Begin statement.
   533  	Begin struct{}
   534  
   535  	// Commit represents a Commit statement.
   536  	Commit struct{}
   537  
   538  	// Rollback represents a Rollback statement.
   539  	Rollback struct{}
   540  
   541  	// SRollback represents a rollback to savepoint statement.
   542  	SRollback struct {
   543  		Name ColIdent
   544  	}
   545  
   546  	// Savepoint represents a savepoint statement.
   547  	Savepoint struct {
   548  		Name ColIdent
   549  	}
   550  
   551  	// Release represents a release savepoint statement.
   552  	Release struct {
   553  		Name ColIdent
   554  	}
   555  
   556  	// CallProc represents a CALL statement
   557  	CallProc struct {
   558  		Name   TableName
   559  		Params Exprs
   560  	}
   561  
   562  	// LockType is an enum for Lock Types
   563  	LockType int8
   564  
   565  	// TableAndLockType contains table and lock association
   566  	TableAndLockType struct {
   567  		Table TableExpr
   568  		Lock  LockType
   569  	}
   570  
   571  	// TableAndLockTypes is a slice of TableAndLockType
   572  	TableAndLockTypes []*TableAndLockType
   573  
   574  	// LockTables represents the lock statement
   575  	LockTables struct {
   576  		Tables TableAndLockTypes
   577  	}
   578  
   579  	// UnlockTables represents the unlock statement
   580  	UnlockTables struct{}
   581  
   582  	// ExplainType is an enum for ExplainStmt.Type
   583  	ExplainType int8
   584  
   585  	// ExplainStmt represents an Explain statement
   586  	ExplainStmt struct {
   587  		Type      ExplainType
   588  		Statement Statement
   589  	}
   590  
   591  	// ExplainTab represents the Explain table
   592  	ExplainTab struct {
   593  		Table TableName
   594  		Wild  string
   595  	}
   596  	// IntervalTypes is an enum to get types of intervals
   597  	IntervalTypes int8
   598  
   599  	// OtherRead represents a DESCRIBE, or EXPLAIN statement.
   600  	// It should be used only as an indicator. It does not contain
   601  	// the full AST for the statement.
   602  	OtherRead struct{}
   603  
   604  	// OtherAdmin represents a misc statement that relies on ADMIN privileges,
   605  	// such as REPAIR, OPTIMIZE, or TRUNCATE statement.
   606  	// It should be used only as an indicator. It does not contain
   607  	// the full AST for the statement.
   608  	OtherAdmin struct{}
   609  )
   610  
   611  func (*Union) iStatement()             {}
   612  func (*Select) iStatement()            {}
   613  func (*Stream) iStatement()            {}
   614  func (*VStream) iStatement()           {}
   615  func (*Insert) iStatement()            {}
   616  func (*Update) iStatement()            {}
   617  func (*Delete) iStatement()            {}
   618  func (*Set) iStatement()               {}
   619  func (*SetTransaction) iStatement()    {}
   620  func (*DropDatabase) iStatement()      {}
   621  func (*Flush) iStatement()             {}
   622  func (*Show) iStatement()              {}
   623  func (*Use) iStatement()               {}
   624  func (*Begin) iStatement()             {}
   625  func (*Commit) iStatement()            {}
   626  func (*Rollback) iStatement()          {}
   627  func (*SRollback) iStatement()         {}
   628  func (*Savepoint) iStatement()         {}
   629  func (*Release) iStatement()           {}
   630  func (*OtherRead) iStatement()         {}
   631  func (*OtherAdmin) iStatement()        {}
   632  func (*Select) iSelectStatement()      {}
   633  func (*Union) iSelectStatement()       {}
   634  func (*Load) iStatement()              {}
   635  func (*CreateDatabase) iStatement()    {}
   636  func (*AlterDatabase) iStatement()     {}
   637  func (*CreateTable) iStatement()       {}
   638  func (*CreateView) iStatement()        {}
   639  func (*AlterView) iStatement()         {}
   640  func (*LockTables) iStatement()        {}
   641  func (*UnlockTables) iStatement()      {}
   642  func (*AlterTable) iStatement()        {}
   643  func (*AlterVschema) iStatement()      {}
   644  func (*AlterMigration) iStatement()    {}
   645  func (*RevertMigration) iStatement()   {}
   646  func (*ShowMigrationLogs) iStatement() {}
   647  func (*DropTable) iStatement()         {}
   648  func (*DropView) iStatement()          {}
   649  func (*TruncateTable) iStatement()     {}
   650  func (*RenameTable) iStatement()       {}
   651  func (*CallProc) iStatement()          {}
   652  func (*ExplainStmt) iStatement()       {}
   653  func (*ExplainTab) iStatement()        {}
   654  
   655  func (*CreateView) iDDLStatement()    {}
   656  func (*AlterView) iDDLStatement()     {}
   657  func (*CreateTable) iDDLStatement()   {}
   658  func (*DropTable) iDDLStatement()     {}
   659  func (*DropView) iDDLStatement()      {}
   660  func (*AlterTable) iDDLStatement()    {}
   661  func (*TruncateTable) iDDLStatement() {}
   662  func (*RenameTable) iDDLStatement()   {}
   663  
   664  func (*AddConstraintDefinition) iAlterOption() {}
   665  func (*AddIndexDefinition) iAlterOption()      {}
   666  func (*AddColumns) iAlterOption()              {}
   667  func (AlgorithmValue) iAlterOption()           {}
   668  func (*AlterColumn) iAlterOption()             {}
   669  func (*ChangeColumn) iAlterOption()            {}
   670  func (*ModifyColumn) iAlterOption()            {}
   671  func (*AlterCharset) iAlterOption()            {}
   672  func (*KeyState) iAlterOption()                {}
   673  func (*TablespaceOperation) iAlterOption()     {}
   674  func (*DropColumn) iAlterOption()              {}
   675  func (*DropKey) iAlterOption()                 {}
   676  func (*Force) iAlterOption()                   {}
   677  func (*LockOption) iAlterOption()              {}
   678  func (*OrderByOption) iAlterOption()           {}
   679  func (*RenameTableName) iAlterOption()         {}
   680  func (*RenameIndex) iAlterOption()             {}
   681  func (*Validation) iAlterOption()              {}
   682  func (TableOptions) iAlterOption()             {}
   683  
   684  func (*ExplainStmt) iExplain() {}
   685  func (*ExplainTab) iExplain()  {}
   686  
   687  // IsFullyParsed implements the DDLStatement interface
   688  func (*TruncateTable) IsFullyParsed() bool {
   689  	return true
   690  }
   691  
   692  // SetFullyParsed implements the DDLStatement interface
   693  func (*TruncateTable) SetFullyParsed(bool) {}
   694  
   695  // IsFullyParsed implements the DDLStatement interface
   696  func (*RenameTable) IsFullyParsed() bool {
   697  	return true
   698  }
   699  
   700  // SetFullyParsed implements the DDLStatement interface
   701  func (node *RenameTable) SetFullyParsed(fullyParsed bool) {}
   702  
   703  // IsFullyParsed implements the DDLStatement interface
   704  func (node *CreateTable) IsFullyParsed() bool {
   705  	return node.FullyParsed
   706  }
   707  
   708  // SetFullyParsed implements the DDLStatement interface
   709  func (node *CreateTable) SetFullyParsed(fullyParsed bool) {
   710  	node.FullyParsed = fullyParsed
   711  }
   712  
   713  // IsFullyParsed implements the DDLStatement interface
   714  func (node *AlterTable) IsFullyParsed() bool {
   715  	return node.FullyParsed
   716  }
   717  
   718  // SetFullyParsed implements the DDLStatement interface
   719  func (node *AlterTable) SetFullyParsed(fullyParsed bool) {
   720  	node.FullyParsed = fullyParsed
   721  }
   722  
   723  // IsFullyParsed implements the DDLStatement interface
   724  func (node *CreateView) IsFullyParsed() bool {
   725  	return true
   726  }
   727  
   728  // SetFullyParsed implements the DDLStatement interface
   729  func (node *CreateView) SetFullyParsed(fullyParsed bool) {}
   730  
   731  // IsFullyParsed implements the DDLStatement interface
   732  func (node *DropView) IsFullyParsed() bool {
   733  	return true
   734  }
   735  
   736  // SetFullyParsed implements the DDLStatement interface
   737  func (node *DropView) SetFullyParsed(fullyParsed bool) {}
   738  
   739  // IsFullyParsed implements the DDLStatement interface
   740  func (node *DropTable) IsFullyParsed() bool {
   741  	return true
   742  }
   743  
   744  // SetFullyParsed implements the DDLStatement interface
   745  func (node *DropTable) SetFullyParsed(fullyParsed bool) {}
   746  
   747  // IsFullyParsed implements the DDLStatement interface
   748  func (node *AlterView) IsFullyParsed() bool {
   749  	return true
   750  }
   751  
   752  // SetFullyParsed implements the DDLStatement interface
   753  func (node *AlterView) SetFullyParsed(fullyParsed bool) {}
   754  
   755  // IsTemporary implements the DDLStatement interface
   756  func (*TruncateTable) IsTemporary() bool {
   757  	return false
   758  }
   759  
   760  // IsTemporary implements the DDLStatement interface
   761  func (*RenameTable) IsTemporary() bool {
   762  	return false
   763  }
   764  
   765  // IsTemporary implements the DDLStatement interface
   766  func (node *CreateTable) IsTemporary() bool {
   767  	return node.Temp
   768  }
   769  
   770  // IsTemporary implements the DDLStatement interface
   771  func (node *AlterTable) IsTemporary() bool {
   772  	return false
   773  }
   774  
   775  // IsTemporary implements the DDLStatement interface
   776  func (node *CreateView) IsTemporary() bool {
   777  	return false
   778  }
   779  
   780  // IsTemporary implements the DDLStatement interface
   781  func (node *DropView) IsTemporary() bool {
   782  	return false
   783  }
   784  
   785  // IsTemporary implements the DDLStatement interface
   786  func (node *DropTable) IsTemporary() bool {
   787  	return node.Temp
   788  }
   789  
   790  // IsTemporary implements the DDLStatement interface
   791  func (node *AlterView) IsTemporary() bool {
   792  	return false
   793  }
   794  
   795  // GetTable implements the DDLStatement interface
   796  func (node *TruncateTable) GetTable() TableName {
   797  	return node.Table
   798  }
   799  
   800  // GetTable implements the DDLStatement interface
   801  func (node *CreateTable) GetTable() TableName {
   802  	return node.Table
   803  }
   804  
   805  // GetTable implements the DDLStatement interface
   806  func (node *AlterTable) GetTable() TableName {
   807  	return node.Table
   808  }
   809  
   810  // GetTable implements the DDLStatement interface
   811  func (node *CreateView) GetTable() TableName {
   812  	return node.ViewName
   813  }
   814  
   815  // GetTable implements the DDLStatement interface
   816  func (node *AlterView) GetTable() TableName {
   817  	return node.ViewName
   818  }
   819  
   820  // GetTable implements the DDLStatement interface
   821  func (node *DropView) GetTable() TableName {
   822  	return TableName{}
   823  }
   824  
   825  // GetTable implements the DDLStatement interface
   826  func (node *DropTable) GetTable() TableName {
   827  	return TableName{}
   828  }
   829  
   830  // GetTable implements the DDLStatement interface
   831  func (node *RenameTable) GetTable() TableName {
   832  	return TableName{}
   833  }
   834  
   835  // GetAction implements the DDLStatement interface
   836  func (node *TruncateTable) GetAction() DDLAction {
   837  	return TruncateDDLAction
   838  }
   839  
   840  // GetAction implements the DDLStatement interface
   841  func (node *AlterTable) GetAction() DDLAction {
   842  	return AlterDDLAction
   843  }
   844  
   845  // GetAction implements the DDLStatement interface
   846  func (node *CreateTable) GetAction() DDLAction {
   847  	return CreateDDLAction
   848  }
   849  
   850  // GetAction implements the DDLStatement interface
   851  func (node *CreateView) GetAction() DDLAction {
   852  	return CreateDDLAction
   853  }
   854  
   855  // GetAction implements the DDLStatement interface
   856  func (node *AlterView) GetAction() DDLAction {
   857  	return AlterDDLAction
   858  }
   859  
   860  // GetAction implements the DDLStatement interface
   861  func (node *RenameTable) GetAction() DDLAction {
   862  	return RenameDDLAction
   863  }
   864  
   865  // GetAction implements the DDLStatement interface
   866  func (node *DropTable) GetAction() DDLAction {
   867  	return DropDDLAction
   868  }
   869  
   870  // GetAction implements the DDLStatement interface
   871  func (node *DropView) GetAction() DDLAction {
   872  	return DropDDLAction
   873  }
   874  
   875  // GetOptLike implements the DDLStatement interface
   876  func (node *CreateTable) GetOptLike() *OptLike {
   877  	return node.OptLike
   878  }
   879  
   880  // GetOptLike implements the DDLStatement interface
   881  func (node *TruncateTable) GetOptLike() *OptLike {
   882  	return nil
   883  }
   884  
   885  // GetOptLike implements the DDLStatement interface
   886  func (node *RenameTable) GetOptLike() *OptLike {
   887  	return nil
   888  }
   889  
   890  // GetOptLike implements the DDLStatement interface
   891  func (node *AlterTable) GetOptLike() *OptLike {
   892  	return nil
   893  }
   894  
   895  // GetOptLike implements the DDLStatement interface
   896  func (node *CreateView) GetOptLike() *OptLike {
   897  	return nil
   898  }
   899  
   900  // GetOptLike implements the DDLStatement interface
   901  func (node *AlterView) GetOptLike() *OptLike {
   902  	return nil
   903  }
   904  
   905  // GetOptLike implements the DDLStatement interface
   906  func (node *DropTable) GetOptLike() *OptLike {
   907  	return nil
   908  }
   909  
   910  // GetOptLike implements the DDLStatement interface
   911  func (node *DropView) GetOptLike() *OptLike {
   912  	return nil
   913  }
   914  
   915  // GetIfExists implements the DDLStatement interface
   916  func (node *RenameTable) GetIfExists() bool {
   917  	return false
   918  }
   919  
   920  // GetIfExists implements the DDLStatement interface
   921  func (node *CreateTable) GetIfExists() bool {
   922  	return false
   923  }
   924  
   925  // GetIfExists implements the DDLStatement interface
   926  func (node *TruncateTable) GetIfExists() bool {
   927  	return false
   928  }
   929  
   930  // GetIfExists implements the DDLStatement interface
   931  func (node *AlterTable) GetIfExists() bool {
   932  	return false
   933  }
   934  
   935  // GetIfExists implements the DDLStatement interface
   936  func (node *CreateView) GetIfExists() bool {
   937  	return false
   938  }
   939  
   940  // GetIfExists implements the DDLStatement interface
   941  func (node *AlterView) GetIfExists() bool {
   942  	return false
   943  }
   944  
   945  // GetIfExists implements the DDLStatement interface
   946  func (node *DropTable) GetIfExists() bool {
   947  	return node.IfExists
   948  }
   949  
   950  // GetIfExists implements the DDLStatement interface
   951  func (node *DropView) GetIfExists() bool {
   952  	return node.IfExists
   953  }
   954  
   955  // GetIfNotExists implements the DDLStatement interface
   956  func (node *RenameTable) GetIfNotExists() bool {
   957  	return false
   958  }
   959  
   960  // GetIfNotExists implements the DDLStatement interface
   961  func (node *CreateTable) GetIfNotExists() bool {
   962  	return node.IfNotExists
   963  }
   964  
   965  // GetIfNotExists implements the DDLStatement interface
   966  func (node *TruncateTable) GetIfNotExists() bool {
   967  	return false
   968  }
   969  
   970  // GetIfNotExists implements the DDLStatement interface
   971  func (node *AlterTable) GetIfNotExists() bool {
   972  	return false
   973  }
   974  
   975  // GetIfNotExists implements the DDLStatement interface
   976  func (node *CreateView) GetIfNotExists() bool {
   977  	return false
   978  }
   979  
   980  // GetIfNotExists implements the DDLStatement interface
   981  func (node *AlterView) GetIfNotExists() bool {
   982  	return false
   983  }
   984  
   985  // GetIfNotExists implements the DDLStatement interface
   986  func (node *DropTable) GetIfNotExists() bool {
   987  	return false
   988  }
   989  
   990  // GetIfNotExists implements the DDLStatement interface
   991  func (node *DropView) GetIfNotExists() bool {
   992  	return false
   993  }
   994  
   995  // GetTableSpec implements the DDLStatement interface
   996  func (node *CreateTable) GetTableSpec() *TableSpec {
   997  	return node.TableSpec
   998  }
   999  
  1000  // GetTableSpec implements the DDLStatement interface
  1001  func (node *RenameTable) GetTableSpec() *TableSpec {
  1002  	return nil
  1003  }
  1004  
  1005  // GetTableSpec implements the DDLStatement interface
  1006  func (node *TruncateTable) GetTableSpec() *TableSpec {
  1007  	return nil
  1008  }
  1009  
  1010  // GetTableSpec implements the DDLStatement interface
  1011  func (node *AlterTable) GetTableSpec() *TableSpec {
  1012  	return nil
  1013  }
  1014  
  1015  // GetTableSpec implements the DDLStatement interface
  1016  func (node *CreateView) GetTableSpec() *TableSpec {
  1017  	return nil
  1018  }
  1019  
  1020  // GetTableSpec implements the DDLStatement interface
  1021  func (node *AlterView) GetTableSpec() *TableSpec {
  1022  	return nil
  1023  }
  1024  
  1025  // GetTableSpec implements the DDLStatement interface
  1026  func (node *DropTable) GetTableSpec() *TableSpec {
  1027  	return nil
  1028  }
  1029  
  1030  // GetTableSpec implements the DDLStatement interface
  1031  func (node *DropView) GetTableSpec() *TableSpec {
  1032  	return nil
  1033  }
  1034  
  1035  // GetFromTables implements the DDLStatement interface
  1036  func (node *RenameTable) GetFromTables() TableNames {
  1037  	var fromTables TableNames
  1038  	for _, pair := range node.TablePairs {
  1039  		fromTables = append(fromTables, pair.FromTable)
  1040  	}
  1041  	return fromTables
  1042  }
  1043  
  1044  // GetFromTables implements the DDLStatement interface
  1045  func (node *TruncateTable) GetFromTables() TableNames {
  1046  	return nil
  1047  }
  1048  
  1049  // GetFromTables implements the DDLStatement interface
  1050  func (node *AlterTable) GetFromTables() TableNames {
  1051  	return nil
  1052  }
  1053  
  1054  // GetFromTables implements the DDLStatement interface
  1055  func (node *CreateTable) GetFromTables() TableNames {
  1056  	return nil
  1057  }
  1058  
  1059  // GetFromTables implements the DDLStatement interface
  1060  func (node *CreateView) GetFromTables() TableNames {
  1061  	return nil
  1062  }
  1063  
  1064  // GetFromTables implements the DDLStatement interface
  1065  func (node *DropTable) GetFromTables() TableNames {
  1066  	return node.FromTables
  1067  }
  1068  
  1069  // GetFromTables implements the DDLStatement interface
  1070  func (node *DropView) GetFromTables() TableNames {
  1071  	return node.FromTables
  1072  }
  1073  
  1074  // GetFromTables implements the DDLStatement interface
  1075  func (node *AlterView) GetFromTables() TableNames {
  1076  	return nil
  1077  }
  1078  
  1079  // SetFromTables implements DDLStatement.
  1080  func (node *RenameTable) SetFromTables(tables TableNames) {
  1081  	if len(node.TablePairs) != len(tables) {
  1082  		return
  1083  	}
  1084  	for i := range node.TablePairs {
  1085  		node.TablePairs[i].FromTable = tables[i]
  1086  	}
  1087  }
  1088  
  1089  // SetFromTables implements DDLStatement.
  1090  func (node *TruncateTable) SetFromTables(tables TableNames) {
  1091  	// irrelevant
  1092  }
  1093  
  1094  // SetFromTables implements DDLStatement.
  1095  func (node *AlterTable) SetFromTables(tables TableNames) {
  1096  	// irrelevant
  1097  }
  1098  
  1099  // SetFromTables implements DDLStatement.
  1100  func (node *CreateTable) SetFromTables(tables TableNames) {
  1101  	// irrelevant
  1102  }
  1103  
  1104  // SetFromTables implements DDLStatement.
  1105  func (node *CreateView) SetFromTables(tables TableNames) {
  1106  	// irrelevant
  1107  }
  1108  
  1109  // SetFromTables implements DDLStatement.
  1110  func (node *DropTable) SetFromTables(tables TableNames) {
  1111  	node.FromTables = tables
  1112  }
  1113  
  1114  // SetFromTables implements DDLStatement.
  1115  func (node *DropView) SetFromTables(tables TableNames) {
  1116  	node.FromTables = tables
  1117  }
  1118  
  1119  // SetFromTables implements DDLStatement.
  1120  func (node *AlterView) SetFromTables(tables TableNames) {
  1121  	// irrelevant
  1122  }
  1123  
  1124  // SetComments implements DDLStatement.
  1125  func (node *RenameTable) SetComments(comments Comments) {
  1126  	// irrelevant
  1127  }
  1128  
  1129  // SetComments implements DDLStatement.
  1130  func (node *TruncateTable) SetComments(comments Comments) {
  1131  	// irrelevant
  1132  }
  1133  
  1134  // SetComments implements DDLStatement.
  1135  func (node *AlterTable) SetComments(comments Comments) {
  1136  	node.Comments = comments
  1137  }
  1138  
  1139  // SetComments implements DDLStatement.
  1140  func (node *CreateTable) SetComments(comments Comments) {
  1141  	node.Comments = comments
  1142  }
  1143  
  1144  // SetComments implements DDLStatement.
  1145  func (node *CreateView) SetComments(comments Comments) {
  1146  	// irrelevant
  1147  }
  1148  
  1149  // SetComments implements DDLStatement.
  1150  func (node *DropTable) SetComments(comments Comments) {
  1151  	node.Comments = comments
  1152  }
  1153  
  1154  // SetComments implements DDLStatement.
  1155  func (node *DropView) SetComments(comments Comments) {
  1156  	// irrelevant
  1157  }
  1158  
  1159  // SetComments implements DDLStatement.
  1160  func (node *AlterView) SetComments(comments Comments) {
  1161  	// irrelevant
  1162  }
  1163  
  1164  // SetComments for RevertMigration, does not implement DDLStatement
  1165  func (node *RevertMigration) SetComments(comments Comments) {
  1166  	node.Comments = comments
  1167  }
  1168  
  1169  // GetComments implements DDLStatement.
  1170  func (node *RenameTable) GetComments() Comments {
  1171  	// irrelevant
  1172  	return nil
  1173  }
  1174  
  1175  // GetComments implements DDLStatement.
  1176  func (node *TruncateTable) GetComments() Comments {
  1177  	// irrelevant
  1178  	return nil
  1179  }
  1180  
  1181  // GetComments implements DDLStatement.
  1182  func (node *AlterTable) GetComments() Comments {
  1183  	return node.Comments
  1184  }
  1185  
  1186  // GetComments implements DDLStatement.
  1187  func (node *CreateTable) GetComments() Comments {
  1188  	return node.Comments
  1189  }
  1190  
  1191  // GetComments implements DDLStatement.
  1192  func (node *CreateView) GetComments() Comments {
  1193  	// irrelevant
  1194  	return nil
  1195  }
  1196  
  1197  // GetComments implements DDLStatement.
  1198  func (node *DropTable) GetComments() Comments {
  1199  	return node.Comments
  1200  }
  1201  
  1202  // GetComments implements DDLStatement.
  1203  func (node *DropView) GetComments() Comments {
  1204  	// irrelevant
  1205  	return nil
  1206  }
  1207  
  1208  // GetComments implements DDLStatement.
  1209  func (node *AlterView) GetComments() Comments {
  1210  	// irrelevant
  1211  	return nil
  1212  }
  1213  
  1214  // GetToTables implements the DDLStatement interface
  1215  func (node *RenameTable) GetToTables() TableNames {
  1216  	var toTables TableNames
  1217  	for _, pair := range node.TablePairs {
  1218  		toTables = append(toTables, pair.ToTable)
  1219  	}
  1220  	return toTables
  1221  }
  1222  
  1223  // GetToTables implements the DDLStatement interface
  1224  func (node *TruncateTable) GetToTables() TableNames {
  1225  	return nil
  1226  }
  1227  
  1228  // GetToTables implements the DDLStatement interface
  1229  func (node *AlterTable) GetToTables() TableNames {
  1230  	for _, option := range node.AlterOptions {
  1231  		switch altOption := option.(type) {
  1232  		case *RenameTableName:
  1233  			return TableNames{altOption.Table}
  1234  		}
  1235  	}
  1236  	return nil
  1237  }
  1238  
  1239  // GetToTables implements the DDLStatement interface
  1240  func (node *CreateView) GetToTables() TableNames {
  1241  	return nil
  1242  }
  1243  
  1244  // GetToTables implements the DDLStatement interface
  1245  func (node *AlterView) GetToTables() TableNames {
  1246  	return nil
  1247  }
  1248  
  1249  // GetToTables implements the DDLStatement interface
  1250  func (node *CreateTable) GetToTables() TableNames {
  1251  	return nil
  1252  }
  1253  
  1254  // GetToTables implements the DDLStatement interface
  1255  func (node *DropTable) GetToTables() TableNames {
  1256  	return nil
  1257  }
  1258  
  1259  // GetToTables implements the DDLStatement interface
  1260  func (node *DropView) GetToTables() TableNames {
  1261  	return nil
  1262  }
  1263  
  1264  // AffectedTables returns the list table names affected by the DDLStatement.
  1265  func (node *RenameTable) AffectedTables() TableNames {
  1266  	list := make(TableNames, 0, 2*len(node.TablePairs))
  1267  	for _, pair := range node.TablePairs {
  1268  		list = append(list, pair.FromTable)
  1269  		list = append(list, pair.ToTable)
  1270  	}
  1271  	return list
  1272  }
  1273  
  1274  // AffectedTables returns the list table names affected by the DDLStatement.
  1275  func (node *AlterTable) AffectedTables() TableNames {
  1276  	affectedTables := TableNames{node.Table}
  1277  	for _, option := range node.AlterOptions {
  1278  		switch altOption := option.(type) {
  1279  		case *RenameTableName:
  1280  			affectedTables = append(affectedTables, altOption.Table)
  1281  		}
  1282  	}
  1283  	return affectedTables
  1284  }
  1285  
  1286  // AffectedTables implements DDLStatement.
  1287  func (node *TruncateTable) AffectedTables() TableNames {
  1288  	return TableNames{node.Table}
  1289  }
  1290  
  1291  // AffectedTables implements DDLStatement.
  1292  func (node *CreateTable) AffectedTables() TableNames {
  1293  	return TableNames{node.Table}
  1294  }
  1295  
  1296  // AffectedTables implements DDLStatement.
  1297  func (node *CreateView) AffectedTables() TableNames {
  1298  	return TableNames{node.ViewName}
  1299  }
  1300  
  1301  // AffectedTables implements DDLStatement.
  1302  func (node *AlterView) AffectedTables() TableNames {
  1303  	return TableNames{node.ViewName}
  1304  }
  1305  
  1306  // AffectedTables returns the list table names affected by the DDLStatement.
  1307  func (node *DropTable) AffectedTables() TableNames {
  1308  	return node.FromTables
  1309  }
  1310  
  1311  // AffectedTables returns the list table names affected by the DDLStatement.
  1312  func (node *DropView) AffectedTables() TableNames {
  1313  	return node.FromTables
  1314  }
  1315  
  1316  // SetTable implements DDLStatement.
  1317  func (node *TruncateTable) SetTable(qualifier string, name string) {
  1318  	node.Table.Qualifier = NewTableIdent(qualifier)
  1319  	node.Table.Name = NewTableIdent(name)
  1320  }
  1321  
  1322  // SetTable implements DDLStatement.
  1323  func (node *AlterTable) SetTable(qualifier string, name string) {
  1324  	node.Table.Qualifier = NewTableIdent(qualifier)
  1325  	node.Table.Name = NewTableIdent(name)
  1326  }
  1327  
  1328  // SetTable implements DDLStatement.
  1329  func (node *CreateTable) SetTable(qualifier string, name string) {
  1330  	node.Table.Qualifier = NewTableIdent(qualifier)
  1331  	node.Table.Name = NewTableIdent(name)
  1332  }
  1333  
  1334  // SetTable implements DDLStatement.
  1335  func (node *CreateView) SetTable(qualifier string, name string) {
  1336  	node.ViewName.Qualifier = NewTableIdent(qualifier)
  1337  	node.ViewName.Name = NewTableIdent(name)
  1338  }
  1339  
  1340  // SetTable implements DDLStatement.
  1341  func (node *AlterView) SetTable(qualifier string, name string) {
  1342  	node.ViewName.Qualifier = NewTableIdent(qualifier)
  1343  	node.ViewName.Name = NewTableIdent(name)
  1344  }
  1345  
  1346  // SetTable implements DDLStatement.
  1347  func (node *RenameTable) SetTable(qualifier string, name string) {}
  1348  
  1349  // SetTable implements DDLStatement.
  1350  func (node *DropTable) SetTable(qualifier string, name string) {}
  1351  
  1352  // SetTable implements DDLStatement.
  1353  func (node *DropView) SetTable(qualifier string, name string) {}
  1354  
  1355  func (*DropDatabase) iDBDDLStatement()   {}
  1356  func (*CreateDatabase) iDBDDLStatement() {}
  1357  func (*AlterDatabase) iDBDDLStatement()  {}
  1358  
  1359  // IsFullyParsed implements the DBDDLStatement interface
  1360  func (node *DropDatabase) IsFullyParsed() bool {
  1361  	return true
  1362  }
  1363  
  1364  // SetFullyParsed implements the DBDDLStatement interface
  1365  func (node *DropDatabase) SetFullyParsed(fullyParsed bool) {}
  1366  
  1367  // IsFullyParsed implements the DBDDLStatement interface
  1368  func (node *CreateDatabase) IsFullyParsed() bool {
  1369  	return node.FullyParsed
  1370  }
  1371  
  1372  // SetFullyParsed implements the DBDDLStatement interface
  1373  func (node *CreateDatabase) SetFullyParsed(fullyParsed bool) {
  1374  	node.FullyParsed = fullyParsed
  1375  }
  1376  
  1377  // IsFullyParsed implements the DBDDLStatement interface
  1378  func (node *AlterDatabase) IsFullyParsed() bool {
  1379  	return node.FullyParsed
  1380  }
  1381  
  1382  // SetFullyParsed implements the DBDDLStatement interface
  1383  func (node *AlterDatabase) SetFullyParsed(fullyParsed bool) {
  1384  	node.FullyParsed = fullyParsed
  1385  }
  1386  
  1387  // GetDatabaseName implements the DBDDLStatement interface
  1388  func (node *DropDatabase) GetDatabaseName() string {
  1389  	return node.DBName.String()
  1390  }
  1391  
  1392  // GetDatabaseName implements the DBDDLStatement interface
  1393  func (node *CreateDatabase) GetDatabaseName() string {
  1394  	return node.DBName.String()
  1395  }
  1396  
  1397  // GetDatabaseName implements the DBDDLStatement interface
  1398  func (node *AlterDatabase) GetDatabaseName() string {
  1399  	return node.DBName.String()
  1400  }
  1401  
  1402  type (
  1403  
  1404  	// ShowInternal will represent all the show statement types.
  1405  	ShowInternal interface {
  1406  		isShowInternal()
  1407  		SQLNode
  1408  	}
  1409  
  1410  	// ShowLegacy is of ShowInternal type, holds the legacy show ast struct.
  1411  	ShowLegacy struct {
  1412  		Extended               string
  1413  		Type                   string
  1414  		OnTable                TableName
  1415  		Table                  TableName
  1416  		ShowTablesOpt          *ShowTablesOpt
  1417  		Scope                  Scope
  1418  		ShowCollationFilterOpt Expr
  1419  	}
  1420  
  1421  	// ShowCommandType represents the show statement type.
  1422  	ShowCommandType int8
  1423  
  1424  	// ShowBasic is of ShowInternal type, holds Simple SHOW queries with a filter.
  1425  	ShowBasic struct {
  1426  		Command ShowCommandType
  1427  		Full    bool
  1428  		Tbl     TableName
  1429  		DbName  TableIdent
  1430  		Filter  *ShowFilter
  1431  	}
  1432  
  1433  	// ShowCreate is of ShowInternal type, holds SHOW CREATE queries.
  1434  	ShowCreate struct {
  1435  		Command ShowCommandType
  1436  		Op      TableName
  1437  	}
  1438  )
  1439  
  1440  func (*ShowLegacy) isShowInternal() {}
  1441  func (*ShowBasic) isShowInternal()  {}
  1442  func (*ShowCreate) isShowInternal() {}
  1443  
  1444  // InsertRows represents the rows for an INSERT statement.
  1445  type InsertRows interface {
  1446  	iInsertRows()
  1447  	SQLNode
  1448  }
  1449  
  1450  func (*Select) iInsertRows() {}
  1451  func (*Union) iInsertRows()  {}
  1452  func (Values) iInsertRows()  {}
  1453  
  1454  // OptLike works for create table xxx like xxx
  1455  type OptLike struct {
  1456  	LikeTable TableName
  1457  }
  1458  
  1459  // PartitionSpec describe partition actions (for alter statements)
  1460  type PartitionSpec struct {
  1461  	Action            PartitionSpecAction
  1462  	Names             Partitions
  1463  	Number            *Literal
  1464  	IsAll             bool
  1465  	TableName         TableName
  1466  	WithoutValidation bool
  1467  	Definitions       []*PartitionDefinition
  1468  }
  1469  
  1470  // PartitionSpecAction is an enum for PartitionSpec.Action
  1471  type PartitionSpecAction int8
  1472  
  1473  // PartitionDefinition describes a very minimal partition definition
  1474  type PartitionDefinition struct {
  1475  	Name     ColIdent
  1476  	Limit    Expr
  1477  	Maxvalue bool
  1478  }
  1479  
  1480  // PartitionOption describes partitioning control (for create table statements)
  1481  type PartitionOption struct {
  1482  	Linear       string
  1483  	isHASH       bool
  1484  	isKEY        bool
  1485  	KeyAlgorithm string
  1486  	KeyColList   Columns
  1487  	RangeOrList  string
  1488  	ExprOrCol    *ExprOrColumns
  1489  	Expr         Expr
  1490  	Partitions   string
  1491  	SubPartition *SubPartition
  1492  	Definitions  []*PartitionDefinition
  1493  }
  1494  
  1495  // ExprOrColumns describes expression and columnlist in the partition
  1496  type ExprOrColumns struct {
  1497  	Expr       Expr
  1498  	ColumnList Columns
  1499  }
  1500  
  1501  // SubPartition describes subpartitions control
  1502  type SubPartition struct {
  1503  	Linear        string
  1504  	isHASH        bool
  1505  	isKEY         bool
  1506  	KeyAlgorithm  string
  1507  	KeyColList    Columns
  1508  	Expr          Expr
  1509  	SubPartitions string
  1510  }
  1511  
  1512  // TableOptions specifies a list of table options
  1513  type TableOptions []*TableOption
  1514  
  1515  // TableSpec describes the structure of a table from a CREATE TABLE statement
  1516  type TableSpec struct {
  1517  	Columns         []*ColumnDefinition
  1518  	Indexes         []*IndexDefinition
  1519  	Constraints     []*ConstraintDefinition
  1520  	Options         TableOptions
  1521  	PartitionOption *PartitionOption
  1522  }
  1523  
  1524  // ColumnDefinition describes a column in a CREATE TABLE statement
  1525  type ColumnDefinition struct {
  1526  	Name ColIdent
  1527  	// TODO: Should this not be a reference?
  1528  	Type ColumnType
  1529  }
  1530  
  1531  // ColumnType represents a sql type in a CREATE TABLE statement
  1532  // All optional fields are nil if not specified
  1533  type ColumnType struct {
  1534  	// The base type string
  1535  	Type string
  1536  
  1537  	// Generic field options.
  1538  	Options *ColumnTypeOptions
  1539  
  1540  	// Numeric field options
  1541  	Length   *Literal
  1542  	Unsigned bool
  1543  	Zerofill bool
  1544  	Scale    *Literal
  1545  
  1546  	// Text field options
  1547  	Charset string
  1548  
  1549  	// Enum values
  1550  	EnumValues []string
  1551  }
  1552  
  1553  // ColumnStorage is an enum that defines the type of storage.
  1554  type ColumnStorage int
  1555  
  1556  // ColumnTypeOptions are generic field options for a column type
  1557  type ColumnTypeOptions struct {
  1558  	/* We need Null to be *bool to distinguish 3 cases -
  1559  	1. When Not Null is specified (Null = false)
  1560  	2. When Null is specified (Null = true)
  1561  	3. When nothing is specified (Null = nil)
  1562  	The complexity arises from the fact that we do not know whether the column will be nullable or not if nothing is specified.
  1563  	Therefore we do not know whether the column is nullable or not in case 3.
  1564  	*/
  1565  	Null          *bool
  1566  	Autoincrement bool
  1567  	Default       Expr
  1568  	OnUpdate      Expr
  1569  	As            Expr
  1570  	Comment       *Literal
  1571  	Storage       ColumnStorage
  1572  	Collate       string
  1573  	// Reference stores a foreign key constraint for the given column
  1574  	Reference *ReferenceDefinition
  1575  
  1576  	// Key specification
  1577  	KeyOpt ColumnKeyOption
  1578  }
  1579  
  1580  // IndexDefinition describes an index in a CREATE TABLE statement
  1581  type IndexDefinition struct {
  1582  	Info    *IndexInfo
  1583  	Columns []*IndexColumn
  1584  	Options []*IndexOption
  1585  }
  1586  
  1587  // IndexInfo describes the name and type of an index in a CREATE TABLE statement
  1588  type IndexInfo struct {
  1589  	Type           string
  1590  	Name           ColIdent
  1591  	ConstraintName ColIdent
  1592  	Primary        bool
  1593  	Spatial        bool
  1594  	Fulltext       bool
  1595  	Unique         bool
  1596  }
  1597  
  1598  // VindexSpec defines a vindex for a CREATE VINDEX or DROP VINDEX statement
  1599  type VindexSpec struct {
  1600  	Name   ColIdent
  1601  	Type   ColIdent
  1602  	Params []VindexParam
  1603  }
  1604  
  1605  // AutoIncSpec defines and autoincrement value for a ADD AUTO_INCREMENT statement
  1606  type AutoIncSpec struct {
  1607  	Column   ColIdent
  1608  	Sequence TableName
  1609  }
  1610  
  1611  // VindexParam defines a key/value parameter for a CREATE VINDEX statement
  1612  type VindexParam struct {
  1613  	Key ColIdent
  1614  	Val string
  1615  }
  1616  
  1617  // ConstraintDefinition describes a constraint in a CREATE TABLE statement
  1618  type ConstraintDefinition struct {
  1619  	Name    ColIdent
  1620  	Details ConstraintInfo
  1621  }
  1622  
  1623  type (
  1624  	// ConstraintInfo details a constraint in a CREATE TABLE statement
  1625  	ConstraintInfo interface {
  1626  		SQLNode
  1627  		iConstraintInfo()
  1628  	}
  1629  
  1630  	// ForeignKeyDefinition describes a foreign key in a CREATE TABLE statement
  1631  	ForeignKeyDefinition struct {
  1632  		Source              Columns
  1633  		IndexName           ColIdent
  1634  		ReferenceDefinition *ReferenceDefinition
  1635  	}
  1636  
  1637  	// ReferenceDefinition describes the referenced tables and columns that the foreign key references
  1638  	ReferenceDefinition struct {
  1639  		ReferencedTable   TableName
  1640  		ReferencedColumns Columns
  1641  		OnDelete          ReferenceAction
  1642  		OnUpdate          ReferenceAction
  1643  	}
  1644  
  1645  	// CheckConstraintDefinition describes a check constraint in a CREATE TABLE statement
  1646  	CheckConstraintDefinition struct {
  1647  		Expr     Expr
  1648  		Enforced bool
  1649  	}
  1650  )
  1651  
  1652  // ShowFilter is show tables filter
  1653  type ShowFilter struct {
  1654  	Like   string
  1655  	Filter Expr
  1656  }
  1657  
  1658  // Comments represents a list of comments.
  1659  type Comments []string
  1660  
  1661  // SelectExprs represents SELECT expressions.
  1662  type SelectExprs []SelectExpr
  1663  
  1664  type (
  1665  	// SelectExpr represents a SELECT expression.
  1666  	SelectExpr interface {
  1667  		iSelectExpr()
  1668  		SQLNode
  1669  	}
  1670  
  1671  	// StarExpr defines a '*' or 'table.*' expression.
  1672  	StarExpr struct {
  1673  		TableName TableName
  1674  	}
  1675  
  1676  	// AliasedExpr defines an aliased SELECT expression.
  1677  	AliasedExpr struct {
  1678  		Expr Expr
  1679  		As   ColIdent
  1680  	}
  1681  
  1682  	// Nextval defines the NEXT VALUE expression.
  1683  	Nextval struct {
  1684  		Expr Expr
  1685  	}
  1686  )
  1687  
  1688  func (*StarExpr) iSelectExpr()    {}
  1689  func (*AliasedExpr) iSelectExpr() {}
  1690  func (*Nextval) iSelectExpr()     {}
  1691  
  1692  // Columns represents an insert column list.
  1693  type Columns []ColIdent
  1694  
  1695  // Partitions is a type alias for Columns so we can handle printing efficiently
  1696  type Partitions Columns
  1697  
  1698  // TableExprs represents a list of table expressions.
  1699  type TableExprs []TableExpr
  1700  
  1701  type (
  1702  	// TableExpr represents a table expression.
  1703  	TableExpr interface {
  1704  		iTableExpr()
  1705  		SQLNode
  1706  	}
  1707  
  1708  	// AliasedTableExpr represents a table expression
  1709  	// coupled with an optional alias or index hint.
  1710  	// If As is empty, no alias was used.
  1711  	AliasedTableExpr struct {
  1712  		Expr       SimpleTableExpr
  1713  		Partitions Partitions
  1714  		As         TableIdent
  1715  		Hints      *IndexHints
  1716  		Columns    Columns
  1717  	}
  1718  
  1719  	// JoinTableExpr represents a TableExpr that's a JOIN operation.
  1720  	JoinTableExpr struct {
  1721  		LeftExpr  TableExpr
  1722  		Join      JoinType
  1723  		RightExpr TableExpr
  1724  		Condition *JoinCondition
  1725  	}
  1726  
  1727  	// JoinType represents the type of Join for JoinTableExpr
  1728  	JoinType int8
  1729  
  1730  	// ParenTableExpr represents a parenthesized list of TableExpr.
  1731  	ParenTableExpr struct {
  1732  		Exprs TableExprs
  1733  	}
  1734  )
  1735  
  1736  func (*AliasedTableExpr) iTableExpr() {}
  1737  func (*ParenTableExpr) iTableExpr()   {}
  1738  func (*JoinTableExpr) iTableExpr()    {}
  1739  
  1740  type (
  1741  	// SimpleTableExpr represents a simple table expression.
  1742  	SimpleTableExpr interface {
  1743  		iSimpleTableExpr()
  1744  		SQLNode
  1745  	}
  1746  
  1747  	// TableName represents a table  name.
  1748  	// Qualifier, if specified, represents a database or keyspace.
  1749  	// TableName is a value struct whose fields are case sensitive.
  1750  	// This means two TableName vars can be compared for equality
  1751  	// and a TableName can also be used as key in a map.
  1752  	TableName struct {
  1753  		Name, Qualifier TableIdent
  1754  	}
  1755  
  1756  	// Subquery represents a subquery used as an value expression.
  1757  	Subquery struct {
  1758  		Select SelectStatement
  1759  	}
  1760  
  1761  	// DerivedTable represents a subquery used as a table expression.
  1762  	DerivedTable struct {
  1763  		Select SelectStatement
  1764  	}
  1765  )
  1766  
  1767  func (TableName) iSimpleTableExpr()     {}
  1768  func (*DerivedTable) iSimpleTableExpr() {}
  1769  
  1770  // TableNames is a list of TableName.
  1771  type TableNames []TableName
  1772  
  1773  // JoinCondition represents the join conditions (either a ON or USING clause)
  1774  // of a JoinTableExpr.
  1775  type JoinCondition struct {
  1776  	On    Expr
  1777  	Using Columns
  1778  }
  1779  
  1780  // IndexHints represents a list of index hints.
  1781  type IndexHints struct {
  1782  	Type    IndexHintsType
  1783  	Indexes []ColIdent
  1784  }
  1785  
  1786  // IndexHintsType is an enum for IndexHints.Type
  1787  type IndexHintsType int8
  1788  
  1789  // Where represents a WHERE or HAVING clause.
  1790  type Where struct {
  1791  	Type WhereType
  1792  	Expr Expr
  1793  }
  1794  
  1795  // WhereType is an enum for Where.Type
  1796  type WhereType int8
  1797  
  1798  // *********** Expressions
  1799  type (
  1800  	// Expr represents an expression.
  1801  	Expr interface {
  1802  		iExpr()
  1803  		SQLNode
  1804  	}
  1805  
  1806  	// AndExpr represents an AND expression.
  1807  	AndExpr struct {
  1808  		Left, Right Expr
  1809  	}
  1810  
  1811  	// OrExpr represents an OR expression.
  1812  	OrExpr struct {
  1813  		Left, Right Expr
  1814  	}
  1815  
  1816  	// XorExpr represents an XOR expression.
  1817  	XorExpr struct {
  1818  		Left, Right Expr
  1819  	}
  1820  
  1821  	// NotExpr represents a NOT expression.
  1822  	NotExpr struct {
  1823  		Expr Expr
  1824  	}
  1825  
  1826  	// ComparisonExpr represents a two-value comparison expression.
  1827  	ComparisonExpr struct {
  1828  		Operator    ComparisonExprOperator
  1829  		Left, Right Expr
  1830  		Escape      Expr
  1831  	}
  1832  
  1833  	// ComparisonExprOperator is an enum for ComparisonExpr.Operator
  1834  	ComparisonExprOperator int8
  1835  
  1836  	// BetweenExpr represents a BETWEEN or a NOT BETWEEN expression.
  1837  	BetweenExpr struct {
  1838  		IsBetween bool
  1839  		Left      Expr
  1840  		From, To  Expr
  1841  	}
  1842  
  1843  	// RangeCondOperator is an enum for RangeCond.Operator
  1844  	RangeCondOperator int8
  1845  
  1846  	// IsExpr represents an IS ... or an IS NOT ... expression.
  1847  	IsExpr struct {
  1848  		Left  Expr
  1849  		Right IsExprOperator
  1850  	}
  1851  
  1852  	// IsExprOperator is an enum for IsExpr.Operator
  1853  	IsExprOperator int8
  1854  
  1855  	// ExistsExpr represents an EXISTS expression.
  1856  	ExistsExpr struct {
  1857  		Subquery *Subquery
  1858  	}
  1859  
  1860  	// Literal represents a fixed value.
  1861  	Literal struct {
  1862  		Type ValType
  1863  		Val  string
  1864  	}
  1865  
  1866  	// Argument represents bindvariable expression
  1867  	Argument string
  1868  
  1869  	// NullVal represents a NULL value.
  1870  	NullVal struct{}
  1871  
  1872  	// BoolVal is true or false.
  1873  	BoolVal bool
  1874  
  1875  	// ColName represents a column name.
  1876  	ColName struct {
  1877  		// Metadata is not populated by the parser.
  1878  		// It's a placeholder for analyzers to store
  1879  		// additional data, typically info about which
  1880  		// table or column this node references.
  1881  		Metadata  interface{}
  1882  		Name      ColIdent
  1883  		Qualifier TableName
  1884  	}
  1885  
  1886  	// ColTuple represents a list of column values.
  1887  	// It can be ValTuple, Subquery, ListArg.
  1888  	ColTuple interface {
  1889  		iColTuple()
  1890  		Expr
  1891  	}
  1892  
  1893  	// ListArg represents a named list argument.
  1894  	ListArg string
  1895  
  1896  	// ValTuple represents a tuple of actual values.
  1897  	ValTuple Exprs
  1898  
  1899  	// BinaryExpr represents a binary value expression.
  1900  	BinaryExpr struct {
  1901  		Operator    BinaryExprOperator
  1902  		Left, Right Expr
  1903  	}
  1904  
  1905  	// BinaryExprOperator is an enum for BinaryExpr.Operator
  1906  	BinaryExprOperator int8
  1907  
  1908  	// UnaryExpr represents a unary value expression.
  1909  	UnaryExpr struct {
  1910  		Operator UnaryExprOperator
  1911  		Expr     Expr
  1912  	}
  1913  
  1914  	// UnaryExprOperator is an enum for UnaryExpr.Operator
  1915  	UnaryExprOperator int8
  1916  
  1917  	// IntroducerExpr represents a unary value expression.
  1918  	IntroducerExpr struct {
  1919  		CharacterSet string
  1920  		Expr         Expr
  1921  	}
  1922  
  1923  	// IntervalExpr represents a date-time INTERVAL expression.
  1924  	IntervalExpr struct {
  1925  		Expr Expr
  1926  		Unit string
  1927  	}
  1928  
  1929  	// TimestampFuncExpr represents the function and arguments for TIMESTAMP{ADD,DIFF} functions.
  1930  	TimestampFuncExpr struct {
  1931  		Name  string
  1932  		Expr1 Expr
  1933  		Expr2 Expr
  1934  		Unit  string
  1935  	}
  1936  
  1937  	// ExtractFuncExpr represents the function and arguments for EXTRACT(YEAR FROM '2019-07-02') type functions.
  1938  	ExtractFuncExpr struct {
  1939  		IntervalTypes IntervalTypes
  1940  		Expr          Expr
  1941  	}
  1942  
  1943  	// CollateExpr represents dynamic collate operator.
  1944  	CollateExpr struct {
  1945  		Expr      Expr
  1946  		Collation string
  1947  	}
  1948  
  1949  	// FuncExpr represents a function call.
  1950  	FuncExpr struct {
  1951  		Qualifier TableIdent
  1952  		Name      ColIdent
  1953  		Distinct  bool
  1954  		Exprs     SelectExprs
  1955  	}
  1956  
  1957  	// GroupConcatExpr represents a call to GROUP_CONCAT
  1958  	GroupConcatExpr struct {
  1959  		Distinct  bool
  1960  		Exprs     SelectExprs
  1961  		OrderBy   OrderBy
  1962  		Separator string
  1963  		Limit     *Limit
  1964  	}
  1965  
  1966  	// ValuesFuncExpr represents a function call.
  1967  	ValuesFuncExpr struct {
  1968  		Name *ColName
  1969  	}
  1970  
  1971  	// SubstrExpr represents a calls to
  1972  	// - SubstrExpr(expression, expression, expression)
  1973  	// - SubstrExpr(expression, expression)
  1974  	// - SubstrExpr(expression FROM expression)
  1975  	// - SubstrExpr(expression FROM expression FOR expression)
  1976  	SubstrExpr struct {
  1977  		Name Expr
  1978  		From Expr
  1979  		To   Expr
  1980  	}
  1981  
  1982  	// ConvertExpr represents a call to CONVERT(expr, type)
  1983  	// or it's equivalent CAST(expr AS type). Both are rewritten to the former.
  1984  	ConvertExpr struct {
  1985  		Expr Expr
  1986  		Type *ConvertType
  1987  	}
  1988  
  1989  	// ConvertUsingExpr represents a call to CONVERT(expr USING charset).
  1990  	ConvertUsingExpr struct {
  1991  		Expr Expr
  1992  		Type string
  1993  	}
  1994  
  1995  	// MatchExpr represents a call to the MATCH function
  1996  	MatchExpr struct {
  1997  		Columns SelectExprs
  1998  		Expr    Expr
  1999  		Option  MatchExprOption
  2000  	}
  2001  
  2002  	// MatchExprOption is an enum for MatchExpr.Option
  2003  	MatchExprOption int8
  2004  
  2005  	// CaseExpr represents a CASE expression.
  2006  	CaseExpr struct {
  2007  		Expr  Expr
  2008  		Whens []*When
  2009  		Else  Expr
  2010  	}
  2011  
  2012  	// Default represents a DEFAULT expression.
  2013  	Default struct {
  2014  		ColName string
  2015  	}
  2016  
  2017  	// When represents a WHEN sub-expression.
  2018  	When struct {
  2019  		Cond Expr
  2020  		Val  Expr
  2021  	}
  2022  
  2023  	// CurTimeFuncExpr represents the function and arguments for CURRENT DATE/TIME functions
  2024  	// supported functions are documented in the grammar
  2025  	CurTimeFuncExpr struct {
  2026  		Name ColIdent
  2027  		Fsp  Expr // fractional seconds precision, integer from 0 to 6 or an Argument
  2028  	}
  2029  
  2030  	// ExtractedSubquery is a subquery that has been extracted from the original AST
  2031  	// This is a struct that the parser will never produce - it's written and read by the gen4 planner
  2032  	// CAUTION: you should only change argName and hasValuesArg through the setter methods
  2033  	ExtractedSubquery struct {
  2034  		Original     Expr // original expression that was replaced by this ExtractedSubquery
  2035  		OpCode       int  // this should really be engine.PulloutOpCode, but we cannot depend on engine :(
  2036  		Subquery     *Subquery
  2037  		OtherSide    Expr // represents the side of the comparison, this field will be nil if Original is not a comparison
  2038  		NeedsRewrite bool // tells whether we need to rewrite this subquery to Original or not
  2039  
  2040  		hasValuesArg string
  2041  		argName      string
  2042  		alternative  Expr // this is what will be used to Format this struct
  2043  	}
  2044  )
  2045  
  2046  // iExpr ensures that only expressions nodes can be assigned to a Expr
  2047  func (*AndExpr) iExpr()           {}
  2048  func (*OrExpr) iExpr()            {}
  2049  func (*XorExpr) iExpr()           {}
  2050  func (*NotExpr) iExpr()           {}
  2051  func (*ComparisonExpr) iExpr()    {}
  2052  func (*BetweenExpr) iExpr()       {}
  2053  func (*IsExpr) iExpr()            {}
  2054  func (*ExistsExpr) iExpr()        {}
  2055  func (*Literal) iExpr()           {}
  2056  func (Argument) iExpr()           {}
  2057  func (*NullVal) iExpr()           {}
  2058  func (BoolVal) iExpr()            {}
  2059  func (*ColName) iExpr()           {}
  2060  func (ValTuple) iExpr()           {}
  2061  func (*Subquery) iExpr()          {}
  2062  func (ListArg) iExpr()            {}
  2063  func (*BinaryExpr) iExpr()        {}
  2064  func (*UnaryExpr) iExpr()         {}
  2065  func (*IntroducerExpr) iExpr()    {}
  2066  func (*IntervalExpr) iExpr()      {}
  2067  func (*CollateExpr) iExpr()       {}
  2068  func (*FuncExpr) iExpr()          {}
  2069  func (*TimestampFuncExpr) iExpr() {}
  2070  func (*ExtractFuncExpr) iExpr()   {}
  2071  func (*CurTimeFuncExpr) iExpr()   {}
  2072  func (*CaseExpr) iExpr()          {}
  2073  func (*ValuesFuncExpr) iExpr()    {}
  2074  func (*ConvertExpr) iExpr()       {}
  2075  func (*SubstrExpr) iExpr()        {}
  2076  func (*ConvertUsingExpr) iExpr()  {}
  2077  func (*MatchExpr) iExpr()         {}
  2078  func (*GroupConcatExpr) iExpr()   {}
  2079  func (*Default) iExpr()           {}
  2080  func (*ExtractedSubquery) iExpr() {}
  2081  
  2082  // Exprs represents a list of value expressions.
  2083  // It's not a valid expression because it's not parenthesized.
  2084  type Exprs []Expr
  2085  
  2086  func (ValTuple) iColTuple()  {}
  2087  func (*Subquery) iColTuple() {}
  2088  func (ListArg) iColTuple()   {}
  2089  
  2090  // ConvertType represents the type in call to CONVERT(expr, type)
  2091  type ConvertType struct {
  2092  	Type     string
  2093  	Length   *Literal
  2094  	Scale    *Literal
  2095  	Operator ConvertTypeOperator
  2096  	Charset  string
  2097  }
  2098  
  2099  // ConvertTypeOperator is an enum for ConvertType.Operator
  2100  type ConvertTypeOperator int8
  2101  
  2102  // GroupBy represents a GROUP BY clause.
  2103  type GroupBy []Expr
  2104  
  2105  // OrderBy represents an ORDER By clause.
  2106  type OrderBy []*Order
  2107  
  2108  // Order represents an ordering expression.
  2109  type Order struct {
  2110  	Expr      Expr
  2111  	Direction OrderDirection
  2112  }
  2113  
  2114  // OrderDirection is an enum for the direction in which to order - asc or desc.
  2115  type OrderDirection int8
  2116  
  2117  // Limit represents a LIMIT clause.
  2118  type Limit struct {
  2119  	Offset, Rowcount Expr
  2120  }
  2121  
  2122  // Values represents a VALUES clause.
  2123  type Values []ValTuple
  2124  
  2125  // UpdateExprs represents a list of update expressions.
  2126  type UpdateExprs []*UpdateExpr
  2127  
  2128  // UpdateExpr represents an update expression.
  2129  type UpdateExpr struct {
  2130  	Name *ColName
  2131  	Expr Expr
  2132  }
  2133  
  2134  // SetExprs represents a list of set expressions.
  2135  type SetExprs []*SetExpr
  2136  
  2137  // SetExpr represents a set expression.
  2138  type SetExpr struct {
  2139  	Scope Scope
  2140  	Name  ColIdent
  2141  	Expr  Expr
  2142  }
  2143  
  2144  // OnDup represents an ON DUPLICATE KEY clause.
  2145  type OnDup UpdateExprs
  2146  
  2147  // ColIdent is a case insensitive SQL identifier. It will be escaped with
  2148  // backquotes if necessary.
  2149  type ColIdent struct {
  2150  	// This artifact prevents this struct from being compared
  2151  	// with itself. It consumes no space as long as it's not the
  2152  	// last field in the struct.
  2153  	_            [0]struct{ _ []byte }
  2154  	val, lowered string
  2155  	at           AtCount
  2156  }
  2157  
  2158  // TableIdent is a case sensitive SQL identifier. It will be escaped with
  2159  // backquotes if necessary.
  2160  type TableIdent struct {
  2161  	v string
  2162  }
  2163  
  2164  // AtCount return the '@' count present in ColIdent Name
  2165  func (node ColIdent) AtCount() AtCount {
  2166  	return node.at
  2167  }
  2168  
  2169  func (IsolationLevel) iChar() {}
  2170  func (AccessMode) iChar()     {}