Skip to content

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

chore: move const (#11813)

Danny Xu15971e10d06d
diff --git a/backend/api/v1/sql_service.go b/backend/api/v1/sql_service.go
index b6f036d557..f98d57ce47 100644
--- a/backend/api/v1/sql_service.go
+++ b/backend/api/v1/sql_service.go
@@ -44,9 +44,6 @@ import (
)
const (
- // The maximum number of bytes for sql results in response body.
- // 100 MB.
- maximumSQLResultSize = 100 * 1024 * 1024
// defaultTimeout is the default timeout for query and admin execution.
defaultTimeout = 10 * time.Minute
)
@@ -147,10 +144,10 @@ func (s *SQLService) AdminExecute(server v1pb.SQLService_AdminExecuteServer) err
response.Results = result
}
- if proto.Size(response) > maximumSQLResultSize {
+ if proto.Size(response) > common.MaximumSQLResultSize {
response.Results = []*v1pb.QueryResult{
{
- Error: fmt.Sprintf("Output of query exceeds max allowed output size of %dMB", maximumSQLResultSize/1024/1024),
+ Error: fmt.Sprintf("Output of query exceeds max allowed output size of %dMB", common.MaximumSQLResultSize/1024/1024),
},
}
}
@@ -226,10 +223,10 @@ func (s *SQLService) Execute(ctx context.Context, request *v1pb.ExecuteRequest)
Results: results,
Advices: advices,
}
- if proto.Size(response) > maximumSQLResultSize {
+ if proto.Size(response) > common.MaximumSQLResultSize {
response.Results = []*v1pb.QueryResult{
{
- Error: fmt.Sprintf("Output of query exceeds max allowed output size of %dMB", maximumSQLResultSize/1024/1024),
+ Error: fmt.Sprintf("Output of query exceeds max allowed output size of %dMB", common.MaximumSQLResultSize/1024/1024),
},
}
}
@@ -504,8 +501,8 @@ func DoExport(ctx context.Context, storeInstance *store.Store, dbFactory *dbfact
if len(result) > 1 {
result = result[len(result)-1:]
}
- if proto.Size(&v1pb.QueryResponse{Results: result}) > maximumSQLResultSize {
- return nil, durationNs, errors.Errorf("Output of query exceeds max allowed output size of %dMB", maximumSQLResultSize/1024/1024)
+ if proto.Size(&v1pb.QueryResponse{Results: result}) > common.MaximumSQLResultSize {
+ return nil, durationNs, errors.Errorf("Output of query exceeds max allowed output size of %dMB", common.MaximumSQLResultSize/1024/1024)
}
if licenseService.IsFeatureEnabledForInstance(api.FeatureSensitiveData, instance) == nil {
@@ -882,10 +879,10 @@ func (s *SQLService) Query(ctx context.Context, request *v1pb.QueryRequest) (*v1
AllowExport: allowExport,
}
- if proto.Size(response) > maximumSQLResultSize {
+ if proto.Size(response) > common.MaximumSQLResultSize {
response.Results = []*v1pb.QueryResult{
{
- Error: fmt.Sprintf("Output of query exceeds max allowed output size of %dMB", maximumSQLResultSize/1024/1024),
+ Error: fmt.Sprintf("Output of query exceeds max allowed output size of %dMB", common.MaximumSQLResultSize/1024/1024),
},
}
}
diff --git a/backend/common/util.go b/backend/common/util.go
index 4a531eb8c3..689a7b234a 100644
--- a/backend/common/util.go
+++ b/backend/common/util.go
@@ -29,6 +29,9 @@ const (
MaxBinlogSizeLimit = 32 * 1024 * 1024
// MaxChunksCount is the maximum number of chunks for a sheet.
MaxSheetChunksCount = 200
+ // The maximum number of bytes for sql results in response body.
+ // 100 MB.
+ MaximumSQLResultSize = 100 * 1024 * 1024
// ExternalURLPlaceholder is the docs link to configure --external-url.
ExternalURLPlaceholder = "https://www.bytebase.com/docs/get-started/install/external-url"
diff --git a/backend/server/routers.go b/backend/server/routers.go
index 2a71647456..c749625c3f 100644
--- a/backend/server/routers.go
+++ b/backend/server/routers.go
@@ -82,8 +82,8 @@ func configureEchoRouters(e *echo.Echo, grpcServer *grpc.Server, lspServer *lsp.
e.GET("/v1:adminExecute", echo.WrapHandler(wsproxy.WebsocketProxy(
mux,
wsproxy.WithTokenCookieName("access-token"),
- // 10M.
- wsproxy.WithMaxRespBodyBufferSize(10*1024*1024),
+ // 100M.
+ wsproxy.WithMaxRespBodyBufferSize(100*1024*1024),
)))
e.Any("/v1/*", echo.WrapHandler(mux))