MCPcopy Index your code
hub / github.com/bytebase/bytebase / getEffectiveQueryDataPolicy

Function getEffectiveQueryDataPolicy

backend/api/v1/sql_service.go:470–496  ·  view source on GitHub ↗
(
	ctx context.Context,
	stores *store.Store,
	licenseService *enterprise.LicenseService,
	limit int32,
	projectID string,
)

Source from the content-addressed store, hash-verified

468}
469
470func getEffectiveQueryDataPolicy(
471 ctx context.Context,
472 stores *store.Store,
473 licenseService *enterprise.LicenseService,
474 limit int32,
475 projectID string,
476) *store.EffectiveQueryDataPolicy {
477 value := &store.EffectiveQueryDataPolicy{
478 MaximumResultSize: common.DefaultMaximumSQLResultSize,
479 MaximumResultRows: math.MaxInt32,
480 }
481 if err := licenseService.IsFeatureEnabled(ctx, common.GetWorkspaceIDFromContext(ctx), v1pb.PlanFeature_FEATURE_QUERY_POLICY); err == nil {
482 policy, err := stores.GetEffectiveQueryDataPolicy(ctx, common.GetWorkspaceIDFromContext(ctx), common.FormatProject(projectID))
483 if err != nil {
484 slog.Error("failed to get the query data policy", log.BBError(err))
485 return value
486 }
487 value = policy
488 }
489 if limit > 0 {
490 value.MaximumResultRows = min(limit, value.MaximumResultRows)
491 }
492 if value.MaximumResultRows == math.MaxInt32 {
493 value.MaximumResultRows = 0
494 }
495 return value
496}
497
498type accessCheckFunc func(context.Context, *store.InstanceMessage, *store.DatabaseMessage, *store.UserMessage, []*parserbase.QuerySpan, bool /* isExplain */, []parserbase.Statement, string /* requestSchema */, bool /* multiStatement */) error
499

Callers 3

AdminExecuteMethod · 0.85
QueryMethod · 0.85
doExportFunction · 0.85

Calls 6

FormatProjectFunction · 0.92
BBErrorFunction · 0.92
IsFeatureEnabledMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected