github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/sem/tree/stmt.go (about)

     1  // Copyright 2012, Google Inc. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in licenses/BSD-vitess.txt.
     4  
     5  // Portions of this file are additionally subject to the following
     6  // license and copyright.
     7  //
     8  // Copyright 2015 The Cockroach Authors.
     9  //
    10  // Use of this software is governed by the Business Source License
    11  // included in the file licenses/BSL.txt.
    12  //
    13  // As of the Change Date specified in that file, in accordance with
    14  // the Business Source License, use of this software will be governed
    15  // by the Apache License, Version 2.0, included in the file
    16  // licenses/APL.txt.
    17  
    18  // This code was derived from https://github.com/youtube/vitess.
    19  
    20  package tree
    21  
    22  import "fmt"
    23  
    24  // Instructions for creating new types: If a type needs to satisfy an
    25  // interface, declare that function along with that interface. This
    26  // will help users identify the list of types to which they can assert
    27  // those interfaces. If the member of a type has a string with a
    28  // predefined list of values, declare those values as const following
    29  // the type. For interfaces that define dummy functions to
    30  // consolidate a set of types, define the function as typeName().
    31  // This will help avoid name collisions.
    32  
    33  // StatementType is the enumerated type for Statement return styles on
    34  // the wire.
    35  type StatementType int
    36  
    37  //go:generate stringer -type=StatementType
    38  const (
    39  	// Ack indicates that the statement does not have a meaningful
    40  	// return. Examples include SET, BEGIN, COMMIT.
    41  	Ack StatementType = iota
    42  	// DDL indicates that the statement mutates the database schema.
    43  	//
    44  	// Note: this is the type indicated back to the client; it is not a
    45  	// sufficient test for schema mutation for planning purposes. There
    46  	// are schema-modifying statements (e.g. CREATE TABLE AS) which
    47  	// report RowsAffected to the client, not DDL.
    48  	// Use CanModifySchema() below instead.
    49  	DDL
    50  	// RowsAffected indicates that the statement returns the count of
    51  	// affected rows.
    52  	RowsAffected
    53  	// Rows indicates that the statement returns the affected rows after
    54  	// the statement was applied.
    55  	Rows
    56  	// CopyIn indicates a COPY FROM statement.
    57  	CopyIn
    58  	// Unknown indicates that the statement does not have a known
    59  	// return style at the time of parsing. This is not first in the
    60  	// enumeration because it is more convenient to have Ack as a zero
    61  	// value, and because the use of Unknown should be an explicit choice.
    62  	// The primary example of this statement type is EXECUTE, where the
    63  	// statement type depends on the statement type of the prepared statement
    64  	// being executed.
    65  	Unknown
    66  )
    67  
    68  // Statement represents a statement.
    69  type Statement interface {
    70  	fmt.Stringer
    71  	NodeFormatter
    72  	StatementType() StatementType
    73  	// StatementTag is a short string identifying the type of statement
    74  	// (usually a single verb). This is different than the Stringer output,
    75  	// which is the actual statement (including args).
    76  	// TODO(dt): Currently tags are always pg-compatible in the future it
    77  	// might make sense to pass a tag format specifier.
    78  	StatementTag() string
    79  }
    80  
    81  // canModifySchema is to be implemented by statements that can modify
    82  // the database schema but may have StatementType() != DDL.
    83  // See CanModifySchema() below.
    84  type canModifySchema interface {
    85  	modifiesSchema() bool
    86  }
    87  
    88  // CanModifySchema returns true if the statement can modify
    89  // the database schema.
    90  func CanModifySchema(stmt Statement) bool {
    91  	if stmt.StatementType() == DDL {
    92  		return true
    93  	}
    94  	scm, ok := stmt.(canModifySchema)
    95  	return ok && scm.modifiesSchema()
    96  }
    97  
    98  // CanWriteData returns true if the statement can modify data.
    99  func CanWriteData(stmt Statement) bool {
   100  	switch stmt.(type) {
   101  	// Normal write operations.
   102  	case *Insert, *Delete, *Update, *Truncate:
   103  		return true
   104  	// Import operations.
   105  	case *CopyFrom, *Import, *Restore:
   106  		return true
   107  	// CockroachDB extensions.
   108  	case *Split, *Unsplit, *Relocate, *Scatter:
   109  		return true
   110  	}
   111  	return false
   112  }
   113  
   114  // IsStmtParallelized determines if a given statement's execution should be
   115  // parallelized. This means that its results should be mocked out, and that
   116  // it should be run asynchronously and in parallel with other statements that
   117  // are independent.
   118  func IsStmtParallelized(stmt Statement) bool {
   119  	parallelizedRetClause := func(ret ReturningClause) bool {
   120  		_, ok := ret.(*ReturningNothing)
   121  		return ok
   122  	}
   123  	switch s := stmt.(type) {
   124  	case *Delete:
   125  		return parallelizedRetClause(s.Returning)
   126  	case *Insert:
   127  		return parallelizedRetClause(s.Returning)
   128  	case *Update:
   129  		return parallelizedRetClause(s.Returning)
   130  	}
   131  	return false
   132  }
   133  
   134  // HiddenFromShowQueries is a pseudo-interface to be implemented
   135  // by statements that should not show up in SHOW QUERIES (and are hence
   136  // not cancellable using CANCEL QUERIES either). Usually implemented by
   137  // statements that spawn jobs.
   138  type HiddenFromShowQueries interface {
   139  	hiddenFromShowQueries()
   140  }
   141  
   142  // ObserverStatement is a marker interface for statements which are allowed to
   143  // run regardless of the current transaction state: statements other than
   144  // rollback are generally rejected if the session is in a failed transaction
   145  // state, but it's convenient to allow some statements (e.g. "show syntax; set
   146  // tracing").
   147  // Such statements are not expected to modify the database, the transaction or
   148  // session state (other than special cases such as enabling/disabling tracing).
   149  //
   150  // These statements short-circuit the regular execution - they don't get planned
   151  // (there are no corresponding planNodes). The connExecutor recognizes them and
   152  // handles them.
   153  type ObserverStatement interface {
   154  	observerStatement()
   155  }
   156  
   157  // CCLOnlyStatement is a marker interface for statements that require
   158  // a CCL binary for successful planning or execution.
   159  // It is used to enhance error messages when attempting to use these
   160  // statements in non-CCL binaries.
   161  type CCLOnlyStatement interface {
   162  	cclOnlyStatement()
   163  }
   164  
   165  var _ CCLOnlyStatement = &Backup{}
   166  var _ CCLOnlyStatement = &ShowBackup{}
   167  var _ CCLOnlyStatement = &Restore{}
   168  var _ CCLOnlyStatement = &CreateRole{}
   169  var _ CCLOnlyStatement = &GrantRole{}
   170  var _ CCLOnlyStatement = &RevokeRole{}
   171  var _ CCLOnlyStatement = &CreateChangefeed{}
   172  var _ CCLOnlyStatement = &Import{}
   173  var _ CCLOnlyStatement = &Export{}
   174  
   175  // StatementType implements the Statement interface.
   176  func (*AlterIndex) StatementType() StatementType { return DDL }
   177  
   178  // StatementTag returns a short string identifying the type of statement.
   179  func (*AlterIndex) StatementTag() string { return "ALTER INDEX" }
   180  
   181  func (*AlterIndex) hiddenFromShowQueries() {}
   182  
   183  // StatementType implements the Statement interface.
   184  func (*AlterTable) StatementType() StatementType { return DDL }
   185  
   186  // StatementTag returns a short string identifying the type of statement.
   187  func (*AlterTable) StatementTag() string { return "ALTER TABLE" }
   188  
   189  func (*AlterTable) hiddenFromShowQueries() {}
   190  
   191  // StatementType implements the Statement interface.
   192  func (*AlterType) StatementType() StatementType { return DDL }
   193  
   194  // StatementTag implements the Statement interface.
   195  func (*AlterType) StatementTag() string { return "ALTER TYPE" }
   196  
   197  func (*AlterType) hiddenFromShowQueries() {}
   198  
   199  // StatementType implements the Statement interface.
   200  func (*AlterSequence) StatementType() StatementType { return DDL }
   201  
   202  // StatementTag returns a short string identifying the type of statement.
   203  func (*AlterSequence) StatementTag() string { return "ALTER SEQUENCE" }
   204  
   205  // StatementType implements the Statement interface.
   206  func (*AlterRole) StatementType() StatementType { return Ack }
   207  
   208  // StatementTag returns a short string identifying the type of statement.
   209  func (*AlterRole) StatementTag() string { return "ALTER ROLE" }
   210  
   211  func (*AlterRole) cclOnlyStatement() {}
   212  
   213  func (*AlterRole) hiddenFromShowQueries() {}
   214  
   215  // StatementType implements the Statement interface.
   216  func (*Backup) StatementType() StatementType { return Rows }
   217  
   218  // StatementTag returns a short string identifying the type of statement.
   219  func (*Backup) StatementTag() string { return "BACKUP" }
   220  
   221  func (*Backup) cclOnlyStatement() {}
   222  
   223  func (*Backup) hiddenFromShowQueries() {}
   224  
   225  // StatementType implements the Statement interface.
   226  func (*BeginTransaction) StatementType() StatementType { return Ack }
   227  
   228  // StatementTag returns a short string identifying the type of statement.
   229  func (*BeginTransaction) StatementTag() string { return "BEGIN" }
   230  
   231  // StatementType implements the Statement interface.
   232  func (*ControlJobs) StatementType() StatementType { return RowsAffected }
   233  
   234  // StatementTag returns a short string identifying the type of statement.
   235  func (n *ControlJobs) StatementTag() string {
   236  	return fmt.Sprintf("%s JOBS", JobCommandToStatement[n.Command])
   237  }
   238  
   239  // StatementType implements the Statement interface.
   240  func (*CancelQueries) StatementType() StatementType { return RowsAffected }
   241  
   242  // StatementTag returns a short string identifying the type of statement.
   243  func (*CancelQueries) StatementTag() string { return "CANCEL QUERIES" }
   244  
   245  // StatementType implements the Statement interface.
   246  func (*CancelSessions) StatementType() StatementType { return RowsAffected }
   247  
   248  // StatementTag returns a short string identifying the type of statement.
   249  func (*CancelSessions) StatementTag() string { return "CANCEL SESSIONS" }
   250  
   251  // StatementType implements the Statement interface.
   252  func (*CannedOptPlan) StatementType() StatementType { return Rows }
   253  
   254  // StatementTag returns a short string identifying the type of statement.
   255  func (*CannedOptPlan) StatementTag() string { return "PREPARE AS OPT PLAN" }
   256  
   257  // StatementType implements the Statement interface.
   258  func (*CommentOnColumn) StatementType() StatementType { return DDL }
   259  
   260  // StatementTag returns a short string identifying the type of statement.
   261  func (*CommentOnColumn) StatementTag() string { return "COMMENT ON COLUMN" }
   262  
   263  // StatementType implements the Statement interface.
   264  func (*CommentOnDatabase) StatementType() StatementType { return DDL }
   265  
   266  // StatementTag returns a short string identifying the type of statement.
   267  func (*CommentOnDatabase) StatementTag() string { return "COMMENT ON DATABASE" }
   268  
   269  // StatementType implements the Statement interface.
   270  func (*CommentOnIndex) StatementType() StatementType { return DDL }
   271  
   272  // StatementTag returns a short string identifying the type of statement.
   273  func (*CommentOnIndex) StatementTag() string { return "COMMENT ON INDEX" }
   274  
   275  // StatementType implements the Statement interface.
   276  func (*CommentOnTable) StatementType() StatementType { return DDL }
   277  
   278  // StatementTag returns a short string identifying the type of statement.
   279  func (*CommentOnTable) StatementTag() string { return "COMMENT ON TABLE" }
   280  
   281  // StatementType implements the Statement interface.
   282  func (*CommitTransaction) StatementType() StatementType { return Ack }
   283  
   284  // StatementTag returns a short string identifying the type of statement.
   285  func (*CommitTransaction) StatementTag() string { return "COMMIT" }
   286  
   287  // StatementType implements the Statement interface.
   288  func (*CopyFrom) StatementType() StatementType { return CopyIn }
   289  
   290  // StatementTag returns a short string identifying the type of statement.
   291  func (*CopyFrom) StatementTag() string { return "COPY" }
   292  
   293  // StatementType implements the Statement interface.
   294  func (*CreateChangefeed) StatementType() StatementType { return Rows }
   295  
   296  // StatementTag returns a short string identifying the type of statement.
   297  func (n *CreateChangefeed) StatementTag() string {
   298  	if n.SinkURI == nil {
   299  		return "EXPERIMENTAL CHANGEFEED"
   300  	}
   301  	return "CREATE CHANGEFEED"
   302  }
   303  
   304  func (*CreateChangefeed) cclOnlyStatement() {}
   305  
   306  // StatementType implements the Statement interface.
   307  func (*CreateDatabase) StatementType() StatementType { return DDL }
   308  
   309  // StatementTag returns a short string identifying the type of statement.
   310  func (*CreateDatabase) StatementTag() string { return "CREATE DATABASE" }
   311  
   312  // StatementType implements the Statement interface.
   313  func (*CreateIndex) StatementType() StatementType { return DDL }
   314  
   315  // StatementTag returns a short string identifying the type of statement.
   316  func (*CreateIndex) StatementTag() string { return "CREATE INDEX" }
   317  
   318  // StatementType implements the Statement interface.
   319  func (n *CreateSchema) StatementType() StatementType { return DDL }
   320  
   321  // StatementTag returns a short string identifying the type of statement.
   322  func (n *CreateSchema) StatementTag() string {
   323  	return "CREATE SCHEMA"
   324  }
   325  
   326  // modifiesSchema implements the canModifySchema interface.
   327  func (*CreateSchema) modifiesSchema() bool { return true }
   328  
   329  // StatementType implements the Statement interface.
   330  func (n *CreateTable) StatementType() StatementType { return DDL }
   331  
   332  // StatementTag returns a short string identifying the type of statement.
   333  func (n *CreateTable) StatementTag() string {
   334  	if n.As() {
   335  		return "CREATE TABLE AS"
   336  	}
   337  	return "CREATE TABLE"
   338  }
   339  
   340  // modifiesSchema implements the canModifySchema interface.
   341  func (*CreateTable) modifiesSchema() bool { return true }
   342  
   343  // StatementType implements the Statement interface.
   344  func (*CreateType) StatementType() StatementType { return DDL }
   345  
   346  // StatementTag implements the Statement interface.
   347  func (*CreateType) StatementTag() string { return "CREATE TYPE" }
   348  
   349  func (*CreateType) modifiesSchema() bool { return true }
   350  
   351  // StatementType implements the Statement interface.
   352  func (*CreateRole) StatementType() StatementType { return Ack }
   353  
   354  // StatementTag returns a short string identifying the type of statement.
   355  func (*CreateRole) StatementTag() string { return "CREATE ROLE" }
   356  
   357  func (*CreateRole) cclOnlyStatement() {}
   358  
   359  func (*CreateRole) hiddenFromShowQueries() {}
   360  
   361  // StatementType implements the Statement interface.
   362  func (*CreateView) StatementType() StatementType { return DDL }
   363  
   364  // StatementTag returns a short string identifying the type of statement.
   365  func (*CreateView) StatementTag() string { return "CREATE VIEW" }
   366  
   367  // StatementType implements the Statement interface.
   368  func (*CreateSequence) StatementType() StatementType { return DDL }
   369  
   370  // StatementTag returns a short string identifying the type of statement.
   371  func (*CreateSequence) StatementTag() string { return "CREATE SEQUENCE" }
   372  
   373  // StatementType implements the Statement interface.
   374  func (*CreateStats) StatementType() StatementType { return DDL }
   375  
   376  // StatementTag returns a short string identifying the type of statement.
   377  func (*CreateStats) StatementTag() string { return "CREATE STATISTICS" }
   378  
   379  // StatementType implements the Statement interface.
   380  func (*Deallocate) StatementType() StatementType { return Ack }
   381  
   382  // StatementTag returns a short string identifying the type of statement.
   383  func (n *Deallocate) StatementTag() string {
   384  	// Postgres distinguishes the command tags for these two cases of Deallocate statements.
   385  	if n.Name == "" {
   386  		return "DEALLOCATE ALL"
   387  	}
   388  	return "DEALLOCATE"
   389  }
   390  
   391  // StatementType implements the Statement interface.
   392  func (*Discard) StatementType() StatementType { return Ack }
   393  
   394  // StatementTag returns a short string identifying the type of statement.
   395  func (*Discard) StatementTag() string { return "DISCARD" }
   396  
   397  // StatementType implements the Statement interface.
   398  func (n *Delete) StatementType() StatementType { return n.Returning.statementType() }
   399  
   400  // StatementTag returns a short string identifying the type of statement.
   401  func (*Delete) StatementTag() string { return "DELETE" }
   402  
   403  // StatementType implements the Statement interface.
   404  func (*DropDatabase) StatementType() StatementType { return DDL }
   405  
   406  // StatementTag returns a short string identifying the type of statement.
   407  func (*DropDatabase) StatementTag() string { return "DROP DATABASE" }
   408  
   409  // StatementType implements the Statement interface.
   410  func (*DropIndex) StatementType() StatementType { return DDL }
   411  
   412  // StatementTag returns a short string identifying the type of statement.
   413  func (*DropIndex) StatementTag() string { return "DROP INDEX" }
   414  
   415  // StatementType implements the Statement interface.
   416  func (*DropTable) StatementType() StatementType { return DDL }
   417  
   418  // StatementTag returns a short string identifying the type of statement.
   419  func (*DropTable) StatementTag() string { return "DROP TABLE" }
   420  
   421  // StatementType implements the Statement interface.
   422  func (*DropView) StatementType() StatementType { return DDL }
   423  
   424  // StatementTag returns a short string identifying the type of statement.
   425  func (*DropView) StatementTag() string { return "DROP VIEW" }
   426  
   427  // StatementType implements the Statement interface.
   428  func (*DropSequence) StatementType() StatementType { return DDL }
   429  
   430  // StatementTag returns a short string identifying the type of statement.
   431  func (*DropSequence) StatementTag() string { return "DROP SEQUENCE" }
   432  
   433  // StatementType implements the Statement interface.
   434  func (*DropRole) StatementType() StatementType { return Ack }
   435  
   436  // StatementTag returns a short string identifying the type of statement.
   437  func (*DropRole) StatementTag() string { return "DROP ROLE" }
   438  
   439  func (*DropRole) cclOnlyStatement() {}
   440  
   441  func (*DropRole) hiddenFromShowQueries() {}
   442  
   443  // StatementType implements the Statement interface.
   444  func (*DropType) StatementType() StatementType { return DDL }
   445  
   446  // StatementTag returns a short string identifying the type of statement.
   447  func (*DropType) StatementTag() string { return "DROP TYPE" }
   448  
   449  // StatementType implements the Statement interface.
   450  func (*Execute) StatementType() StatementType { return Unknown }
   451  
   452  // StatementTag returns a short string identifying the type of statement.
   453  func (*Execute) StatementTag() string { return "EXECUTE" }
   454  
   455  // StatementType implements the Statement interface.
   456  func (*Explain) StatementType() StatementType { return Rows }
   457  
   458  // StatementTag returns a short string identifying the type of statement.
   459  func (*Explain) StatementTag() string { return "EXPLAIN" }
   460  
   461  // StatementType implements the Statement interface.
   462  func (*ExplainAnalyzeDebug) StatementType() StatementType { return Rows }
   463  
   464  // StatementTag returns a short string identifying the type of statement.
   465  func (*ExplainAnalyzeDebug) StatementTag() string { return "EXPLAIN ANALYZE (DEBUG)" }
   466  
   467  // StatementType implements the Statement interface.
   468  func (*Export) StatementType() StatementType { return Rows }
   469  
   470  func (*Export) cclOnlyStatement() {}
   471  
   472  // StatementTag returns a short string identifying the type of statement.
   473  func (*Export) StatementTag() string { return "EXPORT" }
   474  
   475  // StatementType implements the Statement interface.
   476  func (*Grant) StatementType() StatementType { return DDL }
   477  
   478  // StatementTag returns a short string identifying the type of statement.
   479  func (*Grant) StatementTag() string { return "GRANT" }
   480  
   481  // StatementType implements the Statement interface.
   482  func (*GrantRole) StatementType() StatementType { return DDL }
   483  
   484  // StatementTag returns a short string identifying the type of statement.
   485  func (*GrantRole) StatementTag() string { return "GRANT" }
   486  
   487  func (*GrantRole) cclOnlyStatement() {}
   488  
   489  // StatementType implements the Statement interface.
   490  func (n *Insert) StatementType() StatementType { return n.Returning.statementType() }
   491  
   492  // StatementTag returns a short string identifying the type of statement.
   493  func (*Insert) StatementTag() string { return "INSERT" }
   494  
   495  // StatementType implements the Statement interface.
   496  func (n *Import) StatementType() StatementType { return Rows }
   497  
   498  // StatementTag returns a short string identifying the type of statement.
   499  func (*Import) StatementTag() string { return "IMPORT" }
   500  
   501  func (*Import) cclOnlyStatement() {}
   502  
   503  // StatementType implements the Statement interface.
   504  func (*ParenSelect) StatementType() StatementType { return Rows }
   505  
   506  // StatementTag returns a short string identifying the type of statement.
   507  func (*ParenSelect) StatementTag() string { return "SELECT" }
   508  
   509  // StatementType implements the Statement interface.
   510  func (*Prepare) StatementType() StatementType { return Ack }
   511  
   512  // StatementTag returns a short string identifying the type of statement.
   513  func (*Prepare) StatementTag() string { return "PREPARE" }
   514  
   515  // StatementType implements the Statement interface.
   516  func (*ReleaseSavepoint) StatementType() StatementType { return Ack }
   517  
   518  // StatementTag returns a short string identifying the type of statement.
   519  func (*ReleaseSavepoint) StatementTag() string { return "RELEASE" }
   520  
   521  // StatementType implements the Statement interface.
   522  func (*RenameColumn) StatementType() StatementType { return DDL }
   523  
   524  // StatementTag returns a short string identifying the type of statement.
   525  func (*RenameColumn) StatementTag() string { return "RENAME COLUMN" }
   526  
   527  // StatementType implements the Statement interface.
   528  func (*RenameDatabase) StatementType() StatementType { return DDL }
   529  
   530  // StatementTag returns a short string identifying the type of statement.
   531  func (*RenameDatabase) StatementTag() string { return "RENAME DATABASE" }
   532  
   533  // StatementType implements the Statement interface.
   534  func (*RenameIndex) StatementType() StatementType { return DDL }
   535  
   536  // StatementTag returns a short string identifying the type of statement.
   537  func (*RenameIndex) StatementTag() string { return "RENAME INDEX" }
   538  
   539  // StatementType implements the Statement interface.
   540  func (*RenameTable) StatementType() StatementType { return DDL }
   541  
   542  // StatementTag returns a short string identifying the type of statement.
   543  func (n *RenameTable) StatementTag() string {
   544  	if n.IsView {
   545  		return "RENAME VIEW"
   546  	} else if n.IsSequence {
   547  		return "RENAME SEQUENCE"
   548  	}
   549  	return "RENAME TABLE"
   550  }
   551  
   552  // StatementType implements the Statement interface.
   553  func (*Relocate) StatementType() StatementType { return Rows }
   554  
   555  // StatementTag returns a short string identifying the type of statement.
   556  func (n *Relocate) StatementTag() string {
   557  	if n.RelocateLease {
   558  		return "EXPERIMENTAL_RELOCATE LEASE"
   559  	}
   560  	return "EXPERIMENTAL_RELOCATE"
   561  }
   562  
   563  // StatementType implements the Statement interface.
   564  func (*Restore) StatementType() StatementType { return Rows }
   565  
   566  // StatementTag returns a short string identifying the type of statement.
   567  func (*Restore) StatementTag() string { return "RESTORE" }
   568  
   569  func (*Restore) cclOnlyStatement() {}
   570  
   571  func (*Restore) hiddenFromShowQueries() {}
   572  
   573  // StatementType implements the Statement interface.
   574  func (*Revoke) StatementType() StatementType { return DDL }
   575  
   576  // StatementTag returns a short string identifying the type of statement.
   577  func (*Revoke) StatementTag() string { return "REVOKE" }
   578  
   579  // StatementType implements the Statement interface.
   580  func (*RevokeRole) StatementType() StatementType { return DDL }
   581  
   582  // StatementTag returns a short string identifying the type of statement.
   583  func (*RevokeRole) StatementTag() string { return "REVOKE" }
   584  
   585  func (*RevokeRole) cclOnlyStatement() {}
   586  
   587  // StatementType implements the Statement interface.
   588  func (*RollbackToSavepoint) StatementType() StatementType { return Ack }
   589  
   590  // StatementTag returns a short string identifying the type of statement.
   591  func (*RollbackToSavepoint) StatementTag() string { return "ROLLBACK" }
   592  
   593  // StatementType implements the Statement interface.
   594  func (*RollbackTransaction) StatementType() StatementType { return Ack }
   595  
   596  // StatementTag returns a short string identifying the type of statement.
   597  func (*RollbackTransaction) StatementTag() string { return "ROLLBACK" }
   598  
   599  // StatementType implements the Statement interface.
   600  func (*Savepoint) StatementType() StatementType { return Ack }
   601  
   602  // StatementTag returns a short string identifying the type of statement.
   603  func (*Savepoint) StatementTag() string { return "SAVEPOINT" }
   604  
   605  // StatementType implements the Statement interface.
   606  func (*Scatter) StatementType() StatementType { return Rows }
   607  
   608  // StatementTag returns a short string identifying the type of statement.
   609  func (*Scatter) StatementTag() string { return "SCATTER" }
   610  
   611  // StatementType implements the Statement interface.
   612  func (*Scrub) StatementType() StatementType { return Rows }
   613  
   614  // StatementTag returns a short string identifying the type of statement.
   615  func (n *Scrub) StatementTag() string { return "SCRUB" }
   616  
   617  // StatementType implements the Statement interface.
   618  func (*Select) StatementType() StatementType { return Rows }
   619  
   620  // StatementTag returns a short string identifying the type of statement.
   621  func (*Select) StatementTag() string { return "SELECT" }
   622  
   623  // StatementType implements the Statement interface.
   624  func (*SelectClause) StatementType() StatementType { return Rows }
   625  
   626  // StatementTag returns a short string identifying the type of statement.
   627  func (*SelectClause) StatementTag() string { return "SELECT" }
   628  
   629  // StatementType implements the Statement interface.
   630  func (*SetVar) StatementType() StatementType { return Ack }
   631  
   632  // StatementTag returns a short string identifying the type of statement.
   633  func (*SetVar) StatementTag() string { return "SET" }
   634  
   635  // StatementType implements the Statement interface.
   636  func (*SetClusterSetting) StatementType() StatementType { return Ack }
   637  
   638  // StatementTag returns a short string identifying the type of statement.
   639  func (*SetClusterSetting) StatementTag() string { return "SET CLUSTER SETTING" }
   640  
   641  // StatementType implements the Statement interface.
   642  func (*SetTransaction) StatementType() StatementType { return Ack }
   643  
   644  // StatementTag returns a short string identifying the type of statement.
   645  func (*SetTransaction) StatementTag() string { return "SET TRANSACTION" }
   646  
   647  // StatementType implements the Statement interface.
   648  func (*SetTracing) StatementType() StatementType { return Ack }
   649  
   650  // StatementTag returns a short string identifying the type of statement.
   651  func (*SetTracing) StatementTag() string { return "SET TRACING" }
   652  
   653  // observerStatement implements the ObserverStatement interface.
   654  func (*SetTracing) observerStatement() {}
   655  
   656  // StatementType implements the Statement interface.
   657  func (*SetZoneConfig) StatementType() StatementType { return RowsAffected }
   658  
   659  // StatementTag returns a short string identifying the type of statement.
   660  func (*SetZoneConfig) StatementTag() string { return "CONFIGURE ZONE" }
   661  
   662  // StatementType implements the Statement interface.
   663  func (*SetSessionAuthorizationDefault) StatementType() StatementType { return Ack }
   664  
   665  // StatementTag returns a short string identifying the type of statement.
   666  func (*SetSessionAuthorizationDefault) StatementTag() string { return "SET" }
   667  
   668  // StatementType implements the Statement interface.
   669  func (*SetSessionCharacteristics) StatementType() StatementType { return Ack }
   670  
   671  // StatementTag returns a short string identifying the type of statement.
   672  func (*SetSessionCharacteristics) StatementTag() string { return "SET" }
   673  
   674  // StatementType implements the Statement interface.
   675  func (*ShowVar) StatementType() StatementType { return Rows }
   676  
   677  // StatementTag returns a short string identifying the type of statement.
   678  func (*ShowVar) StatementTag() string { return "SHOW" }
   679  
   680  // StatementType implements the Statement interface.
   681  func (*ShowClusterSetting) StatementType() StatementType { return Rows }
   682  
   683  // StatementTag returns a short string identifying the type of statement.
   684  func (*ShowClusterSetting) StatementTag() string { return "SHOW" }
   685  
   686  // StatementType implements the Statement interface.
   687  func (*ShowClusterSettingList) StatementType() StatementType { return Rows }
   688  
   689  // StatementTag returns a short string identifying the type of statement.
   690  func (*ShowClusterSettingList) StatementTag() string { return "SHOW" }
   691  
   692  // StatementType implements the Statement interface.
   693  func (*ShowColumns) StatementType() StatementType { return Rows }
   694  
   695  // StatementTag returns a short string identifying the type of statement.
   696  func (*ShowColumns) StatementTag() string { return "SHOW COLUMNS" }
   697  
   698  // StatementType implements the Statement interface.
   699  func (*ShowCreate) StatementType() StatementType { return Rows }
   700  
   701  // StatementTag returns a short string identifying the type of statement.
   702  func (*ShowCreate) StatementTag() string { return "SHOW CREATE" }
   703  
   704  // StatementType implements the Statement interface.
   705  func (*ShowBackup) StatementType() StatementType { return Rows }
   706  
   707  // StatementTag returns a short string identifying the type of statement.
   708  func (*ShowBackup) StatementTag() string { return "SHOW BACKUP" }
   709  
   710  func (*ShowBackup) cclOnlyStatement() {}
   711  
   712  // StatementType implements the Statement interface.
   713  func (*ShowDatabases) StatementType() StatementType { return Rows }
   714  
   715  // StatementTag returns a short string identifying the type of statement.
   716  func (*ShowDatabases) StatementTag() string { return "SHOW DATABASES" }
   717  
   718  // StatementType implements the Statement interface.
   719  func (*ShowTraceForSession) StatementType() StatementType { return Rows }
   720  
   721  // StatementTag returns a short string identifying the type of statement.
   722  func (*ShowTraceForSession) StatementTag() string { return "SHOW TRACE FOR SESSION" }
   723  
   724  // StatementType implements the Statement interface.
   725  func (*ShowGrants) StatementType() StatementType { return Rows }
   726  
   727  // StatementTag returns a short string identifying the type of statement.
   728  func (*ShowGrants) StatementTag() string { return "SHOW GRANTS" }
   729  
   730  // StatementType implements the Statement interface.
   731  func (*ShowDatabaseIndexes) StatementType() StatementType { return Rows }
   732  
   733  // StatementTag returns a short string identifying the type of statement.
   734  func (*ShowDatabaseIndexes) StatementTag() string { return "SHOW INDEXES FROM DATABASE" }
   735  
   736  // StatementType implements the Statement interface.
   737  func (*ShowIndexes) StatementType() StatementType { return Rows }
   738  
   739  // StatementTag returns a short string identifying the type of statement.
   740  func (*ShowIndexes) StatementTag() string { return "SHOW INDEXES FROM TABLE" }
   741  
   742  // StatementType implements the Statement interface.
   743  func (*ShowPartitions) StatementType() StatementType { return Rows }
   744  
   745  // StatementTag returns a short string identifying the type of the statement.
   746  func (*ShowPartitions) StatementTag() string { return "SHOW PARTITIONS" }
   747  
   748  // StatementType implements the Statement interface.
   749  func (*ShowQueries) StatementType() StatementType { return Rows }
   750  
   751  // StatementTag returns a short string identifying the type of statement.
   752  func (*ShowQueries) StatementTag() string { return "SHOW QUERIES" }
   753  
   754  // StatementType implements the Statement interface.
   755  func (*ShowJobs) StatementType() StatementType { return Rows }
   756  
   757  // StatementTag returns a short string identifying the type of statement.
   758  func (*ShowJobs) StatementTag() string { return "SHOW JOBS" }
   759  
   760  // StatementType implements the Statement interface.
   761  func (*ShowRoleGrants) StatementType() StatementType { return Rows }
   762  
   763  // StatementTag returns a short string identifying the type of statement.
   764  func (*ShowRoleGrants) StatementTag() string { return "SHOW GRANTS ON ROLE" }
   765  
   766  // StatementType implements the Statement interface.
   767  func (*ShowSessions) StatementType() StatementType { return Rows }
   768  
   769  // StatementTag returns a short string identifying the type of statement.
   770  func (*ShowSessions) StatementTag() string { return "SHOW SESSIONS" }
   771  
   772  // StatementType implements the Statement interface.
   773  func (*ShowTableStats) StatementType() StatementType { return Rows }
   774  
   775  // StatementTag returns a short string identifying the type of statement.
   776  func (*ShowTableStats) StatementTag() string { return "SHOW STATISTICS" }
   777  
   778  // StatementType implements the Statement interface.
   779  func (*ShowHistogram) StatementType() StatementType { return Rows }
   780  
   781  // StatementTag returns a short string identifying the type of statement.
   782  func (*ShowHistogram) StatementTag() string { return "SHOW HISTOGRAM" }
   783  
   784  // StatementType implements the Statement interface.
   785  func (*ShowSyntax) StatementType() StatementType { return Rows }
   786  
   787  // StatementTag returns a short string identifying the type of statement.
   788  func (*ShowSyntax) StatementTag() string { return "SHOW SYNTAX" }
   789  
   790  func (*ShowSyntax) observerStatement() {}
   791  
   792  // StatementType implements the Statement interface.
   793  func (*ShowTransactionStatus) StatementType() StatementType { return Rows }
   794  
   795  // StatementTag returns a short string identifying the type of statement.
   796  func (*ShowTransactionStatus) StatementTag() string { return "SHOW TRANSACTION STATUS" }
   797  
   798  func (*ShowTransactionStatus) observerStatement() {}
   799  
   800  // StatementType implements the Statement interface.
   801  func (*ShowSavepointStatus) StatementType() StatementType { return Rows }
   802  
   803  // StatementTag returns a short string identifying the type of statement.
   804  func (*ShowSavepointStatus) StatementTag() string { return "SHOW SAVEPOINT STATUS" }
   805  
   806  func (*ShowSavepointStatus) observerStatement() {}
   807  
   808  // StatementType implements the Statement interface.
   809  func (*ShowUsers) StatementType() StatementType { return Rows }
   810  
   811  // StatementTag returns a short string identifying the type of statement.
   812  func (*ShowUsers) StatementTag() string { return "SHOW USERS" }
   813  
   814  // StatementType implements the Statement interface.
   815  func (*ShowRoles) StatementType() StatementType { return Rows }
   816  
   817  // StatementTag returns a short string identifying the type of statement.
   818  func (*ShowRoles) StatementTag() string { return "SHOW ROLES" }
   819  
   820  // StatementType implements the Statement interface.
   821  func (*ShowZoneConfig) StatementType() StatementType { return Rows }
   822  
   823  // StatementTag returns a short string identifying the type of statement.
   824  func (*ShowZoneConfig) StatementTag() string { return "SHOW ZONE CONFIGURATION" }
   825  
   826  // StatementType implements the Statement interface.
   827  func (*ShowRanges) StatementType() StatementType { return Rows }
   828  
   829  // StatementTag returns a short string identifying the type of statement.
   830  func (*ShowRanges) StatementTag() string { return "SHOW RANGES" }
   831  
   832  // StatementType implements the Statement interface.
   833  func (*ShowRangeForRow) StatementType() StatementType { return Rows }
   834  
   835  // StatementTag returns a short string identifying the type of statement.
   836  func (*ShowRangeForRow) StatementTag() string { return "SHOW RANGE FOR ROW" }
   837  
   838  // StatementType implements the Statement interface.
   839  func (*ShowFingerprints) StatementType() StatementType { return Rows }
   840  
   841  // StatementTag returns a short string identifying the type of statement.
   842  func (*ShowFingerprints) StatementTag() string { return "SHOW EXPERIMENTAL_FINGERPRINTS" }
   843  
   844  // StatementType implements the Statement interface.
   845  func (*ShowConstraints) StatementType() StatementType { return Rows }
   846  
   847  // StatementTag returns a short string identifying the type of statement.
   848  func (*ShowConstraints) StatementTag() string { return "SHOW CONSTRAINTS" }
   849  
   850  // StatementType implements the Statement interface.
   851  func (*ShowTables) StatementType() StatementType { return Rows }
   852  
   853  // StatementTag returns a short string identifying the type of statement.
   854  func (*ShowTables) StatementTag() string { return "SHOW TABLES" }
   855  
   856  // StatementType implements the Statement interface.
   857  func (*ShowSchemas) StatementType() StatementType { return Rows }
   858  
   859  // StatementTag returns a short string identifying the type of statement.
   860  func (*ShowSchemas) StatementTag() string { return "SHOW SCHEMAS" }
   861  
   862  // StatementType implements the Statement interface.
   863  func (*ShowSequences) StatementType() StatementType { return Rows }
   864  
   865  // StatementTag returns a short string identifying the type of statement.
   866  func (*ShowSequences) StatementTag() string { return "SHOW SCHEMAS" }
   867  
   868  // StatementType implements the Statement interface.
   869  func (*Split) StatementType() StatementType { return Rows }
   870  
   871  // StatementTag returns a short string identifying the type of statement.
   872  func (*Split) StatementTag() string { return "SPLIT" }
   873  
   874  // StatementType implements the Statement interface.
   875  func (*Unsplit) StatementType() StatementType { return Rows }
   876  
   877  // StatementTag returns a short string identifying the type of statement.
   878  func (*Unsplit) StatementTag() string { return "UNSPLIT" }
   879  
   880  // StatementType implements the Statement interface.
   881  func (*Truncate) StatementType() StatementType { return Ack }
   882  
   883  // StatementTag returns a short string identifying the type of statement.
   884  func (*Truncate) StatementTag() string { return "TRUNCATE" }
   885  
   886  // modifiesSchema implements the canModifySchema interface.
   887  func (*Truncate) modifiesSchema() bool { return true }
   888  
   889  // StatementType implements the Statement interface.
   890  func (n *Update) StatementType() StatementType { return n.Returning.statementType() }
   891  
   892  // StatementTag returns a short string identifying the type of statement.
   893  func (*Update) StatementTag() string { return "UPDATE" }
   894  
   895  // StatementType implements the Statement interface.
   896  func (*UnionClause) StatementType() StatementType { return Rows }
   897  
   898  // StatementTag returns a short string identifying the type of statement.
   899  func (*UnionClause) StatementTag() string { return "UNION" }
   900  
   901  // StatementType implements the Statement interface.
   902  func (*ValuesClause) StatementType() StatementType { return Rows }
   903  
   904  // StatementTag returns a short string identifying the type of statement.
   905  func (*ValuesClause) StatementTag() string { return "VALUES" }
   906  
   907  func (n *AlterIndex) String() string                     { return AsString(n) }
   908  func (n *AlterTable) String() string                     { return AsString(n) }
   909  func (n *AlterTableCmds) String() string                 { return AsString(n) }
   910  func (n *AlterTableAddColumn) String() string            { return AsString(n) }
   911  func (n *AlterTableAddConstraint) String() string        { return AsString(n) }
   912  func (n *AlterTableAlterColumnType) String() string      { return AsString(n) }
   913  func (n *AlterTableDropColumn) String() string           { return AsString(n) }
   914  func (n *AlterTableDropConstraint) String() string       { return AsString(n) }
   915  func (n *AlterTableDropNotNull) String() string          { return AsString(n) }
   916  func (n *AlterTableDropStored) String() string           { return AsString(n) }
   917  func (n *AlterTableSetDefault) String() string           { return AsString(n) }
   918  func (n *AlterTableSetNotNull) String() string           { return AsString(n) }
   919  func (n *AlterType) String() string                      { return AsString(n) }
   920  func (n *AlterRole) String() string                      { return AsString(n) }
   921  func (n *AlterSequence) String() string                  { return AsString(n) }
   922  func (n *Backup) String() string                         { return AsString(n) }
   923  func (n *BeginTransaction) String() string               { return AsString(n) }
   924  func (n *ControlJobs) String() string                    { return AsString(n) }
   925  func (n *CancelQueries) String() string                  { return AsString(n) }
   926  func (n *CancelSessions) String() string                 { return AsString(n) }
   927  func (n *CannedOptPlan) String() string                  { return AsString(n) }
   928  func (n *CommentOnColumn) String() string                { return AsString(n) }
   929  func (n *CommentOnDatabase) String() string              { return AsString(n) }
   930  func (n *CommentOnIndex) String() string                 { return AsString(n) }
   931  func (n *CommentOnTable) String() string                 { return AsString(n) }
   932  func (n *CommitTransaction) String() string              { return AsString(n) }
   933  func (n *CopyFrom) String() string                       { return AsString(n) }
   934  func (n *CreateChangefeed) String() string               { return AsString(n) }
   935  func (n *CreateDatabase) String() string                 { return AsString(n) }
   936  func (n *CreateIndex) String() string                    { return AsString(n) }
   937  func (n *CreateRole) String() string                     { return AsString(n) }
   938  func (n *CreateTable) String() string                    { return AsString(n) }
   939  func (n *CreateSchema) String() string                   { return AsString(n) }
   940  func (n *CreateSequence) String() string                 { return AsString(n) }
   941  func (n *CreateStats) String() string                    { return AsString(n) }
   942  func (n *CreateView) String() string                     { return AsString(n) }
   943  func (n *Deallocate) String() string                     { return AsString(n) }
   944  func (n *Delete) String() string                         { return AsString(n) }
   945  func (n *DropDatabase) String() string                   { return AsString(n) }
   946  func (n *DropIndex) String() string                      { return AsString(n) }
   947  func (n *DropTable) String() string                      { return AsString(n) }
   948  func (n *DropType) String() string                       { return AsString(n) }
   949  func (n *DropView) String() string                       { return AsString(n) }
   950  func (n *DropSequence) String() string                   { return AsString(n) }
   951  func (n *DropRole) String() string                       { return AsString(n) }
   952  func (n *Execute) String() string                        { return AsString(n) }
   953  func (n *Explain) String() string                        { return AsString(n) }
   954  func (n *ExplainAnalyzeDebug) String() string            { return AsString(n) }
   955  func (n *Export) String() string                         { return AsString(n) }
   956  func (n *Grant) String() string                          { return AsString(n) }
   957  func (n *GrantRole) String() string                      { return AsString(n) }
   958  func (n *Insert) String() string                         { return AsString(n) }
   959  func (n *Import) String() string                         { return AsString(n) }
   960  func (n *ParenSelect) String() string                    { return AsString(n) }
   961  func (n *Prepare) String() string                        { return AsString(n) }
   962  func (n *ReleaseSavepoint) String() string               { return AsString(n) }
   963  func (n *Relocate) String() string                       { return AsString(n) }
   964  func (n *RenameColumn) String() string                   { return AsString(n) }
   965  func (n *RenameDatabase) String() string                 { return AsString(n) }
   966  func (n *RenameIndex) String() string                    { return AsString(n) }
   967  func (n *RenameTable) String() string                    { return AsString(n) }
   968  func (n *Restore) String() string                        { return AsString(n) }
   969  func (n *Revoke) String() string                         { return AsString(n) }
   970  func (n *RevokeRole) String() string                     { return AsString(n) }
   971  func (n *RollbackToSavepoint) String() string            { return AsString(n) }
   972  func (n *RollbackTransaction) String() string            { return AsString(n) }
   973  func (n *Savepoint) String() string                      { return AsString(n) }
   974  func (n *Scatter) String() string                        { return AsString(n) }
   975  func (n *Scrub) String() string                          { return AsString(n) }
   976  func (n *Select) String() string                         { return AsString(n) }
   977  func (n *SelectClause) String() string                   { return AsString(n) }
   978  func (n *SetClusterSetting) String() string              { return AsString(n) }
   979  func (n *SetZoneConfig) String() string                  { return AsString(n) }
   980  func (n *SetSessionAuthorizationDefault) String() string { return AsString(n) }
   981  func (n *SetSessionCharacteristics) String() string      { return AsString(n) }
   982  func (n *SetTransaction) String() string                 { return AsString(n) }
   983  func (n *SetTracing) String() string                     { return AsString(n) }
   984  func (n *SetVar) String() string                         { return AsString(n) }
   985  func (n *ShowBackup) String() string                     { return AsString(n) }
   986  func (n *ShowClusterSetting) String() string             { return AsString(n) }
   987  func (n *ShowClusterSettingList) String() string         { return AsString(n) }
   988  func (n *ShowColumns) String() string                    { return AsString(n) }
   989  func (n *ShowConstraints) String() string                { return AsString(n) }
   990  func (n *ShowCreate) String() string                     { return AsString(n) }
   991  func (n *ShowDatabases) String() string                  { return AsString(n) }
   992  func (n *ShowDatabaseIndexes) String() string            { return AsString(n) }
   993  func (n *ShowGrants) String() string                     { return AsString(n) }
   994  func (n *ShowHistogram) String() string                  { return AsString(n) }
   995  func (n *ShowIndexes) String() string                    { return AsString(n) }
   996  func (n *ShowPartitions) String() string                 { return AsString(n) }
   997  func (n *ShowJobs) String() string                       { return AsString(n) }
   998  func (n *ShowQueries) String() string                    { return AsString(n) }
   999  func (n *ShowRanges) String() string                     { return AsString(n) }
  1000  func (n *ShowRangeForRow) String() string                { return AsString(n) }
  1001  func (n *ShowRoleGrants) String() string                 { return AsString(n) }
  1002  func (n *ShowRoles) String() string                      { return AsString(n) }
  1003  func (n *ShowSavepointStatus) String() string            { return AsString(n) }
  1004  func (n *ShowSchemas) String() string                    { return AsString(n) }
  1005  func (n *ShowSequences) String() string                  { return AsString(n) }
  1006  func (n *ShowSessions) String() string                   { return AsString(n) }
  1007  func (n *ShowSyntax) String() string                     { return AsString(n) }
  1008  func (n *ShowTableStats) String() string                 { return AsString(n) }
  1009  func (n *ShowTables) String() string                     { return AsString(n) }
  1010  func (n *ShowTraceForSession) String() string            { return AsString(n) }
  1011  func (n *ShowTransactionStatus) String() string          { return AsString(n) }
  1012  func (n *ShowUsers) String() string                      { return AsString(n) }
  1013  func (n *ShowVar) String() string                        { return AsString(n) }
  1014  func (n *ShowZoneConfig) String() string                 { return AsString(n) }
  1015  func (n *ShowFingerprints) String() string               { return AsString(n) }
  1016  func (n *Split) String() string                          { return AsString(n) }
  1017  func (n *Unsplit) String() string                        { return AsString(n) }
  1018  func (n *Truncate) String() string                       { return AsString(n) }
  1019  func (n *UnionClause) String() string                    { return AsString(n) }
  1020  func (n *Update) String() string                         { return AsString(n) }
  1021  func (n *ValuesClause) String() string                   { return AsString(n) }