syntax = "proto2"; // ifdef PROTOBUF_LITE: option optimize_for = LITE_RUNTIME; package Polarx.ExecPlan; option java_package = "com.mysql.cj.x.protobuf"; import "polarx.proto"; // comment_out_if PROTOBUF_LITE import "polarx_expr.proto"; import "polarx_datatypes.proto"; // // Reserved for session. // Session id in header. // // Request. message NewSession { } message CloseSession { } message EnumSession { } // Response. message SessionInfo { } message SessionInfos { repeated SessionInfo sessions = 1; } // // Basic components. // message TableInfo { optional int64 version = 1; // Multi-version? required Polarx.Datatypes.Scalar name = 2; // Need support string and place holder. optional Polarx.Datatypes.Scalar schema_name = 3; // Need support string and place holder. } message IndexInfo { required Polarx.Datatypes.Scalar name = 1; // Need support string and place holder. optional int32 use_parts = 2; } message Transaction { } message BloomFilter { required uint32 total_bits = 1; required uint32 number_hash = 2; required bytes strategy = 3; // 'murmur3_128' required bytes data = 4; } //Client send GetTSO message to Server message GetTSO { required bytes leader_name = 1; required int32 batch_count = 2; } //Server return ResultTSO message to Client message ResultTSO { required int32 error_no = 1; required uint64 ts = 2; } // // Exec plan. // // 单个列条件 message KeyExpr { required Polarx.Datatypes.Scalar field = 1; // 需要能处理列名或列id,列id从0开始 required Polarx.Datatypes.Scalar value = 2; // 需要能处理动态参数 } // 完整的行条件,可包含多个列条件,and关系 message GetExpr { repeated KeyExpr keys = 1; } message GetPlan { required TableInfo table_info = 1; optional IndexInfo index_info = 2; // 如果没指定,默认走primary repeated GetExpr keys = 3; // 索引列过滤条件,如果为空就报错,全表扫描走TableScanPlan } message TableScanPlan { required TableInfo table_info = 1; optional IndexInfo index_info = 2; // 如果没指定,默认走primary optional bool reverse = 3; // 扫描顺序,默认正向 } message KeyOnlyRangeScan { optional Transaction snapshot = 1; // 读取快照,只有作为 top plan 时填写 optional TableInfo table_info = 3; // 读取的目标 table optional IndexInfo index_info = 4; // 读取的目标 index // optional Polarx.Expr.Expr key_expr = 5; // scan 的条件 // 这里写的应该是是索引列中的条件,类似 // idx_field1 > 5 and idx_field2 > 1 optional GetExpr key = 5; optional GetExpr end_key = 6; // end 条件,可选 optional bool reverse = 8; // 扫描顺序 optional int64 flag = 9; // 预留 } message RangeScan { optional Transaction snapshot = 1; // 读取快照,只有作为 top plan 时填写 optional TableInfo table_info = 3; // 读取的目标 table optional IndexInfo index_info = 4; // 读取的目标 index // optional Polarx.Expr.Expr key_expr = 5; // scan 的条件 // 这里写的应该是是索引列中的条件,类似 // idx_field1 > 5 and idx_field2 > 1 optional GetExpr key = 5; optional GetExpr end_key = 6; // end 条件,可选 optional bool reverse = 8; // 扫描顺序 optional int64 flag = 9; // 预留 } message TableProject { required AnyPlan sub_read_plan = 1; // 只支持GET和SCAN两种就行 repeated Polarx.Datatypes.Scalar fields = 2; // 支持列名和列id(int uint),从0开始 } message Project { required AnyPlan sub_read_plan = 1; repeated Polarx.Datatypes.Scalar fields = 2; // 输出列名 repeated Polarx.Expr.Expr exprs = 3; // 支持使用Expr全部功能,包括新增的ref,引用sub_read_plan的输出 } message Filter { required AnyPlan sub_read_plan = 1; required Polarx.Expr.Expr expr = 2; } message Aggr { enum AggrType { COUNT_FUNC = 1; // COUNT COUNT_DISTINCT_FUNC = 2; // COUNT(DISTINCT) SUM_FUNC = 3; // SUM SUM_DISTINCT_FUNC = 4; // SUM(DISTINCT) AVG_FUNC = 5; // AVG AVG_DISTINCT_FUNC = 6; // AVG(DISTINCT) MIN_FUNC = 7; // MIN MAX_FUNC = 8; // MAX }; required AnyPlan sub_read_plan = 1; required AggrType type = 2; //聚集函数类型 required Polarx.Datatypes.Scalar field = 3; //列名 required Polarx.Expr.Expr expr = 4; //聚集函数对应的表达式 } message AnyPlan { enum PlanType { GET = 1; TABLE_SCAN = 2; TABLE_PROJECT = 3; PROJECT = 4; FILTER = 5; RANGE_SCAN = 8; //LIMIT = 7; AGGR = 9; }; required PlanType plan_type = 1; optional GetPlan get_plan = 2; optional TableScanPlan table_scan_plan = 3; optional TableProject table_project = 4; optional Project project = 5; optional Filter filter = 6; optional RangeScan range_scan = 8; optional Aggr aggr = 9; // SortPlan sort_plan = 5; // ProjectPlan project_plan = 6; // FilterPlan filter_plan = 7; // LimitPlan limit_plan = 8; // AggPlan agg_plan = 9; } // server接收的plan message ExecPlan { optional Transaction transaction = 1; optional AnyPlan plan = 2; optional bytes plan_digest = 3; repeated Polarx.Datatypes.Scalar parameters = 4; // 动态参数记录在这,从0开始 **有修改** repeated Polarx.Datatypes.SessionVariable session_variables = 5; optional int32 token = 6; optional bool reset_error = 7; optional bool compact_metadata = 8 [ default = false ]; optional uint64 snapshot_seq = 9; optional uint64 commit_seq = 10; optional bool use_cts_transaction = 12; optional bool chunk_result = 11 [default = false]; optional bool feed_back = 13 [default = false]; }