github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/opt/ops/statement.opt (about)

     1  # statement.opt contains Optgen language definitions for non-DML statements with
     2  # specific optimizer support, such as CreateTable.
     3  #
     4  # Although though many of them have no return result, they are still treated as
     5  # if they were expressions with a zero row, zero column result.
     6  
     7  # CreateTable represents a CREATE TABLE statement.
     8  [Relational, DDL, Mutation]
     9  define CreateTable {
    10      # Input is only used if the AS clause was used in the CREATE TABLE
    11      # statement. If it was not used, then the Input is a dummy zero row, zero
    12      # column Values expression (and nil inputs are not allowed).
    13      Input RelExpr
    14      _ CreateTablePrivate
    15  }
    16  
    17  [Private]
    18  define CreateTablePrivate {
    19      # Schema is the ID of the catalog schema into which the new table goes.
    20      Schema SchemaID
    21  
    22      # InputCols gives the ordering and naming of input columns. It is only
    23      # defined when the AS clause was used in the CREATE TABLE statement.
    24      InputCols Presentation
    25  
    26      # Syntax is the CREATE TABLE AST node. All data sources inside AsSource are
    27      # fully qualified.
    28      Syntax CreateTable
    29  }
    30  
    31  [Relational, DDL, Mutation]
    32  define CreateView {
    33      _ CreateViewPrivate
    34  }
    35  
    36  [Private]
    37  define CreateViewPrivate {
    38      # Schema is the ID of the catalog schema into which the new table goes.
    39      Schema SchemaID
    40      ViewName string
    41      Temporary bool
    42      IfNotExists bool
    43      Replace bool
    44  
    45      # ViewQuery contains the query for the view; data sources are always fully
    46      # qualified.
    47      ViewQuery string
    48  
    49      # Columns that correspond to the output of the view query, with the names
    50      # they will have as part of the view.
    51      Columns Presentation
    52  
    53      # Deps contains the data source dependencies of the view.
    54      Deps ViewDeps
    55  }
    56  
    57  # Explain returns information about the execution plan of the "input"
    58  # expression.
    59  [Relational]
    60  define Explain {
    61      Input RelExpr
    62      _ ExplainPrivate
    63  }
    64  
    65  [Private]
    66  define ExplainPrivate {
    67      # Options contains settings that control the output of the explain statement.
    68      Options ExplainOptions
    69  
    70      # ColList stores the column IDs for the explain columns.
    71      ColList ColList
    72  
    73      # Props stores the required physical properties for the enclosed expression.
    74      Props PhysProps
    75  
    76      # StmtType stores the type of the statement we are explaining.
    77      StmtType StatementType
    78  }
    79  
    80  # ShowTraceForSession returns the current session traces.
    81  [Relational]
    82  define ShowTraceForSession {
    83      _ ShowTracePrivate
    84  }
    85  
    86  [Private]
    87  define ShowTracePrivate {
    88      TraceType ShowTraceType
    89  
    90      # Compact indicates that we output a smaller set of columns; set
    91      # when SHOW COMPACT [KV] TRACE is used.
    92      Compact bool
    93  
    94      # ColList stores the column IDs for the SHOW TRACE columns.
    95      ColList ColList
    96  }
    97  
    98  # OpaqueRel is an opaque relational operator which is planned outside of the
    99  # optimizer. The operator contains an opaque metadata which is passed to the
   100  # exec factory.
   101  #
   102  # This is used for statements that are not directly supported by the optimizer,
   103  # and which don't use the result of other relational expressions (in other
   104  # words, they are a "leaf" operator).
   105  #
   106  # OpaqueRel can produce data and can be used as a data source as part of a
   107  # larger enclosing query.
   108  [Relational]
   109  define OpaqueRel {
   110      _ OpaqueRelPrivate
   111  }
   112  
   113  # OpaqueMutation is a variant of OpaqueRel for operators that can mutate data as
   114  # part of the transaction.
   115  [Relational, Mutation]
   116  define OpaqueMutation {
   117      _ OpaqueRelPrivate
   118  }
   119  
   120  # OpaqueMutation is a variant of OpaqueRel for operators that cause a schema
   121  # change and cannot be executed following a mutation in the same transaction.
   122  [Relational, Mutation, DDL]
   123  define OpaqueDDL {
   124      _ OpaqueRelPrivate
   125  }
   126  
   127  [Private]
   128  define OpaqueRelPrivate {
   129      Columns ColList
   130      Metadata OpaqueMetadata
   131  }
   132  
   133  # AlterTableSplit represents an `ALTER TABLE/INDEX .. SPLIT AT ..` statement.
   134  [Relational, Mutation]
   135  define AlterTableSplit {
   136      # The input expression provides values for the index columns (or a prefix of
   137      # them).
   138      Input RelExpr
   139  
   140      # Expiration is a string scalar that indicates a timestamp after which the
   141      # ranges are eligible for automatic merging (or Null if there is no
   142      # expiration).
   143      Expiration ScalarExpr
   144      _ AlterTableSplitPrivate
   145  }
   146  
   147  [Private]
   148  define AlterTableSplitPrivate {
   149      # Table identifies the table to alter. It is an id that can be passed to
   150      # the Metadata.Table method in order to fetch cat.Table metadata.
   151      Table TableID
   152  
   153      # Index identifies the index to scan (whether primary or secondary). It
   154      # can be passed to the cat.Table.Index() method in order to fetch the
   155      # cat.Index metadata.
   156      Index IndexOrdinal
   157  
   158      # Props stores the required physical properties for the input expression.
   159      Props PhysProps
   160  
   161      # Columns stores the column IDs for the statement result columns.
   162      Columns ColList
   163  }
   164  
   165  # AlterTableUnsplit represents an `ALTER TABLE/INDEX .. UNSPLIT AT ..`
   166  # statement.
   167  [Relational, Mutation]
   168  define AlterTableUnsplit {
   169      Input RelExpr
   170      _ AlterTableSplitPrivate
   171  }
   172  
   173  # AlterTableUnsplit represents an `ALTER TABLE/INDEX .. UNSPLIT ALL` statement.
   174  [Relational, Mutation]
   175  define AlterTableUnsplitAll {
   176      _ AlterTableSplitPrivate
   177  }
   178  
   179  # AlterTableRelocate represents an `ALTER TABLE/INDEX .. SPLIT AT ..` statement.
   180  [Relational, Mutation]
   181  define AlterTableRelocate {
   182      # The input expression provides values for the index columns (or a prefix of
   183      # them).
   184      Input RelExpr
   185      _ AlterTableRelocatePrivate
   186  }
   187  
   188  [Private]
   189  define AlterTableRelocatePrivate {
   190      RelocateLease bool
   191      _ AlterTableSplitPrivate
   192  }
   193  
   194  # ControlJobs represents a `PAUSE/CANCEL/RESUME JOBS` statement.
   195  [Relational]
   196  define ControlJobs {
   197      # The input expression returns job IDs (as integers).
   198      Input RelExpr
   199      _ ControlJobsPrivate
   200  }
   201  
   202  [Private]
   203  define ControlJobsPrivate {
   204      # Props stores the required physical properties for the input
   205      # expression.
   206      Props PhysProps
   207      Command JobCommand
   208  }
   209  
   210  # CancelQueries represents a `CANCEL QUERIES` statement.
   211  [Relational]
   212  define CancelQueries {
   213      # The input expression returns query IDs (as strings).
   214      Input RelExpr
   215      _ CancelPrivate
   216  }
   217  
   218  [Private]
   219  define CancelPrivate {
   220      # Props stores the required physical properties for the input
   221      # expression.
   222      Props PhysProps
   223  
   224      # IfExists is set if we should tolerate IDs that don't exist.
   225      IfExists bool
   226  }
   227  
   228  # CancelSessions represents a `CANCEL SESSIONS` statement.
   229  [Relational]
   230  define CancelSessions {
   231      # The input expression returns session IDs (as strings).
   232      Input RelExpr
   233      _ CancelPrivate
   234  }
   235  
   236  # Export represents an `EXPORT` statement.
   237  [Relational]
   238  define Export {
   239      # Input is the relational expression for the data we are exporting.
   240      Input RelExpr
   241  
   242      # FileName is the string URI for the output file.
   243      FileName ScalarExpr
   244      Options KVOptionsExpr
   245      _ ExportPrivate
   246  }
   247  
   248  [Private]
   249  define ExportPrivate {
   250      # FileFormat describes the requested format, e.g. "CSV".
   251      FileFormat string
   252  
   253      # Props stores the required physical properties for the input expression.
   254      Props PhysProps
   255  
   256      # Columns stores the column IDs for the statement result columns.
   257      Columns ColList
   258  }