Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: impl sql service check (#8307)
p0ny65d3b7261e36
diff --git a/backend/api/v1/sql_service.go b/backend/api/v1/sql_service.goindex 6e451b0b77..9aea3c80a0 100644--- a/backend/api/v1/sql_service.go+++ b/backend/api/v1/sql_service.go@@ -2,19 +2,20 @@ package v1import ("bytes"- "cmp""context""database/sql""encoding/base64""encoding/json""fmt""io"- "log/slog""reflect""strconv""strings""time"+ "cmp"+ "log/slog"+"github.com/google/cel-go/cel""github.com/labstack/echo/v4""github.com/lib/pq"@@ -920,6 +921,57 @@ func (s *SQLService) createExportActivity(ctx context.Context, user *store.UserMreturn activity, nil}+func (s *SQLService) Check(ctx context.Context, request *v1pb.CheckRequest) (*v1pb.CheckResponse, error) {+ if len(request.Statement) > common.MaxStatementSizeForSQLReview {+ return nil, status.Errorf(codes.FailedPrecondition, "statement size exceeds maximum allowed size %dKB", common.MaxStatementSizeForSQLReview/1024)+ }++ instanceID, databaseName, err := common.GetInstanceDatabaseID(request.Database)+ if err != nil {+ return nil, status.Errorf(codes.InvalidArgument, err.Error())+ }++ instance, err := s.store.GetInstanceV2(ctx, &store.FindInstanceMessage{+ ResourceID: &instanceID,+ })+ if err != nil {+ return nil, status.Errorf(codes.Internal, "failed to get instance, error: %v", err)+ }+ if instance == nil {+ return nil, status.Errorf(codes.NotFound, "instance %q not found", instanceID)+ }++ database, err := s.store.GetDatabaseV2(ctx, &store.FindDatabaseMessage{+ InstanceID: &instanceID,+ DatabaseName: &databaseName,+ })+ if err != nil {+ return nil, status.Errorf(codes.Internal, "failed to get database, error: %v", err)+ }+ if database == nil {+ return nil, status.Errorf(codes.NotFound, "database %q not found", request.Database)+ }++ environment, err := s.store.GetEnvironmentV2(ctx, &store.FindEnvironmentMessage{+ ResourceID: &database.EffectiveEnvironmentID,+ })+ if err != nil {+ return nil, status.Errorf(codes.Internal, "failed to get environment, error: %v", err)+ }+ if environment == nil {+ return nil, status.Errorf(codes.NotFound, "environment %q not found", database.EffectiveEnvironmentID)+ }++ _, adviceList, err := s.sqlReviewCheck(ctx, request.Statement, environment, instance, database)+ if err != nil {+ return nil, status.Errorf(codes.Internal, "failed to do sql review check, error: %v", err)+ }++ return &v1pb.CheckResponse{+ Advices: adviceList,+ }, nil+}+// Query executes a SQL query.// We have the following stages:// 1. pre-querydiff --git a/backend/common/util.go b/backend/common/util.goindex 14378bfcf7..e901ae3425 100644--- a/backend/common/util.go+++ b/backend/common/util.go@@ -28,6 +28,8 @@ const (MaxSheetSizeForRollback = 8 * 1024 * 1024// MaxSheetSizeForPlanCheckDML is the maximum size of a sheet for plan check to check DML changes.MaxSheetSizeForPlanCheckDML = 512 * 1024+ // MaxStatementSizeForSQLReview is the maximum size of the statement to do sql review checks in sql service.+ MaxStatementSizeForSQLReview = 512 * 1024// ExternalURLPlaceholder is the docs link to configure --external-url.ExternalURLPlaceholder = "https://www.bytebase.com/docs/get-started/install/external-url"diff --git a/frontend/src/types/proto/v1/sql_service.ts b/frontend/src/types/proto/v1/sql_service.tsindex 2174f1c971..faffc61a67 100644--- a/frontend/src/types/proto/v1/sql_service.ts+++ b/frontend/src/types/proto/v1/sql_service.ts@@ -229,56 +229,10 @@ export interface PrettyResponse {export interface CheckRequest {statement: string;- changeDatabaseType: CheckRequest_ChangeDatabaseType;/** Format: instances/{instance}/databases/{databaseName} */database: string;}-export enum CheckRequest_ChangeDatabaseType {- CHANGE_DATABASE_TYPE_UNSPECIFIED = 0,- DDL = 1,- DML = 2,- SDL = 3,- UNRECOGNIZED = -1,-}--export function checkRequest_ChangeDatabaseTypeFromJSON(object: any): CheckRequest_ChangeDatabaseType {- switch (object) {- case 0:- case "CHANGE_DATABASE_TYPE_UNSPECIFIED":- return CheckRequest_ChangeDatabaseType.CHANGE_DATABASE_TYPE_UNSPECIFIED;- case 1:- case "DDL":- return CheckRequest_ChangeDatabaseType.DDL;- case 2:- case "DML":- return CheckRequest_ChangeDatabaseType.DML;- case 3:- case "SDL":- return CheckRequest_ChangeDatabaseType.SDL;- case -1:- case "UNRECOGNIZED":- default:- return CheckRequest_ChangeDatabaseType.UNRECOGNIZED;- }-}--export function checkRequest_ChangeDatabaseTypeToJSON(object: CheckRequest_ChangeDatabaseType): string {- switch (object) {- case CheckRequest_ChangeDatabaseType.CHANGE_DATABASE_TYPE_UNSPECIFIED:- return "CHANGE_DATABASE_TYPE_UNSPECIFIED";- case CheckRequest_ChangeDatabaseType.DDL:- return "DDL";- case CheckRequest_ChangeDatabaseType.DML:- return "DML";- case CheckRequest_ChangeDatabaseType.SDL:- return "SDL";- case CheckRequest_ChangeDatabaseType.UNRECOGNIZED:- default:- return "UNRECOGNIZED";- }-}-export interface CheckResponse {advices: Advice[];}@@ -1727,7 +1681,7 @@ export const PrettyResponse = {};function createBaseCheckRequest(): CheckRequest {- return { statement: "", changeDatabaseType: 0, database: "" };+ return { statement: "", database: "" };}export const CheckRequest = {@@ -1735,11 +1689,8 @@ export const CheckRequest = {if (message.statement !== "") {writer.uint32(10).string(message.statement);}- if (message.changeDatabaseType !== 0) {- writer.uint32(16).int32(message.changeDatabaseType);- }if (message.database !== "") {- writer.uint32(26).string(message.database);+ writer.uint32(18).string(message.database);}return writer;},@@ -1759,14 +1710,7 @@ export const CheckRequest = {message.statement = reader.string();continue;case 2:- if (tag !== 16) {- break;- }-- message.changeDatabaseType = reader.int32() as any;- continue;- case 3:- if (tag !== 26) {+ if (tag !== 18) {break;}@@ -1784,9 +1728,6 @@ export const CheckRequest = {fromJSON(object: any): CheckRequest {return {statement: isSet(object.statement) ? String(object.statement) : "",- changeDatabaseType: isSet(object.changeDatabaseType)- ? checkRequest_ChangeDatabaseTypeFromJSON(object.changeDatabaseType)- : 0,database: isSet(object.database) ? String(object.database) : "",};},@@ -1794,8 +1735,6 @@ export const CheckRequest = {toJSON(message: CheckRequest): unknown {const obj: any = {};message.statement !== undefined && (obj.statement = message.statement);- message.changeDatabaseType !== undefined &&- (obj.changeDatabaseType = checkRequest_ChangeDatabaseTypeToJSON(message.changeDatabaseType));message.database !== undefined && (obj.database = message.database);return obj;},@@ -1807,7 +1746,6 @@ export const CheckRequest = {fromPartial(object: DeepPartial<CheckRequest>): CheckRequest {const message = createBaseCheckRequest();message.statement = object.statement ?? "";- message.changeDatabaseType = object.changeDatabaseType ?? 0;message.database = object.database ?? "";return message;},diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex 4a7b507f72..bc5b0a37f8 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -609,7 +609,6 @@- [RowValue](#bytebase-v1-RowValue)- [Advice.Status](#bytebase-v1-Advice-Status)- - [CheckRequest.ChangeDatabaseType](#bytebase-v1-CheckRequest-ChangeDatabaseType)- [SQLService](#bytebase-v1-SQLService)@@ -9471,7 +9470,6 @@ The sheet's `name` field is used to identify the sheet to update. Format: pr| Field | Type | Label | Description || ----- | ---- | ----- | ----------- || statement | [string](#string) | | |-| change_database_type | [CheckRequest.ChangeDatabaseType](#bytebase-v1-CheckRequest-ChangeDatabaseType) | | || database | [string](#string) | | Format: instances/{instance}/databases/{databaseName} |@@ -9707,20 +9705,6 @@ The sheet's `name` field is used to identify the sheet to update. Format: pr| ERROR | 3 | |--<a name="bytebase-v1-CheckRequest-ChangeDatabaseType"></a>--### CheckRequest.ChangeDatabaseType---| Name | Number | Description |-| ---- | ------ | ----------- |-| CHANGE_DATABASE_TYPE_UNSPECIFIED | 0 | |-| DDL | 1 | |-| DML | 2 | |-| SDL | 3 | |--diff --git a/proto/generated-go/v1/sql_service.pb.go b/proto/generated-go/v1/sql_service.pb.goindex c1114841d9..55cec4240e 100644--- a/proto/generated-go/v1/sql_service.pb.go+++ b/proto/generated-go/v1/sql_service.pb.go@@ -76,58 +76,6 @@ func (Advice_Status) EnumDescriptor() ([]byte, []int) {return file_v1_sql_service_proto_rawDescGZIP(), []int{11, 0}}-type CheckRequest_ChangeDatabaseType int32--const (- CheckRequest_CHANGE_DATABASE_TYPE_UNSPECIFIED CheckRequest_ChangeDatabaseType = 0- CheckRequest_DDL CheckRequest_ChangeDatabaseType = 1- CheckRequest_DML CheckRequest_ChangeDatabaseType = 2- CheckRequest_SDL CheckRequest_ChangeDatabaseType = 3-)--// Enum value maps for CheckRequest_ChangeDatabaseType.-var (- CheckRequest_ChangeDatabaseType_name = map[int32]string{- 0: "CHANGE_DATABASE_TYPE_UNSPECIFIED",- 1: "DDL",- 2: "DML",- 3: "SDL",- }- CheckRequest_ChangeDatabaseType_value = map[string]int32{- "CHANGE_DATABASE_TYPE_UNSPECIFIED": 0,- "DDL": 1,- "DML": 2,- "SDL": 3,- }-)--func (x CheckRequest_ChangeDatabaseType) Enum() *CheckRequest_ChangeDatabaseType {- p := new(CheckRequest_ChangeDatabaseType)- *p = x- return p-}--func (x CheckRequest_ChangeDatabaseType) String() string {- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))-}--func (CheckRequest_ChangeDatabaseType) Descriptor() protoreflect.EnumDescriptor {- return file_v1_sql_service_proto_enumTypes[1].Descriptor()-}--func (CheckRequest_ChangeDatabaseType) Type() protoreflect.EnumType {- return &file_v1_sql_service_proto_enumTypes[1]-}--func (x CheckRequest_ChangeDatabaseType) Number() protoreflect.EnumNumber {- return protoreflect.EnumNumber(x)-}--// Deprecated: Use CheckRequest_ChangeDatabaseType.Descriptor instead.-func (CheckRequest_ChangeDatabaseType) EnumDescriptor() ([]byte, []int) {- return file_v1_sql_service_proto_rawDescGZIP(), []int{14, 0}-}-type DifferPreviewRequest struct {state protoimpl.MessageStatesizeCache protoimpl.SizeCache@@ -1260,10 +1208,9 @@ type CheckRequest struct {sizeCache protoimpl.SizeCacheunknownFields protoimpl.UnknownFields- Statement string `protobuf:"bytes,1,opt,name=statement,proto3" json:"statement,omitempty"`- ChangeDatabaseType CheckRequest_ChangeDatabaseType `protobuf:"varint,2,opt,name=change_database_type,json=changeDatabaseType,proto3,enum=bytebase.v1.CheckRequest_ChangeDatabaseType" json:"change_database_type,omitempty"`+ Statement string `protobuf:"bytes,1,opt,name=statement,proto3" json:"statement,omitempty"`// Format: instances/{instance}/databases/{databaseName}- Database string `protobuf:"bytes,3,opt,name=database,proto3" json:"database,omitempty"`+ Database string `protobuf:"bytes,2,opt,name=database,proto3" json:"database,omitempty"`}func (x *CheckRequest) Reset() {@@ -1305,13 +1252,6 @@ func (x *CheckRequest) GetStatement() string {return ""}-func (x *CheckRequest) GetChangeDatabaseType() CheckRequest_ChangeDatabaseType {- if x != nil {- return x.ChangeDatabaseType- }- return CheckRequest_CHANGE_DATABASE_TYPE_UNSPECIFIED-}-func (x *CheckRequest) GetDatabase() string {if x != nil {return x.Database@@ -1532,69 +1472,57 @@ var file_v1_sql_service_proto_rawDesc = []byte{0x74, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x27, 0x0a, 0x0f, 0x65, 0x78, 0x70, 0x65, 0x63,0x74, 0x65, 0x64, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,0x52, 0x0e, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61,- 0x22, 0xff, 0x01, 0x0a, 0x0c, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,- 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01,- 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12,- 0x5e, 0x0a, 0x14, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61,- 0x73, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2c, 0x2e,- 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63,- 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x44,- 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x12, 0x63, 0x68, 0x61,- 0x6e, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12,- 0x1a, 0x0a, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28,- 0x09, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x22, 0x55, 0x0a, 0x12, 0x43,- 0x68, 0x61, 0x6e, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x54, 0x79, 0x70,- 0x65, 0x12, 0x24, 0x0a, 0x20, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x5f, 0x44, 0x41, 0x54, 0x41,- 0x42, 0x41, 0x53, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43,- 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x44, 0x44, 0x4c, 0x10, 0x01,- 0x12, 0x07, 0x0a, 0x03, 0x44, 0x4d, 0x4c, 0x10, 0x02, 0x12, 0x07, 0x0a, 0x03, 0x53, 0x44, 0x4c,- 0x10, 0x03, 0x22, 0x3e, 0x0a, 0x0d, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f,- 0x6e, 0x73, 0x65, 0x12, 0x2d, 0x0a, 0x07, 0x61, 0x64, 0x76, 0x69, 0x63, 0x65, 0x73, 0x18, 0x01,- 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,- 0x76, 0x31, 0x2e, 0x41, 0x64, 0x76, 0x69, 0x63, 0x65, 0x52, 0x07, 0x61, 0x64, 0x76, 0x69, 0x63,- 0x65, 0x73, 0x32, 0x87, 0x05, 0x0a, 0x0a, 0x53, 0x51, 0x4c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,- 0x65, 0x12, 0x5c, 0x0a, 0x06, 0x50, 0x72, 0x65, 0x74, 0x74, 0x79, 0x12, 0x1a, 0x2e, 0x62, 0x79,- 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x65, 0x74, 0x74, 0x79,- 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,- 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x65, 0x74, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70,- 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x3a, 0x01, 0x2a, 0x22,- 0x0e, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x71, 0x6c, 0x2f, 0x70, 0x72, 0x65, 0x74, 0x74, 0x79, 0x12,- 0x67, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x19, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62,- 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75,- 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76,- 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,- 0x27, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x21, 0x3a, 0x01, 0x2a, 0x22, 0x1c, 0x2f, 0x76, 0x31, 0x2f,- 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x2f,- 0x2a, 0x7d, 0x3a, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x6b, 0x0a, 0x06, 0x45, 0x78, 0x70, 0x6f,- 0x72, 0x74, 0x12, 0x1a, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31,- 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b,- 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x70,- 0x6f, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x28, 0x82, 0xd3, 0xe4,- 0x93, 0x02, 0x22, 0x3a, 0x01, 0x2a, 0x22, 0x1d, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d,- 0x65, 0x3d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x2f, 0x2a, 0x7d, 0x3a, 0x65,- 0x78, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x71, 0x0a, 0x0c, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x45, 0x78,- 0x65, 0x63, 0x75, 0x74, 0x65, 0x12, 0x20, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65,- 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65,- 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,- 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x45, 0x78, 0x65, 0x63, 0x75,- 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93,- 0x02, 0x12, 0x12, 0x10, 0x2f, 0x76, 0x31, 0x3a, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x45, 0x78, 0x65,- 0x63, 0x75, 0x74, 0x65, 0x28, 0x01, 0x30, 0x01, 0x12, 0x78, 0x0a, 0x0d, 0x44, 0x69, 0x66, 0x66,- 0x65, 0x72, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x12, 0x21, 0x2e, 0x62, 0x79, 0x74, 0x65,- 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x65, 0x72, 0x50, 0x72,- 0x65, 0x76, 0x69, 0x65, 0x77, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x62,- 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x65,- 0x72, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,- 0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x3a, 0x01, 0x2a, 0x22, 0x15, 0x2f, 0x76, 0x31,- 0x2f, 0x73, 0x71, 0x6c, 0x2f, 0x64, 0x69, 0x66, 0x66, 0x65, 0x72, 0x50, 0x72, 0x65, 0x76, 0x69,- 0x65, 0x77, 0x12, 0x58, 0x0a, 0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x19, 0x2e, 0x62, 0x79,- 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52,- 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73,- 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,- 0x73, 0x65, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x3a, 0x01, 0x2a, 0x22, 0x0d, 0x2f,- 0x76, 0x31, 0x2f, 0x73, 0x71, 0x6c, 0x2f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x42, 0x11, 0x5a, 0x0f,- 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f, 0x2f, 0x76, 0x31, 0x62,- 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,+ 0x22, 0x48, 0x0a, 0x0c, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,+ 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20,+ 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x1a,+ 0x0a, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,+ 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x22, 0x3e, 0x0a, 0x0d, 0x43, 0x68,+ 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2d, 0x0a, 0x07, 0x61,+ 0x64, 0x76, 0x69, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x62,+ 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x64, 0x76, 0x69, 0x63,+ 0x65, 0x52, 0x07, 0x61, 0x64, 0x76, 0x69, 0x63, 0x65, 0x73, 0x32, 0x87, 0x05, 0x0a, 0x0a, 0x53,+ 0x51, 0x4c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5c, 0x0a, 0x06, 0x50, 0x72, 0x65,+ 0x74, 0x74, 0x79, 0x12, 0x1a, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76,+ 0x31, 0x2e, 0x50, 0x72, 0x65, 0x74, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,+ 0x1b, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72,+ 0x65, 0x74, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3,+ 0xe4, 0x93, 0x02, 0x13, 0x3a, 0x01, 0x2a, 0x22, 0x0e, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x71, 0x6c,+ 0x2f, 0x70, 0x72, 0x65, 0x74, 0x74, 0x79, 0x12, 0x67, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79,+ 0x12, 0x19, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x51,+ 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x62, 0x79,+ 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52,+ 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x27, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x21, 0x3a,+ 0x01, 0x2a, 0x22, 0x1c, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x69, 0x6e,+ 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x2f, 0x2a, 0x7d, 0x3a, 0x71, 0x75, 0x65, 0x72, 0x79,+ 0x12, 0x6b, 0x0a, 0x06, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x1a, 0x2e, 0x62, 0x79, 0x74,+ 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x52,+ 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73,+ 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f,+ 0x6e, 0x73, 0x65, 0x22, 0x28, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x22, 0x3a, 0x01, 0x2a, 0x22, 0x1d,+ 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e,+ 0x63, 0x65, 0x73, 0x2f, 0x2a, 0x7d, 0x3a, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x71, 0x0a,+ 0x0c, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x12, 0x20, 0x2e,+ 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x64, 0x6d, 0x69,+ 0x6e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,+ 0x21, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x64,+ 0x6d, 0x69, 0x6e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,+ 0x73, 0x65, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x12, 0x10, 0x2f, 0x76, 0x31, 0x3a,+ 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x28, 0x01, 0x30, 0x01,+ 0x12, 0x78, 0x0a, 0x0d, 0x44, 0x69, 0x66, 0x66, 0x65, 0x72, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65,+ 0x77, 0x12, 0x21, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e,+ 0x44, 0x69, 0x66, 0x66, 0x65, 0x72, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x52, 0x65, 0x71,+ 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,+ 0x76, 0x31, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x65, 0x72, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77,+ 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a,+ 0x3a, 0x01, 0x2a, 0x22, 0x15, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x71, 0x6c, 0x2f, 0x64, 0x69, 0x66,+ 0x66, 0x65, 0x72, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x12, 0x58, 0x0a, 0x05, 0x43, 0x68,+ 0x65, 0x63, 0x6b, 0x12, 0x19, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76,+ 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a,+ 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x65,+ 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93,+ 0x02, 0x12, 0x3a, 0x01, 0x2a, 0x22, 0x0d, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x71, 0x6c, 0x2f, 0x63,+ 0x68, 0x65, 0x63, 0x6b, 0x42, 0x11, 0x5a, 0x0f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65,+ 0x64, 0x2d, 0x67, 0x6f, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,}var (@@ -1609,69 +1537,67 @@ func file_v1_sql_service_proto_rawDescGZIP() []byte {return file_v1_sql_service_proto_rawDescData}-var file_v1_sql_service_proto_enumTypes = make([]protoimpl.EnumInfo, 2)+var file_v1_sql_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1)var file_v1_sql_service_proto_msgTypes = make([]protoimpl.MessageInfo, 16)var file_v1_sql_service_proto_goTypes = []interface{}{- (Advice_Status)(0), // 0: bytebase.v1.Advice.Status- (CheckRequest_ChangeDatabaseType)(0), // 1: bytebase.v1.CheckRequest.ChangeDatabaseType- (*DifferPreviewRequest)(nil), // 2: bytebase.v1.DifferPreviewRequest- (*DifferPreviewResponse)(nil), // 3: bytebase.v1.DifferPreviewResponse- (*AdminExecuteRequest)(nil), // 4: bytebase.v1.AdminExecuteRequest- (*AdminExecuteResponse)(nil), // 5: bytebase.v1.AdminExecuteResponse- (*ExportRequest)(nil), // 6: bytebase.v1.ExportRequest- (*ExportResponse)(nil), // 7: bytebase.v1.ExportResponse- (*QueryRequest)(nil), // 8: bytebase.v1.QueryRequest- (*QueryResponse)(nil), // 9: bytebase.v1.QueryResponse- (*QueryResult)(nil), // 10: bytebase.v1.QueryResult- (*QueryRow)(nil), // 11: bytebase.v1.QueryRow- (*RowValue)(nil), // 12: bytebase.v1.RowValue- (*Advice)(nil), // 13: bytebase.v1.Advice- (*PrettyRequest)(nil), // 14: bytebase.v1.PrettyRequest- (*PrettyResponse)(nil), // 15: bytebase.v1.PrettyResponse- (*CheckRequest)(nil), // 16: bytebase.v1.CheckRequest- (*CheckResponse)(nil), // 17: bytebase.v1.CheckResponse- (Engine)(0), // 18: bytebase.v1.Engine- (*DatabaseMetadata)(nil), // 19: bytebase.v1.DatabaseMetadata- (*durationpb.Duration)(nil), // 20: google.protobuf.Duration- (ExportFormat)(0), // 21: bytebase.v1.ExportFormat- (structpb.NullValue)(0), // 22: google.protobuf.NullValue- (*structpb.Value)(nil), // 23: google.protobuf.Value+ (Advice_Status)(0), // 0: bytebase.v1.Advice.Status+ (*DifferPreviewRequest)(nil), // 1: bytebase.v1.DifferPreviewRequest+ (*DifferPreviewResponse)(nil), // 2: bytebase.v1.DifferPreviewResponse+ (*AdminExecuteRequest)(nil), // 3: bytebase.v1.AdminExecuteRequest+ (*AdminExecuteResponse)(nil), // 4: bytebase.v1.AdminExecuteResponse+ (*ExportRequest)(nil), // 5: bytebase.v1.ExportRequest+ (*ExportResponse)(nil), // 6: bytebase.v1.ExportResponse+ (*QueryRequest)(nil), // 7: bytebase.v1.QueryRequest+ (*QueryResponse)(nil), // 8: bytebase.v1.QueryResponse+ (*QueryResult)(nil), // 9: bytebase.v1.QueryResult+ (*QueryRow)(nil), // 10: bytebase.v1.QueryRow+ (*RowValue)(nil), // 11: bytebase.v1.RowValue+ (*Advice)(nil), // 12: bytebase.v1.Advice+ (*PrettyRequest)(nil), // 13: bytebase.v1.PrettyRequest+ (*PrettyResponse)(nil), // 14: bytebase.v1.PrettyResponse+ (*CheckRequest)(nil), // 15: bytebase.v1.CheckRequest+ (*CheckResponse)(nil), // 16: bytebase.v1.CheckResponse+ (Engine)(0), // 17: bytebase.v1.Engine+ (*DatabaseMetadata)(nil), // 18: bytebase.v1.DatabaseMetadata+ (*durationpb.Duration)(nil), // 19: google.protobuf.Duration+ (ExportFormat)(0), // 20: bytebase.v1.ExportFormat+ (structpb.NullValue)(0), // 21: google.protobuf.NullValue+ (*structpb.Value)(nil), // 22: google.protobuf.Value}var file_v1_sql_service_proto_depIdxs = []int32{- 18, // 0: bytebase.v1.DifferPreviewRequest.engine:type_name -> bytebase.v1.Engine- 19, // 1: bytebase.v1.DifferPreviewRequest.new_metadata:type_name -> bytebase.v1.DatabaseMetadata- 20, // 2: bytebase.v1.AdminExecuteRequest.timeout:type_name -> google.protobuf.Duration- 10, // 3: bytebase.v1.AdminExecuteResponse.results:type_name -> bytebase.v1.QueryResult- 21, // 4: bytebase.v1.ExportRequest.format:type_name -> bytebase.v1.ExportFormat- 20, // 5: bytebase.v1.QueryRequest.timeout:type_name -> google.protobuf.Duration- 10, // 6: bytebase.v1.QueryResponse.results:type_name -> bytebase.v1.QueryResult- 13, // 7: bytebase.v1.QueryResponse.advices:type_name -> bytebase.v1.Advice- 11, // 8: bytebase.v1.QueryResult.rows:type_name -> bytebase.v1.QueryRow- 20, // 9: bytebase.v1.QueryResult.latency:type_name -> google.protobuf.Duration- 12, // 10: bytebase.v1.QueryRow.values:type_name -> bytebase.v1.RowValue- 22, // 11: bytebase.v1.RowValue.null_value:type_name -> google.protobuf.NullValue- 23, // 12: bytebase.v1.RowValue.value_value:type_name -> google.protobuf.Value+ 17, // 0: bytebase.v1.DifferPreviewRequest.engine:type_name -> bytebase.v1.Engine+ 18, // 1: bytebase.v1.DifferPreviewRequest.new_metadata:type_name -> bytebase.v1.DatabaseMetadata+ 19, // 2: bytebase.v1.AdminExecuteRequest.timeout:type_name -> google.protobuf.Duration+ 9, // 3: bytebase.v1.AdminExecuteResponse.results:type_name -> bytebase.v1.QueryResult+ 20, // 4: bytebase.v1.ExportRequest.format:type_name -> bytebase.v1.ExportFormat+ 19, // 5: bytebase.v1.QueryRequest.timeout:type_name -> google.protobuf.Duration+ 9, // 6: bytebase.v1.QueryResponse.results:type_name -> bytebase.v1.QueryResult+ 12, // 7: bytebase.v1.QueryResponse.advices:type_name -> bytebase.v1.Advice+ 10, // 8: bytebase.v1.QueryResult.rows:type_name -> bytebase.v1.QueryRow+ 19, // 9: bytebase.v1.QueryResult.latency:type_name -> google.protobuf.Duration+ 11, // 10: bytebase.v1.QueryRow.values:type_name -> bytebase.v1.RowValue+ 21, // 11: bytebase.v1.RowValue.null_value:type_name -> google.protobuf.NullValue+ 22, // 12: bytebase.v1.RowValue.value_value:type_name -> google.protobuf.Value0, // 13: bytebase.v1.Advice.status:type_name -> bytebase.v1.Advice.Status- 18, // 14: bytebase.v1.PrettyRequest.engine:type_name -> bytebase.v1.Engine- 1, // 15: bytebase.v1.CheckRequest.change_database_type:type_name -> bytebase.v1.CheckRequest.ChangeDatabaseType- 13, // 16: bytebase.v1.CheckResponse.advices:type_name -> bytebase.v1.Advice- 14, // 17: bytebase.v1.SQLService.Pretty:input_type -> bytebase.v1.PrettyRequest- 8, // 18: bytebase.v1.SQLService.Query:input_type -> bytebase.v1.QueryRequest- 6, // 19: bytebase.v1.SQLService.Export:input_type -> bytebase.v1.ExportRequest- 4, // 20: bytebase.v1.SQLService.AdminExecute:input_type -> bytebase.v1.AdminExecuteRequest- 2, // 21: bytebase.v1.SQLService.DifferPreview:input_type -> bytebase.v1.DifferPreviewRequest- 16, // 22: bytebase.v1.SQLService.Check:input_type -> bytebase.v1.CheckRequest- 15, // 23: bytebase.v1.SQLService.Pretty:output_type -> bytebase.v1.PrettyResponse- 9, // 24: bytebase.v1.SQLService.Query:output_type -> bytebase.v1.QueryResponse- 7, // 25: bytebase.v1.SQLService.Export:output_type -> bytebase.v1.ExportResponse- 5, // 26: bytebase.v1.SQLService.AdminExecute:output_type -> bytebase.v1.AdminExecuteResponse- 3, // 27: bytebase.v1.SQLService.DifferPreview:output_type -> bytebase.v1.DifferPreviewResponse- 17, // 28: bytebase.v1.SQLService.Check:output_type -> bytebase.v1.CheckResponse- 23, // [23:29] is the sub-list for method output_type- 17, // [17:23] is the sub-list for method input_type- 17, // [17:17] is the sub-list for extension type_name- 17, // [17:17] is the sub-list for extension extendee- 0, // [0:17] is the sub-list for field type_name+ 17, // 14: bytebase.v1.PrettyRequest.engine:type_name -> bytebase.v1.Engine+ 12, // 15: bytebase.v1.CheckResponse.advices:type_name -> bytebase.v1.Advice+ 13, // 16: bytebase.v1.SQLService.Pretty:input_type -> bytebase.v1.PrettyRequest+ 7, // 17: bytebase.v1.SQLService.Query:input_type -> bytebase.v1.QueryRequest+ 5, // 18: bytebase.v1.SQLService.Export:input_type -> bytebase.v1.ExportRequest+ 3, // 19: bytebase.v1.SQLService.AdminExecute:input_type -> bytebase.v1.AdminExecuteRequest+ 1, // 20: bytebase.v1.SQLService.DifferPreview:input_type -> bytebase.v1.DifferPreviewRequest+ 15, // 21: bytebase.v1.SQLService.Check:input_type -> bytebase.v1.CheckRequest+ 14, // 22: bytebase.v1.SQLService.Pretty:output_type -> bytebase.v1.PrettyResponse+ 8, // 23: bytebase.v1.SQLService.Query:output_type -> bytebase.v1.QueryResponse+ 6, // 24: bytebase.v1.SQLService.Export:output_type -> bytebase.v1.ExportResponse+ 4, // 25: bytebase.v1.SQLService.AdminExecute:output_type -> bytebase.v1.AdminExecuteResponse+ 2, // 26: bytebase.v1.SQLService.DifferPreview:output_type -> bytebase.v1.DifferPreviewResponse+ 16, // 27: bytebase.v1.SQLService.Check:output_type -> bytebase.v1.CheckResponse+ 22, // [22:28] is the sub-list for method output_type+ 16, // [16:22] is the sub-list for method input_type+ 16, // [16:16] is the sub-list for extension type_name+ 16, // [16:16] is the sub-list for extension extendee+ 0, // [0:16] is the sub-list for field type_name}func init() { file_v1_sql_service_proto_init() }@@ -1893,7 +1819,7 @@ func file_v1_sql_service_proto_init() {File: protoimpl.DescBuilder{GoPackagePath: reflect.TypeOf(x{}).PkgPath(),RawDescriptor: file_v1_sql_service_proto_rawDesc,- NumEnums: 2,+ NumEnums: 1,NumMessages: 16,NumExtensions: 0,NumServices: 1,diff --git a/proto/v1/sql_service.proto b/proto/v1/sql_service.protoindex eddbbbd189..5cef84f5d4 100644--- a/proto/v1/sql_service.proto+++ b/proto/v1/sql_service.proto@@ -242,16 +242,8 @@ message PrettyResponse {message CheckRequest {string statement = 1;- enum ChangeDatabaseType {- CHANGE_DATABASE_TYPE_UNSPECIFIED = 0;- DDL = 1;- DML = 2;- SDL = 3;- }- ChangeDatabaseType change_database_type = 2;-// Format: instances/{instance}/databases/{databaseName}- string database = 3;+ string database = 2;}message CheckResponse {