Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat(proto): sheet command (#11859)

p0ny761a1ffa214a
diff --git a/frontend/src/types/proto/store/sheet.ts b/frontend/src/types/proto/store/sheet.ts
index ec756e6116..686f47b5dc 100644
--- a/frontend/src/types/proto/store/sheet.ts
+++ b/frontend/src/types/proto/store/sheet.ts
@@ -17,10 +17,22 @@ export interface SheetPayload {
| undefined;
/** The SQL dialect. */
engine: Engine;
+ /** The start and end position of each command in the sheet statement. */
+ commands: SheetCommand[];
+}
+
+export interface SheetCommand {
+ start: number;
+ end: number;
}
function createBaseSheetPayload(): SheetPayload {
- return { databaseConfig: undefined, baselineDatabaseConfig: undefined, engine: Engine.ENGINE_UNSPECIFIED };
+ return {
+ databaseConfig: undefined,
+ baselineDatabaseConfig: undefined,
+ engine: Engine.ENGINE_UNSPECIFIED,
+ commands: [],
+ };
}
export const SheetPayload = {
@@ -34,6 +46,9 @@ export const SheetPayload = {
if (message.engine !== Engine.ENGINE_UNSPECIFIED) {
writer.uint32(24).int32(engineToNumber(message.engine));
}
+ for (const v of message.commands) {
+ SheetCommand.encode(v!, writer.uint32(34).fork()).ldelim();
+ }
return writer;
},
@@ -65,6 +80,13 @@ export const SheetPayload = {
message.engine = engineFromJSON(reader.int32());
continue;
+ case 4:
+ if (tag !== 34) {
+ break;
+ }
+
+ message.commands.push(SheetCommand.decode(reader, reader.uint32()));
+ continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
@@ -81,6 +103,9 @@ export const SheetPayload = {
? DatabaseConfig.fromJSON(object.baselineDatabaseConfig)
: undefined,
engine: isSet(object.engine) ? engineFromJSON(object.engine) : Engine.ENGINE_UNSPECIFIED,
+ commands: globalThis.Array.isArray(object?.commands)
+ ? object.commands.map((e: any) => SheetCommand.fromJSON(e))
+ : [],
};
},
@@ -95,6 +120,9 @@ export const SheetPayload = {
if (message.engine !== Engine.ENGINE_UNSPECIFIED) {
obj.engine = engineToJSON(message.engine);
}
+ if (message.commands?.length) {
+ obj.commands = message.commands.map((e) => SheetCommand.toJSON(e));
+ }
return obj;
},
@@ -111,6 +139,81 @@ export const SheetPayload = {
? DatabaseConfig.fromPartial(object.baselineDatabaseConfig)
: undefined;
message.engine = object.engine ?? Engine.ENGINE_UNSPECIFIED;
+ message.commands = object.commands?.map((e) => SheetCommand.fromPartial(e)) || [];
+ return message;
+ },
+};
+
+function createBaseSheetCommand(): SheetCommand {
+ return { start: 0, end: 0 };
+}
+
+export const SheetCommand = {
+ encode(message: SheetCommand, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
+ if (message.start !== 0) {
+ writer.uint32(8).int32(message.start);
+ }
+ if (message.end !== 0) {
+ writer.uint32(16).int32(message.end);
+ }
+ return writer;
+ },
+
+ decode(input: _m0.Reader | Uint8Array, length?: number): SheetCommand {
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseSheetCommand();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1:
+ if (tag !== 8) {
+ break;
+ }
+
+ message.start = reader.int32();
+ continue;
+ case 2:
+ if (tag !== 16) {
+ break;
+ }
+
+ message.end = reader.int32();
+ continue;
+ }
+ if ((tag & 7) === 4 || tag === 0) {
+ break;
+ }
+ reader.skipType(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(object: any): SheetCommand {
+ return {
+ start: isSet(object.start) ? globalThis.Number(object.start) : 0,
+ end: isSet(object.end) ? globalThis.Number(object.end) : 0,
+ };
+ },
+
+ toJSON(message: SheetCommand): unknown {
+ const obj: any = {};
+ if (message.start !== 0) {
+ obj.start = Math.round(message.start);
+ }
+ if (message.end !== 0) {
+ obj.end = Math.round(message.end);
+ }
+ return obj;
+ },
+
+ create(base?: DeepPartial<SheetCommand>): SheetCommand {
+ return SheetCommand.fromPartial(base ?? {});
+ },
+ fromPartial(object: DeepPartial<SheetCommand>): SheetCommand {
+ const message = createBaseSheetCommand();
+ message.start = object.start ?? 0;
+ message.end = object.end ?? 0;
return message;
},
};
diff --git a/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.md
index 4b640b11cd..640c730bea 100644
--- a/proto/gen/grpc-doc/store/README.md
+++ b/proto/gen/grpc-doc/store/README.md
@@ -225,6 +225,7 @@
- [SMTPMailDeliverySetting.Encryption](#bytebase-store-SMTPMailDeliverySetting-Encryption)
- [store/sheet.proto](#store_sheet-proto)
+ - [SheetCommand](#bytebase-store-SheetCommand)
- [SheetPayload](#bytebase-store-SheetPayload)
- [store/slow_query.proto](#store_slow_query-proto)
@@ -3453,6 +3454,22 @@ We support three types of SMTP encryption: NONE, STARTTLS, and SSL/TLS.
+<a name="bytebase-store-SheetCommand"></a>
+
+### SheetCommand
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| start | [int32](#int32) | | |
+| end | [int32](#int32) | | |
+
+
+
+
+
+
<a name="bytebase-store-SheetPayload"></a>
### SheetPayload
@@ -3464,6 +3481,7 @@ We support three types of SMTP encryption: NONE, STARTTLS, and SSL/TLS.
| database_config | [DatabaseConfig](#bytebase-store-DatabaseConfig) | | The snapshot of the database config when creating the sheet, be used to compare with the baseline_database_config and apply the diff to the database. |
| baseline_database_config | [DatabaseConfig](#bytebase-store-DatabaseConfig) | | The snapshot of the baseline database config when creating the sheet. |
| engine | [Engine](#bytebase-store-Engine) | | The SQL dialect. |
+| commands | [SheetCommand](#bytebase-store-SheetCommand) | repeated | The start and end position of each command in the sheet statement. |
diff --git a/proto/gen/grpc-doc/store/index.html b/proto/gen/grpc-doc/store/index.html
index fd8ba0f166..cdf6fe0092 100644
--- a/proto/gen/grpc-doc/store/index.html
+++ b/proto/gen/grpc-doc/store/index.html
@@ -1073,6 +1073,10 @@
<a href="#store%2fsheet.proto">store/sheet.proto</a>
<ul>
+ <li>
+ <a href="#bytebase.store.SheetCommand"><span class="badge">M</span>SheetCommand</a>
+ </li>
+
<li>
<a href="#bytebase.store.SheetPayload"><span class="badge">M</span>SheetPayload</a>
</li>
@@ -8553,6 +8557,37 @@ GitOps workflow. The webhook endpoint points to the backend. </p></td>
<p></p>
+ <h3 id="bytebase.store.SheetCommand">SheetCommand</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>start</td>
+ <td><a href="#int32">int32</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ <tr>
+ <td>end</td>
+ <td><a href="#int32">int32</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
<h3 id="bytebase.store.SheetPayload">SheetPayload</h3>
<p></p>
@@ -8584,6 +8619,13 @@ GitOps workflow. The webhook endpoint points to the backend. </p></td>
<td><p>The SQL dialect. </p></td>
</tr>
+ <tr>
+ <td>commands</td>
+ <td><a href="#bytebase.store.SheetCommand">SheetCommand</a></td>
+ <td>repeated</td>
+ <td><p>The start and end position of each command in the sheet statement. </p></td>
+ </tr>
+
</tbody>
</table>
diff --git a/proto/generated-go/store/sheet.pb.go b/proto/generated-go/store/sheet.pb.go
index 40b9e5fc3c..9f64e28b08 100644
--- a/proto/generated-go/store/sheet.pb.go
+++ b/proto/generated-go/store/sheet.pb.go
@@ -31,6 +31,8 @@ type SheetPayload struct {
BaselineDatabaseConfig *DatabaseConfig `protobuf:"bytes,2,opt,name=baseline_database_config,json=baselineDatabaseConfig,proto3" json:"baseline_database_config,omitempty"`
// The SQL dialect.
Engine Engine `protobuf:"varint,3,opt,name=engine,proto3,enum=bytebase.store.Engine" json:"engine,omitempty"`
+ // The start and end position of each command in the sheet statement.
+ Commands []*SheetCommand `protobuf:"bytes,4,rep,name=commands,proto3" json:"commands,omitempty"`
}
func (x *SheetPayload) Reset() {
@@ -86,6 +88,68 @@ func (x *SheetPayload) GetEngine() Engine {
return Engine_ENGINE_UNSPECIFIED
}
+func (x *SheetPayload) GetCommands() []*SheetCommand {
+ if x != nil {
+ return x.Commands
+ }
+ return nil
+}
+
+type SheetCommand struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Start int32 `protobuf:"varint,1,opt,name=start,proto3" json:"start,omitempty"`
+ End int32 `protobuf:"varint,2,opt,name=end,proto3" json:"end,omitempty"`
+}
+
+func (x *SheetCommand) Reset() {
+ *x = SheetCommand{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_store_sheet_proto_msgTypes[1]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *SheetCommand) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*SheetCommand) ProtoMessage() {}
+
+func (x *SheetCommand) ProtoReflect() protoreflect.Message {
+ mi := &file_store_sheet_proto_msgTypes[1]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use SheetCommand.ProtoReflect.Descriptor instead.
+func (*SheetCommand) Descriptor() ([]byte, []int) {
+ return file_store_sheet_proto_rawDescGZIP(), []int{1}
+}
+
+func (x *SheetCommand) GetStart() int32 {
+ if x != nil {
+ return x.Start
+ }
+ return 0
+}
+
+func (x *SheetCommand) GetEnd() int32 {
+ if x != nil {
+ return x.End
+ }
+ return 0
+}
+
var File_store_sheet_proto protoreflect.FileDescriptor
var file_store_sheet_proto_rawDesc = []byte{
@@ -93,7 +157,7 @@ var file_store_sheet_proto_rawDesc = []byte{
0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74,
0x6f, 0x72, 0x65, 0x1a, 0x12, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f,
0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x64,
- 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe1, 0x01,
+ 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9b, 0x02,
0x0a, 0x0c, 0x53, 0x68, 0x65, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x47,
0x0a, 0x0f, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69,
0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,
@@ -108,8 +172,16 @@ var file_store_sheet_proto_rawDesc = []byte{
0x67, 0x12, 0x2e, 0x0a, 0x06, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28,
0x0e, 0x32, 0x16, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f,
0x72, 0x65, 0x2e, 0x45, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x52, 0x06, 0x65, 0x6e, 0x67, 0x69, 0x6e,
- 0x65, 0x42, 0x14, 0x5a, 0x12, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67,
- 0x6f, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+ 0x65, 0x12, 0x38, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x18, 0x04, 0x20,
+ 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73,
+ 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x53, 0x68, 0x65, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e,
+ 0x64, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x22, 0x36, 0x0a, 0x0c, 0x53,
+ 0x68, 0x65, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x73,
+ 0x74, 0x61, 0x72, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x73, 0x74, 0x61, 0x72,
+ 0x74, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03,
+ 0x65, 0x6e, 0x64, 0x42, 0x14, 0x5a, 0x12, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64,
+ 0x2d, 0x67, 0x6f, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
+ 0x33,
}
var (
@@ -124,21 +196,23 @@ func file_store_sheet_proto_rawDescGZIP() []byte {
return file_store_sheet_proto_rawDescData
}
-var file_store_sheet_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
+var file_store_sheet_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_store_sheet_proto_goTypes = []interface{}{
(*SheetPayload)(nil), // 0: bytebase.store.SheetPayload
- (*DatabaseConfig)(nil), // 1: bytebase.store.DatabaseConfig
- (Engine)(0), // 2: bytebase.store.Engine
+ (*SheetCommand)(nil), // 1: bytebase.store.SheetCommand
+ (*DatabaseConfig)(nil), // 2: bytebase.store.DatabaseConfig
+ (Engine)(0), // 3: bytebase.store.Engine
}
var file_store_sheet_proto_depIdxs = []int32{
- 1, // 0: bytebase.store.SheetPayload.database_config:type_name -> bytebase.store.DatabaseConfig
- 1, // 1: bytebase.store.SheetPayload.baseline_database_config:type_name -> bytebase.store.DatabaseConfig
- 2, // 2: bytebase.store.SheetPayload.engine:type_name -> bytebase.store.Engine
- 3, // [3:3] is the sub-list for method output_type
- 3, // [3:3] is the sub-list for method input_type
- 3, // [3:3] is the sub-list for extension type_name
- 3, // [3:3] is the sub-list for extension extendee
- 0, // [0:3] is the sub-list for field type_name
+ 2, // 0: bytebase.store.SheetPayload.database_config:type_name -> bytebase.store.DatabaseConfig
+ 2, // 1: bytebase.store.SheetPayload.baseline_database_config:type_name -> bytebase.store.DatabaseConfig
+ 3, // 2: bytebase.store.SheetPayload.engine:type_name -> bytebase.store.Engine
+ 1, // 3: bytebase.store.SheetPayload.commands:type_name -> bytebase.store.SheetCommand
+ 4, // [4:4] is the sub-list for method output_type
+ 4, // [4:4] is the sub-list for method input_type
+ 4, // [4:4] is the sub-list for extension type_name
+ 4, // [4:4] is the sub-list for extension extendee
+ 0, // [0:4] is the sub-list for field type_name
}
func init() { file_store_sheet_proto_init() }
@@ -161,6 +235,18 @@ func file_store_sheet_proto_init() {
return nil
}
}
+ file_store_sheet_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*SheetCommand); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
}
type x struct{}
out := protoimpl.TypeBuilder{
@@ -168,7 +254,7 @@ func file_store_sheet_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_store_sheet_proto_rawDesc,
NumEnums: 0,
- NumMessages: 1,
+ NumMessages: 2,
NumExtensions: 0,
NumServices: 0,
},
diff --git a/proto/store/sheet.proto b/proto/store/sheet.proto
index b6fa2a3d43..3232b02f61 100644
--- a/proto/store/sheet.proto
+++ b/proto/store/sheet.proto
@@ -16,4 +16,12 @@ message SheetPayload {
// The SQL dialect.
Engine engine = 3;
+
+ // The start and end position of each command in the sheet statement.
+ repeated SheetCommand commands = 4;
+}
+
+message SheetCommand {
+ int32 start = 1;
+ int32 end = 2;
}