From e4152ff6f108fbe30ae6702cf69fc49150bed62a Mon Sep 17 00:00:00 2001 From: lance6716 Date: Wed, 11 Feb 2026 16:15:52 +0800 Subject: [PATCH] *: use `buf` to format the proto files Signed-off-by: lance6716 --- .github/workflows/unit-test.yml | 9 + Makefile | 8 +- README.md | 7 + include/rustproto.proto | 66 +- proto/analyze.proto | 180 ++-- proto/checksum.proto | 37 +- proto/executor.proto | 834 +++++++++-------- proto/explain.proto | 137 ++- proto/expression.proto | 1559 +++++++++++++++---------------- proto/metadata.proto | 33 +- proto/resourcetag.proto | 11 +- proto/schema.proto | 47 +- proto/select.proto | 310 +++--- proto/tici/indexer.proto | 13 +- proto/topsql_agent.proto | 179 ++-- proto/trace.proto | 27 +- scripts/check.sh | 12 +- scripts/proto_format.sh | 94 ++ 18 files changed, 1840 insertions(+), 1723 deletions(-) create mode 100755 scripts/proto_format.sh diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 1963ed62b..97b48110b 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -3,6 +3,15 @@ name: "Unit Test" on: [ push,pull_request ] jobs: + proto-format: + name: Check proto format + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Check format + run: make proto-fmt-check + go: name: Test go generation runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index 839d03640..529615375 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all go rust c++ +.PHONY: all dependence check proto-fmt proto-fmt-check go rust c++ CURDIR := $(shell pwd) @@ -13,6 +13,12 @@ dependence: check: dependence ./scripts/check.sh +proto-fmt: + ./scripts/proto_format.sh --write + +proto-fmt-check: + ./scripts/proto_format.sh --check + go: dependence check ./scripts/generate-go.sh GO111MODULE=on go mod tidy diff --git a/README.md b/README.md index de9f88c4a..d2bd518d0 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,13 @@ TiDB protobuf files We use `protoc` 3.5.1, to download: [protobuf/releases/tag/v3.5.1](https://github.com/google/protobuf/releases/tag/v3.5.1) +## Proto formatting + +To avoid IDE-induced diffs, we use `buf format` to keep `.proto` files consistently formatted. + +- Check formatting (also runs as part of `make check`): `make proto-fmt-check` +- Format in-place: `make proto-fmt` + ## Generate the Go and Rust codes ```sh diff --git a/include/rustproto.proto b/include/rustproto.proto index 83e76fdfb..1bc533451 100644 --- a/include/rustproto.proto +++ b/include/rustproto.proto @@ -1,47 +1,47 @@ syntax = "proto2"; -import "google/protobuf/descriptor.proto"; - // see https://github.com/gogo/protobuf/blob/master/gogoproto/gogo.proto // for the original idea package rustproto; +import "google/protobuf/descriptor.proto"; + extend google.protobuf.FileOptions { - // When true, oneof field is generated public - optional bool expose_oneof_all = 17001; - // When true all fields are public, and not accessors generated - optional bool expose_fields_all = 17003; - // When false, `get_`, `set_`, `mut_` etc. accessors are not generated - optional bool generate_accessors_all = 17004; - // Use `bytes::Bytes` for `bytes` fields - optional bool carllerche_bytes_for_bytes_all = 17011; - // Use `bytes::Bytes` for `string` fields - optional bool carllerche_bytes_for_string_all = 17012; - // When true, will only generate codes that works with lite runtime. - optional bool lite_runtime_all = 17035; + // When true, oneof field is generated public + optional bool expose_oneof_all = 17001; + // When true all fields are public, and not accessors generated + optional bool expose_fields_all = 17003; + // When false, `get_`, `set_`, `mut_` etc. accessors are not generated + optional bool generate_accessors_all = 17004; + // Use `bytes::Bytes` for `bytes` fields + optional bool carllerche_bytes_for_bytes_all = 17011; + // Use `bytes::Bytes` for `string` fields + optional bool carllerche_bytes_for_string_all = 17012; + // When true, will only generate codes that works with lite runtime. + optional bool lite_runtime_all = 17035; } extend google.protobuf.MessageOptions { - // When true, oneof field is generated public - optional bool expose_oneof = 17001; - // When true all fields are public, and not accessors generated - optional bool expose_fields = 17003; - // When false, `get_`, `set_`, `mut_` etc. accessors are not generated - optional bool generate_accessors = 17004; - // Use `bytes::Bytes` for `bytes` fields - optional bool carllerche_bytes_for_bytes = 17011; - // Use `bytes::Bytes` for `string` fields - optional bool carllerche_bytes_for_string = 17012; + // When true, oneof field is generated public + optional bool expose_oneof = 17001; + // When true all fields are public, and not accessors generated + optional bool expose_fields = 17003; + // When false, `get_`, `set_`, `mut_` etc. accessors are not generated + optional bool generate_accessors = 17004; + // Use `bytes::Bytes` for `bytes` fields + optional bool carllerche_bytes_for_bytes = 17011; + // Use `bytes::Bytes` for `string` fields + optional bool carllerche_bytes_for_string = 17012; } extend google.protobuf.FieldOptions { - // When true all fields are public, and not accessors generated - optional bool expose_fields_field = 17003; - // When false, `get_`, `set_`, `mut_` etc. accessors are not generated - optional bool generate_accessors_field = 17004; - // Use `bytes::Bytes` for `bytes` fields - optional bool carllerche_bytes_for_bytes_field = 17011; - // Use `bytes::Bytes` for `string` fields - optional bool carllerche_bytes_for_string_field = 17012; -} \ No newline at end of file + // When true all fields are public, and not accessors generated + optional bool expose_fields_field = 17003; + // When false, `get_`, `set_`, `mut_` etc. accessors are not generated + optional bool generate_accessors_field = 17004; + // Use `bytes::Bytes` for `bytes` fields + optional bool carllerche_bytes_for_bytes_field = 17011; + // Use `bytes::Bytes` for `string` fields + optional bool carllerche_bytes_for_string_field = 17012; +} diff --git a/proto/analyze.proto b/proto/analyze.proto index b1d509d7d..a7b306684 100644 --- a/proto/analyze.proto +++ b/proto/analyze.proto @@ -2,175 +2,173 @@ syntax = "proto2"; package tipb; -option java_multiple_files = true; -option java_package = "com.pingcap.tidb.tipb"; - -import "schema.proto"; - import "gogoproto/gogo.proto"; import "rustproto.proto"; +import "schema.proto"; +option java_multiple_files = true; +option java_package = "com.pingcap.tidb.tipb"; +option (gogoproto.goproto_sizecache_all) = false; +option (gogoproto.goproto_unkeyed_all) = false; +option (gogoproto.goproto_unrecognized_all) = false; option (gogoproto.marshaler_all) = true; option (gogoproto.sizer_all) = true; option (gogoproto.unmarshaler_all) = true; -option (gogoproto.goproto_unkeyed_all) = false; -option (gogoproto.goproto_unrecognized_all) = false; -option (gogoproto.goproto_sizecache_all) = false; option (rustproto.lite_runtime_all) = true; enum AnalyzeType { - TypeIndex = 0; - TypeColumn = 1; - TypeCommonHandle = 2; - TypeSampleIndex = 3; - TypeMixed = 4; - TypeFullSampling = 5; + TypeIndex = 0; + TypeColumn = 1; + TypeCommonHandle = 2; + TypeSampleIndex = 3; + TypeMixed = 4; + TypeFullSampling = 5; } message AnalyzeReq { - optional AnalyzeType tp = 1 [(gogoproto.nullable) = false]; - // Deprecated. Start Ts has been moved to coprocessor.Request. - optional uint64 start_ts_fallback = 2; - optional uint64 flags = 3 [(gogoproto.nullable) = false]; - optional int64 time_zone_offset = 4 [(gogoproto.nullable) = false]; - optional AnalyzeIndexReq idx_req = 5; - optional AnalyzeColumnsReq col_req = 6; + optional AnalyzeType tp = 1 [(gogoproto.nullable) = false]; + // Deprecated. Start Ts has been moved to coprocessor.Request. + optional uint64 start_ts_fallback = 2; + optional uint64 flags = 3 [(gogoproto.nullable) = false]; + optional int64 time_zone_offset = 4 [(gogoproto.nullable) = false]; + optional AnalyzeIndexReq idx_req = 5; + optional AnalyzeColumnsReq col_req = 6; } message AnalyzeIndexReq { - // bucket_size is the max histograms bucket size. - optional int64 bucket_size = 1 [(gogoproto.nullable) = false]; + // bucket_size is the max histograms bucket size. + optional int64 bucket_size = 1 [(gogoproto.nullable) = false]; - // num_columns is the number of columns in the index. - optional int32 num_columns = 2 [(gogoproto.nullable) = false]; + // num_columns is the number of columns in the index. + optional int32 num_columns = 2 [(gogoproto.nullable) = false]; - optional int32 cmsketch_depth = 3; + optional int32 cmsketch_depth = 3; - optional int32 cmsketch_width = 4; + optional int32 cmsketch_width = 4; - optional int64 sample_size = 5 [(gogoproto.nullable) = false]; + optional int64 sample_size = 5 [(gogoproto.nullable) = false]; - optional int64 sketch_size = 6 [(gogoproto.nullable) = false]; + optional int64 sketch_size = 6 [(gogoproto.nullable) = false]; - optional int32 top_n_size = 7; + optional int32 top_n_size = 7; - optional int32 version = 8; + optional int32 version = 8; } message AnalyzeColumnsReq { - // bucket_size is the max histograms bucket size, we need this because when primary key is handle, - // the histogram will be directly built. - optional int64 bucket_size = 1 [(gogoproto.nullable) = false]; + // bucket_size is the max histograms bucket size, we need this because when primary key is handle, + // the histogram will be directly built. + optional int64 bucket_size = 1 [(gogoproto.nullable) = false]; - // sample_size is the max number of samples that will be collected. - optional int64 sample_size = 2 [(gogoproto.nullable) = false]; + // sample_size is the max number of samples that will be collected. + optional int64 sample_size = 2 [(gogoproto.nullable) = false]; - // sketch_size is the max sketch size. - optional int64 sketch_size = 3 [(gogoproto.nullable) = false]; + // sketch_size is the max sketch size. + optional int64 sketch_size = 3 [(gogoproto.nullable) = false]; - // columns_info is the info of all the columns that needs to be analyzed. - repeated ColumnInfo columns_info = 4; + // columns_info is the info of all the columns that needs to be analyzed. + repeated ColumnInfo columns_info = 4; - optional int32 cmsketch_depth = 5; + optional int32 cmsketch_depth = 5; - optional int32 cmsketch_width = 6; + optional int32 cmsketch_width = 6; - repeated int64 primary_column_ids = 7; + repeated int64 primary_column_ids = 7; - optional int32 version = 8; + optional int32 version = 8; - repeated int64 primary_prefix_column_ids = 9; + repeated int64 primary_prefix_column_ids = 9; - repeated AnalyzeColumnGroup column_groups = 10; - // sample_rate is the sampling rate that how many samples will collected. - // There must be one non-zero value in sample_rate and sample_size. - optional double sample_rate = 11; + repeated AnalyzeColumnGroup column_groups = 10; + // sample_rate is the sampling rate that how many samples will collected. + // There must be one non-zero value in sample_rate and sample_size. + optional double sample_rate = 11; } message AnalyzeMixedResp { - optional AnalyzeColumnsResp columns_resp = 1; + optional AnalyzeColumnsResp columns_resp = 1; - optional AnalyzeIndexResp index_resp = 2; + optional AnalyzeIndexResp index_resp = 2; } message AnalyzeColumnGroup { - repeated int64 column_offsets = 1; - repeated int64 prefix_lengths = 2; + repeated int64 column_offsets = 1; + repeated int64 prefix_lengths = 2; } message AnalyzeColumnsResp { - // collectors is the sample collectors for columns. - repeated SampleCollector collectors = 1; + // collectors is the sample collectors for columns. + repeated SampleCollector collectors = 1; - // pk_hist is the histogram for primary key when it is the handle. - optional Histogram pk_hist = 2; + // pk_hist is the histogram for primary key when it is the handle. + optional Histogram pk_hist = 2; - optional RowSampleCollector row_collector = 3; + optional RowSampleCollector row_collector = 3; } message AnalyzeIndexResp { - optional Histogram hist = 1; - optional CMSketch cms = 2; - optional SampleCollector collector = 3; + optional Histogram hist = 1; + optional CMSketch cms = 2; + optional SampleCollector collector = 3; } // Bucket is an element of histogram. message Bucket { - optional int64 count = 1 [(gogoproto.nullable) = false]; - optional bytes lower_bound = 2; - optional bytes upper_bound = 3; - optional int64 repeats = 4 [(gogoproto.nullable) = false]; - optional int64 ndv = 5; + optional int64 count = 1 [(gogoproto.nullable) = false]; + optional bytes lower_bound = 2; + optional bytes upper_bound = 3; + optional int64 repeats = 4 [(gogoproto.nullable) = false]; + optional int64 ndv = 5; } message Histogram { - // ndv is the number of distinct values. - optional int64 ndv = 1 [(gogoproto.nullable) = false]; + // ndv is the number of distinct values. + optional int64 ndv = 1 [(gogoproto.nullable) = false]; - // buckets represents all the buckets. - repeated Bucket buckets = 2; + // buckets represents all the buckets. + repeated Bucket buckets = 2; } // FMSketch is used to count distinct values for columns. message FMSketch { - optional uint64 mask = 1 [(gogoproto.nullable) = false]; - repeated uint64 hashset = 2; + optional uint64 mask = 1 [(gogoproto.nullable) = false]; + repeated uint64 hashset = 2; } // SampleCollector is used for collect samples and calculate the count and ndv of an column. message SampleCollector { - repeated bytes samples = 1; - optional int64 null_count = 2 [(gogoproto.nullable) = false]; - optional int64 count = 3 [(gogoproto.nullable) = false]; - optional FMSketch fm_sketch = 4; - optional CMSketch cm_sketch = 5; - optional int64 total_size = 6; + repeated bytes samples = 1; + optional int64 null_count = 2 [(gogoproto.nullable) = false]; + optional int64 count = 3 [(gogoproto.nullable) = false]; + optional FMSketch fm_sketch = 4; + optional CMSketch cm_sketch = 5; + optional int64 total_size = 6; } message RowSampleCollector { - repeated RowSample samples = 1; - repeated int64 null_counts = 2 [(gogoproto.nullable) = false]; - optional int64 count = 3 [(gogoproto.nullable) = false]; - repeated FMSketch fm_sketch = 4; - repeated int64 total_size = 5; + repeated RowSample samples = 1; + repeated int64 null_counts = 2 [(gogoproto.nullable) = false]; + optional int64 count = 3 [(gogoproto.nullable) = false]; + repeated FMSketch fm_sketch = 4; + repeated int64 total_size = 5; } message RowSample { - repeated bytes row = 1; - optional int64 weight = 2 [(gogoproto.nullable) = false]; + repeated bytes row = 1; + optional int64 weight = 2 [(gogoproto.nullable) = false]; } message CMSketchRow { - repeated uint32 counters = 1; + repeated uint32 counters = 1; } message CMSketchTopN { - optional bytes data = 1; - optional uint64 count = 2 [(gogoproto.nullable) = false]; + optional bytes data = 1; + optional uint64 count = 2 [(gogoproto.nullable) = false]; } message CMSketch { - repeated CMSketchRow rows = 1; - repeated CMSketchTopN top_n = 2; - optional uint64 default_value = 3 [(gogoproto.nullable) = false]; + repeated CMSketchRow rows = 1; + repeated CMSketchTopN top_n = 2; + optional uint64 default_value = 3 [(gogoproto.nullable) = false]; } diff --git a/proto/checksum.proto b/proto/checksum.proto index 0754689ee..bb300aa40 100644 --- a/proto/checksum.proto +++ b/proto/checksum.proto @@ -2,44 +2,43 @@ syntax = "proto2"; package tipb; -option java_multiple_files = true; -option java_package = "com.pingcap.tidb.tipb"; - import "gogoproto/gogo.proto"; import "rustproto.proto"; +option java_multiple_files = true; +option java_package = "com.pingcap.tidb.tipb"; +option (gogoproto.goproto_sizecache_all) = false; +option (gogoproto.goproto_unkeyed_all) = false; +option (gogoproto.goproto_unrecognized_all) = false; option (gogoproto.marshaler_all) = true; option (gogoproto.sizer_all) = true; option (gogoproto.unmarshaler_all) = true; -option (gogoproto.goproto_unkeyed_all) = false; -option (gogoproto.goproto_unrecognized_all) = false; -option (gogoproto.goproto_sizecache_all) = false; option (rustproto.lite_runtime_all) = true; enum ChecksumScanOn { - Table = 0; - Index = 1; + Table = 0; + Index = 1; } enum ChecksumAlgorithm { - Crc64_Xor = 0; + Crc64_Xor = 0; } message ChecksumRewriteRule { - optional bytes old_prefix = 1; - optional bytes new_prefix = 2; + optional bytes old_prefix = 1; + optional bytes new_prefix = 2; } message ChecksumRequest { - // Deprecated. Start Ts has been moved to coprocessor.Request. - optional uint64 start_ts_fallback = 1; - optional ChecksumScanOn scan_on = 2 [(gogoproto.nullable) = false]; - optional ChecksumAlgorithm algorithm = 3 [(gogoproto.nullable) = false]; - optional ChecksumRewriteRule rule = 4; + // Deprecated. Start Ts has been moved to coprocessor.Request. + optional uint64 start_ts_fallback = 1; + optional ChecksumScanOn scan_on = 2 [(gogoproto.nullable) = false]; + optional ChecksumAlgorithm algorithm = 3 [(gogoproto.nullable) = false]; + optional ChecksumRewriteRule rule = 4; } message ChecksumResponse { - optional uint64 checksum = 1 [(gogoproto.nullable) = false]; - optional uint64 total_kvs = 2 [(gogoproto.nullable) = false]; - optional uint64 total_bytes = 3 [(gogoproto.nullable) = false]; + optional uint64 checksum = 1 [(gogoproto.nullable) = false]; + optional uint64 total_kvs = 2 [(gogoproto.nullable) = false]; + optional uint64 total_bytes = 3 [(gogoproto.nullable) = false]; } diff --git a/proto/executor.proto b/proto/executor.proto index 05bf7c923..9710fbbcc 100644 --- a/proto/executor.proto +++ b/proto/executor.proto @@ -2,622 +2,620 @@ syntax = "proto2"; package tipb; -option java_multiple_files = true; -option java_package = "com.pingcap.tidb.tipb"; - import "expression.proto"; -import "schema.proto"; - import "gogoproto/gogo.proto"; import "rustproto.proto"; +import "schema.proto"; +option java_multiple_files = true; +option java_package = "com.pingcap.tidb.tipb"; +option (gogoproto.goproto_sizecache_all) = false; +option (gogoproto.goproto_unkeyed_all) = false; +option (gogoproto.goproto_unrecognized_all) = false; option (gogoproto.marshaler_all) = true; option (gogoproto.sizer_all) = true; option (gogoproto.unmarshaler_all) = true; -option (gogoproto.goproto_unkeyed_all) = false; -option (gogoproto.goproto_unrecognized_all) = false; -option (gogoproto.goproto_sizecache_all) = false; option (rustproto.lite_runtime_all) = true; enum ExecType { - TypeTableScan = 0; - TypeIndexScan = 1; - TypeSelection = 2; - TypeAggregation = 3; // TODO: Rename it to hash aggregation after support stream aggregation in TiKV. - TypeTopN = 4; - TypeLimit = 5; - TypeStreamAgg = 6; - TypeJoin = 7; - TypeKill = 8; - TypeExchangeSender = 9; - TypeExchangeReceiver = 10; - TypeProjection = 11; - TypePartitionTableScan = 12; - TypeSort = 13; - TypeWindow = 14; - TypeExpand = 15; // Expand executor is used to expand underlying data sources to feed different grouping sets. - TypeExpand2 = 16; // Expand2 executor is used to expand underlying data sources to feed different grouping sets. - TypeBroadcastQuery = 17; - TypeCTESink = 18; - TypeCTESource = 19; - TypeIndexLookUp = 20; + TypeTableScan = 0; + TypeIndexScan = 1; + TypeSelection = 2; + TypeAggregation = 3; // TODO: Rename it to hash aggregation after support stream aggregation in TiKV. + TypeTopN = 4; + TypeLimit = 5; + TypeStreamAgg = 6; + TypeJoin = 7; + TypeKill = 8; + TypeExchangeSender = 9; + TypeExchangeReceiver = 10; + TypeProjection = 11; + TypePartitionTableScan = 12; + TypeSort = 13; + TypeWindow = 14; + TypeExpand = 15; // Expand executor is used to expand underlying data sources to feed different grouping sets. + TypeExpand2 = 16; // Expand2 executor is used to expand underlying data sources to feed different grouping sets. + TypeBroadcastQuery = 17; + TypeCTESink = 18; + TypeCTESource = 19; + TypeIndexLookUp = 20; } // It represents a Executor. message Executor { - optional ExecType tp = 1 [(gogoproto.nullable) = false]; - optional TableScan tbl_scan = 2; - optional IndexScan idx_scan = 3; - optional Selection selection = 4; - optional Aggregation aggregation = 5; - optional TopN topN = 6; - optional Limit limit = 7; - optional ExchangeReceiver exchange_receiver = 8; - optional Join join = 9; - optional string executor_id = 10; - optional Kill kill = 11; - optional ExchangeSender exchange_sender = 12; - optional Projection Projection = 13; - optional PartitionTableScan partition_table_scan = 14; - optional Sort sort = 15; - optional Window window = 16; - optional uint64 fine_grained_shuffle_stream_count = 17 [(gogoproto.nullable) = false]; - optional uint64 fine_grained_shuffle_batch_size = 18 [(gogoproto.nullable) = false]; - optional Expand expand = 19; - optional Expand2 expand2= 20; - optional BroadcastQuery broadcast_query = 21; - optional CTESink cte_sink = 22; - optional CTESource cte_source = 23; - optional IndexLookUp index_lookup = 24; - // It indicates the parent index of current executor. - // Not set indicates its parent is the next executor in `DAGRequest.executors`. - optional uint32 parent_idx = 25; + optional ExecType tp = 1 [(gogoproto.nullable) = false]; + optional TableScan tbl_scan = 2; + optional IndexScan idx_scan = 3; + optional Selection selection = 4; + optional Aggregation aggregation = 5; + optional TopN topN = 6; + optional Limit limit = 7; + optional ExchangeReceiver exchange_receiver = 8; + optional Join join = 9; + optional string executor_id = 10; + optional Kill kill = 11; + optional ExchangeSender exchange_sender = 12; + optional Projection Projection = 13; + optional PartitionTableScan partition_table_scan = 14; + optional Sort sort = 15; + optional Window window = 16; + optional uint64 fine_grained_shuffle_stream_count = 17 [(gogoproto.nullable) = false]; + optional uint64 fine_grained_shuffle_batch_size = 18 [(gogoproto.nullable) = false]; + optional Expand expand = 19; + optional Expand2 expand2 = 20; + optional BroadcastQuery broadcast_query = 21; + optional CTESink cte_sink = 22; + optional CTESource cte_source = 23; + optional IndexLookUp index_lookup = 24; + // It indicates the parent index of current executor. + // Not set indicates its parent is the next executor in `DAGRequest.executors`. + optional uint32 parent_idx = 25; } enum ExchangeType { - PassThrough = 0; - Broadcast = 1; - Hash = 2; + PassThrough = 0; + Broadcast = 1; + Hash = 2; } // Data compression mode enum CompressionMode { - NONE = 0; // no compression - FAST = 1; // fast compression/decompression speed, compression ratio is lower than HC mode - HIGH_COMPRESSION = 2; // high compression (HC) ratio mode + NONE = 0; // no compression + FAST = 1; // fast compression/decompression speed, compression ratio is lower than HC mode + HIGH_COMPRESSION = 2; // high compression (HC) ratio mode } // ExchangeSender will build connection with ExchangeReceiver. message ExchangeSender { - optional ExchangeType tp = 1 [(gogoproto.nullable) = false]; - repeated bytes encoded_task_meta = 2; - repeated Expr partition_keys = 3; - optional Executor child = 4; - repeated FieldType types = 5; // partition keys' types - repeated FieldType all_field_types = 6; - optional CompressionMode compression = 7 [(gogoproto.nullable) = false]; - repeated EncodedBytesSlice upstream_cte_task_meta = 8; - repeated bool same_zone_flag = 9; + optional ExchangeType tp = 1 [(gogoproto.nullable) = false]; + repeated bytes encoded_task_meta = 2; + repeated Expr partition_keys = 3; + optional Executor child = 4; + repeated FieldType types = 5; // partition keys' types + repeated FieldType all_field_types = 6; + optional CompressionMode compression = 7 [(gogoproto.nullable) = false]; + repeated EncodedBytesSlice upstream_cte_task_meta = 8; + repeated bool same_zone_flag = 9; } message CTESink { - required uint32 cte_id = 1 [(gogoproto.nullable) = false]; - required uint32 cte_source_num = 2 [(gogoproto.nullable) = false]; - required uint32 cte_sink_num = 3 [(gogoproto.nullable) = false]; - optional Executor child = 4; - repeated FieldType field_types = 5; + required uint32 cte_id = 1 [(gogoproto.nullable) = false]; + required uint32 cte_source_num = 2 [(gogoproto.nullable) = false]; + required uint32 cte_sink_num = 3 [(gogoproto.nullable) = false]; + optional Executor child = 4; + repeated FieldType field_types = 5; } message CTESource { - required uint32 cte_id = 1 [(gogoproto.nullable) = false]; - required uint32 cte_source_num = 2 [(gogoproto.nullable) = false]; - required uint32 cte_sink_num = 3 [(gogoproto.nullable) = false]; - repeated FieldType field_types = 4; + required uint32 cte_id = 1 [(gogoproto.nullable) = false]; + required uint32 cte_source_num = 2 [(gogoproto.nullable) = false]; + required uint32 cte_sink_num = 3 [(gogoproto.nullable) = false]; + repeated FieldType field_types = 4; } message IndexLookUp { - // It represents the index columns we should use to build the row handle. - repeated uint32 index_handle_offsets = 1; - optional bool keep_order = 2; - repeated Executor children = 3; + // It represents the index columns we should use to build the row handle. + repeated uint32 index_handle_offsets = 1; + optional bool keep_order = 2; + repeated Executor children = 3; } message EncodedBytesSlice { - repeated bytes encoded_tasks = 1; + repeated bytes encoded_tasks = 1; } // ExchangeReceiver accept connection and receiver data from ExchangeSender. message ExchangeReceiver { - repeated bytes encoded_task_meta = 1; - repeated FieldType field_types = 2; - optional ExchangeType tp = 3; - repeated bytes original_cte_prdocuer_task_meta = 4; - repeated bool same_zone_flag = 5; + repeated bytes encoded_task_meta = 1; + repeated FieldType field_types = 2; + optional ExchangeType tp = 3; + repeated bytes original_cte_prdocuer_task_meta = 4; + repeated bool same_zone_flag = 5; } enum EngineType { - Local = 0; - TiKV = 1; - TiFlash = 2; + Local = 0; + TiKV = 1; + TiFlash = 2; } // Note: The name of the enum is intentionally aligned with tidb/parser/index_vector.go. enum VectorIndexKind { - INVALID_INDEX_KIND = 0; - HNSW = 1; + INVALID_INDEX_KIND = 0; + HNSW = 1; } // Note: The name of the enum is intentionally aligned with tidb/parser/index_vector.go. enum VectorDistanceMetric { - INVALID_DISTANCE_METRIC = 0; - L1 = 1; - L2 = 2; - COSINE = 3; - INNER_PRODUCT = 4; + INVALID_DISTANCE_METRIC = 0; + L1 = 1; + L2 = 2; + COSINE = 3; + INNER_PRODUCT = 4; } enum ANNQueryType { - InvalidQueryType = 0; - OrderBy = 1; - // Where = 2; // Not supported for now + InvalidQueryType = 0; + OrderBy = 1; + // Where = 2; // Not supported for now } // ANN = Approximate Nearest Neighbor. For some queries, ANN index can be used. message ANNQueryInfo { - optional ANNQueryType query_type = 1 [(gogoproto.nullable) = false]; - optional VectorDistanceMetric distance_metric = 2 [(gogoproto.nullable) = false]; - optional uint32 top_k = 3 [(gogoproto.nullable) = false]; - optional string column_name = 4 [(gogoproto.nullable) = false]; // For debug purpose only. Currently only used in explain. - // deprecated field, we use column to get the id first, and this field will not be set again. - // Retain this field to be compatible with older versions of TiDB - optional int64 deprecated_column_id = 5; + optional ANNQueryType query_type = 1 [(gogoproto.nullable) = false]; + optional VectorDistanceMetric distance_metric = 2 [(gogoproto.nullable) = false]; + optional uint32 top_k = 3 [(gogoproto.nullable) = false]; + optional string column_name = 4 [(gogoproto.nullable) = false]; // For debug purpose only. Currently only used in explain. + // deprecated field, we use column to get the id first, and this field will not be set again. + // Retain this field to be compatible with older versions of TiDB + optional int64 deprecated_column_id = 5; - optional bytes ref_vec_f32 = 6; // The reference vector to calculate distance with, with each element is a Float32 - reserved 7; // reserved for ref_vec_f64 + optional bytes ref_vec_f32 = 6; // The reference vector to calculate distance with, with each element is a Float32 + reserved 7; // reserved for ref_vec_f64 - optional int64 index_id = 8 [(gogoproto.nullable) = false]; + optional int64 index_id = 8 [(gogoproto.nullable) = false]; - optional double max_distance = 10 [(gogoproto.nullable) = false]; // Only for ANNQueryType==Where + optional double max_distance = 10 [(gogoproto.nullable) = false]; // Only for ANNQueryType==Where - optional uint32 hnsw_ef_search = 20 [(gogoproto.nullable) = false]; // Only for HNSW indexes + optional uint32 hnsw_ef_search = 20 [(gogoproto.nullable) = false]; // Only for HNSW indexes - // Persists the original vector column's type information (including nullability) - // to ensure correct data handling. This field is always populated with the column's - // schema metadata, regardless of whether enable_distance_proj is enabled. - optional ColumnInfo column = 21 [(gogoproto.nullable) = false]; + // Persists the original vector column's type information (including nullability) + // to ensure correct data handling. This field is always populated with the column's + // schema metadata, regardless of whether enable_distance_proj is enabled. + optional ColumnInfo column = 21 [(gogoproto.nullable) = false]; - // If enabled, the content of TableScan's vector output column (whose ID is column.id) will be removed and - // TableScan will read a distance column (whose id must be -2000) as replacement, TiFlash persistent layer - // does not need to really read the Vector data column when index has been built. - optional bool enable_distance_proj = 22 [(gogoproto.nullable) = false]; + // If enabled, the content of TableScan's vector output column (whose ID is column.id) will be removed and + // TableScan will read a distance column (whose id must be -2000) as replacement, TiFlash persistent layer + // does not need to really read the Vector data column when index has been built. + optional bool enable_distance_proj = 22 [(gogoproto.nullable) = false]; } message InvertedQueryInfo { - optional int64 index_id = 1 [(gogoproto.nullable) = false]; - optional int64 column_id = 2 [(gogoproto.nullable) = false]; + optional int64 index_id = 1 [(gogoproto.nullable) = false]; + optional int64 column_id = 2 [(gogoproto.nullable) = false]; } enum FTSQueryType { - FTSQueryTypeInvalid = 0; - FTSQueryTypeNoScore = 1; // Means no scoring is ever needed, encourages the engine to use a fast path. - FTSQueryTypeWithScore = 2; + FTSQueryTypeInvalid = 0; + FTSQueryTypeNoScore = 1; // Means no scoring is ever needed, encourages the engine to use a fast path. + FTSQueryTypeWithScore = 2; } message FTSQueryInfo { - optional FTSQueryType query_type = 1 [(gogoproto.nullable) = false]; + optional FTSQueryType query_type = 1 [(gogoproto.nullable) = false]; - optional int64 index_id = 2 [(gogoproto.nullable) = false]; + optional int64 index_id = 2 [(gogoproto.nullable) = false]; - // Currently only one column is supported. - repeated ColumnInfo columns = 3; - repeated string column_names = 4; // For debug purpose only. Currently only used in explain. + // Currently only one column is supported. + repeated ColumnInfo columns = 3; + repeated string column_names = 4; // For debug purpose only. Currently only used in explain. - optional string query_text = 5 [(gogoproto.nullable) = false]; - optional string query_tokenizer = 6 [(gogoproto.nullable) = false]; // Always the same as parser/model/index_full_text.go:FullTextParserType + optional string query_text = 5 [(gogoproto.nullable) = false]; + optional string query_tokenizer = 6 [(gogoproto.nullable) = false]; // Always the same as parser/model/index_full_text.go:FullTextParserType - // These fields support pushdown for order-by and limit scenarios. - optional uint32 top_k = 10; - repeated int64 sort_column_ids = 11; - repeated bool sort_column_asc = 12; + // These fields support pushdown for order-by and limit scenarios. + optional uint32 top_k = 10; + repeated int64 sort_column_ids = 11; + repeated bool sort_column_asc = 12; - // Distinguish match_word, match_expression, match_prefix, match_regexp - optional ScalarFuncSig query_func = 20 [(gogoproto.nullable) = false]; + // Distinguish match_word, match_expression, match_prefix, match_regexp + optional ScalarFuncSig query_func = 20 [(gogoproto.nullable) = false]; - // Filter pushed down to tici - repeated Expr match_expr = 21 [(gogoproto.nullable) = false]; + // Filter pushed down to tici + repeated Expr match_expr = 21 [(gogoproto.nullable) = false]; } enum ColumnarIndexType { - TypeInvalid = 0; - TypeVector = 1; - TypeInverted = 2; - TypeFulltext = 3; + TypeInvalid = 0; + TypeVector = 1; + TypeInverted = 2; + TypeFulltext = 3; } message ColumnarIndexInfo { - optional ColumnarIndexType index_type = 1 [(gogoproto.nullable) = false]; - oneof index { - ANNQueryInfo ann_query_info = 2; - InvertedQueryInfo inverted_query_info = 3; - FTSQueryInfo fts_query_info = 4; - } + optional ColumnarIndexType index_type = 1 [(gogoproto.nullable) = false]; + oneof index { + ANNQueryInfo ann_query_info = 2; + InvertedQueryInfo inverted_query_info = 3; + FTSQueryInfo fts_query_info = 4; + } } message TableScan { - optional int64 table_id = 1 [(gogoproto.nullable) = false]; - repeated ColumnInfo columns = 2; - optional bool desc = 3 [(gogoproto.nullable) = false]; - repeated int64 primary_column_ids = 4; - optional EngineType next_read_engine = 5 [(gogoproto.nullable) = false]; // which engine we should in next step, only used by tiflash - repeated KeyRange ranges = 6 [(gogoproto.nullable) = false]; // For global read in join, we must point out the key ranges when we don't have the region info. - repeated int64 primary_prefix_column_ids = 7; - optional bool keep_order = 8; - optional bool is_fast_scan = 9; // fast_scan is a feature only provided by TiFlash (but not TiKV). - repeated Expr pushed_down_filter_conditions = 10; // conditions that are pushed down to storage layer, only used by TiFlash. - repeated RuntimeFilter runtime_filter_list = 11; // only used by TiFlash - optional int32 max_wait_time_ms = 12 [(gogoproto.nullable) = false]; // only used by TiFlash - optional ANNQueryInfo deprecated_ann_query = 13; // only used by TiFlash - repeated ColumnarIndexInfo used_columnar_indexes = 14; // only used by TiFlash + optional int64 table_id = 1 [(gogoproto.nullable) = false]; + repeated ColumnInfo columns = 2; + optional bool desc = 3 [(gogoproto.nullable) = false]; + repeated int64 primary_column_ids = 4; + optional EngineType next_read_engine = 5 [(gogoproto.nullable) = false]; // which engine we should in next step, only used by tiflash + repeated KeyRange ranges = 6 [(gogoproto.nullable) = false]; // For global read in join, we must point out the key ranges when we don't have the region info. + repeated int64 primary_prefix_column_ids = 7; + optional bool keep_order = 8; + optional bool is_fast_scan = 9; // fast_scan is a feature only provided by TiFlash (but not TiKV). + repeated Expr pushed_down_filter_conditions = 10; // conditions that are pushed down to storage layer, only used by TiFlash. + repeated RuntimeFilter runtime_filter_list = 11; // only used by TiFlash + optional int32 max_wait_time_ms = 12 [(gogoproto.nullable) = false]; // only used by TiFlash + optional ANNQueryInfo deprecated_ann_query = 13; // only used by TiFlash + repeated ColumnarIndexInfo used_columnar_indexes = 14; // only used by TiFlash } message PartitionTableScan { - optional int64 table_id = 1 [(gogoproto.nullable) = false]; - repeated ColumnInfo columns = 2; - optional bool desc = 3 [(gogoproto.nullable) = false]; - repeated int64 primary_column_ids = 4; - repeated int64 primary_prefix_column_ids = 5; - repeated int64 partition_ids = 6; - optional bool is_fast_scan = 7; // fast_scan is a feature only provided by TiFlash (but not TiKV). - repeated Expr pushed_down_filter_conditions = 8; // conditions that are pushed down to storage layer, only used by TiFlash. - repeated RuntimeFilter runtime_filter_list = 9; // only used by TiFlash - optional int32 max_wait_time_ms = 10 [(gogoproto.nullable) = false]; // only used by TiFlash - optional ANNQueryInfo deprecated_ann_query = 11; // only used by TiFlash - repeated ColumnarIndexInfo used_columnar_indexes = 12; // only used by TiFlash + optional int64 table_id = 1 [(gogoproto.nullable) = false]; + repeated ColumnInfo columns = 2; + optional bool desc = 3 [(gogoproto.nullable) = false]; + repeated int64 primary_column_ids = 4; + repeated int64 primary_prefix_column_ids = 5; + repeated int64 partition_ids = 6; + optional bool is_fast_scan = 7; // fast_scan is a feature only provided by TiFlash (but not TiKV). + repeated Expr pushed_down_filter_conditions = 8; // conditions that are pushed down to storage layer, only used by TiFlash. + repeated RuntimeFilter runtime_filter_list = 9; // only used by TiFlash + optional int32 max_wait_time_ms = 10 [(gogoproto.nullable) = false]; // only used by TiFlash + optional ANNQueryInfo deprecated_ann_query = 11; // only used by TiFlash + repeated ColumnarIndexInfo used_columnar_indexes = 12; // only used by TiFlash } enum JoinType { - TypeInnerJoin = 0; - TypeLeftOuterJoin = 1; - TypeRightOuterJoin = 2; - TypeSemiJoin = 3; - TypeAntiSemiJoin = 4; - TypeLeftOuterSemiJoin = 5; - TypeAntiLeftOuterSemiJoin = 6; + TypeInnerJoin = 0; + TypeLeftOuterJoin = 1; + TypeRightOuterJoin = 2; + TypeSemiJoin = 3; + TypeAntiSemiJoin = 4; + TypeLeftOuterSemiJoin = 5; + TypeAntiLeftOuterSemiJoin = 6; } enum JoinExecType { - TypeHashJoin = 0; + TypeHashJoin = 0; } message Join { - optional JoinType join_type = 1 [(gogoproto.nullable) = false]; - optional JoinExecType join_exec_type = 2 [(gogoproto.nullable) = false]; - repeated Executor children = 3; - optional int64 inner_idx = 4 [(gogoproto.nullable) = false]; // 0 or 1 - repeated Expr left_join_keys = 5; - repeated Expr right_join_keys = 6; - // used by TiFlash join when new collation is enabled. - repeated FieldType probe_types = 7; - repeated FieldType build_types = 8; - repeated Expr left_conditions = 9; - repeated Expr right_conditions = 10; - repeated Expr other_conditions = 11; - repeated Expr other_eq_conditions_from_in = 12; - optional bool is_null_aware_semi_join = 13; - repeated RuntimeFilter runtime_filter_list = 14; // only used by TiFlash + optional JoinType join_type = 1 [(gogoproto.nullable) = false]; + optional JoinExecType join_exec_type = 2 [(gogoproto.nullable) = false]; + repeated Executor children = 3; + optional int64 inner_idx = 4 [(gogoproto.nullable) = false]; // 0 or 1 + repeated Expr left_join_keys = 5; + repeated Expr right_join_keys = 6; + // used by TiFlash join when new collation is enabled. + repeated FieldType probe_types = 7; + repeated FieldType build_types = 8; + repeated Expr left_conditions = 9; + repeated Expr right_conditions = 10; + repeated Expr other_conditions = 11; + repeated Expr other_eq_conditions_from_in = 12; + optional bool is_null_aware_semi_join = 13; + repeated RuntimeFilter runtime_filter_list = 14; // only used by TiFlash } message RuntimeFilter { - optional int32 id = 1 [(gogoproto.nullable) = false]; - repeated Expr source_expr_list = 2; - repeated Expr target_expr_list = 3; - optional string source_executor_id = 4 [(gogoproto.nullable) = false]; - optional string target_executor_id = 5 [(gogoproto.nullable) = false]; - optional RuntimeFilterType rf_type = 6 [(gogoproto.nullable) = false]; - optional RuntimeFilterMode rf_mode = 7 [(gogoproto.nullable) = false]; + optional int32 id = 1 [(gogoproto.nullable) = false]; + repeated Expr source_expr_list = 2; + repeated Expr target_expr_list = 3; + optional string source_executor_id = 4 [(gogoproto.nullable) = false]; + optional string target_executor_id = 5 [(gogoproto.nullable) = false]; + optional RuntimeFilterType rf_type = 6 [(gogoproto.nullable) = false]; + optional RuntimeFilterMode rf_mode = 7 [(gogoproto.nullable) = false]; } enum RuntimeFilterType { - IN = 0; - MIN_MAX = 1; - BLOOM_FILTER= 2; + IN = 0; + MIN_MAX = 1; + BLOOM_FILTER = 2; } enum RuntimeFilterMode { - LOCAL = 0; - GLOBAL = 1; + LOCAL = 0; + GLOBAL = 1; } message IndexScan { - optional int64 table_id = 1 [(gogoproto.nullable) = false]; - optional int64 index_id = 2 [(gogoproto.nullable) = false]; - repeated ColumnInfo columns = 3; - optional bool desc = 4 [(gogoproto.nullable) = false]; - optional bool unique = 5; // check whether it is a unique index. - repeated int64 primary_column_ids = 6; - optional FTSQueryInfo fts_query_info = 7; // only used by TiFlash + optional int64 table_id = 1 [(gogoproto.nullable) = false]; + optional int64 index_id = 2 [(gogoproto.nullable) = false]; + repeated ColumnInfo columns = 3; + optional bool desc = 4 [(gogoproto.nullable) = false]; + optional bool unique = 5; // check whether it is a unique index. + repeated int64 primary_column_ids = 6; + optional FTSQueryInfo fts_query_info = 7; // only used by TiFlash } message Selection { - // Where conditions. - repeated Expr conditions = 1; - repeated RpnExpr rpn_conditions = 2; - optional Executor child = 3; + // Where conditions. + repeated Expr conditions = 1; + repeated RpnExpr rpn_conditions = 2; + optional Executor child = 3; } message Projection { - // Projection expressions. - repeated Expr exprs = 1; - repeated RpnExpr rpn_exprs = 2; - optional Executor child = 3; + // Projection expressions. + repeated Expr exprs = 1; + repeated RpnExpr rpn_exprs = 2; + optional Executor child = 3; } enum TiFlashPreAggMode { - ForcePreAgg = 0; - Auto = 1; - ForceStreaming = 2; + ForcePreAgg = 0; + Auto = 1; + ForceStreaming = 2; } message Aggregation { - // Group by clause. - repeated Expr group_by = 1; - repeated RpnExpr rpn_group_by = 4; - // Aggregate functions. - repeated Expr agg_func = 2; - repeated RpnExpr rpn_agg_func = 5; - // If it is a stream aggregation. - optional bool streamed = 3 [(gogoproto.nullable) = false]; - optional Executor child = 6; - optional TiFlashPreAggMode pre_agg_mode = 7; + // Group by clause. + repeated Expr group_by = 1; + repeated RpnExpr rpn_group_by = 4; + // Aggregate functions. + repeated Expr agg_func = 2; + repeated RpnExpr rpn_agg_func = 5; + // If it is a stream aggregation. + optional bool streamed = 3 [(gogoproto.nullable) = false]; + optional Executor child = 6; + optional TiFlashPreAggMode pre_agg_mode = 7; } message TopN { - // Order by clause. - repeated ByItem order_by = 1; - optional uint64 limit = 2 [(gogoproto.nullable) = false]; - optional Executor child = 3; - // If partition_by is not empty, it means need to return topN of each partition. - // Generally used in sqls like `where row_number() over (partition by ... order by ...) < X` - repeated ByItem partition_by = 4; + // Order by clause. + repeated ByItem order_by = 1; + optional uint64 limit = 2 [(gogoproto.nullable) = false]; + optional Executor child = 3; + // If partition_by is not empty, it means need to return topN of each partition. + // Generally used in sqls like `where row_number() over (partition by ... order by ...) < X` + repeated ByItem partition_by = 4; } message Limit { - // Limit the result to be returned. - optional uint64 limit = 1 [(gogoproto.nullable) = false]; - optional Executor child = 2; - // If partition_by is not empty, it means need to return limitN of each partition. - // Generally used in sqls like `where row_number() over (partition by ...) < X` - repeated ByItem partition_by = 3; - repeated Expr truncate_key_expr = 4; + // Limit the result to be returned. + optional uint64 limit = 1 [(gogoproto.nullable) = false]; + optional Executor child = 2; + // If partition_by is not empty, it means need to return limitN of each partition. + // Generally used in sqls like `where row_number() over (partition by ...) < X` + repeated ByItem partition_by = 3; + repeated Expr truncate_key_expr = 4; } message Kill { - optional uint64 connID = 1 [(gogoproto.nullable) = false]; + optional uint64 connID = 1 [(gogoproto.nullable) = false]; - // Query indicates whether terminate a single query on this connection or the whole connection. - // If Query is true, terminates the statement the connection is currently executing, but leaves the connection itself intact. - // If Query is false, terminates the connection associated with the given ConnectionID, after terminating any statement the connection is executing. - // See https://dev.mysql.com/doc/refman/8.0/en/kill.html. - optional bool query = 2 [(gogoproto.nullable) = false]; + // Query indicates whether terminate a single query on this connection or the whole connection. + // If Query is true, terminates the statement the connection is currently executing, but leaves the connection itself intact. + // If Query is false, terminates the connection associated with the given ConnectionID, after terminating any statement the connection is executing. + // See https://dev.mysql.com/doc/refman/8.0/en/kill.html. + optional bool query = 2 [(gogoproto.nullable) = false]; } message ExecutorExecutionSummary { - // Total time cost in this executor. Includes self time cost and children time cost. - optional uint64 time_processed_ns = 1; + // Total time cost in this executor. Includes self time cost and children time cost. + optional uint64 time_processed_ns = 1; - // How many rows this executor produced totally. - optional uint64 num_produced_rows = 2; + // How many rows this executor produced totally. + optional uint64 num_produced_rows = 2; - // How many times executor's `next()` is called. - optional uint64 num_iterations = 3; + // How many times executor's `next()` is called. + optional uint64 num_iterations = 3; - // Coresponding executor id - optional string executor_id = 4; + // Coresponding executor id + optional string executor_id = 4; - // The execution concurrency for this executor - optional uint64 concurrency = 5; + // The execution concurrency for this executor + optional uint64 concurrency = 5; - oneof DetailInfo { - TiFlashScanContext tiflash_scan_context = 6; - } + oneof DetailInfo { + TiFlashScanContext tiflash_scan_context = 6; + } - // Serialize kvproto resource_manager.Consumption to tell tidb the consumption info. For now it's only for tiflash. - // And it's the ru consumption of one MPPTask/cop/batchCop instead of one executor. - optional bytes ru_consumption = 7; + // Serialize kvproto resource_manager.Consumption to tell tidb the consumption info. For now it's only for tiflash. + // And it's the ru consumption of one MPPTask/cop/batchCop instead of one executor. + optional bytes ru_consumption = 7; - // Only for tiflash, records the wait info. - optional TiFlashWaitSummary tiflash_wait_summary = 8; + // Only for tiflash, records the wait info. + optional TiFlashWaitSummary tiflash_wait_summary = 8; - // Only for tiflash, records network info. - optional TiFlashNetWorkSummary tiflash_network_summary = 9; + // Only for tiflash, records network info. + optional TiFlashNetWorkSummary tiflash_network_summary = 9; } message TiFlashExecutionInfo { - // The execution summary of each executor, no order limitation. - repeated ExecutorExecutionSummary execution_summaries = 1; + // The execution summary of each executor, no order limitation. + repeated ExecutorExecutionSummary execution_summaries = 1; } message TiFlashRegionNumOfInstance { - optional string instance_id = 1; - optional uint64 region_num = 2; + optional string instance_id = 1; + optional uint64 region_num = 2; } message TiFlashScanContext { - optional uint64 dmfile_scanned_packs = 1 [deprecated=true]; - optional uint64 dmfile_skipped_packs = 2 [deprecated=true]; - optional uint64 dmfile_data_scanned_rows = 3; - optional uint64 dmfile_data_skipped_rows = 4; - optional uint64 total_dmfile_rs_load_ms = 5 [deprecated=true]; - optional uint64 total_dmfile_read_ms = 6; - optional uint64 total_build_snapshot_ms = 7; - optional uint64 local_regions = 8; - optional uint64 remote_regions = 9; - optional uint64 user_read_bytes = 10; - optional uint64 total_learner_read_ms = 11; - optional uint64 disagg_read_cache_hit_bytes = 12; - optional uint64 disagg_read_cache_miss_bytes = 13; - optional uint64 total_dmfile_rs_check_ms = 14; - optional uint64 stale_read_regions = 15; - optional uint64 segments = 16; - optional uint64 read_tasks = 17; - optional uint64 delta_rows = 18; - optional uint64 delta_bytes = 19; - optional uint64 mvcc_input_rows = 20; - optional uint64 mvcc_input_bytes = 21; - optional uint64 mvcc_output_rows = 22; - optional uint64 lm_skip_rows = 23; - optional uint64 total_build_inputstream_ms = 24; - optional uint64 total_build_bitmap_ms = 25; - optional uint64 min_local_stream_ms = 26; - optional uint64 max_local_stream_ms = 27; - optional uint64 min_remote_stream_ms = 28; - optional uint64 max_remote_stream_ms = 29; - repeated TiFlashRegionNumOfInstance regions_of_instance = 30; - optional uint64 dmfile_mvcc_scanned_rows = 31; - optional uint64 dmfile_mvcc_skipped_rows = 32; - optional uint64 dmfile_lm_filter_scanned_rows = 33; - optional uint64 dmfile_lm_filter_skipped_rows = 34; - - /// vector index related fields - - optional uint64 vector_idx_load_from_s3 = 100; // Index file not available in disk - optional uint64 vector_idx_load_from_disk = 101; // Index file available in disk and not cached in memory - optional uint64 vector_idx_load_from_cache = 102; // Index file available in disk and cached in memory - optional uint64 vector_idx_load_time_ms = 103; - optional uint64 vector_idx_search_time_ms = 104; - optional uint64 vector_idx_search_visited_nodes = 105; - optional uint64 vector_idx_search_discarded_nodes = 106; - optional uint64 vector_idx_read_vec_time_ms = 107; - optional uint64 vector_idx_read_others_time_ms = 108; - - /// inverted index related fields - - optional uint32 inverted_idx_load_from_s3 = 120; - optional uint32 inverted_idx_load_from_disk = 121; - optional uint32 inverted_idx_load_from_cache = 122; - optional uint64 inverted_idx_load_time_ms = 123; - optional uint64 inverted_idx_search_time_ms = 124; - optional uint32 inverted_idx_search_skipped_packs = 125; - optional uint64 inverted_idx_indexed_rows = 126; - optional uint64 inverted_idx_search_selected_rows = 127; - - /// fulltext index related fields - - optional uint32 fts_n_from_inmemory_noindex = 150; - optional uint32 fts_n_from_tiny_index = 151; - optional uint32 fts_n_from_tiny_noindex = 152; - optional uint32 fts_n_from_dmf_index = 153; - optional uint32 fts_n_from_dmf_noindex = 154; - optional uint64 fts_rows_from_inmemory_noindex = 155; - optional uint64 fts_rows_from_tiny_index = 156; - optional uint64 fts_rows_from_tiny_noindex = 157; - optional uint64 fts_rows_from_dmf_index = 158; - optional uint64 fts_rows_from_dmf_noindex = 159; - optional uint64 fts_idx_load_total_ms = 160; - optional uint32 fts_idx_load_from_cache = 161; - optional uint32 fts_idx_load_from_column_file = 162; - optional uint32 fts_idx_load_from_stable_s3 = 163; - optional uint32 fts_idx_load_from_stable_disk = 164; - optional uint32 fts_idx_search_n = 165; - optional uint64 fts_idx_search_total_ms = 166; - optional uint64 fts_idx_dm_search_rows = 167; - optional uint64 fts_idx_dm_total_read_fts_ms = 168; - optional uint64 fts_idx_dm_total_read_others_ms = 169; - optional uint64 fts_idx_tiny_search_rows = 170; - optional uint64 fts_idx_tiny_total_read_fts_ms = 171; - optional uint64 fts_idx_tiny_total_read_others_ms = 172; - optional uint64 fts_brute_total_read_ms = 173; - optional uint64 fts_brute_total_search_ms = 174; + optional uint64 dmfile_scanned_packs = 1 [deprecated = true]; + optional uint64 dmfile_skipped_packs = 2 [deprecated = true]; + optional uint64 dmfile_data_scanned_rows = 3; + optional uint64 dmfile_data_skipped_rows = 4; + optional uint64 total_dmfile_rs_load_ms = 5 [deprecated = true]; + optional uint64 total_dmfile_read_ms = 6; + optional uint64 total_build_snapshot_ms = 7; + optional uint64 local_regions = 8; + optional uint64 remote_regions = 9; + optional uint64 user_read_bytes = 10; + optional uint64 total_learner_read_ms = 11; + optional uint64 disagg_read_cache_hit_bytes = 12; + optional uint64 disagg_read_cache_miss_bytes = 13; + optional uint64 total_dmfile_rs_check_ms = 14; + optional uint64 stale_read_regions = 15; + optional uint64 segments = 16; + optional uint64 read_tasks = 17; + optional uint64 delta_rows = 18; + optional uint64 delta_bytes = 19; + optional uint64 mvcc_input_rows = 20; + optional uint64 mvcc_input_bytes = 21; + optional uint64 mvcc_output_rows = 22; + optional uint64 lm_skip_rows = 23; + optional uint64 total_build_inputstream_ms = 24; + optional uint64 total_build_bitmap_ms = 25; + optional uint64 min_local_stream_ms = 26; + optional uint64 max_local_stream_ms = 27; + optional uint64 min_remote_stream_ms = 28; + optional uint64 max_remote_stream_ms = 29; + repeated TiFlashRegionNumOfInstance regions_of_instance = 30; + optional uint64 dmfile_mvcc_scanned_rows = 31; + optional uint64 dmfile_mvcc_skipped_rows = 32; + optional uint64 dmfile_lm_filter_scanned_rows = 33; + optional uint64 dmfile_lm_filter_skipped_rows = 34; + + /// vector index related fields + + optional uint64 vector_idx_load_from_s3 = 100; // Index file not available in disk + optional uint64 vector_idx_load_from_disk = 101; // Index file available in disk and not cached in memory + optional uint64 vector_idx_load_from_cache = 102; // Index file available in disk and cached in memory + optional uint64 vector_idx_load_time_ms = 103; + optional uint64 vector_idx_search_time_ms = 104; + optional uint64 vector_idx_search_visited_nodes = 105; + optional uint64 vector_idx_search_discarded_nodes = 106; + optional uint64 vector_idx_read_vec_time_ms = 107; + optional uint64 vector_idx_read_others_time_ms = 108; + + /// inverted index related fields + + optional uint32 inverted_idx_load_from_s3 = 120; + optional uint32 inverted_idx_load_from_disk = 121; + optional uint32 inverted_idx_load_from_cache = 122; + optional uint64 inverted_idx_load_time_ms = 123; + optional uint64 inverted_idx_search_time_ms = 124; + optional uint32 inverted_idx_search_skipped_packs = 125; + optional uint64 inverted_idx_indexed_rows = 126; + optional uint64 inverted_idx_search_selected_rows = 127; + + /// fulltext index related fields + + optional uint32 fts_n_from_inmemory_noindex = 150; + optional uint32 fts_n_from_tiny_index = 151; + optional uint32 fts_n_from_tiny_noindex = 152; + optional uint32 fts_n_from_dmf_index = 153; + optional uint32 fts_n_from_dmf_noindex = 154; + optional uint64 fts_rows_from_inmemory_noindex = 155; + optional uint64 fts_rows_from_tiny_index = 156; + optional uint64 fts_rows_from_tiny_noindex = 157; + optional uint64 fts_rows_from_dmf_index = 158; + optional uint64 fts_rows_from_dmf_noindex = 159; + optional uint64 fts_idx_load_total_ms = 160; + optional uint32 fts_idx_load_from_cache = 161; + optional uint32 fts_idx_load_from_column_file = 162; + optional uint32 fts_idx_load_from_stable_s3 = 163; + optional uint32 fts_idx_load_from_stable_disk = 164; + optional uint32 fts_idx_search_n = 165; + optional uint64 fts_idx_search_total_ms = 166; + optional uint64 fts_idx_dm_search_rows = 167; + optional uint64 fts_idx_dm_total_read_fts_ms = 168; + optional uint64 fts_idx_dm_total_read_others_ms = 169; + optional uint64 fts_idx_tiny_search_rows = 170; + optional uint64 fts_idx_tiny_total_read_fts_ms = 171; + optional uint64 fts_idx_tiny_total_read_others_ms = 172; + optional uint64 fts_brute_total_read_ms = 173; + optional uint64 fts_brute_total_search_ms = 174; } message TiFlashWaitSummary { - optional uint64 minTSO_wait_ns = 1; // Time waited for minTSO satified - optional uint64 pipeline_queue_wait_ns = 2; // Time waited in task queue. - optional uint64 pipeline_breaker_wait_ns = 3; // Time waited for dependant pipeline finished. + optional uint64 minTSO_wait_ns = 1; // Time waited for minTSO satified + optional uint64 pipeline_queue_wait_ns = 2; // Time waited in task queue. + optional uint64 pipeline_breaker_wait_ns = 3; // Time waited for dependant pipeline finished. } message TiFlashNetWorkSummary { - optional uint64 inner_zone_send_bytes = 1; - optional uint64 inner_zone_receive_bytes = 2; - optional uint64 inter_zone_send_bytes = 3; - optional uint64 inter_zone_receive_bytes = 4; + optional uint64 inner_zone_send_bytes = 1; + optional uint64 inner_zone_receive_bytes = 2; + optional uint64 inter_zone_send_bytes = 3; + optional uint64 inter_zone_receive_bytes = 4; } message Sort { - repeated ByItem byItems = 1; - optional bool isPartialSort = 2; - optional Executor child = 3; + repeated ByItem byItems = 1; + optional bool isPartialSort = 2; + optional Executor child = 3; } enum WindowBoundType { - Following = 0; - Preceding = 1; - CurrentRow = 2; + Following = 0; + Preceding = 1; + CurrentRow = 2; } // Used for range frame's comparison when finding frame's boundary enum RangeCmpDataType { - Int = 0; - Float = 1; - Decimal = 2; - DateTime = 3; - Duration = 4; + Int = 0; + Float = 1; + Decimal = 2; + DateTime = 3; + Duration = 4; } message WindowFrameBound { - optional WindowBoundType type = 1 [(gogoproto.nullable) = false]; - optional bool unbounded = 2 [(gogoproto.nullable) = false]; - optional uint64 offset = 3; // only use for `rows` frame type - repeated Expr calcFuncs = 4; // Deprecated - optional Expr frame_range = 5; // only use for `range` frame type - optional RangeCmpDataType cmp_data_type = 6; // only use for `range` frame type + optional WindowBoundType type = 1 [(gogoproto.nullable) = false]; + optional bool unbounded = 2 [(gogoproto.nullable) = false]; + optional uint64 offset = 3; // only use for `rows` frame type + repeated Expr calcFuncs = 4; // Deprecated + optional Expr frame_range = 5; // only use for `range` frame type + optional RangeCmpDataType cmp_data_type = 6; // only use for `range` frame type } enum WindowFrameType { - Rows = 0; - Ranges = 1; - Groups = 2; + Rows = 0; + Ranges = 1; + Groups = 2; } message WindowFrame { - optional WindowFrameType type = 1 [(gogoproto.nullable) = false]; - optional WindowFrameBound start = 2; - optional WindowFrameBound end = 3; + optional WindowFrameType type = 1 [(gogoproto.nullable) = false]; + optional WindowFrameBound start = 2; + optional WindowFrameBound end = 3; } message Window { - repeated Expr func_desc = 1; - repeated ByItem partition_by = 2; - repeated ByItem order_by = 3; - optional WindowFrame frame = 4; - optional Executor child = 5; + repeated Expr func_desc = 1; + repeated ByItem partition_by = 2; + repeated ByItem order_by = 3; + optional WindowFrame frame = 4; + optional Executor child = 5; } message GroupingExpr { - repeated Expr grouping_expr = 1; // for grouping expressions like: expr[a,b] + repeated Expr grouping_expr = 1; // for grouping expressions like: expr[a,b] } message GroupingSet { - repeated GroupingExpr grouping_exprs = 1; + repeated GroupingExpr grouping_exprs = 1; } // Deprecated in the nearly feature usage -message Expand{ - repeated GroupingSet grouping_sets = 1; // for grouping sets like: expr[a,b] and expr[c] - optional Executor child = 2; - optional uint64 version = 3; // expand version +message Expand { + repeated GroupingSet grouping_sets = 1; // for grouping sets like: expr[a,b] and expr[c] + optional Executor child = 2; + optional uint64 version = 3; // expand version } message ExprSlice { - repeated Expr exprs = 1; + repeated Expr exprs = 1; } -message Expand2{ - repeated ExprSlice proj_exprs = 1; // for grouping sets generated projection levels, like [a, b, c, 1#gen_col1, 2#gen_col2] - repeated string generated_output_names = 2; // for output names for generated cols like grouping_id etc, like "gen_col1", "gen_col2" here - optional Executor child = 3; +message Expand2 { + repeated ExprSlice proj_exprs = 1; // for grouping sets generated projection levels, like [a, b, c, 1#gen_col1, 2#gen_col2] + repeated string generated_output_names = 2; // for output names for generated cols like grouping_id etc, like "gen_col1", "gen_col2" here + optional Executor child = 3; } message BroadcastQuery { - optional string query = 1; + optional string query = 1; } diff --git a/proto/explain.proto b/proto/explain.proto index 0881b48c7..ddcd4cb3e 100644 --- a/proto/explain.proto +++ b/proto/explain.proto @@ -2,118 +2,117 @@ syntax = "proto3"; package tipb; -option java_multiple_files = true; -option java_package = "com.pingcap.tidb.tipb"; - import "gogoproto/gogo.proto"; import "rustproto.proto"; +option java_multiple_files = true; +option java_package = "com.pingcap.tidb.tipb"; +option (gogoproto.goproto_sizecache_all) = false; +option (gogoproto.goproto_unkeyed_all) = false; +option (gogoproto.goproto_unrecognized_all) = false; option (gogoproto.marshaler_all) = true; option (gogoproto.sizer_all) = true; option (gogoproto.unmarshaler_all) = true; -option (gogoproto.goproto_unkeyed_all) = false; -option (gogoproto.goproto_unrecognized_all) = false; -option (gogoproto.goproto_sizecache_all) = false; option (rustproto.lite_runtime_all) = true; message ExplainData { - ExplainOperator main = 1; - repeated ExplainOperator ctes = 2; - // with_runtime_stats represents if runtime stats are available. - // If not available, the act_rows, *_exec_info, memory_bytes and disk_bytes should not be used. - bool with_runtime_stats = 3; - // If discarded_due_to_too_long is true. The main and ctes fields should be empty and should not be used. - // This field can be changed to a enum or int if we need to represent more states in the future. - bool discarded_due_to_too_long = 4; - repeated ExplainOperator subqueries = 5; + ExplainOperator main = 1; + repeated ExplainOperator ctes = 2; + // with_runtime_stats represents if runtime stats are available. + // If not available, the act_rows, *_exec_info, memory_bytes and disk_bytes should not be used. + bool with_runtime_stats = 3; + // If discarded_due_to_too_long is true. The main and ctes fields should be empty and should not be used. + // This field can be changed to a enum or int if we need to represent more states in the future. + bool discarded_due_to_too_long = 4; + repeated ExplainOperator subqueries = 5; } message ExplainOperator { - string name = 1; - repeated ExplainOperator children = 2; + string name = 1; + repeated ExplainOperator children = 2; + + repeated OperatorLabel labels = 3; - repeated OperatorLabel labels = 3; + // the cost of the current operator + double cost = 4; - // the cost of the current operator - double cost = 4; + double est_rows = 5; + uint64 act_rows = 6; - double est_rows = 5; - uint64 act_rows = 6; + TaskType task_type = 7; + StoreType store_type = 8; - TaskType task_type = 7; - StoreType store_type = 8; + // The XXXReader/XXXScan/MemTable/PointGet/BatchPointGet may use this + repeated AccessObject access_objects = 9; - // The XXXReader/XXXScan/MemTable/PointGet/BatchPointGet may use this - repeated AccessObject access_objects = 9; + string operator_info = 10; + string root_basic_exec_info = 11; + repeated string root_group_exec_info = 12; + string cop_exec_info = 13; - string operator_info = 10; - string root_basic_exec_info = 11; - repeated string root_group_exec_info = 12; - string cop_exec_info = 13; + // memory_bytes and disk_bytes are expected to be displayed as "N/A" when they are -1, + // this will be consistent with the result of EXPLAIN ANALYZE. + int64 memory_bytes = 14; + int64 disk_bytes = 15; - // memory_bytes and disk_bytes are expected to be displayed as "N/A" when they are -1, - // this will be consistent with the result of EXPLAIN ANALYZE. - int64 memory_bytes = 14; - int64 disk_bytes = 15; - - string brief_name = 16; - string brief_operator_info = 17; + string brief_name = 16; + string brief_operator_info = 17; } message AccessObject { - oneof access_object { - ScanAccessObject scan_object = 1; - DynamicPartitionAccessObjects dynamic_partition_objects = 2; - string other_object = 3; - } + oneof access_object { + ScanAccessObject scan_object = 1; + DynamicPartitionAccessObjects dynamic_partition_objects = 2; + string other_object = 3; + } } message DynamicPartitionAccessObjects { - repeated DynamicPartitionAccessObject objects = 1; + repeated DynamicPartitionAccessObject objects = 1; } // DynamicPartitionAccessObject represents the partitions accessed by the children of this operator. message DynamicPartitionAccessObject { - string database = 1; - string table = 2; - bool all_partitions = 3; - repeated string partitions = 4; + string database = 1; + string table = 2; + bool all_partitions = 3; + repeated string partitions = 4; } // ScanAccessObject represents the access to a single table. It may contain multiple indexes and multiple partitions. message ScanAccessObject { - string database = 1; - string table = 2; - repeated IndexAccess indexes = 3; - repeated string partitions = 4; + string database = 1; + string table = 2; + repeated IndexAccess indexes = 3; + repeated string partitions = 4; } message IndexAccess { - string name = 1; - repeated string cols = 2; - bool is_clustered_index = 3; + string name = 1; + repeated string cols = 2; + bool is_clustered_index = 3; } enum TaskType { - unknown = 0; - root = 1; - cop = 2; - batchCop = 3; - mpp = 4; + unknown = 0; + root = 1; + cop = 2; + batchCop = 3; + mpp = 4; } enum StoreType { - unspecified = 0; - tidb = 1; - tikv = 2; - tiflash = 3; + unspecified = 0; + tidb = 1; + tikv = 2; + tiflash = 3; } enum OperatorLabel { - // empty is not expected to be used. - empty = 0; - buildSide = 1; - probeSide = 2; - seedPart = 3; - recursivePart = 4; + // empty is not expected to be used. + empty = 0; + buildSide = 1; + probeSide = 2; + seedPart = 3; + recursivePart = 4; } diff --git a/proto/expression.proto b/proto/expression.proto index ab0bcc316..1b3818b8d 100644 --- a/proto/expression.proto +++ b/proto/expression.proto @@ -2,817 +2,816 @@ syntax = "proto2"; package tipb; -option java_multiple_files = true; -option java_package = "com.pingcap.tidb.tipb"; - import "gogoproto/gogo.proto"; import "rustproto.proto"; +option java_multiple_files = true; +option java_package = "com.pingcap.tidb.tipb"; +option (gogoproto.goproto_sizecache_all) = false; +option (gogoproto.goproto_unkeyed_all) = false; +option (gogoproto.goproto_unrecognized_all) = false; option (gogoproto.marshaler_all) = true; option (gogoproto.sizer_all) = true; option (gogoproto.unmarshaler_all) = true; -option (gogoproto.goproto_unkeyed_all) = false; -option (gogoproto.goproto_unrecognized_all) = false; -option (gogoproto.goproto_sizecache_all) = false; option (rustproto.lite_runtime_all) = true; message FieldType { - optional int32 tp = 1 [(gogoproto.nullable) = false]; - optional uint32 flag = 2 [(gogoproto.nullable) = false]; - optional int32 flen = 3 [(gogoproto.nullable) = false]; - optional int32 decimal = 4 [(gogoproto.nullable) = false]; - optional int32 collate = 5 [(gogoproto.nullable) = false]; - optional string charset = 6 [(gogoproto.nullable) = false]; - repeated string elems = 7 [(gogoproto.nullable) = false]; - optional bool array = 8 [(gogoproto.nullable) = false]; + optional int32 tp = 1 [(gogoproto.nullable) = false]; + optional uint32 flag = 2 [(gogoproto.nullable) = false]; + optional int32 flen = 3 [(gogoproto.nullable) = false]; + optional int32 decimal = 4 [(gogoproto.nullable) = false]; + optional int32 collate = 5 [(gogoproto.nullable) = false]; + optional string charset = 6 [(gogoproto.nullable) = false]; + repeated string elems = 7 [(gogoproto.nullable) = false]; + optional bool array = 8 [(gogoproto.nullable) = false]; } enum ExprType { - /* Children count 0. */ - // Values are encoded bytes. - Null = 0; - Int64 = 1; - Uint64 = 2; - Float32 = 3; - Float64 = 4; - String = 5; - Bytes = 6; - - // Mysql specific types. - MysqlBit = 101; - MysqlDecimal = 102; - MysqlDuration = 103; - MysqlEnum = 104; - MysqlHex = 105; - MysqlSet = 106; - MysqlTime = 107; - MysqlJson = 108; - - TiDBVectorFloat32 = 121; - - // Encoded value list. - ValueList = 151; - - // Column reference. value is int64 column ID. - ColumnRef = 201; - - /* Mysql functions, children count is function specific. */ - // Aggregate functions. - Count = 3001; - Sum = 3002; - Avg = 3003; - Min = 3004; - Max = 3005; - First = 3006; - GroupConcat = 3007; - Agg_BitAnd = 3008; - Agg_BitOr = 3009; - Agg_BitXor = 3010; - Std = 3011; - Stddev = 3012; - StddevPop = 3013; - StddevSamp = 3014; - VarPop = 3015; - VarSamp = 3016; - Variance = 3017; - JsonArrayAgg = 3018; - JsonObjectAgg = 3019; - ApproxCountDistinct = 3020; - - // Window functions - RowNumber = 4001; - Rank = 4002; - DenseRank = 4003; - CumeDist = 4004; - PercentRank = 4005; - Ntile = 4006; - Lead = 4007; - Lag = 4008; - FirstValue = 4009; - LastValue = 4010; - NthValue = 4011; - - /* Scalar Function */ - ScalarFunc = 10000; + /* Children count 0. */ + // Values are encoded bytes. + Null = 0; + Int64 = 1; + Uint64 = 2; + Float32 = 3; + Float64 = 4; + String = 5; + Bytes = 6; + + // Mysql specific types. + MysqlBit = 101; + MysqlDecimal = 102; + MysqlDuration = 103; + MysqlEnum = 104; + MysqlHex = 105; + MysqlSet = 106; + MysqlTime = 107; + MysqlJson = 108; + + TiDBVectorFloat32 = 121; + + // Encoded value list. + ValueList = 151; + + // Column reference. value is int64 column ID. + ColumnRef = 201; + + /* Mysql functions, children count is function specific. */ + // Aggregate functions. + Count = 3001; + Sum = 3002; + Avg = 3003; + Min = 3004; + Max = 3005; + First = 3006; + GroupConcat = 3007; + Agg_BitAnd = 3008; + Agg_BitOr = 3009; + Agg_BitXor = 3010; + Std = 3011; + Stddev = 3012; + StddevPop = 3013; + StddevSamp = 3014; + VarPop = 3015; + VarSamp = 3016; + Variance = 3017; + JsonArrayAgg = 3018; + JsonObjectAgg = 3019; + ApproxCountDistinct = 3020; + + // Window functions + RowNumber = 4001; + Rank = 4002; + DenseRank = 4003; + CumeDist = 4004; + PercentRank = 4005; + Ntile = 4006; + Lead = 4007; + Lag = 4008; + FirstValue = 4009; + LastValue = 4010; + NthValue = 4011; + + /* Scalar Function */ + ScalarFunc = 10000; } enum ScalarFuncSig { - Unspecified = 0; - - /* Casting */ - CastIntAsInt = 1; - CastIntAsReal = 2; - CastIntAsString = 3; - CastIntAsDecimal = 4; - CastIntAsTime = 5; - CastIntAsDuration = 6; - CastIntAsJson = 7; - - CastRealAsInt = 10; - CastRealAsReal = 11; - CastRealAsString = 12; - CastRealAsDecimal = 13; - CastRealAsTime = 14; - CastRealAsDuration = 15; - CastRealAsJson = 16; - - CastDecimalAsInt = 20; - CastDecimalAsReal = 21; - CastDecimalAsString = 22; - CastDecimalAsDecimal = 23; - CastDecimalAsTime = 24; - CastDecimalAsDuration = 25; - CastDecimalAsJson = 26; - - CastStringAsInt = 30; - CastStringAsReal = 31; - CastStringAsString = 32; - CastStringAsDecimal = 33; - CastStringAsTime = 34; - CastStringAsDuration = 35; - CastStringAsJson = 36; - - CastTimeAsInt = 40; - CastTimeAsReal = 41; - CastTimeAsString = 42; - CastTimeAsDecimal = 43; - CastTimeAsTime = 44; - CastTimeAsDuration = 45; - CastTimeAsJson = 46; - - CastDurationAsInt = 50; - CastDurationAsReal = 51; - CastDurationAsString = 52; - CastDurationAsDecimal = 53; - CastDurationAsTime = 54; - CastDurationAsDuration = 55; - CastDurationAsJson = 56; - - CastJsonAsInt = 60; - CastJsonAsReal = 61; - CastJsonAsString = 62; - CastJsonAsDecimal = 63; - CastJsonAsTime = 64; - CastJsonAsDuration = 65; - CastJsonAsJson = 66; - - /*compare*/ - CoalesceInt = 4201; - CoalesceReal = 4202; - CoalesceDecimal = 4203; - CoalesceString = 4204; - CoalesceTime = 4205; - CoalesceDuration = 4206; - // unimplemented in tidb - CoalesceJson = 4207; - LTInt = 100; - LTReal = 101; - LTDecimal = 102; - LTString = 103; - LTTime = 104; - LTDuration = 105; - LTJson = 106; - LEInt = 110; - LEReal = 111; - LEDecimal = 112; - LEString = 113; - LETime = 114; - LEDuration = 115; - LEJson = 116; - GTInt = 120; - GTReal = 121; - GTDecimal = 122; - GTString = 123; - GTTime = 124; - GTDuration = 125; - GTJson = 126; - GreatestInt = 4215; - GreatestReal = 4216; - GreatestDecimal = 4217; - GreatestString = 4218; - GreatestTime = 4219; - LeastInt = 4220; - LeastReal = 4221; - LeastDecimal = 4222; - LeastString = 4223; - LeastTime = 4224; - IntervalInt = 4225; - IntervalReal = 4226; - GEInt = 130; - GEReal = 131; - GEDecimal = 132; - GEString = 133; - GETime = 134; - GEDuration = 135; - GEJson = 136; - EQInt = 140; - EQReal = 141; - EQDecimal = 142; - EQString = 143; - EQTime = 144; - EQDuration = 145; - EQJson = 146; - NEInt = 150; - NEReal = 151; - NEDecimal = 152; - NEString = 153; - NETime = 154; - NEDuration = 155; - NEJson = 156; - NullEQInt = 160; - NullEQReal = 161; - NullEQDecimal = 162; - NullEQString = 163; - NullEQTime = 164; - NullEQDuration = 165; - NullEQJson = 166; - - /*arithmetic*/ - PlusReal = 200; - PlusDecimal = 201; - PlusInt = 203; - MinusReal = 204; - MinusDecimal = 205; - MinusInt = 207; - MultiplyReal = 208; - MultiplyDecimal = 209; - MultiplyInt = 210; - DivideReal = 211; - DivideDecimal = 212; - IntDivideInt = 213; - IntDivideDecimal = 214; - ModReal = 215; - ModDecimal = 216; - ModInt = 217; - MultiplyIntUnsigned = 218; - PlusIntUnsignedUnsigned = 219; - PlusIntUnsignedSigned = 220; - PlusIntSignedUnsigned = 221; - PlusIntSignedSigned = 222; - ModIntUnsignedUnsigned = 223; - ModIntUnsignedSigned = 224; - ModIntSignedUnsigned = 225; - ModIntSignedSigned = 226; - MinusIntUnsignedUnsigned = 227; - MinusIntUnsignedSigned = 228; - MinusIntSignedUnsigned = 229; - MinusIntSignedSigned = 230; - MinusIntForcedUnsignedUnsigned = 231; - MinusIntForcedUnsignedSigned = 232; - MinusIntForcedSignedUnsigned = 233; - IntDivideIntUnsignedUnsigned = 234; - IntDivideIntUnsignedSigned = 235; - IntDivideIntSignedSigned = 236; - IntDivideIntSignedUnsigned = 237; - - /*math*/ - AbsInt = 2101; - AbsUInt = 2102; - AbsReal = 2103; - AbsDecimal = 2104; - CeilIntToDec = 2105; - CeilIntToInt = 2106; - CeilDecToInt = 2107; - CeilDecToDec = 2108; - CeilReal = 2109; - FloorIntToDec = 2110; - FloorIntToInt = 2111; - FloorDecToInt = 2112; - FloorDecToDec = 2113; - FloorReal = 2114; - RoundReal = 2121; - RoundInt = 2122; - RoundDec = 2123; - RoundWithFracReal = 2124; - RoundWithFracInt = 2125; - RoundWithFracDec = 2126; - Log1Arg = 2131; - Log2Args = 2132; - Log2 = 2133; - Log10 = 2134; - Rand = 2135; - RandWithSeedFirstGen = 2136; - Pow = 2137; - Conv = 2138; - CRC32 = 2139; - Sign = 2140; - Sqrt = 2141; - Acos = 2142; - Asin = 2143; - Atan1Arg = 2144; - Atan2Args = 2145; - Cos = 2146; - Cot = 2147; - Degrees = 2148; - Exp = 2149; - PI = 2150; - Radians = 2151; - Sin = 2152; - Tan = 2153; - TruncateInt = 2154; - TruncateReal = 2155; - TruncateDecimal = 2156; - TruncateUint = 2157; - - /*op*/ - LogicalAnd = 3101; - LogicalOr = 3102; - LogicalXor = 3103; - UnaryNotInt = 3104; - UnaryNotDecimal = 3105; - UnaryNotReal = 3106; - UnaryNotJSON = 3107; - UnaryMinusInt = 3108; - UnaryMinusReal = 3109; - UnaryMinusDecimal = 3110; - DecimalIsNull = 3111; - DurationIsNull = 3112; - RealIsNull = 3113; - StringIsNull = 3114; - TimeIsNull = 3115; - IntIsNull = 3116; - // unimplemented in tidb - JsonIsNull = 3117; - BitAndSig = 3118; - BitOrSig = 3119; - BitXorSig = 3120; - BitNegSig = 3121; - IntIsTrue = 3122; - RealIsTrue = 3123; - DecimalIsTrue = 3124; - IntIsFalse = 3125; - RealIsFalse = 3126; - DecimalIsFalse = 3127; - LeftShift = 3129; - RightShift = 3130; - IntIsTrueWithNull = 3142; - RealIsTrueWithNull = 3143; - DecimalIsTrueWithNull = 3144; - IntIsFalseWithNull = 3145; - RealIsFalseWithNull = 3146; - DecimalIsFalseWithNull = 3147; - - /*other*/ - BitCount = 3128; - GetParamString = 3131; - GetVar = 3132; - RowSig = 3133; - SetVar = 3134; - ValuesDecimal = 3135; - ValuesDuration = 3136; - ValuesInt = 3137; - ValuesJSON = 3138; - ValuesReal = 3139; - ValuesString = 3140; - ValuesTime = 3141; - InInt = 4001; - InReal = 4002; - InDecimal = 4003; - InString = 4004; - InTime = 4005; - InDuration = 4006; - InJson = 4007; - - /*control*/ - IfNullInt = 4101; - IfNullReal = 4102; - IfNullDecimal = 4103; - IfNullString = 4104; - IfNullTime = 4105; - IfNullDuration = 4106; - IfInt = 4107; - IfReal = 4108; - IfDecimal = 4109; - IfString = 4110; - IfTime = 4111; - IfDuration = 4112; - IfNullJson = 4113; - IfJson = 4114; - CaseWhenInt = 4208; - CaseWhenReal = 4209; - CaseWhenDecimal = 4210; - CaseWhenString = 4211; - CaseWhenTime = 4212; - CaseWhenDuration = 4213; - // unimplemented in tidb - CaseWhenJson = 4214; - - /* encryption */ - AesDecrypt = 4501; - AesEncrypt = 4502; - Compress = 4503; - MD5 = 4504; - Password = 4505; - RandomBytes = 4506; - SHA1 = 4507; - SHA2 = 4508; - Uncompress = 4509; - UncompressedLength = 4510; - AesDecryptIV = 4511; - AesEncryptIV = 4512; - Encode = 4513; - Decode = 4514; + Unspecified = 0; + + /* Casting */ + CastIntAsInt = 1; + CastIntAsReal = 2; + CastIntAsString = 3; + CastIntAsDecimal = 4; + CastIntAsTime = 5; + CastIntAsDuration = 6; + CastIntAsJson = 7; + + CastRealAsInt = 10; + CastRealAsReal = 11; + CastRealAsString = 12; + CastRealAsDecimal = 13; + CastRealAsTime = 14; + CastRealAsDuration = 15; + CastRealAsJson = 16; + + CastDecimalAsInt = 20; + CastDecimalAsReal = 21; + CastDecimalAsString = 22; + CastDecimalAsDecimal = 23; + CastDecimalAsTime = 24; + CastDecimalAsDuration = 25; + CastDecimalAsJson = 26; + + CastStringAsInt = 30; + CastStringAsReal = 31; + CastStringAsString = 32; + CastStringAsDecimal = 33; + CastStringAsTime = 34; + CastStringAsDuration = 35; + CastStringAsJson = 36; + + CastTimeAsInt = 40; + CastTimeAsReal = 41; + CastTimeAsString = 42; + CastTimeAsDecimal = 43; + CastTimeAsTime = 44; + CastTimeAsDuration = 45; + CastTimeAsJson = 46; + + CastDurationAsInt = 50; + CastDurationAsReal = 51; + CastDurationAsString = 52; + CastDurationAsDecimal = 53; + CastDurationAsTime = 54; + CastDurationAsDuration = 55; + CastDurationAsJson = 56; + + CastJsonAsInt = 60; + CastJsonAsReal = 61; + CastJsonAsString = 62; + CastJsonAsDecimal = 63; + CastJsonAsTime = 64; + CastJsonAsDuration = 65; + CastJsonAsJson = 66; + + /*compare*/ + CoalesceInt = 4201; + CoalesceReal = 4202; + CoalesceDecimal = 4203; + CoalesceString = 4204; + CoalesceTime = 4205; + CoalesceDuration = 4206; + // unimplemented in tidb + CoalesceJson = 4207; + LTInt = 100; + LTReal = 101; + LTDecimal = 102; + LTString = 103; + LTTime = 104; + LTDuration = 105; + LTJson = 106; + LEInt = 110; + LEReal = 111; + LEDecimal = 112; + LEString = 113; + LETime = 114; + LEDuration = 115; + LEJson = 116; + GTInt = 120; + GTReal = 121; + GTDecimal = 122; + GTString = 123; + GTTime = 124; + GTDuration = 125; + GTJson = 126; + GreatestInt = 4215; + GreatestReal = 4216; + GreatestDecimal = 4217; + GreatestString = 4218; + GreatestTime = 4219; + LeastInt = 4220; + LeastReal = 4221; + LeastDecimal = 4222; + LeastString = 4223; + LeastTime = 4224; + IntervalInt = 4225; + IntervalReal = 4226; + GEInt = 130; + GEReal = 131; + GEDecimal = 132; + GEString = 133; + GETime = 134; + GEDuration = 135; + GEJson = 136; + EQInt = 140; + EQReal = 141; + EQDecimal = 142; + EQString = 143; + EQTime = 144; + EQDuration = 145; + EQJson = 146; + NEInt = 150; + NEReal = 151; + NEDecimal = 152; + NEString = 153; + NETime = 154; + NEDuration = 155; + NEJson = 156; + NullEQInt = 160; + NullEQReal = 161; + NullEQDecimal = 162; + NullEQString = 163; + NullEQTime = 164; + NullEQDuration = 165; + NullEQJson = 166; + + /*arithmetic*/ + PlusReal = 200; + PlusDecimal = 201; + PlusInt = 203; + MinusReal = 204; + MinusDecimal = 205; + MinusInt = 207; + MultiplyReal = 208; + MultiplyDecimal = 209; + MultiplyInt = 210; + DivideReal = 211; + DivideDecimal = 212; + IntDivideInt = 213; + IntDivideDecimal = 214; + ModReal = 215; + ModDecimal = 216; + ModInt = 217; + MultiplyIntUnsigned = 218; + PlusIntUnsignedUnsigned = 219; + PlusIntUnsignedSigned = 220; + PlusIntSignedUnsigned = 221; + PlusIntSignedSigned = 222; + ModIntUnsignedUnsigned = 223; + ModIntUnsignedSigned = 224; + ModIntSignedUnsigned = 225; + ModIntSignedSigned = 226; + MinusIntUnsignedUnsigned = 227; + MinusIntUnsignedSigned = 228; + MinusIntSignedUnsigned = 229; + MinusIntSignedSigned = 230; + MinusIntForcedUnsignedUnsigned = 231; + MinusIntForcedUnsignedSigned = 232; + MinusIntForcedSignedUnsigned = 233; + IntDivideIntUnsignedUnsigned = 234; + IntDivideIntUnsignedSigned = 235; + IntDivideIntSignedSigned = 236; + IntDivideIntSignedUnsigned = 237; + + /*math*/ + AbsInt = 2101; + AbsUInt = 2102; + AbsReal = 2103; + AbsDecimal = 2104; + CeilIntToDec = 2105; + CeilIntToInt = 2106; + CeilDecToInt = 2107; + CeilDecToDec = 2108; + CeilReal = 2109; + FloorIntToDec = 2110; + FloorIntToInt = 2111; + FloorDecToInt = 2112; + FloorDecToDec = 2113; + FloorReal = 2114; + RoundReal = 2121; + RoundInt = 2122; + RoundDec = 2123; + RoundWithFracReal = 2124; + RoundWithFracInt = 2125; + RoundWithFracDec = 2126; + Log1Arg = 2131; + Log2Args = 2132; + Log2 = 2133; + Log10 = 2134; + Rand = 2135; + RandWithSeedFirstGen = 2136; + Pow = 2137; + Conv = 2138; + CRC32 = 2139; + Sign = 2140; + Sqrt = 2141; + Acos = 2142; + Asin = 2143; + Atan1Arg = 2144; + Atan2Args = 2145; + Cos = 2146; + Cot = 2147; + Degrees = 2148; + Exp = 2149; + PI = 2150; + Radians = 2151; + Sin = 2152; + Tan = 2153; + TruncateInt = 2154; + TruncateReal = 2155; + TruncateDecimal = 2156; + TruncateUint = 2157; + + /*op*/ + LogicalAnd = 3101; + LogicalOr = 3102; + LogicalXor = 3103; + UnaryNotInt = 3104; + UnaryNotDecimal = 3105; + UnaryNotReal = 3106; + UnaryNotJSON = 3107; + UnaryMinusInt = 3108; + UnaryMinusReal = 3109; + UnaryMinusDecimal = 3110; + DecimalIsNull = 3111; + DurationIsNull = 3112; + RealIsNull = 3113; + StringIsNull = 3114; + TimeIsNull = 3115; + IntIsNull = 3116; + // unimplemented in tidb + JsonIsNull = 3117; + BitAndSig = 3118; + BitOrSig = 3119; + BitXorSig = 3120; + BitNegSig = 3121; + IntIsTrue = 3122; + RealIsTrue = 3123; + DecimalIsTrue = 3124; + IntIsFalse = 3125; + RealIsFalse = 3126; + DecimalIsFalse = 3127; + LeftShift = 3129; + RightShift = 3130; + IntIsTrueWithNull = 3142; + RealIsTrueWithNull = 3143; + DecimalIsTrueWithNull = 3144; + IntIsFalseWithNull = 3145; + RealIsFalseWithNull = 3146; + DecimalIsFalseWithNull = 3147; + + /*other*/ + BitCount = 3128; + GetParamString = 3131; + GetVar = 3132; + RowSig = 3133; + SetVar = 3134; + ValuesDecimal = 3135; + ValuesDuration = 3136; + ValuesInt = 3137; + ValuesJSON = 3138; + ValuesReal = 3139; + ValuesString = 3140; + ValuesTime = 3141; + InInt = 4001; + InReal = 4002; + InDecimal = 4003; + InString = 4004; + InTime = 4005; + InDuration = 4006; + InJson = 4007; + + /*control*/ + IfNullInt = 4101; + IfNullReal = 4102; + IfNullDecimal = 4103; + IfNullString = 4104; + IfNullTime = 4105; + IfNullDuration = 4106; + IfInt = 4107; + IfReal = 4108; + IfDecimal = 4109; + IfString = 4110; + IfTime = 4111; + IfDuration = 4112; + IfNullJson = 4113; + IfJson = 4114; + CaseWhenInt = 4208; + CaseWhenReal = 4209; + CaseWhenDecimal = 4210; + CaseWhenString = 4211; + CaseWhenTime = 4212; + CaseWhenDuration = 4213; + // unimplemented in tidb + CaseWhenJson = 4214; + + /* encryption */ + AesDecrypt = 4501; + AesEncrypt = 4502; + Compress = 4503; + MD5 = 4504; + Password = 4505; + RandomBytes = 4506; + SHA1 = 4507; + SHA2 = 4508; + Uncompress = 4509; + UncompressedLength = 4510; + AesDecryptIV = 4511; + AesEncryptIV = 4512; + Encode = 4513; + Decode = 4514; SM3 = 4515; - /*info*/ - Database = 4521; - FoundRows = 4522; - CurrentUser = 4523; - User = 4524; - ConnectionID = 4525; - LastInsertID = 4526; - LastInsertIDWithID = 4527; - Version = 4528; - TiDBVersion = 4529; - RowCount = 4530; - - /*miscellaneous*/ - Sleep = 4551; - Lock = 4552; - ReleaseLock = 4553; - DecimalAnyValue = 4554; - DurationAnyValue = 4555; - IntAnyValue = 4556; - JSONAnyValue = 4557; - RealAnyValue = 4558; - StringAnyValue = 4559; - TimeAnyValue = 4560; - InetAton = 4561; - InetNtoa = 4562; - Inet6Aton = 4563; - Inet6Ntoa = 4564; - IsIPv4 = 4565; - IsIPv4Compat = 4566; - IsIPv4Mapped = 4567; - IsIPv6 = 4568; - UUID = 4569; - VitessHash = 4570; - IsUUID = 4571; - TiDBShard = 4572; - GroupingSig = 4573; - UUIDv4 = 4574; - UUIDv7 = 4575; - UUIDVersion = 4576; - UUIDTimestamp = 4577; - - /*like*/ - IlikeSig = 4309; - LikeSig = 4310; - RegexpSig = 4311; - RegexpUTF8Sig = 4312; - RegexpLikeSig = 4313; - RegexpLikeUTF8Sig = 4314; - RegexpInStrSig = 4315; - RegexpInStrUTF8Sig = 4316; - RegexpReplaceSig = 4317; - RegexpReplaceUTF8Sig = 4318; - RegexpSubstrSig = 4319; - RegexpSubstrUTF8Sig = 4320; - - /*json*/ - JsonExtractSig = 5001; - JsonUnquoteSig = 5002; - JsonTypeSig = 5003; - JsonSetSig = 5004; - JsonInsertSig = 5005; - JsonReplaceSig = 5006; - JsonRemoveSig = 5007; - JsonMergeSig = 5008; - JsonObjectSig = 5009; - JsonArraySig = 5010; - JsonValidJsonSig = 5011; - JsonContainsSig = 5012; - JsonArrayAppendSig = 5013; - JsonArrayInsertSig = 5014; - JsonMergePatchSig = 5015; - JsonMergePreserveSig = 5016; - JsonContainsPathSig = 5017; - JsonPrettySig = 5018; - JsonQuoteSig = 5019; - JsonSearchSig = 5020; - JsonStorageSizeSig = 5021; - JsonDepthSig = 5022; - JsonKeysSig = 5023; - JsonLengthSig = 5024; - JsonKeys2ArgsSig = 5025; - JsonValidStringSig = 5026; - JsonValidOthersSig = 5027; - JsonStorageFreeSig = 5028; - JsonMemberOfSig = 5029; - - /*vector*/ - VecAsTextSig = 5110; - VecFromTextSig = 5111; - VecDimsSig = 5112; - VecL1DistanceSig = 5113; - VecL2DistanceSig = 5114; - VecNegativeInnerProductSig = 5115; - VecCosineDistanceSig = 5116; - VecL2NormSig = 5117; - - CastStringAsVectorFloat32 = 5180; - CastVectorFloat32AsInt = 5181; - CastVectorFloat32AsReal = 5182; - CastVectorFloat32AsString = 5183; - CastVectorFloat32AsDecimal = 5184; - CastVectorFloat32AsTime = 5185; - CastVectorFloat32AsDuration = 5186; - CastVectorFloat32AsJson = 5187; - CastVectorFloat32AsVectorFloat32 = 5188; - - PlusVectorFloat32 = 5141; - MinusVectorFloat32 = 5142; - MultiplyVectorFloat32 = 5143; - VectorFloat32AnyValue = 5144; - CoalesceVectorFloat32 = 5145; - LTVectorFloat32 = 5146; - LEVectorFloat32 = 5147; - GTVectorFloat32 = 5148; - GreatestVectorFloat32 = 5149; - LeastVectorFloat32 = 5150; - GEVectorFloat32 = 5151; - EQVectorFloat32 = 5152; - NEVectorFloat32 = 5153; - NullEQVectorFloat32 = 5154; - VectorFloat32IsNull = 5155; - VectorFloat32IsTrue = 5156; - VectorFloat32IsFalse = 5157; - VectorFloat32IsTrueWithNull = 5158; - VectorFloat32IsFalseWithNull = 5159; - IfNullVectorFloat32 = 5160; - IfVectorFloat32 = 5161; - CaseWhenVectorFloat32 = 5162; - - /*fts*/ - FTSMatchWord = 5201; - FTSMatchExpression = 5202; - FTSMatchPrefix = 5203; - FTSMatchRegexp = 5204; - FTSMatchPhrase = 5205; - - /*time*/ - DateFormatSig = 6001; - DateLiteral = 6002; - DateDiff = 6003; - NullTimeDiff = 6004; - TimeStringTimeDiff = 6005; - DurationStringTimeDiff = 6006; - DurationDurationTimeDiff = 6007; - StringTimeTimeDiff = 6008; - StringDurationTimeDiff = 6009; - StringStringTimeDiff = 6010; - TimeTimeTimeDiff = 6011; - Date = 6012; - Hour = 6013; - Minute = 6014; - Second = 6015; - MicroSecond = 6016; - Month = 6017; - MonthName = 6018; - NowWithArg = 6019; - NowWithoutArg = 6020; - DayName = 6021; - DayOfMonth = 6022; - DayOfWeek = 6023; - DayOfYear = 6024; - WeekWithMode = 6025; - WeekWithoutMode = 6026; - WeekDay = 6027; - WeekOfYear = 6028; - Year = 6029; - YearWeekWithMode = 6030; - YearWeekWithoutMode = 6031; - GetFormat = 6032; - SysDateWithFsp = 6033; - SysDateWithoutFsp = 6034; - CurrentDate = 6035; - CurrentTime0Arg = 6036; - CurrentTime1Arg = 6037; - Time = 6038; - TimeLiteral = 6039; - UTCDate = 6040; - UTCTimestampWithArg = 6041; - UTCTimestampWithoutArg = 6042; - AddDatetimeAndDuration = 6043; - AddDatetimeAndString = 6044; - AddTimeDateTimeNull = 6045; - AddStringAndDuration = 6046; - AddStringAndString = 6047; - AddTimeStringNull = 6048; - AddDurationAndDuration = 6049; - AddDurationAndString = 6050; - AddTimeDurationNull = 6051; - AddDateAndDuration = 6052; - AddDateAndString = 6053; - SubDatetimeAndDuration = 6054; - SubDatetimeAndString = 6055; - SubTimeDateTimeNull = 6056; - SubStringAndDuration = 6057; - SubStringAndString = 6058; - SubTimeStringNull = 6059; - SubDurationAndDuration = 6060; - SubDurationAndString = 6061; - SubTimeDurationNull = 6062; - SubDateAndDuration = 6063; - SubDateAndString = 6064; - UnixTimestampCurrent = 6065; - UnixTimestampInt = 6066; - UnixTimestampDec = 6067; - ConvertTz = 6068; - MakeDate = 6069; - MakeTime = 6070; - PeriodAdd = 6071; - PeriodDiff = 6072; - Quarter = 6073; - SecToTime = 6074; - TimeToSec = 6075; - TimestampAdd = 6076; - ToDays = 6077; - ToSeconds = 6078; - UTCTimeWithArg = 6079; - UTCTimeWithoutArg = 6080; - Timestamp1Arg = 6081; - Timestamp2Args = 6082; - TimestampLiteral = 6083; - LastDay = 6084; - StrToDateDate = 6085; - StrToDateDatetime = 6086; - StrToDateDuration = 6087; - FromUnixTime1Arg = 6088; - FromUnixTime2Arg = 6089; - ExtractDatetime = 6090; - ExtractDuration = 6091; - AddDateStringString = 6092; - AddDateStringInt = 6093; - AddDateStringDecimal = 6094; - AddDateIntString = 6095; - AddDateIntInt = 6096; - AddDateDatetimeString = 6097; - AddDateDatetimeInt = 6098; - SubDateStringString = 6099; - SubDateStringInt = 6100; - SubDateStringDecimal = 6101; - SubDateIntString = 6102; - SubDateIntInt = 6103; - SubDateDatetimeString = 6104; - SubDateDatetimeInt = 6105; - FromDays = 6106; - TimeFormat = 6107; - TimestampDiff = 6108; - SubDateStringReal = 6109; - SubDateIntReal = 6110; - SubDateIntDecimal = 6111; - SubDateDatetimeReal = 6112; - SubDateDatetimeDecimal = 6113; - SubDateDurationString = 6114; - SubDateDurationInt = 6115; - SubDateDurationReal = 6116; - SubDateDurationDecimal = 6117; - AddDateStringReal = 6118; - AddDateIntReal = 6119; - AddDateIntDecimal = 6120; - AddDateDatetimeReal = 6121; - AddDateDatetimeDecimal = 6122; - AddDateDurationString = 6123; - AddDateDurationInt = 6124; - AddDateDurationReal = 6125; - AddDateDurationDecimal = 6126; - ExtractDatetimeFromString = 6127; - AddDateRealString = 6128; - AddDateRealInt = 6129; - AddDateRealReal = 6130; - AddDateRealDecimal = 6131; - AddDateDecimalString = 6132; - AddDateDecimalInt = 6133; - AddDateDecimalReal = 6134; - AddDateDecimalDecimal = 6135; - SubDateRealString = 6136; - SubDateRealInt = 6137; - SubDateRealReal = 6138; - SubDateRealDecimal = 6139; - SubDateDecimalString = 6140; - SubDateDecimalInt = 6141; - SubDateDecimalReal = 6142; - SubDateDecimalDecimal = 6143; - AddDateDurationStringDatetime = 6144; - AddDateDurationIntDatetime = 6145; - AddDateDurationRealDatetime = 6146; - AddDateDurationDecimalDatetime = 6147; - SubDateDurationStringDatetime = 6148; - SubDateDurationIntDatetime = 6149; - SubDateDurationRealDatetime = 6150; - SubDateDurationDecimalDatetime = 6151; - - /* String functions */ - BitLength = 7001; - Bin = 7002; - ASCII = 7003; - Char = 7004; - CharLengthUTF8 = 7005; - Concat = 7006; - ConcatWS = 7007; - Convert = 7008; - Elt = 7009; - ExportSet3Arg = 7010; - ExportSet4Arg = 7011; - ExportSet5Arg = 7012; - FieldInt = 7013; - FieldReal = 7014; - FieldString = 7015; - FindInSet = 7016; - Format = 7017; - FormatWithLocale = 7018; - FromBase64 = 7019; - HexIntArg = 7020; - HexStrArg = 7021; - InsertUTF8 = 7022; - Insert = 7023; - InstrUTF8 = 7024; - Instr = 7025; - LTrim = 7026; - LeftUTF8 = 7027; - Left = 7028; - Length = 7029; - Locate2ArgsUTF8 = 7030; - Locate3ArgsUTF8 = 7031; - Locate2Args = 7032; - Locate3Args = 7033; - Lower = 7034; - LpadUTF8 = 7035; - Lpad = 7036; - MakeSet = 7037; - OctInt = 7038; - OctString = 7039; - Ord = 7040; - Quote = 7041; - RTrim = 7042; - Repeat = 7043; - Replace = 7044; - ReverseUTF8 = 7045; - Reverse = 7046; - RightUTF8 = 7047; - Right = 7048; - RpadUTF8 = 7049; - Rpad = 7050; - Space = 7051; - Strcmp = 7052; - Substring2ArgsUTF8 = 7053; - Substring3ArgsUTF8 = 7054; - Substring2Args = 7055; - Substring3Args = 7056; - SubstringIndex = 7057; - ToBase64 = 7058; - Trim1Arg = 7059; - Trim2Args = 7060; - Trim3Args = 7061; - UnHex = 7062; - UpperUTF8 = 7063; - Upper = 7064; - CharLength = 7065; - LowerUTF8 = 7066; - GreatestDuration = 7067; - GreatestCmpStringAsTime = 7068; - LeastDuration = 7069; - LeastCmpStringAsTime = 7070; - ToBinary = 7071; - FromBinary = 7072; - GreatestCmpStringAsDate = 7073; - LeastCmpStringAsDate = 7074; - GreatestDate = 7075; //Greatest,Least functions will return Date Type value when all the parameters are Date types - LeastDate = 7076; + /*info*/ + Database = 4521; + FoundRows = 4522; + CurrentUser = 4523; + User = 4524; + ConnectionID = 4525; + LastInsertID = 4526; + LastInsertIDWithID = 4527; + Version = 4528; + TiDBVersion = 4529; + RowCount = 4530; + + /*miscellaneous*/ + Sleep = 4551; + Lock = 4552; + ReleaseLock = 4553; + DecimalAnyValue = 4554; + DurationAnyValue = 4555; + IntAnyValue = 4556; + JSONAnyValue = 4557; + RealAnyValue = 4558; + StringAnyValue = 4559; + TimeAnyValue = 4560; + InetAton = 4561; + InetNtoa = 4562; + Inet6Aton = 4563; + Inet6Ntoa = 4564; + IsIPv4 = 4565; + IsIPv4Compat = 4566; + IsIPv4Mapped = 4567; + IsIPv6 = 4568; + UUID = 4569; + VitessHash = 4570; + IsUUID = 4571; + TiDBShard = 4572; + GroupingSig = 4573; + UUIDv4 = 4574; + UUIDv7 = 4575; + UUIDVersion = 4576; + UUIDTimestamp = 4577; + + /*like*/ + IlikeSig = 4309; + LikeSig = 4310; + RegexpSig = 4311; + RegexpUTF8Sig = 4312; + RegexpLikeSig = 4313; + RegexpLikeUTF8Sig = 4314; + RegexpInStrSig = 4315; + RegexpInStrUTF8Sig = 4316; + RegexpReplaceSig = 4317; + RegexpReplaceUTF8Sig = 4318; + RegexpSubstrSig = 4319; + RegexpSubstrUTF8Sig = 4320; + + /*json*/ + JsonExtractSig = 5001; + JsonUnquoteSig = 5002; + JsonTypeSig = 5003; + JsonSetSig = 5004; + JsonInsertSig = 5005; + JsonReplaceSig = 5006; + JsonRemoveSig = 5007; + JsonMergeSig = 5008; + JsonObjectSig = 5009; + JsonArraySig = 5010; + JsonValidJsonSig = 5011; + JsonContainsSig = 5012; + JsonArrayAppendSig = 5013; + JsonArrayInsertSig = 5014; + JsonMergePatchSig = 5015; + JsonMergePreserveSig = 5016; + JsonContainsPathSig = 5017; + JsonPrettySig = 5018; + JsonQuoteSig = 5019; + JsonSearchSig = 5020; + JsonStorageSizeSig = 5021; + JsonDepthSig = 5022; + JsonKeysSig = 5023; + JsonLengthSig = 5024; + JsonKeys2ArgsSig = 5025; + JsonValidStringSig = 5026; + JsonValidOthersSig = 5027; + JsonStorageFreeSig = 5028; + JsonMemberOfSig = 5029; + + /*vector*/ + VecAsTextSig = 5110; + VecFromTextSig = 5111; + VecDimsSig = 5112; + VecL1DistanceSig = 5113; + VecL2DistanceSig = 5114; + VecNegativeInnerProductSig = 5115; + VecCosineDistanceSig = 5116; + VecL2NormSig = 5117; + + CastStringAsVectorFloat32 = 5180; + CastVectorFloat32AsInt = 5181; + CastVectorFloat32AsReal = 5182; + CastVectorFloat32AsString = 5183; + CastVectorFloat32AsDecimal = 5184; + CastVectorFloat32AsTime = 5185; + CastVectorFloat32AsDuration = 5186; + CastVectorFloat32AsJson = 5187; + CastVectorFloat32AsVectorFloat32 = 5188; + + PlusVectorFloat32 = 5141; + MinusVectorFloat32 = 5142; + MultiplyVectorFloat32 = 5143; + VectorFloat32AnyValue = 5144; + CoalesceVectorFloat32 = 5145; + LTVectorFloat32 = 5146; + LEVectorFloat32 = 5147; + GTVectorFloat32 = 5148; + GreatestVectorFloat32 = 5149; + LeastVectorFloat32 = 5150; + GEVectorFloat32 = 5151; + EQVectorFloat32 = 5152; + NEVectorFloat32 = 5153; + NullEQVectorFloat32 = 5154; + VectorFloat32IsNull = 5155; + VectorFloat32IsTrue = 5156; + VectorFloat32IsFalse = 5157; + VectorFloat32IsTrueWithNull = 5158; + VectorFloat32IsFalseWithNull = 5159; + IfNullVectorFloat32 = 5160; + IfVectorFloat32 = 5161; + CaseWhenVectorFloat32 = 5162; + + /*fts*/ + FTSMatchWord = 5201; + FTSMatchExpression = 5202; + FTSMatchPrefix = 5203; + FTSMatchRegexp = 5204; + FTSMatchPhrase = 5205; + + /*time*/ + DateFormatSig = 6001; + DateLiteral = 6002; + DateDiff = 6003; + NullTimeDiff = 6004; + TimeStringTimeDiff = 6005; + DurationStringTimeDiff = 6006; + DurationDurationTimeDiff = 6007; + StringTimeTimeDiff = 6008; + StringDurationTimeDiff = 6009; + StringStringTimeDiff = 6010; + TimeTimeTimeDiff = 6011; + Date = 6012; + Hour = 6013; + Minute = 6014; + Second = 6015; + MicroSecond = 6016; + Month = 6017; + MonthName = 6018; + NowWithArg = 6019; + NowWithoutArg = 6020; + DayName = 6021; + DayOfMonth = 6022; + DayOfWeek = 6023; + DayOfYear = 6024; + WeekWithMode = 6025; + WeekWithoutMode = 6026; + WeekDay = 6027; + WeekOfYear = 6028; + Year = 6029; + YearWeekWithMode = 6030; + YearWeekWithoutMode = 6031; + GetFormat = 6032; + SysDateWithFsp = 6033; + SysDateWithoutFsp = 6034; + CurrentDate = 6035; + CurrentTime0Arg = 6036; + CurrentTime1Arg = 6037; + Time = 6038; + TimeLiteral = 6039; + UTCDate = 6040; + UTCTimestampWithArg = 6041; + UTCTimestampWithoutArg = 6042; + AddDatetimeAndDuration = 6043; + AddDatetimeAndString = 6044; + AddTimeDateTimeNull = 6045; + AddStringAndDuration = 6046; + AddStringAndString = 6047; + AddTimeStringNull = 6048; + AddDurationAndDuration = 6049; + AddDurationAndString = 6050; + AddTimeDurationNull = 6051; + AddDateAndDuration = 6052; + AddDateAndString = 6053; + SubDatetimeAndDuration = 6054; + SubDatetimeAndString = 6055; + SubTimeDateTimeNull = 6056; + SubStringAndDuration = 6057; + SubStringAndString = 6058; + SubTimeStringNull = 6059; + SubDurationAndDuration = 6060; + SubDurationAndString = 6061; + SubTimeDurationNull = 6062; + SubDateAndDuration = 6063; + SubDateAndString = 6064; + UnixTimestampCurrent = 6065; + UnixTimestampInt = 6066; + UnixTimestampDec = 6067; + ConvertTz = 6068; + MakeDate = 6069; + MakeTime = 6070; + PeriodAdd = 6071; + PeriodDiff = 6072; + Quarter = 6073; + SecToTime = 6074; + TimeToSec = 6075; + TimestampAdd = 6076; + ToDays = 6077; + ToSeconds = 6078; + UTCTimeWithArg = 6079; + UTCTimeWithoutArg = 6080; + Timestamp1Arg = 6081; + Timestamp2Args = 6082; + TimestampLiteral = 6083; + LastDay = 6084; + StrToDateDate = 6085; + StrToDateDatetime = 6086; + StrToDateDuration = 6087; + FromUnixTime1Arg = 6088; + FromUnixTime2Arg = 6089; + ExtractDatetime = 6090; + ExtractDuration = 6091; + AddDateStringString = 6092; + AddDateStringInt = 6093; + AddDateStringDecimal = 6094; + AddDateIntString = 6095; + AddDateIntInt = 6096; + AddDateDatetimeString = 6097; + AddDateDatetimeInt = 6098; + SubDateStringString = 6099; + SubDateStringInt = 6100; + SubDateStringDecimal = 6101; + SubDateIntString = 6102; + SubDateIntInt = 6103; + SubDateDatetimeString = 6104; + SubDateDatetimeInt = 6105; + FromDays = 6106; + TimeFormat = 6107; + TimestampDiff = 6108; + SubDateStringReal = 6109; + SubDateIntReal = 6110; + SubDateIntDecimal = 6111; + SubDateDatetimeReal = 6112; + SubDateDatetimeDecimal = 6113; + SubDateDurationString = 6114; + SubDateDurationInt = 6115; + SubDateDurationReal = 6116; + SubDateDurationDecimal = 6117; + AddDateStringReal = 6118; + AddDateIntReal = 6119; + AddDateIntDecimal = 6120; + AddDateDatetimeReal = 6121; + AddDateDatetimeDecimal = 6122; + AddDateDurationString = 6123; + AddDateDurationInt = 6124; + AddDateDurationReal = 6125; + AddDateDurationDecimal = 6126; + ExtractDatetimeFromString = 6127; + AddDateRealString = 6128; + AddDateRealInt = 6129; + AddDateRealReal = 6130; + AddDateRealDecimal = 6131; + AddDateDecimalString = 6132; + AddDateDecimalInt = 6133; + AddDateDecimalReal = 6134; + AddDateDecimalDecimal = 6135; + SubDateRealString = 6136; + SubDateRealInt = 6137; + SubDateRealReal = 6138; + SubDateRealDecimal = 6139; + SubDateDecimalString = 6140; + SubDateDecimalInt = 6141; + SubDateDecimalReal = 6142; + SubDateDecimalDecimal = 6143; + AddDateDurationStringDatetime = 6144; + AddDateDurationIntDatetime = 6145; + AddDateDurationRealDatetime = 6146; + AddDateDurationDecimalDatetime = 6147; + SubDateDurationStringDatetime = 6148; + SubDateDurationIntDatetime = 6149; + SubDateDurationRealDatetime = 6150; + SubDateDurationDecimalDatetime = 6151; + + /* String functions */ + BitLength = 7001; + Bin = 7002; + ASCII = 7003; + Char = 7004; + CharLengthUTF8 = 7005; + Concat = 7006; + ConcatWS = 7007; + Convert = 7008; + Elt = 7009; + ExportSet3Arg = 7010; + ExportSet4Arg = 7011; + ExportSet5Arg = 7012; + FieldInt = 7013; + FieldReal = 7014; + FieldString = 7015; + FindInSet = 7016; + Format = 7017; + FormatWithLocale = 7018; + FromBase64 = 7019; + HexIntArg = 7020; + HexStrArg = 7021; + InsertUTF8 = 7022; + Insert = 7023; + InstrUTF8 = 7024; + Instr = 7025; + LTrim = 7026; + LeftUTF8 = 7027; + Left = 7028; + Length = 7029; + Locate2ArgsUTF8 = 7030; + Locate3ArgsUTF8 = 7031; + Locate2Args = 7032; + Locate3Args = 7033; + Lower = 7034; + LpadUTF8 = 7035; + Lpad = 7036; + MakeSet = 7037; + OctInt = 7038; + OctString = 7039; + Ord = 7040; + Quote = 7041; + RTrim = 7042; + Repeat = 7043; + Replace = 7044; + ReverseUTF8 = 7045; + Reverse = 7046; + RightUTF8 = 7047; + Right = 7048; + RpadUTF8 = 7049; + Rpad = 7050; + Space = 7051; + Strcmp = 7052; + Substring2ArgsUTF8 = 7053; + Substring3ArgsUTF8 = 7054; + Substring2Args = 7055; + Substring3Args = 7056; + SubstringIndex = 7057; + ToBase64 = 7058; + Trim1Arg = 7059; + Trim2Args = 7060; + Trim3Args = 7061; + UnHex = 7062; + UpperUTF8 = 7063; + Upper = 7064; + CharLength = 7065; + LowerUTF8 = 7066; + GreatestDuration = 7067; + GreatestCmpStringAsTime = 7068; + LeastDuration = 7069; + LeastCmpStringAsTime = 7070; + ToBinary = 7071; + FromBinary = 7072; + GreatestCmpStringAsDate = 7073; + LeastCmpStringAsDate = 7074; + GreatestDate = 7075; //Greatest,Least functions will return Date Type value when all the parameters are Date types + LeastDate = 7076; } // Evaluators should implement evaluation functions for every expression type. message Expr { - optional ExprType tp = 1 [(gogoproto.nullable) = false]; - optional bytes val = 2; - repeated Expr children = 3; - optional uint32 rpn_args_len = 6; - optional ScalarFuncSig sig = 4 [(gogoproto.nullable) = false]; - optional FieldType field_type = 5; - optional bool has_distinct = 7 [(gogoproto.nullable) = false]; - repeated ByItem order_by = 8; - optional AggFunctionMode aggFuncMode = 9; + optional ExprType tp = 1 [(gogoproto.nullable) = false]; + optional bytes val = 2; + repeated Expr children = 3; + optional uint32 rpn_args_len = 6; + optional ScalarFuncSig sig = 4 [(gogoproto.nullable) = false]; + optional FieldType field_type = 5; + optional bool has_distinct = 7 [(gogoproto.nullable) = false]; + repeated ByItem order_by = 8; + optional AggFunctionMode aggFuncMode = 9; } // Expression organized in RPN form. // https://en.wikipedia.org/wiki/Reverse_Polish_notation message RpnExpr { - // All children fields in exprs should be empty. - repeated Expr exprs = 1; + // All children fields in exprs should be empty. + repeated Expr exprs = 1; } // ByItem type for group by and order by. message ByItem { - optional Expr expr = 1; - optional RpnExpr rpn_expr = 3; - optional bool desc = 2 [(gogoproto.nullable) = false]; + optional Expr expr = 1; + optional RpnExpr rpn_expr = 3; + optional bool desc = 2 [(gogoproto.nullable) = false]; } enum AggFunctionMode { - CompleteMode = 0; - FinalMode = 1; - Partial1Mode = 2; - Partial2Mode = 3; - DedupMode = 4; + CompleteMode = 0; + FinalMode = 1; + Partial1Mode = 2; + Partial2Mode = 3; + DedupMode = 4; } diff --git a/proto/metadata.proto b/proto/metadata.proto index 94c9eb1c0..57130acdb 100644 --- a/proto/metadata.proto +++ b/proto/metadata.proto @@ -2,42 +2,41 @@ syntax = "proto2"; package tipb; -option java_multiple_files = true; -option java_package = "com.pingcap.tidb.tipb"; - import "gogoproto/gogo.proto"; import "rustproto.proto"; +option java_multiple_files = true; +option java_package = "com.pingcap.tidb.tipb"; +option (gogoproto.goproto_sizecache_all) = false; +option (gogoproto.goproto_unkeyed_all) = false; +option (gogoproto.goproto_unrecognized_all) = false; option (gogoproto.marshaler_all) = true; option (gogoproto.sizer_all) = true; option (gogoproto.unmarshaler_all) = true; -option (gogoproto.goproto_unkeyed_all) = false; -option (gogoproto.goproto_unrecognized_all) = false; -option (gogoproto.goproto_sizecache_all) = false; option (rustproto.lite_runtime_all) = true; message InUnionMetadata { - required bool in_union = 1 [(gogoproto.nullable) = false]; + required bool in_union = 1 [(gogoproto.nullable) = false]; } message CompareInMetadata { - required bool has_null = 1 [(gogoproto.nullable) = false]; - // consts represents all non-null const args in repeated Datum format. - optional bytes consts = 2; + required bool has_null = 1 [(gogoproto.nullable) = false]; + // consts represents all non-null const args in repeated Datum format. + optional bytes consts = 2; } enum GroupingMode { - ModeBitAnd = 1; // Do 'and' operation, e.g. x & y - ModeNumericCmp = 2; // Compare two number - ModeNumericSet = 3; // Find if number in the set + ModeBitAnd = 1; // Do 'and' operation, e.g. x & y + ModeNumericCmp = 2; // Compare two number + ModeNumericSet = 3; // Find if number in the set } message GroupingMark { - repeated uint64 grouping_nums = 1; + repeated uint64 grouping_nums = 1; } message GroupingFunctionMetadata { - required GroupingMode mode = 1; - // 2 dimension here, out-most dimension is for grouping(a,b) = grouping(a) << 1 + grouping(b); we should maintain a slice of grouping mark. - repeated GroupingMark grouping_marks = 2; // Contain the grouping's meta info + required GroupingMode mode = 1; + // 2 dimension here, out-most dimension is for grouping(a,b) = grouping(a) << 1 + grouping(b); we should maintain a slice of grouping mark. + repeated GroupingMark grouping_marks = 2; // Contain the grouping's meta info } diff --git a/proto/resourcetag.proto b/proto/resourcetag.proto index 76ece9654..9f51e57cc 100644 --- a/proto/resourcetag.proto +++ b/proto/resourcetag.proto @@ -2,18 +2,17 @@ syntax = "proto2"; package tipb; -option java_multiple_files = true; -option java_package = "com.pingcap.tidb.tipb"; - import "gogoproto/gogo.proto"; import "rustproto.proto"; +option java_multiple_files = true; +option java_package = "com.pingcap.tidb.tipb"; +option (gogoproto.goproto_sizecache_all) = false; +option (gogoproto.goproto_unkeyed_all) = false; +option (gogoproto.goproto_unrecognized_all) = false; option (gogoproto.marshaler_all) = true; option (gogoproto.sizer_all) = true; option (gogoproto.unmarshaler_all) = true; -option (gogoproto.goproto_unkeyed_all) = false; -option (gogoproto.goproto_unrecognized_all) = false; -option (gogoproto.goproto_sizecache_all) = false; option (rustproto.lite_runtime_all) = true; message ResourceGroupTag { diff --git a/proto/schema.proto b/proto/schema.proto index ac7a82a52..e1945c2b0 100644 --- a/proto/schema.proto +++ b/proto/schema.proto @@ -2,47 +2,46 @@ syntax = "proto2"; package tipb; -option java_multiple_files = true; -option java_package = "com.pingcap.tidb.tipb"; - import "gogoproto/gogo.proto"; import "rustproto.proto"; +option java_multiple_files = true; +option java_package = "com.pingcap.tidb.tipb"; +option (gogoproto.goproto_sizecache_all) = false; +option (gogoproto.goproto_unkeyed_all) = false; +option (gogoproto.goproto_unrecognized_all) = false; option (gogoproto.marshaler_all) = true; option (gogoproto.sizer_all) = true; option (gogoproto.unmarshaler_all) = true; -option (gogoproto.goproto_unkeyed_all) = false; -option (gogoproto.goproto_unrecognized_all) = false; -option (gogoproto.goproto_sizecache_all) = false; option (rustproto.lite_runtime_all) = true; message TableInfo { - optional int64 table_id = 1 [(gogoproto.nullable) = false]; - repeated ColumnInfo columns = 2; + optional int64 table_id = 1 [(gogoproto.nullable) = false]; + repeated ColumnInfo columns = 2; } message ColumnInfo { - optional int64 column_id = 1 [(gogoproto.nullable) = false]; - optional int32 tp = 2 [(gogoproto.nullable) = false]; // MySQL type. - optional int32 collation = 3 [(gogoproto.nullable) = false]; - optional int32 columnLen = 4 [(gogoproto.nullable) = false]; - optional int32 decimal = 5 [(gogoproto.nullable) = false]; - optional int32 flag = 6 [(gogoproto.nullable) = false]; - repeated string elems = 7; - optional bytes default_val = 8; // Encoded datum. - optional bool pk_handle = 21 [(gogoproto.nullable) = false]; // PK handle column value is row handle. - optional bool array = 22 [(gogoproto.nullable) = false]; + optional int64 column_id = 1 [(gogoproto.nullable) = false]; + optional int32 tp = 2 [(gogoproto.nullable) = false]; // MySQL type. + optional int32 collation = 3 [(gogoproto.nullable) = false]; + optional int32 columnLen = 4 [(gogoproto.nullable) = false]; + optional int32 decimal = 5 [(gogoproto.nullable) = false]; + optional int32 flag = 6 [(gogoproto.nullable) = false]; + repeated string elems = 7; + optional bytes default_val = 8; // Encoded datum. + optional bool pk_handle = 21 [(gogoproto.nullable) = false]; // PK handle column value is row handle. + optional bool array = 22 [(gogoproto.nullable) = false]; } message IndexInfo { - optional int64 table_id = 1 [(gogoproto.nullable) = false]; - optional int64 index_id = 2 [(gogoproto.nullable) = false]; - repeated ColumnInfo columns = 3; - optional bool unique = 4 [(gogoproto.nullable) = false]; + optional int64 table_id = 1 [(gogoproto.nullable) = false]; + optional int64 index_id = 2 [(gogoproto.nullable) = false]; + repeated ColumnInfo columns = 3; + optional bool unique = 4 [(gogoproto.nullable) = false]; } // KeyRange is the encoded index key range, low is closed, high is open. (low <= x < high) message KeyRange { - optional bytes low = 1; - optional bytes high = 2; + optional bytes low = 1; + optional bytes high = 2; } diff --git a/proto/select.proto b/proto/select.proto index 49629363e..1bb49bf06 100644 --- a/proto/select.proto +++ b/proto/select.proto @@ -2,213 +2,217 @@ syntax = "proto2"; package tipb; -option java_multiple_files = true; -option java_package = "com.pingcap.tidb.tipb"; - import "executor.proto"; - import "gogoproto/gogo.proto"; import "rustproto.proto"; +option java_multiple_files = true; +option java_package = "com.pingcap.tidb.tipb"; +option (gogoproto.goproto_sizecache_all) = false; +option (gogoproto.goproto_unkeyed_all) = false; +option (gogoproto.goproto_unrecognized_all) = false; option (gogoproto.marshaler_all) = true; option (gogoproto.sizer_all) = true; option (gogoproto.unmarshaler_all) = true; -option (gogoproto.goproto_unkeyed_all) = false; -option (gogoproto.goproto_unrecognized_all) = false; -option (gogoproto.goproto_sizecache_all) = false; option (rustproto.lite_runtime_all) = true; // values are all in text format. message Row { - optional bytes handle = 1; - optional bytes data = 2; + optional bytes handle = 1; + optional bytes data = 2; } message Error { - optional int32 code = 1 [(gogoproto.nullable) = false]; - optional string msg = 2 [(gogoproto.nullable) = false]; + optional int32 code = 1 [(gogoproto.nullable) = false]; + optional string msg = 2 [(gogoproto.nullable) = false]; } // It is the data of a intermidiate output channel message IntermediateOutput { - optional EncodeType encode_type = 1 [(gogoproto.nullable) = false]; - repeated Chunk chunks = 2 [(gogoproto.nullable) = false]; + optional EncodeType encode_type = 1 [(gogoproto.nullable) = false]; + repeated Chunk chunks = 2 [(gogoproto.nullable) = false]; } // Response for SelectRequest. message SelectResponse { - optional Error error = 1; - - // Result rows. - repeated Row rows = 2; - - // Use multiple chunks to reduce memory allocation and - // avoid allocating large contiguous memory. - repeated Chunk chunks = 3 [(gogoproto.nullable) = false]; - repeated Error warnings = 4; - repeated int64 output_counts = 5; - optional int64 warning_count = 6; - - // Not used any more - // optional bytes row_batch_data = 7 [(gogoproto.customtype) = "github.com/pingcap/tipb/sharedbytes.SharedBytes", (gogoproto.nullable) = false]; - - // The execution summary of each executor, in the order in request. - repeated ExecutorExecutionSummary execution_summaries = 8; - // It indicates the encode type of response. - optional EncodeType encode_type = 9 [(gogoproto.nullable) = false]; - // ndvs collects the number of distinct value information per range. It will be used to serve as execution feedback information. - // Helping us improve the table's statistics information. - repeated int64 ndvs = 10; - // It contains all the intermedidate outputs. - repeated IntermediateOutput intermediate_outputs = 11; + optional Error error = 1; + + // Result rows. + repeated Row rows = 2; + + // Use multiple chunks to reduce memory allocation and + // avoid allocating large contiguous memory. + repeated Chunk chunks = 3 [(gogoproto.nullable) = false]; + repeated Error warnings = 4; + repeated int64 output_counts = 5; + optional int64 warning_count = 6; + + // Not used any more + // optional bytes row_batch_data = 7 [(gogoproto.customtype) = "github.com/pingcap/tipb/sharedbytes.SharedBytes", (gogoproto.nullable) = false]; + + // The execution summary of each executor, in the order in request. + repeated ExecutorExecutionSummary execution_summaries = 8; + // It indicates the encode type of response. + optional EncodeType encode_type = 9 [(gogoproto.nullable) = false]; + // ndvs collects the number of distinct value information per range. It will be used to serve as execution feedback information. + // Helping us improve the table's statistics information. + repeated int64 ndvs = 10; + // It contains all the intermedidate outputs. + repeated IntermediateOutput intermediate_outputs = 11; } // Chunk contains multiple rows data and rows meta. message Chunk { - // Data for all rows in the chunk. - optional bytes rows_data = 3 [(gogoproto.customtype) = "github.com/pingcap/tipb/sharedbytes.SharedBytes", (gogoproto.nullable) = false]; - - // Meta data for every row. - repeated RowMeta rows_meta = 4 [(gogoproto.nullable) = false]; + // Data for all rows in the chunk. + optional bytes rows_data = 3 [ + (gogoproto.customtype) = "github.com/pingcap/tipb/sharedbytes.SharedBytes", + (gogoproto.nullable) = false + ]; + + // Meta data for every row. + repeated RowMeta rows_meta = 4 [(gogoproto.nullable) = false]; } // IntermediateOutputChannel is the channel description for the intermediate ouput. // The SelectResponse of a DAGRequest may output some intermediate data because not all rows can be processed in DAG. -// For example, the executor IndexLookUp scans the index records and look up the rows locally. +// For example, the executor IndexLookUp scans the index records and look up the rows locally. // If a related row of a index is not found locally, this index record should be ouput into the intermediate channel // for the further processment in the TiDB side. message IntermediateOutputChannel { - // executor_idx indicates which executor outputs this intermediate result. - required uint32 executor_idx = 1 [(gogoproto.nullable) = false]; - // It represents which columns we should output. - repeated uint32 output_offsets = 2; + // executor_idx indicates which executor outputs this intermediate result. + required uint32 executor_idx = 1 [(gogoproto.nullable) = false]; + // It represents which columns we should output. + repeated uint32 output_offsets = 2; } // RowMeta contains row handle and length of a row. message RowMeta { - optional int64 handle = 1 [(gogoproto.nullable) = false]; - optional int64 length = 2 [(gogoproto.nullable) = false]; + optional int64 handle = 1 [(gogoproto.nullable) = false]; + optional int64 length = 2 [(gogoproto.nullable) = false]; } // DAGRequest represents the request that will be handled with DAG mode. message DAGRequest { - // Transaction start timestamp. - // Deprecated. Start Ts has been moved to coprocessor.Request. - optional uint64 start_ts_fallback = 1; - - // It represents push down Executors and follows the order of depth-first search with post-order traversal. - // That is: left child first, then right child, then parent. - // For example, a DAG: - // A - // / - // B - // / \ - // C D - // / / \ - // E F G - // / - // H - // Its order should be: [H, E, C, F, G, D, B, A] - // In most cases, there is only one child for each parent, that makes executors simple array from the srouce - // to the out most executors, and the response only need to output the final rows. - // But when a executor has more than one children, for example, IndexLookUp, some intermedidate result is required to output. - // The field `intermediate_output_channels` describes it. - repeated Executor executors = 2; - - // time zone offset in seconds - optional int64 time_zone_offset = 3 [(gogoproto.nullable) = false]; - - // flags are used to store flags that change the execution mode, it contains: - // ignore_truncate = 1 - // truncate error should be ignore if set. - // truncate_as_warning = 1 << 1 - // when ignored_truncate is not set, return warning instead of error if this flag is set. - // ... - // add more when needed. - optional uint64 flags = 4 [(gogoproto.nullable) = false]; - - // It represents which columns we should output. - repeated uint32 output_offsets = 5; - - // It represents whether we collect the detailed scan counts in each range. - optional bool collect_range_counts = 6; - - // It indicates the maximum number of warning, - // which is the number of messages that SHOW WARNINGS displays. - optional uint64 max_warning_count = 7; - - // It indicates the encode type of response. - optional EncodeType encode_type = 8 [(gogoproto.nullable) = false]; - - // It indicates the sql_mode. - optional uint64 sql_mode = 9; - - // It indicates whether the sql mode is strict. - // Deprecated. Don't use. - // optional bool is_strict_sql_mode = 10; - - // supply offset is not enough since we have daylight saving time present in some regions - optional string time_zone_name = 11 [(gogoproto.nullable) = false]; - - // It represents whether or not TiKV should collect execution summaries. - // Execution summaries will be collected into `execution_summaries` field - // in the response. - optional bool collect_execution_summaries = 12; - - // Represents the maximum size of one packet, any generated string, or any parameter sent as long data. - optional uint64 max_allowed_packet = 13; - - // Represents the chunk memory layout. - optional ChunkMemoryLayout chunk_memory_layout = 14; - - // Represents whether the expression use RPN form. - optional bool is_rpn_expr = 15; - - // UserIdentity uses to do privilege check. It is only used in TiDB cluster memory table. - optional UserIdentity user = 16; - - // Represents tree struct based executors, if this field is set, should ignore the executors field, currently only used in TiFlash - optional Executor root_executor = 17; - - // Force using the encode type specified by encode_type, currently only used in TiFlash - optional bool force_encode_type = 18; - - // It indicates the number of digits by which to increase the scale of the result of division operations performed with the / operator. - optional uint32 div_precision_increment = 19; - - // It inidcates the intermdidate result channels. - repeated IntermediateOutputChannel intermediate_output_channels = 20; + // Transaction start timestamp. + // Deprecated. Start Ts has been moved to coprocessor.Request. + optional uint64 start_ts_fallback = 1; + + // It represents push down Executors and follows the order of depth-first search with post-order traversal. + // That is: left child first, then right child, then parent. + // For example, a DAG: + // A + // / + // B + // / \ + // C D + // / / \ + // E F G + // / + // H + // Its order should be: [H, E, C, F, G, D, B, A] + // In most cases, there is only one child for each parent, that makes executors simple array from the srouce + // to the out most executors, and the response only need to output the final rows. + // But when a executor has more than one children, for example, IndexLookUp, some intermedidate result is required to output. + // The field `intermediate_output_channels` describes it. + repeated Executor executors = 2; + + // time zone offset in seconds + optional int64 time_zone_offset = 3 [(gogoproto.nullable) = false]; + + // flags are used to store flags that change the execution mode, it contains: + // ignore_truncate = 1 + // truncate error should be ignore if set. + // truncate_as_warning = 1 << 1 + // when ignored_truncate is not set, return warning instead of error if this flag is set. + // ... + // add more when needed. + optional uint64 flags = 4 [(gogoproto.nullable) = false]; + + // It represents which columns we should output. + repeated uint32 output_offsets = 5; + + // It represents whether we collect the detailed scan counts in each range. + optional bool collect_range_counts = 6; + + // It indicates the maximum number of warning, + // which is the number of messages that SHOW WARNINGS displays. + optional uint64 max_warning_count = 7; + + // It indicates the encode type of response. + optional EncodeType encode_type = 8 [(gogoproto.nullable) = false]; + + // It indicates the sql_mode. + optional uint64 sql_mode = 9; + + // It indicates whether the sql mode is strict. + // Deprecated. Don't use. + // optional bool is_strict_sql_mode = 10; + + // supply offset is not enough since we have daylight saving time present in some regions + optional string time_zone_name = 11 [(gogoproto.nullable) = false]; + + // It represents whether or not TiKV should collect execution summaries. + // Execution summaries will be collected into `execution_summaries` field + // in the response. + optional bool collect_execution_summaries = 12; + + // Represents the maximum size of one packet, any generated string, or any parameter sent as long data. + optional uint64 max_allowed_packet = 13; + + // Represents the chunk memory layout. + optional ChunkMemoryLayout chunk_memory_layout = 14; + + // Represents whether the expression use RPN form. + optional bool is_rpn_expr = 15; + + // UserIdentity uses to do privilege check. It is only used in TiDB cluster memory table. + optional UserIdentity user = 16; + + // Represents tree struct based executors, if this field is set, should ignore the executors field, currently only used in TiFlash + optional Executor root_executor = 17; + + // Force using the encode type specified by encode_type, currently only used in TiFlash + optional bool force_encode_type = 18; + + // It indicates the number of digits by which to increase the scale of the result of division operations performed with the / operator. + optional uint32 div_precision_increment = 19; + + // It inidcates the intermdidate result channels. + repeated IntermediateOutputChannel intermediate_output_channels = 20; } enum EncodeType { - TypeDefault = 0; - TypeChunk = 1; - // TypeCHBlock is used by TiSpark and TiFlash, in this encode mode, TiFlash will encode the data using native ch block format - TypeCHBlock = 2; + TypeDefault = 0; + TypeChunk = 1; + // TypeCHBlock is used by TiSpark and TiFlash, in this encode mode, TiFlash will encode the data using native ch block format + TypeCHBlock = 2; } message ChunkMemoryLayout { - // Represents the endian. - optional Endian endian = 1 [(gogoproto.nullable) = false]; + // Represents the endian. + optional Endian endian = 1 [(gogoproto.nullable) = false]; } enum Endian { - LittleEndian = 0; - BigEndian = 1; + LittleEndian = 0; + BigEndian = 1; } message UserIdentity { - optional string user_name = 1 [(gogoproto.nullable) = false]; - optional string user_host = 2 [(gogoproto.nullable) = false]; + optional string user_name = 1 [(gogoproto.nullable) = false]; + optional string user_host = 2 [(gogoproto.nullable) = false]; } message StreamResponse { - optional Error error = 1; - // Data for all rows - optional bytes data = 3 [(gogoproto.customtype) = "github.com/pingcap/tipb/sharedbytes.SharedBytes", (gogoproto.nullable) = false]; - repeated Error warnings = 4; - // output row count for each executor - repeated int64 output_counts = 5; - optional int64 warning_count = 6; - repeated int64 ndvs = 7; + optional Error error = 1; + // Data for all rows + optional bytes data = 3 [ + (gogoproto.customtype) = "github.com/pingcap/tipb/sharedbytes.SharedBytes", + (gogoproto.nullable) = false + ]; + repeated Error warnings = 4; + // output row count for each executor + repeated int64 output_counts = 5; + optional int64 warning_count = 6; + repeated int64 ndvs = 7; } diff --git a/proto/tici/indexer.proto b/proto/tici/indexer.proto index 1e9d17bb3..7e67a4c8e 100644 --- a/proto/tici/indexer.proto +++ b/proto/tici/indexer.proto @@ -5,22 +5,22 @@ package tipb.tici; import "gogoproto/gogo.proto"; import "rustproto.proto"; +option (gogoproto.goproto_sizecache_all) = false; +option (gogoproto.goproto_unkeyed_all) = false; +option (gogoproto.goproto_unrecognized_all) = false; option (gogoproto.marshaler_all) = true; option (gogoproto.sizer_all) = true; option (gogoproto.unmarshaler_all) = true; -option (gogoproto.goproto_unkeyed_all) = false; -option (gogoproto.goproto_unrecognized_all) = false; -option (gogoproto.goproto_sizecache_all) = false; option (rustproto.lite_runtime_all) = true; // IndexerService provides index creation and deletion functionality service IndexerService { // CreateIndex creates a new index rpc CreateIndex(CreateIndexRequest) returns (CreateIndexResponse); - + // DropIndex removes an existing index rpc DropIndex(DropIndexRequest) returns (DropIndexResponse); - + // GetIndexProgress retrieves the current progress of an index build rpc GetIndexProgress(GetIndexProgressRequest) returns (GetIndexProgressResponse); } @@ -68,7 +68,6 @@ message DropIndexRequest { // Index ID int64 table_id = 1; string index_id = 2; - } // DropIndexResponse is a response to the index drop request @@ -169,4 +168,4 @@ message GetIndexProgressResponse { string last_upload_time = 6; // S3 path where the index is stored repeated string s3_path = 7; -} \ No newline at end of file +} diff --git a/proto/topsql_agent.proto b/proto/topsql_agent.proto index 44e4a320b..e80c06728 100644 --- a/proto/topsql_agent.proto +++ b/proto/topsql_agent.proto @@ -2,148 +2,147 @@ syntax = "proto3"; package tipb; -option java_multiple_files = true; -option java_package = "com.pingcap.tidb.tipb"; - import "gogoproto/gogo.proto"; import "rustproto.proto"; +option java_multiple_files = true; +option java_package = "com.pingcap.tidb.tipb"; +option (gogoproto.goproto_sizecache_all) = false; +option (gogoproto.goproto_unkeyed_all) = false; +option (gogoproto.goproto_unrecognized_all) = false; option (gogoproto.marshaler_all) = true; option (gogoproto.sizer_all) = true; option (gogoproto.unmarshaler_all) = true; -option (gogoproto.goproto_unkeyed_all) = false; -option (gogoproto.goproto_unrecognized_all) = false; -option (gogoproto.goproto_sizecache_all) = false; option (rustproto.lite_runtime_all) = true; // TopSQLAgent is the persistent agent service for TopSQL records service TopSQLAgent { - // ReportTopSQLRecords is called periodically (e.g. per minute) to save the in-memory TopSQL records - rpc ReportTopSQLRecords(stream TopSQLRecord) returns (EmptyResponse) {} - // ReportSQLMeta reports SQL meta to the agent. - // The agent should ensure that the SQL meta exists before sending the SQL CPU time records to the remote database. - rpc ReportSQLMeta(stream SQLMeta) returns (EmptyResponse) {} - // ReportPlanMeta reports plan meta to the agent. - // The agent should deal with plan meta similarly to SQL meta. - rpc ReportPlanMeta(stream PlanMeta) returns (EmptyResponse) {} - // ReportTopRURecords is called periodically to save the in-memory TopRU records. - rpc ReportTopRURecords(stream TopRURecord) returns (EmptyResponse) {} + // ReportTopSQLRecords is called periodically (e.g. per minute) to save the in-memory TopSQL records + rpc ReportTopSQLRecords(stream TopSQLRecord) returns (EmptyResponse) {} + // ReportSQLMeta reports SQL meta to the agent. + // The agent should ensure that the SQL meta exists before sending the SQL CPU time records to the remote database. + rpc ReportSQLMeta(stream SQLMeta) returns (EmptyResponse) {} + // ReportPlanMeta reports plan meta to the agent. + // The agent should deal with plan meta similarly to SQL meta. + rpc ReportPlanMeta(stream PlanMeta) returns (EmptyResponse) {} + // ReportTopRURecords is called periodically to save the in-memory TopRU records. + rpc ReportTopRURecords(stream TopRURecord) returns (EmptyResponse) {} } message TopSQLRecord { - bytes sql_digest = 1; - bytes plan_digest = 2; - repeated TopSQLRecordItem items = 3; - bytes keyspace_name = 4; + bytes sql_digest = 1; + bytes plan_digest = 2; + repeated TopSQLRecordItem items = 3; + bytes keyspace_name = 4; } // TopRURecord represents RU statistics for a single (user, sql_digest, plan_digest) combination. message TopRURecord { - bytes keyspace_name = 1; - string user = 2; - bytes sql_digest = 3; - bytes plan_digest = 4; - repeated TopRURecordItem items = 5; + bytes keyspace_name = 1; + string user = 2; + bytes sql_digest = 3; + bytes plan_digest = 4; + repeated TopRURecordItem items = 5; } // TopRURecordItem represents statistics within a single time bucket. message TopRURecordItem { - uint64 timestamp_sec = 1; // timestamp in second - double total_ru = 2; // cumulative RU consumption (RRU + WRU) - uint64 exec_count = 3; // execution count - uint64 exec_duration = 4; // cumulative execution time (nanoseconds) + uint64 timestamp_sec = 1; // timestamp in second + double total_ru = 2; // cumulative RU consumption (RRU + WRU) + uint64 exec_count = 3; // execution count + uint64 exec_duration = 4; // cumulative execution time (nanoseconds) } message TopSQLRecordItem { - uint64 timestamp_sec = 1; // timestamp in second - uint32 cpu_time_ms = 2; // this value can be greater than 1000 when counting concurrent running SQL queries - uint64 stmt_exec_count = 3; - map stmt_kv_exec_count = 4; // target => count - uint64 stmt_duration_sum_ns = 5; - uint64 stmt_duration_count = 6; - uint64 stmt_network_in_bytes = 7; // traffic from client - uint64 stmt_network_out_bytes = 8; // traffic to client + uint64 timestamp_sec = 1; // timestamp in second + uint32 cpu_time_ms = 2; // this value can be greater than 1000 when counting concurrent running SQL queries + uint64 stmt_exec_count = 3; + map stmt_kv_exec_count = 4; // target => count + uint64 stmt_duration_sum_ns = 5; + uint64 stmt_duration_count = 6; + uint64 stmt_network_in_bytes = 7; // traffic from client + uint64 stmt_network_out_bytes = 8; // traffic to client } message SQLMeta { - bytes sql_digest = 1; + bytes sql_digest = 1; - // SQL text with sensitive fields trimmed. - // - // Producers should limit the size to less than 4KiB. Truncation can be chosen to reduce size. - string normalized_sql = 2; + // SQL text with sensitive fields trimmed. + // + // Producers should limit the size to less than 4KiB. Truncation can be chosen to reduce size. + string normalized_sql = 2; - // If true, this sql and plan is internally generated by tidb itself, not user. - bool is_internal_sql = 3; - bytes keyspace_name = 4; + // If true, this sql and plan is internally generated by tidb itself, not user. + bool is_internal_sql = 3; + bytes keyspace_name = 4; } message PlanMeta { - bytes plan_digest = 1; - - // Plan text with sensitive fields trimmed. - // - // Producers should limit the size to less than 4KiB. Consider use `encoded_normalized_plan` if the size exceeds. - string normalized_plan = 2; - - // If `normalized_plan` is unacceptably large, set `encoded_normalized_plan` instead. - // - // The textual normalized plan is expected to get by following steps: - // 1. decode from base64 - // 2. decode from snappy - // 3. decode from github.com/pingcap/tidb/util/plancodec.DecodeNormalizedPlan - string encoded_normalized_plan = 3; - bytes keyspace_name = 4; + bytes plan_digest = 1; + + // Plan text with sensitive fields trimmed. + // + // Producers should limit the size to less than 4KiB. Consider use `encoded_normalized_plan` if the size exceeds. + string normalized_plan = 2; + + // If `normalized_plan` is unacceptably large, set `encoded_normalized_plan` instead. + // + // The textual normalized plan is expected to get by following steps: + // 1. decode from base64 + // 2. decode from snappy + // 3. decode from github.com/pingcap/tidb/util/plancodec.DecodeNormalizedPlan + string encoded_normalized_plan = 3; + bytes keyspace_name = 4; } message EmptyResponse {} // TiDB implements TopSQLPubSub service for clients to subscribe to TopSQL data. service TopSQLPubSub { - // Clients subscribe to TopSQL data through this RPC, and TiDB periodically (e.g. per minute) - // publishes TopSQL data to clients via gRPC stream. - rpc Subscribe(TopSQLSubRequest) returns (stream TopSQLSubResponse) {} + // Clients subscribe to TopSQL data through this RPC, and TiDB periodically (e.g. per minute) + // publishes TopSQL data to clients via gRPC stream. + rpc Subscribe(TopSQLSubRequest) returns (stream TopSQLSubResponse) {} } enum CollectorType { - COLLECTOR_TYPE_UNSPECIFIED = 0; // For compatibility when this variable is not present. Defaults to COLLECTOR_TYPE_TOPSQL. - COLLECTOR_TYPE_TOPSQL = 1; - COLLECTOR_TYPE_TOPRU = 2; - // future: COLLECTOR_TYPE_XXX = 3; + COLLECTOR_TYPE_UNSPECIFIED = 0; // For compatibility when this variable is not present. Defaults to COLLECTOR_TYPE_TOPSQL. + COLLECTOR_TYPE_TOPSQL = 1; + COLLECTOR_TYPE_TOPRU = 2; + // future: COLLECTOR_TYPE_XXX = 3; } enum ItemInterval { - ITEM_INTERVAL_UNSPECIFIED = 0; - ITEM_INTERVAL_15S = 15; - ITEM_INTERVAL_30S = 30; - ITEM_INTERVAL_60S = 60; + ITEM_INTERVAL_UNSPECIFIED = 0; + ITEM_INTERVAL_15S = 15; + ITEM_INTERVAL_30S = 30; + ITEM_INTERVAL_60S = 60; } // TopRU-only options message TopRUConfig { - // allowed: 15/30/60; server validates and applies default if 0 - ItemInterval item_interval_seconds = 1; + // allowed: 15/30/60; server validates and applies default if 0 + ItemInterval item_interval_seconds = 1; } message TopSQLSubRequest { - // Semantics: - // - collectors empty => default enable TOPSQL - // - collectors non-empty => authoritative (only those enabled) - // Examples: - // - TOPSQL only: collectors=[TOPSQL] (or empty) - // - TOPRU only: collectors=[TOPRU] - // - both: collectors=[TOPSQL, TOPRU] - repeated CollectorType collectors = 1; - - // Only used when COLLECTOR_TYPE_TOPRU is present in collectors. - TopRUConfig topru = 2; + // Semantics: + // - collectors empty => default enable TOPSQL + // - collectors non-empty => authoritative (only those enabled) + // Examples: + // - TOPSQL only: collectors=[TOPSQL] (or empty) + // - TOPRU only: collectors=[TOPRU] + // - both: collectors=[TOPSQL, TOPRU] + repeated CollectorType collectors = 1; + + // Only used when COLLECTOR_TYPE_TOPRU is present in collectors. + TopRUConfig topru = 2; } message TopSQLSubResponse { - oneof resp_oneof { - TopSQLRecord record = 1; - SQLMeta sql_meta = 2; - PlanMeta plan_meta = 3; - TopRURecord ru_record = 4; - } + oneof resp_oneof { + TopSQLRecord record = 1; + SQLMeta sql_meta = 2; + PlanMeta plan_meta = 3; + TopRURecord ru_record = 4; + } } diff --git a/proto/trace.proto b/proto/trace.proto index f3cd832ce..5857d5cde 100644 --- a/proto/trace.proto +++ b/proto/trace.proto @@ -2,26 +2,25 @@ syntax = "proto2"; package tipb; -option java_multiple_files = true; -option java_package = "com.pingcap.tidb.tipb"; - import "gogoproto/gogo.proto"; import "rustproto.proto"; +option java_multiple_files = true; +option java_package = "com.pingcap.tidb.tipb"; +option (gogoproto.goproto_sizecache_all) = false; +option (gogoproto.goproto_unkeyed_all) = false; +option (gogoproto.goproto_unrecognized_all) = false; option (gogoproto.marshaler_all) = true; option (gogoproto.sizer_all) = true; option (gogoproto.unmarshaler_all) = true; -option (gogoproto.goproto_unkeyed_all) = false; -option (gogoproto.goproto_unrecognized_all) = false; -option (gogoproto.goproto_sizecache_all) = false; option (rustproto.lite_runtime_all) = true; enum Event { - Unknown = 0; - TiKvCoprGetRequest = 1000; - TiKvCoprHandleRequest = 1001; - TiKvCoprScheduleTask = 1002; - TiKvCoprGetSnapshot = 1003; - TiKvCoprExecuteDagRunner = 1004; - TiKvCoprExecuteBatchDagRunner = 1005; -}; + Unknown = 0; + TiKvCoprGetRequest = 1000; + TiKvCoprHandleRequest = 1001; + TiKvCoprScheduleTask = 1002; + TiKvCoprGetSnapshot = 1003; + TiKvCoprExecuteDagRunner = 1004; + TiKvCoprExecuteBatchDagRunner = 1005; +} diff --git a/scripts/check.sh b/scripts/check.sh index ba49cda35..1d3a40f5f 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -1,5 +1,11 @@ #!/usr/bin/env bash +PROGRAM=$(basename "$0") +SCRIPTS_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +TIPB_ROOT=$(cd "${SCRIPTS_DIR}/.." && pwd) + +cd "${TIPB_ROOT}" + check_protoc_version() { version=$(protoc --version | awk '{print $NF}') major=$(echo ${version} | cut -d '.' -f 1) @@ -16,6 +22,10 @@ check_protoc_version() { return 1 } +check-protos-format() { + "${SCRIPTS_DIR}/proto_format.sh" --check +} + check-protos-compatible() { GOPATH=$(go env GOPATH) if [ -z $GOPATH ]; then @@ -86,6 +96,6 @@ check-protos-options() { return 0 } -if ! check_protoc_version || ! check-protos-compatible || ! check-protos-options; then +if ! check_protoc_version || ! check-protos-format || ! check-protos-compatible || ! check-protos-options; then exit 1 fi diff --git a/scripts/proto_format.sh b/scripts/proto_format.sh new file mode 100755 index 000000000..596db37a1 --- /dev/null +++ b/scripts/proto_format.sh @@ -0,0 +1,94 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPTS_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +TIPB_ROOT=$(cd "${SCRIPTS_DIR}/.." && pwd) + +# Keep this pinned to ensure deterministic formatting across machines/CI. +BUF_VERSION="${BUF_VERSION:-1.34.0}" +BUF_BIN="${TIPB_ROOT}/bin/buf" + +usage() { + cat <&2 + return 1 + ;; + esac + + case "${os}" in + Linux | Darwin) ;; + *) + echo "Unsupported OS for buf: ${os}" >&2 + return 1 + ;; + esac + + url="https://github.com/bufbuild/buf/releases/download/v${BUF_VERSION}/buf-${os}-${arch}" + echo "Installing buf v${BUF_VERSION} to ${BUF_BIN}" >&2 + curl -sSfL "${url}" -o "${BUF_BIN}" + chmod +x "${BUF_BIN}" +} + +run_check() { + if ! "${BUF_BIN}" format . \ + --path proto \ + --path include/rustproto.proto \ + --diff \ + --exit-code; then + echo >&2 + echo "Proto files are not formatted. Run: make proto-fmt" >&2 + return 1 + fi +} + +run_write() { + "${BUF_BIN}" format . \ + --path proto \ + --path include/rustproto.proto \ + -w +} + +main() { + if [ $# -ne 1 ]; then + usage >&2 + return 2 + fi + + cd "${TIPB_ROOT}" + install_buf + + case "$1" in + --check) run_check ;; + --write) run_write ;; + *) + usage >&2 + return 2 + ;; + esac +} + +main "$@"