Skip to content

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

refactor: get metadata string (#15514)

rebelice30fefc946df8
diff --git a/backend/api/v1/setting_service.go b/backend/api/v1/setting_service.go
index 1dc4b815fb..35a7a2d60d 100644
--- a/backend/api/v1/setting_service.go
+++ b/backend/api/v1/setting_service.go
@@ -901,7 +901,7 @@ func validateTableMetadata(engine v1pb.Engine, tableMetadata *v1pb.TableMetadata
if err := checkDatabaseMetadata(storepb.Engine(engine), tempStoreSchemaMetadata); err != nil {
return errors.Wrap(err, "failed to check database metadata")
}
- if _, err := schema.GetDesignSchema(storepb.Engine(engine), tempStoreSchemaMetadata); err != nil {
+ if _, err := schema.GetDatabaseDefinition(storepb.Engine(engine), schema.GetDefinitionContext{}, tempStoreSchemaMetadata); err != nil {
return errors.Wrap(err, "failed to transform database metadata to schema string")
}
return nil
diff --git a/backend/api/v1/sql_service.go b/backend/api/v1/sql_service.go
index 6950c38cb0..0478feca78 100644
--- a/backend/api/v1/sql_service.go
+++ b/backend/api/v1/sql_service.go
@@ -1652,58 +1652,6 @@ func (*SQLService) ParseMyBatisMapper(_ context.Context, request *v1pb.ParseMyBa
}, nil
}
-// StringifyMetadata returns the stringified schema of the given metadata.
-func (*SQLService) StringifyMetadata(_ context.Context, request *v1pb.StringifyMetadataRequest) (*v1pb.StringifyMetadataResponse, error) {
- switch request.Engine {
- case v1pb.Engine_MYSQL, v1pb.Engine_OCEANBASE, v1pb.Engine_POSTGRES, v1pb.Engine_TIDB, v1pb.Engine_ORACLE, v1pb.Engine_REDSHIFT, v1pb.Engine_CLICKHOUSE:
- default:
- return nil, status.Errorf(codes.InvalidArgument, "unsupported engine: %v", request.Engine)
- }
-
- if request.Metadata == nil {
- return nil, status.Errorf(codes.InvalidArgument, "metadata is required")
- }
- storeSchemaMetadata, err := convertV1DatabaseMetadata(request.Metadata)
- if err != nil {
- return nil, err
- }
-
- if !request.ClassificationFromConfig {
- if request.Catalog == nil {
- return nil, status.Errorf(codes.InvalidArgument, "database catalog is required")
- }
- config := convertDatabaseCatalog(request.GetCatalog())
- sanitizeCommentForSchemaMetadata(storeSchemaMetadata, model.NewDatabaseConfig(config), request.ClassificationFromConfig)
- }
-
- if request.Engine == v1pb.Engine_MYSQL && isSingleTable(storeSchemaMetadata) {
- table := storeSchemaMetadata.Schemas[0].Tables[0]
- schema, err := schema.StringifyTable(storepb.Engine(request.Engine), table)
- if err != nil {
- return nil, status.Errorf(codes.Internal, "failed to stringify table: %v", err)
- }
- return &v1pb.StringifyMetadataResponse{
- Schema: schema,
- }, nil
- }
-
- schema, err := schema.GetDesignSchema(storepb.Engine(request.Engine), storeSchemaMetadata)
- if err != nil {
- return nil, err
- }
-
- if request.Engine == v1pb.Engine_ORACLE {
- schema, err = appendComments(schema, storeSchemaMetadata)
- if err != nil {
- return nil, status.Errorf(codes.Internal, "failed to append comments: %v", err)
- }
- }
-
- return &v1pb.StringifyMetadataResponse{
- Schema: schema,
- }, nil
-}
-
func (*SQLService) DiffMetadata(_ context.Context, request *v1pb.DiffMetadataRequest) (*v1pb.DiffMetadataResponse, error) {
switch request.Engine {
case v1pb.Engine_MYSQL, v1pb.Engine_POSTGRES, v1pb.Engine_TIDB, v1pb.Engine_ORACLE:
@@ -1736,11 +1684,17 @@ func (*SQLService) DiffMetadata(_ context.Context, request *v1pb.DiffMetadataReq
return nil, status.Errorf(codes.InvalidArgument, "invalid target metadata: %v", err)
}
- sourceSchema, err := schema.GetDesignSchema(storepb.Engine(request.Engine), storeSourceMetadata)
+ sourceSchema, err := schema.GetDatabaseDefinition(storepb.Engine(request.Engine), schema.GetDefinitionContext{
+ SkipBackupSchema: false,
+ PrintHeader: true,
+ }, storeSourceMetadata)
if err != nil {
return nil, err
}
- targetSchema, err := schema.GetDesignSchema(storepb.Engine(request.Engine), storeTargetMetadata)
+ targetSchema, err := schema.GetDatabaseDefinition(storepb.Engine(request.Engine), schema.GetDefinitionContext{
+ SkipBackupSchema: false,
+ PrintHeader: true,
+ }, storeTargetMetadata)
if err != nil {
return nil, err
}
@@ -1780,61 +1734,6 @@ func sanitizeCommentForSchemaMetadata(dbSchema *storepb.DatabaseSchemaMetadata,
}
}
-func appendComments(schema string, storeSchemaMetadata *storepb.DatabaseSchemaMetadata) (string, error) {
- if !isSingleTable(storeSchemaMetadata) {
- return schema, nil
- }
-
- schemaName := storeSchemaMetadata.Schemas[0].Name
- table := storeSchemaMetadata.Schemas[0].Tables[0]
- // Append comments to the schema.
- comments, err := getComments(schemaName, table)
- if err != nil {
- return "", err
- }
- return schema + comments, nil
-}
-
-func getComments(schemaName string, table *storepb.TableMetadata) (string, error) {
- var buf strings.Builder
- if table.Comment != "" {
- if _, err := fmt.Fprintf(&buf, "COMMENT ON TABLE \"%s\".\"%s\" IS '%s';\n", schemaName, table.Name, table.Comment); err != nil {
- return "", err
- }
- }
- for _, column := range table.Columns {
- if column.Comment != "" {
- if _, err := fmt.Fprintf(&buf, "COMMENT ON COLUMN \"%s\".\"%s\".\"%s\" IS '%s';\n", schemaName, table.Name, column.Name, column.Comment); err != nil {
- return "", err
- }
- }
- }
- return buf.String(), nil
-}
-
-func isSingleTable(storeSchemaMetadata *storepb.DatabaseSchemaMetadata) bool {
- if len(storeSchemaMetadata.Schemas) != 1 {
- return false
- }
-
- if len(storeSchemaMetadata.Schemas[0].Tables) != 1 {
- return false
- }
-
- if len(storeSchemaMetadata.Schemas[0].ExternalTables)+
- len(storeSchemaMetadata.Schemas[0].Views)+
- len(storeSchemaMetadata.Schemas[0].MaterializedViews)+
- len(storeSchemaMetadata.Schemas[0].Functions)+
- len(storeSchemaMetadata.Schemas[0].Procedures)+
- len(storeSchemaMetadata.Schemas[0].Sequences)+
- len(storeSchemaMetadata.Schemas[0].Streams)+
- len(storeSchemaMetadata.Schemas[0].Tasks) != 0 {
- return false
- }
-
- return true
-}
-
// Pretty returns pretty format SDL.
func (*SQLService) Pretty(_ context.Context, request *v1pb.PrettyRequest) (*v1pb.PrettyResponse, error) {
engine := convertEngine(request.Engine)
diff --git a/backend/plugin/schema/clickhouse/get_design_schema.go b/backend/plugin/schema/clickhouse/get_design_schema.go
deleted file mode 100644
index 56b237606b..0000000000
--- a/backend/plugin/schema/clickhouse/get_design_schema.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package clickhouse
-
-import (
- "strings"
-
- "github.com/bytebase/bytebase/backend/plugin/schema"
- storepb "github.com/bytebase/bytebase/proto/generated-go/store"
-)
-
-func init() {
- schema.RegisterGetDesignSchema(storepb.Engine_CLICKHOUSE, GetDesignSchema)
-}
-
-func GetDesignSchema(to *storepb.DatabaseSchemaMetadata) (string, error) {
- toState := convertToDatabaseState(to)
-
- var sb strings.Builder
-
- if err := writeTables(&sb, to, toState); err != nil {
- return "", err
- }
- if err := writeViews(&sb, to, toState); err != nil {
- return "", err
- }
-
- s := sb.String()
- // Make goyamlv3 happy.
- s = strings.TrimLeft(s, "\n")
- return s, nil
-}
diff --git a/backend/plugin/schema/mysql/get_database_definition.go b/backend/plugin/schema/mysql/get_database_definition.go
index fb221dc3b7..e5df05ebd8 100644
--- a/backend/plugin/schema/mysql/get_database_definition.go
+++ b/backend/plugin/schema/mysql/get_database_definition.go
@@ -31,6 +31,21 @@ const (
setTimezone = "SET time_zone = "
delimiterDoubleSemi = "DELIMITER ;;\n"
delimiterSemi = "DELIMITER ;\n"
+
+ mysqlTypeBlob = "blob"
+ mysqlTypeTinyBob = "tinyblob"
+ mysqlTypeMediumBlob = "mediumblob"
+ mysqlTypeLongBlob = "longblob"
+ mysqlTypeJSON = "json"
+ mysqlTypeGeometry = "geometry"
+
+ mysqlIndexFullText = "FULLTEXT"
+ mysqlIndexSpatial = "SPATIAL"
+
+ mysqlNoAction = "NO ACTION"
+
+ autoIncrementSymbol = "AUTO_INCREMENT"
+ autoRandSymbol = "AUTO_RANDOM"
)
func init() {
@@ -836,6 +851,56 @@ func printPartitionClause(buf *strings.Builder, partitions []*storepb.TableParti
return nil
}
+func getPrepositionByType(tp storepb.TablePartitionMetadata_Type) (string, error) {
+ switch tp {
+ case storepb.TablePartitionMetadata_RANGE:
+ return "LESS THAN", nil
+ case storepb.TablePartitionMetadata_RANGE_COLUMNS:
+ return "LESS THAN", nil
+ case storepb.TablePartitionMetadata_LIST:
+ return "IN", nil
+ case storepb.TablePartitionMetadata_LIST_COLUMNS:
+ return "IN", nil
+ case storepb.TablePartitionMetadata_HASH, storepb.TablePartitionMetadata_KEY, storepb.TablePartitionMetadata_LINEAR_HASH, storepb.TablePartitionMetadata_LINEAR_KEY:
+ return "", nil
+ default:
+ return "", errors.Errorf("unsupported partition type: %v", tp)
+ }
+}
+
+func writePartitionOptions(buf io.StringWriter) error {
+ /*
+ int err = 0;
+ err += add_space(fptr);
+ if (p_elem->tablespace_name) {
+ err += add_string(fptr, "TABLESPACE = ");
+ err += add_ident_string(fptr, p_elem->tablespace_name);
+ err += add_space(fptr);
+ }
+ if (p_elem->nodegroup_id != UNDEF_NODEGROUP)
+ err += add_keyword_int(fptr, "NODEGROUP", (longlong)p_elem->nodegroup_id);
+ if (p_elem->part_max_rows)
+ err += add_keyword_int(fptr, "MAX_ROWS", (longlong)p_elem->part_max_rows);
+ if (p_elem->part_min_rows)
+ err += add_keyword_int(fptr, "MIN_ROWS", (longlong)p_elem->part_min_rows);
+ if (!(current_thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE)) {
+ if (p_elem->data_file_name)
+ err += add_keyword_path(fptr, "DATA DIRECTORY", p_elem->data_file_name);
+ if (p_elem->index_file_name)
+ err += add_keyword_path(fptr, "INDEX DIRECTORY", p_elem->index_file_name);
+ }
+ if (p_elem->part_comment)
+ err += add_keyword_string(fptr, "COMMENT", true, p_elem->part_comment);
+ return err + add_engine(fptr, p_elem->engine_type);
+ */
+ // TODO(zp): Get all the partition options from the metadata is too complex, just write ENGINE=InnoDB for now.
+ if _, err := buf.WriteString(" ENGINE=InnoDB"); err != nil {
+ return err
+ }
+
+ return nil
+}
+
func getVersionSpecificComment(partitions []*storepb.TablePartitionMetadata) string {
if len(partitions) == 0 {
return ""
diff --git a/backend/plugin/schema/mysql/get_design_schema.go b/backend/plugin/schema/mysql/get_design_schema.go
deleted file mode 100644
index 028114db38..0000000000
--- a/backend/plugin/schema/mysql/get_design_schema.go
+++ /dev/null
@@ -1,190 +0,0 @@
-package mysql
-
-import (
- "fmt"
- "io"
- "log/slog"
- "strings"
-
- mysqlparser "github.com/bytebase/bytebase/backend/plugin/parser/mysql"
- "github.com/bytebase/bytebase/backend/plugin/schema"
- storepb "github.com/bytebase/bytebase/proto/generated-go/store"
-)
-
-func init() {
- schema.RegisterGetDesignSchema(storepb.Engine_MYSQL, GetDesignSchema)
- schema.RegisterGetDesignSchema(storepb.Engine_OCEANBASE, GetDesignSchema)
-}
-
-func GetDesignSchema(to *storepb.DatabaseSchemaMetadata) (string, error) {
- toState := convertToDatabaseState(to)
-
- var sb strings.Builder
-
- if err := writeTables(&sb, to, toState); err != nil {
- return "", err
- }
-
- if err := writeViews(&sb, to, toState); err != nil {
- return "", err
- }
-
- if err := writeFunctions(&sb, to, toState); err != nil {
- return "", err
- }
-
- if err := writeProcedures(&sb, to, toState); err != nil {
- return "", err
- }
-
- s := sb.String()
- // Make goyamlv3 happy.
- s = strings.TrimLeft(s, "\n")
- result, err := mysqlparser.RestoreDelimiter(s)
- if err != nil {
- slog.Warn("Failed to restore delimiter", slog.String("result", s), slog.String("error", err.Error()))
- return s, nil
- }
- return result, nil
-}
-
-func writeTables(w io.StringWriter, to *storepb.DatabaseSchemaMetadata, state *databaseState) error {
- // Follow the order of the input schemas.
- for _, schema := range to.Schemas {
- schemaState, ok := state.schemas[schema.Name]
- if !ok {
- continue
- }
- // Follow the order of the input tables.
- for _, table := range schema.Tables {
- table, ok := schemaState.tables[table.Name]
- if !ok {
- continue
- }
- if _, err := w.WriteString(getTableAnnouncement(table.name)); err != nil {
- return err
- }
-
- // Avoid new line.
- buf := &strings.Builder{}
- if err := table.toString(buf); err != nil {
- return err
- }
- if _, err := w.WriteString(buf.String()); err != nil {
- return err
- }
- delete(schemaState.tables, table.name)
- }
- }
- return nil
-}
-
-func writeViews(w io.StringWriter, to *storepb.DatabaseSchemaMetadata, state *databaseState) error {
- // Follow the order of the input schemas.
- for _, schema := range to.Schemas {
- schemaState, ok := state.schemas[schema.Name]
- if !ok {
- continue
- }
- // Follow the order of the input views.
- for _, view := range schema.Views {
- _, handled := schemaState.handledViews[view.Name]
- if handled {
- continue
- }
- view, ok := schemaState.views[view.Name]
- if !ok {
- continue
- }
- if _, err := w.WriteString(getViewAnnouncement(view.name)); err != nil {
- return err
- }
-
- buf := &strings.Builder{}
- if err := view.toString(buf); err != nil {
- return err
- }
- if _, err := w.WriteString(buf.String()); err != nil {
- return err
- }
- delete(schemaState.views, view.name)
- }
- }
- return nil
-}
-
-func writeProcedures(w io.StringWriter, to *storepb.DatabaseSchemaMetadata, state *databaseState) error {
- // Follow the order of the input schemas.
- for _, schema := range to.Schemas {
- schemaState, ok := state.schemas[schema.Name]
- if !ok {
- continue
- }
- // Follow the order of the input procedures.
- for _, procedure := range schema.Procedures {
- procedure, ok := schemaState.procedures[procedure.Name]
- if !ok {
- continue
- }
- if _, err := w.WriteString(getProcedureAnnouncement(procedure.name)); err != nil {
- return err
- }
-
- buf := &strings.Builder{}
- if err := procedure.toString(buf); err != nil {
- return err
- }
- if _, err := w.WriteString(buf.String()); err != nil {
- return err
- }
- delete(schemaState.procedures, procedure.name)
- }
- }
- return nil
-}
-
-func writeFunctions(w io.StringWriter, to *storepb.DatabaseSchemaMetadata, state *databaseState) error {
- // Follow the order of the input schemas.
- for _, schema := range to.Schemas {
- schemaState, ok := state.schemas[schema.Name]
- if !ok {
- continue
- }
- // Follow the order of the input functions.
- for _, function := range schema.Functions {
- function, ok := schemaState.functions[function.Name]
- if !ok {
- continue
- }
- if _, err := w.WriteString(getFunctionAnnouncement(function.name)); err != nil {
- return err
- }
-
- buf := &strings.Builder{}
- if err := function.toString(buf); err != nil {
- return err
- }
- if _, err := w.WriteString(buf.String()); err != nil {
- return err
- }
- delete(schemaState.functions, function.name)
- }
- }
- return nil
-}
-
-func getViewAnnouncement(name string) string {
- return fmt.Sprintf("\n--\n-- View structure for `%s`\n--\n", name)
-}
-
-func getTableAnnouncement(name string) string {
- return fmt.Sprintf("\n--\n-- Table structure for `%s`\n--\n", name)
-}
-
-func getFunctionAnnouncement(name string) string {
- return fmt.Sprintf("\n--\n-- Function structure for `%s`\n--\n", name)
-}
-
-func getProcedureAnnouncement(name string) string {
- return fmt.Sprintf("\n--\n-- Procedure structure for `%s`\n--\n", name)
-}
diff --git a/backend/plugin/schema/mysql/get_design_schema_test.go b/backend/plugin/schema/mysql/get_design_schema_test.go
deleted file mode 100644
index 67a073c3a3..0000000000
--- a/backend/plugin/schema/mysql/get_design_schema_test.go
+++ /dev/null
@@ -1,138 +0,0 @@
-package mysql
-
-import (
- "io"
- "os"
- "testing"
-
- "github.com/stretchr/testify/require"
- "gopkg.in/yaml.v3"
-
- "github.com/bytebase/bytebase/backend/common"
- parser "github.com/bytebase/bytebase/backend/plugin/parser/mysql"
- storepb "github.com/bytebase/bytebase/proto/generated-go/store"
-)
-
-func TestGetDesignSchema_Debug(t *testing.T) {
- if true {
- t.Skip()
- }
-
- TestGetDesignSchema_Basic(t)
- TestGetDesignSchema_Partition(t)
- TestGetDesignSchema_View(t)
- TestGetDesignSchema_Function(t)
- TestGetDesignSchema_Procedure(t)
-}
-
-func TestGetDesignSchema_Basic(t *testing.T) {
- testGetDesignSchema(t, []string{
- "testdata/get-design-schema/get_design_schema.yaml",
- }, false)
-}
-
-func TestGetDesignSchema_Partition(t *testing.T) {
- testGetDesignSchema(t, []string{
- "testdata/get-design-schema/partition/range.yaml",
- "testdata/get-design-schema/partition/list.yaml",
- "testdata/get-design-schema/partition/hash.yaml",
- "testdata/get-design-schema/partition/key.yaml",
- "testdata/get-design-schema/partition/write-default.yaml",
- "testdata/get-design-schema/partition/keep-algorithm.yaml",
- "testdata/get-design-schema/partition/keep-version-comment.yaml",
- }, false)
-}
-
-func TestGetDesignSchema_View(t *testing.T) {
- testGetDesignSchema(t, []string{
- "testdata/get-design-schema/view/add-new-view.yaml",
- "testdata/get-design-schema/view/drop-view.yaml",
- "testdata/get-design-schema/view/modify-view.yaml",
- }, false)
-}
-
-func TestGetDesignSchema_Function(t *testing.T) {
- testGetDesignSchema(t, []string{
- "testdata/get-design-schema/function/create-new-function.yaml",
- "testdata/get-design-schema/function/delete-function.yaml",
- "testdata/get-design-schema/function/delete-function-without-set.yaml",
- "testdata/get-design-schema/function/modify-function.yaml",
- }, false)
-}
-
-func TestGetDesignSchema_Procedure(t *testing.T) {
- testGetDesignSchema(t, []string{
- "testdata/get-design-schema/procedure/create-new-procedure.yaml",
- "testdata/get-design-schema/procedure/delete-procedure.yaml",
- "testdata/get-design-schema/procedure/delete-procedure-without-set.yaml",
- "testdata/get-design-schema/procedure/modify-procedure.yaml",
- }, false)
-}
-
-type designTest struct {
- Description string
- Target string
- Result string
-}
-
-func testGetDesignSchema(t *testing.T, filepaths []string, writeback bool) {
- a := require.New(t)
- for _, filepath := range filepaths {
- yamlFile, err := os.Open(filepath)
- a.NoError(err)
-
- tests := []designTest{}
- byteValue, err := io.ReadAll(yamlFile)
- a.NoError(yamlFile.Close())
- a.NoError(err)
- a.NoError(yaml.Unmarshal(byteValue, &tests))
-
- for i, t := range tests {
- targetMeta := &storepb.DatabaseSchemaMetadata{}
- a.NoError(common.ProtojsonUnmarshaler.Unmarshal([]byte(t.Target), targetMeta))
- result, err := GetDesignSchema(targetMeta)
- a.NoError(err)
-
- // Addintional parse stage to verify the result is parsable.
- _, err = parser.ParseMySQL(result)
- a.NoErrorf(err, "[%s] test case %d: %s\n content:\n%s", filepath, i, t.Description, result)
-
- if writeback {
- tests[i].Result = result
- } else {
- a.Equalf(t.Result, result, "[%s] test case %d: %s", filepath, i, t.Description)
- }
- }
-
- if writeback {
- byteValue, err := yaml.Marshal(tests)
- a.NoError(err)
- err = os.WriteFile(filepath, byteValue, 0644)
- a.NoError(err)
- }
- }
-}
-
-func TestNormalizeOnUpdate(t *testing.T) {
- tests := []struct {
- s string
- want string
- }{
- {
- s: "current_timestamp(6)",
- want: "CURRENT_TIMESTAMP(6)",
- },
- {
- s: "current_timestamp",
- want: "CURRENT_TIMESTAMP",
- },
- {
- s: "hello",
- want: "hello",
- },
- }
- for _, tc := range tests {
- got := normalizeOnUpdate(tc.s)
- require.Equal(t, tc.want, got, tc.s)
- }
-}
diff --git a/backend/plugin/schema/mysql/state.go b/backend/plugin/schema/mysql/state.go
deleted file mode 100644
index 431bbd5c79..0000000000
--- a/backend/plugin/schema/mysql/state.go
+++ /dev/null
@@ -1,1129 +0,0 @@
-package mysql
-
-import (
- "fmt"
- "io"
- "log/slog"
- "regexp"
- "sort"
- "strconv"
- "strings"
-
- "github.com/antlr4-go/antlr/v4"
- "github.com/pkg/errors"
-
- mysql "github.com/bytebase/mysql-parser"
-
- mysqldb "github.com/bytebase/bytebase/backend/plugin/db/mysql"
-
- storepb "github.com/bytebase/bytebase/proto/generated-go/store"
-)
-
-type databaseState struct {
- name string
- schemas map[string]*schemaState
-}
-
-func newDatabaseState() *databaseState {
- return &databaseState{
- schemas: make(map[string]*schemaState),
- }
-}
-
-func convertToDatabaseState(database *storepb.DatabaseSchemaMetadata) *databaseState {
- state := newDatabaseState()
- state.name = database.Name
- for _, schema := range database.Schemas {
- state.schemas[schema.Name] = convertToSchemaState(schema)
- }
- return state
-}
-
-type schemaState struct {
- name string
- tables map[string]*tableState
- views map[string]*viewState
- handledViews map[string]bool
- functions map[string]*functionState
- procedures map[string]*procedureState
-}
-
-func newSchemaState() *schemaState {
- return &schemaState{
- tables: make(map[string]*tableState),
- views: make(map[string]*viewState),
- handledViews: make(map[string]bool),
- functions: make(map[string]*functionState),
- procedures: make(map[string]*procedureState),
- }
-}
-
-func convertToSchemaState(schema *storepb.SchemaMetadata) *schemaState {
- state := newSchemaState()
- state.name = schema.Name
- for i, table := range schema.Tables {
- state.tables[table.Name] = convertToTableState(i, table)
- }
- for i, view := range schema.Views {
- state.views[view.Name] = convertToViewState(i, view)
- }
- for i, function := range schema.Functions {
- state.functions[function.Name] = convertToFunctionState(i, function)
- }
- for i, procedure := range schema.Procedures {
- state.procedures[procedure.Name] = convertToProcedureState(i, procedure)
- }
- return state
-}
-
-type tableState struct {
- id int
- name string
- columns map[string]*columnState
- indexes map[string]*indexState
- foreignKeys map[string]*foreignKeyState
- comment string
- // engine and collation is only supported in ParseToMetadata.
- engine string
- collation string
- partition *partitionState
-}
-
-func (t *tableState) toString(buf io.StringWriter) error {
- if _, err := buf.WriteString(fmt.Sprintf("CREATE TABLE `%s` (\n ", t.name)); err != nil {
- return err
- }
- var columns []*columnState
- for _, column := range t.columns {
- columns = append(columns, column)
- }
- sort.Slice(columns, func(i, j int) bool {
- return columns[i].id < columns[j].id
- })
- for i, column := range columns {
- if i > 0 {
- if _, err := buf.WriteString(",\n "); err != nil {
- return err
- }
- }
- if err := column.toString(buf); err != nil {
- return err
- }
- }
-
- var indexes []*indexState
- for _, index := range t.indexes {
- indexes = append(indexes, index)
- }
- // Our sync query is ordered by index name, and our UI only support append-only
- // create index, to avoid introducing text diff, sorting by name instead of id.
- sort.Slice(indexes, func(i, j int) bool {
- if indexes[i].primary {
- return true
- }
- if indexes[j].primary {
- return false
- }
- return indexes[i].name < indexes[j].name
- })
-
- for i, index := range indexes {
- if i+len(columns) > 0 {
- if _, err := buf.WriteString(",\n "); err != nil {
- return err
- }
- }
- if err := index.toString(buf); err != nil {
- return err
- }
- }
-
- var foreignKeys []*foreignKeyState
- for _, fk := range t.foreignKeys {
- foreignKeys = append(foreignKeys, fk)
- }
- sort.Slice(foreignKeys, func(i, j int) bool {
- return foreignKeys[i].name < foreignKeys[j].name
- })
-
- for i, fk := range foreignKeys {
- if i+len(columns)+len(indexes) > 0 {
- if _, err := buf.WriteString(",\n "); err != nil {
- return err
- }
- }
- if err := fk.toString(buf); err != nil {
- return err
- }
- }
-
- if _, err := buf.WriteString("\n)"); err != nil {
- return err
- }
-
- if t.engine != "" {
- if _, err := buf.WriteString(fmt.Sprintf(" ENGINE=%s", t.engine)); err != nil {
- return err
- }
- }
-
- if t.collation != "" {
- if _, err := buf.WriteString(fmt.Sprintf(" COLLATE=%s", t.collation)); err != nil {
- return err
- }
- }
-
- if t.comment != "" {
- if _, err := buf.WriteString(fmt.Sprintf(" COMMENT '%s'", t.comment)); err != nil {
- return err
- }
- }
-
- if t.partition != nil {
- if err := t.partition.toString(buf, nil); err != nil {
- return err
- }
- }
-
- if _, err := buf.WriteString(";\n"); err != nil {
- return err
- }
- return nil
-}
-
-func newTableState(id int, name string) *tableState {
- return &tableState{
- id: id,
- name: name,
- columns: make(map[string]*columnState),
- indexes: make(map[string]*indexState),
- foreignKeys: make(map[string]*foreignKeyState),
- }
-}
-
-func convertToTableState(id int, table *storepb.TableMetadata) *tableState {
- state := newTableState(id, table.Name)
- state.comment = table.Comment
- state.engine = table.Engine
- state.collation = table.Collation
- for i, column := range table.Columns {
- state.columns[column.Name] = convertToColumnState(i, column)
- }
- for i, index := range table.Indexes {
- state.indexes[index.Name] = convertToIndexState(i, index)
- }
- for i, fk := range table.ForeignKeys {
- state.foreignKeys[fk.Name] = convertToForeignKeyState(i, fk)
- }
- state.partition = convertToPartitionState(table.Partitions)
- return state
-}
-
-type foreignKeyState struct {
- id int
- name string
- columns []string
- referencedTable string
- referencedColumns []string
-}
-
-func convertToForeignKeyState(id int, foreignKey *storepb.ForeignKeyMetadata) *foreignKeyState {
- return &foreignKeyState{
- id: id,
- name: foreignKey.Name,
- columns: foreignKey.Columns,
- referencedTable: foreignKey.ReferencedTable,
- referencedColumns: foreignKey.ReferencedColumns,
- }
-}
-
-func (f *foreignKeyState) toString(buf io.StringWriter) error {
- if _, err := buf.WriteString("CONSTRAINT `"); err != nil {
- return err
- }
- if _, err := buf.WriteString(f.name); err != nil {
- return err
- }
- if _, err := buf.WriteString("` FOREIGN KEY ("); err != nil {
- return err
- }
- for i, column := range f.columns {
- if i > 0 {
- if _, err := buf.WriteString(", "); err != nil {
- return err
- }
- }
- if _, err := buf.WriteString("`"); err != nil {
- return err
- }
- if _, err := buf.WriteString(column); err != nil {
- return err
- }
- if _, err := buf.WriteString("`"); err != nil {
- return err
- }
- }
- if _, err := buf.WriteString(") REFERENCES `"); err != nil {
- return err
- }
- if _, err := buf.WriteString(f.referencedTable); err != nil {
- return err
- }
- if _, err := buf.WriteString("` ("); err != nil {
- return err
- }
- for i, column := range f.referencedColumns {
- if i > 0 {
- if _, err := buf.WriteString(", "); err != nil {
- return err
- }
- }
- if _, err := buf.WriteString("`"); err != nil {
- return err
- }
- if _, err := buf.WriteString(column); err != nil {
- return err
- }
- if _, err := buf.WriteString("`"); err != nil {
- return err
- }
- }
- if _, err := buf.WriteString(")"); err != nil {
- return err
- }
- return nil
-}
-
-type viewState struct {
- id int
- name string
- definition string
-}
-
-func convertToViewState(id int, view *storepb.ViewMetadata) *viewState {
- return &viewState{
- id: id,
- name: view.Name,
- definition: view.Definition,
- }
-}
-
-func (v *viewState) toString(buf io.StringWriter) error {
- stmt := fmt.Sprintf("CREATE OR REPLACE VIEW `%s` AS %s", v.name, v.definition)
- if !strings.HasSuffix(stmt, ";") {
- stmt += ";"
- }
- stmt += "\n"
- if _, err := buf.WriteString(stmt); err != nil {
- return err
- }
- return nil
-}
-
-type procedureState struct {
- id int
- name string
- definition string
-}
-
-func convertToProcedureState(id int, procedure *storepb.ProcedureMetadata) *procedureState {
- return &procedureState{
- id: id,
- name: procedure.Name,
- definition: procedure.Definition,
- }
-}
-
-func (f *procedureState) toString(buf io.StringWriter) error {
- def := f.definition
- if !strings.HasSuffix(def, " ;;") {
- def = strings.TrimRight(def, ";")
- def += " ;;"
- }
-
- stmt := fmt.Sprintf("DELIMITER ;;\n%s\nDELIMITER ;\n", def)
- if _, err := buf.WriteString(stmt); err != nil {
- return err
- }
- return nil
-}
-
-type functionState struct {
- id int
- name string
- definition string
-}
-
-func convertToFunctionState(id int, function *storepb.FunctionMetadata) *functionState {
- return &functionState{
- id: id,
- name: function.Name,
- definition: function.Definition,
- }
-}
-
-func (f *functionState) toString(buf io.StringWriter) error {
- def := f.definition
- if !strings.HasSuffix(def, " ;;") {
- def = strings.TrimRight(def, ";")
- def += " ;;"
- }
-
- stmt := fmt.Sprintf("DELIMITER ;;\n%s\nDELIMITER ;\n", def)
- if _, err := buf.WriteString(stmt); err != nil {
- return err
- }
- return nil
-}
-
-type indexState struct {
- id int
- name string
- keys []string
- lengths []int64
- primary bool
- unique bool
- tp string
- comment string
-}
-
-func convertToIndexState(id int, index *storepb.IndexMetadata) *indexState {
- return &indexState{
- id: id,
- name: index.Name,
- keys: index.Expressions,
- primary: index.Primary,
- unique: index.Unique,
- tp: index.Type,
- comment: index.Comment,
- lengths: index.KeyLength,
- }
-}
-
-func (i *indexState) toString(buf io.StringWriter) error {
- if i.primary {
- if _, err := buf.WriteString("PRIMARY KEY ("); err != nil {
- return err
- }
- for j, key := range i.keys {
- if j > 0 {
- if _, err := buf.WriteString(", "); err != nil {
- return err
- }
- }
- if _, err := buf.WriteString(fmt.Sprintf("`%s`", key)); err != nil {
- return err
- }
- if j < len(i.lengths) && i.lengths[j] > 0 {
- if _, err := buf.WriteString(fmt.Sprintf("(%d)", i.lengths[j])); err != nil {
- return err
- }
- }
- }
- if _, err := buf.WriteString(")"); err != nil {
- return err
- }
- } else {
- if strings.ToUpper(i.tp) == "FULLTEXT" {
- if _, err := buf.WriteString("FULLTEXT KEY "); err != nil {
- return err
- }
- } else if strings.ToUpper(i.tp) == "SPATIAL" {
- if _, err := buf.WriteString("SPATIAL KEY "); err != nil {
- return err
- }
- } else if i.unique {
- if _, err := buf.WriteString("UNIQUE KEY "); err != nil {
- return err
- }
- } else {
- if _, err := buf.WriteString("KEY "); err != nil {
- return err
- }
- }
-
- if _, err := buf.WriteString(fmt.Sprintf("`%s` (", i.name)); err != nil {
- return err
- }
- for j, key := range i.keys {
- if j > 0 {
- if _, err := buf.WriteString(","); err != nil {
- return err
- }
- }
- if len(key) > 2 && key[0] == '(' && key[len(key)-1] == ')' {
- // Expressions are surrounded by parentheses.
- if _, err := buf.WriteString(key); err != nil {
- return err
- }
- } else {
- if _, err := buf.WriteString(fmt.Sprintf("`%s`", key)); err != nil {
- return err
- }
- if j < len(i.lengths) && i.lengths[j] > 0 {
- if _, err := buf.WriteString(fmt.Sprintf("(%d)", i.lengths[j])); err != nil {
- return err
- }
- }
- }
- }
- if _, err := buf.WriteString(")"); err != nil {
- return err
- }
-
- if strings.ToUpper(i.tp) == "BTREE" {
- if _, err := buf.WriteString(" USING BTREE"); err != nil {
- return err
- }
- } else if strings.ToUpper(i.tp) == "HASH" {
- if _, err := buf.WriteString(" USING HASH"); err != nil {
- return err
- }
- }
- }
-
- if i.comment != "" {
- if _, err := buf.WriteString(fmt.Sprintf(" COMMENT '%s'", i.comment)); err != nil {
- return err
- }
- }
- return nil
-}
-
-type partitionState struct {
- info partitionInfo
- subInfo *partitionInfo
- partitions map[string]*partitionDefinition
-}
-
-type partitionInfo struct {
- tp storepb.TablePartitionMetadata_Type
- useDefault int
- expr string
-}
-
-type partitionDefinition struct {
- id int
- name string
- value string
- subpartitions map[string]*partitionDefinition
-}
-
-func convertToPartitionState(partitions []*storepb.TablePartitionMetadata) *partitionState {
- if len(partitions) == 0 {
- return nil
- }
- state := &partitionState{
- partitions: make(map[string]*partitionDefinition),
- }
- for i, partition := range partitions {
- if i == 0 {
- state.info.tp = partition.Type
- state.info.expr = partition.Expression
- if partition.UseDefault != "" {
- var err error
- state.info.useDefault, err = strconv.Atoi(partition.UseDefault)
- if err != nil {
- slog.Warn(err.Error())
- }
- }
- }
- partitionDef := &partitionDefinition{
- id: i,
- name: partition.Name,
- value: partition.Value,
- subpartitions: make(map[string]*partitionDefinition),
- }
-
- for j, subPartition := range partition.Subpartitions {
- if j == 0 {
- state.subInfo = &partitionInfo{
- tp: subPartition.Type,
- expr: subPartition.Expression,
- }
- if subPartition.UseDefault != "" {
- var err error
- state.subInfo.useDefault, err = strconv.Atoi(subPartition.UseDefault)
- if err != nil {
- slog.Warn(err.Error())
- }
- }
- }
- partitionDef.subpartitions[subPartition.Name] = &partitionDefinition{
- id: j,
- name: subPartition.Name,
- value: subPartition.Value,
- }
- }
- state.partitions[partition.Name] = partitionDef
- }
- return state
-}
-
-// toString() writes the partition state as SHOW CREATE TABLE syntax to buf, referencing MySQL source code:
-// https://sourcegraph.com/github.com/mysql/mysql-server@824e2b4064053f7daf17d7f3f84b7a3ed92e5fb4/-/blob/sql/sql_show.cc?L2528-2550
-// partitionClauseCtx is use to minimize the difference between the original one and the output, it is safe to pass nil.
-func (p *partitionState) toString(buf io.StringWriter, partitionClauseCtx mysql.IPartitionClauseContext) error {
- // Write version specific comment.
- vsc := p.getVersionSpecificComment(partitionClauseCtx)
- curComment := vsc
- if _, err := buf.WriteString(vsc); err != nil {
- return err
- }
- if _, err := buf.WriteString(" PARTITION BY "); err != nil {
- return err
- }
-
- switch p.info.tp {
- case storepb.TablePartitionMetadata_RANGE, storepb.TablePartitionMetadata_RANGE_COLUMNS:
- if _, err := buf.WriteString("RANGE "); err != nil {
- return err
- }
- if p.info.tp == storepb.TablePartitionMetadata_RANGE {
- fields := splitPartitionExprIntoFields(p.info.expr)
- for i, field := range fields {
- if !strings.Contains(field, "(") {
- fields[i] = fmt.Sprintf("`%s`", field)
- }
- }
- if _, err := buf.WriteString(fmt.Sprintf("(%s)", strings.Join(fields, ","))); err != nil {
- return err
- }
- } else {
- // I think MySQL need to write "COLUMNS " instead of " COLUMNS" here...
- if _, err := buf.WriteString(" COLUMNS"); err != nil {
- return err
- }
- fields := splitPartitionExprIntoFields(p.info.expr)
- if _, err := buf.WriteString(fmt.Sprintf("(%s)", strings.Join(fields, ","))); err != nil {
- return err
- }
- }
- case storepb.TablePartitionMetadata_LIST, storepb.TablePartitionMetadata_LIST_COLUMNS:
- if _, err := buf.WriteString("LIST "); err != nil {
- return err
- }
- if p.info.tp == storepb.TablePartitionMetadata_LIST {
- fields := splitPartitionExprIntoFields(p.info.expr)
- for i, field := range fields {
- if !strings.Contains(field, "(") {
- fields[i] = fmt.Sprintf("`%s`", field)
- }
- }
- if _, err := buf.WriteString(fmt.Sprintf("(%s)", strings.Join(fields, ","))); err != nil {
- return err
- }
- } else {
- // I think MySQL need to write "COLUMNS " instead of " COLUMNS" here...
- if _, err := buf.WriteString(" COLUMNS"); err != nil {
- return err
- }
- fields := splitPartitionExprIntoFields(p.info.expr)
- if _, err := buf.WriteString(fmt.Sprintf("(%s)", strings.Join(fields, ","))); err != nil {
- return err
- }
- }
- case storepb.TablePartitionMetadata_HASH, storepb.TablePartitionMetadata_KEY, storepb.TablePartitionMetadata_LINEAR_HASH, storepb.TablePartitionMetadata_LINEAR_KEY:
- if p.info.tp == storepb.TablePartitionMetadata_LINEAR_HASH || p.info.tp == storepb.TablePartitionMetadata_LINEAR_KEY {
- if _, err := buf.WriteString("LINEAR "); err != nil {
- return err
- }
- }
- if p.info.tp == storepb.TablePartitionMetadata_KEY || p.info.tp == storepb.TablePartitionMetadata_LINEAR_KEY {
- if _, err := buf.WriteString("KEY "); err != nil {
- return err
- }
- // NOTE: MySQL supports an ALGORITHM option with [SUB]PARTITION BY [LINEAR KEY]. ALGORITHM=1 causes the server to use the same key-hashing function as MYSQL 5.1, and ALGORITHM=1 is the only possible output in
- // the following code. Sadly, I do not know how to get the key_algorithm from the INFORMATION_SCHEMA, AND 5.1 IS TOO LEGACY TO SUPPORT! So use the original one.
- /*
- current_comment_start is given when called from SHOW CREATE TABLE,
- Then only add ALGORITHM = 1, not the default 2 or non-set 0!
- For .frm current_comment_start is NULL, then add ALGORITHM if != 0.
- */
- // if (part_info->key_algorithm ==
- // enum_key_algorithm::KEY_ALGORITHM_51 || // SHOW
- // (!current_comment_start && // .frm
- // (part_info->key_algorithm != enum_key_algorithm::KEY_ALGORITHM_NONE))) {
- // /* If we already are within a comment, end that comment first. */
- // if (current_comment_start) err += add_string(fptr, "*/ ");
- // err += add_string(fptr, "/*!50611 ");
- // err += add_part_key_word(fptr, partition_keywords[PKW_ALGORITHM].str);
- // err += add_equal(fptr);
- // err += add_space(fptr);
- // err += add_int(fptr, static_cast<longlong>(part_info->key_algorithm));
- // err += add_space(fptr);
- // err += add_string(fptr, "*/ ");
- // if (current_comment_start) {
- // /* Skip new line. */
- // if (current_comment_start[0] == '\n') current_comment_start++;
- // err += add_string(fptr, current_comment_start);
- // err += add_space(fptr);
- // }
- // }
- if partitionClauseCtx != nil && partitionClauseCtx.PartitionTypeDef() != nil {
- v := partitionClauseCtx.PartitionTypeDef()
- partitionDefKeyCtx, ok := v.(*mysql.PartitionDefKeyContext)
- if ok && partitionDefKeyCtx.PartitionKeyAlgorithm() != nil {
- numText := partitionDefKeyCtx.PartitionKeyAlgorithm().Real_ulong_number().GetText()
- num, err := strconv.Atoi(numText)
- if err != nil {
- slog.Warn(err.Error())
- } else if num == 1 || (num == 0 && len(curComment) == 0) {
- if _, err := buf.WriteString(fmt.Sprintf("*/ /*!50611 ALGORITHM = %d */ ", num)); err != nil {
- return err
- }
- if len(curComment) > 0 {
- s := curComment
- if curComment[0] == '\n' {
- s = curComment[1:]
- }
- if _, err := buf.WriteString(fmt.Sprintf("%s ", s)); err != nil {
- return err
- }
- }
- }
- }
- }
- // HACK(zp): Write the part field list. In the MySQL source code, it calls append_identifier(), which considers the quote character. We should figure out the logic of it later.
- // Currently, I just found that if the expr contains more than one field, it would not be quoted by '`'.
- // KEY and LINEAR KEY can take the field list.
- // While MySQL calls append_field_list() to write the field list, it unmasks the OPTION_QUOTE_SHOW_CREATE flag,
- // for us, we do the best effort to split the expr by ',' and trim the leading and trailing '`', and write it to the buffer after joining them with ','.
- fields := splitPartitionExprIntoFields(p.info.expr)
- if _, err := buf.WriteString(fmt.Sprintf("(%s)", strings.Join(fields, ","))); err != nil {
- return err
- }
- } else {
- if _, err := buf.WriteString("HASH "); err != nil {
- return err
- }
- fields := splitPartitionExprIntoFields(p.info.expr)
- for i, field := range fields {
- if !strings.Contains(field, "(") {
- fields[i] = fmt.Sprintf("`%s`", field)
- }
- }
- if _, err := buf.WriteString(fmt.Sprintf("(%s)", strings.Join(fields, ","))); err != nil {
- return err
- }
- }
- default:
- return errors.Errorf("unsupported partition type: %v", p.info.tp)
- }
-
- // NOTE: MySQL writes the default partitions in the following code, which means that the server
- // takes the responsibility to generate the partitions. Sadly, we cannot get whether the user
- // use this or not in the metadata. So we skip it.
- /*
- if ((!part_info->use_default_num_partitions) &&
- part_info->use_default_partitions) {
- err += add_string(fptr, "\n");
- err += add_string(fptr, "PARTITIONS ");
- err += add_int(fptr, part_info->num_parts);
- }
- */
- if p.info.useDefault != 0 {
- if _, err := buf.WriteString(fmt.Sprintf("\nPARTITIONS %d", p.info.useDefault)); err != nil {
- return err
- }
- }
-
- isSubpartitioned := p.subInfo != nil && p.subInfo.tp != storepb.TablePartitionMetadata_TYPE_UNSPECIFIED
- if isSubpartitioned {
- if _, err := buf.WriteString("\nSUBPARTITION BY "); err != nil {
- return err
- }
- }
- // Subpartition must be hash or key.
- if isSubpartitioned {
- switch p.subInfo.tp {
- case storepb.TablePartitionMetadata_HASH, storepb.TablePartitionMetadata_LINEAR_HASH:
- if p.subInfo.tp == storepb.TablePartitionMetadata_LINEAR_HASH {
- if _, err := buf.WriteString("LINEAR "); err != nil {
- return err
- }
- }
- if _, err := buf.WriteString("HASH "); err != nil {
- return err
- }
- fields := splitPartitionExprIntoFields(p.subInfo.expr)
- for i, field := range fields {
- if !strings.Contains(field, "(") {
- fields[i] = fmt.Sprintf("`%s`", field)
- }
- }
- if _, err := buf.WriteString(fmt.Sprintf("(%s)", strings.Join(fields, ","))); err != nil {
- return err
- }
- case storepb.TablePartitionMetadata_KEY, storepb.TablePartitionMetadata_LINEAR_KEY:
- if p.subInfo.tp == storepb.TablePartitionMetadata_LINEAR_KEY {
- if _, err := buf.WriteString("LINEAR "); err != nil {
- return err
- }
- }
- if _, err := buf.WriteString("KEY "); err != nil {
- return err
- }
- if partitionClauseCtx != nil && partitionClauseCtx.SubPartitions() != nil {
- if v := partitionClauseCtx.SubPartitions().PartitionKeyAlgorithm(); v != nil {
- numText := v.Real_ulong_number().GetText()
- num, err := strconv.Atoi(numText)
- if err != nil {
- slog.Warn(err.Error())
- } else if num == 1 || (num == 0 && len(curComment) == 0) {
- if _, err := buf.WriteString(fmt.Sprintf("*/ /*!50611 ALGORITHM = %d */ ", num)); err != nil {
- return err
- }
- if len(curComment) > 0 {
- s := curComment
- if curComment[0] == '\n' {
- s = curComment[1:]
- }
- if _, err := buf.WriteString(fmt.Sprintf("%s ", s)); err != nil {
- return err
- }
- }
- }
- }
- }
- fields := splitPartitionExprIntoFields(p.subInfo.expr)
- if _, err := buf.WriteString(fmt.Sprintf("(%s)", strings.Join(fields, ","))); err != nil {
- return err
- }
- default:
- return errors.Errorf("invalid subpartition type: %v", p.subInfo.tp)
- }
- }
-
- // TODO(zp): MySQL writes the default subpartitions in the following code, which means that the server
- // takes the responsibility to generate the subpartitions. Sadly, we cannot get whether the user
- // use this or not in the metadata. So we skip it.
- /*
- if ((!part_info->use_default_num_subpartitions) &&
- part_info->use_default_subpartitions) {
- err += add_string(fptr, "\n");
- err += add_string(fptr, "SUBPARTITIONS ");
- err += add_int(fptr, part_info->num_subparts);
- }
- */
- if isSubpartitioned && p.subInfo.useDefault != 0 {
- if _, err := buf.WriteString(fmt.Sprintf("\nSUBPARTITIONS %d", p.subInfo.useDefault)); err != nil {
- return err
- }
- }
-
- if p.info.useDefault == 0 {
- // Write the partition list.
- if len(p.partitions) == 0 {
- return errors.New("empty partition list")
- }
- sortedPartitions := make([]*partitionDefinition, 0, len(p.partitions))
- for _, partition := range p.partitions {
- sortedPartitions = append(sortedPartitions, partition)
- }
- sort.Slice(sortedPartitions, func(i, j int) bool {
- return sortedPartitions[i].id < sortedPartitions[j].id
- })
- if _, err := buf.WriteString("\n("); err != nil {
- return err
- }
- preposition, err := getPrepositionByType(p.info.tp)
- if err != nil {
- return err
- }
- for i, partition := range sortedPartitions {
- if i != 0 {
- if _, err := buf.WriteString(",\n "); err != nil {
- return err
- }
- }
- if _, err := buf.WriteString(fmt.Sprintf("PARTITION %s", partition.name)); err != nil {
- return err
- }
- if preposition != "" {
- if partition.value != "MAXVALUE" {
- if _, err := buf.WriteString(fmt.Sprintf(" VALUES %s (%s)", preposition, partition.value)); err != nil {
- return err
- }
- } else {
- if _, err := buf.WriteString(fmt.Sprintf(" VALUES %s %s", preposition, partition.value)); err != nil {
- return err
- }
- }
- }
-
- if isSubpartitioned && p.subInfo.useDefault == 0 {
- if len(partition.subpartitions) == 0 {
- return errors.New("empty subpartition list")
- }
- if _, err := buf.WriteString("\n ("); err != nil {
- return err
- }
- sortedSubpartitions := make([]*partitionDefinition, 0, len(partition.subpartitions))
- for _, subPartition := range partition.subpartitions {
- sortedSubpartitions = append(sortedSubpartitions, subPartition)
- }
- sort.Slice(sortedSubpartitions, func(i, j int) bool {
- return sortedSubpartitions[i].id < sortedSubpartitions[j].id
- })
- for j, subPartition := range sortedSubpartitions {
- if _, err := buf.WriteString(fmt.Sprintf("SUBPARTITION %s", subPartition.name)); err != nil {
- return err
- }
- if err := writePartitionOptions(buf); err != nil {
- return err
- }
- if j == len(sortedSubpartitions)-1 {
- if _, err := buf.WriteString(")"); err != nil {
- return err
- }
- } else {
- if _, err := buf.WriteString(",\n "); err != nil {
- return err
- }
- }
- }
- } else {
- if err := writePartitionOptions(buf); err != nil {
- return err
- }
- }
-
- if i == len(sortedPartitions)-1 {
- if _, err := buf.WriteString(")"); err != nil {
- return err
- }
- }
- }
- }
-
- if _, err := buf.WriteString(" */"); err != nil {
- return err
- }
-
- return nil
-}
-
-func writePartitionOptions(buf io.StringWriter) error {
- /*
- int err = 0;
- err += add_space(fptr);
- if (p_elem->tablespace_name) {
- err += add_string(fptr, "TABLESPACE = ");
- err += add_ident_string(fptr, p_elem->tablespace_name);
- err += add_space(fptr);
- }
- if (p_elem->nodegroup_id != UNDEF_NODEGROUP)
- err += add_keyword_int(fptr, "NODEGROUP", (longlong)p_elem->nodegroup_id);
- if (p_elem->part_max_rows)
- err += add_keyword_int(fptr, "MAX_ROWS", (longlong)p_elem->part_max_rows);
- if (p_elem->part_min_rows)
- err += add_keyword_int(fptr, "MIN_ROWS", (longlong)p_elem->part_min_rows);
- if (!(current_thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE)) {
- if (p_elem->data_file_name)
- err += add_keyword_path(fptr, "DATA DIRECTORY", p_elem->data_file_name);
- if (p_elem->index_file_name)
- err += add_keyword_path(fptr, "INDEX DIRECTORY", p_elem->index_file_name);
- }
- if (p_elem->part_comment)
- err += add_keyword_string(fptr, "COMMENT", true, p_elem->part_comment);
- return err + add_engine(fptr, p_elem->engine_type);
- */
- // TODO(zp): Get all the partition options from the metadata is too complex, just write ENGINE=InnoDB for now.
- if _, err := buf.WriteString(" ENGINE=InnoDB"); err != nil {
- return err
- }
-
- return nil
-}
-
-// getVersionSpecificComment is the go code equivalent of MySQL void partition_info::set_show_version_string(String *packet).
-// partitionClauseCtx is use to minimize the difference between the original one and the output, it is safe to pass nil.
-func (p *partitionState) getVersionSpecificComment(partitionClauseCtx mysql.IPartitionClauseContext) string {
- if p.info.tp == storepb.TablePartitionMetadata_RANGE_COLUMNS || p.info.tp == storepb.TablePartitionMetadata_LIST_COLUMNS {
- // MySQL introduce columns partitioning in 5.5+.
- return "\n/*!50500"
- } else if partitionClauseCtx != nil {
- /*
- if (part_expr)
- part_expr->walk(&Item::intro_version, enum_walk::POSTFIX,
- (uchar *)&version);
- if (subpart_expr)
- subpart_expr->walk(&Item::intro_version, enum_walk::POSTFIX,
- (uchar *)&version);
- */
- tokenStream := partitionClauseCtx.GetParser().GetTokenStream()
- startPos := partitionClauseCtx.GetStart().GetTokenIndex()
- if tokenStream != nil {
- if startPos-2 > 0 && tokenStream.Size() > startPos-2 {
- regexp := regexp.MustCompile(`\/\*![0-9]+`)
- for i := 0; i < 2; i++ {
- if tokenStream.Get(startPos-i-1).GetChannel() == antlr.TokenHiddenChannel {
- if regexp.MatchString(tokenStream.Get(startPos - i - 1).GetText()) {
- return fmt.Sprintf("\n%s", tokenStream.Get(startPos-i-1).GetText())
- }
- }
- }
- }
- }
- }
- // NOTE: Users can use function in partition expr or subpartition expr, and the intro version of function should be the infimum of the version.
- // But sadly, it's a huge work for us to copy the intro version for each function in MySQL. So we use the original one.
- return "\n/*!50100"
-}
-
-func getPrepositionByType(tp storepb.TablePartitionMetadata_Type) (string, error) {
- switch tp {
- case storepb.TablePartitionMetadata_RANGE:
- return "LESS THAN", nil
- case storepb.TablePartitionMetadata_RANGE_COLUMNS:
- return "LESS THAN", nil
- case storepb.TablePartitionMetadata_LIST:
- return "IN", nil
- case storepb.TablePartitionMetadata_LIST_COLUMNS:
- return "IN", nil
- case storepb.TablePartitionMetadata_HASH, storepb.TablePartitionMetadata_KEY, storepb.TablePartitionMetadata_LINEAR_HASH, storepb.TablePartitionMetadata_LINEAR_KEY:
- return "", nil
- default:
- return "", errors.Errorf("unsupported partition type: %v", tp)
- }
-}
-
-type defaultValue interface {
- toString() string
-}
-
-type defaultValueNull struct {
-}
-
-func (*defaultValueNull) toString() string {
- return "NULL"
-}
-
-type defaultValueString struct {
- value string
-}
-
-func (d *defaultValueString) toString() string {
- return fmt.Sprintf("'%s'", d.value)
-}
-
-type defaultValueExpression struct {
- value string
-}
-
-func (d *defaultValueExpression) toString() string {
- return d.value
-}
-
-type columnState struct {
- id int
- name string
- tp string
- defaultValue defaultValue
- onUpdate string
- comment string
- nullable bool
-}
-
-func (c *columnState) toString(buf io.StringWriter) error {
- columnCanonicalType := mysqldb.GetColumnTypeCanonicalSynonym(strings.ToLower(c.tp))
- if _, err := buf.WriteString(fmt.Sprintf("`%s` %s", c.name, columnCanonicalType)); err != nil {
- return err
- }
- if !c.nullable {
- if _, err := buf.WriteString(" NOT NULL"); err != nil {
- return err
- }
- }
- if c.defaultValue != nil {
- _, isDefaultNull := c.defaultValue.(*defaultValueNull)
- dontWriteDefaultNull := isDefaultNull && c.nullable && expressionDefaultOnlyTypes[strings.ToUpper(c.tp)]
- // Some types do not default to NULL, but support default expressions.
- if !dontWriteDefaultNull {
- // todo(zp): refactor column attribute.
- if strings.EqualFold(c.defaultValue.toString(), autoIncrementSymbol) {
- if _, err := buf.WriteString(" " + autoIncrementSymbol); err != nil {
- return err
- }
- } else if strings.Contains(strings.ToUpper(c.defaultValue.toString()), autoRandSymbol) {
- if _, err := buf.WriteString(fmt.Sprintf(" /*T![auto_rand] %s */", c.defaultValue.toString())); err != nil {
- return err
- }
- } else {
- if _, err := buf.WriteString(fmt.Sprintf(" DEFAULT %s", c.defaultValue.toString())); err != nil {
- return err
- }
- }
- }
- }
- if len(c.onUpdate) > 0 {
- if _, err := buf.WriteString(fmt.Sprintf(" ON UPDATE %s", c.onUpdate)); err != nil {
- return err
- }
- }
- if c.comment != "" {
- if _, err := buf.WriteString(fmt.Sprintf(" COMMENT '%s'", c.comment)); err != nil {
- return err
- }
- }
- return nil
-}
-
-func convertToColumnState(id int, column *storepb.ColumnMetadata) *columnState {
- result := &columnState{
- id: id,
- name: column.Name,
- tp: column.Type,
- nullable: column.Nullable,
- onUpdate: normalizeOnUpdate(column.OnUpdate),
- comment: column.Comment,
- }
- if column.GetDefaultValue() != nil {
- switch value := column.GetDefaultValue().(type) {
- case *storepb.ColumnMetadata_DefaultNull:
- result.defaultValue = &defaultValueNull{}
- case *storepb.ColumnMetadata_Default:
- if value.Default == nil {
- result.defaultValue = &defaultValueNull{}
- } else {
- result.defaultValue = &defaultValueString{value: value.Default.GetValue()}
- }
- case *storepb.ColumnMetadata_DefaultExpression:
- result.defaultValue = &defaultValueExpression{value: value.DefaultExpression}
- }
- }
- return result
-}
-
-// splitPartitioNExprIntoFields splits the partition expression by ',', and trims the leading and trailing '`' for each element.
-func splitPartitionExprIntoFields(expr string) []string {
- // We do not support the expression contains parentheses, so we can split the expression by ','.
- ss := strings.Split(expr, ",")
- for i, s := range ss {
- if strings.HasPrefix(s, "`") && strings.HasSuffix(s, "`") {
- ss[i] = s[1 : len(s)-1]
- }
- }
- return ss
-}
-
-func normalizeOnUpdate(s string) string {
- if s == "" {
- return ""
- }
-
- lowerS := strings.ToLower(s)
- re := regexp.MustCompile(`(current_timestamp|now|localtime|localtimestamp)(?:\((\d+)\))?`)
- match := re.FindStringSubmatch(lowerS)
- if len(match) > 0 {
- if len(match) >= 3 && match[2] != "" {
- // has precision
- return fmt.Sprintf("CURRENT_TIMESTAMP(%s)", match[2])
- }
- // no precision
- return "CURRENT_TIMESTAMP"
- }
- // not a current_timestamp family function
- return s
-}
diff --git a/backend/plugin/schema/mysql/stringify_table.go b/backend/plugin/schema/mysql/stringify_table.go
deleted file mode 100644
index e0281ea028..0000000000
--- a/backend/plugin/schema/mysql/stringify_table.go
+++ /dev/null
@@ -1,105 +0,0 @@
-package mysql
-
-import (
- "fmt"
- "strings"
-
- "github.com/bytebase/bytebase/backend/plugin/schema"
- storepb "github.com/bytebase/bytebase/proto/generated-go/store"
-)
-
-const (
- mysqlTypeBlob = "blob"
- mysqlTypeTinyBob = "tinyblob"
- mysqlTypeMediumBlob = "mediumblob"
- mysqlTypeLongBlob = "longblob"
- mysqlTypeJSON = "json"
- mysqlTypeGeometry = "geometry"
-
- mysqlIndexFullText = "FULLTEXT"
- mysqlIndexSpatial = "SPATIAL"
-
- mysqlNoAction = "NO ACTION"
-)
-
-func init() {
- schema.RegisterStringifyTable(storepb.Engine_MYSQL, StringifyTable)
-}
-
-func StringifyTable(metadata *storepb.TableMetadata) (string, error) {
- var buf strings.Builder
-
- if _, err := fmt.Fprintf(&buf, "CREATE TABLE `%s` (\n", metadata.Name); err != nil {
- return "", err
- }
-
- for i, column := range metadata.Columns {
- if i != 0 {
- if _, err := fmt.Fprintf(&buf, ",\n"); err != nil {
- return "", err
- }
- }
- if err := printColumnClause(&buf, column); err != nil {
- return "", err
- }
- }
-
- if err := printPrimaryKeyClause(&buf, metadata.Indexes); err != nil {
- return "", err
- }
-
- for _, index := range metadata.Indexes {
- if index.Primary {
- continue
- }
- if err := printIndexClause(&buf, index); err != nil {
- return "", err
- }
- }
-
- for _, fk := range metadata.ForeignKeys {
- if err := printForeignKeyClause(&buf, fk); err != nil {
- return "", err
- }
- }
-
- for _, check := range metadata.CheckConstraints {
- if err := printCheckClause(&buf, check); err != nil {
- return "", err
- }
- }
-
- if _, err := fmt.Fprintf(&buf, "\n) ENGINE=%s", metadata.Engine); err != nil {
- return "", err
- }
-
- if metadata.Charset != "" {
- if _, err := fmt.Fprintf(&buf, " DEFAULT CHARSET=%s", metadata.Charset); err != nil {
- return "", err
- }
- }
-
- if metadata.Collation != "" {
- if _, err := fmt.Fprintf(&buf, " COLLATE=%s", metadata.Collation); err != nil {
- return "", err
- }
- }
-
- if metadata.Comment != "" {
- if _, err := fmt.Fprintf(&buf, " COMMENT='%s'", metadata.Comment); err != nil {
- return "", err
- }
- }
-
- if len(metadata.Partitions) > 0 {
- if err := printPartitionClause(&buf, metadata.Partitions); err != nil {
- return "", err
- }
- }
-
- if _, err := fmt.Fprintf(&buf, ";\n"); err != nil {
- return "", err
- }
-
- return buf.String(), nil
-}
diff --git a/backend/plugin/schema/mysql/utils.go b/backend/plugin/schema/mysql/utils.go
deleted file mode 100644
index 16e3dbad5b..0000000000
--- a/backend/plugin/schema/mysql/utils.go
+++ /dev/null
@@ -1,41 +0,0 @@
-package mysql
-
-const (
- autoIncrementSymbol = "AUTO_INCREMENT"
- autoRandSymbol = "AUTO_RANDOM"
-)
-
-var (
- // https://dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html
- // expressionDefaultOnlyTypes is a list of types that only accept expression as default
- // value. While we restore the following types, we should not restore the default null.
- // +-------+--------------------------------------------------------------------+
- // | Table | Create Table |
- // +-------+--------------------------------------------------------------------+
- // | u | CREATE TABLE `u` ( |
- // | | `b` blob, |
- // | | `t` text, |
- // | | `g` geometry DEFAULT NULL, |
- // | | `j` json DEFAULT NULL |
- // | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
- // +-------+--------------------------------------------------------------------+.
- expressionDefaultOnlyTypes = map[string]bool{
- // BLOB & TEXT
- // https://dev.mysql.com/doc/refman/8.0/en/blob.html
- "TINYBLOB": true,
- "BLOB": true,
- "MEIDUMBLOB": true,
- "LONGBLOB": true,
- "TINYTEXT": true,
- "TEXT": true,
- "MEDIUMTEXT": true,
- "LONGTEXT": true,
-
- // In practice, the following types restore the default null by mysqldump.
- // // GEOMETRY
- // "GEOMETRY": true,
- // // JSON
- // // https://dev.mysql.com/doc/refman/8.0/en/json.html
- // "JSON": true,
- }
-)
diff --git a/backend/plugin/schema/oracle/get_design_schema.go b/backend/plugin/schema/oracle/get_design_schema.go
deleted file mode 100644
index d1f98d18dd..0000000000
--- a/backend/plugin/schema/oracle/get_design_schema.go
+++ /dev/null
@@ -1,82 +0,0 @@
-package oracle
-
-import (
- "strings"
-
- "github.com/antlr4-go/antlr/v4"
-
- "github.com/bytebase/bytebase/backend/plugin/parser/plsql"
- "github.com/bytebase/bytebase/backend/plugin/schema"
- storepb "github.com/bytebase/bytebase/proto/generated-go/store"
-)
-
-func init() {
- schema.RegisterGetDesignSchema(storepb.Engine_ORACLE, GetDesignSchema)
-}
-
-func GetDesignSchema(to *storepb.DatabaseSchemaMetadata) (string, error) {
- baselineSchema := ""
- toState := convertToDatabaseState(to)
- tree, tokens, err := plsql.ParsePLSQL(baselineSchema)
- if err != nil {
- return "", err
- }
-
- generator := &designSchemaGenerator{
- to: toState,
- }
- antlr.ParseTreeWalkerDefault.Walk(generator, tree)
- if generator.err != nil {
- return "", generator.err
- }
-
- for _, schema := range to.Schemas {
- schemaState, ok := toState.schemas[schema.Name]
- if !ok {
- continue
- }
- for _, table := range schema.Tables {
- tableState, ok := schemaState.tables[table.Name]
- if !ok {
- continue
- }
- if tableState.deleted {
- // Add indexes.
- for _, index := range table.Indexes {
- if index.Primary || index.Unique {
- continue
- }
- if indexState := tableState.indexes[index.Name]; indexState != nil {
- var buf strings.Builder
- if err := indexState.toOutlineString(schemaState.name, tableState.name, &buf); err != nil {
- return "", err
- }
- generator.actions = append(generator.actions, plsql.NewAddIndexAction(schema.Name, table.Name, buf.String()))
- }
- }
- continue
- }
- buf := &strings.Builder{}
- if err := tableState.toString(schema.Name, buf); err != nil {
- return "", err
- }
- generator.actions = append(generator.actions, plsql.NewAddTableAction(schema.Name, table.Name, buf.String()))
- for _, index := range table.Indexes {
- indexState := tableState.indexes[index.Name]
- if indexState == nil {
- continue
- }
- if index.Primary || index.Unique {
- continue
- }
- buf := &strings.Builder{}
- if err := indexState.toOutlineString(schemaState.name, tableState.name, buf); err != nil {
- return "", err
- }
- generator.actions = append(generator.actions, plsql.NewAddIndexAction(schema.Name, table.Name, buf.String()))
- }
- }
- }
- manipulator := plsql.NewStringsManipulator(tree, tokens)
- return manipulator.Manipulate(generator.actions...)
-}
diff --git a/backend/plugin/schema/oracle/get_design_schema_test.go b/backend/plugin/schema/oracle/get_design_schema_test.go
deleted file mode 100644
index b739743b89..0000000000
--- a/backend/plugin/schema/oracle/get_design_schema_test.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package oracle
-
-import (
- "io"
- "os"
- "testing"
-
- "github.com/stretchr/testify/require"
- "gopkg.in/yaml.v3"
-
- "github.com/bytebase/bytebase/backend/common"
- storepb "github.com/bytebase/bytebase/proto/generated-go/store"
-)
-
-type designTest struct {
- Baseline string
- Target string
- Result string
-}
-
-func TestGetDesignSchema(t *testing.T) {
- const (
- record = false
- )
- var (
- filepath = "testdata/get_design_schema.yaml"
- )
-
- a := require.New(t)
- yamlFile, err := os.Open(filepath)
- a.NoError(err)
-
- tests := []designTest{}
- byteValue, err := io.ReadAll(yamlFile)
- a.NoError(yamlFile.Close())
- a.NoError(err)
- a.NoError(yaml.Unmarshal(byteValue, &tests))
-
- for i, t := range tests {
- targetMeta := &storepb.DatabaseSchemaMetadata{}
- a.NoError(common.ProtojsonUnmarshaler.Unmarshal([]byte(t.Target), targetMeta))
- result, err := GetDesignSchema(targetMeta)
- a.NoError(err)
- if record {
- tests[i].Result = result
- } else {
- a.Equal(t.Result, result)
- }
- }
-
- if record {
- byteValue, err := yaml.Marshal(tests)
- a.NoError(err)
- err = os.WriteFile(filepath, byteValue, 0644)
- a.NoError(err)
- }
-}
diff --git a/backend/plugin/schema/pg/common.go b/backend/plugin/schema/pg/common.go
deleted file mode 100644
index 4b50f81b6a..0000000000
--- a/backend/plugin/schema/pg/common.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package pg
-
-import "strings"
-
-func escapePostgreSQLString(s string) string {
- return strings.ReplaceAll(s, "'", "''")
-}
-
-func unescapePostgreSQLString(s string) string {
- return strings.ReplaceAll(s, "''", "'")
-}
diff --git a/backend/plugin/schema/pg/get_design_schema.go b/backend/plugin/schema/pg/get_design_schema.go
deleted file mode 100644
index 6b55d61c83..0000000000
--- a/backend/plugin/schema/pg/get_design_schema.go
+++ /dev/null
@@ -1,950 +0,0 @@
-package pg
-
-import (
- "fmt"
- "sort"
- "strings"
-
- "github.com/antlr4-go/antlr/v4"
- "github.com/pkg/errors"
-
- postgres "github.com/bytebase/postgresql-parser"
-
- pgparser "github.com/bytebase/bytebase/backend/plugin/parser/pg"
- "github.com/bytebase/bytebase/backend/plugin/schema"
-
- "github.com/bytebase/bytebase/backend/plugin/parser/sql/ast"
- pgrawparser "github.com/bytebase/bytebase/backend/plugin/parser/sql/engine/pg"
- storepb "github.com/bytebase/bytebase/proto/generated-go/store"
-)
-
-func init() {
- schema.RegisterGetDesignSchema(storepb.Engine_POSTGRES, GetDesignSchema)
-}
-
-type designSchemaGenerator struct {
- *postgres.BasePostgreSQLParserListener
-
- to *databaseState
- result strings.Builder
- currentTable *tableState
- firstElementInTable bool
- columnDefine strings.Builder
- tableConstraints strings.Builder
- err error
-
- lastTokenIndex int
-}
-
-// GetDesignSchema returns the schema string for the design schema.
-func GetDesignSchema(to *storepb.DatabaseSchemaMetadata) (string, error) {
- baselineSchema := ""
- toState := convertToDatabaseState(to)
- parseResult, err := pgparser.ParsePostgreSQL(baselineSchema)
- if err != nil {
- return "", err
- }
- if parseResult == nil {
- return "", nil
- }
- if parseResult.Tree == nil {
- return "", nil
- }
-
- listener := &designSchemaGenerator{
- lastTokenIndex: 0,
- to: toState,
- }
-
- antlr.ParseTreeWalkerDefault.Walk(listener, parseResult.Tree)
- if listener.err != nil {
- return "", listener.err
- }
- root, ok := parseResult.Tree.(*postgres.RootContext)
- if !ok {
- return "", errors.Errorf("failed to convert to RootContext")
- }
- if root.GetStop() != nil {
- if _, err := listener.result.WriteString(root.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: listener.lastTokenIndex,
- Stop: root.GetStop().GetTokenIndex(),
- })); err != nil {
- return "", err
- }
- }
-
- // Follow the order of the input schema.
- for _, schema := range to.Schemas {
- schemaState, exists := listener.to.schemas[schema.Name]
- if !exists {
- continue
- }
- if err := schemaState.printCreateSchema(&listener.result); err != nil {
- return "", err
- }
- // Follow the order of the input table.
- for _, table := range schema.Tables {
- tableState, exists := schemaState.tables[table.Name]
- if !exists {
- continue
- }
- if err := tableState.toString(&listener.result, schema.Name); err != nil {
- return "", err
- }
-
- if _, err := listener.result.WriteString("\n"); err != nil {
- return "", err
- }
-
- for _, column := range table.Columns {
- columnState, exists := tableState.columns[column.Name]
- if !exists {
- continue
- }
-
- if column.Comment != "" && !columnState.ignoreComment {
- if err := columnState.commentToString(&listener.result, schema.Name, table.Name); err != nil {
- return "", err
- }
- if _, err := listener.result.WriteString("\n"); err != nil {
- return "", err
- }
- }
- }
-
- if table.Comment != "" && !tableState.ignoreComment {
- if err := tableState.commentToString(&listener.result, schema.Name); err != nil {
- return "", err
- }
- if _, err := listener.result.WriteString("\n"); err != nil {
- return "", err
- }
- }
- }
- }
- s := listener.result.String()
- // Make goyamlv3 happy.
- s = strings.TrimLeft(s, "\n")
-
- return s, nil
-}
-
-// EnterCreatestmt is called when production createstmt is entered.
-func (g *designSchemaGenerator) EnterCreatestmt(ctx *postgres.CreatestmtContext) {
- if g.err != nil {
- return
- }
- if ctx.Opttableelementlist() == nil {
- // Skip other create statement for now.
- return
- }
- schemaName, tableName, err := pgparser.NormalizePostgreSQLQualifiedNameAsTableName(ctx.Qualified_name(0))
- if err != nil {
- g.err = err
- return
- }
-
- if _, err := g.result.WriteString(
- ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: g.lastTokenIndex,
- Stop: ctx.GetStart().GetTokenIndex() - 1,
- }),
- ); err != nil {
- g.err = err
- return
- }
- g.lastTokenIndex = ctx.GetStart().GetTokenIndex()
-
- schema, exists := g.to.schemas[schemaName]
- if !exists {
- // Skip not found schema.
- g.lastTokenIndex = skipFollowingSemiIndex(ctx.GetParser().GetTokenStream(), ctx.GetStop().GetTokenIndex()+1)
- return
- }
-
- table, exists := schema.tables[tableName]
- if !exists {
- // Skip not found table.
- g.lastTokenIndex = skipFollowingSemiIndex(ctx.GetParser().GetTokenStream(), ctx.GetStop().GetTokenIndex()+1)
- return
- }
-
- g.currentTable = table
- g.firstElementInTable = true
- g.columnDefine.Reset()
- g.tableConstraints.Reset()
-
- table.ignoreTable = true
- // Write the text before the table element list.
- if _, err := g.result.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: ctx.GetStart().GetTokenIndex(),
- Stop: ctx.Opttableelementlist().GetStart().GetTokenIndex() - 1,
- })); err != nil {
- g.err = err
- return
- }
-}
-
-func (g *designSchemaGenerator) ExitCreatestmt(ctx *postgres.CreatestmtContext) {
- if g.err != nil || g.currentTable == nil {
- return
- }
-
- var columnList []*columnState
- for _, column := range g.currentTable.columns {
- if column.ignore {
- continue
- }
- columnList = append(columnList, column)
- }
- sort.Slice(columnList, func(i, j int) bool {
- return columnList[i].id < columnList[j].id
- })
- for _, column := range columnList {
- if g.firstElementInTable {
- g.firstElementInTable = false
- } else {
- if _, err := g.columnDefine.WriteString(",\n "); err != nil {
- g.err = err
- return
- }
- }
- if err := column.toString(&g.columnDefine); err != nil {
- g.err = err
- return
- }
- }
-
- if _, err := g.result.WriteString(g.columnDefine.String()); err != nil {
- g.err = err
- return
- }
- if _, err := g.result.WriteString(g.tableConstraints.String()); err != nil {
- g.err = err
- return
- }
-
- if _, err := g.result.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: ctx.Opttableelementlist().GetStop().GetTokenIndex() + 1,
- Stop: ctx.GetStop().GetTokenIndex(),
- })); err != nil {
- g.err = err
- return
- }
- g.lastTokenIndex = ctx.GetStop().GetTokenIndex() + 1
- g.currentTable = nil
- g.firstElementInTable = false
-}
-
-func skipFollowingSemiIndex(stream antlr.TokenStream, index int) int {
- for i := index; i < stream.Size(); i++ {
- token := stream.Get(i)
- if token.GetTokenType() == postgres.PostgreSQLParserSEMI {
- return i + 1
- }
- if token.GetTokenType() == postgres.PostgreSQLParserEOF {
- return i
- }
- }
- return index
-}
-
-func (g *designSchemaGenerator) EnterAltertablestmt(ctx *postgres.AltertablestmtContext) {
- if g.err != nil {
- return
- }
-
- if ctx.TABLE() == nil || ctx.Alter_table_cmds() == nil || len(ctx.Alter_table_cmds().AllAlter_table_cmd()) != 1 {
- // Skip other alter table statement for now.
- return
- }
-
- if _, err := g.result.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: g.lastTokenIndex,
- Stop: ctx.GetStart().GetTokenIndex() - 1,
- })); err != nil {
- g.err = err
- return
- }
- g.lastTokenIndex = skipFollowingSemiIndex(ctx.GetParser().GetTokenStream(), ctx.GetStop().GetTokenIndex()+1)
-
- schemaName, tableName, err := pgparser.NormalizePostgreSQLQualifiedNameAsTableName(ctx.Relation_expr().Qualified_name())
- if err != nil {
- g.err = err
- return
- }
-
- schema, exists := g.to.schemas[schemaName]
- if !exists {
- // Skip not found schema.
- return
- }
-
- table, exists := schema.tables[tableName]
- if !exists {
- // Skip not found table.
- return
- }
-
- cmd := ctx.Alter_table_cmds().Alter_table_cmd(0)
- switch {
- case cmd.ADD_P() != nil && cmd.Tableconstraint() != nil:
- constraint := cmd.Tableconstraint().Constraintelem()
- switch {
- case constraint.PRIMARY() != nil && constraint.KEY() != nil:
- name := cmd.Tableconstraint().Name()
- if name == nil {
- g.err = errors.Errorf("primary key constraint must have a name")
- return
- }
- nameText := pgparser.NormalizePostgreSQLColid(name.Colid())
- index, exists := table.indexes[nameText]
- if !exists {
- // Skip not found primary key.
- return
- }
- delete(table.indexes, nameText)
- keys := extractColumnList(constraint.Columnlist())
- if equalKeys(keys, index.keys) {
- if _, err := g.result.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: ctx.GetStart().GetTokenIndex(),
- Stop: g.lastTokenIndex - 1,
- })); err != nil {
- g.err = err
- return
- }
- } else {
- if _, err := g.result.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: ctx.GetStart().GetTokenIndex(),
- Stop: constraint.Columnlist().GetStart().GetTokenIndex() - 1,
- })); err != nil {
- g.err = err
- return
- }
- newKeys := []string{}
- for _, key := range index.keys {
- newKeys = append(newKeys, fmt.Sprintf(`"%s"`, key))
- }
- if _, err := g.result.WriteString(strings.Join(newKeys, ", ")); err != nil {
- g.err = err
- return
- }
- if _, err := g.result.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: constraint.Columnlist().GetStop().GetTokenIndex() + 1,
- Stop: g.lastTokenIndex - 1,
- })); err != nil {
- g.err = err
- return
- }
- }
- case constraint.FOREIGN() != nil && constraint.KEY() != nil:
- name := cmd.Tableconstraint().Name()
- if name == nil {
- g.err = errors.Errorf("foreign key constraint must have a name")
- return
- }
- nameText := pgparser.NormalizePostgreSQLColid(name.Colid())
- fk, exists := table.foreignKeys[nameText]
- if !exists {
- // Skip not found foreign key.
- return
- }
- delete(table.foreignKeys, nameText)
- columns := extractColumnList(constraint.Columnlist())
- referencedSchemaName, referencedTableName, err := pgparser.NormalizePostgreSQLQualifiedNameAsTableName(constraint.Qualified_name())
- if err != nil {
- g.err = err
- return
- }
- referencedColumns := extractColumnList(constraint.Opt_column_list().Columnlist())
- equal := equalKeys(columns, fk.columns) && equalKeys(referencedColumns, fk.referencedColumns) && referencedSchemaName == fk.referencedSchema && referencedTableName == fk.referencedTable
- if equal {
- if _, err := g.result.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: ctx.GetStart().GetTokenIndex(),
- Stop: g.lastTokenIndex - 1,
- })); err != nil {
- g.err = err
- return
- }
- } else {
- if _, err := g.result.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: ctx.GetStart().GetTokenIndex(),
- Stop: constraint.Columnlist().GetStart().GetTokenIndex() - 1,
- })); err != nil {
- g.err = err
- return
- }
- newColumns := []string{}
- for _, column := range fk.columns {
- newColumns = append(newColumns, fmt.Sprintf(`"%s"`, column))
- }
- if _, err := g.result.WriteString(strings.Join(newColumns, ", ")); err != nil {
- g.err = err
- return
- }
- if _, err := g.result.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: constraint.Columnlist().GetStop().GetTokenIndex() + 1,
- Stop: constraint.Qualified_name().GetStart().GetTokenIndex() - 1,
- })); err != nil {
- g.err = err
- return
- }
- if _, err := g.result.WriteString(fmt.Sprintf(`"%s"."%s"(`, fk.referencedSchema, fk.referencedTable)); err != nil {
- g.err = err
- return
- }
- newReferencedColumns := []string{}
- for _, column := range fk.referencedColumns {
- newReferencedColumns = append(newReferencedColumns, fmt.Sprintf(`"%s"`, column))
- }
- if _, err := g.result.WriteString(strings.Join(newReferencedColumns, ", ")); err != nil {
- g.err = err
- return
- }
- if _, err := g.result.WriteString(")"); err != nil {
- g.err = err
- return
- }
- if _, err := g.result.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: constraint.Opt_column_list().GetStop().GetTokenIndex() + 1,
- Stop: g.lastTokenIndex - 1,
- })); err != nil {
- g.err = err
- return
- }
- }
- default:
- if _, err := g.result.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: ctx.GetStart().GetTokenIndex(),
- Stop: g.lastTokenIndex - 1,
- })); err != nil {
- g.err = err
- return
- }
- }
- default:
- if _, err := g.result.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: ctx.GetStart().GetTokenIndex(),
- Stop: g.lastTokenIndex - 1,
- })); err != nil {
- g.err = err
- return
- }
- }
-}
-
-func equalKeys(keys1, keys2 []string) bool {
- if len(keys1) != len(keys2) {
- return false
- }
- for i, key := range keys1 {
- if key != keys2[i] {
- return false
- }
- }
- return true
-}
-
-func extractColumnList(columnList postgres.IColumnlistContext) []string {
- result := []string{}
- for _, item := range columnList.AllColumnElem() {
- result = append(result, pgparser.NormalizePostgreSQLColid(item.Colid()))
- }
- return result
-}
-
-func (g *designSchemaGenerator) EnterTableconstraint(ctx *postgres.TableconstraintContext) {
- if g.err != nil || g.currentTable == nil {
- return
- }
-
- if g.firstElementInTable {
- g.firstElementInTable = false
- } else {
- if _, err := g.tableConstraints.WriteString(",\n "); err != nil {
- g.err = err
- return
- }
- }
- if _, err := g.tableConstraints.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: ctx.GetStart().GetTokenIndex(),
- Stop: ctx.GetStop().GetTokenIndex(),
- })); err != nil {
- g.err = err
- return
- }
-}
-
-func (g *designSchemaGenerator) EnterTablelikeclause(ctx *postgres.TablelikeclauseContext) {
- if g.err != nil || g.currentTable == nil {
- return
- }
-
- if g.firstElementInTable {
- g.firstElementInTable = false
- } else {
- if _, err := g.tableConstraints.WriteString(",\n "); err != nil {
- g.err = err
- return
- }
- }
- if _, err := g.tableConstraints.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: ctx.GetStart().GetTokenIndex(),
- Stop: ctx.GetStop().GetTokenIndex(),
- })); err != nil {
- g.err = err
- return
- }
-}
-
-func (g *designSchemaGenerator) EnterCreateschemastmt(ctx *postgres.CreateschemastmtContext) {
- if g.err != nil {
- return
- }
- if _, err := g.result.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: g.lastTokenIndex,
- Stop: ctx.GetStart().GetTokenIndex() - 1,
- })); err != nil {
- g.err = err
- return
- }
-
- g.lastTokenIndex = skipFollowingSemiIndex(ctx.GetParser().GetTokenStream(), ctx.GetStop().GetTokenIndex()+1)
- endTokenIndex := g.lastTokenIndex - 1
-
- var schemaName string
- if ctx.Colid() != nil {
- schemaName = pgparser.NormalizePostgreSQLColid(ctx.Colid())
- } else if ctx.Optschemaname() != nil && ctx.Optschemaname().Colid() != nil {
- schemaName = pgparser.NormalizePostgreSQLColid(ctx.Optschemaname().Colid())
- }
-
- schema, exists := g.to.schemas[schemaName]
- if !exists {
- // Skip not found schema.
- return
- }
-
- schema.ignore = true
- if _, err := g.result.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: ctx.GetStart().GetTokenIndex(),
- Stop: endTokenIndex,
- })); err != nil {
- g.err = err
- return
- }
-}
-
-func (g *designSchemaGenerator) EnterCommentstmt(ctx *postgres.CommentstmtContext) {
- if g.err != nil {
- return
- }
- if _, err := g.result.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: g.lastTokenIndex,
- Stop: ctx.GetStart().GetTokenIndex() - 1,
- })); err != nil {
- g.err = err
- return
- }
-
- g.lastTokenIndex = skipFollowingSemiIndex(ctx.GetParser().GetTokenStream(), ctx.GetStop().GetTokenIndex()+1)
- endTokenIndex := g.lastTokenIndex - 1
-
- if ctx.Object_type_any_name() != nil {
- if ctx.Object_type_any_name().TABLE() != nil && ctx.Object_type_any_name().FOREIGN() == nil {
- schemaName, tableName, err := pgparser.NormalizePostgreSQLAnyNameAsTableName(ctx.Any_name())
- if err != nil {
- g.err = err
- return
- }
- schema, exists := g.to.schemas[schemaName]
- if !exists {
- // Skip not found schema.
- return
- }
- _, exists = schema.tables[tableName]
- if !exists {
- // Skip not found table.
- return
- }
- }
- }
-
- switch {
- case ctx.COLUMN() != nil:
- schemaName, tableName, columnName, err := pgparser.NormalizePostgreSQLAnyNameAsColumnName(ctx.Any_name())
- if err != nil {
- g.err = err
- return
- }
- schema, exists := g.to.schemas[schemaName]
- if !exists {
- // Skip not found schema.
- return
- }
- table, exists := schema.tables[tableName]
- if !exists {
- // Skip not found table.
- return
- }
- column, exists := table.columns[columnName]
- if !exists {
- // Skip not found column.
- return
- }
- equal := false
- column.ignoreComment = true
- if ctx.Comment_text().NULL_P() != nil {
- equal = len(column.comment) == 0
- } else {
- if len(column.comment) == 0 {
- // Skip for empty comment string.
- return
- }
- commentText := ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: ctx.Comment_text().GetStart().GetTokenIndex(),
- Stop: ctx.Comment_text().GetStop().GetTokenIndex(),
- })
- if len(commentText) > 2 && commentText[0] == '\'' && commentText[len(commentText)-1] == '\'' {
- commentText = unescapePostgreSQLString(commentText[1 : len(commentText)-1])
- }
-
- equal = commentText == column.comment
- }
-
- if equal {
- if _, err := g.result.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: ctx.GetStart().GetTokenIndex(),
- Stop: endTokenIndex,
- })); err != nil {
- g.err = err
- return
- }
- } else {
- if _, err := g.result.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: ctx.GetStart().GetTokenIndex(),
- Stop: ctx.Comment_text().GetStart().GetTokenIndex() - 1,
- })); err != nil {
- g.err = err
- return
- }
- if _, err := g.result.WriteString(fmt.Sprintf("'%s'", escapePostgreSQLString(column.comment))); err != nil {
- g.err = err
- return
- }
- if _, err := g.result.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: ctx.Comment_text().GetStop().GetTokenIndex() + 1,
- Stop: endTokenIndex,
- })); err != nil {
- g.err = err
- return
- }
- }
- case ctx.Object_type_any_name() != nil && ctx.Object_type_any_name().TABLE() != nil:
- schemaName, tableName, err := pgparser.NormalizePostgreSQLAnyNameAsTableName(ctx.Any_name())
- if err != nil {
- g.err = err
- return
- }
- schema, exists := g.to.schemas[schemaName]
- if !exists {
- // Skip not found schema.
- return
- }
- table, exists := schema.tables[tableName]
- if !exists {
- // Skip not found table.
- return
- }
- equal := false
- table.ignoreComment = true
- if ctx.Comment_text().NULL_P() != nil {
- equal = len(table.comment) == 0
- } else {
- if len(table.comment) == 0 {
- // Skip for empty comment string.
- return
- }
- commentText := ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: ctx.Comment_text().GetStart().GetTokenIndex(),
- Stop: ctx.Comment_text().GetStop().GetTokenIndex(),
- })
- if len(commentText) > 2 && commentText[0] == '\'' && commentText[len(commentText)-1] == '\'' {
- commentText = unescapePostgreSQLString(commentText[1 : len(commentText)-1])
- }
-
- equal = commentText == table.comment
- }
-
- if equal {
- if _, err := g.result.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: ctx.GetStart().GetTokenIndex(),
- Stop: endTokenIndex,
- })); err != nil {
- g.err = err
- return
- }
- } else {
- if _, err := g.result.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: ctx.GetStart().GetTokenIndex(),
- Stop: ctx.Comment_text().GetStart().GetTokenIndex() - 1,
- })); err != nil {
- g.err = err
- return
- }
- if _, err := g.result.WriteString(fmt.Sprintf("'%s'", escapePostgreSQLString(table.comment))); err != nil {
- g.err = err
- return
- }
- if _, err := g.result.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: ctx.Comment_text().GetStop().GetTokenIndex() + 1,
- Stop: endTokenIndex,
- })); err != nil {
- g.err = err
- return
- }
- }
- default:
- // Keep other comment statements.
- if _, err := g.result.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: ctx.GetStart().GetTokenIndex(),
- Stop: endTokenIndex,
- })); err != nil {
- g.err = err
- return
- }
- return
- }
-}
-
-func (g *designSchemaGenerator) EnterColumnDef(ctx *postgres.ColumnDefContext) {
- if g.err != nil || g.currentTable == nil {
- return
- }
-
- columnName := pgparser.NormalizePostgreSQLColid(ctx.Colid())
- column, exists := g.currentTable.columns[columnName]
- if !exists {
- return
- }
- column.ignore = true
-
- if g.firstElementInTable {
- g.firstElementInTable = false
- } else {
- if _, err := g.columnDefine.WriteString(",\n "); err != nil {
- g.err = err
- return
- }
- }
-
- // compare column type
- columnType := ctx.GetParser().GetTokenStream().GetTextFromRuleContext(
- ctx.Typename(),
- )
- equal, err := equalType(column.tp, columnType)
- if err != nil {
- g.err = err
- return
- }
- if !equal {
- if _, err := g.columnDefine.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: ctx.GetStart().GetTokenIndex(),
- Stop: ctx.Typename().GetStart().GetTokenIndex() - 1,
- })); err != nil {
- g.err = err
- return
- }
- if _, err := g.columnDefine.WriteString(column.tp); err != nil {
- g.err = err
- return
- }
- } else {
- if _, err := g.columnDefine.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: ctx.GetStart().GetTokenIndex(),
- Stop: ctx.Typename().GetStop().GetTokenIndex(),
- })); err != nil {
- g.err = err
- return
- }
- }
- needOneSpace := false
-
- // if there are other tokens between column type and column constraint, write them.
- if ctx.Colquallist().GetStop().GetTokenIndex() > ctx.Colquallist().GetStart().GetTokenIndex() {
- if _, err := g.columnDefine.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: ctx.Typename().GetStop().GetTokenIndex() + 1,
- Stop: ctx.Colquallist().GetStart().GetTokenIndex() - 1,
- })); err != nil {
- g.err = err
- return
- }
- } else {
- needOneSpace = true
- }
- startPos := ctx.Colquallist().GetStart().GetTokenIndex()
-
- if !column.nullable && !nullableExists(ctx.Colquallist()) {
- if needOneSpace {
- if _, err := g.columnDefine.WriteString(" "); err != nil {
- g.err = err
- return
- }
- }
- if _, err := g.columnDefine.WriteString("NOT NULL"); err != nil {
- g.err = err
- return
- }
- needOneSpace = true
- }
-
- if column.hasDefault && !defaultExists(ctx.Colquallist()) {
- if needOneSpace {
- if _, err := g.columnDefine.WriteString(" "); err != nil {
- g.err = err
- return
- }
- }
- if _, err := g.columnDefine.WriteString(fmt.Sprintf("DEFAULT %s", column.defaultValue.toString())); err != nil {
- g.err = err
- return
- }
- needOneSpace = true
- }
-
- for i, item := range ctx.Colquallist().AllColconstraint() {
- if i == 0 && needOneSpace {
- if _, err := g.columnDefine.WriteString(" "); err != nil {
- g.err = err
- return
- }
- }
- if item.Colconstraintelem() == nil {
- if _, err := g.columnDefine.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(
- antlr.Interval{
- Start: startPos,
- Stop: item.GetStop().GetTokenIndex(),
- },
- )); err != nil {
- g.err = err
- return
- }
- startPos = item.GetStop().GetTokenIndex() + 1
- continue
- }
-
- constraint := item.Colconstraintelem()
-
- switch {
- case constraint.NULL_P() != nil:
- sameNullable := (constraint.NOT() == nil && column.nullable) || (constraint.NOT() != nil && !column.nullable)
- if sameNullable {
- if _, err := g.columnDefine.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(
- antlr.Interval{
- Start: startPos,
- Stop: item.GetStop().GetTokenIndex(),
- },
- )); err != nil {
- g.err = err
- return
- }
- }
- case constraint.DEFAULT() != nil:
- defaultValue := ctx.GetParser().GetTokenStream().GetTextFromInterval(antlr.Interval{
- Start: constraint.B_expr().GetStart().GetTokenIndex(),
- Stop: constraint.B_expr().GetStop().GetTokenIndex(),
- })
- if column.hasDefault && column.defaultValue.toString() == defaultValue {
- if _, err := g.columnDefine.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(
- antlr.Interval{
- Start: startPos,
- Stop: item.GetStop().GetTokenIndex(),
- },
- )); err != nil {
- g.err = err
- return
- }
- } else if column.hasDefault {
- if _, err := g.columnDefine.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(
- antlr.Interval{
- Start: startPos,
- Stop: constraint.B_expr().GetStart().GetTokenIndex() - 1,
- },
- )); err != nil {
- g.err = err
- return
- }
- if _, err := g.columnDefine.WriteString(column.defaultValue.toString()); err != nil {
- g.err = err
- return
- }
- }
- default:
- if _, err := g.columnDefine.WriteString(ctx.GetParser().GetTokenStream().GetTextFromInterval(
- antlr.Interval{
- Start: startPos,
- Stop: item.GetStop().GetTokenIndex(),
- },
- )); err != nil {
- g.err = err
- return
- }
- }
- startPos = item.GetStop().GetTokenIndex() + 1
- }
-}
-
-func defaultExists(colquallist postgres.IColquallistContext) bool {
- if colquallist == nil {
- return false
- }
-
- for _, item := range colquallist.AllColconstraint() {
- if item.Colconstraintelem() == nil {
- continue
- }
-
- if item.Colconstraintelem().DEFAULT() != nil {
- return true
- }
- }
-
- return false
-}
-
-func nullableExists(colquallist postgres.IColquallistContext) bool {
- if colquallist == nil {
- return false
- }
-
- for _, item := range colquallist.AllColconstraint() {
- if item.Colconstraintelem() == nil {
- continue
- }
-
- if item.Colconstraintelem().NULL_P() != nil {
- return true
- }
- }
-
- return false
-}
-
-func equalType(typeA, typeB string) (bool, error) {
- list, err := pgrawparser.Parse(pgrawparser.ParseContext{}, fmt.Sprintf("CREATE TABLE t (a %s)", typeA))
- if err != nil {
- return false, err
- }
- if len(list) != 1 {
- return false, errors.Errorf("failed to compare type %q and %q: more than one statement", typeA, typeB)
- }
- node, ok := list[0].(*ast.CreateTableStmt)
- if !ok {
- return false, errors.Errorf("failed to compare type %q and %q: not CreateTableStmt", typeA, typeB)
- }
- if len(node.ColumnList) != 1 {
- return false, errors.Errorf("failed to compare type %q and %q: more than one column", typeA, typeB)
- }
- column := node.ColumnList[0]
- return column.Type.EquivalentType(typeB), nil
-}
diff --git a/backend/plugin/schema/pg/get_design_schema_test.go b/backend/plugin/schema/pg/get_design_schema_test.go
deleted file mode 100644
index 35e169cb4a..0000000000
--- a/backend/plugin/schema/pg/get_design_schema_test.go
+++ /dev/null
@@ -1,59 +0,0 @@
-package pg
-
-import (
- "io"
- "os"
- "testing"
-
- "github.com/stretchr/testify/require"
- "gopkg.in/yaml.v3"
-
- // Import PostgreSQL parser.
- "github.com/bytebase/bytebase/backend/common"
- _ "github.com/bytebase/bytebase/backend/plugin/parser/sql/engine/pg"
- storepb "github.com/bytebase/bytebase/proto/generated-go/store"
-)
-
-type getSchemaDesignTest struct {
- Baseline string
- Target string
- Result string
-}
-
-func TestGetSchemaDesign(t *testing.T) {
- const (
- record = false
- )
- var (
- filepath = "testdata/get_design_schema.yaml"
- )
-
- a := require.New(t)
- yamlFile, err := os.Open(filepath)
- a.NoError(err)
-
- tests := []getSchemaDesignTest{}
- byteValue, err := io.ReadAll(yamlFile)
- a.NoError(yamlFile.Close())
- a.NoError(err)
- a.NoError(yaml.Unmarshal(byteValue, &tests))
-
- for i, t := range tests {
- targetSchema := &storepb.DatabaseSchemaMetadata{}
- a.NoError(common.ProtojsonUnmarshaler.Unmarshal([]byte(t.Target), targetSchema))
- result, err := GetDesignSchema(targetSchema)
- a.NoError(err)
- if record {
- tests[i].Result = result
- } else {
- a.Equal(t.Result, result)
- }
- }
-
- if record {
- byteValue, err := yaml.Marshal(tests)
- a.NoError(err)
- err = os.WriteFile(filepath, byteValue, 0644)
- a.NoError(err)
- }
-}
diff --git a/backend/plugin/schema/pg/state.go b/backend/plugin/schema/pg/state.go
deleted file mode 100644
index aa1b8ee20e..0000000000
--- a/backend/plugin/schema/pg/state.go
+++ /dev/null
@@ -1,421 +0,0 @@
-package pg
-
-import (
- "fmt"
- "sort"
- "strings"
-
- storepb "github.com/bytebase/bytebase/proto/generated-go/store"
-)
-
-type databaseState struct {
- name string
- schemas map[string]*schemaState
-}
-
-func newDatabaseState() *databaseState {
- return &databaseState{
- schemas: make(map[string]*schemaState),
- }
-}
-
-func convertToDatabaseState(database *storepb.DatabaseSchemaMetadata) *databaseState {
- state := newDatabaseState()
- state.name = database.Name
- for i, schema := range database.Schemas {
- state.schemas[schema.Name] = convertToSchemaState(i, schema)
- }
- return state
-}
-
-type schemaState struct {
- id int
- // ignore means CREATE SCHEMA statement for this schema is already in the target schema info.
- // But we need the schemaState to deal with the other objects.
- // So we cannot delete the schemaState, instead we set ignore to true.
- ignore bool
- name string
- tables map[string]*tableState
-}
-
-func (s *schemaState) printCreateSchema(buf *strings.Builder) error {
- if s.ignore || s.name == "public" {
- return nil
- }
-
- _, err := buf.WriteString(fmt.Sprintf("\nCREATE SCHEMA \"%s\";\n\n", s.name))
-
- return err
-}
-
-func newSchemaState(id int, name string) *schemaState {
- return &schemaState{
- id: id,
- name: name,
- tables: make(map[string]*tableState),
- }
-}
-
-func convertToSchemaState(id int, schema *storepb.SchemaMetadata) *schemaState {
- state := newSchemaState(id, schema.Name)
- for i, table := range schema.Tables {
- state.tables[table.Name] = convertToTableState(i, table)
- }
- return state
-}
-
-type tableState struct {
- ignoreTable bool
- id int
- name string
- columns map[string]*columnState
- indexes map[string]*indexState
- foreignKeys map[string]*foreignKeyState
- // ignoreComment means this column is already in the target schema.
- ignoreComment bool
- comment string
-}
-
-func (t *tableState) commentToString(buf *strings.Builder, schemaName string) error {
- if _, err := buf.WriteString(fmt.Sprintf("COMMENT ON TABLE \"%s\".\"%s\" IS '%s';\n", schemaName, t.name, escapePostgreSQLString(t.comment))); err != nil {
- return err
- }
- return nil
-}
-
-func (t *tableState) toString(buf *strings.Builder, schemaName string) error {
- if !t.ignoreTable {
- if _, err := buf.WriteString(fmt.Sprintf("CREATE TABLE \"%s\".\"%s\" (\n ", schemaName, t.name)); err != nil {
- return err
- }
- columns := []*columnState{}
- for _, column := range t.columns {
- columns = append(columns, column)
- }
- sort.Slice(columns, func(i, j int) bool {
- return columns[i].id < columns[j].id
- })
- for i, column := range columns {
- if i > 0 {
- if _, err := buf.WriteString(",\n "); err != nil {
- return err
- }
- }
- if err := column.toString(buf); err != nil {
- return err
- }
- }
- if _, err := buf.WriteString("\n);\n"); err != nil {
- return err
- }
- }
-
- indexes := []*indexState{}
- for _, index := range t.indexes {
- indexes = append(indexes, index)
- }
- sort.Slice(indexes, func(i, j int) bool {
- return indexes[i].id < indexes[j].id
- })
-
- for _, index := range indexes {
- if err := index.toString(buf, schemaName, t.name); err != nil {
- return err
- }
- if _, err := buf.WriteString("\n"); err != nil {
- return err
- }
- }
-
- foreignKeys := []*foreignKeyState{}
- for _, fk := range t.foreignKeys {
- foreignKeys = append(foreignKeys, fk)
- }
- sort.Slice(foreignKeys, func(i, j int) bool {
- return foreignKeys[i].id < foreignKeys[j].id
- })
-
- for _, fk := range foreignKeys {
- if err := fk.toString(buf, schemaName, t.name); err != nil {
- return err
- }
- if _, err := buf.WriteString("\n"); err != nil {
- return err
- }
- }
-
- return nil
-}
-
-func newTableState(id int, name string) *tableState {
- return &tableState{
- id: id,
- name: name,
- columns: make(map[string]*columnState),
- indexes: make(map[string]*indexState),
- foreignKeys: make(map[string]*foreignKeyState),
- }
-}
-
-func convertToTableState(id int, table *storepb.TableMetadata) *tableState {
- state := newTableState(id, table.Name)
- for i, column := range table.Columns {
- state.columns[column.Name] = convertToColumnState(i, column)
- }
- for i, index := range table.Indexes {
- state.indexes[index.Name] = convertToIndexState(i, index)
- }
- for i, fk := range table.ForeignKeys {
- state.foreignKeys[fk.Name] = convertToForeignKeyState(i, fk)
- }
- state.comment = table.Comment
- return state
-}
-
-type foreignKeyState struct {
- id int
- name string
- columns []string
- referencedSchema string
- referencedTable string
- referencedColumns []string
-}
-
-func convertToForeignKeyState(id int, foreignKey *storepb.ForeignKeyMetadata) *foreignKeyState {
- return &foreignKeyState{
- id: id,
- name: foreignKey.Name,
- columns: foreignKey.Columns,
- referencedSchema: foreignKey.ReferencedSchema,
- referencedTable: foreignKey.ReferencedTable,
- referencedColumns: foreignKey.ReferencedColumns,
- }
-}
-
-func (f *foreignKeyState) toString(buf *strings.Builder, schemaName, tableName string) error {
- if _, err := buf.WriteString("ALTER TABLE ONLY \""); err != nil {
- return err
- }
- if _, err := buf.WriteString(schemaName); err != nil {
- return err
- }
- if _, err := buf.WriteString("\".\""); err != nil {
- return err
- }
- if _, err := buf.WriteString(tableName); err != nil {
- return err
- }
- if _, err := buf.WriteString("\"\n ADD CONSTRAINT \""); err != nil {
- return err
- }
- if _, err := buf.WriteString(f.name); err != nil {
- return err
- }
- if _, err := buf.WriteString(`" FOREIGN KEY (`); err != nil {
- return err
- }
- for i, column := range f.columns {
- if i > 0 {
- if _, err := buf.WriteString(", "); err != nil {
- return err
- }
- }
- if _, err := buf.WriteString("\""); err != nil {
- return err
- }
- if _, err := buf.WriteString(column); err != nil {
- return err
- }
- if _, err := buf.WriteString("\""); err != nil {
- return err
- }
- }
- if _, err := buf.WriteString(`) REFERENCES "`); err != nil {
- return err
- }
- if _, err := buf.WriteString(f.referencedSchema); err != nil {
- return err
- }
- if _, err := buf.WriteString(`"."`); err != nil {
- return err
- }
- if _, err := buf.WriteString(f.referencedTable); err != nil {
- return err
- }
- if _, err := buf.WriteString(`"(`); err != nil {
- return err
- }
- for i, column := range f.referencedColumns {
- if i > 0 {
- if _, err := buf.WriteString(", "); err != nil {
- return err
- }
- }
- if _, err := buf.WriteString("\""); err != nil {
- return err
- }
- if _, err := buf.WriteString(column); err != nil {
- return err
- }
- if _, err := buf.WriteString("\""); err != nil {
- return err
- }
- }
- if _, err := buf.WriteString(");\n"); err != nil {
- return err
- }
- return nil
-}
-
-type indexState struct {
- id int
- name string
- keys []string
- primary bool
- unique bool
- definition string
-}
-
-func convertToIndexState(id int, index *storepb.IndexMetadata) *indexState {
- return &indexState{
- id: id,
- name: index.Name,
- keys: index.Expressions,
- primary: index.Primary,
- unique: index.Unique,
- definition: index.Definition,
- }
-}
-
-func (i *indexState) toString(buf *strings.Builder, schemaName, tableName string) error {
- if i.primary {
- if _, err := buf.WriteString(fmt.Sprintf("ALTER TABLE ONLY \"%s\".\"%s\"\n ADD CONSTRAINT \"%s\" PRIMARY KEY (", schemaName, tableName, i.name)); err != nil {
- return err
- }
- for i, key := range i.keys {
- if i > 0 {
- if _, err := buf.WriteString(", "); err != nil {
- return err
- }
- }
- if _, err := buf.WriteString("\""); err != nil {
- return err
- }
- if _, err := buf.WriteString(key); err != nil {
- return err
- }
- if _, err := buf.WriteString("\""); err != nil {
- return err
- }
- }
- if _, err := buf.WriteString(");\n"); err != nil {
- return err
- }
- } else {
- if _, err := buf.WriteString(i.definition); err != nil {
- return err
- }
- }
- return nil
-}
-
-type defaultValue interface {
- isDefaultValue()
- toString() string
-}
-
-type defaultValueNull struct {
-}
-
-func (*defaultValueNull) isDefaultValue() {}
-func (*defaultValueNull) toString() string {
- return "NULL"
-}
-
-type defaultValueString struct {
- value string
-}
-
-func (*defaultValueString) isDefaultValue() {}
-func (d *defaultValueString) toString() string {
- return fmt.Sprintf("'%s'", strings.ReplaceAll(d.value, "'", "''"))
-}
-
-type defaultValueExpression struct {
- value string
-}
-
-func (*defaultValueExpression) isDefaultValue() {}
-func (d *defaultValueExpression) toString() string {
- return d.value
-}
-
-type columnState struct {
- // ignore means this column is already in the target schema.
- // But we need the columnState to deal with the comment statement.
- // So we cannot delete the columnState, instead we set ignore to true.
- ignore bool
- // ignoreComment means this column is already in the target schema.
- ignoreComment bool
- id int
- name string
- tp string
- hasDefault bool
- defaultValue defaultValue
- comment string
- nullable bool
-}
-
-func (c *columnState) commentToString(buf *strings.Builder, schemaName, tableName string) error {
- if _, err := buf.WriteString(fmt.Sprintf("COMMENT ON COLUMN \"%s\".\"%s\".\"%s\" IS '%s';\n", schemaName, tableName, c.name, escapePostgreSQLString(c.comment))); err != nil {
- return err
- }
- return nil
-}
-
-func (c *columnState) toString(buf *strings.Builder) error {
- if _, err := buf.WriteString(fmt.Sprintf(`"%s" %s`, c.name, c.tp)); err != nil {
- return err
- }
- if c.nullable {
- if _, err := buf.WriteString(" NULL"); err != nil {
- return err
- }
- } else {
- if _, err := buf.WriteString(" NOT NULL"); err != nil {
- return err
- }
- }
- if c.hasDefault {
- if _, err := buf.WriteString(fmt.Sprintf(" DEFAULT %s", c.defaultValue.toString())); err != nil {
- return err
- }
- }
- return nil
-}
-
-func convertToColumnState(id int, column *storepb.ColumnMetadata) *columnState {
- result := &columnState{
- id: id,
- name: column.Name,
- tp: column.Type,
- hasDefault: column.GetDefaultValue() != nil,
- nullable: column.Nullable,
- comment: column.Comment,
- }
- if result.hasDefault {
- switch value := column.GetDefaultValue().(type) {
- case *storepb.ColumnMetadata_DefaultNull:
- result.defaultValue = &defaultValueNull{}
- case *storepb.ColumnMetadata_Default:
- if value.Default == nil {
- result.defaultValue = &defaultValueNull{}
- } else {
- result.defaultValue = &defaultValueString{value: value.Default.GetValue()}
- }
- case *storepb.ColumnMetadata_DefaultExpression:
- result.defaultValue = &defaultValueExpression{value: value.DefaultExpression}
- }
- }
- return result
-}
diff --git a/backend/plugin/schema/redshift/get_design_schema.go b/backend/plugin/schema/redshift/get_design_schema.go
deleted file mode 100644
index 3ae519be6e..0000000000
--- a/backend/plugin/schema/redshift/get_design_schema.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package redshift
-
-import (
- "strings"
-
- "github.com/bytebase/bytebase/backend/plugin/schema"
- storepb "github.com/bytebase/bytebase/proto/generated-go/store"
-)
-
-func init() {
- schema.RegisterGetDesignSchema(storepb.Engine_REDSHIFT, GetDesignSchema)
-}
-
-func GetDesignSchema(to *storepb.DatabaseSchemaMetadata) (string, error) {
- toState := convertToDatabaseState(to)
-
- var sb strings.Builder
-
- if err := writeTables(&sb, to, toState); err != nil {
- return "", err
- }
- if err := writeViews(&sb, to, toState); err != nil {
- return "", err
- }
-
- s := sb.String()
- // Make goyamlv3 happy.
- s = strings.TrimLeft(s, "\n")
- return s, nil
-}
diff --git a/backend/plugin/schema/schema.go b/backend/plugin/schema/schema.go
index 3ede1e7a54..8b512ef1ee 100644
--- a/backend/plugin/schema/schema.go
+++ b/backend/plugin/schema/schema.go
@@ -11,9 +11,7 @@ import (
var (
mux sync.Mutex
- getDesignSchemas = make(map[storepb.Engine]getDesignSchema)
checkColumnTypes = make(map[storepb.Engine]checkColumnType)
- stringifyTables = make(map[storepb.Engine]stringifyTable)
getDatabaseDefinitions = make(map[storepb.Engine]getDatabaseDefinition)
getSchemaDefinitions = make(map[storepb.Engine]getSchemaDefinition)
getTableDefinitions = make(map[storepb.Engine]getTableDefinition)
@@ -24,9 +22,7 @@ var (
getSequenceDefinitions = make(map[storepb.Engine]getSequenceDefinition)
)
-type getDesignSchema func(*storepb.DatabaseSchemaMetadata) (string, error)
type checkColumnType func(string) bool
-type stringifyTable func(*storepb.TableMetadata) (string, error)
type getDatabaseDefinition func(GetDefinitionContext, *storepb.DatabaseSchemaMetadata) (string, error)
type getSchemaDefinition func(*storepb.SchemaMetadata) (string, error)
type getTableDefinition func(string, *storepb.TableMetadata, []*storepb.SequenceMetadata) (string, error)
@@ -177,23 +173,6 @@ func GetDatabaseDefinition(engine storepb.Engine, ctx GetDefinitionContext, meta
return f(ctx, metadata)
}
-func RegisterGetDesignSchema(engine storepb.Engine, f getDesignSchema) {
- mux.Lock()
- defer mux.Unlock()
- if _, dup := getDesignSchemas[engine]; dup {
- panic(fmt.Sprintf("Register called twice %s", engine))
- }
- getDesignSchemas[engine] = f
-}
-
-func GetDesignSchema(engine storepb.Engine, to *storepb.DatabaseSchemaMetadata) (string, error) {
- f, ok := getDesignSchemas[engine]
- if !ok {
- return "", errors.Errorf("engine %s is not supported", engine)
- }
- return f(to)
-}
-
func RegisterCheckColumnType(engine storepb.Engine, f checkColumnType) {
mux.Lock()
defer mux.Unlock()
@@ -210,20 +189,3 @@ func CheckColumnType(engine storepb.Engine, tp string) bool {
}
return f(tp)
}
-
-func RegisterStringifyTable(engine storepb.Engine, f stringifyTable) {
- mux.Lock()
- defer mux.Unlock()
- if _, dup := stringifyTables[engine]; dup {
- panic(fmt.Sprintf("Register called twice %s", engine))
- }
- stringifyTables[engine] = f
-}
-
-func StringifyTable(engine storepb.Engine, table *storepb.TableMetadata) (string, error) {
- f, ok := stringifyTables[engine]
- if !ok {
- return "", errors.Errorf("engine %s is not supported", engine)
- }
- return f(table)
-}
diff --git a/backend/plugin/schema/tidb/get_design_schema.go b/backend/plugin/schema/tidb/get_design_schema.go
deleted file mode 100644
index ada0759962..0000000000
--- a/backend/plugin/schema/tidb/get_design_schema.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package tidb
-
-import (
- "strings"
-
- "github.com/bytebase/bytebase/backend/plugin/schema"
- storepb "github.com/bytebase/bytebase/proto/generated-go/store"
-)
-
-func init() {
- schema.RegisterGetDesignSchema(storepb.Engine_TIDB, GetDesignSchema)
-}
-
-func GetDesignSchema(to *storepb.DatabaseSchemaMetadata) (string, error) {
- toState := convertToDatabaseState(to)
-
- var sb strings.Builder
-
- if err := writeTables(&sb, to, toState); err != nil {
- return "", err
- }
- if err := writeViews(&sb, to, toState); err != nil {
- return "", err
- }
-
- s := sb.String()
- // Make goyamlv3 happy.
- s = strings.TrimLeft(s, "\n")
- return s, nil
-}
diff --git a/backend/plugin/schema/tidb/get_design_schema_test.go b/backend/plugin/schema/tidb/get_design_schema_test.go
deleted file mode 100644
index 8bcbb1f0f3..0000000000
--- a/backend/plugin/schema/tidb/get_design_schema_test.go
+++ /dev/null
@@ -1,80 +0,0 @@
-package tidb
-
-import (
- "io"
- "os"
- "testing"
-
- "github.com/stretchr/testify/require"
- "gopkg.in/yaml.v3"
-
- "github.com/bytebase/bytebase/backend/common"
- storepb "github.com/bytebase/bytebase/proto/generated-go/store"
-)
-
-type designTest struct {
- Target string
- Result string
-}
-
-func TestGetDesignSchema(t *testing.T) {
- const (
- record = false
- )
- var (
- filepath = "testdata/get_design_schema.yaml"
- )
-
- a := require.New(t)
- yamlFile, err := os.Open(filepath)
- a.NoError(err)
-
- tests := []designTest{}
- byteValue, err := io.ReadAll(yamlFile)
- a.NoError(yamlFile.Close())
- a.NoError(err)
- a.NoError(yaml.Unmarshal(byteValue, &tests))
-
- for i, t := range tests {
- targetMeta := &storepb.DatabaseSchemaMetadata{}
- a.NoError(common.ProtojsonUnmarshaler.Unmarshal([]byte(t.Target), targetMeta))
- result, err := GetDesignSchema(targetMeta)
- a.NoError(err)
- if record {
- tests[i].Result = result
- } else {
- a.Equal(t.Result, result)
- }
- }
-
- if record {
- byteValue, err := yaml.Marshal(tests)
- a.NoError(err)
- err = os.WriteFile(filepath, byteValue, 0644)
- a.NoError(err)
- }
-}
-
-func TestNormalizeOnUpdate(t *testing.T) {
- tests := []struct {
- s string
- want string
- }{
- {
- s: "current_timestamp(6)",
- want: "CURRENT_TIMESTAMP(6)",
- },
- {
- s: "current_timestamp",
- want: "CURRENT_TIMESTAMP",
- },
- {
- s: "hello",
- want: "hello",
- },
- }
- for _, tc := range tests {
- got := normalizeOnUpdate(tc.s)
- require.Equal(t, tc.want, got, tc.s)
- }
-}
diff --git a/frontend/src/components/SchemaEditorLite/Panels/PreviewPane.vue b/frontend/src/components/SchemaEditorLite/Panels/PreviewPane.vue
index 20862642c6..2cb1fa71ec 100644
--- a/frontend/src/components/SchemaEditorLite/Panels/PreviewPane.vue
+++ b/frontend/src/components/SchemaEditorLite/Panels/PreviewPane.vue
@@ -54,7 +54,7 @@ import { ChevronDownIcon } from "lucide-vue-next";
import { computed, toRef } from "vue";
import { MonacoEditor } from "@/components/MonacoEditor";
import MaskSpinner from "@/components/misc/MaskSpinner.vue";
-import { sqlServiceClient } from "@/grpcweb";
+import { databaseServiceClient } from "@/grpcweb";
import type { ComposedDatabase } from "@/types";
import type { DatabaseCatalog } from "@/types/proto/v1/database_catalog_service";
import {
@@ -94,20 +94,14 @@ const { status, data, error } = useQuery({
queryFn: async () => {
if (!expanded.value) return "";
if (!debouncedMocked.value) return "";
- const { metadata, catalog } = debouncedMocked.value;
+ const { metadata } = debouncedMocked.value;
try {
- const response = await sqlServiceClient.stringifyMetadata(
- {
- engine: engine.value,
- metadata,
- catalog,
- },
- {
- silent: true,
- }
- );
- return response.schema;
+ const response = await databaseServiceClient.getSchemaString({
+ name: props.db.name,
+ metadata,
+ })
+ return response.schemaString;
} catch (err) {
return Promise.reject(new Error(extractGrpcErrorMessage(err)));
}
diff --git a/frontend/src/components/TableDetailDrawer.vue b/frontend/src/components/TableDetailDrawer.vue
index f7dfa0ce5b..3824752f71 100644
--- a/frontend/src/components/TableDetailDrawer.vue
+++ b/frontend/src/components/TableDetailDrawer.vue
@@ -74,7 +74,7 @@
<NPopover
trigger="click"
placement="bottom"
- v-if="supportStringifyMetadata(instanceEngine)"
+ v-if="supportGetStringSchema(instanceEngine)"
@update:show="(show: boolean) => show"
>
<template #trigger>
@@ -279,7 +279,7 @@ import {
hasTableEngineProperty,
instanceV1SupportsTrigger,
isDatabaseV1Queryable,
- supportStringifyMetadata,
+ supportGetStringSchema,
} from "@/utils";
import ColumnDataTable from "./ColumnDataTable/index.vue";
import { SQLEditorButtonV1 } from "./DatabaseDetail";
diff --git a/frontend/src/components/TableSchemaViewer.vue b/frontend/src/components/TableSchemaViewer.vue
index 89ddedad79..23ae47f82f 100644
--- a/frontend/src/components/TableSchemaViewer.vue
+++ b/frontend/src/components/TableSchemaViewer.vue
@@ -33,26 +33,19 @@
<script lang="ts" setup>
import { useClipboard } from "@vueuse/core";
-import { cloneDeep, isUndefined } from "lodash-es";
import { ClipboardIcon } from "lucide-vue-next";
import { NButton, NTooltip } from "naive-ui";
import { onMounted, ref, computed } from "vue";
import { nextTick } from "vue";
import { useI18n } from "vue-i18n";
import { MonacoEditor } from "@/components/MonacoEditor";
-import { sqlServiceClient } from "@/grpcweb";
+import { databaseServiceClient } from "@/grpcweb";
import {
pushNotification,
- useDBSchemaV1Store,
- useSettingV1Store,
- useDatabaseCatalogV1Store,
} from "@/store";
import type { ComposedDatabase } from "@/types";
import {
- DatabaseMetadata,
- DatabaseMetadataView,
- SchemaMetadata,
- TableMetadata,
+ GetSchemaStringRequest_ObjectType,
} from "@/types/proto/v1/database_service";
import { hasSchemaProperty } from "@/utils";
@@ -63,9 +56,6 @@ const props = defineProps<{
}>();
const { t } = useI18n();
-const dbSchemaStore = useDBSchemaV1Store();
-const dbCatalogStore = useDatabaseCatalogV1Store();
-const settingStore = useSettingV1Store();
const { copy: copyTextToClipboard, isSupported } = useClipboard({
legacy: true,
@@ -76,28 +66,6 @@ const engine = computed(() => {
return props.database.instanceResource.engine;
});
-const databaseMetadata = computed(() => {
- return dbSchemaStore.getDatabaseMetadata(props.database.name);
-});
-
-const schemaMetadata = computed(() => {
- if (!isUndefined(props.schema)) {
- return databaseMetadata.value?.schemas.find(
- (schema) => schema.name === props.schema
- );
- }
- return null;
-});
-
-const tableMetadata = computed(() => {
- if (props.table && schemaMetadata.value) {
- return schemaMetadata.value.tables.find(
- (table) => table.name === props.table
- );
- }
- return null;
-});
-
const resourceName = computed(() => {
if (props.table) {
if (hasSchemaProperty(engine.value)) {
@@ -113,47 +81,14 @@ const resourceName = computed(() => {
});
onMounted(async () => {
- await dbSchemaStore.getOrFetchDatabaseMetadata({
- database: props.database.name,
- view: DatabaseMetadataView.DATABASE_METADATA_VIEW_FULL,
- silent: true,
- });
-
nextTick(async () => {
- const mockedDatabaseMetadata = DatabaseMetadata.fromPartial({
+ const response = await databaseServiceClient.getSchemaString({
name: props.database.name,
- });
- const catalog = await dbCatalogStore.getOrFetchDatabaseCatalog({
- database: props.database.name,
- skipCache: false,
- });
-
- if (!isUndefined(props.schema)) {
- const schemaMetadata = SchemaMetadata.fromPartial({
- name: props.schema,
- });
- if (props.table) {
- schemaMetadata.tables = [
- TableMetadata.fromPartial({
- ...cloneDeep(tableMetadata.value),
- foreignKeys: tableMetadata.value?.foreignKeys ?? [],
- }),
- ];
- }
- mockedDatabaseMetadata.schemas = [schemaMetadata];
- }
-
- const classificationConfig = settingStore.getProjectClassification(
- props.database.projectEntity.dataClassificationConfigId
- );
- const { schema } = await sqlServiceClient.stringifyMetadata({
- metadata: mockedDatabaseMetadata,
- catalog,
- engine: engine.value,
- classificationFromConfig:
- classificationConfig?.classificationFromConfig ?? false,
- });
- schemaString.value = schema.trim();
+ type: GetSchemaStringRequest_ObjectType.TABLE,
+ schema: props.schema,
+ object: props.table,
+ })
+ schemaString.value = response.schemaString.trim();
});
});
diff --git a/frontend/src/types/proto/v1/sql_service.ts b/frontend/src/types/proto/v1/sql_service.ts
index bd39fe94fc..049f7780b2 100644
--- a/frontend/src/types/proto/v1/sql_service.ts
+++ b/frontend/src/types/proto/v1/sql_service.ts
@@ -500,22 +500,6 @@ export interface ParseMyBatisMapperResponse {
statements: string[];
}
-export interface StringifyMetadataRequest {
- metadata:
- | DatabaseMetadata
- | undefined;
- /** The database engine of the schema string. */
- engine: Engine;
- /** If false, we will build the raw common by classification in database catalog. */
- classificationFromConfig: boolean;
- /** Database catlog is required if classification_from_config is false. */
- catalog?: DatabaseCatalog | undefined;
-}
-
-export interface StringifyMetadataResponse {
- schema: string;
-}
-
export interface DiffMetadataRequest {
/** The metadata of the source schema. */
sourceMetadata:
@@ -3129,183 +3113,6 @@ export const ParseMyBatisMapperResponse: MessageFns<ParseMyBatisMapperResponse>
},
};
-function createBaseStringifyMetadataRequest(): StringifyMetadataRequest {
- return {
- metadata: undefined,
- engine: Engine.ENGINE_UNSPECIFIED,
- classificationFromConfig: false,
- catalog: undefined,
- };
-}
-
-export const StringifyMetadataRequest: MessageFns<StringifyMetadataRequest> = {
- encode(message: StringifyMetadataRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.metadata !== undefined) {
- DatabaseMetadata.encode(message.metadata, writer.uint32(10).fork()).join();
- }
- if (message.engine !== Engine.ENGINE_UNSPECIFIED) {
- writer.uint32(16).int32(engineToNumber(message.engine));
- }
- if (message.classificationFromConfig !== false) {
- writer.uint32(24).bool(message.classificationFromConfig);
- }
- if (message.catalog !== undefined) {
- DatabaseCatalog.encode(message.catalog, writer.uint32(34).fork()).join();
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): StringifyMetadataRequest {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseStringifyMetadataRequest();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 10) {
- break;
- }
-
- message.metadata = DatabaseMetadata.decode(reader, reader.uint32());
- continue;
- }
- case 2: {
- if (tag !== 16) {
- break;
- }
-
- message.engine = engineFromJSON(reader.int32());
- continue;
- }
- case 3: {
- if (tag !== 24) {
- break;
- }
-
- message.classificationFromConfig = reader.bool();
- continue;
- }
- case 4: {
- if (tag !== 34) {
- break;
- }
-
- message.catalog = DatabaseCatalog.decode(reader, reader.uint32());
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): StringifyMetadataRequest {
- return {
- metadata: isSet(object.metadata) ? DatabaseMetadata.fromJSON(object.metadata) : undefined,
- engine: isSet(object.engine) ? engineFromJSON(object.engine) : Engine.ENGINE_UNSPECIFIED,
- classificationFromConfig: isSet(object.classificationFromConfig)
- ? globalThis.Boolean(object.classificationFromConfig)
- : false,
- catalog: isSet(object.catalog) ? DatabaseCatalog.fromJSON(object.catalog) : undefined,
- };
- },
-
- toJSON(message: StringifyMetadataRequest): unknown {
- const obj: any = {};
- if (message.metadata !== undefined) {
- obj.metadata = DatabaseMetadata.toJSON(message.metadata);
- }
- if (message.engine !== Engine.ENGINE_UNSPECIFIED) {
- obj.engine = engineToJSON(message.engine);
- }
- if (message.classificationFromConfig !== false) {
- obj.classificationFromConfig = message.classificationFromConfig;
- }
- if (message.catalog !== undefined) {
- obj.catalog = DatabaseCatalog.toJSON(message.catalog);
- }
- return obj;
- },
-
- create(base?: DeepPartial<StringifyMetadataRequest>): StringifyMetadataRequest {
- return StringifyMetadataRequest.fromPartial(base ?? {});
- },
- fromPartial(object: DeepPartial<StringifyMetadataRequest>): StringifyMetadataRequest {
- const message = createBaseStringifyMetadataRequest();
- message.metadata = (object.metadata !== undefined && object.metadata !== null)
- ? DatabaseMetadata.fromPartial(object.metadata)
- : undefined;
- message.engine = object.engine ?? Engine.ENGINE_UNSPECIFIED;
- message.classificationFromConfig = object.classificationFromConfig ?? false;
- message.catalog = (object.catalog !== undefined && object.catalog !== null)
- ? DatabaseCatalog.fromPartial(object.catalog)
- : undefined;
- return message;
- },
-};
-
-function createBaseStringifyMetadataResponse(): StringifyMetadataResponse {
- return { schema: "" };
-}
-
-export const StringifyMetadataResponse: MessageFns<StringifyMetadataResponse> = {
- encode(message: StringifyMetadataResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.schema !== "") {
- writer.uint32(10).string(message.schema);
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): StringifyMetadataResponse {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseStringifyMetadataResponse();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 10) {
- break;
- }
-
- message.schema = reader.string();
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): StringifyMetadataResponse {
- return { schema: isSet(object.schema) ? globalThis.String(object.schema) : "" };
- },
-
- toJSON(message: StringifyMetadataResponse): unknown {
- const obj: any = {};
- if (message.schema !== "") {
- obj.schema = message.schema;
- }
- return obj;
- },
-
- create(base?: DeepPartial<StringifyMetadataResponse>): StringifyMetadataResponse {
- return StringifyMetadataResponse.fromPartial(base ?? {});
- },
- fromPartial(object: DeepPartial<StringifyMetadataResponse>): StringifyMetadataResponse {
- const message = createBaseStringifyMetadataResponse();
- message.schema = object.schema ?? "";
- return message;
- },
-};
-
function createBaseDiffMetadataRequest(): DiffMetadataRequest {
return {
sourceMetadata: undefined,
@@ -4271,62 +4078,6 @@ export const SQLServiceDefinition = {
},
},
},
- stringifyMetadata: {
- name: "StringifyMetadata",
- requestType: StringifyMetadataRequest,
- requestStream: false,
- responseType: StringifyMetadataResponse,
- responseStream: false,
- options: {
- _unknownFields: {
- 800000: [new Uint8Array([1])],
- 578365826: [
- new Uint8Array([
- 39,
- 58,
- 1,
- 42,
- 34,
- 34,
- 47,
- 118,
- 49,
- 47,
- 115,
- 99,
- 104,
- 101,
- 109,
- 97,
- 68,
- 101,
- 115,
- 105,
- 103,
- 110,
- 58,
- 115,
- 116,
- 114,
- 105,
- 110,
- 103,
- 105,
- 102,
- 121,
- 77,
- 101,
- 116,
- 97,
- 100,
- 97,
- 116,
- 97,
- ]),
- ],
- },
- },
- },
diffMetadata: {
name: "DiffMetadata",
requestType: DiffMetadataRequest,
diff --git a/frontend/src/utils/v1/instance.ts b/frontend/src/utils/v1/instance.ts
index 739984e11a..fc398b40ac 100644
--- a/frontend/src/utils/v1/instance.ts
+++ b/frontend/src/utils/v1/instance.ts
@@ -411,8 +411,8 @@ export const getFixedPrimaryKey = (engine: Engine) => {
return undefined;
};
-// supportStringifyMetadata returns true if the engine supports stringify metadata.
-export const supportStringifyMetadata = (engine: Engine) => {
+// supportGetStringSchema returns true if the engine supports getting schema string.
+export const supportGetStringSchema = (engine: Engine) => {
return [
Engine.MYSQL,
Engine.OCEANBASE,
@@ -420,5 +420,6 @@ export const supportStringifyMetadata = (engine: Engine) => {
Engine.TIDB,
Engine.CLICKHOUSE,
Engine.REDSHIFT,
+ Engine.ORACLE
].includes(engine);
};
diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/actions.tsx b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/actions.tsx
index 5b0285229b..ee589665ee 100644
--- a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/actions.tsx
+++ b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/actions.tsx
@@ -46,7 +46,7 @@ import {
instanceV1HasAlterSchema,
keyForDependencyColumn,
sortByDictionary,
- supportStringifyMetadata,
+ supportGetStringSchema,
toClipboard,
} from "@/utils";
import { keyWithPosition } from "../../EditorCommon";
@@ -420,7 +420,7 @@ export const useDropdown = () => {
},
});
- if (supportStringifyMetadata(db.instanceResource.engine)) {
+ if (supportGetStringSchema(db.instanceResource.engine)) {
items.push({
key: "view-schema-text",
label: t("sql-editor.view-schema-text"),
diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yaml
index 1bcab69230..b3553251aa 100644
--- a/proto/gen/grpc-doc/openapi.yaml
+++ b/proto/gen/grpc-doc/openapi.yaml
@@ -6828,30 +6828,6 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Status'
- /v1/schemaDesign:stringifyMetadata:
- post:
- tags:
- - SQLService
- operationId: SQLService_StringifyMetadata
- requestBody:
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/StringifyMetadataRequest'
- required: true
- responses:
- "200":
- description: OK
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/StringifyMetadataResponse'
- default:
- description: Default error response
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/Status'
/v1/settings:
get:
tags:
@@ -12933,58 +12909,6 @@ components:
$ref: '#/components/schemas/GoogleProtobufAny'
description: A list of messages that carry the error details. There is a common set of message types for APIs to use.
description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).'
- StringifyMetadataRequest:
- required:
- - metadata
- type: object
- properties:
- metadata:
- $ref: '#/components/schemas/DatabaseMetadata'
- engine:
- enum:
- - ENGINE_UNSPECIFIED
- - CLICKHOUSE
- - MYSQL
- - POSTGRES
- - SNOWFLAKE
- - SQLITE
- - TIDB
- - MONGODB
- - REDIS
- - ORACLE
- - SPANNER
- - MSSQL
- - REDSHIFT
- - MARIADB
- - OCEANBASE
- - DM
- - RISINGWAVE
- - OCEANBASE_ORACLE
- - STARROCKS
- - DORIS
- - HIVE
- - ELASTICSEARCH
- - BIGQUERY
- - DYNAMODB
- - DATABRICKS
- - COCKROACHDB
- - COSMOSDB
- type: string
- description: The database engine of the schema string.
- format: enum
- classificationFromConfig:
- type: boolean
- description: If false, we will build the raw common by classification in database catalog.
- catalog:
- allOf:
- - $ref: '#/components/schemas/DatabaseCatalog'
- description: Database catlog is required if classification_from_config is false.
- StringifyMetadataResponse:
- type: object
- properties:
- schema:
- readOnly: true
- type: string
Subscription:
type: object
properties:
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 1e27181834..44a74f8c00 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -553,8 +553,6 @@
- [RowValue.TimestampTZ](#bytebase-v1-RowValue-TimestampTZ)
- [SearchQueryHistoriesRequest](#bytebase-v1-SearchQueryHistoriesRequest)
- [SearchQueryHistoriesResponse](#bytebase-v1-SearchQueryHistoriesResponse)
- - [StringifyMetadataRequest](#bytebase-v1-StringifyMetadataRequest)
- - [StringifyMetadataResponse](#bytebase-v1-StringifyMetadataResponse)
- [Advice.Status](#bytebase-v1-Advice-Status)
- [CheckRequest.ChangeType](#bytebase-v1-CheckRequest-ChangeType)
@@ -8986,39 +8984,6 @@ for field description.
-
-<a name="bytebase-v1-StringifyMetadataRequest"></a>
-
-### StringifyMetadataRequest
-
-
-
-| Field | Type | Label | Description |
-| ----- | ---- | ----- | ----------- |
-| metadata | [DatabaseMetadata](#bytebase-v1-DatabaseMetadata) | | |
-| engine | [Engine](#bytebase-v1-Engine) | | The database engine of the schema string. |
-| classification_from_config | [bool](#bool) | | If false, we will build the raw common by classification in database catalog. |
-| catalog | [DatabaseCatalog](#bytebase-v1-DatabaseCatalog) | optional | Database catlog is required if classification_from_config is false. |
-
-
-
-
-
-
-<a name="bytebase-v1-StringifyMetadataResponse"></a>
-
-### StringifyMetadataResponse
-
-
-
-| Field | Type | Label | Description |
-| ----- | ---- | ----- | ----------- |
-| schema | [string](#string) | | |
-
-
-
-
-
@@ -9095,7 +9060,6 @@ for field description.
| Check | [CheckRequest](#bytebase-v1-CheckRequest) | [CheckResponse](#bytebase-v1-CheckResponse) | |
| ParseMyBatisMapper | [ParseMyBatisMapperRequest](#bytebase-v1-ParseMyBatisMapperRequest) | [ParseMyBatisMapperResponse](#bytebase-v1-ParseMyBatisMapperResponse) | |
| Pretty | [PrettyRequest](#bytebase-v1-PrettyRequest) | [PrettyResponse](#bytebase-v1-PrettyResponse) | |
-| StringifyMetadata | [StringifyMetadataRequest](#bytebase-v1-StringifyMetadataRequest) | [StringifyMetadataResponse](#bytebase-v1-StringifyMetadataResponse) | |
| DiffMetadata | [DiffMetadataRequest](#bytebase-v1-DiffMetadataRequest) | [DiffMetadataResponse](#bytebase-v1-DiffMetadataResponse) | |
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index 80a0d47f9b..7f77e53a6c 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -2286,14 +2286,6 @@
<a href="#bytebase.v1.SearchQueryHistoriesResponse"><span class="badge">M</span>SearchQueryHistoriesResponse</a>
</li>
- <li>
- <a href="#bytebase.v1.StringifyMetadataRequest"><span class="badge">M</span>StringifyMetadataRequest</a>
- </li>
-
- <li>
- <a href="#bytebase.v1.StringifyMetadataResponse"><span class="badge">M</span>StringifyMetadataResponse</a>
- </li>
-
<li>
<a href="#bytebase.v1.Advice.Status"><span class="badge">E</span>Advice.Status</a>
@@ -24877,75 +24869,6 @@ Pass this value in the page_token field in the subsequent call to
- <h3 id="bytebase.v1.StringifyMetadataRequest">StringifyMetadataRequest</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>metadata</td>
- <td><a href="#bytebase.v1.DatabaseMetadata">DatabaseMetadata</a></td>
- <td></td>
- <td><p> </p></td>
- </tr>
-
- <tr>
- <td>engine</td>
- <td><a href="#bytebase.v1.Engine">Engine</a></td>
- <td></td>
- <td><p>The database engine of the schema string. </p></td>
- </tr>
-
- <tr>
- <td>classification_from_config</td>
- <td><a href="#bool">bool</a></td>
- <td></td>
- <td><p>If false, we will build the raw common by classification in database catalog. </p></td>
- </tr>
-
- <tr>
- <td>catalog</td>
- <td><a href="#bytebase.v1.DatabaseCatalog">DatabaseCatalog</a></td>
- <td>optional</td>
- <td><p>Database catlog is required if classification_from_config is false. </p></td>
- </tr>
-
- </tbody>
- </table>
-
-
-
-
-
- <h3 id="bytebase.v1.StringifyMetadataResponse">StringifyMetadataResponse</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>schema</td>
- <td><a href="#string">string</a></td>
- <td></td>
- <td><p> </p></td>
- </tr>
-
- </tbody>
- </table>
-
-
-
-
-
<h3 id="bytebase.v1.Advice.Status">Advice.Status</h3>
@@ -25143,13 +25066,6 @@ Pass this value in the page_token field in the subsequent call to
<td><p></p></td>
</tr>
- <tr>
- <td>StringifyMetadata</td>
- <td><a href="#bytebase.v1.StringifyMetadataRequest">StringifyMetadataRequest</a></td>
- <td><a href="#bytebase.v1.StringifyMetadataResponse">StringifyMetadataResponse</a></td>
- <td><p></p></td>
- </tr>
-
<tr>
<td>DiffMetadata</td>
<td><a href="#bytebase.v1.DiffMetadataRequest">DiffMetadataRequest</a></td>
@@ -25268,16 +25184,6 @@ Pass this value in the page_token field in the subsequent call to
- <tr>
- <td>StringifyMetadata</td>
- <td>POST</td>
- <td>/v1/schemaDesign:stringifyMetadata</td>
- <td>*</td>
- </tr>
-
-
-
-
<tr>
<td>DiffMetadata</td>
<td>POST</td>
diff --git a/proto/generated-go/v1/sql_service.pb.go b/proto/generated-go/v1/sql_service.pb.go
index 7d90f930a1..cc9d9cdeca 100644
--- a/proto/generated-go/v1/sql_service.pb.go
+++ b/proto/generated-go/v1/sql_service.pb.go
@@ -229,7 +229,7 @@ func (x QueryHistory_Type) Number() protoreflect.EnumNumber {
// Deprecated: Use QueryHistory_Type.Descriptor instead.
func (QueryHistory_Type) EnumDescriptor() ([]byte, []int) {
- return file_v1_sql_service_proto_rawDescGZIP(), []int{23, 0}
+ return file_v1_sql_service_proto_rawDescGZIP(), []int{21, 0}
}
type AdminExecuteRequest struct {
@@ -1609,121 +1609,6 @@ func (x *ParseMyBatisMapperResponse) GetStatements() []string {
return nil
}
-type StringifyMetadataRequest struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Metadata *DatabaseMetadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
- // The database engine of the schema string.
- Engine Engine `protobuf:"varint,2,opt,name=engine,proto3,enum=bytebase.v1.Engine" json:"engine,omitempty"`
- // If false, we will build the raw common by classification in database catalog.
- ClassificationFromConfig bool `protobuf:"varint,3,opt,name=classification_from_config,json=classificationFromConfig,proto3" json:"classification_from_config,omitempty"`
- // Database catlog is required if classification_from_config is false.
- Catalog *DatabaseCatalog `protobuf:"bytes,4,opt,name=catalog,proto3,oneof" json:"catalog,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *StringifyMetadataRequest) Reset() {
- *x = StringifyMetadataRequest{}
- mi := &file_v1_sql_service_proto_msgTypes[17]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *StringifyMetadataRequest) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*StringifyMetadataRequest) ProtoMessage() {}
-
-func (x *StringifyMetadataRequest) ProtoReflect() protoreflect.Message {
- mi := &file_v1_sql_service_proto_msgTypes[17]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use StringifyMetadataRequest.ProtoReflect.Descriptor instead.
-func (*StringifyMetadataRequest) Descriptor() ([]byte, []int) {
- return file_v1_sql_service_proto_rawDescGZIP(), []int{17}
-}
-
-func (x *StringifyMetadataRequest) GetMetadata() *DatabaseMetadata {
- if x != nil {
- return x.Metadata
- }
- return nil
-}
-
-func (x *StringifyMetadataRequest) GetEngine() Engine {
- if x != nil {
- return x.Engine
- }
- return Engine_ENGINE_UNSPECIFIED
-}
-
-func (x *StringifyMetadataRequest) GetClassificationFromConfig() bool {
- if x != nil {
- return x.ClassificationFromConfig
- }
- return false
-}
-
-func (x *StringifyMetadataRequest) GetCatalog() *DatabaseCatalog {
- if x != nil {
- return x.Catalog
- }
- return nil
-}
-
-type StringifyMetadataResponse struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Schema string `protobuf:"bytes,1,opt,name=schema,proto3" json:"schema,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *StringifyMetadataResponse) Reset() {
- *x = StringifyMetadataResponse{}
- mi := &file_v1_sql_service_proto_msgTypes[18]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *StringifyMetadataResponse) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*StringifyMetadataResponse) ProtoMessage() {}
-
-func (x *StringifyMetadataResponse) ProtoReflect() protoreflect.Message {
- mi := &file_v1_sql_service_proto_msgTypes[18]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use StringifyMetadataResponse.ProtoReflect.Descriptor instead.
-func (*StringifyMetadataResponse) Descriptor() ([]byte, []int) {
- return file_v1_sql_service_proto_rawDescGZIP(), []int{18}
-}
-
-func (x *StringifyMetadataResponse) GetSchema() string {
- if x != nil {
- return x.Schema
- }
- return ""
-}
-
type DiffMetadataRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
// The metadata of the source schema.
@@ -1742,7 +1627,7 @@ type DiffMetadataRequest struct {
func (x *DiffMetadataRequest) Reset() {
*x = DiffMetadataRequest{}
- mi := &file_v1_sql_service_proto_msgTypes[19]
+ mi := &file_v1_sql_service_proto_msgTypes[17]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -1754,7 +1639,7 @@ func (x *DiffMetadataRequest) String() string {
func (*DiffMetadataRequest) ProtoMessage() {}
func (x *DiffMetadataRequest) ProtoReflect() protoreflect.Message {
- mi := &file_v1_sql_service_proto_msgTypes[19]
+ mi := &file_v1_sql_service_proto_msgTypes[17]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -1767,7 +1652,7 @@ func (x *DiffMetadataRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use DiffMetadataRequest.ProtoReflect.Descriptor instead.
func (*DiffMetadataRequest) Descriptor() ([]byte, []int) {
- return file_v1_sql_service_proto_rawDescGZIP(), []int{19}
+ return file_v1_sql_service_proto_rawDescGZIP(), []int{17}
}
func (x *DiffMetadataRequest) GetSourceMetadata() *DatabaseMetadata {
@@ -1822,7 +1707,7 @@ type DiffMetadataResponse struct {
func (x *DiffMetadataResponse) Reset() {
*x = DiffMetadataResponse{}
- mi := &file_v1_sql_service_proto_msgTypes[20]
+ mi := &file_v1_sql_service_proto_msgTypes[18]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -1834,7 +1719,7 @@ func (x *DiffMetadataResponse) String() string {
func (*DiffMetadataResponse) ProtoMessage() {}
func (x *DiffMetadataResponse) ProtoReflect() protoreflect.Message {
- mi := &file_v1_sql_service_proto_msgTypes[20]
+ mi := &file_v1_sql_service_proto_msgTypes[18]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -1847,7 +1732,7 @@ func (x *DiffMetadataResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use DiffMetadataResponse.ProtoReflect.Descriptor instead.
func (*DiffMetadataResponse) Descriptor() ([]byte, []int) {
- return file_v1_sql_service_proto_rawDescGZIP(), []int{20}
+ return file_v1_sql_service_proto_rawDescGZIP(), []int{18}
}
func (x *DiffMetadataResponse) GetDiff() string {
@@ -1884,7 +1769,7 @@ type SearchQueryHistoriesRequest struct {
func (x *SearchQueryHistoriesRequest) Reset() {
*x = SearchQueryHistoriesRequest{}
- mi := &file_v1_sql_service_proto_msgTypes[21]
+ mi := &file_v1_sql_service_proto_msgTypes[19]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -1896,7 +1781,7 @@ func (x *SearchQueryHistoriesRequest) String() string {
func (*SearchQueryHistoriesRequest) ProtoMessage() {}
func (x *SearchQueryHistoriesRequest) ProtoReflect() protoreflect.Message {
- mi := &file_v1_sql_service_proto_msgTypes[21]
+ mi := &file_v1_sql_service_proto_msgTypes[19]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -1909,7 +1794,7 @@ func (x *SearchQueryHistoriesRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use SearchQueryHistoriesRequest.ProtoReflect.Descriptor instead.
func (*SearchQueryHistoriesRequest) Descriptor() ([]byte, []int) {
- return file_v1_sql_service_proto_rawDescGZIP(), []int{21}
+ return file_v1_sql_service_proto_rawDescGZIP(), []int{19}
}
func (x *SearchQueryHistoriesRequest) GetPageSize() int32 {
@@ -1947,7 +1832,7 @@ type SearchQueryHistoriesResponse struct {
func (x *SearchQueryHistoriesResponse) Reset() {
*x = SearchQueryHistoriesResponse{}
- mi := &file_v1_sql_service_proto_msgTypes[22]
+ mi := &file_v1_sql_service_proto_msgTypes[20]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -1959,7 +1844,7 @@ func (x *SearchQueryHistoriesResponse) String() string {
func (*SearchQueryHistoriesResponse) ProtoMessage() {}
func (x *SearchQueryHistoriesResponse) ProtoReflect() protoreflect.Message {
- mi := &file_v1_sql_service_proto_msgTypes[22]
+ mi := &file_v1_sql_service_proto_msgTypes[20]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -1972,7 +1857,7 @@ func (x *SearchQueryHistoriesResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use SearchQueryHistoriesResponse.ProtoReflect.Descriptor instead.
func (*SearchQueryHistoriesResponse) Descriptor() ([]byte, []int) {
- return file_v1_sql_service_proto_rawDescGZIP(), []int{22}
+ return file_v1_sql_service_proto_rawDescGZIP(), []int{20}
}
func (x *SearchQueryHistoriesResponse) GetQueryHistories() []*QueryHistory {
@@ -2009,7 +1894,7 @@ type QueryHistory struct {
func (x *QueryHistory) Reset() {
*x = QueryHistory{}
- mi := &file_v1_sql_service_proto_msgTypes[23]
+ mi := &file_v1_sql_service_proto_msgTypes[21]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2021,7 +1906,7 @@ func (x *QueryHistory) String() string {
func (*QueryHistory) ProtoMessage() {}
func (x *QueryHistory) ProtoReflect() protoreflect.Message {
- mi := &file_v1_sql_service_proto_msgTypes[23]
+ mi := &file_v1_sql_service_proto_msgTypes[21]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2034,7 +1919,7 @@ func (x *QueryHistory) ProtoReflect() protoreflect.Message {
// Deprecated: Use QueryHistory.ProtoReflect.Descriptor instead.
func (*QueryHistory) Descriptor() ([]byte, []int) {
- return file_v1_sql_service_proto_rawDescGZIP(), []int{23}
+ return file_v1_sql_service_proto_rawDescGZIP(), []int{21}
}
func (x *QueryHistory) GetName() string {
@@ -2120,7 +2005,7 @@ type QueryResult_PostgresError struct {
func (x *QueryResult_PostgresError) Reset() {
*x = QueryResult_PostgresError{}
- mi := &file_v1_sql_service_proto_msgTypes[24]
+ mi := &file_v1_sql_service_proto_msgTypes[22]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2132,7 +2017,7 @@ func (x *QueryResult_PostgresError) String() string {
func (*QueryResult_PostgresError) ProtoMessage() {}
func (x *QueryResult_PostgresError) ProtoReflect() protoreflect.Message {
- mi := &file_v1_sql_service_proto_msgTypes[24]
+ mi := &file_v1_sql_service_proto_msgTypes[22]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2278,7 +2163,7 @@ type RowValue_Timestamp struct {
func (x *RowValue_Timestamp) Reset() {
*x = RowValue_Timestamp{}
- mi := &file_v1_sql_service_proto_msgTypes[25]
+ mi := &file_v1_sql_service_proto_msgTypes[23]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2290,7 +2175,7 @@ func (x *RowValue_Timestamp) String() string {
func (*RowValue_Timestamp) ProtoMessage() {}
func (x *RowValue_Timestamp) ProtoReflect() protoreflect.Message {
- mi := &file_v1_sql_service_proto_msgTypes[25]
+ mi := &file_v1_sql_service_proto_msgTypes[23]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2339,7 +2224,7 @@ type RowValue_TimestampTZ struct {
func (x *RowValue_TimestampTZ) Reset() {
*x = RowValue_TimestampTZ{}
- mi := &file_v1_sql_service_proto_msgTypes[26]
+ mi := &file_v1_sql_service_proto_msgTypes[24]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2351,7 +2236,7 @@ func (x *RowValue_TimestampTZ) String() string {
func (*RowValue_TimestampTZ) ProtoMessage() {}
func (x *RowValue_TimestampTZ) ProtoReflect() protoreflect.Message {
- mi := &file_v1_sql_service_proto_msgTypes[26]
+ mi := &file_v1_sql_service_proto_msgTypes[24]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2683,187 +2568,156 @@ var file_v1_sql_service_proto_rawDesc = string([]byte{
0x61, 0x72, 0x73, 0x65, 0x4d, 0x79, 0x42, 0x61, 0x74, 0x69, 0x73, 0x4d, 0x61, 0x70, 0x70, 0x65,
0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x74, 0x61,
0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x73,
- 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x8f, 0x02, 0x0a, 0x18, 0x53, 0x74,
- 0x72, 0x69, 0x6e, 0x67, 0x69, 0x66, 0x79, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52,
- 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x3f, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61,
- 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62,
+ 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0xa6, 0x03, 0x0a, 0x13, 0x44, 0x69,
+ 0x66, 0x66, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
+ 0x74, 0x12, 0x4c, 0x0a, 0x0f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61,
+ 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x62, 0x79, 0x74,
+ 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73,
+ 0x65, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52,
+ 0x0e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12,
+ 0x4c, 0x0a, 0x0f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61,
+ 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62,
0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x4d,
- 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x08, 0x6d,
- 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x2b, 0x0a, 0x06, 0x65, 0x6e, 0x67, 0x69, 0x6e,
- 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x13, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,
+ 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x0e, 0x74,
+ 0x61, 0x72, 0x67, 0x65, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x43, 0x0a,
+ 0x0e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x18,
+ 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65,
+ 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x43, 0x61, 0x74, 0x61,
+ 0x6c, 0x6f, 0x67, 0x52, 0x0d, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x43, 0x61, 0x74, 0x61, 0x6c,
+ 0x6f, 0x67, 0x12, 0x43, 0x0a, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x63, 0x61, 0x74,
+ 0x61, 0x6c, 0x6f, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x62, 0x79, 0x74,
+ 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73,
+ 0x65, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x52, 0x0d, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74,
+ 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x12, 0x2b, 0x0a, 0x06, 0x65, 0x6e, 0x67, 0x69, 0x6e,
+ 0x65, 0x18, 0x03, 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, 0x3c, 0x0a, 0x1a, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x69, 0x66, 0x69,
0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x72, 0x6f, 0x6d, 0x5f, 0x63, 0x6f, 0x6e, 0x66,
- 0x69, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x18, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x69,
+ 0x69, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x18, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x69,
0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x72, 0x6f, 0x6d, 0x43, 0x6f, 0x6e, 0x66,
- 0x69, 0x67, 0x12, 0x3b, 0x0a, 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x18, 0x04, 0x20,
- 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76,
- 0x31, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f,
- 0x67, 0x48, 0x00, 0x52, 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x88, 0x01, 0x01, 0x42,
- 0x0a, 0x0a, 0x08, 0x5f, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x22, 0x39, 0x0a, 0x19, 0x53,
- 0x74, 0x72, 0x69, 0x6e, 0x67, 0x69, 0x66, 0x79, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61,
- 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65,
- 0x6d, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x03, 0x52, 0x06,
- 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x22, 0xa6, 0x03, 0x0a, 0x13, 0x44, 0x69, 0x66, 0x66, 0x4d,
- 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x4c,
- 0x0a, 0x0f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74,
- 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,
- 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x4d, 0x65,
- 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x0e, 0x73, 0x6f,
- 0x75, 0x72, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x4c, 0x0a, 0x0f,
- 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18,
- 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65,
- 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x4d, 0x65, 0x74, 0x61,
- 0x64, 0x61, 0x74, 0x61, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x0e, 0x74, 0x61, 0x72, 0x67,
- 0x65, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x43, 0x0a, 0x0e, 0x73, 0x6f,
- 0x75, 0x72, 0x63, 0x65, 0x5f, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x18, 0x05, 0x20, 0x01,
- 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31,
- 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67,
- 0x52, 0x0d, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x12,
- 0x43, 0x0a, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f,
- 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,
- 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x43, 0x61,
- 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x52, 0x0d, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x43, 0x61, 0x74,
- 0x61, 0x6c, 0x6f, 0x67, 0x12, 0x2b, 0x0a, 0x06, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x18, 0x03,
- 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, 0x3c, 0x0a, 0x1a, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74,
- 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x72, 0x6f, 0x6d, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18,
- 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x18, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x69, 0x66, 0x69, 0x63,
- 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x72, 0x6f, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22,
- 0x2a, 0x0a, 0x14, 0x44, 0x69, 0x66, 0x66, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52,
- 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x69, 0x66, 0x66, 0x18,
- 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x69, 0x66, 0x66, 0x22, 0x71, 0x0a, 0x1b, 0x53,
- 0x65, 0x61, 0x72, 0x63, 0x68, 0x51, 0x75, 0x65, 0x72, 0x79, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72,
- 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61,
- 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70,
- 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f,
- 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67,
- 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72,
- 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x22, 0x90,
- 0x01, 0x0a, 0x1c, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x51, 0x75, 0x65, 0x72, 0x79, 0x48, 0x69,
- 0x73, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
- 0x48, 0x0a, 0x0f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69,
- 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62,
- 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x48, 0x69, 0x73, 0x74,
- 0x6f, 0x72, 0x79, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x03, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x72, 0x79,
- 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78,
- 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01,
- 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65,
- 0x6e, 0x22, 0xa2, 0x03, 0x0a, 0x0c, 0x51, 0x75, 0x65, 0x72, 0x79, 0x48, 0x69, 0x73, 0x74, 0x6f,
- 0x72, 0x79, 0x12, 0x18, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
- 0x42, 0x04, 0xe2, 0x41, 0x01, 0x03, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x08,
- 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04,
- 0xe2, 0x41, 0x01, 0x03, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x1e,
- 0x0a, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42,
- 0x04, 0xe2, 0x41, 0x01, 0x03, 0x52, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x41,
- 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20,
- 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f,
- 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42,
- 0x04, 0xe2, 0x41, 0x01, 0x03, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d,
- 0x65, 0x12, 0x22, 0x0a, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x05,
- 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x03, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74,
- 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x1f, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x06,
- 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x03, 0x48, 0x00, 0x52, 0x05, 0x65, 0x72,
- 0x72, 0x6f, 0x72, 0x88, 0x01, 0x01, 0x12, 0x3b, 0x0a, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69,
- 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
- 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74,
- 0x69, 0x6f, 0x6e, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x03, 0x52, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74,
- 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28,
- 0x0e, 0x32, 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e,
- 0x51, 0x75, 0x65, 0x72, 0x79, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x54, 0x79, 0x70,
- 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x33, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12,
- 0x14, 0x0a, 0x10, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46,
- 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x51, 0x55, 0x45, 0x52, 0x59, 0x10, 0x01,
- 0x12, 0x0a, 0x0a, 0x06, 0x45, 0x58, 0x50, 0x4f, 0x52, 0x54, 0x10, 0x02, 0x42, 0x08, 0x0a, 0x06,
- 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x32, 0xd1, 0x0a, 0x0a, 0x0a, 0x53, 0x51, 0x4c, 0x53, 0x65,
- 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xb2, 0x01, 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, 0x72, 0x8a, 0xea, 0x30, 0x10, 0x62, 0x62, 0x2e, 0x64,
- 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x67, 0x65, 0x74, 0x90, 0xea, 0x30, 0x01,
- 0x98, 0xea, 0x30, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x50, 0x3a, 0x01, 0x2a, 0x5a, 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,
- 0x22, 0x28, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x69, 0x6e, 0x73, 0x74,
- 0x61, 0x6e, 0x63, 0x65, 0x73, 0x2f, 0x2a, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65,
- 0x73, 0x2f, 0x2a, 0x7d, 0x3a, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x89, 0x01, 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, 0x30, 0x8a, 0xea, 0x30, 0x0c, 0x62, 0x62, 0x2e, 0x73, 0x71, 0x6c, 0x2e, 0x61, 0x64, 0x6d,
- 0x69, 0x6e, 0x90, 0xea, 0x30, 0x01, 0x98, 0xea, 0x30, 0x01, 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, 0x95, 0x01, 0x0a, 0x14, 0x53, 0x65, 0x61, 0x72, 0x63,
- 0x68, 0x51, 0x75, 0x65, 0x72, 0x79, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x12,
- 0x28, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65,
+ 0x69, 0x67, 0x22, 0x2a, 0x0a, 0x14, 0x44, 0x69, 0x66, 0x66, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61,
+ 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x69,
+ 0x66, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x69, 0x66, 0x66, 0x22, 0x71,
+ 0x0a, 0x1b, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x51, 0x75, 0x65, 0x72, 0x79, 0x48, 0x69, 0x73,
+ 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a,
+ 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
+ 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61,
+ 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
+ 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x66, 0x69, 0x6c,
+ 0x74, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65,
+ 0x72, 0x22, 0x90, 0x01, 0x0a, 0x1c, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x51, 0x75, 0x65, 0x72,
+ 0x79, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
+ 0x73, 0x65, 0x12, 0x48, 0x0a, 0x0f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x68, 0x69, 0x73, 0x74,
+ 0x6f, 0x72, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x62, 0x79,
+ 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x48,
+ 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x03, 0x52, 0x0e, 0x71, 0x75,
+ 0x65, 0x72, 0x79, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0f,
+ 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18,
+ 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54,
+ 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0xa2, 0x03, 0x0a, 0x0c, 0x51, 0x75, 0x65, 0x72, 0x79, 0x48, 0x69,
+ 0x73, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x18, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20,
+ 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x03, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12,
+ 0x20, 0x0a, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
+ 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x03, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73,
+ 0x65, 0x12, 0x1e, 0x0a, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01,
+ 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x03, 0x52, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f,
+ 0x72, 0x12, 0x41, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65,
+ 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
+ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61,
+ 0x6d, 0x70, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x03, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65,
+ 0x54, 0x69, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e,
+ 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x03, 0x52, 0x09, 0x73,
+ 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x1f, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f,
+ 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x03, 0x48, 0x00, 0x52,
+ 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x88, 0x01, 0x01, 0x12, 0x3b, 0x0a, 0x08, 0x64, 0x75, 0x72,
+ 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f,
+ 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75,
+ 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x03, 0x52, 0x08, 0x64, 0x75,
+ 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x08,
+ 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,
+ 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2e,
+ 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x33, 0x0a, 0x04, 0x54, 0x79,
+ 0x70, 0x65, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45,
+ 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x51, 0x55, 0x45, 0x52,
+ 0x59, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x45, 0x58, 0x50, 0x4f, 0x52, 0x54, 0x10, 0x02, 0x42,
+ 0x08, 0x0a, 0x06, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x32, 0xb9, 0x09, 0x0a, 0x0a, 0x53, 0x51,
+ 0x4c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xb2, 0x01, 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, 0x72, 0x8a, 0xea, 0x30, 0x10, 0x62,
+ 0x62, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x67, 0x65, 0x74, 0x90,
+ 0xea, 0x30, 0x01, 0x98, 0xea, 0x30, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x50, 0x3a, 0x01, 0x2a,
+ 0x5a, 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, 0x22, 0x28, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x69,
+ 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x2f, 0x2a, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x62,
+ 0x61, 0x73, 0x65, 0x73, 0x2f, 0x2a, 0x7d, 0x3a, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x89, 0x01,
+ 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, 0x30, 0x8a, 0xea, 0x30, 0x0c, 0x62, 0x62, 0x2e, 0x73, 0x71, 0x6c, 0x2e,
+ 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x90, 0xea, 0x30, 0x01, 0x98, 0xea, 0x30, 0x01, 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, 0x95, 0x01, 0x0a, 0x14, 0x53, 0x65,
0x61, 0x72, 0x63, 0x68, 0x51, 0x75, 0x65, 0x72, 0x79, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69,
- 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x62, 0x79, 0x74, 0x65,
- 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x51, 0x75,
- 0x65, 0x72, 0x79, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70,
- 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x28, 0x90, 0xea, 0x30, 0x02, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1e,
- 0x3a, 0x01, 0x2a, 0x22, 0x19, 0x2f, 0x76, 0x31, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x48, 0x69,
- 0x73, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x3a, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x12, 0xe4,
- 0x01, 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,
+ 0x65, 0x73, 0x12, 0x28, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31,
+ 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x51, 0x75, 0x65, 0x72, 0x79, 0x48, 0x69, 0x73, 0x74,
+ 0x6f, 0x72, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x62,
+ 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63,
+ 0x68, 0x51, 0x75, 0x65, 0x72, 0x79, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x52,
+ 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x28, 0x90, 0xea, 0x30, 0x02, 0x82, 0xd3, 0xe4,
+ 0x93, 0x02, 0x1e, 0x3a, 0x01, 0x2a, 0x22, 0x19, 0x2f, 0x76, 0x31, 0x2f, 0x71, 0x75, 0x65, 0x72,
+ 0x79, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x3a, 0x73, 0x65, 0x61, 0x72, 0x63,
+ 0x68, 0x12, 0xe4, 0x01, 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, 0xa0, 0x01, 0x8a, 0xea, 0x30, 0x10, 0x62, 0x62, 0x2e, 0x64,
+ 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x67, 0x65, 0x74, 0x90, 0xea, 0x30, 0x01,
+ 0x98, 0xea, 0x30, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x7e, 0x3a, 0x01, 0x2a, 0x5a, 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, 0x5a, 0x2a, 0x3a, 0x01, 0x2a, 0x22, 0x25, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d,
+ 0x65, 0x3d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x2f, 0x2a, 0x2f, 0x69, 0x73, 0x73,
+ 0x75, 0x65, 0x73, 0x2f, 0x2a, 0x7d, 0x3a, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x22, 0x29, 0x2f,
+ 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63,
+ 0x65, 0x73, 0x2f, 0x2a, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x2a,
+ 0x7d, 0x3a, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x72, 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, 0x32, 0x8a, 0xea, 0x30, 0x12, 0x62, 0x62,
+ 0x2e, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x63, 0x68, 0x65, 0x63, 0x6b,
+ 0x90, 0xea, 0x30, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x3a, 0x01, 0x2a, 0x22, 0x0d, 0x2f,
+ 0x76, 0x31, 0x2f, 0x73, 0x71, 0x6c, 0x2f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x90, 0x01, 0x0a,
+ 0x12, 0x50, 0x61, 0x72, 0x73, 0x65, 0x4d, 0x79, 0x42, 0x61, 0x74, 0x69, 0x73, 0x4d, 0x61, 0x70,
+ 0x70, 0x65, 0x72, 0x12, 0x26, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76,
+ 0x31, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x4d, 0x79, 0x42, 0x61, 0x74, 0x69, 0x73, 0x4d, 0x61,
+ 0x70, 0x70, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x62, 0x79,
+ 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x4d,
+ 0x79, 0x42, 0x61, 0x74, 0x69, 0x73, 0x4d, 0x61, 0x70, 0x70, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70,
+ 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x80, 0xea, 0x30, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1f,
+ 0x3a, 0x01, 0x2a, 0x22, 0x1a, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x71, 0x6c, 0x2f, 0x70, 0x61, 0x72,
+ 0x73, 0x65, 0x4d, 0x79, 0x42, 0x61, 0x74, 0x69, 0x73, 0x4d, 0x61, 0x70, 0x70, 0x65, 0x72, 0x12,
+ 0x60, 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, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
- 0x73, 0x65, 0x22, 0xa0, 0x01, 0x8a, 0xea, 0x30, 0x10, 0x62, 0x62, 0x2e, 0x64, 0x61, 0x74, 0x61,
- 0x62, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x67, 0x65, 0x74, 0x90, 0xea, 0x30, 0x01, 0x98, 0xea, 0x30,
- 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x7e, 0x3a, 0x01, 0x2a, 0x5a, 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, 0x5a, 0x2a,
- 0x3a, 0x01, 0x2a, 0x22, 0x25, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x70,
- 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x2f, 0x2a, 0x2f, 0x69, 0x73, 0x73, 0x75, 0x65, 0x73,
- 0x2f, 0x2a, 0x7d, 0x3a, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x22, 0x29, 0x2f, 0x76, 0x31, 0x2f,
- 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x2f,
- 0x2a, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x2a, 0x7d, 0x3a, 0x65,
- 0x78, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x72, 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, 0x32, 0x8a, 0xea, 0x30, 0x12, 0x62, 0x62, 0x2e, 0x64, 0x61,
- 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x90, 0xea, 0x30,
- 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x3a, 0x01, 0x2a, 0x22, 0x0d, 0x2f, 0x76, 0x31, 0x2f,
- 0x73, 0x71, 0x6c, 0x2f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x90, 0x01, 0x0a, 0x12, 0x50, 0x61,
- 0x72, 0x73, 0x65, 0x4d, 0x79, 0x42, 0x61, 0x74, 0x69, 0x73, 0x4d, 0x61, 0x70, 0x70, 0x65, 0x72,
- 0x12, 0x26, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50,
- 0x61, 0x72, 0x73, 0x65, 0x4d, 0x79, 0x42, 0x61, 0x74, 0x69, 0x73, 0x4d, 0x61, 0x70, 0x70, 0x65,
- 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62,
- 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x4d, 0x79, 0x42, 0x61,
- 0x74, 0x69, 0x73, 0x4d, 0x61, 0x70, 0x70, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
- 0x65, 0x22, 0x29, 0x80, 0xea, 0x30, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1f, 0x3a, 0x01, 0x2a,
- 0x22, 0x1a, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x71, 0x6c, 0x2f, 0x70, 0x61, 0x72, 0x73, 0x65, 0x4d,
- 0x79, 0x42, 0x61, 0x74, 0x69, 0x73, 0x4d, 0x61, 0x70, 0x70, 0x65, 0x72, 0x12, 0x60, 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,
- 0x1d, 0x80, 0xea, 0x30, 0x01, 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, 0x95,
- 0x01, 0x0a, 0x11, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x69, 0x66, 0x79, 0x4d, 0x65, 0x74, 0x61,
- 0x64, 0x61, 0x74, 0x61, 0x12, 0x25, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,
- 0x76, 0x31, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x69, 0x66, 0x79, 0x4d, 0x65, 0x74, 0x61,
- 0x64, 0x61, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x62, 0x79,
- 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67,
- 0x69, 0x66, 0x79, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f,
- 0x6e, 0x73, 0x65, 0x22, 0x31, 0x80, 0xea, 0x30, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x27, 0x3a,
- 0x01, 0x2a, 0x22, 0x22, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x44, 0x65,
- 0x73, 0x69, 0x67, 0x6e, 0x3a, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x69, 0x66, 0x79, 0x4d, 0x65,
- 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x81, 0x01, 0x0a, 0x0c, 0x44, 0x69, 0x66, 0x66, 0x4d,
- 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x20, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,
- 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61,
- 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x62, 0x79, 0x74, 0x65,
- 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x4d, 0x65, 0x74, 0x61,
- 0x64, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2c, 0x80, 0xea,
- 0x30, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x22, 0x3a, 0x01, 0x2a, 0x22, 0x1d, 0x2f, 0x76, 0x31,
- 0x2f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x44, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x3a, 0x64, 0x69,
- 0x66, 0x66, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 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,
+ 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x65, 0x74, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
+ 0x73, 0x65, 0x22, 0x1d, 0x80, 0xea, 0x30, 0x01, 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, 0x81, 0x01, 0x0a, 0x0c, 0x44, 0x69, 0x66, 0x66, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61,
+ 0x74, 0x61, 0x12, 0x20, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31,
+ 0x2e, 0x44, 0x69, 0x66, 0x66, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x65, 0x71,
+ 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,
+ 0x76, 0x31, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52,
+ 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2c, 0x80, 0xea, 0x30, 0x01, 0x82, 0xd3, 0xe4,
+ 0x93, 0x02, 0x22, 0x3a, 0x01, 0x2a, 0x22, 0x1d, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x63, 0x68, 0x65,
+ 0x6d, 0x61, 0x44, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x3a, 0x64, 0x69, 0x66, 0x66, 0x4d, 0x65, 0x74,
+ 0x61, 0x64, 0x61, 0x74, 0x61, 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 (
@@ -2879,7 +2733,7 @@ func file_v1_sql_service_proto_rawDescGZIP() []byte {
}
var file_v1_sql_service_proto_enumTypes = make([]protoimpl.EnumInfo, 4)
-var file_v1_sql_service_proto_msgTypes = make([]protoimpl.MessageInfo, 27)
+var file_v1_sql_service_proto_msgTypes = make([]protoimpl.MessageInfo, 25)
var file_v1_sql_service_proto_goTypes = []any{
(QueryOption_RedisRunCommandsOn)(0), // 0: bytebase.v1.QueryOption.RedisRunCommandsOn
(Advice_Status)(0), // 1: bytebase.v1.Advice.Status
@@ -2902,25 +2756,23 @@ var file_v1_sql_service_proto_goTypes = []any{
(*CheckResponse)(nil), // 18: bytebase.v1.CheckResponse
(*ParseMyBatisMapperRequest)(nil), // 19: bytebase.v1.ParseMyBatisMapperRequest
(*ParseMyBatisMapperResponse)(nil), // 20: bytebase.v1.ParseMyBatisMapperResponse
- (*StringifyMetadataRequest)(nil), // 21: bytebase.v1.StringifyMetadataRequest
- (*StringifyMetadataResponse)(nil), // 22: bytebase.v1.StringifyMetadataResponse
- (*DiffMetadataRequest)(nil), // 23: bytebase.v1.DiffMetadataRequest
- (*DiffMetadataResponse)(nil), // 24: bytebase.v1.DiffMetadataResponse
- (*SearchQueryHistoriesRequest)(nil), // 25: bytebase.v1.SearchQueryHistoriesRequest
- (*SearchQueryHistoriesResponse)(nil), // 26: bytebase.v1.SearchQueryHistoriesResponse
- (*QueryHistory)(nil), // 27: bytebase.v1.QueryHistory
- (*QueryResult_PostgresError)(nil), // 28: bytebase.v1.QueryResult.PostgresError
- (*RowValue_Timestamp)(nil), // 29: bytebase.v1.RowValue.Timestamp
- (*RowValue_TimestampTZ)(nil), // 30: bytebase.v1.RowValue.TimestampTZ
- (*durationpb.Duration)(nil), // 31: google.protobuf.Duration
- (structpb.NullValue)(0), // 32: google.protobuf.NullValue
- (*structpb.Value)(nil), // 33: google.protobuf.Value
- (*Position)(nil), // 34: bytebase.v1.Position
- (ExportFormat)(0), // 35: bytebase.v1.ExportFormat
- (Engine)(0), // 36: bytebase.v1.Engine
- (*DatabaseMetadata)(nil), // 37: bytebase.v1.DatabaseMetadata
- (*DatabaseCatalog)(nil), // 38: bytebase.v1.DatabaseCatalog
- (*timestamppb.Timestamp)(nil), // 39: google.protobuf.Timestamp
+ (*DiffMetadataRequest)(nil), // 21: bytebase.v1.DiffMetadataRequest
+ (*DiffMetadataResponse)(nil), // 22: bytebase.v1.DiffMetadataResponse
+ (*SearchQueryHistoriesRequest)(nil), // 23: bytebase.v1.SearchQueryHistoriesRequest
+ (*SearchQueryHistoriesResponse)(nil), // 24: bytebase.v1.SearchQueryHistoriesResponse
+ (*QueryHistory)(nil), // 25: bytebase.v1.QueryHistory
+ (*QueryResult_PostgresError)(nil), // 26: bytebase.v1.QueryResult.PostgresError
+ (*RowValue_Timestamp)(nil), // 27: bytebase.v1.RowValue.Timestamp
+ (*RowValue_TimestampTZ)(nil), // 28: bytebase.v1.RowValue.TimestampTZ
+ (*durationpb.Duration)(nil), // 29: google.protobuf.Duration
+ (structpb.NullValue)(0), // 30: google.protobuf.NullValue
+ (*structpb.Value)(nil), // 31: google.protobuf.Value
+ (*Position)(nil), // 32: bytebase.v1.Position
+ (ExportFormat)(0), // 33: bytebase.v1.ExportFormat
+ (Engine)(0), // 34: bytebase.v1.Engine
+ (*DatabaseMetadata)(nil), // 35: bytebase.v1.DatabaseMetadata
+ (*DatabaseCatalog)(nil), // 36: bytebase.v1.DatabaseCatalog
+ (*timestamppb.Timestamp)(nil), // 37: google.protobuf.Timestamp
}
var file_v1_sql_service_proto_depIdxs = []int32{
9, // 0: bytebase.v1.AdminExecuteResponse.results:type_name -> bytebase.v1.QueryResult
@@ -2928,57 +2780,52 @@ var file_v1_sql_service_proto_depIdxs = []int32{
9, // 2: bytebase.v1.QueryResponse.results:type_name -> bytebase.v1.QueryResult
0, // 3: bytebase.v1.QueryOption.redis_run_commands_on:type_name -> bytebase.v1.QueryOption.RedisRunCommandsOn
10, // 4: bytebase.v1.QueryResult.rows:type_name -> bytebase.v1.QueryRow
- 31, // 5: bytebase.v1.QueryResult.latency:type_name -> google.protobuf.Duration
- 28, // 6: bytebase.v1.QueryResult.postgres_error:type_name -> bytebase.v1.QueryResult.PostgresError
+ 29, // 5: bytebase.v1.QueryResult.latency:type_name -> google.protobuf.Duration
+ 26, // 6: bytebase.v1.QueryResult.postgres_error:type_name -> bytebase.v1.QueryResult.PostgresError
11, // 7: bytebase.v1.QueryRow.values:type_name -> bytebase.v1.RowValue
- 32, // 8: bytebase.v1.RowValue.null_value:type_name -> google.protobuf.NullValue
- 33, // 9: bytebase.v1.RowValue.value_value:type_name -> google.protobuf.Value
- 29, // 10: bytebase.v1.RowValue.timestamp_value:type_name -> bytebase.v1.RowValue.Timestamp
- 30, // 11: bytebase.v1.RowValue.timestamp_tz_value:type_name -> bytebase.v1.RowValue.TimestampTZ
+ 30, // 8: bytebase.v1.RowValue.null_value:type_name -> google.protobuf.NullValue
+ 31, // 9: bytebase.v1.RowValue.value_value:type_name -> google.protobuf.Value
+ 27, // 10: bytebase.v1.RowValue.timestamp_value:type_name -> bytebase.v1.RowValue.Timestamp
+ 28, // 11: bytebase.v1.RowValue.timestamp_tz_value:type_name -> bytebase.v1.RowValue.TimestampTZ
1, // 12: bytebase.v1.Advice.status:type_name -> bytebase.v1.Advice.Status
- 34, // 13: bytebase.v1.Advice.start_position:type_name -> bytebase.v1.Position
- 34, // 14: bytebase.v1.Advice.end_position:type_name -> bytebase.v1.Position
- 35, // 15: bytebase.v1.ExportRequest.format:type_name -> bytebase.v1.ExportFormat
- 36, // 16: bytebase.v1.PrettyRequest.engine:type_name -> bytebase.v1.Engine
+ 32, // 13: bytebase.v1.Advice.start_position:type_name -> bytebase.v1.Position
+ 32, // 14: bytebase.v1.Advice.end_position:type_name -> bytebase.v1.Position
+ 33, // 15: bytebase.v1.ExportRequest.format:type_name -> bytebase.v1.ExportFormat
+ 34, // 16: bytebase.v1.PrettyRequest.engine:type_name -> bytebase.v1.Engine
2, // 17: bytebase.v1.CheckRequest.change_type:type_name -> bytebase.v1.CheckRequest.ChangeType
12, // 18: bytebase.v1.CheckResponse.advices:type_name -> bytebase.v1.Advice
- 37, // 19: bytebase.v1.StringifyMetadataRequest.metadata:type_name -> bytebase.v1.DatabaseMetadata
- 36, // 20: bytebase.v1.StringifyMetadataRequest.engine:type_name -> bytebase.v1.Engine
- 38, // 21: bytebase.v1.StringifyMetadataRequest.catalog:type_name -> bytebase.v1.DatabaseCatalog
- 37, // 22: bytebase.v1.DiffMetadataRequest.source_metadata:type_name -> bytebase.v1.DatabaseMetadata
- 37, // 23: bytebase.v1.DiffMetadataRequest.target_metadata:type_name -> bytebase.v1.DatabaseMetadata
- 38, // 24: bytebase.v1.DiffMetadataRequest.source_catalog:type_name -> bytebase.v1.DatabaseCatalog
- 38, // 25: bytebase.v1.DiffMetadataRequest.target_catalog:type_name -> bytebase.v1.DatabaseCatalog
- 36, // 26: bytebase.v1.DiffMetadataRequest.engine:type_name -> bytebase.v1.Engine
- 27, // 27: bytebase.v1.SearchQueryHistoriesResponse.query_histories:type_name -> bytebase.v1.QueryHistory
- 39, // 28: bytebase.v1.QueryHistory.create_time:type_name -> google.protobuf.Timestamp
- 31, // 29: bytebase.v1.QueryHistory.duration:type_name -> google.protobuf.Duration
- 3, // 30: bytebase.v1.QueryHistory.type:type_name -> bytebase.v1.QueryHistory.Type
- 39, // 31: bytebase.v1.RowValue.Timestamp.google_timestamp:type_name -> google.protobuf.Timestamp
- 39, // 32: bytebase.v1.RowValue.TimestampTZ.google_timestamp:type_name -> google.protobuf.Timestamp
- 6, // 33: bytebase.v1.SQLService.Query:input_type -> bytebase.v1.QueryRequest
- 4, // 34: bytebase.v1.SQLService.AdminExecute:input_type -> bytebase.v1.AdminExecuteRequest
- 25, // 35: bytebase.v1.SQLService.SearchQueryHistories:input_type -> bytebase.v1.SearchQueryHistoriesRequest
- 13, // 36: bytebase.v1.SQLService.Export:input_type -> bytebase.v1.ExportRequest
- 17, // 37: bytebase.v1.SQLService.Check:input_type -> bytebase.v1.CheckRequest
- 19, // 38: bytebase.v1.SQLService.ParseMyBatisMapper:input_type -> bytebase.v1.ParseMyBatisMapperRequest
- 15, // 39: bytebase.v1.SQLService.Pretty:input_type -> bytebase.v1.PrettyRequest
- 21, // 40: bytebase.v1.SQLService.StringifyMetadata:input_type -> bytebase.v1.StringifyMetadataRequest
- 23, // 41: bytebase.v1.SQLService.DiffMetadata:input_type -> bytebase.v1.DiffMetadataRequest
- 7, // 42: bytebase.v1.SQLService.Query:output_type -> bytebase.v1.QueryResponse
- 5, // 43: bytebase.v1.SQLService.AdminExecute:output_type -> bytebase.v1.AdminExecuteResponse
- 26, // 44: bytebase.v1.SQLService.SearchQueryHistories:output_type -> bytebase.v1.SearchQueryHistoriesResponse
- 14, // 45: bytebase.v1.SQLService.Export:output_type -> bytebase.v1.ExportResponse
- 18, // 46: bytebase.v1.SQLService.Check:output_type -> bytebase.v1.CheckResponse
- 20, // 47: bytebase.v1.SQLService.ParseMyBatisMapper:output_type -> bytebase.v1.ParseMyBatisMapperResponse
- 16, // 48: bytebase.v1.SQLService.Pretty:output_type -> bytebase.v1.PrettyResponse
- 22, // 49: bytebase.v1.SQLService.StringifyMetadata:output_type -> bytebase.v1.StringifyMetadataResponse
- 24, // 50: bytebase.v1.SQLService.DiffMetadata:output_type -> bytebase.v1.DiffMetadataResponse
- 42, // [42:51] is the sub-list for method output_type
- 33, // [33:42] is the sub-list for method input_type
- 33, // [33:33] is the sub-list for extension type_name
- 33, // [33:33] is the sub-list for extension extendee
- 0, // [0:33] is the sub-list for field type_name
+ 35, // 19: bytebase.v1.DiffMetadataRequest.source_metadata:type_name -> bytebase.v1.DatabaseMetadata
+ 35, // 20: bytebase.v1.DiffMetadataRequest.target_metadata:type_name -> bytebase.v1.DatabaseMetadata
+ 36, // 21: bytebase.v1.DiffMetadataRequest.source_catalog:type_name -> bytebase.v1.DatabaseCatalog
+ 36, // 22: bytebase.v1.DiffMetadataRequest.target_catalog:type_name -> bytebase.v1.DatabaseCatalog
+ 34, // 23: bytebase.v1.DiffMetadataRequest.engine:type_name -> bytebase.v1.Engine
+ 25, // 24: bytebase.v1.SearchQueryHistoriesResponse.query_histories:type_name -> bytebase.v1.QueryHistory
+ 37, // 25: bytebase.v1.QueryHistory.create_time:type_name -> google.protobuf.Timestamp
+ 29, // 26: bytebase.v1.QueryHistory.duration:type_name -> google.protobuf.Duration
+ 3, // 27: bytebase.v1.QueryHistory.type:type_name -> bytebase.v1.QueryHistory.Type
+ 37, // 28: bytebase.v1.RowValue.Timestamp.google_timestamp:type_name -> google.protobuf.Timestamp
+ 37, // 29: bytebase.v1.RowValue.TimestampTZ.google_timestamp:type_name -> google.protobuf.Timestamp
+ 6, // 30: bytebase.v1.SQLService.Query:input_type -> bytebase.v1.QueryRequest
+ 4, // 31: bytebase.v1.SQLService.AdminExecute:input_type -> bytebase.v1.AdminExecuteRequest
+ 23, // 32: bytebase.v1.SQLService.SearchQueryHistories:input_type -> bytebase.v1.SearchQueryHistoriesRequest
+ 13, // 33: bytebase.v1.SQLService.Export:input_type -> bytebase.v1.ExportRequest
+ 17, // 34: bytebase.v1.SQLService.Check:input_type -> bytebase.v1.CheckRequest
+ 19, // 35: bytebase.v1.SQLService.ParseMyBatisMapper:input_type -> bytebase.v1.ParseMyBatisMapperRequest
+ 15, // 36: bytebase.v1.SQLService.Pretty:input_type -> bytebase.v1.PrettyRequest
+ 21, // 37: bytebase.v1.SQLService.DiffMetadata:input_type -> bytebase.v1.DiffMetadataRequest
+ 7, // 38: bytebase.v1.SQLService.Query:output_type -> bytebase.v1.QueryResponse
+ 5, // 39: bytebase.v1.SQLService.AdminExecute:output_type -> bytebase.v1.AdminExecuteResponse
+ 24, // 40: bytebase.v1.SQLService.SearchQueryHistories:output_type -> bytebase.v1.SearchQueryHistoriesResponse
+ 14, // 41: bytebase.v1.SQLService.Export:output_type -> bytebase.v1.ExportResponse
+ 18, // 42: bytebase.v1.SQLService.Check:output_type -> bytebase.v1.CheckResponse
+ 20, // 43: bytebase.v1.SQLService.ParseMyBatisMapper:output_type -> bytebase.v1.ParseMyBatisMapperResponse
+ 16, // 44: bytebase.v1.SQLService.Pretty:output_type -> bytebase.v1.PrettyResponse
+ 22, // 45: bytebase.v1.SQLService.DiffMetadata:output_type -> bytebase.v1.DiffMetadataResponse
+ 38, // [38:46] is the sub-list for method output_type
+ 30, // [30:38] is the sub-list for method input_type
+ 30, // [30:30] is the sub-list for extension type_name
+ 30, // [30:30] is the sub-list for extension extendee
+ 0, // [0:30] is the sub-list for field type_name
}
func init() { file_v1_sql_service_proto_init() }
@@ -3010,15 +2857,14 @@ func file_v1_sql_service_proto_init() {
(*RowValue_TimestampValue)(nil),
(*RowValue_TimestampTzValue)(nil),
}
- file_v1_sql_service_proto_msgTypes[17].OneofWrappers = []any{}
- file_v1_sql_service_proto_msgTypes[23].OneofWrappers = []any{}
+ file_v1_sql_service_proto_msgTypes[21].OneofWrappers = []any{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_v1_sql_service_proto_rawDesc), len(file_v1_sql_service_proto_rawDesc)),
NumEnums: 4,
- NumMessages: 27,
+ NumMessages: 25,
NumExtensions: 0,
NumServices: 1,
},
diff --git a/proto/generated-go/v1/sql_service.pb.gw.go b/proto/generated-go/v1/sql_service.pb.gw.go
index 50c51e6274..86a06817a4 100644
--- a/proto/generated-go/v1/sql_service.pb.gw.go
+++ b/proto/generated-go/v1/sql_service.pb.gw.go
@@ -384,30 +384,6 @@ func local_request_SQLService_Pretty_0(ctx context.Context, marshaler runtime.Ma
return msg, metadata, err
}
-func request_SQLService_StringifyMetadata_0(ctx context.Context, marshaler runtime.Marshaler, client SQLServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var (
- protoReq StringifyMetadataRequest
- metadata runtime.ServerMetadata
- )
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- msg, err := client.StringifyMetadata(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-}
-
-func local_request_SQLService_StringifyMetadata_0(ctx context.Context, marshaler runtime.Marshaler, server SQLServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var (
- protoReq StringifyMetadataRequest
- metadata runtime.ServerMetadata
- )
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- msg, err := server.StringifyMetadata(ctx, &protoReq)
- return msg, metadata, err
-}
-
func request_SQLService_DiffMetadata_0(ctx context.Context, marshaler runtime.Marshaler, client SQLServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq DiffMetadataRequest
@@ -625,26 +601,6 @@ func RegisterSQLServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux,
}
forward_SQLService_Pretty_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
- mux.Handle(http.MethodPost, pattern_SQLService_StringifyMetadata_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)
- annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.SQLService/StringifyMetadata", runtime.WithHTTPPathPattern("/v1/schemaDesign:stringifyMetadata"))
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_SQLService_StringifyMetadata_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_StringifyMetadata_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
- })
mux.Handle(http.MethodPost, pattern_SQLService_DiffMetadata_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@@ -875,23 +831,6 @@ func RegisterSQLServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux,
}
forward_SQLService_Pretty_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
- mux.Handle(http.MethodPost, pattern_SQLService_StringifyMetadata_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)
- annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.SQLService/StringifyMetadata", runtime.WithHTTPPathPattern("/v1/schemaDesign:stringifyMetadata"))
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_SQLService_StringifyMetadata_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_StringifyMetadata_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
- })
mux.Handle(http.MethodPost, pattern_SQLService_DiffMetadata_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@@ -923,7 +862,6 @@ var (
pattern_SQLService_Check_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "sql", "check"}, ""))
pattern_SQLService_ParseMyBatisMapper_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "sql", "parseMyBatisMapper"}, ""))
pattern_SQLService_Pretty_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "sql", "pretty"}, ""))
- pattern_SQLService_StringifyMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "schemaDesign"}, "stringifyMetadata"))
pattern_SQLService_DiffMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "schemaDesign"}, "diffMetadata"))
)
@@ -938,6 +876,5 @@ var (
forward_SQLService_Check_0 = runtime.ForwardResponseMessage
forward_SQLService_ParseMyBatisMapper_0 = runtime.ForwardResponseMessage
forward_SQLService_Pretty_0 = runtime.ForwardResponseMessage
- forward_SQLService_StringifyMetadata_0 = runtime.ForwardResponseMessage
forward_SQLService_DiffMetadata_0 = runtime.ForwardResponseMessage
)
diff --git a/proto/generated-go/v1/sql_service_grpc.pb.go b/proto/generated-go/v1/sql_service_grpc.pb.go
index b54e05bbe0..f38dcac3ba 100644
--- a/proto/generated-go/v1/sql_service_grpc.pb.go
+++ b/proto/generated-go/v1/sql_service_grpc.pb.go
@@ -26,7 +26,6 @@ const (
SQLService_Check_FullMethodName = "/bytebase.v1.SQLService/Check"
SQLService_ParseMyBatisMapper_FullMethodName = "/bytebase.v1.SQLService/ParseMyBatisMapper"
SQLService_Pretty_FullMethodName = "/bytebase.v1.SQLService/Pretty"
- SQLService_StringifyMetadata_FullMethodName = "/bytebase.v1.SQLService/StringifyMetadata"
SQLService_DiffMetadata_FullMethodName = "/bytebase.v1.SQLService/DiffMetadata"
)
@@ -42,7 +41,6 @@ type SQLServiceClient interface {
Check(ctx context.Context, in *CheckRequest, opts ...grpc.CallOption) (*CheckResponse, error)
ParseMyBatisMapper(ctx context.Context, in *ParseMyBatisMapperRequest, opts ...grpc.CallOption) (*ParseMyBatisMapperResponse, error)
Pretty(ctx context.Context, in *PrettyRequest, opts ...grpc.CallOption) (*PrettyResponse, error)
- StringifyMetadata(ctx context.Context, in *StringifyMetadataRequest, opts ...grpc.CallOption) (*StringifyMetadataResponse, error)
DiffMetadata(ctx context.Context, in *DiffMetadataRequest, opts ...grpc.CallOption) (*DiffMetadataResponse, error)
}
@@ -127,16 +125,6 @@ func (c *sQLServiceClient) Pretty(ctx context.Context, in *PrettyRequest, opts .
return out, nil
}
-func (c *sQLServiceClient) StringifyMetadata(ctx context.Context, in *StringifyMetadataRequest, opts ...grpc.CallOption) (*StringifyMetadataResponse, error) {
- cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
- out := new(StringifyMetadataResponse)
- err := c.cc.Invoke(ctx, SQLService_StringifyMetadata_FullMethodName, in, out, cOpts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
func (c *sQLServiceClient) DiffMetadata(ctx context.Context, in *DiffMetadataRequest, opts ...grpc.CallOption) (*DiffMetadataResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(DiffMetadataResponse)
@@ -159,7 +147,6 @@ type SQLServiceServer interface {
Check(context.Context, *CheckRequest) (*CheckResponse, error)
ParseMyBatisMapper(context.Context, *ParseMyBatisMapperRequest) (*ParseMyBatisMapperResponse, error)
Pretty(context.Context, *PrettyRequest) (*PrettyResponse, error)
- StringifyMetadata(context.Context, *StringifyMetadataRequest) (*StringifyMetadataResponse, error)
DiffMetadata(context.Context, *DiffMetadataRequest) (*DiffMetadataResponse, error)
mustEmbedUnimplementedSQLServiceServer()
}
@@ -192,9 +179,6 @@ func (UnimplementedSQLServiceServer) ParseMyBatisMapper(context.Context, *ParseM
func (UnimplementedSQLServiceServer) Pretty(context.Context, *PrettyRequest) (*PrettyResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Pretty not implemented")
}
-func (UnimplementedSQLServiceServer) StringifyMetadata(context.Context, *StringifyMetadataRequest) (*StringifyMetadataResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method StringifyMetadata not implemented")
-}
func (UnimplementedSQLServiceServer) DiffMetadata(context.Context, *DiffMetadataRequest) (*DiffMetadataResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method DiffMetadata not implemented")
}
@@ -334,24 +318,6 @@ func _SQLService_Pretty_Handler(srv interface{}, ctx context.Context, dec func(i
return interceptor(ctx, in, info, handler)
}
-func _SQLService_StringifyMetadata_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(StringifyMetadataRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(SQLServiceServer).StringifyMetadata(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: SQLService_StringifyMetadata_FullMethodName,
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(SQLServiceServer).StringifyMetadata(ctx, req.(*StringifyMetadataRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
func _SQLService_DiffMetadata_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DiffMetadataRequest)
if err := dec(in); err != nil {
@@ -401,10 +367,6 @@ var SQLService_ServiceDesc = grpc.ServiceDesc{
MethodName: "Pretty",
Handler: _SQLService_Pretty_Handler,
},
- {
- MethodName: "StringifyMetadata",
- Handler: _SQLService_StringifyMetadata_Handler,
- },
{
MethodName: "DiffMetadata",
Handler: _SQLService_DiffMetadata_Handler,
diff --git a/proto/v1/sql_service.proto b/proto/v1/sql_service.proto
index 2f0ad462ad..a39c7fe227 100644
--- a/proto/v1/sql_service.proto
+++ b/proto/v1/sql_service.proto
@@ -92,14 +92,6 @@ service SQLService {
option (bytebase.v1.allow_without_credential) = true;
}
- rpc StringifyMetadata(StringifyMetadataRequest) returns (StringifyMetadataResponse) {
- option (google.api.http) = {
- post: "/v1/schemaDesign:stringifyMetadata"
- body: "*"
- };
- option (bytebase.v1.allow_without_credential) = true;
- }
-
rpc DiffMetadata(DiffMetadataRequest) returns (DiffMetadataResponse) {
option (google.api.http) = {
post: "/v1/schemaDesign:diffMetadata"
@@ -430,20 +422,6 @@ message ParseMyBatisMapperResponse {
repeated string statements = 1;
}
-message StringifyMetadataRequest {
- DatabaseMetadata metadata = 1 [(google.api.field_behavior) = REQUIRED];
- // The database engine of the schema string.
- Engine engine = 2;
- // If false, we will build the raw common by classification in database catalog.
- bool classification_from_config = 3;
- // Database catlog is required if classification_from_config is false.
- optional DatabaseCatalog catalog = 4;
-}
-
-message StringifyMetadataResponse {
- string schema = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
-}
-
message DiffMetadataRequest {
// The metadata of the source schema.
DatabaseMetadata source_metadata = 1 [(google.api.field_behavior) = REQUIRED];