github.com/matrixorigin/matrixone@v0.7.0/proto/plan.proto (about)

     1  /* 
     2   * Copyright 2021 Matrix Origin
     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  syntax = "proto3";
    18  package plan;
    19  
    20  import "github.com/gogo/protobuf/gogoproto/gogo.proto";
    21  
    22  option go_package = "github.com/matrixorigin/matrixone/pkg/pb/plan";
    23  option (gogoproto.sizer_all) = false;
    24  option (gogoproto.protosizer_all) = true;
    25  
    26  message Type {
    27  	int32 id            = 1;
    28  	bool notNullable	= 2;
    29  	bool auto_incr      = 3;
    30  	int32 width			= 4;
    31  	int32 precision		= 5;
    32  	int32 size 			= 6;
    33  	int32 scale 		= 7;
    34  	string table 		= 8;
    35  };
    36  
    37  // Const: if a const value can be reprensented by int64 or
    38  // double, use that, otherwise store a string representation.
    39  message Const {
    40  	bool isnull			= 1;
    41  	oneof value {
    42  		int32 i8val		= 2;  // pb have no int8
    43  		int32 i16val	= 3;  // pb have no int16
    44  		int32 i32val	= 4;
    45  		int64 i64val	= 5;
    46  		uint32 u8val 	= 6;  // pb have no uint8
    47  		uint32 u16val 	= 7;  // pb have no uint16
    48  		uint32 u32val 	= 8;
    49  		uint64 u64val 	= 9;
    50  		double dval 	= 10;
    51  		string sval		= 11;
    52  		bool bval 		= 12;
    53  		float fval		= 13;
    54  		int32 dateval 	= 14;
    55  		int64 timeval 	= 15;
    56  		int64 datetimeval			= 16;
    57  		decimal64 decimal64val 		= 17;
    58  		decimal128 decimal128val 	= 18;
    59  		int64 timestampval 			= 19;
    60  		string jsonval 				= 20;
    61  		bool defaultval 			= 21;
    62  		bool updateVal 				= 22;
    63  	}
    64  	bool isBin = 23;
    65  	Expr src = 24; // if generated by replacing an existing expr
    66  }
    67  
    68  // Bounded param for prepared statement.  User fill on execution.
    69  message ParamRef {
    70  	int32 pos	= 1;
    71  }
    72  
    73  // Session variable ref, compiler should fold.
    74  message VarRef {
    75  	string name = 1;
    76  	bool system = 2;
    77  	bool global = 3;
    78  }
    79  
    80  // Reference a column in the proj list of a node.
    81  message ColRef {
    82  	int32	rel_pos	= 1;
    83  	int32	col_pos	= 2;
    84  	string	name	= 3;
    85  }
    86  
    87  // Reference a column by its internal table id and column id
    88  message RawColRef {
    89  	uint64 tbl_id = 1;
    90  	uint64 col_id = 2;
    91  }
    92  
    93  // Reference a correlated column in the proj list of a node.
    94  message CorrColRef {
    95  	int32 rel_pos	= 1;
    96  	int32 col_pos	= 2;
    97  	int32 depth		= 3;
    98  }
    99  
   100  // ExprList is a type of Expr
   101  message ExprList {
   102  	repeated Expr list = 1;
   103  }
   104  
   105  message MaxValue {
   106  	string value = 1;
   107  }
   108  
   109  // TargetType used in cast function as target type
   110  message TargetType {
   111  	Type typ = 1;
   112  }
   113  
   114  // Reference a subquery
   115  message SubqueryRef {
   116  	enum Type {
   117  		SCALAR		= 0;
   118  		EXISTS		= 1;
   119  		NOT_EXISTS	= 2;
   120  		IN			= 3;
   121  		NOT_IN		= 4;
   122  		ANY			= 5;
   123  		ALL			= 6;
   124  	}
   125  
   126  	Type typ		= 1;
   127  	int32 node_id	= 2;
   128  	string op		= 3;
   129  	Expr child		= 4;
   130  	int32 row_size	= 5;
   131  }
   132  
   133  // Object ref, reference a object in database, 4 part name.
   134  message ObjectRef {
   135  	int64 server	= 1;
   136  	int64 db		= 2;
   137  	int64 schema	= 3;
   138  	int64 obj		= 4;
   139  	string server_name	= 5;
   140  	string db_name		= 6;
   141  	string schema_name	= 7;
   142  	string obj_name		= 8;
   143  }
   144  
   145  message Function {
   146  	// Function flags
   147  	enum FuncFlag {
   148  		NONE     = 0;
   149  		// Internal function is generated by system, cannot
   150  		// by called by user.
   151  		INTERNAL = 1;
   152  
   153  		// Function, by default is immutable.
   154  		STABLE   = 2;
   155  		VOLATILE = 4;
   156  
   157  		// Nulls
   158  		STRICT				= 8;
   159  		PRODUCE_NULL		= 16;
   160  		PRODUCE_NO_NULL		= 32;
   161  
   162  		// Vararg, all trailing args must be of the same type.
   163  		VARARG     = 64;
   164  
   165  		// Window and Agg
   166  		AGG        = 128;
   167  		WIN        = 256;
   168  
   169  		// Monotonic function can filter by zonemap
   170  		MONOTONIC = 512;
   171  	}
   172  
   173  	ObjectRef func		= 1;
   174  	repeated Expr args	= 2;
   175  }
   176  
   177  message Expr {
   178  	Type typ = 1;
   179  	oneof expr {
   180  		Const		c		= 2;
   181  		ParamRef	p		= 3;
   182  		VarRef		v		= 4;
   183  		ColRef		col 	= 5;
   184  		RawColRef	raw		= 6;
   185  		Function	f		= 7;
   186  		SubqueryRef	sub		= 8;
   187  		CorrColRef	corr	= 9;
   188  		TargetType  t		= 10;
   189  		ExprList	list	= 11;
   190  		MaxValue	max		= 12;
   191  	}
   192  }
   193  
   194  enum CompressType {
   195  	None 	= 0;
   196  	Lz4 	= 1;
   197  }
   198  
   199  message decimal64 {
   200  	int64 a = 1;
   201  }
   202  
   203  message decimal128 {
   204  	int64 a = 1;
   205  	int64 b = 2;
   206  }
   207  
   208  message ResultColDef {
   209  	repeated ColDef ResultCols = 1;
   210  }
   211  
   212  message ColDef {
   213  	uint64 col_id		= 1;
   214  	string name 		= 2;
   215  	bool hidden			= 3;
   216  	CompressType alg 	= 4;
   217  	Type typ			= 5;
   218  	bool not_null		= 6;
   219  	Default default 	= 7;
   220  	string comment		= 8;
   221  	OnUpdate on_update  = 9;
   222  	bool low_card 		= 10;
   223  
   224  	// XXX: Deprecated and to be removed soon.
   225  	bool clusterBy		= 11;
   226  	bool primary        = 12;
   227  	int32 pkidx 		= 13;
   228  }
   229  
   230  message Default {
   231  	Expr expr = 1;
   232  	string origin_string = 2;
   233  
   234  	// XXX: Deprecated and to be removed soon.
   235  	bool null_ability = 3;
   236  }
   237  
   238  message OnUpdate {
   239  	Expr expr = 1;
   240  	string origin_string = 2;
   241  }
   242  
   243  message IndexOption {
   244  	bool create_extra_table = 1;
   245  }
   246  
   247  message PrimaryKeyDef {
   248  	// currently not used
   249  	repeated uint64 cols	= 1;
   250  	// currently not used
   251  	uint64 pkey_col_id		= 2;
   252  	// currently not used
   253  	IndexOption option		= 3;
   254  
   255  	// Composed primary key column name: __mo_cpkey
   256  	string pkey_col_name = 4;
   257  	// XXX: Deprecated and to be removed soon.
   258  	repeated string names = 5;
   259  }
   260  
   261  message IndexDef {
   262  	// Generate UUID for each index, currently not used
   263  	string idx_id			       = 1;
   264  	string index_name        = 2;
   265  	// The constituent columns of the index
   266  	repeated string parts    = 3;
   267  	bool unique				       = 4;
   268  	string index_table_name  = 5;
   269  	bool table_exist        = 6;
   270  	string comment          = 7;
   271  	// currently not used
   272  	IndexOption option		  = 8;
   273  }
   274  
   275  
   276  message ForeignKeyDef {
   277  	enum RefAction {
   278  		RESTRICT	= 0;
   279  		CASCADE		= 1;
   280  		SET_NULL	= 2;
   281  		SET_DEFAULT	= 3;
   282  		NO_ACTION	= 4;
   283  	}
   284  
   285  	string name						= 1;
   286  	repeated uint64 cols			= 2;
   287  	uint64 foreign_tbl				= 3;
   288  	repeated uint64 foreign_cols	= 4;
   289  	RefAction on_delete				= 5;
   290  	RefAction on_update				= 6;
   291  }
   292  
   293  message CheckDef {
   294  	string name	= 1;
   295  	// Name for anonymous constraints, __mo_chk_[INDEX_ID]
   296  	Expr check	= 2;
   297  }
   298  
   299  message ClusterByDef {
   300  	repeated Expr parts = 1;
   301  
   302  	// XXX: Deprecated and to be removed soon.
   303  	string name = 2;
   304  }
   305  
   306  message PropertyDef {
   307  	string key 		= 1;
   308  	string value 	= 2;
   309  }
   310  
   311  message Property {
   312  	string key 		= 1;
   313  	string value 	= 2;
   314  }
   315  
   316  message PropertiesDef {
   317  	repeated Property properties 	= 1;
   318  }
   319  
   320  
   321  enum PartitionType {
   322  	KEY = 0;
   323  	LINEAR_KEY = 1;
   324  	HASH = 2;
   325  	LINEAR_HASH = 3;
   326  	RANGE = 4;
   327  	RANGE_COLUMNS = 5;
   328  	LIST = 6;
   329  	LIST_COLUMNS = 7;
   330  }
   331  
   332  message PartitionByDef {
   333  	PartitionType type = 1;
   334  	PartitionExpr partition_expr = 2;
   335  	Expr partition_expression = 3;
   336  	PartitionColumns partition_columns = 4;
   337  	uint64 partitionNum = 5;
   338  	repeated PartitionItem partitions = 6;
   339  	int64 algorithm = 7;
   340  	bool is_sub_partition = 8;
   341  	string partition_msg = 9;
   342  }
   343  
   344  message PartitionExpr {
   345  	Expr expr = 1;
   346  	string expr_str = 2;
   347  }
   348  
   349  message PartitionColumns {
   350  	repeated Expr columns = 1;
   351  	repeated string partition_columns = 2;
   352  }
   353  
   354  message PartitionItem {
   355  	string partition_name = 1;
   356  	uint32 ordinal_position = 2;
   357  	string description = 3;
   358  	string comment = 4;
   359  	repeated Expr less_than = 5;
   360  	repeated Expr in_values = 6;
   361  }
   362  
   363  
   364  message ViewDef {
   365  	string view  = 1;
   366  }
   367  
   368  message TableDef {
   369  	// XXX: Deprecated and to be removed soon.
   370  	message DefType {
   371  		oneof def {
   372  			PropertiesDef properties	= 1;
   373  		}
   374  	}
   375  
   376  	uint64 tbl_id			= 1;
   377  	string name				= 2;
   378  	bool hidden				= 3;
   379  	repeated ColDef cols	= 4;
   380  	string table_type 		= 5;
   381  	string createsql 		= 6;
   382  	TableFunction tbl_func	= 7;
   383  
   384  	PrimaryKeyDef pkey				= 11;
   385  	repeated IndexDef indexes = 12;
   386  	repeated ForeignKeyDef fkeys	= 13;
   387  	repeated uint64 ref_child_tbls	= 14;
   388  	repeated CheckDef checks		= 15;
   389  
   390  	PartitionByDef partition		= 21;
   391  	ClusterByDef cluster_by		= 22;
   392  	repeated PropertyDef props	= 23;
   393  	ViewDef view_sql			= 24;
   394  	repeated ColDef origin_cols	= 25;
   395  
   396  	// XXX: Deprecated and to be removed soon.
   397  	repeated DefType defs	= 31;
   398  	map<string, int32> name2col_index = 32;
   399  	ColDef composite_pkey = 33;
   400  }
   401  
   402  message TableFunction{
   403  	string name = 1;
   404  	bytes param = 2;
   405  }
   406  
   407  
   408  message Stats {
   409  	//for scan, number of blocks to read from S3
   410  	//for other nodes, it's meaningless
   411  	int32  block_num        = 1;
   412  	//for scan, cost of reading from S3, basically the read lines
   413  	//for other nodes, it means the estimated cost of current node
   414  	double cost				= 2;
   415  	//number of output lines
   416  	double outcnt			= 3;
   417  	// average size of one row, currently not used
   418  	double rowsize	        = 4;
   419  	// hashmap size for nodes which build a hashmap
   420  	//for other nodes, it's meaningless
   421  	double hashmap_size		= 5;
   422  	//for scan, this means total count of all table, before filtering
   423  	//for other nodes, this is meanlingless
   424  	double table_cnt = 6;
   425  	//for scan, selectivity means outcnt divide total count
   426  	//for other node, currently be 0. will change in the future
   427  	double selectivity = 7;
   428  }
   429  
   430  message ColData {
   431  	repeated Expr data = 1;
   432  }
   433  
   434  message RowsetData {
   435  	repeated ColData cols	= 1;
   436  }
   437  
   438  message OrderBySpec {
   439  	enum OrderByFlag {
   440  		INTERNAL    = 0;
   441  		ASC  		= 1;
   442  		DESC 		= 2;
   443  		NULLS_FIRST = 4;
   444  		NULLS_LAST  = 8;
   445  		UNIQUE      = 16;
   446  	}
   447  
   448  	Expr expr = 1;
   449  	string collation = 2;
   450  	OrderByFlag flag = 3;
   451  }
   452  
   453  message WindowSpec {
   454  	repeated Expr partition_by = 1;
   455  	repeated OrderBySpec order_by = 2;
   456  	int32 lead = 3;
   457  	int32 lag  = 4;
   458  }
   459  
   460  message InsertCtx {
   461  	ObjectRef ref 					= 1;
   462  	repeated int32 idx 				= 2;
   463  	TableDef table_def 				= 3;
   464  
   465  	map<string, int32> parent_idx 	= 4;
   466  
   467  	ClusterTable cluster_table = 5;
   468  }
   469  
   470  message UpdateCtx {
   471  	repeated ObjectRef ref 				= 1;
   472  	repeated IdList idx 				= 2;
   473  	repeated TableDef tableDefs 		= 3;
   474  	repeated ColPosMap update_col 		= 4; 
   475  
   476  	repeated ObjectRef idx_ref 			= 5;
   477  	repeated int32 idx_idx 				= 6;
   478  
   479  	repeated ObjectRef on_restrict_ref 	= 7;
   480  	repeated int32 on_restrict_idx 		= 8;
   481  
   482  	repeated ObjectRef on_cascade_ref 			= 9;
   483  	repeated IdList on_cascade_idx 				= 10;
   484  	repeated TableDef on_cascade_def			= 11;
   485  	repeated ColPosMap on_cascade_update_col 	= 12; 
   486  
   487  	repeated ObjectRef on_set_ref 			= 13;
   488  	repeated IdList on_set_idx 				= 14;
   489  	repeated TableDef on_set_def			= 15;
   490  	repeated ColPosMap on_set_update_col 	= 16; 
   491  
   492  	repeated ColPosMap parent_idx = 17;
   493  }
   494  
   495  message AnalyzeInfo {
   496      int64 input_rows = 1;
   497      int64 output_rows = 2;
   498      int64 input_size = 3;
   499      int64 output_size = 4;
   500      int64 time_consumed = 5;
   501      int64 memory_size = 6;
   502      int64 wait_time_consumed = 7;
   503      int64 diskIO = 8;
   504      int64 s3IO_byte = 9;
   505      int64 s3IO_count = 10;
   506      int64 networkIO = 11;
   507  	int64 scanTime = 12;
   508  	int64 insertTime = 13;
   509  }
   510  
   511  message Node {
   512  	enum NodeType {
   513  		UNKNOWN = 0;
   514  		// Node Types
   515  
   516  		// Scans
   517  		VALUE_SCAN = 1;
   518  		TABLE_SCAN = 2;
   519  		FUNCTION_SCAN = 3;
   520  		EXTERNAL_SCAN = 4;
   521  		MATERIAL_SCAN = 5;
   522  
   523  		// Proj, for convenience
   524  		PROJECT = 10;
   525  		// External function call (UDF)
   526  		EXTERNAL_FUNCTION = 11;
   527  
   528  		// Material, CTE, etc.
   529  		MATERIAL = 20;
   530  		RECURSIVE_CTE = 21;
   531  		SINK = 22;
   532  		SINK_SCAN = 23;
   533  
   534  		// Proper Relational Operators
   535  		AGG = 30;
   536  		DISTINCT = 31;
   537  		FILTER = 32;
   538  		JOIN = 33;
   539  		SAMPLE = 34;
   540  		SORT = 35;
   541  		UNION = 36;
   542  		UNION_ALL = 37;
   543  		UNIQUE = 38;
   544  		WINDOW = 39;
   545  
   546  		// Physical tuple mover
   547  		BROADCAST = 40;
   548  		SPLIT = 41;
   549  		GATHER = 42;
   550  
   551  		// Misc
   552  		ASSERT = 50;
   553  
   554  		//
   555  		INSERT = 51;
   556  		UPDATE = 52;
   557  		DELETE = 53;
   558  
   559  		//
   560  		INTERSECT = 54;
   561  		INTERSECT_ALL = 55;
   562  		MINUS = 56;
   563  		MINUS_ALL = 57;
   564  	}
   565  
   566  	enum JoinFlag {
   567  		//INNER = 0;
   568  		//OUTER = 1;
   569  		//SEMI = 2;
   570  		//ANTI = 4;
   571  		//SINGLE = 8;
   572  		//MARK = 16;
   573  		//APPLY = 32;
   574  
   575  		INNER	= 0;
   576  		LEFT	= 1;
   577  		RIGHT	= 2;
   578  		OUTER	= 3;
   579  		SEMI	= 4;
   580  		ANTI	= 5;
   581  		SINGLE	= 6;
   582  		MARK	= 7;
   583  		APPLY	= 8;
   584  	}
   585  
   586  	enum AggMode {
   587  		FULL = 0;
   588  		BOTTOM = 1;
   589  		TOP = 2;
   590  	}
   591  
   592  	NodeType node_type = 1;
   593  	int32 node_id = 2;
   594  	Stats stats = 3;
   595  
   596  	repeated Expr project_list = 4;
   597  	repeated int32 children = 5;
   598  	JoinFlag join_type = 6;
   599  	repeated Expr on_list = 7;
   600  	repeated Expr filter_list = 8;
   601  	repeated Expr group_by = 9;
   602  	repeated Expr grouping_set = 10;
   603  	repeated Expr agg_list = 11;
   604  	repeated OrderBySpec order_by = 12;
   605  	UpdateCtx update_ctx = 13;
   606  	WindowSpec win_spec = 14;
   607  	Expr limit = 15;
   608  	Expr offset = 16;
   609  	TableDef table_def = 17;
   610  	repeated TableDef table_def_vec = 18;
   611  	ObjectRef obj_ref = 19;
   612  	RowsetData rowset_data = 20;
   613  	string extra_options = 21;
   614  	DeleteCtx delete_ctx = 22;
   615  
   616  	repeated int32 binding_tags = 23;
   617  
   618      AnalyzeInfo analyze_info = 24;
   619  
   620  	repeated Expr tbl_func_expr_list = 25;
   621  
   622      // The pipeline will determine the parallelism by traversing the plan 
   623      // when it is received. Then the build is built based on this information.
   624      int32   parallelism = 26;
   625  
   626  	ClusterTable cluster_table = 27;
   627  	bool not_cacheable = 28;
   628  	InsertCtx insert_ctx = 29;
   629  }
   630  
   631  message IdList {
   632  	repeated int64 list = 1;
   633  }
   634  
   635  message ColPosMap {
   636  	map<string, int32> map = 1;
   637  }
   638  
   639  message DeleteCtx {
   640  	repeated ObjectRef ref 			= 1;
   641  
   642  	repeated ObjectRef idx_ref 		= 2;
   643  	repeated int32 idx_idx 			= 3;
   644  
   645  	repeated ObjectRef on_restrict_ref 	= 4;
   646  	repeated int32 on_restrict_idx 		= 5;
   647  
   648  	repeated ObjectRef on_cascade_ref 	= 6;
   649  	repeated int32 on_cascade_idx 		= 7;
   650  
   651  	repeated ObjectRef on_set_ref 			= 8;
   652  	repeated TableDef on_set_def 			= 9;
   653  	repeated IdList on_set_idx 				= 10;
   654  	repeated ColPosMap on_set_update_col 	= 11; 
   655  	
   656  	bool can_truncate = 12;
   657  }
   658  
   659  message Query {
   660  	enum StatementType {
   661  		UNKNOWN		= 0;
   662  		SELECT		= 1;
   663  		INSERT		= 2;
   664  		DELETE		= 3;
   665  		UPDATE		= 4;
   666  		MERGE		= 5;
   667  	}
   668  
   669  	StatementType stmt_type		= 1;
   670  
   671  	// A query may need to run in steps.   This in theory is not
   672  	// necessary but often convenient and/or can be better optimized.
   673  	// For example, executing non correctlated scalar subquery first
   674  	// we can plug the value in the optmizer and the newly available
   675  	// value may generate better plan.
   676  
   677  	// Each step is simply a root node.  Root node refers to other
   678  	// node as children and the whole step is a DAG.
   679  	repeated int32 steps	= 2;
   680  
   681  	// All the nodes.  It is OK to have dangle nodes, we only excute nodes
   682  	// reachable from step roots.
   683  	repeated Node nodes		= 3;
   684  
   685  	// Bound Parameter for the query.
   686  	repeated Expr params	= 4;
   687  
   688  	// return head
   689  	repeated string headings = 5;
   690  
   691  	// load Tag
   692  	bool loadTag = 6;
   693  }
   694  
   695  message TransationControl {
   696  	enum TclType {
   697  		BEGIN 		= 0;
   698  		COMMIT 		= 1;
   699  		ROLLBACK 	= 2;
   700  	}
   701  	//TransationControl type
   702  	TclType tcl_type = 1;
   703  	oneof action {
   704  		TransationBegin begin 		= 2;
   705  		TransationCommit commit 	= 3;
   706  		TransationRollback rollback = 4;
   707  	}
   708  }
   709  
   710  message TransationBegin {
   711  	enum TransationMode {
   712  		NONE 		= 0;
   713  		READ_ONLY 	= 1;
   714  		READ_WRITE 	= 2;
   715  	}
   716  	TransationMode mode = 1;
   717  }
   718  
   719  enum TransationCompletionType {
   720  	CHAIN 		= 0;
   721  	NO_CHAIN 	= 1;
   722  	RELEASE 	= 2;
   723  }
   724  message TransationCommit {
   725  	TransationCompletionType completion_type = 1;
   726  }
   727  message TransationRollback {
   728  	TransationCompletionType completion_type = 1;
   729  }
   730  
   731  message Plan {
   732  	oneof plan {
   733  		Query query 			= 1;
   734  		TransationControl tcl 	= 2;
   735  		DataDefinition ddl 		= 3;
   736  		DataControl	dcl			= 4;
   737  	}
   738  }
   739  
   740  message column{
   741  	repeated Expr column = 1;
   742  }
   743  
   744  message DataControl {
   745  	enum DclType {
   746  		SET_VARIABLES	= 0;
   747  		GRANT			= 1;
   748  		REVOKE			= 2;
   749  		DENY			= 3;
   750  		PREPARE			= 4;
   751  		EXECUTE			= 5;
   752  		DEALLOCATE		= 6;
   753  	}
   754  	//DataDefinition type
   755  	DclType dcl_type = 1;
   756  	oneof control {
   757  		SetVariables set_variables  = 2;
   758  		Prepare prepare 			= 3;
   759  		Execute execute				= 4;
   760  		Deallocate deallocate 		= 5;
   761  	}
   762  }
   763  
   764  message DataDefinition {
   765  	enum DdlType {
   766  		CREATE_DATABASE 	= 0;
   767  		ALTER_DATABASE 		= 1;
   768  		DROP_DATABASE		= 2;
   769  		CREATE_TABLE 		= 3;
   770  		ALTER_TABLE			= 4;
   771  		DROP_TABLE			= 5;
   772  		CREATE_INDEX		= 6;
   773  		ALTER_INDEX			= 7;
   774  		DROP_INDEX			= 8;
   775  		TRUNCATE_TABLE		= 9;
   776  		CREATE_VIEW			= 10;
   777  		ALTER_VIEW			= 11;
   778  		DROP_VIEW			= 12;
   779  		SHOW_CREATEDATABASE = 13;
   780  		SHOW_CREATETABLE 	= 14;
   781  		SHOW_DATABASES		= 15;
   782  		SHOW_TABLES			= 16;
   783  		SHOW_COLUMNS		= 17;
   784  		SHOW_INDEX			= 18;
   785  		SHOW_VARIABLES		= 19;
   786  		SHOW_WARNINGS		= 20;
   787  		SHOW_ERRORS			= 21;
   788  		SHOW_STATUS			= 22;
   789  		SHOW_PROCESSLIST	= 23;
   790  		SHOW_TABLE_STATUS 	= 24;
   791  		SHOW_TARGET 		= 25;
   792  		SHOW_COLLATION 		= 26;
   793  	}
   794  	//DataDefinition type
   795  	DdlType ddl_type = 1;
   796  
   797  	//other show statement we will rewrite to a select statement
   798  	//then we will get a Query
   799  	//eg: 'show databases' will rewrite to 'select md.datname as `Database` from mo_database md'
   800  	Query query = 2;
   801  
   802  	oneof definition {
   803  		CreateDatabase create_database 	= 3;
   804  		AlterDatabase alter_database 	= 4;
   805  		DropDatabase drop_database		= 5;
   806  		CreateTable create_table		= 6;
   807  		AlterTable alter_table 			= 7;
   808  		DropTable drop_table			= 8;
   809  		CreateIndex create_index 		= 9;
   810  		AlterIndex alter_index 			= 10;
   811  		DropIndex drop_index 			= 11;
   812  		TruncateTable truncate_table	= 12;
   813  		ShowVariables show_variables 	= 13;
   814  		AlterView alter_view			= 14;
   815  	}
   816  }
   817  
   818  message CreateDatabase {
   819  	bool if_not_exists 	= 1;
   820  	string database 	= 2;
   821  }
   822  
   823  message AlterDatabase {
   824  	bool if_exists 		= 1;
   825  	string database 	= 2;
   826  }
   827  
   828  message DropDatabase {
   829  	bool if_exists 		= 1;
   830  	string database 	= 2;
   831  }
   832  
   833  message CreateTable {
   834  	message FkColName {
   835  		repeated string cols = 1;
   836  	}
   837  	bool if_not_exists 	= 1;
   838  	bool temporary 		= 2;
   839  	string database 	= 3;
   840  	TableDef table_def 	= 4;
   841  	repeated TableDef index_tables = 5;
   842  	// we need the db/table name of foreign key when create table. but we don't need it in ForeignKeyDef
   843  	repeated string fk_dbs = 6;
   844  	repeated string fk_tables = 7;
   845  	// we need column name when create table, but not in ForeignKeyDef
   846  	repeated FkColName fk_cols = 8;
   847  }
   848  
   849  message AlterTable {
   850  	string table 		= 1;
   851  	TableDef table_def 	= 2;
   852  }
   853  
   854  message AlterView {
   855  	bool if_exists		= 1;
   856  	string database 	= 2;
   857  	bool temporary		= 3;
   858  	string table		= 4;
   859  	TableDef table_def	= 5;
   860  	repeated TableDef index_tables = 6;
   861  }
   862  
   863  message DropTable {
   864  	bool if_exists 	= 1;
   865  	string database = 2;
   866  	string table 	= 3;
   867  	repeated string index_table_names = 4;
   868  	ClusterTable cluster_table = 5;
   869  	uint64 table_id = 6;
   870  	repeated uint64 foreign_tbl = 7;
   871  }
   872  
   873  message CreateIndex {
   874  	string database = 1;
   875  	string table = 2;
   876  	string	origin_table_primary_key = 3;
   877  	CreateTable index = 4;
   878  	bool table_exist = 5;
   879  }
   880  
   881  message AlterIndex {
   882  	string index = 1;
   883  }
   884  
   885  message DropIndex {
   886  	string database = 1;
   887  	string table = 2;
   888  	string index_name = 3;
   889  	string index_table_name = 4;
   890  }
   891  
   892  message TruncateTable {
   893  	string database = 1;
   894  	string table = 2;
   895  	repeated string index_table_names = 3;
   896  	ClusterTable cluster_table = 4;
   897  	uint64 table_id = 5;
   898  	repeated uint64 foreign_tbl = 6;
   899  }
   900  
   901  message ClusterTable{
   902  	bool is_cluster_table = 1;//insert into a cluster table
   903  	repeated uint32 accountIDs = 2;//insert data into the cluster table for every account
   904  	int32 column_index_of_accountId = 3;//the column index of the account id in the cluster table
   905  }
   906  
   907  message ShowVariables {
   908  	bool global 			= 1;
   909  	repeated Expr where 	= 2;
   910  }
   911  
   912  message SetVariables {
   913  	repeated SetVariablesItem items	= 1;
   914  }
   915  
   916  message SetVariablesItem {
   917  	bool system     = 1;
   918  	bool global     = 2;
   919  	string name     = 3;
   920  	Expr   value    = 4;
   921  	Expr   reserved = 5;
   922  }
   923  
   924  message Prepare {
   925  	string name		 			= 1;
   926  	repeated ObjectRef schemas 	= 2;
   927  	Plan   plan		 			= 3;
   928  	repeated int32 param_types  = 4;
   929  }
   930  
   931  message Execute {
   932  	string name 		= 1;
   933  	repeated Expr args 	= 2;
   934  }
   935  
   936  message Deallocate {
   937  	string name			= 1;
   938  }