Skip to content

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

refactor: remove unused Engine and Payload fields from Sheet (#18545)

Danny Xu5038342b2906
diff --git a/backend/api/mcp/gen/openapi.yaml b/backend/api/mcp/gen/openapi.yaml
index 74685326ce..1602fe0585 100644
--- a/backend/api/mcp/gen/openapi.yaml
+++ b/backend/api/mcp/gen/openapi.yaml
@@ -6848,12 +6848,17 @@ components:
type: integer
title: start
format: int32
- description: start is the start index of the original value, start from 0 and should be less than stop.
+ description: |-
+ start is the start character index (0-based) of the original value, should be less than end.
+ Uses character indices (not byte offsets) for display-oriented masking.
+ Example: For "你好world", character index 2 refers to 'w' (the 3rd character).
end:
type: integer
title: end
format: int32
- description: stop is the stop index of the original value, should be less than the length of the original value.
+ description: |-
+ end is the end character index (exclusive) of the original value.
+ Uses character indices (not byte offsets) for display-oriented masking.
substitution:
type: string
title: substitution
@@ -14020,15 +14025,18 @@ components:
type: integer
title: start
format: int32
- description: Start position (inclusive).
+ description: Start index (inclusive).
end:
type: integer
title: end
format: int32
- description: End position (exclusive).
+ description: End index (exclusive).
title: Range
additionalProperties: false
- description: Range of positions in text or sequence.
+ description: |-
+ Range represents a span within a text or sequence.
+ Whether the indices are byte offsets or character indices depends on the context.
+ Check the documentation of the field using Range for specific semantics.
bytebase.v1.RejectIssueRequest:
type: object
properties:
@@ -15654,10 +15662,6 @@ components:
title: content_size
format: int64
description: content_size is the full size of the content, may not match the size of the `content` field.
- engine:
- title: engine
- description: The SQL dialect.
- $ref: '#/components/schemas/bytebase.v1.Engine'
title: Sheet
additionalProperties: false
bytebase.v1.SpatialIndexConfig:
@@ -16670,7 +16674,10 @@ components:
$ref: '#/components/schemas/google.protobuf.Timestamp'
range:
title: range
- description: The byte offset range of the executed command in the sheet.
+ description: |-
+ The byte offset range of the executed command in the sheet.
+ Uses byte offsets (not character indices) for efficient slicing of sheet content bytes.
+ Example: For "SELECT 你好;" in a UTF-8 sheet, range [0, 13) represents all 13 bytes.
$ref: '#/components/schemas/bytebase.v1.Range'
statement:
type: string
diff --git a/backend/api/v1/plan_service.go b/backend/api/v1/plan_service.go
index d9e1c9512d..16b7be8a47 100644
--- a/backend/api/v1/plan_service.go
+++ b/backend/api/v1/plan_service.go
@@ -257,7 +257,7 @@ func (s *PlanService) CreatePlan(ctx context.Context, request *connect.Request[v
}
planMessage.Config.Deployment = deployment
- if _, err := GetPipelineCreate(ctx, s.store, s.sheetManager, s.dbFactory, planMessage.Config.GetSpecs(), deployment, project); err != nil {
+ if _, err := GetPipelineCreate(ctx, s.store, s.dbFactory, planMessage.Config.GetSpecs(), deployment, project); err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("failed to get pipeline from the plan, please check you request, error: %v", err))
}
plan, err := s.store.CreatePlan(ctx, planMessage, user.Email)
@@ -393,7 +393,6 @@ func (s *PlanService) UpdatePlan(ctx context.Context, request *connect.Request[v
if _, err := GetPipelineCreate(ctx,
s.store,
- s.sheetManager,
s.dbFactory,
allSpecs,
oldPlan.Config.GetDeployment(),
diff --git a/backend/api/v1/release_service.go b/backend/api/v1/release_service.go
index 5b15010aa1..0d4eb20dd5 100644
--- a/backend/api/v1/release_service.go
+++ b/backend/api/v1/release_service.go
@@ -94,7 +94,7 @@ func (s *ReleaseService) CreateRelease(ctx context.Context, req *connect.Request
// Batch create sheets if needed.
if len(sheetsToCreate) > 0 {
- createdSheets, err := s.sheetManager.CreateSheets(ctx, project.ResourceID, user.Email, sheetsToCreate...)
+ createdSheets, err := s.store.CreateSheets(ctx, project.ResourceID, user.Email, sheetsToCreate...)
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to create sheets"))
}
diff --git a/backend/api/v1/rollout_service.go b/backend/api/v1/rollout_service.go
index 1eacb992f7..8ee6a84d6a 100644
--- a/backend/api/v1/rollout_service.go
+++ b/backend/api/v1/rollout_service.go
@@ -80,7 +80,7 @@ func (s *RolloutService) PreviewRollout(ctx context.Context, req *connect.Reques
specs := convertPlanSpecs(request.Plan.Specs)
- rollout, err := GetPipelineCreate(ctx, s.store, s.sheetManager, s.dbFactory, specs, nil /* snapshot */, project)
+ rollout, err := GetPipelineCreate(ctx, s.store, s.dbFactory, specs, nil /* snapshot */, project)
if err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("failed to get pipeline create, error: %v", err))
}
@@ -239,7 +239,7 @@ func (s *RolloutService) CreateRollout(ctx context.Context, req *connect.Request
return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("plan %d not found in project %s", planID, projectID))
}
- pipelineCreate, err := GetPipelineCreate(ctx, s.store, s.sheetManager, s.dbFactory, plan.Config.GetSpecs(), plan.Config.GetDeployment(), project)
+ pipelineCreate, err := GetPipelineCreate(ctx, s.store, s.dbFactory, plan.Config.GetSpecs(), plan.Config.GetDeployment(), project)
if err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("failed to get pipeline create, error: %v", err))
}
@@ -965,7 +965,7 @@ func getPlanEnvironmentSnapshots(ctx context.Context, s *store.Store, deployment
}
// GetPipelineCreate gets a pipeline create message from a plan.
-func GetPipelineCreate(ctx context.Context, s *store.Store, sheetManager *sheet.Manager, dbFactory *dbfactory.DBFactory, specs []*storepb.PlanConfig_Spec, deployment *storepb.PlanConfig_Deployment /* nullable */, project *store.ProjectMessage) (*store.PipelineMessage, error) {
+func GetPipelineCreate(ctx context.Context, s *store.Store, dbFactory *dbfactory.DBFactory, specs []*storepb.PlanConfig_Spec, deployment *storepb.PlanConfig_Deployment /* nullable */, project *store.ProjectMessage) (*store.PipelineMessage, error) {
// Step 1 - transform database group specs.
// Others are untouched.
transformedSpecs := applyDatabaseGroupSpecTransformations(specs, deployment)
@@ -973,7 +973,7 @@ func GetPipelineCreate(ctx context.Context, s *store.Store, sheetManager *sheet.
// Step 2 - convert all task creates.
var taskCreates []*store.TaskMessage
for _, spec := range transformedSpecs {
- tcs, err := getTaskCreatesFromSpec(ctx, s, sheetManager, dbFactory, spec, project)
+ tcs, err := getTaskCreatesFromSpec(ctx, s, dbFactory, spec, project)
if err != nil {
return nil, errors.Wrap(err, "failed to get task creates from spec")
}
diff --git a/backend/api/v1/rollout_service_task.go b/backend/api/v1/rollout_service_task.go
index edc2aece63..1bd08dc568 100644
--- a/backend/api/v1/rollout_service_task.go
+++ b/backend/api/v1/rollout_service_task.go
@@ -14,7 +14,6 @@ import (
"github.com/bytebase/bytebase/backend/common/log"
"github.com/bytebase/bytebase/backend/component/dbfactory"
"github.com/bytebase/bytebase/backend/component/ghost"
- "github.com/bytebase/bytebase/backend/component/sheet"
storepb "github.com/bytebase/bytebase/backend/generated-go/store"
v1pb "github.com/bytebase/bytebase/backend/generated-go/v1"
"github.com/bytebase/bytebase/backend/plugin/db"
@@ -47,10 +46,10 @@ func applyDatabaseGroupSpecTransformations(specs []*storepb.PlanConfig_Spec, dep
return result
}
-func getTaskCreatesFromSpec(ctx context.Context, s *store.Store, sheetManager *sheet.Manager, dbFactory *dbfactory.DBFactory, spec *storepb.PlanConfig_Spec, project *store.ProjectMessage) ([]*store.TaskMessage, error) {
+func getTaskCreatesFromSpec(ctx context.Context, s *store.Store, dbFactory *dbfactory.DBFactory, spec *storepb.PlanConfig_Spec, project *store.ProjectMessage) ([]*store.TaskMessage, error) {
switch config := spec.Config.(type) {
case *storepb.PlanConfig_Spec_CreateDatabaseConfig:
- return getTaskCreatesFromCreateDatabaseConfig(ctx, s, sheetManager, dbFactory, spec, config.CreateDatabaseConfig, project)
+ return getTaskCreatesFromCreateDatabaseConfig(ctx, s, dbFactory, spec, config.CreateDatabaseConfig, project)
case *storepb.PlanConfig_Spec_ChangeDatabaseConfig:
return getTaskCreatesFromChangeDatabaseConfig(ctx, s, spec, config.ChangeDatabaseConfig)
case *storepb.PlanConfig_Spec_ExportDataConfig:
@@ -60,7 +59,7 @@ func getTaskCreatesFromSpec(ctx context.Context, s *store.Store, sheetManager *s
return nil, errors.Errorf("invalid spec config type %T", spec.Config)
}
-func getTaskCreatesFromCreateDatabaseConfig(ctx context.Context, s *store.Store, sheetManager *sheet.Manager, dbFactory *dbfactory.DBFactory, spec *storepb.PlanConfig_Spec, c *storepb.PlanConfig_CreateDatabaseConfig, project *store.ProjectMessage) ([]*store.TaskMessage, error) {
+func getTaskCreatesFromCreateDatabaseConfig(ctx context.Context, s *store.Store, dbFactory *dbfactory.DBFactory, spec *storepb.PlanConfig_Spec, c *storepb.PlanConfig_CreateDatabaseConfig, project *store.ProjectMessage) ([]*store.TaskMessage, error) {
if c.Database == "" {
return nil, errors.Errorf("database name is required")
}
@@ -142,12 +141,9 @@ func getTaskCreatesFromCreateDatabaseConfig(ctx context.Context, s *store.Store,
if err != nil {
return nil, err
}
- sheets, err := sheetManager.CreateSheets(ctx, project.ResourceID, common.SystemBotEmail, &store.SheetMessage{
+ sheets, err := s.CreateSheets(ctx, project.ResourceID, common.SystemBotEmail, &store.SheetMessage{
Title: fmt.Sprintf("Sheet for creating database %v", databaseName),
Statement: statement,
- Payload: &storepb.SheetPayload{
- Engine: instance.Metadata.GetEngine(),
- },
})
if err != nil {
return nil, errors.Wrap(err, "failed to create database creation sheet")
diff --git a/backend/api/v1/sheet_service.go b/backend/api/v1/sheet_service.go
index 92d1b47ba1..028192b260 100644
--- a/backend/api/v1/sheet_service.go
+++ b/backend/api/v1/sheet_service.go
@@ -13,7 +13,6 @@ import (
"github.com/bytebase/bytebase/backend/component/iam"
"github.com/bytebase/bytebase/backend/component/sheet"
"github.com/bytebase/bytebase/backend/enterprise"
- storepb "github.com/bytebase/bytebase/backend/generated-go/store"
v1pb "github.com/bytebase/bytebase/backend/generated-go/v1"
"github.com/bytebase/bytebase/backend/generated-go/v1/v1connect"
"github.com/bytebase/bytebase/backend/store"
@@ -68,7 +67,7 @@ func (s *SheetService) CreateSheet(ctx context.Context, request *connect.Request
}
storeSheetCreate := convertToStoreSheetMessage(project.ResourceID, user.Email, request.Msg.Sheet)
- sheets, err := s.sheetManager.CreateSheets(ctx, project.ResourceID, user.Email, storeSheetCreate)
+ sheets, err := s.store.CreateSheets(ctx, project.ResourceID, user.Email, storeSheetCreate)
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to create sheet"))
}
@@ -117,7 +116,7 @@ func (s *SheetService) BatchCreateSheets(ctx context.Context, request *connect.R
sheetCreates = append(sheetCreates, storeSheetCreate)
}
- sheets, err := s.sheetManager.CreateSheets(ctx, project.ResourceID, user.Email, sheetCreates...)
+ sheets, err := s.store.CreateSheets(ctx, project.ResourceID, user.Email, sheetCreates...)
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to create sheet"))
}
@@ -203,7 +202,6 @@ func (s *SheetService) convertToAPISheetMessage(ctx context.Context, sheet *stor
CreateTime: timestamppb.New(sheet.CreatedAt),
Content: []byte(sheet.Statement),
ContentSize: sheet.Size,
- Engine: convertToEngine(sheet.Payload.GetEngine()),
}, nil
}
@@ -213,9 +211,7 @@ func convertToStoreSheetMessage(projectID string, creator string, sheet *v1pb.Sh
Creator: creator,
Title: sheet.Title,
Statement: string(sheet.Content),
- Payload: &storepb.SheetPayload{},
}
- sheetMessage.Payload.Engine = convertEngine(sheet.Engine)
return sheetMessage
}
diff --git a/backend/component/sheet/sheet.go b/backend/component/sheet/sheet.go
index 0ad645d876..76f97b657f 100644
--- a/backend/component/sheet/sheet.go
+++ b/backend/component/sheet/sheet.go
@@ -1,22 +1,14 @@
package sheet
import (
- "context"
- "io"
- "log/slog"
- "strings"
"sync"
"time"
lru "github.com/hashicorp/golang-lru/v2/expirable"
- "github.com/pkg/errors"
"github.com/zeebo/xxh3"
- "github.com/bytebase/bytebase/backend/common"
storepb "github.com/bytebase/bytebase/backend/generated-go/store"
"github.com/bytebase/bytebase/backend/plugin/parser/base"
- tsqlbatch "github.com/bytebase/bytebase/backend/plugin/parser/tsql/batch"
- "github.com/bytebase/bytebase/backend/store"
// Import parsers to register their parse functions.
_ "github.com/bytebase/bytebase/backend/plugin/parser/cockroachdb"
@@ -41,7 +33,6 @@ const (
type Manager struct {
sync.Mutex
- store *store.Store
statementCache *lru.LRU[astHashKey, *StatementResult]
}
@@ -51,129 +42,12 @@ type astHashKey struct {
}
// NewManager creates a new sheet manager.
-func NewManager(store *store.Store) *Manager {
+func NewManager() *Manager {
return &Manager{
- store: store,
statementCache: lru.NewLRU[astHashKey, *StatementResult](8, nil, 3*time.Minute),
}
}
-func (sm *Manager) CreateSheets(ctx context.Context, projectID string, creator string, sheets ...*store.SheetMessage) ([]*store.SheetMessage, error) {
- for _, sheet := range sheets {
- if sheet.Payload == nil {
- sheet.Payload = &storepb.SheetPayload{}
- }
- sheet.Payload.Commands = getSheetCommands(sheet.Payload.Engine, sheet.Statement)
- }
-
- result, err := sm.store.CreateSheets(ctx, projectID, creator, sheets...)
- if err != nil {
- return nil, errors.Wrapf(err, "failed to create sheets")
- }
- return result, nil
-}
-
-func getSheetCommands(engine storepb.Engine, statement string) []*storepb.Range {
- // Burnout for large SQL.
- if len(statement) > common.MaxSheetCheckSize {
- return nil
- }
-
- switch engine {
- case
- storepb.Engine_TIDB,
- storepb.Engine_ORACLE:
- return getSheetCommandsFromByteOffset(engine, statement)
- case storepb.Engine_MSSQL:
- return getSheetCommandsForMSSQL(statement)
- default:
- return getSheetCommandsGeneral(engine, statement)
- }
-}
-
-func getSheetCommandsGeneral(engine storepb.Engine, statement string) []*storepb.Range {
- statements, err := base.ParseStatements(engine, statement)
- if err != nil {
- if !strings.Contains(err.Error(), "not supported") {
- slog.Warn("failed to parse statements", "engine", engine.String(), "statement", statement)
- }
- return nil
- }
- // HACK(p0ny): always split for pg
- if len(statements) > common.MaximumCommands && engine != storepb.Engine_POSTGRES {
- return nil
- }
-
- var sheetCommands []*storepb.Range
- p := 0
- for _, s := range statements {
- np := p + len(s.Text)
- sheetCommands = append(sheetCommands, &storepb.Range{
- Start: int32(p),
- End: int32(np),
- })
- p = np
- }
- return sheetCommands
-}
-
-func getSheetCommandsFromByteOffset(engine storepb.Engine, statement string) []*storepb.Range {
- statements, err := base.ParseStatements(engine, statement)
- if err != nil {
- if !strings.Contains(err.Error(), "not supported") {
- slog.Warn("failed to parse statements", "engine", engine.String(), "statement", statement)
- }
- return nil
- }
- if len(statements) > common.MaximumCommands {
- return nil
- }
-
- var sheetCommands []*storepb.Range
- for _, s := range statements {
- sheetCommands = append(sheetCommands, s.Range)
- }
- return sheetCommands
-}
-
-func getSheetCommandsForMSSQL(statement string) []*storepb.Range {
- var sheetCommands []*storepb.Range
-
- batch := tsqlbatch.NewBatcher(statement)
- for {
- command, err := batch.Next()
- if err == io.EOF {
- b := batch.Batch()
- sheetCommands = append(sheetCommands, &storepb.Range{
- Start: int32(b.Start),
- End: int32(b.End),
- })
- batch.Reset(nil)
- break
- }
- if err != nil {
- slog.Warn("failed to get sheet commands for mssql", "statement", statement)
- return nil
- }
- if command == nil {
- continue
- }
- switch command.(type) {
- case *tsqlbatch.GoCommand:
- b := batch.Batch()
- sheetCommands = append(sheetCommands, &storepb.Range{
- Start: int32(b.Start),
- End: int32(b.End),
- })
- batch.Reset(nil)
- default:
- }
- // No command count limit for MSSQL to ensure consistency between sheet payload
- // and actual execution in mssql.go which splits and executes all batches
- }
- return sheetCommands
-}
-
// StatementResult holds the cached parsing results with the unified ParsedStatement type.
type StatementResult struct {
sync.Mutex
diff --git a/backend/generated-go/store/common.pb.go b/backend/generated-go/store/common.pb.go
index 1c0b7706b6..acc18887f4 100644
--- a/backend/generated-go/store/common.pb.go
+++ b/backend/generated-go/store/common.pb.go
@@ -562,6 +562,8 @@ func (x *Position) GetColumn() int32 {
}
// Range represents a span within a text or sequence.
+// Whether the indices are byte offsets or character indices depends on the context.
+// Check the documentation of the field using Range for specific semantics.
type Range struct {
state protoimpl.MessageState `protogen:"open.v1"`
// Start index (inclusive).
diff --git a/backend/generated-go/store/setting.pb.go b/backend/generated-go/store/setting.pb.go
index 900008282e..0615a130d8 100644
--- a/backend/generated-go/store/setting.pb.go
+++ b/backend/generated-go/store/setting.pb.go
@@ -1659,11 +1659,14 @@ func (x *Algorithm_InnerOuterMask) GetSubstitution() string {
type Algorithm_RangeMask_Slice struct {
state protoimpl.MessageState `protogen:"open.v1"`
- // start is the start index of the original value, start from 0 and should be less than stop.
+ // start is the start character index (0-based) of the original value, should be less than end.
+ // Uses character indices (not byte offsets) for display-oriented masking.
+ // Example: For "你好world", character index 2 refers to 'w' (the 3rd character).
Start int32 `protobuf:"varint,1,opt,name=start,proto3" json:"start,omitempty"`
- // stop is the stop index of the original value, should be less than the length of the original value.
+ // end is the end character index (exclusive) of the original value.
+ // Uses character indices (not byte offsets) for display-oriented masking.
End int32 `protobuf:"varint,2,opt,name=end,proto3" json:"end,omitempty"`
- // OriginalValue[start:end) would be replaced with replace_with.
+ // OriginalValue[start:end) would be replaced with substitution.
Substitution string `protobuf:"bytes,3,opt,name=substitution,proto3" json:"substitution,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
diff --git a/backend/generated-go/store/sheet.pb.go b/backend/generated-go/store/sheet.pb.go
deleted file mode 100644
index 16ec25b147..0000000000
--- a/backend/generated-go/store/sheet.pb.go
+++ /dev/null
@@ -1,140 +0,0 @@
-// Code generated by protoc-gen-go. DO NOT EDIT.
-// versions:
-// protoc-gen-go v1.36.11
-// protoc (unknown)
-// source: store/sheet.proto
-
-package store
-
-import (
- protoreflect "google.golang.org/protobuf/reflect/protoreflect"
- protoimpl "google.golang.org/protobuf/runtime/protoimpl"
- reflect "reflect"
- sync "sync"
- unsafe "unsafe"
-)
-
-const (
- // Verify that this generated code is sufficiently up-to-date.
- _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
- // Verify that runtime/protoimpl is sufficiently up-to-date.
- _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
-)
-
-type SheetPayload struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- // The SQL dialect of the sheet.
- Engine Engine `protobuf:"varint,1,opt,name=engine,proto3,enum=bytebase.store.Engine" json:"engine,omitempty"`
- // The start and end position of each command in the sheet statement.
- Commands []*Range `protobuf:"bytes,2,rep,name=commands,proto3" json:"commands,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *SheetPayload) Reset() {
- *x = SheetPayload{}
- mi := &file_store_sheet_proto_msgTypes[0]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *SheetPayload) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*SheetPayload) ProtoMessage() {}
-
-func (x *SheetPayload) ProtoReflect() protoreflect.Message {
- mi := &file_store_sheet_proto_msgTypes[0]
- 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 SheetPayload.ProtoReflect.Descriptor instead.
-func (*SheetPayload) Descriptor() ([]byte, []int) {
- return file_store_sheet_proto_rawDescGZIP(), []int{0}
-}
-
-func (x *SheetPayload) GetEngine() Engine {
- if x != nil {
- return x.Engine
- }
- return Engine_ENGINE_UNSPECIFIED
-}
-
-func (x *SheetPayload) GetCommands() []*Range {
- if x != nil {
- return x.Commands
- }
- return nil
-}
-
-var File_store_sheet_proto protoreflect.FileDescriptor
-
-const file_store_sheet_proto_rawDesc = "" +
- "\n" +
- "\x11store/sheet.proto\x12\x0ebytebase.store\x1a\x12store/common.proto\"q\n" +
- "\fSheetPayload\x12.\n" +
- "\x06engine\x18\x01 \x01(\x0e2\x16.bytebase.store.EngineR\x06engine\x121\n" +
- "\bcommands\x18\x02 \x03(\v2\x15.bytebase.store.RangeR\bcommandsB\x8d\x01\n" +
- "\x12com.bytebase.storeB\n" +
- "SheetProtoP\x01Z\x12generated-go/store\xa2\x02\x03BSX\xaa\x02\x0eBytebase.Store\xca\x02\x0eBytebase\\Store\xe2\x02\x1aBytebase\\Store\\GPBMetadata\xea\x02\x0fBytebase::Storeb\x06proto3"
-
-var (
- file_store_sheet_proto_rawDescOnce sync.Once
- file_store_sheet_proto_rawDescData []byte
-)
-
-func file_store_sheet_proto_rawDescGZIP() []byte {
- file_store_sheet_proto_rawDescOnce.Do(func() {
- file_store_sheet_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_store_sheet_proto_rawDesc), len(file_store_sheet_proto_rawDesc)))
- })
- return file_store_sheet_proto_rawDescData
-}
-
-var file_store_sheet_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
-var file_store_sheet_proto_goTypes = []any{
- (*SheetPayload)(nil), // 0: bytebase.store.SheetPayload
- (Engine)(0), // 1: bytebase.store.Engine
- (*Range)(nil), // 2: bytebase.store.Range
-}
-var file_store_sheet_proto_depIdxs = []int32{
- 1, // 0: bytebase.store.SheetPayload.engine:type_name -> bytebase.store.Engine
- 2, // 1: bytebase.store.SheetPayload.commands:type_name -> bytebase.store.Range
- 2, // [2:2] is the sub-list for method output_type
- 2, // [2:2] is the sub-list for method input_type
- 2, // [2:2] is the sub-list for extension type_name
- 2, // [2:2] is the sub-list for extension extendee
- 0, // [0:2] is the sub-list for field type_name
-}
-
-func init() { file_store_sheet_proto_init() }
-func file_store_sheet_proto_init() {
- if File_store_sheet_proto != nil {
- return
- }
- file_store_common_proto_init()
- type x struct{}
- out := protoimpl.TypeBuilder{
- File: protoimpl.DescBuilder{
- GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
- RawDescriptor: unsafe.Slice(unsafe.StringData(file_store_sheet_proto_rawDesc), len(file_store_sheet_proto_rawDesc)),
- NumEnums: 0,
- NumMessages: 1,
- NumExtensions: 0,
- NumServices: 0,
- },
- GoTypes: file_store_sheet_proto_goTypes,
- DependencyIndexes: file_store_sheet_proto_depIdxs,
- MessageInfos: file_store_sheet_proto_msgTypes,
- }.Build()
- File_store_sheet_proto = out.File
- file_store_sheet_proto_goTypes = nil
- file_store_sheet_proto_depIdxs = nil
-}
diff --git a/backend/generated-go/store/sheet_equal.pb.go b/backend/generated-go/store/sheet_equal.pb.go
deleted file mode 100644
index ffd3f8ee97..0000000000
--- a/backend/generated-go/store/sheet_equal.pb.go
+++ /dev/null
@@ -1,25 +0,0 @@
-// Code generated by protoc-gen-equal-go. DO NOT EDIT.
-// source: store/sheet.proto
-
-package store
-
-func (x *SheetPayload) Equal(y *SheetPayload) bool {
- if x == y {
- return true
- }
- if x == nil || y == nil {
- return x == nil && y == nil
- }
- if x.Engine != y.Engine {
- return false
- }
- if len(x.Commands) != len(y.Commands) {
- return false
- }
- for i := 0; i < len(x.Commands); i++ {
- if !x.Commands[i].Equal(y.Commands[i]) {
- return false
- }
- }
- return true
-}
diff --git a/backend/generated-go/store/task_run_log.pb.go b/backend/generated-go/store/task_run_log.pb.go
index c8ecad2c7b..4bd50e8164 100644
--- a/backend/generated-go/store/task_run_log.pb.go
+++ b/backend/generated-go/store/task_run_log.pb.go
@@ -445,6 +445,8 @@ func (x *TaskRunLog_SchemaDumpEnd) GetError() string {
type TaskRunLog_CommandExecute struct {
state protoimpl.MessageState `protogen:"open.v1"`
// The byte offset range of the executed command in the sheet.
+ // Uses byte offsets (not character indices) for efficient slicing of sheet content bytes.
+ // Example: For "SELECT 你好;" in a UTF-8 sheet, range [0, 13) represents all 13 bytes.
Range *Range `protobuf:"bytes,1,opt,name=range,proto3" json:"range,omitempty"`
// The statement to be executed.
Statement string `protobuf:"bytes,2,opt,name=statement,proto3" json:"statement,omitempty"`
diff --git a/backend/generated-go/v1/common.pb.go b/backend/generated-go/v1/common.pb.go
index 50a1bde95d..2077449acc 100644
--- a/backend/generated-go/v1/common.pb.go
+++ b/backend/generated-go/v1/common.pb.go
@@ -599,12 +599,14 @@ func (x *Position) GetColumn() int32 {
return 0
}
-// Range of positions in text or sequence.
+// Range represents a span within a text or sequence.
+// Whether the indices are byte offsets or character indices depends on the context.
+// Check the documentation of the field using Range for specific semantics.
type Range struct {
state protoimpl.MessageState `protogen:"open.v1"`
- // Start position (inclusive).
+ // Start index (inclusive).
Start int32 `protobuf:"varint,1,opt,name=start,proto3" json:"start,omitempty"`
- // End position (exclusive).
+ // End index (exclusive).
End int32 `protobuf:"varint,2,opt,name=end,proto3" json:"end,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
diff --git a/backend/generated-go/v1/rollout_service.pb.go b/backend/generated-go/v1/rollout_service.pb.go
index b1b4a3f862..6583e2d0c9 100644
--- a/backend/generated-go/v1/rollout_service.pb.go
+++ b/backend/generated-go/v1/rollout_service.pb.go
@@ -2896,6 +2896,8 @@ type TaskRunLogEntry_CommandExecute struct {
// When the command was logged.
LogTime *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=log_time,json=logTime,proto3" json:"log_time,omitempty"`
// The byte offset range of the executed command in the sheet.
+ // Uses byte offsets (not character indices) for efficient slicing of sheet content bytes.
+ // Example: For "SELECT 你好;" in a UTF-8 sheet, range [0, 13) represents all 13 bytes.
Range *Range `protobuf:"bytes,2,opt,name=range,proto3" json:"range,omitempty"`
// The executed statement.
Statement string `protobuf:"bytes,4,opt,name=statement,proto3" json:"statement,omitempty"`
diff --git a/backend/generated-go/v1/setting_service.pb.go b/backend/generated-go/v1/setting_service.pb.go
index 35772d4d31..f74d6fc101 100644
--- a/backend/generated-go/v1/setting_service.pb.go
+++ b/backend/generated-go/v1/setting_service.pb.go
@@ -2649,9 +2649,12 @@ func (x *Algorithm_InnerOuterMask) GetSubstitution() string {
type Algorithm_RangeMask_Slice struct {
state protoimpl.MessageState `protogen:"open.v1"`
- // start is the start index of the original value, start from 0 and should be less than stop.
+ // start is the start character index (0-based) of the original value, should be less than end.
+ // Uses character indices (not byte offsets) for display-oriented masking.
+ // Example: For "你好world", character index 2 refers to 'w' (the 3rd character).
Start int32 `protobuf:"varint,1,opt,name=start,proto3" json:"start,omitempty"`
- // stop is the stop index of the original value, should be less than the length of the original value.
+ // end is the end character index (exclusive) of the original value.
+ // Uses character indices (not byte offsets) for display-oriented masking.
End int32 `protobuf:"varint,2,opt,name=end,proto3" json:"end,omitempty"`
// substitution is the string used to replace the OriginalValue[start:end).
Substitution string `protobuf:"bytes,3,opt,name=substitution,proto3" json:"substitution,omitempty"`
diff --git a/backend/generated-go/v1/sheet_service.pb.go b/backend/generated-go/v1/sheet_service.pb.go
index 353fb10fb1..ef47de3183 100644
--- a/backend/generated-go/v1/sheet_service.pb.go
+++ b/backend/generated-go/v1/sheet_service.pb.go
@@ -250,9 +250,7 @@ type Sheet struct {
// set the `raw` to true in GetSheet request to retrieve the full content.
Content []byte `protobuf:"bytes,5,opt,name=content,proto3" json:"content,omitempty"`
// content_size is the full size of the content, may not match the size of the `content` field.
- ContentSize int64 `protobuf:"varint,6,opt,name=content_size,json=contentSize,proto3" json:"content_size,omitempty"`
- // The SQL dialect.
- Engine Engine `protobuf:"varint,8,opt,name=engine,proto3,enum=bytebase.v1.Engine" json:"engine,omitempty"`
+ ContentSize int64 `protobuf:"varint,6,opt,name=content_size,json=contentSize,proto3" json:"content_size,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -329,18 +327,11 @@ func (x *Sheet) GetContentSize() int64 {
return 0
}
-func (x *Sheet) GetEngine() Engine {
- if x != nil {
- return x.Engine
- }
- return Engine_ENGINE_UNSPECIFIED
-}
-
var File_v1_sheet_service_proto protoreflect.FileDescriptor
const file_v1_sheet_service_proto_rawDesc = "" +
"\n" +
- "\x16v1/sheet_service.proto\x12\vbytebase.v1\x1a\x1bbuf/validate/validate.proto\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x13v1/annotation.proto\x1a\x0fv1/common.proto\"y\n" +
+ "\x16v1/sheet_service.proto\x12\vbytebase.v1\x1a\x1bbuf/validate/validate.proto\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x13v1/annotation.proto\"y\n" +
"\x12CreateSheetRequest\x124\n" +
"\x06parent\x18\x01 \x01(\tB\x1c\xe0A\x02\xfaA\x16\n" +
"\x14bytebase.com/ProjectR\x06parent\x12-\n" +
@@ -354,7 +345,7 @@ const file_v1_sheet_service_proto_rawDesc = "" +
"\x0fGetSheetRequest\x12.\n" +
"\x04name\x18\x01 \x01(\tB\x1a\xe0A\x02\xfaA\x14\n" +
"\x12bytebase.com/SheetR\x04name\x12\x10\n" +
- "\x03raw\x18\x02 \x01(\bR\x03raw\"\xdc\x02\n" +
+ "\x03raw\x18\x02 \x01(\bR\x03raw\"\xaa\x02\n" +
"\x05Sheet\x12\x1a\n" +
"\x04name\x18\x01 \x01(\tB\x06\xe0A\x02\xe0A\x05R\x04name\x12!\n" +
"\x05title\x18\x02 \x01(\tB\v\xe0A\x02\xbaH\x05r\x03\x18\xc8\x01R\x05title\x12\x1d\n" +
@@ -362,8 +353,7 @@ const file_v1_sheet_service_proto_rawDesc = "" +
"\vcreate_time\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampB\x03\xe0A\x03R\n" +
"createTime\x12\x1d\n" +
"\acontent\x18\x05 \x01(\fB\x03\xe0A\x02R\acontent\x12&\n" +
- "\fcontent_size\x18\x06 \x01(\x03B\x03\xe0A\x03R\vcontentSize\x120\n" +
- "\x06engine\x18\b \x01(\x0e2\x13.bytebase.v1.EngineB\x03\xe0A\x02R\x06engine::\xeaA7\n" +
+ "\fcontent_size\x18\x06 \x01(\x03B\x03\xe0A\x03R\vcontentSize::\xeaA7\n" +
"\x12bytebase.com/Sheet\x12!projects/{project}/sheets/{sheet}2\xe0\x03\n" +
"\fSheetService\x12\x98\x01\n" +
"\vCreateSheet\x12\x1f.bytebase.v1.CreateSheetRequest\x1a\x12.bytebase.v1.Sheet\"T\xdaA\fparent,sheet\x8a\xea0\x10bb.sheets.create\x90\xea0\x01\x82\xd3\xe4\x93\x02':\x05sheet\"\x1e/v1/{parent=projects/*}/sheets\x12\xb1\x01\n" +
@@ -391,25 +381,23 @@ var file_v1_sheet_service_proto_goTypes = []any{
(*GetSheetRequest)(nil), // 3: bytebase.v1.GetSheetRequest
(*Sheet)(nil), // 4: bytebase.v1.Sheet
(*timestamppb.Timestamp)(nil), // 5: google.protobuf.Timestamp
- (Engine)(0), // 6: bytebase.v1.Engine
}
var file_v1_sheet_service_proto_depIdxs = []int32{
4, // 0: bytebase.v1.CreateSheetRequest.sheet:type_name -> bytebase.v1.Sheet
0, // 1: bytebase.v1.BatchCreateSheetsRequest.requests:type_name -> bytebase.v1.CreateSheetRequest
4, // 2: bytebase.v1.BatchCreateSheetsResponse.sheets:type_name -> bytebase.v1.Sheet
5, // 3: bytebase.v1.Sheet.create_time:type_name -> google.protobuf.Timestamp
- 6, // 4: bytebase.v1.Sheet.engine:type_name -> bytebase.v1.Engine
- 0, // 5: bytebase.v1.SheetService.CreateSheet:input_type -> bytebase.v1.CreateSheetRequest
- 1, // 6: bytebase.v1.SheetService.BatchCreateSheets:input_type -> bytebase.v1.BatchCreateSheetsRequest
- 3, // 7: bytebase.v1.SheetService.GetSheet:input_type -> bytebase.v1.GetSheetRequest
- 4, // 8: bytebase.v1.SheetService.CreateSheet:output_type -> bytebase.v1.Sheet
- 2, // 9: bytebase.v1.SheetService.BatchCreateSheets:output_type -> bytebase.v1.BatchCreateSheetsResponse
- 4, // 10: bytebase.v1.SheetService.GetSheet:output_type -> bytebase.v1.Sheet
- 8, // [8:11] is the sub-list for method output_type
- 5, // [5:8] is the sub-list for method input_type
- 5, // [5:5] is the sub-list for extension type_name
- 5, // [5:5] is the sub-list for extension extendee
- 0, // [0:5] is the sub-list for field type_name
+ 0, // 4: bytebase.v1.SheetService.CreateSheet:input_type -> bytebase.v1.CreateSheetRequest
+ 1, // 5: bytebase.v1.SheetService.BatchCreateSheets:input_type -> bytebase.v1.BatchCreateSheetsRequest
+ 3, // 6: bytebase.v1.SheetService.GetSheet:input_type -> bytebase.v1.GetSheetRequest
+ 4, // 7: bytebase.v1.SheetService.CreateSheet:output_type -> bytebase.v1.Sheet
+ 2, // 8: bytebase.v1.SheetService.BatchCreateSheets:output_type -> bytebase.v1.BatchCreateSheetsResponse
+ 4, // 9: bytebase.v1.SheetService.GetSheet:output_type -> bytebase.v1.Sheet
+ 7, // [7:10] is the sub-list for method output_type
+ 4, // [4:7] is the sub-list for method input_type
+ 4, // [4:4] is the sub-list for extension type_name
+ 4, // [4:4] is the sub-list for extension extendee
+ 0, // [0:4] is the sub-list for field type_name
}
func init() { file_v1_sheet_service_proto_init() }
@@ -418,7 +406,6 @@ func file_v1_sheet_service_proto_init() {
return
}
file_v1_annotation_proto_init()
- file_v1_common_proto_init()
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
diff --git a/backend/generated-go/v1/sheet_service_equal.pb.go b/backend/generated-go/v1/sheet_service_equal.pb.go
index 2d92dcc092..c28a3d9011 100644
--- a/backend/generated-go/v1/sheet_service_equal.pb.go
+++ b/backend/generated-go/v1/sheet_service_equal.pb.go
@@ -99,8 +99,5 @@ func (x *Sheet) Equal(y *Sheet) bool {
if x.ContentSize != y.ContentSize {
return false
}
- if x.Engine != y.Engine {
- return false
- }
return true
}
diff --git a/backend/plugin/advisor/utils_for_tests.go b/backend/plugin/advisor/utils_for_tests.go
index 651efd90b7..80e993543a 100644
--- a/backend/plugin/advisor/utils_for_tests.go
+++ b/backend/plugin/advisor/utils_for_tests.go
@@ -179,7 +179,7 @@ func RunSQLReviewRuleTest(t *testing.T, rule *storepb.SQLReviewRule, dbType stor
err = yaml.Unmarshal(byteValue, &tests)
require.NoError(t, err, rule.Type)
- sm := sheet.NewManager(nil)
+ sm := sheet.NewManager()
for i, tc := range tests {
// Set metadata and database-specific settings based on engine type
var schemaMetadata *storepb.DatabaseSchemaMetadata
diff --git a/backend/plugin/schema/mysql/walk_through_test.go b/backend/plugin/schema/mysql/walk_through_test.go
index 67f063c71b..64e35e08a8 100644
--- a/backend/plugin/schema/mysql/walk_through_test.go
+++ b/backend/plugin/schema/mysql/walk_through_test.go
@@ -42,7 +42,7 @@ func TestWalkThrough(t *testing.T) {
require.NoError(t, err)
err = yaml.Unmarshal(byteValue, &tests)
require.NoError(t, err)
- sm := sheet.NewManager(nil)
+ sm := sheet.NewManager()
for _, test := range tests {
// Make a deep copy to avoid mutation across tests
diff --git a/backend/plugin/schema/pg/walk_through_test.go b/backend/plugin/schema/pg/walk_through_test.go
index 54fb545791..09e394067b 100644
--- a/backend/plugin/schema/pg/walk_through_test.go
+++ b/backend/plugin/schema/pg/walk_through_test.go
@@ -84,7 +84,7 @@ func TestWalkThrough(t *testing.T) {
require.NoError(t, err)
err = yaml.Unmarshal(byteValue, &tests)
require.NoError(t, err)
- sm := sheet.NewManager(nil)
+ sm := sheet.NewManager()
for _, test := range tests {
// Make a deep copy to avoid mutation across tests
diff --git a/backend/plugin/schema/tidb/walk_through_test.go b/backend/plugin/schema/tidb/walk_through_test.go
index 0a4cc91811..de779eb9ff 100644
--- a/backend/plugin/schema/tidb/walk_through_test.go
+++ b/backend/plugin/schema/tidb/walk_through_test.go
@@ -42,7 +42,7 @@ func TestWalkThrough(t *testing.T) {
require.NoError(t, err)
err = yaml.Unmarshal(byteValue, &tests)
require.NoError(t, err)
- sm := sheet.NewManager(nil)
+ sm := sheet.NewManager()
for _, test := range tests {
// Make a deep copy to avoid mutation across tests
diff --git a/backend/runner/approval/runner.go b/backend/runner/approval/runner.go
index 535c2b72dd..0237c9463d 100644
--- a/backend/runner/approval/runner.go
+++ b/backend/runner/approval/runner.go
@@ -482,7 +482,7 @@ func (r *Runner) buildCELVariablesForDatabaseChange(ctx context.Context, issue *
}
// Build CEL variables for each task
- pipelineCreate, err := apiv1.GetPipelineCreate(ctx, r.store, r.sheetManager, r.dbFactory, plan.Config.GetSpecs(), plan.Config.GetDeployment(), issue.Project)
+ pipelineCreate, err := apiv1.GetPipelineCreate(ctx, r.store, r.dbFactory, plan.Config.GetSpecs(), plan.Config.GetDeployment(), issue.Project)
if err != nil {
return nil, false, errors.Wrap(err, "failed to get pipeline create")
}
@@ -593,7 +593,7 @@ func (r *Runner) buildCELVariablesForDataExport(ctx context.Context, issue *stor
return nil, false, errors.Errorf("plan %v not found", *issue.PlanUID)
}
- pipelineCreate, err := apiv1.GetPipelineCreate(ctx, r.store, r.sheetManager, r.dbFactory, plan.Config.GetSpecs(), plan.Config.GetDeployment(), issue.Project)
+ pipelineCreate, err := apiv1.GetPipelineCreate(ctx, r.store, r.dbFactory, plan.Config.GetSpecs(), plan.Config.GetDeployment(), issue.Project)
if err != nil {
return nil, false, errors.Wrap(err, "failed to get pipeline create")
}
diff --git a/backend/server/server.go b/backend/server/server.go
index f6ce1b0dc7..972ffca205 100644
--- a/backend/server/server.go
+++ b/backend/server/server.go
@@ -141,7 +141,7 @@ func NewServer(ctx context.Context, profile *config.Profile) (*Server, error) {
return nil, errors.Wrapf(err, "failed to migrate schema")
}
s.store = stores
- sheetManager := sheet.NewManager(stores)
+ sheetManager := sheet.NewManager()
// Initialize sample instance manager and start sample instances if they exist
s.sampleInstanceManager = sampleinstance.NewManager(stores, profile)
diff --git a/backend/store/sheet.go b/backend/store/sheet.go
index 7443e56cd3..bc8f510394 100644
--- a/backend/store/sheet.go
+++ b/backend/store/sheet.go
@@ -9,11 +9,9 @@ import (
"time"
"github.com/pkg/errors"
- "google.golang.org/protobuf/encoding/protojson"
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/common/qb"
- storepb "github.com/bytebase/bytebase/backend/generated-go/store"
)
// SheetMessage is the message for a sheet.
@@ -24,7 +22,6 @@ type SheetMessage struct {
Title string
Statement string
- Payload *storepb.SheetPayload
// Sha256 is the Sha256 hash of the statement.
Sha256 []byte
@@ -89,7 +86,6 @@ func (s *Store) getSheet(ctx context.Context, id int, loadFull bool) (*SheetMess
sheet.name,
%s,
sheet.sha256,
- sheet.payload,
OCTET_LENGTH(sheet_blob.content)
FROM sheet
LEFT JOIN sheet_blob ON sheet.sha256 = sheet_blob.sha256
@@ -115,7 +111,6 @@ func (s *Store) getSheet(ctx context.Context, id int, loadFull bool) (*SheetMess
var sheet *SheetMessage
if rows.Next() {
sheet = &SheetMessage{}
- var payload []byte
if err := rows.Scan(
&sheet.UID,
&sheet.Creator,
@@ -124,16 +119,10 @@ func (s *Store) getSheet(ctx context.Context, id int, loadFull bool) (*SheetMess
&sheet.Title,
&sheet.Statement,
&sheet.Sha256,
- &payload,
&sheet.Size,
); err != nil {
return nil, err
}
- sheetPayload := &storepb.SheetPayload{}
- if err := common.ProtojsonUnmarshaler.Unmarshal(payload, sheetPayload); err != nil {
- return nil, err
- }
- sheet.Payload = sheetPayload
}
if err := rows.Err(); err != nil {
@@ -157,7 +146,6 @@ func (s *Store) CreateSheets(ctx context.Context, projectID string, creator stri
var names []string
var statements []string
var sha256s [][]byte
- var payloads [][]byte
for _, c := range creates {
c.ProjectID = projectID
@@ -167,14 +155,6 @@ func (s *Store) CreateSheets(ctx context.Context, projectID string, creator stri
h := sha256.Sum256([]byte(c.Statement))
c.Sha256 = h[:]
sha256s = append(sha256s, c.Sha256)
- if c.Payload == nil {
- c.Payload = &storepb.SheetPayload{}
- }
- payload, err := protojson.Marshal(c.Payload)
- if err != nil {
- return nil, err
- }
- payloads = append(payloads, payload)
}
if err := s.batchCreateSheetBlob(ctx, sha256s, statements); err != nil {
@@ -186,16 +166,14 @@ func (s *Store) CreateSheets(ctx context.Context, projectID string, creator stri
creator,
project,
name,
- sha256,
- payload
+ sha256
) SELECT
?,
?,
unnest(CAST(? AS TEXT[])),
- unnest(CAST(? AS BYTEA[])),
- unnest(CAST(? AS JSONB[]))
+ unnest(CAST(? AS BYTEA[]))
RETURNING id, created_at
- `, creator, projectID, names, sha256s, payloads)
+ `, creator, projectID, names, sha256s)
query, args, err := q.ToSQL()
if err != nil {
diff --git a/backend/store/worksheet.go b/backend/store/worksheet.go
index ec08ee9e62..ab9ca718f0 100644
--- a/backend/store/worksheet.go
+++ b/backend/store/worksheet.go
@@ -190,11 +190,6 @@ func (s *Store) ListWorkSheets(ctx context.Context, find *FindWorkSheetMessage,
// CreateWorkSheet creates a new sheet.
func (s *Store) CreateWorkSheet(ctx context.Context, create *WorkSheetMessage) (*WorkSheetMessage, error) {
- payload, err := protojson.Marshal(&storepb.SheetPayload{})
- if err != nil {
- return nil, err
- }
-
q := qb.Q().Space(`
INSERT INTO worksheet (
creator,
@@ -206,9 +201,9 @@ func (s *Store) CreateWorkSheet(ctx context.Context, create *WorkSheetMessage) (
visibility,
payload
)
- VALUES (?, ?, ?, ?, ?, ?, ?, ?)
+ VALUES (?, ?, ?, ?, ?, ?, ?, '{}')
RETURNING id, created_at, updated_at, OCTET_LENGTH(statement)
- `, create.Creator, create.ProjectID, create.InstanceID, create.DatabaseName, create.Title, create.Statement, create.Visibility, payload)
+ `, create.Creator, create.ProjectID, create.InstanceID, create.DatabaseName, create.Title, create.Statement, create.Visibility)
query, args, err := q.ToSQL()
if err != nil {
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vue
index 5c40e58456..dae15637de 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vue
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vue
@@ -58,11 +58,7 @@ import {
specForTask,
useIssueContext,
} from "@/components/IssueV1/logic";
-import {
- databaseEngineForSpec,
- getLocalSheetByName,
- isValidSpec,
-} from "@/components/Plan";
+import { getLocalSheetByName, isValidSpec } from "@/components/Plan";
import { getSpecChangeType } from "@/components/Plan/components/SQLCheckSection/common";
import { usePlanSQLCheckContext } from "@/components/Plan/components/SQLCheckSection/context";
import { SQLCheckPanel } from "@/components/SQLCheck";
@@ -243,8 +239,6 @@ const createSheets = async () => {
if (uid.startsWith("-")) {
// The sheet is pending create
const sheet = getLocalSheetByName(config.sheet);
- const engine = await databaseEngineForSpec(spec);
- sheet.engine = engine;
pendingCreateSheetMap.set(sheet.name, sheet);
}
}
diff --git a/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue b/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue
index f067c91148..173ba6ac5e 100644
--- a/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue
+++ b/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue
@@ -176,7 +176,7 @@
<script setup lang="ts">
import { create } from "@bufbuild/protobuf";
import { useElementSize } from "@vueuse/core";
-import { cloneDeep, head, isEmpty } from "lodash-es";
+import { cloneDeep, isEmpty } from "lodash-es";
import { ExpandIcon } from "lucide-vue-next";
import { NButton, NTooltip, useDialog } from "naive-ui";
import { computed, reactive, ref, toRef, watch } from "vue";
@@ -191,10 +191,7 @@ import {
import { MonacoEditor } from "@/components/MonacoEditor";
import { extensionNameOfLanguage } from "@/components/MonacoEditor/utils";
import SQLUploadButton from "@/components/misc/SQLUploadButton.vue";
-import {
- createEmptyLocalSheet,
- databaseEngineForSpec,
-} from "@/components/Plan";
+import { createEmptyLocalSheet } from "@/components/Plan";
import RequiredStar from "@/components/RequiredStar.vue";
import DownloadSheetButton from "@/components/Sheet/DownloadSheetButton.vue";
import { planServiceClientConnect } from "@/grpcweb";
@@ -452,7 +449,6 @@ const updateStatement = async (statement: string) => {
const sheet = create(SheetSchema, {
...createEmptyLocalSheet(),
title: issue.value.title,
- engine: await databaseEngineForSpec(head(planPatch.specs)),
});
setSheetStatement(sheet, statement);
const createdSheet = await useSheetV1Store().createSheet(
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue
index 7c59acd4df..c9dc5a4233 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue
@@ -29,11 +29,7 @@ import {
ErrorList,
useSpecsValidation,
} from "@/components/Plan/components/common";
-import {
- databaseEngineForSpec,
- getLocalSheetByName,
- usePlanContext,
-} from "@/components/Plan/logic";
+import { getLocalSheetByName, usePlanContext } from "@/components/Plan/logic";
import {
issueServiceClientConnect,
planServiceClientConnect,
@@ -224,8 +220,6 @@ const createSheets = async () => {
if (uid.startsWith("-")) {
// The sheet is pending create.
const sheetToCreate = getLocalSheetByName(config.sheet);
- const engine = await databaseEngineForSpec(spec);
- sheetToCreate.engine = engine;
sheetToCreate.title = plan.value.title;
const createdSheet = await sheetStore.createSheet(
project.value.name,
diff --git a/frontend/src/components/Plan/components/RolloutView/TaskRunRollbackDrawer.vue b/frontend/src/components/Plan/components/RolloutView/TaskRunRollbackDrawer.vue
index b53aeae7e0..f47b02f928 100644
--- a/frontend/src/components/Plan/components/RolloutView/TaskRunRollbackDrawer.vue
+++ b/frontend/src/components/Plan/components/RolloutView/TaskRunRollbackDrawer.vue
@@ -302,7 +302,6 @@ const handleConfirm = async () => {
name: `${project.value.name}/sheets/${uuidv4()}`,
title: `Rollback for ${preview.task.target}`,
content: new TextEncoder().encode(preview.statement),
- engine: preview.database.instanceResource.engine,
})
);
diff --git a/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue b/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue
index 557d078b13..2843e9cb1c 100644
--- a/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue
+++ b/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue
@@ -84,7 +84,7 @@ import {
import type { Plan_Spec } from "@/types/proto-es/v1/plan_service_pb";
import { UpdatePlanRequestSchema } from "@/types/proto-es/v1/plan_service_pb";
import { extractSheetUID } from "@/utils";
-import { databaseEngineForSpec, getLocalSheetByName } from "../../logic";
+import { getLocalSheetByName } from "../../logic";
import { usePlanContext } from "../../logic/context";
import { useEditorState } from "../../logic/useEditorState";
import { getSpecTitle } from "../../logic/utils";
@@ -132,8 +132,6 @@ const handleSpecCreated = async (spec: Plan_Spec) => {
if (uid.startsWith("-")) {
// The sheet is pending create.
const sheetToCreate = getLocalSheetByName(spec.config.value.sheet);
- const engine = await databaseEngineForSpec(spec);
- sheetToCreate.engine = engine;
sheetToCreate.title = plan.value.title;
const createdSheet = await sheetStore.createSheet(
project.value.name,
diff --git a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue
index a9da057490..2dcb22b65d 100644
--- a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue
+++ b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue
@@ -205,7 +205,6 @@ import SQLUploadButton from "@/components/misc/SQLUploadButton.vue";
import { ErrorList } from "@/components/Plan/components/common";
import {
createEmptyLocalSheet,
- databaseEngineForSpec,
databaseForSpec,
planCheckRunListForSpec,
usePlanContext,
@@ -512,11 +511,9 @@ const updateStatement = async (statement: string) => {
`Unsupported spec type for plan update ${JSON.stringify(specToPatch)}`
);
}
- const specEngine = await databaseEngineForSpec(specToPatch);
const sheet = create(SheetSchema, {
...createEmptyLocalSheet(),
title: plan.value.title,
- engine: specEngine,
});
setSheetStatement(sheet, statement);
const createdSheet = await useSheetV1Store().createSheet(
diff --git a/frontend/src/components/Plan/logic/utils.ts b/frontend/src/components/Plan/logic/utils.ts
index 474bd1ec5e..a014883934 100644
--- a/frontend/src/components/Plan/logic/utils.ts
+++ b/frontend/src/components/Plan/logic/utils.ts
@@ -9,7 +9,7 @@ import { UpdatePlanRequestSchema } from "@/types/proto-es/v1/plan_service_pb";
import type { Project } from "@/types/proto-es/v1/project_service_pb";
import { SheetSchema } from "@/types/proto-es/v1/sheet_service_pb";
import { extractProjectResourceName, setSheetStatement } from "@/utils";
-import { createEmptyLocalSheet, databaseEngineForSpec } from ".";
+import { createEmptyLocalSheet } from ".";
export const projectOfPlan = (plan: Plan): Project => {
const project = `projects/${extractProjectResourceName(plan.name)}`;
@@ -56,11 +56,9 @@ export const updateSpecSheetWithStatement = async (
);
}
- const specEngine = await databaseEngineForSpec(specToPatch);
const newSheet = create(SheetSchema, {
...createEmptyLocalSheet(),
title: plan.title,
- engine: specEngine,
});
setSheetStatement(newSheet, statement);
diff --git a/frontend/src/store/modules/v1/localSheet.ts b/frontend/src/store/modules/v1/localSheet.ts
index 187a32f006..100d33e277 100644
--- a/frontend/src/store/modules/v1/localSheet.ts
+++ b/frontend/src/store/modules/v1/localSheet.ts
@@ -28,7 +28,6 @@ export const useLocalSheetStore = defineStore("local_sheet", () => {
creator: defaults.creator || "",
content: defaults.content || new Uint8Array(),
contentSize: defaults.contentSize || BigInt(0),
- engine: defaults.engine,
createTime: defaults.createTime,
});
return reactive(sheet);
diff --git a/frontend/src/store/modules/v1/sheet.ts b/frontend/src/store/modules/v1/sheet.ts
index 8cbae41e41..edede0942e 100644
--- a/frontend/src/store/modules/v1/sheet.ts
+++ b/frontend/src/store/modules/v1/sheet.ts
@@ -5,7 +5,6 @@ import { sheetServiceClientConnect } from "@/grpcweb";
import { useCache } from "@/store/cache";
import type { MaybeRef } from "@/types";
import { UNKNOWN_ID } from "@/types";
-import { Engine } from "@/types/proto-es/v1/common_pb";
import type { Sheet } from "@/types/proto-es/v1/sheet_service_pb";
import {
CreateSheetRequestSchema,
@@ -32,19 +31,12 @@ export const useSheetV1Store = defineStore("sheet_v1", () => {
// CRUD
const createSheet = async (parent: string, sheet: Partial<Sheet>) => {
- if (!sheet.engine) {
- console.warn(
- `[SheetService.CreateSheet] sheet.engine unspecified: ${sheet.engine}`
- );
- sheet.engine = Engine.ENGINE_UNSPECIFIED;
- }
const fullSheet = create(SheetSchema, {
name: sheet.name || "",
title: sheet.title || "",
creator: sheet.creator || "",
content: sheet.content || new Uint8Array(),
contentSize: sheet.contentSize || BigInt(0),
- engine: sheet.engine || Engine.MYSQL,
createTime: sheet.createTime,
});
const request = create(CreateSheetRequestSchema, {
diff --git a/frontend/src/types/proto-es/v1/common_pb.d.ts b/frontend/src/types/proto-es/v1/common_pb.d.ts
index 218f2972f2..2c7c8398f3 100644
--- a/frontend/src/types/proto-es/v1/common_pb.d.ts
+++ b/frontend/src/types/proto-es/v1/common_pb.d.ts
@@ -60,20 +60,22 @@ export declare type Position = Message<"bytebase.v1.Position"> & {
export declare const PositionSchema: GenMessage<Position>;
/**
- * Range of positions in text or sequence.
+ * Range represents a span within a text or sequence.
+ * Whether the indices are byte offsets or character indices depends on the context.
+ * Check the documentation of the field using Range for specific semantics.
*
* @generated from message bytebase.v1.Range
*/
export declare type Range = Message<"bytebase.v1.Range"> & {
/**
- * Start position (inclusive).
+ * Start index (inclusive).
*
* @generated from field: int32 start = 1;
*/
start: number;
/**
- * End position (exclusive).
+ * End index (exclusive).
*
* @generated from field: int32 end = 2;
*/
diff --git a/frontend/src/types/proto-es/v1/rollout_service_pb.d.ts b/frontend/src/types/proto-es/v1/rollout_service_pb.d.ts
index 86b15b8fb4..036b919dbd 100644
--- a/frontend/src/types/proto-es/v1/rollout_service_pb.d.ts
+++ b/frontend/src/types/proto-es/v1/rollout_service_pb.d.ts
@@ -1399,6 +1399,8 @@ export declare type TaskRunLogEntry_CommandExecute = Message<"bytebase.v1.TaskRu
/**
* The byte offset range of the executed command in the sheet.
+ * Uses byte offsets (not character indices) for efficient slicing of sheet content bytes.
+ * Example: For "SELECT 你好;" in a UTF-8 sheet, range [0, 13) represents all 13 bytes.
*
* @generated from field: bytebase.v1.Range range = 2;
*/
diff --git a/frontend/src/types/proto-es/v1/setting_service_pb.d.ts b/frontend/src/types/proto-es/v1/setting_service_pb.d.ts
index 9cb1d666a3..f53cb7f288 100644
--- a/frontend/src/types/proto-es/v1/setting_service_pb.d.ts
+++ b/frontend/src/types/proto-es/v1/setting_service_pb.d.ts
@@ -1092,14 +1092,17 @@ export declare const Algorithm_RangeMaskSchema: GenMessage<Algorithm_RangeMask>;
*/
export declare type Algorithm_RangeMask_Slice = Message<"bytebase.v1.Algorithm.RangeMask.Slice"> & {
/**
- * start is the start index of the original value, start from 0 and should be less than stop.
+ * start is the start character index (0-based) of the original value, should be less than end.
+ * Uses character indices (not byte offsets) for display-oriented masking.
+ * Example: For "你好world", character index 2 refers to 'w' (the 3rd character).
*
* @generated from field: int32 start = 1;
*/
start: number;
/**
- * stop is the stop index of the original value, should be less than the length of the original value.
+ * end is the end character index (exclusive) of the original value.
+ * Uses character indices (not byte offsets) for display-oriented masking.
*
* @generated from field: int32 end = 2;
*/
diff --git a/frontend/src/types/proto-es/v1/sheet_service_pb.d.ts b/frontend/src/types/proto-es/v1/sheet_service_pb.d.ts
index 005cecb52d..59554dfd0c 100644
--- a/frontend/src/types/proto-es/v1/sheet_service_pb.d.ts
+++ b/frontend/src/types/proto-es/v1/sheet_service_pb.d.ts
@@ -5,7 +5,6 @@
import type { GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2";
import type { Message } from "@bufbuild/protobuf";
import type { Timestamp } from "@bufbuild/protobuf/wkt";
-import type { Engine } from "./common_pb";
/**
* Describes the file v1/sheet_service.proto.
@@ -154,13 +153,6 @@ export declare type Sheet = Message<"bytebase.v1.Sheet"> & {
* @generated from field: int64 content_size = 6;
*/
contentSize: bigint;
-
- /**
- * The SQL dialect.
- *
- * @generated from field: bytebase.v1.Engine engine = 8;
- */
- engine: Engine;
};
/**
diff --git a/frontend/src/types/proto-es/v1/sheet_service_pb.js b/frontend/src/types/proto-es/v1/sheet_service_pb.js
index a60bf33d1e..77436c50b2 100644
--- a/frontend/src/types/proto-es/v1/sheet_service_pb.js
+++ b/frontend/src/types/proto-es/v1/sheet_service_pb.js
@@ -10,13 +10,12 @@ import { file_google_api_field_behavior } from "../google/api/field_behavior_pb"
import { file_google_api_resource } from "../google/api/resource_pb";
import { file_google_protobuf_timestamp } from "@bufbuild/protobuf/wkt";
import { file_v1_annotation } from "./annotation_pb";
-import { file_v1_common } from "./common_pb";
/**
* Describes the file v1/sheet_service.proto.
*/
export const file_v1_sheet_service = /*@__PURE__*/
- fileDesc("ChZ2MS9zaGVldF9zZXJ2aWNlLnByb3RvEgtieXRlYmFzZS52MSJqChJDcmVhdGVTaGVldFJlcXVlc3QSLAoGcGFyZW50GAEgASgJQhzgQQL6QRYKFGJ5dGViYXNlLmNvbS9Qcm9qZWN0EiYKBXNoZWV0GAIgASgLMhIuYnl0ZWJhc2UudjEuU2hlZXRCA+BBAiKAAQoYQmF0Y2hDcmVhdGVTaGVldHNSZXF1ZXN0EiwKBnBhcmVudBgBIAEoCUIc4EEC+kEWChRieXRlYmFzZS5jb20vUHJvamVjdBI2CghyZXF1ZXN0cxgCIAMoCzIfLmJ5dGViYXNlLnYxLkNyZWF0ZVNoZWV0UmVxdWVzdEID4EECIj8KGUJhdGNoQ3JlYXRlU2hlZXRzUmVzcG9uc2USIgoGc2hlZXRzGAEgAygLMhIuYnl0ZWJhc2UudjEuU2hlZXQiSAoPR2V0U2hlZXRSZXF1ZXN0EigKBG5hbWUYASABKAlCGuBBAvpBFAoSYnl0ZWJhc2UuY29tL1NoZWV0EgsKA3JhdxgCIAEoCCKcAgoFU2hlZXQSFAoEbmFtZRgBIAEoCUIG4EEC4EEFEhoKBXRpdGxlGAIgASgJQgvgQQK6SAVyAxjIARIUCgdjcmVhdG9yGAMgASgJQgPgQQMSNAoLY3JlYXRlX3RpbWUYBCABKAsyGi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wQgPgQQMSFAoHY29udGVudBgFIAEoDEID4EECEhkKDGNvbnRlbnRfc2l6ZRgGIAEoA0ID4EEDEigKBmVuZ2luZRgIIAEoDjITLmJ5dGViYXNlLnYxLkVuZ2luZUID4EECOjrqQTcKEmJ5dGViYXNlLmNvbS9TaGVldBIhcHJvamVjdHMve3Byb2plY3R9L3NoZWV0cy97c2hlZXR9MuADCgxTaGVldFNlcnZpY2USmAEKC0NyZWF0ZVNoZWV0Eh8uYnl0ZWJhc2UudjEuQ3JlYXRlU2hlZXRSZXF1ZXN0GhIuYnl0ZWJhc2UudjEuU2hlZXQiVNpBDHBhcmVudCxzaGVldIrqMBBiYi5zaGVldHMuY3JlYXRlkOowAYLT5JMCJzoFc2hlZXQiHi92MS97cGFyZW50PXByb2plY3RzLyp9L3NoZWV0cxKxAQoRQmF0Y2hDcmVhdGVTaGVldHMSJS5ieXRlYmFzZS52MS5CYXRjaENyZWF0ZVNoZWV0c1JlcXVlc3QaJi5ieXRlYmFzZS52MS5CYXRjaENyZWF0ZVNoZWV0c1Jlc3BvbnNlIk2K6jAQYmIuc2hlZXRzLmNyZWF0ZZDqMAGC0+STAi86ASoiKi92MS97cGFyZW50PXByb2plY3RzLyp9L3NoZWV0czpiYXRjaENyZWF0ZRKAAQoIR2V0U2hlZXQSHC5ieXRlYmFzZS52MS5HZXRTaGVldFJlcXVlc3QaEi5ieXRlYmFzZS52MS5TaGVldCJC2kEEbmFtZYrqMA1iYi5zaGVldHMuZ2V0kOowAYLT5JMCIBIeL3YxL3tuYW1lPXByb2plY3RzLyovc2hlZXRzLyp9QqcBCg9jb20uYnl0ZWJhc2UudjFCEVNoZWV0U2VydmljZVByb3RvUAFaNGdpdGh1Yi5jb20vYnl0ZWJhc2UvYnl0ZWJhc2UvYmFja2VuZC9nZW5lcmF0ZWQtZ28vdjGiAgNCWFiqAgtCeXRlYmFzZS5WMcoCC0J5dGViYXNlXFYx4gIXQnl0ZWJhc2VcVjFcR1BCTWV0YWRhdGHqAgxCeXRlYmFzZTo6VjFiBnByb3RvMw", [file_buf_validate_validate, file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_timestamp, file_v1_annotation, file_v1_common]);
+ fileDesc("ChZ2MS9zaGVldF9zZXJ2aWNlLnByb3RvEgtieXRlYmFzZS52MSJqChJDcmVhdGVTaGVldFJlcXVlc3QSLAoGcGFyZW50GAEgASgJQhzgQQL6QRYKFGJ5dGViYXNlLmNvbS9Qcm9qZWN0EiYKBXNoZWV0GAIgASgLMhIuYnl0ZWJhc2UudjEuU2hlZXRCA+BBAiKAAQoYQmF0Y2hDcmVhdGVTaGVldHNSZXF1ZXN0EiwKBnBhcmVudBgBIAEoCUIc4EEC+kEWChRieXRlYmFzZS5jb20vUHJvamVjdBI2CghyZXF1ZXN0cxgCIAMoCzIfLmJ5dGViYXNlLnYxLkNyZWF0ZVNoZWV0UmVxdWVzdEID4EECIj8KGUJhdGNoQ3JlYXRlU2hlZXRzUmVzcG9uc2USIgoGc2hlZXRzGAEgAygLMhIuYnl0ZWJhc2UudjEuU2hlZXQiSAoPR2V0U2hlZXRSZXF1ZXN0EigKBG5hbWUYASABKAlCGuBBAvpBFAoSYnl0ZWJhc2UuY29tL1NoZWV0EgsKA3JhdxgCIAEoCCLyAQoFU2hlZXQSFAoEbmFtZRgBIAEoCUIG4EEC4EEFEhoKBXRpdGxlGAIgASgJQgvgQQK6SAVyAxjIARIUCgdjcmVhdG9yGAMgASgJQgPgQQMSNAoLY3JlYXRlX3RpbWUYBCABKAsyGi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wQgPgQQMSFAoHY29udGVudBgFIAEoDEID4EECEhkKDGNvbnRlbnRfc2l6ZRgGIAEoA0ID4EEDOjrqQTcKEmJ5dGViYXNlLmNvbS9TaGVldBIhcHJvamVjdHMve3Byb2plY3R9L3NoZWV0cy97c2hlZXR9MuADCgxTaGVldFNlcnZpY2USmAEKC0NyZWF0ZVNoZWV0Eh8uYnl0ZWJhc2UudjEuQ3JlYXRlU2hlZXRSZXF1ZXN0GhIuYnl0ZWJhc2UudjEuU2hlZXQiVNpBDHBhcmVudCxzaGVldIrqMBBiYi5zaGVldHMuY3JlYXRlkOowAYLT5JMCJzoFc2hlZXQiHi92MS97cGFyZW50PXByb2plY3RzLyp9L3NoZWV0cxKxAQoRQmF0Y2hDcmVhdGVTaGVldHMSJS5ieXRlYmFzZS52MS5CYXRjaENyZWF0ZVNoZWV0c1JlcXVlc3QaJi5ieXRlYmFzZS52MS5CYXRjaENyZWF0ZVNoZWV0c1Jlc3BvbnNlIk2K6jAQYmIuc2hlZXRzLmNyZWF0ZZDqMAGC0+STAi86ASoiKi92MS97cGFyZW50PXByb2plY3RzLyp9L3NoZWV0czpiYXRjaENyZWF0ZRKAAQoIR2V0U2hlZXQSHC5ieXRlYmFzZS52MS5HZXRTaGVldFJlcXVlc3QaEi5ieXRlYmFzZS52MS5TaGVldCJC2kEEbmFtZYrqMA1iYi5zaGVldHMuZ2V0kOowAYLT5JMCIBIeL3YxL3tuYW1lPXByb2plY3RzLyovc2hlZXRzLyp9QqcBCg9jb20uYnl0ZWJhc2UudjFCEVNoZWV0U2VydmljZVByb3RvUAFaNGdpdGh1Yi5jb20vYnl0ZWJhc2UvYnl0ZWJhc2UvYmFja2VuZC9nZW5lcmF0ZWQtZ28vdjGiAgNCWFiqAgtCeXRlYmFzZS5WMcoCC0J5dGViYXNlXFYx4gIXQnl0ZWJhc2VcVjFcR1BCTWV0YWRhdGHqAgxCeXRlYmFzZTo6VjFiBnByb3RvMw", [file_buf_validate_validate, file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_timestamp, file_v1_annotation]);
/**
* Describes the message bytebase.v1.CreateSheetRequest.
diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yaml
index 8626a05d18..83e92c42e8 100644
--- a/proto/gen/grpc-doc/openapi.yaml
+++ b/proto/gen/grpc-doc/openapi.yaml
@@ -12714,23 +12714,31 @@ components:
properties:
start:
type: integer
- description: Start position (inclusive).
+ description: Start index (inclusive).
format: int32
end:
type: integer
- description: End position (exclusive).
+ description: End index (exclusive).
format: int32
- description: Range of positions in text or sequence.
+ description: |-
+ Range represents a span within a text or sequence.
+ Whether the indices are byte offsets or character indices depends on the context.
+ Check the documentation of the field using Range for specific semantics.
RangeMask_Slice:
type: object
properties:
start:
type: integer
- description: start is the start index of the original value, start from 0 and should be less than stop.
+ description: |-
+ start is the start character index (0-based) of the original value, should be less than end.
+ Uses character indices (not byte offsets) for display-oriented masking.
+ Example: For "你好world", character index 2 refers to 'w' (the 3rd character).
format: int32
end:
type: integer
- description: stop is the stop index of the original value, should be less than the length of the original value.
+ description: |-
+ end is the end character index (exclusive) of the original value.
+ Uses character indices (not byte offsets) for display-oriented masking.
format: int32
substitution:
type: string
@@ -13983,7 +13991,6 @@ components:
- name
- title
- content
- - engine
type: object
properties:
name:
@@ -14017,37 +14024,6 @@ components:
readOnly: true
type: string
description: content_size is the full size of the content, may not match the size of the `content` field.
- engine:
- enum:
- - ENGINE_UNSPECIFIED
- - CLICKHOUSE
- - MYSQL
- - POSTGRES
- - SNOWFLAKE
- - SQLITE
- - TIDB
- - MONGODB
- - REDIS
- - ORACLE
- - SPANNER
- - MSSQL
- - REDSHIFT
- - MARIADB
- - OCEANBASE
- - STARROCKS
- - DORIS
- - HIVE
- - ELASTICSEARCH
- - BIGQUERY
- - DYNAMODB
- - DATABRICKS
- - COCKROACHDB
- - COSMOSDB
- - TRINO
- - CASSANDRA
- type: string
- description: The SQL dialect.
- format: enum
SpatialIndexConfig:
type: object
properties:
@@ -14699,7 +14675,10 @@ components:
range:
allOf:
- $ref: '#/components/schemas/Range'
- description: The byte offset range of the executed command in the sheet.
+ description: |-
+ The byte offset range of the executed command in the sheet.
+ Uses byte offsets (not character indices) for efficient slicing of sheet content bytes.
+ Example: For "SELECT 你好;" in a UTF-8 sheet, range [0, 13) represents all 13 bytes.
statement:
type: string
description: The executed statement.
diff --git a/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.md
index 20bd380675..3441769d39 100644
--- a/proto/gen/grpc-doc/store/README.md
+++ b/proto/gen/grpc-doc/store/README.md
@@ -279,9 +279,6 @@
- [WorkspaceProfileSetting.Announcement.AlertLevel](#bytebase-store-WorkspaceProfileSetting-Announcement-AlertLevel)
- [WorkspaceProfileSetting.DatabaseChangeMode](#bytebase-store-WorkspaceProfileSetting-DatabaseChangeMode)
-- [store/sheet.proto](#store_sheet-proto)
- - [SheetPayload](#bytebase-store-SheetPayload)
-
- [store/task.proto](#store_task-proto)
- [Task](#bytebase-store-Task)
- [Task.FlagsEntry](#bytebase-store-Task-FlagsEntry)
@@ -392,6 +389,8 @@ Examples: - &#34;SELECT * FROM t&#34; - column 8 is &#39;*&#39; - &#34;SELECT
### Range
Range represents a span within a text or sequence.
+Whether the indices are byte offsets or character indices depends on the context.
+Check the documentation of the field using Range for specific semantics.
| Field | Type | Label | Description |
@@ -4137,9 +4136,9 @@ The severity level for SQL review rules.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
-| start | [int32](#int32) | | start is the start index of the original value, start from 0 and should be less than stop. |
-| end | [int32](#int32) | | stop is the stop index of the original value, should be less than the length of the original value. |
-| substitution | [string](#string) | | OriginalValue[start:end) would be replaced with replace_with. |
+| start | [int32](#int32) | | start is the start character index (0-based) of the original value, should be less than end. Uses character indices (not byte offsets) for display-oriented masking. Example: For &#34;你好world&#34;, character index 2 refers to &#39;w&#39; (the 3rd character). |
+| end | [int32](#int32) | | end is the end character index (exclusive) of the original value. Uses character indices (not byte offsets) for display-oriented masking. |
+| substitution | [string](#string) | | OriginalValue[start:end) would be replaced with substitution. |
@@ -4664,38 +4663,6 @@ We support three levels of AlertLevel: INFO, WARNING, and ERROR.
-<a name="store_sheet-proto"></a>
-<p align="right"><a href="#top">Top</a></p>
-
-## store/sheet.proto
-
-
-
-<a name="bytebase-store-SheetPayload"></a>
-
-### SheetPayload
-
-
-
-| Field | Type | Label | Description |
-| ----- | ---- | ----- | ----------- |
-| engine | [Engine](#bytebase-store-Engine) | | The SQL dialect of the sheet. |
-| commands | [Range](#bytebase-store-Range) | repeated | The start and end position of each command in the sheet statement. |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
<a name="store_task-proto"></a>
<p align="right"><a href="#top">Top</a></p>
@@ -4980,7 +4947,7 @@ Status represents the current execution state of a task run.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
-| range | [Range](#bytebase-store-Range) | | The byte offset range of the executed command in the sheet. |
+| range | [Range](#bytebase-store-Range) | | The byte offset range of the executed command in the sheet. Uses byte offsets (not character indices) for efficient slicing of sheet content bytes. Example: For &#34;SELECT 你好;&#34; in a UTF-8 sheet, range [0, 13) represents all 13 bytes. |
| statement | [string](#string) | | The statement to be executed. |
diff --git a/proto/gen/grpc-doc/store/index.html b/proto/gen/grpc-doc/store/index.html
index 1b201d5d9b..f0a67965c7 100644
--- a/proto/gen/grpc-doc/store/index.html
+++ b/proto/gen/grpc-doc/store/index.html
@@ -1290,21 +1290,6 @@
</li>
- <li>
- <a href="#store%2fsheet.proto">store/sheet.proto</a>
- <ul>
-
- <li>
- <a href="#bytebase.store.SheetPayload"><span class="badge">M</span>SheetPayload</a>
- </li>
-
-
-
-
- </ul>
- </li>
-
-
<li>
<a href="#store%2ftask.proto">store/task.proto</a>
<ul>
@@ -1584,7 +1569,7 @@ Examples:
<h3 id="bytebase.store.Range">Range</h3>
- <p>Range represents a span within a text or sequence.</p>
+ <p>Range represents a span within a text or sequence.</p><p>Whether the indices are byte offsets or character indices depends on the context.</p><p>Check the documentation of the field using Range for specific semantics.</p>
<table class="field-table">
@@ -11457,21 +11442,24 @@ But frontend can be started with a single rule easily. </p></td>
<td>start</td>
<td><a href="#int32">int32</a></td>
<td></td>
- <td><p>start is the start index of the original value, start from 0 and should be less than stop. </p></td>
+ <td><p>start is the start character index (0-based) of the original value, should be less than end.
+Uses character indices (not byte offsets) for display-oriented masking.
+Example: For &#34;你好world&#34;, character index 2 refers to &#39;w&#39; (the 3rd character). </p></td>
</tr>
<tr>
<td>end</td>
<td><a href="#int32">int32</a></td>
<td></td>
- <td><p>stop is the stop index of the original value, should be less than the length of the original value. </p></td>
+ <td><p>end is the end character index (exclusive) of the original value.
+Uses character indices (not byte offsets) for display-oriented masking. </p></td>
</tr>
<tr>
<td>substitution</td>
<td><a href="#string">string</a></td>
<td></td>
- <td><p>OriginalValue[start:end) would be replaced with replace_with. </p></td>
+ <td><p>OriginalValue[start:end) would be replaced with substitution. </p></td>
</tr>
</tbody>
@@ -12733,51 +12721,6 @@ Default to this mode.</p></td>
- <div class="file-heading">
- <h2 id="store/sheet.proto">store/sheet.proto</h2><a href="#title">Top</a>
- </div>
- <p></p>
-
-
- <h3 id="bytebase.store.SheetPayload">SheetPayload</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>engine</td>
- <td><a href="#bytebase.store.Engine">Engine</a></td>
- <td></td>
- <td><p>The SQL dialect of the sheet. </p></td>
- </tr>
-
- <tr>
- <td>commands</td>
- <td><a href="#bytebase.store.Range">Range</a></td>
- <td>repeated</td>
- <td><p>The start and end position of each command in the sheet statement. </p></td>
- </tr>
-
- </tbody>
- </table>
-
-
-
-
-
-
-
-
-
-
-
-
-
<div class="file-heading">
<h2 id="store/task.proto">store/task.proto</h2><a href="#title">Top</a>
</div>
@@ -13484,7 +13427,9 @@ Format: instances/{instance}/databases/{database}/changelogs/{changelog} </p></t
<td>range</td>
<td><a href="#bytebase.store.Range">Range</a></td>
<td></td>
- <td><p>The byte offset range of the executed command in the sheet. </p></td>
+ <td><p>The byte offset range of the executed command in the sheet.
+Uses byte offsets (not character indices) for efficient slicing of sheet content bytes.
+Example: For &#34;SELECT 你好;&#34; in a UTF-8 sheet, range [0, 13) represents all 13 bytes. </p></td>
</tr>
<tr>
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 3c8bebd294..74167b5483 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -761,13 +761,15 @@ Examples: - &#34;SELECT * FROM t&#34; - column 8 is &#39;*&#39; - &#34;SELECT
<a name="bytebase-v1-Range"></a>
### Range
-Range of positions in text or sequence.
+Range represents a span within a text or sequence.
+Whether the indices are byte offsets or character indices depends on the context.
+Check the documentation of the field using Range for specific semantics.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
-| start | [int32](#int32) | | Start position (inclusive). |
-| end | [int32](#int32) | | End position (exclusive). |
+| start | [int32](#int32) | | Start index (inclusive). |
+| end | [int32](#int32) | | End index (exclusive). |
@@ -1599,8 +1601,8 @@ IssueService manages issues for tracking database changes and tasks.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
-| start | [int32](#int32) | | start is the start index of the original value, start from 0 and should be less than stop. |
-| end | [int32](#int32) | | stop is the stop index of the original value, should be less than the length of the original value. |
+| start | [int32](#int32) | | start is the start character index (0-based) of the original value, should be less than end. Uses character indices (not byte offsets) for display-oriented masking. Example: For &#34;你好world&#34;, character index 2 refers to &#39;w&#39; (the 3rd character). |
+| end | [int32](#int32) | | end is the end character index (exclusive) of the original value. Uses character indices (not byte offsets) for display-oriented masking. |
| substitution | [string](#string) | | substitution is the string used to replace the OriginalValue[start:end). |
@@ -10050,7 +10052,7 @@ Command execution details.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| log_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | When the command was logged. |
-| range | [Range](#bytebase-v1-Range) | | The byte offset range of the executed command in the sheet. |
+| range | [Range](#bytebase-v1-Range) | | The byte offset range of the executed command in the sheet. Uses byte offsets (not character indices) for efficient slicing of sheet content bytes. Example: For &#34;SELECT 你好;&#34; in a UTF-8 sheet, range [0, 13) represents all 13 bytes. |
| statement | [string](#string) | | The executed statement. |
| response | [TaskRunLogEntry.CommandExecute.CommandResponse](#bytebase-v1-TaskRunLogEntry-CommandExecute-CommandResponse) | | The response from executing the command. |
@@ -10478,7 +10480,6 @@ RolloutService manages the execution of deployment plans.
| create_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | The create time of the sheet. |
| content | [bytes](#bytes) | | The content of the sheet. By default, it will be cut off, if it doesn&#39;t match the `content_size`, you can set the `raw` to true in GetSheet request to retrieve the full content. |
| content_size | [int64](#int64) | | content_size is the full size of the content, may not match the size of the `content` field. |
-| engine | [Engine](#bytebase-v1-Engine) | | The SQL dialect. |
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index 46265c9583..9ec6cd41b5 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -2898,7 +2898,7 @@ Examples:
<h3 id="bytebase.v1.Range">Range</h3>
- <p>Range of positions in text or sequence.</p>
+ <p>Range represents a span within a text or sequence.</p><p>Whether the indices are byte offsets or character indices depends on the context.</p><p>Check the documentation of the field using Range for specific semantics.</p>
<table class="field-table">
@@ -2911,14 +2911,14 @@ Examples:
<td>start</td>
<td><a href="#int32">int32</a></td>
<td></td>
- <td><p>Start position (inclusive). </p></td>
+ <td><p>Start index (inclusive). </p></td>
</tr>
<tr>
<td>end</td>
<td><a href="#int32">int32</a></td>
<td></td>
- <td><p>End position (exclusive). </p></td>
+ <td><p>End index (exclusive). </p></td>
</tr>
</tbody>
@@ -5212,14 +5212,17 @@ But frontend can be started with a single rule easily. </p></td>
<td>start</td>
<td><a href="#int32">int32</a></td>
<td></td>
- <td><p>start is the start index of the original value, start from 0 and should be less than stop. </p></td>
+ <td><p>start is the start character index (0-based) of the original value, should be less than end.
+Uses character indices (not byte offsets) for display-oriented masking.
+Example: For &#34;你好world&#34;, character index 2 refers to &#39;w&#39; (the 3rd character). </p></td>
</tr>
<tr>
<td>end</td>
<td><a href="#int32">int32</a></td>
<td></td>
- <td><p>stop is the stop index of the original value, should be less than the length of the original value. </p></td>
+ <td><p>end is the end character index (exclusive) of the original value.
+Uses character indices (not byte offsets) for display-oriented masking. </p></td>
</tr>
<tr>
@@ -28207,7 +28210,9 @@ Format: instances/{instance}/databases/{database} </p></td>
<td>range</td>
<td><a href="#bytebase.v1.Range">Range</a></td>
<td></td>
- <td><p>The byte offset range of the executed command in the sheet. </p></td>
+ <td><p>The byte offset range of the executed command in the sheet.
+Uses byte offsets (not character indices) for efficient slicing of sheet content bytes.
+Example: For &#34;SELECT 你好;&#34; in a UTF-8 sheet, range [0, 13) represents all 13 bytes. </p></td>
</tr>
<tr>
@@ -29465,13 +29470,6 @@ set the `raw` to true in GetSheet request to retrieve the full content. </p></td
<td><p>content_size is the full size of the content, may not match the size of the `content` field. </p></td>
</tr>
- <tr>
- <td>engine</td>
- <td><a href="#bytebase.v1.Engine">Engine</a></td>
- <td></td>
- <td><p>The SQL dialect. </p></td>
- </tr>
-
</tbody>
</table>
diff --git a/proto/store/store/sheet.proto b/proto/store/store/sheet.proto
deleted file mode 100644
index b7a92949ed..0000000000
--- a/proto/store/store/sheet.proto
+++ /dev/null
@@ -1,14 +0,0 @@
-syntax = "proto3";
-
-package bytebase.store;
-
-import "store/common.proto";
-
-option go_package = "generated-go/store";
-
-message SheetPayload {
- // The SQL dialect of the sheet.
- Engine engine = 1;
- // The start and end position of each command in the sheet statement.
- repeated Range commands = 2;
-}
diff --git a/proto/v1/v1/sheet_service.proto b/proto/v1/v1/sheet_service.proto
index a2652e68da..fe362ed3a3 100644
--- a/proto/v1/v1/sheet_service.proto
+++ b/proto/v1/v1/sheet_service.proto
@@ -9,7 +9,6 @@ import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/protobuf/timestamp.proto";
import "v1/annotation.proto";
-import "v1/common.proto";
option go_package = "github.com/bytebase/bytebase/backend/generated-go/v1";
@@ -121,7 +120,4 @@ message Sheet {
// content_size is the full size of the content, may not match the size of the `content` field.
int64 content_size = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
-
- // The SQL dialect.
- Engine engine = 8 [(google.api.field_behavior) = REQUIRED];
}