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: add proto to sql query API (#6277)
rebelice85dda6a2fdcb
diff --git a/frontend/src/types/proto/v1/sql_service.ts b/frontend/src/types/proto/v1/sql_service.tsindex cf527f169b..61a4fe7112 100644--- a/frontend/src/types/proto/v1/sql_service.ts+++ b/frontend/src/types/proto/v1/sql_service.ts@@ -5,6 +5,110 @@ import { Engine, engineFromJSON, engineToJSON } from "./common";export const protobufPackage = "bytebase.v1";+export interface QueryRequest {+ /**+ * The name is the instance name to execute the query against.+ * Format: instances/{instance}+ */+ name: string;+ /**+ * The connection database name to execute the query against.+ * For PostgreSQL, it's required.+ * For other database engines, it's optional. Use empty string to execute against without specifying a database.+ */+ connectionDatabase: string;+ /** The SQL statement to execute. */+ statement: string;+ /** The maximum number of rows to return. */+ limit: number;+}++export interface QueryResponse {+ /** The query results. */+ results: QueryResult[];+ /** The query advices. */+ advices: Advice[];+}++export interface QueryResult {+ /** Column names of the query result. */+ columnNames: string[];+ /** Column types of the query result. */+ columnTypeNames: string[];+ /** Rows of the query result. */+ rows: QueryRow[];+ /** Columns are masked or not. */+ masked: boolean[];+ /** The error message if the query failed. */+ error: string;+}++export interface QueryRow {+ /** Row values of the query result. */+ values: string[];+}++export interface Advice {+ /** The advice status. */+ status: Advice_Status;+ /** The advice code. */+ code: number;+ /** The advice title. */+ title: string;+ /** The advice content. */+ content: string;+ /** The advice line number in the SQL statement. */+ line: number;+ /** The advice detail. */+ detail: string;+}++export enum Advice_Status {+ /** STATUS_UNSPECIFIED - Unspecified. */+ STATUS_UNSPECIFIED = 0,+ SUCCESS = 1,+ WARNING = 2,+ ERROR = 3,+ UNRECOGNIZED = -1,+}++export function advice_StatusFromJSON(object: any): Advice_Status {+ switch (object) {+ case 0:+ case "STATUS_UNSPECIFIED":+ return Advice_Status.STATUS_UNSPECIFIED;+ case 1:+ case "SUCCESS":+ return Advice_Status.SUCCESS;+ case 2:+ case "WARNING":+ return Advice_Status.WARNING;+ case 3:+ case "ERROR":+ return Advice_Status.ERROR;+ case -1:+ case "UNRECOGNIZED":+ default:+ return Advice_Status.UNRECOGNIZED;+ }+}++export function advice_StatusToJSON(object: Advice_Status): string {+ switch (object) {+ case Advice_Status.STATUS_UNSPECIFIED:+ return "STATUS_UNSPECIFIED";+ case Advice_Status.SUCCESS:+ return "SUCCESS";+ case Advice_Status.WARNING:+ return "WARNING";+ case Advice_Status.ERROR:+ return "ERROR";+ case Advice_Status.UNRECOGNIZED:+ default:+ return "UNRECOGNIZED";+ }+}+export interface PrettyRequest {engine: Engine;/**@@ -23,6 +127,503 @@ export interface PrettyResponse {expectedSchema: string;}+function createBaseQueryRequest(): QueryRequest {+ return { name: "", connectionDatabase: "", statement: "", limit: 0 };+}++export const QueryRequest = {+ encode(message: QueryRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {+ if (message.name !== "") {+ writer.uint32(10).string(message.name);+ }+ if (message.connectionDatabase !== "") {+ writer.uint32(18).string(message.connectionDatabase);+ }+ if (message.statement !== "") {+ writer.uint32(26).string(message.statement);+ }+ if (message.limit !== 0) {+ writer.uint32(32).int32(message.limit);+ }+ return writer;+ },++ decode(input: _m0.Reader | Uint8Array, length?: number): QueryRequest {+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);+ let end = length === undefined ? reader.len : reader.pos + length;+ const message = createBaseQueryRequest();+ while (reader.pos < end) {+ const tag = reader.uint32();+ switch (tag >>> 3) {+ case 1:+ if (tag !== 10) {+ break;+ }++ message.name = reader.string();+ continue;+ case 2:+ if (tag !== 18) {+ break;+ }++ message.connectionDatabase = reader.string();+ continue;+ case 3:+ if (tag !== 26) {+ break;+ }++ message.statement = reader.string();+ continue;+ case 4:+ if (tag !== 32) {+ break;+ }++ message.limit = reader.int32();+ continue;+ }+ if ((tag & 7) === 4 || tag === 0) {+ break;+ }+ reader.skipType(tag & 7);+ }+ return message;+ },++ fromJSON(object: any): QueryRequest {+ return {+ name: isSet(object.name) ? String(object.name) : "",+ connectionDatabase: isSet(object.connectionDatabase) ? String(object.connectionDatabase) : "",+ statement: isSet(object.statement) ? String(object.statement) : "",+ limit: isSet(object.limit) ? Number(object.limit) : 0,+ };+ },++ toJSON(message: QueryRequest): unknown {+ const obj: any = {};+ message.name !== undefined && (obj.name = message.name);+ message.connectionDatabase !== undefined && (obj.connectionDatabase = message.connectionDatabase);+ message.statement !== undefined && (obj.statement = message.statement);+ message.limit !== undefined && (obj.limit = Math.round(message.limit));+ return obj;+ },++ create(base?: DeepPartial<QueryRequest>): QueryRequest {+ return QueryRequest.fromPartial(base ?? {});+ },++ fromPartial(object: DeepPartial<QueryRequest>): QueryRequest {+ const message = createBaseQueryRequest();+ message.name = object.name ?? "";+ message.connectionDatabase = object.connectionDatabase ?? "";+ message.statement = object.statement ?? "";+ message.limit = object.limit ?? 0;+ return message;+ },+};++function createBaseQueryResponse(): QueryResponse {+ return { results: [], advices: [] };+}++export const QueryResponse = {+ encode(message: QueryResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {+ for (const v of message.results) {+ QueryResult.encode(v!, writer.uint32(10).fork()).ldelim();+ }+ for (const v of message.advices) {+ Advice.encode(v!, writer.uint32(18).fork()).ldelim();+ }+ return writer;+ },++ decode(input: _m0.Reader | Uint8Array, length?: number): QueryResponse {+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);+ let end = length === undefined ? reader.len : reader.pos + length;+ const message = createBaseQueryResponse();+ while (reader.pos < end) {+ const tag = reader.uint32();+ switch (tag >>> 3) {+ case 1:+ if (tag !== 10) {+ break;+ }++ message.results.push(QueryResult.decode(reader, reader.uint32()));+ continue;+ case 2:+ if (tag !== 18) {+ break;+ }++ message.advices.push(Advice.decode(reader, reader.uint32()));+ continue;+ }+ if ((tag & 7) === 4 || tag === 0) {+ break;+ }+ reader.skipType(tag & 7);+ }+ return message;+ },++ fromJSON(object: any): QueryResponse {+ return {+ results: Array.isArray(object?.results) ? object.results.map((e: any) => QueryResult.fromJSON(e)) : [],+ advices: Array.isArray(object?.advices) ? object.advices.map((e: any) => Advice.fromJSON(e)) : [],+ };+ },++ toJSON(message: QueryResponse): unknown {+ const obj: any = {};+ if (message.results) {+ obj.results = message.results.map((e) => e ? QueryResult.toJSON(e) : undefined);+ } else {+ obj.results = [];+ }+ if (message.advices) {+ obj.advices = message.advices.map((e) => e ? Advice.toJSON(e) : undefined);+ } else {+ obj.advices = [];+ }+ return obj;+ },++ create(base?: DeepPartial<QueryResponse>): QueryResponse {+ return QueryResponse.fromPartial(base ?? {});+ },++ fromPartial(object: DeepPartial<QueryResponse>): QueryResponse {+ const message = createBaseQueryResponse();+ message.results = object.results?.map((e) => QueryResult.fromPartial(e)) || [];+ message.advices = object.advices?.map((e) => Advice.fromPartial(e)) || [];+ return message;+ },+};++function createBaseQueryResult(): QueryResult {+ return { columnNames: [], columnTypeNames: [], rows: [], masked: [], error: "" };+}++export const QueryResult = {+ encode(message: QueryResult, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {+ for (const v of message.columnNames) {+ writer.uint32(10).string(v!);+ }+ for (const v of message.columnTypeNames) {+ writer.uint32(18).string(v!);+ }+ for (const v of message.rows) {+ QueryRow.encode(v!, writer.uint32(26).fork()).ldelim();+ }+ writer.uint32(34).fork();+ for (const v of message.masked) {+ writer.bool(v);+ }+ writer.ldelim();+ if (message.error !== "") {+ writer.uint32(42).string(message.error);+ }+ return writer;+ },++ decode(input: _m0.Reader | Uint8Array, length?: number): QueryResult {+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);+ let end = length === undefined ? reader.len : reader.pos + length;+ const message = createBaseQueryResult();+ while (reader.pos < end) {+ const tag = reader.uint32();+ switch (tag >>> 3) {+ case 1:+ if (tag !== 10) {+ break;+ }++ message.columnNames.push(reader.string());+ continue;+ case 2:+ if (tag !== 18) {+ break;+ }++ message.columnTypeNames.push(reader.string());+ continue;+ case 3:+ if (tag !== 26) {+ break;+ }++ message.rows.push(QueryRow.decode(reader, reader.uint32()));+ continue;+ case 4:+ if (tag === 32) {+ message.masked.push(reader.bool());++ continue;+ }++ if (tag === 34) {+ const end2 = reader.uint32() + reader.pos;+ while (reader.pos < end2) {+ message.masked.push(reader.bool());+ }++ continue;+ }++ break;+ case 5:+ if (tag !== 42) {+ break;+ }++ message.error = reader.string();+ continue;+ }+ if ((tag & 7) === 4 || tag === 0) {+ break;+ }+ reader.skipType(tag & 7);+ }+ return message;+ },++ fromJSON(object: any): QueryResult {+ return {+ columnNames: Array.isArray(object?.columnNames) ? object.columnNames.map((e: any) => String(e)) : [],+ columnTypeNames: Array.isArray(object?.columnTypeNames) ? object.columnTypeNames.map((e: any) => String(e)) : [],+ rows: Array.isArray(object?.rows) ? object.rows.map((e: any) => QueryRow.fromJSON(e)) : [],+ masked: Array.isArray(object?.masked) ? object.masked.map((e: any) => Boolean(e)) : [],+ error: isSet(object.error) ? String(object.error) : "",+ };+ },++ toJSON(message: QueryResult): unknown {+ const obj: any = {};+ if (message.columnNames) {+ obj.columnNames = message.columnNames.map((e) => e);+ } else {+ obj.columnNames = [];+ }+ if (message.columnTypeNames) {+ obj.columnTypeNames = message.columnTypeNames.map((e) => e);+ } else {+ obj.columnTypeNames = [];+ }+ if (message.rows) {+ obj.rows = message.rows.map((e) => e ? QueryRow.toJSON(e) : undefined);+ } else {+ obj.rows = [];+ }+ if (message.masked) {+ obj.masked = message.masked.map((e) => e);+ } else {+ obj.masked = [];+ }+ message.error !== undefined && (obj.error = message.error);+ return obj;+ },++ create(base?: DeepPartial<QueryResult>): QueryResult {+ return QueryResult.fromPartial(base ?? {});+ },++ fromPartial(object: DeepPartial<QueryResult>): QueryResult {+ const message = createBaseQueryResult();+ message.columnNames = object.columnNames?.map((e) => e) || [];+ message.columnTypeNames = object.columnTypeNames?.map((e) => e) || [];+ message.rows = object.rows?.map((e) => QueryRow.fromPartial(e)) || [];+ message.masked = object.masked?.map((e) => e) || [];+ message.error = object.error ?? "";+ return message;+ },+};++function createBaseQueryRow(): QueryRow {+ return { values: [] };+}++export const QueryRow = {+ encode(message: QueryRow, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {+ for (const v of message.values) {+ writer.uint32(10).string(v!);+ }+ return writer;+ },++ decode(input: _m0.Reader | Uint8Array, length?: number): QueryRow {+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);+ let end = length === undefined ? reader.len : reader.pos + length;+ const message = createBaseQueryRow();+ while (reader.pos < end) {+ const tag = reader.uint32();+ switch (tag >>> 3) {+ case 1:+ if (tag !== 10) {+ break;+ }++ message.values.push(reader.string());+ continue;+ }+ if ((tag & 7) === 4 || tag === 0) {+ break;+ }+ reader.skipType(tag & 7);+ }+ return message;+ },++ fromJSON(object: any): QueryRow {+ return { values: Array.isArray(object?.values) ? object.values.map((e: any) => String(e)) : [] };+ },++ toJSON(message: QueryRow): unknown {+ const obj: any = {};+ if (message.values) {+ obj.values = message.values.map((e) => e);+ } else {+ obj.values = [];+ }+ return obj;+ },++ create(base?: DeepPartial<QueryRow>): QueryRow {+ return QueryRow.fromPartial(base ?? {});+ },++ fromPartial(object: DeepPartial<QueryRow>): QueryRow {+ const message = createBaseQueryRow();+ message.values = object.values?.map((e) => e) || [];+ return message;+ },+};++function createBaseAdvice(): Advice {+ return { status: 0, code: 0, title: "", content: "", line: 0, detail: "" };+}++export const Advice = {+ encode(message: Advice, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {+ if (message.status !== 0) {+ writer.uint32(8).int32(message.status);+ }+ if (message.code !== 0) {+ writer.uint32(16).int32(message.code);+ }+ if (message.title !== "") {+ writer.uint32(26).string(message.title);+ }+ if (message.content !== "") {+ writer.uint32(34).string(message.content);+ }+ if (message.line !== 0) {+ writer.uint32(40).int32(message.line);+ }+ if (message.detail !== "") {+ writer.uint32(50).string(message.detail);+ }+ return writer;+ },++ decode(input: _m0.Reader | Uint8Array, length?: number): Advice {+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);+ let end = length === undefined ? reader.len : reader.pos + length;+ const message = createBaseAdvice();+ while (reader.pos < end) {+ const tag = reader.uint32();+ switch (tag >>> 3) {+ case 1:+ if (tag !== 8) {+ break;+ }++ message.status = reader.int32() as any;+ continue;+ case 2:+ if (tag !== 16) {+ break;+ }++ message.code = reader.int32();+ continue;+ case 3:+ if (tag !== 26) {+ break;+ }++ message.title = reader.string();+ continue;+ case 4:+ if (tag !== 34) {+ break;+ }++ message.content = reader.string();+ continue;+ case 5:+ if (tag !== 40) {+ break;+ }++ message.line = reader.int32();+ continue;+ case 6:+ if (tag !== 50) {+ break;+ }++ message.detail = reader.string();+ continue;+ }+ if ((tag & 7) === 4 || tag === 0) {+ break;+ }+ reader.skipType(tag & 7);+ }+ return message;+ },++ fromJSON(object: any): Advice {+ return {+ status: isSet(object.status) ? advice_StatusFromJSON(object.status) : 0,+ code: isSet(object.code) ? Number(object.code) : 0,+ title: isSet(object.title) ? String(object.title) : "",+ content: isSet(object.content) ? String(object.content) : "",+ line: isSet(object.line) ? Number(object.line) : 0,+ detail: isSet(object.detail) ? String(object.detail) : "",+ };+ },++ toJSON(message: Advice): unknown {+ const obj: any = {};+ message.status !== undefined && (obj.status = advice_StatusToJSON(message.status));+ message.code !== undefined && (obj.code = Math.round(message.code));+ message.title !== undefined && (obj.title = message.title);+ message.content !== undefined && (obj.content = message.content);+ message.line !== undefined && (obj.line = Math.round(message.line));+ message.detail !== undefined && (obj.detail = message.detail);+ return obj;+ },++ create(base?: DeepPartial<Advice>): Advice {+ return Advice.fromPartial(base ?? {});+ },++ fromPartial(object: DeepPartial<Advice>): Advice {+ const message = createBaseAdvice();+ message.status = object.status ?? 0;+ message.code = object.code ?? 0;+ message.title = object.title ?? "";+ message.content = object.content ?? "";+ message.line = object.line ?? 0;+ message.detail = object.detail ?? "";+ return message;+ },+};+function createBasePrettyRequest(): PrettyRequest {return { engine: 0, currentSchema: "", expectedSchema: "" };}@@ -197,15 +798,66 @@ export const SQLServiceDefinition = {},},},+ query: {+ name: "Query",+ requestType: QueryRequest,+ requestStream: false,+ responseType: QueryResponse,+ responseStream: false,+ options: {+ _unknownFields: {+ 578365826: [+ new Uint8Array([+ 33,+ 58,+ 1,+ 42,+ 34,+ 28,+ 47,+ 118,+ 49,+ 47,+ 123,+ 110,+ 97,+ 109,+ 101,+ 61,+ 105,+ 110,+ 115,+ 116,+ 97,+ 110,+ 99,+ 101,+ 115,+ 47,+ 42,+ 125,+ 58,+ 113,+ 117,+ 101,+ 114,+ 121,+ ]),+ ],+ },+ },+ },},} as const;export interface SQLServiceImplementation<CallContextExt = {}> {pretty(request: PrettyRequest, context: CallContext & CallContextExt): Promise<DeepPartial<PrettyResponse>>;+ query(request: QueryRequest, context: CallContext & CallContextExt): Promise<DeepPartial<QueryResponse>>;}export interface SQLServiceClient<CallOptionsExt = {}> {pretty(request: DeepPartial<PrettyRequest>, options?: CallOptions & CallOptionsExt): Promise<PrettyResponse>;+ query(request: DeepPartial<QueryRequest>, options?: CallOptions & CallOptionsExt): Promise<QueryResponse>;}type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex 1b53204445..cf0ec475d1 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -448,8 +448,15 @@- [SheetService](#bytebase-v1-SheetService)- [v1/sql_service.proto](#v1_sql_service-proto)+ - [Advice](#bytebase-v1-Advice)- [PrettyRequest](#bytebase-v1-PrettyRequest)- [PrettyResponse](#bytebase-v1-PrettyResponse)+ - [QueryRequest](#bytebase-v1-QueryRequest)+ - [QueryResponse](#bytebase-v1-QueryResponse)+ - [QueryResult](#bytebase-v1-QueryResult)+ - [QueryRow](#bytebase-v1-QueryRow)++ - [Advice.Status](#bytebase-v1-Advice-Status)- [SQLService](#bytebase-v1-SQLService)@@ -6962,6 +6969,26 @@ The sheet's `name` field is used to identify the sheet to update. Format: pr+<a name="bytebase-v1-Advice"></a>++### Advice++++| Field | Type | Label | Description |+| ----- | ---- | ----- | ----------- |+| status | [Advice.Status](#bytebase-v1-Advice-Status) | | The advice status. |+| code | [int32](#int32) | | The advice code. |+| title | [string](#string) | | The advice title. |+| content | [string](#string) | | The advice content. |+| line | [int32](#int32) | | The advice line number in the SQL statement. |+| detail | [string](#string) | | The advice detail. |++++++<a name="bytebase-v1-PrettyRequest"></a>### PrettyRequest@@ -6994,8 +7021,90 @@ The sheet's `name` field is used to identify the sheet to update. Format: pr++<a name="bytebase-v1-QueryRequest"></a>++### QueryRequest++++| Field | Type | Label | Description |+| ----- | ---- | ----- | ----------- |+| name | [string](#string) | | The name is the instance name to execute the query against. Format: instances/{instance} |+| connection_database | [string](#string) | | The connection database name to execute the query against. For PostgreSQL, it's required. For other database engines, it's optional. Use empty string to execute against without specifying a database. |+| statement | [string](#string) | | The SQL statement to execute. |+| limit | [int32](#int32) | | The maximum number of rows to return. |+++++++<a name="bytebase-v1-QueryResponse"></a>++### QueryResponse++++| Field | Type | Label | Description |+| ----- | ---- | ----- | ----------- |+| results | [QueryResult](#bytebase-v1-QueryResult) | repeated | The query results. |+| advices | [Advice](#bytebase-v1-Advice) | repeated | The query advices. |+++++++<a name="bytebase-v1-QueryResult"></a>++### QueryResult++++| Field | Type | Label | Description |+| ----- | ---- | ----- | ----------- |+| column_names | [string](#string) | repeated | Column names of the query result. |+| column_type_names | [string](#string) | repeated | Column types of the query result. |+| rows | [QueryRow](#bytebase-v1-QueryRow) | repeated | Rows of the query result. |+| masked | [bool](#bool) | repeated | Columns are masked or not. |+| error | [string](#string) | | The error message if the query failed. |+++++++<a name="bytebase-v1-QueryRow"></a>++### QueryRow++++| Field | Type | Label | Description |+| ----- | ---- | ----- | ----------- |+| values | [string](#string) | repeated | Row values of the query result. |+++++++<a name="bytebase-v1-Advice-Status"></a>++### Advice.Status+++| Name | Number | Description |+| ---- | ------ | ----------- |+| STATUS_UNSPECIFIED | 0 | Unspecified. |+| SUCCESS | 1 | |+| WARNING | 2 | |+| ERROR | 3 | |++@@ -7009,6 +7118,7 @@ The sheet's `name` field is used to identify the sheet to update. Format: pr| Method Name | Request Type | Response Type | Description || ----------- | ------------ | ------------- | ------------|| Pretty | [PrettyRequest](#bytebase-v1-PrettyRequest) | [PrettyResponse](#bytebase-v1-PrettyResponse) | |+| Query | [QueryRequest](#bytebase-v1-QueryRequest) | [QueryResponse](#bytebase-v1-QueryResponse) | |diff --git a/proto/generated-go/v1/sql_service.pb.go b/proto/generated-go/v1/sql_service.pb.goindex 50e7d98311..13ce553db9 100644--- a/proto/generated-go/v1/sql_service.pb.go+++ b/proto/generated-go/v1/sql_service.pb.go@@ -21,6 +21,419 @@ const (_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20))+type Advice_Status int32++const (+ // Unspecified.+ Advice_STATUS_UNSPECIFIED Advice_Status = 0+ Advice_SUCCESS Advice_Status = 1+ Advice_WARNING Advice_Status = 2+ Advice_ERROR Advice_Status = 3+)++// Enum value maps for Advice_Status.+var (+ Advice_Status_name = map[int32]string{+ 0: "STATUS_UNSPECIFIED",+ 1: "SUCCESS",+ 2: "WARNING",+ 3: "ERROR",+ }+ Advice_Status_value = map[string]int32{+ "STATUS_UNSPECIFIED": 0,+ "SUCCESS": 1,+ "WARNING": 2,+ "ERROR": 3,+ }+)++func (x Advice_Status) Enum() *Advice_Status {+ p := new(Advice_Status)+ *p = x+ return p+}++func (x Advice_Status) String() string {+ return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))+}++func (Advice_Status) Descriptor() protoreflect.EnumDescriptor {+ return file_v1_sql_service_proto_enumTypes[0].Descriptor()+}++func (Advice_Status) Type() protoreflect.EnumType {+ return &file_v1_sql_service_proto_enumTypes[0]+}++func (x Advice_Status) Number() protoreflect.EnumNumber {+ return protoreflect.EnumNumber(x)+}++// Deprecated: Use Advice_Status.Descriptor instead.+func (Advice_Status) EnumDescriptor() ([]byte, []int) {+ return file_v1_sql_service_proto_rawDescGZIP(), []int{4, 0}+}++type QueryRequest struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ // The name is the instance name to execute the query against.+ // Format: instances/{instance}+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`+ // The connection database name to execute the query against.+ // For PostgreSQL, it's required.+ // For other database engines, it's optional. Use empty string to execute against without specifying a database.+ ConnectionDatabase string `protobuf:"bytes,2,opt,name=connection_database,json=connectionDatabase,proto3" json:"connection_database,omitempty"`+ // The SQL statement to execute.+ Statement string `protobuf:"bytes,3,opt,name=statement,proto3" json:"statement,omitempty"`+ // The maximum number of rows to return.+ Limit int32 `protobuf:"varint,4,opt,name=limit,proto3" json:"limit,omitempty"`+}++func (x *QueryRequest) Reset() {+ *x = QueryRequest{}+ if protoimpl.UnsafeEnabled {+ mi := &file_v1_sql_service_proto_msgTypes[0]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *QueryRequest) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*QueryRequest) ProtoMessage() {}++func (x *QueryRequest) ProtoReflect() protoreflect.Message {+ mi := &file_v1_sql_service_proto_msgTypes[0]+ 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 QueryRequest.ProtoReflect.Descriptor instead.+func (*QueryRequest) Descriptor() ([]byte, []int) {+ return file_v1_sql_service_proto_rawDescGZIP(), []int{0}+}++func (x *QueryRequest) GetName() string {+ if x != nil {+ return x.Name+ }+ return ""+}++func (x *QueryRequest) GetConnectionDatabase() string {+ if x != nil {+ return x.ConnectionDatabase+ }+ return ""+}++func (x *QueryRequest) GetStatement() string {+ if x != nil {+ return x.Statement+ }+ return ""+}++func (x *QueryRequest) GetLimit() int32 {+ if x != nil {+ return x.Limit+ }+ return 0+}++type QueryResponse struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ // The query results.+ Results []*QueryResult `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"`+ // The query advices.+ Advices []*Advice `protobuf:"bytes,2,rep,name=advices,proto3" json:"advices,omitempty"`+}++func (x *QueryResponse) Reset() {+ *x = QueryResponse{}+ if protoimpl.UnsafeEnabled {+ mi := &file_v1_sql_service_proto_msgTypes[1]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *QueryResponse) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*QueryResponse) ProtoMessage() {}++func (x *QueryResponse) ProtoReflect() protoreflect.Message {+ mi := &file_v1_sql_service_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 QueryResponse.ProtoReflect.Descriptor instead.+func (*QueryResponse) Descriptor() ([]byte, []int) {+ return file_v1_sql_service_proto_rawDescGZIP(), []int{1}+}++func (x *QueryResponse) GetResults() []*QueryResult {+ if x != nil {+ return x.Results+ }+ return nil+}++func (x *QueryResponse) GetAdvices() []*Advice {+ if x != nil {+ return x.Advices+ }+ return nil+}++type QueryResult struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ // Column names of the query result.+ ColumnNames []string `protobuf:"bytes,1,rep,name=column_names,json=columnNames,proto3" json:"column_names,omitempty"`+ // Column types of the query result.+ ColumnTypeNames []string `protobuf:"bytes,2,rep,name=column_type_names,json=columnTypeNames,proto3" json:"column_type_names,omitempty"`+ // Rows of the query result.+ Rows []*QueryRow `protobuf:"bytes,3,rep,name=rows,proto3" json:"rows,omitempty"`+ // Columns are masked or not.+ Masked []bool `protobuf:"varint,4,rep,packed,name=masked,proto3" json:"masked,omitempty"`+ // The error message if the query failed.+ Error string `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty"`+}++func (x *QueryResult) Reset() {+ *x = QueryResult{}+ if protoimpl.UnsafeEnabled {+ mi := &file_v1_sql_service_proto_msgTypes[2]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *QueryResult) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*QueryResult) ProtoMessage() {}++func (x *QueryResult) ProtoReflect() protoreflect.Message {+ mi := &file_v1_sql_service_proto_msgTypes[2]+ 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 QueryResult.ProtoReflect.Descriptor instead.+func (*QueryResult) Descriptor() ([]byte, []int) {+ return file_v1_sql_service_proto_rawDescGZIP(), []int{2}+}++func (x *QueryResult) GetColumnNames() []string {+ if x != nil {+ return x.ColumnNames+ }+ return nil+}++func (x *QueryResult) GetColumnTypeNames() []string {+ if x != nil {+ return x.ColumnTypeNames+ }+ return nil+}++func (x *QueryResult) GetRows() []*QueryRow {+ if x != nil {+ return x.Rows+ }+ return nil+}++func (x *QueryResult) GetMasked() []bool {+ if x != nil {+ return x.Masked+ }+ return nil+}++func (x *QueryResult) GetError() string {+ if x != nil {+ return x.Error+ }+ return ""+}++type QueryRow struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ // Row values of the query result.+ Values []string `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"`+}++func (x *QueryRow) Reset() {+ *x = QueryRow{}+ if protoimpl.UnsafeEnabled {+ mi := &file_v1_sql_service_proto_msgTypes[3]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *QueryRow) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*QueryRow) ProtoMessage() {}++func (x *QueryRow) ProtoReflect() protoreflect.Message {+ mi := &file_v1_sql_service_proto_msgTypes[3]+ 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 QueryRow.ProtoReflect.Descriptor instead.+func (*QueryRow) Descriptor() ([]byte, []int) {+ return file_v1_sql_service_proto_rawDescGZIP(), []int{3}+}++func (x *QueryRow) GetValues() []string {+ if x != nil {+ return x.Values+ }+ return nil+}++type Advice struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ // The advice status.+ Status Advice_Status `protobuf:"varint,1,opt,name=status,proto3,enum=bytebase.v1.Advice_Status" json:"status,omitempty"`+ // The advice code.+ Code int32 `protobuf:"varint,2,opt,name=code,proto3" json:"code,omitempty"`+ // The advice title.+ Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"`+ // The advice content.+ Content string `protobuf:"bytes,4,opt,name=content,proto3" json:"content,omitempty"`+ // The advice line number in the SQL statement.+ Line int32 `protobuf:"varint,5,opt,name=line,proto3" json:"line,omitempty"`+ // The advice detail.+ Detail string `protobuf:"bytes,6,opt,name=detail,proto3" json:"detail,omitempty"`+}++func (x *Advice) Reset() {+ *x = Advice{}+ if protoimpl.UnsafeEnabled {+ mi := &file_v1_sql_service_proto_msgTypes[4]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *Advice) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*Advice) ProtoMessage() {}++func (x *Advice) ProtoReflect() protoreflect.Message {+ mi := &file_v1_sql_service_proto_msgTypes[4]+ 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 Advice.ProtoReflect.Descriptor instead.+func (*Advice) Descriptor() ([]byte, []int) {+ return file_v1_sql_service_proto_rawDescGZIP(), []int{4}+}++func (x *Advice) GetStatus() Advice_Status {+ if x != nil {+ return x.Status+ }+ return Advice_STATUS_UNSPECIFIED+}++func (x *Advice) GetCode() int32 {+ if x != nil {+ return x.Code+ }+ return 0+}++func (x *Advice) GetTitle() string {+ if x != nil {+ return x.Title+ }+ return ""+}++func (x *Advice) GetContent() string {+ if x != nil {+ return x.Content+ }+ return ""+}++func (x *Advice) GetLine() int32 {+ if x != nil {+ return x.Line+ }+ return 0+}++func (x *Advice) GetDetail() string {+ if x != nil {+ return x.Detail+ }+ return ""+}+type PrettyRequest struct {state protoimpl.MessageStatesizeCache protoimpl.SizeCache@@ -37,7 +450,7 @@ type PrettyRequest struct {func (x *PrettyRequest) Reset() {*x = PrettyRequest{}if protoimpl.UnsafeEnabled {- mi := &file_v1_sql_service_proto_msgTypes[0]+ mi := &file_v1_sql_service_proto_msgTypes[5]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -50,7 +463,7 @@ func (x *PrettyRequest) String() string {func (*PrettyRequest) ProtoMessage() {}func (x *PrettyRequest) ProtoReflect() protoreflect.Message {- mi := &file_v1_sql_service_proto_msgTypes[0]+ mi := &file_v1_sql_service_proto_msgTypes[5]if protoimpl.UnsafeEnabled && x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -63,7 +476,7 @@ func (x *PrettyRequest) ProtoReflect() protoreflect.Message {// Deprecated: Use PrettyRequest.ProtoReflect.Descriptor instead.func (*PrettyRequest) Descriptor() ([]byte, []int) {- return file_v1_sql_service_proto_rawDescGZIP(), []int{0}+ return file_v1_sql_service_proto_rawDescGZIP(), []int{5}}func (x *PrettyRequest) GetEngine() Engine {@@ -101,7 +514,7 @@ type PrettyResponse struct {func (x *PrettyResponse) Reset() {*x = PrettyResponse{}if protoimpl.UnsafeEnabled {- mi := &file_v1_sql_service_proto_msgTypes[1]+ mi := &file_v1_sql_service_proto_msgTypes[6]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -114,7 +527,7 @@ func (x *PrettyResponse) String() string {func (*PrettyResponse) ProtoMessage() {}func (x *PrettyResponse) ProtoReflect() protoreflect.Message {- mi := &file_v1_sql_service_proto_msgTypes[1]+ mi := &file_v1_sql_service_proto_msgTypes[6]if protoimpl.UnsafeEnabled && x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -127,7 +540,7 @@ func (x *PrettyResponse) ProtoReflect() protoreflect.Message {// Deprecated: Use PrettyResponse.ProtoReflect.Descriptor instead.func (*PrettyResponse) Descriptor() ([]byte, []int) {- return file_v1_sql_service_proto_rawDescGZIP(), []int{1}+ return file_v1_sql_service_proto_rawDescGZIP(), []int{6}}func (x *PrettyResponse) GetCurrentSchema() string {@@ -151,29 +564,83 @@ var file_v1_sql_service_proto_rawDesc = []byte{0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65,0x2e, 0x76, 0x31, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f,0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74,- 0x6f, 0x1a, 0x0f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f,- 0x74, 0x6f, 0x22, 0x8c, 0x01, 0x0a, 0x0d, 0x50, 0x72, 0x65, 0x74, 0x74, 0x79, 0x52, 0x65, 0x71,- 0x75, 0x65, 0x73, 0x74, 0x12, 0x2b, 0x0a, 0x06, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x18, 0x01,- 0x20, 0x01, 0x28, 0x0e, 0x32, 0x13, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,- 0x76, 0x31, 0x2e, 0x45, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x52, 0x06, 0x65, 0x6e, 0x67, 0x69, 0x6e,- 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x63, 0x68,- 0x65, 0x6d, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x75, 0x72, 0x72, 0x65,- 0x6e, 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, 0x03, 0x20, 0x01, 0x28,- 0x09, 0x52, 0x0e, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d,- 0x61, 0x22, 0x60, 0x0a, 0x0e, 0x50, 0x72, 0x65, 0x74, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f,- 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x73,- 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x75, 0x72,- 0x72, 0x65, 0x6e, 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, 0x32, 0x6a, 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, 0x42,+ 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x66, 0x69,+ 0x65, 0x6c, 0x64, 0x5f, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f,+ 0x74, 0x6f, 0x1a, 0x0f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72,+ 0x6f, 0x74, 0x6f, 0x22, 0x8c, 0x01, 0x0a, 0x0c, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71,+ 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01,+ 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2f, 0x0a,+ 0x13, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x64, 0x61, 0x74, 0x61,+ 0x62, 0x61, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x63, 0x6f, 0x6e, 0x6e,+ 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x1c,+ 0x0a, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28,+ 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05,+ 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x69, 0x6d,+ 0x69, 0x74, 0x22, 0x72, 0x0a, 0x0d, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f,+ 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x01,+ 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,+ 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x07,+ 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x12, 0x2d, 0x0a, 0x07, 0x61, 0x64, 0x76, 0x69, 0x63,+ 0x65, 0x73, 0x18, 0x02, 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, 0x22, 0xb5, 0x01, 0x0a, 0x0b, 0x51, 0x75, 0x65, 0x72, 0x79,+ 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e,+ 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f,+ 0x6c, 0x75, 0x6d, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x2a, 0x0a, 0x11, 0x63, 0x6f, 0x6c,+ 0x75, 0x6d, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x02,+ 0x20, 0x03, 0x28, 0x09, 0x52, 0x0f, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x54, 0x79, 0x70, 0x65,+ 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x29, 0x0a, 0x04, 0x72, 0x6f, 0x77, 0x73, 0x18, 0x03, 0x20,+ 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76,+ 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x6f, 0x77, 0x52, 0x04, 0x72, 0x6f, 0x77, 0x73,+ 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x61, 0x73, 0x6b, 0x65, 0x64, 0x18, 0x04, 0x20, 0x03, 0x28, 0x08,+ 0x52, 0x06, 0x6d, 0x61, 0x73, 0x6b, 0x65, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f,+ 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x22,+ 0x0a, 0x08, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x6f, 0x77, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x61,+ 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75,+ 0x65, 0x73, 0x22, 0xf3, 0x01, 0x0a, 0x06, 0x41, 0x64, 0x76, 0x69, 0x63, 0x65, 0x12, 0x32, 0x0a,+ 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e,+ 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x64, 0x76, 0x69,+ 0x63, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75,+ 0x73, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52,+ 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x03,+ 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63,+ 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f,+ 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x05, 0x20,+ 0x01, 0x28, 0x05, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x65, 0x74,+ 0x61, 0x69, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x65, 0x74, 0x61, 0x69,+ 0x6c, 0x22, 0x45, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x12, 0x53,+ 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45,+ 0x44, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, 0x01,+ 0x12, 0x0b, 0x0a, 0x07, 0x57, 0x41, 0x52, 0x4e, 0x49, 0x4e, 0x47, 0x10, 0x02, 0x12, 0x09, 0x0a,+ 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x03, 0x22, 0x8c, 0x01, 0x0a, 0x0d, 0x50, 0x72, 0x65,+ 0x74, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2b, 0x0a, 0x06, 0x65, 0x6e,+ 0x67, 0x69, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x13, 0x2e, 0x62, 0x79, 0x74,+ 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x52,+ 0x06, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x63, 0x75, 0x72, 0x72, 0x65,+ 0x6e, 0x74, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,+ 0x0d, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 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, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65,+ 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x22, 0x60, 0x0a, 0x0e, 0x50, 0x72, 0x65, 0x74, 0x74,+ 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x63, 0x75, 0x72,+ 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28,+ 0x09, 0x52, 0x0d, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 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, 0x32, 0xd3, 0x01, 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, 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,}@@ -190,21 +657,34 @@ func file_v1_sql_service_proto_rawDescGZIP() []byte {return file_v1_sql_service_proto_rawDescData}-var file_v1_sql_service_proto_msgTypes = make([]protoimpl.MessageInfo, 2)+var file_v1_sql_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1)+var file_v1_sql_service_proto_msgTypes = make([]protoimpl.MessageInfo, 7)var file_v1_sql_service_proto_goTypes = []interface{}{- (*PrettyRequest)(nil), // 0: bytebase.v1.PrettyRequest- (*PrettyResponse)(nil), // 1: bytebase.v1.PrettyResponse- (Engine)(0), // 2: bytebase.v1.Engine+ (Advice_Status)(0), // 0: bytebase.v1.Advice.Status+ (*QueryRequest)(nil), // 1: bytebase.v1.QueryRequest+ (*QueryResponse)(nil), // 2: bytebase.v1.QueryResponse+ (*QueryResult)(nil), // 3: bytebase.v1.QueryResult+ (*QueryRow)(nil), // 4: bytebase.v1.QueryRow+ (*Advice)(nil), // 5: bytebase.v1.Advice+ (*PrettyRequest)(nil), // 6: bytebase.v1.PrettyRequest+ (*PrettyResponse)(nil), // 7: bytebase.v1.PrettyResponse+ (Engine)(0), // 8: bytebase.v1.Engine}var file_v1_sql_service_proto_depIdxs = []int32{- 2, // 0: bytebase.v1.PrettyRequest.engine:type_name -> bytebase.v1.Engine- 0, // 1: bytebase.v1.SQLService.Pretty:input_type -> bytebase.v1.PrettyRequest- 1, // 2: bytebase.v1.SQLService.Pretty:output_type -> bytebase.v1.PrettyResponse- 2, // [2:3] is the sub-list for method output_type- 1, // [1:2] is the sub-list for method input_type- 1, // [1:1] is the sub-list for extension type_name- 1, // [1:1] is the sub-list for extension extendee- 0, // [0:1] is the sub-list for field type_name+ 3, // 0: bytebase.v1.QueryResponse.results:type_name -> bytebase.v1.QueryResult+ 5, // 1: bytebase.v1.QueryResponse.advices:type_name -> bytebase.v1.Advice+ 4, // 2: bytebase.v1.QueryResult.rows:type_name -> bytebase.v1.QueryRow+ 0, // 3: bytebase.v1.Advice.status:type_name -> bytebase.v1.Advice.Status+ 8, // 4: bytebase.v1.PrettyRequest.engine:type_name -> bytebase.v1.Engine+ 6, // 5: bytebase.v1.SQLService.Pretty:input_type -> bytebase.v1.PrettyRequest+ 1, // 6: bytebase.v1.SQLService.Query:input_type -> bytebase.v1.QueryRequest+ 7, // 7: bytebase.v1.SQLService.Pretty:output_type -> bytebase.v1.PrettyResponse+ 2, // 8: bytebase.v1.SQLService.Query:output_type -> bytebase.v1.QueryResponse+ 7, // [7:9] is the sub-list for method output_type+ 5, // [5:7] is the sub-list for method input_type+ 5, // [5:5] is the sub-list for extension type_name+ 5, // [5:5] is the sub-list for extension extendee+ 0, // [0:5] is the sub-list for field type_name}func init() { file_v1_sql_service_proto_init() }@@ -215,7 +695,7 @@ func file_v1_sql_service_proto_init() {file_v1_common_proto_init()if !protoimpl.UnsafeEnabled {file_v1_sql_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {- switch v := v.(*PrettyRequest); i {+ switch v := v.(*QueryRequest); i {case 0:return &v.statecase 1:@@ -227,6 +707,66 @@ func file_v1_sql_service_proto_init() {}}file_v1_sql_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*QueryResponse); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ file_v1_sql_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*QueryResult); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ file_v1_sql_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*QueryRow); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ file_v1_sql_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*Advice); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ file_v1_sql_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*PrettyRequest); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ file_v1_sql_service_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {switch v := v.(*PrettyResponse); i {case 0:return &v.state@@ -244,13 +784,14 @@ func file_v1_sql_service_proto_init() {File: protoimpl.DescBuilder{GoPackagePath: reflect.TypeOf(x{}).PkgPath(),RawDescriptor: file_v1_sql_service_proto_rawDesc,- NumEnums: 0,- NumMessages: 2,+ NumEnums: 1,+ NumMessages: 7,NumExtensions: 0,NumServices: 1,},GoTypes: file_v1_sql_service_proto_goTypes,DependencyIndexes: file_v1_sql_service_proto_depIdxs,+ EnumInfos: file_v1_sql_service_proto_enumTypes,MessageInfos: file_v1_sql_service_proto_msgTypes,}.Build()File_v1_sql_service_proto = out.Filediff --git a/proto/generated-go/v1/sql_service.pb.gw.go b/proto/generated-go/v1/sql_service.pb.gw.goindex 98e37edd89..8c4d75e057 100644--- a/proto/generated-go/v1/sql_service.pb.gw.go+++ b/proto/generated-go/v1/sql_service.pb.gw.go@@ -65,6 +65,74 @@ func local_request_SQLService_Pretty_0(ctx context.Context, marshaler runtime.Ma}+func request_SQLService_Query_0(ctx context.Context, marshaler runtime.Marshaler, client SQLServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq QueryRequest+ var metadata runtime.ServerMetadata++ newReader, berr := utilities.IOReaderFactory(req.Body)+ if berr != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)+ }+ if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }++ var (+ val string+ ok bool+ err error+ _ = err+ )++ val, ok = pathParams["name"]+ if !ok {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")+ }++ protoReq.Name, err = runtime.String(val)+ if err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)+ }++ msg, err := client.Query(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))+ return msg, metadata, err++}++func local_request_SQLService_Query_0(ctx context.Context, marshaler runtime.Marshaler, server SQLServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq QueryRequest+ var metadata runtime.ServerMetadata++ newReader, berr := utilities.IOReaderFactory(req.Body)+ if berr != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)+ }+ if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }++ var (+ val string+ ok bool+ err error+ _ = err+ )++ val, ok = pathParams["name"]+ if !ok {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")+ }++ protoReq.Name, err = runtime.String(val)+ if err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)+ }++ msg, err := server.Query(ctx, &protoReq)+ return msg, metadata, err++}+// RegisterSQLServiceHandlerServer registers the http handlers for service SQLService to "mux".// UnaryRPC :call SQLServiceServer directly.// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.@@ -96,6 +164,31 @@ func RegisterSQLServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux,})+ mux.Handle("POST", pattern_SQLService_Query_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ var stream runtime.ServerTransportStream+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ var err error+ var annotatedContext context.Context+ annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.SQLService/Query", runtime.WithHTTPPathPattern("/v1/{name=instances/*}:query"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := local_request_SQLService_Query_0(annotatedContext, inboundMarshaler, server, req, pathParams)+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_SQLService_Query_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })+return nil}@@ -159,13 +252,39 @@ func RegisterSQLServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux,})+ mux.Handle("POST", pattern_SQLService_Query_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ var err error+ var annotatedContext context.Context+ annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.SQLService/Query", runtime.WithHTTPPathPattern("/v1/{name=instances/*}:query"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := request_SQLService_Query_0(annotatedContext, inboundMarshaler, client, req, pathParams)+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_SQLService_Query_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })+return nil}var (pattern_SQLService_Pretty_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "sql", "pretty"}, ""))++ pattern_SQLService_Query_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "instances", "name"}, "query")))var (forward_SQLService_Pretty_0 = runtime.ForwardResponseMessage++ forward_SQLService_Query_0 = runtime.ForwardResponseMessage)diff --git a/proto/generated-go/v1/sql_service_grpc.pb.go b/proto/generated-go/v1/sql_service_grpc.pb.goindex f48cda74e5..59f0ab97ac 100644--- a/proto/generated-go/v1/sql_service_grpc.pb.go+++ b/proto/generated-go/v1/sql_service_grpc.pb.go@@ -20,6 +20,7 @@ const _ = grpc.SupportPackageIsVersion7const (SQLService_Pretty_FullMethodName = "/bytebase.v1.SQLService/Pretty"+ SQLService_Query_FullMethodName = "/bytebase.v1.SQLService/Query")// SQLServiceClient is the client API for SQLService service.@@ -27,6 +28,7 @@ const (// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.type SQLServiceClient interface {Pretty(ctx context.Context, in *PrettyRequest, opts ...grpc.CallOption) (*PrettyResponse, error)+ Query(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error)}type sQLServiceClient struct {@@ -46,11 +48,21 @@ func (c *sQLServiceClient) Pretty(ctx context.Context, in *PrettyRequest, opts .return out, nil}+func (c *sQLServiceClient) Query(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error) {+ out := new(QueryResponse)+ err := c.cc.Invoke(ctx, SQLService_Query_FullMethodName, in, out, opts...)+ if err != nil {+ return nil, err+ }+ return out, nil+}+// SQLServiceServer is the server API for SQLService service.// All implementations must embed UnimplementedSQLServiceServer// for forward compatibilitytype SQLServiceServer interface {Pretty(context.Context, *PrettyRequest) (*PrettyResponse, error)+ Query(context.Context, *QueryRequest) (*QueryResponse, error)mustEmbedUnimplementedSQLServiceServer()}@@ -61,6 +73,9 @@ type UnimplementedSQLServiceServer struct {func (UnimplementedSQLServiceServer) Pretty(context.Context, *PrettyRequest) (*PrettyResponse, error) {return nil, status.Errorf(codes.Unimplemented, "method Pretty not implemented")}+func (UnimplementedSQLServiceServer) Query(context.Context, *QueryRequest) (*QueryResponse, error) {+ return nil, status.Errorf(codes.Unimplemented, "method Query not implemented")+}func (UnimplementedSQLServiceServer) mustEmbedUnimplementedSQLServiceServer() {}// UnsafeSQLServiceServer may be embedded to opt out of forward compatibility for this service.@@ -92,6 +107,24 @@ func _SQLService_Pretty_Handler(srv interface{}, ctx context.Context, dec func(ireturn interceptor(ctx, in, info, handler)}+func _SQLService_Query_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {+ in := new(QueryRequest)+ if err := dec(in); err != nil {+ return nil, err+ }+ if interceptor == nil {+ return srv.(SQLServiceServer).Query(ctx, in)+ }+ info := &grpc.UnaryServerInfo{+ Server: srv,+ FullMethod: SQLService_Query_FullMethodName,+ }+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {+ return srv.(SQLServiceServer).Query(ctx, req.(*QueryRequest))+ }+ return interceptor(ctx, in, info, handler)+}+// SQLService_ServiceDesc is the grpc.ServiceDesc for SQLService service.// It's only intended for direct use with grpc.RegisterService,// and not to be introspected or modified (even as a copy)@@ -103,6 +136,10 @@ var SQLService_ServiceDesc = grpc.ServiceDesc{MethodName: "Pretty",Handler: _SQLService_Pretty_Handler,},+ {+ MethodName: "Query",+ Handler: _SQLService_Query_Handler,+ },},Streams: []grpc.StreamDesc{},Metadata: "v1/sql_service.proto",diff --git a/proto/v1/sql_service.proto b/proto/v1/sql_service.protoindex 578ce64c01..7f16631f11 100644--- a/proto/v1/sql_service.proto+++ b/proto/v1/sql_service.proto@@ -3,6 +3,7 @@ syntax = "proto3";package bytebase.v1;import "google/api/annotations.proto";+import "google/api/field_behavior.proto";import "v1/common.proto";option go_package = "generated-go/v1";@@ -14,6 +15,86 @@ service SQLService {body: "*"};}+ rpc Query(QueryRequest) returns (QueryResponse) {+ option (google.api.http) = {+ post: "/v1/{name=instances/*}:query"+ body: "*"+ };+ }+}++message QueryRequest {+ // The name is the instance name to execute the query against.+ // Format: instances/{instance}+ string name = 1 [(google.api.field_behavior) = REQUIRED];++ // The connection database name to execute the query against.+ // For PostgreSQL, it's required.+ // For other database engines, it's optional. Use empty string to execute against without specifying a database.+ string connection_database = 2;++ // The SQL statement to execute.+ string statement = 3;++ // The maximum number of rows to return.+ int32 limit = 4;+}++message QueryResponse {+ // The query results.+ repeated QueryResult results = 1;++ // The query advices.+ repeated Advice advices = 2;+}++message QueryResult {+ // Column names of the query result.+ repeated string column_names = 1;++ // Column types of the query result.+ repeated string column_type_names = 2;++ // Rows of the query result.+ repeated QueryRow rows = 3;++ // Columns are masked or not.+ repeated bool masked = 4;++ // The error message if the query failed.+ string error = 5;+}++message QueryRow {+ // Row values of the query result.+ repeated string values = 1;+}++message Advice {+ enum Status {+ // Unspecified.+ STATUS_UNSPECIFIED = 0;+ SUCCESS = 1;+ WARNING = 2;+ ERROR = 3;+ }+ // The advice status.+ Status status = 1;++ // The advice code.+ int32 code = 2;++ // The advice title.+ string title = 3;++ // The advice content.+ string content = 4;++ // The advice line number in the SQL statement.+ int32 line = 5;++ // The advice detail.+ string detail = 6;}message PrettyRequest {