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

Function buildExportQueryContext

backend/api/v1/sql_service.go:172–186  ·  view source on GitHub ↗

buildExportQueryContext assembles the db.QueryContext for an export request. SkipMasking has to be set here (not only checked around the post-execution MaskResults pass) because some drivers mask at query time via SQL rewrites — by the time the second pass runs the rows would already be masked, and

(restriction *store.EffectiveQueryDataPolicy, userEmail string, schema *string, skipMasking bool)

Source from the content-addressed store, hash-verified

170// a JIT grant with unmask=true would silently export masked data. See PR
171// #20487 review (RainbowDashy).
172func buildExportQueryContext(restriction *store.EffectiveQueryDataPolicy, userEmail string, schema *string, skipMasking bool) db.QueryContext {
173 qc := db.QueryContext{
174 Limit: int(restriction.MaximumResultRows),
175 OperatorEmail: userEmail,
176 MaximumSQLResultSize: restriction.MaximumResultSize,
177 SkipMasking: skipMasking,
178 }
179 if restriction.MaxQueryTimeoutInSeconds > 0 {
180 qc.Timeout = &durationpb.Duration{Seconds: restriction.MaxQueryTimeoutInSeconds}
181 }
182 if schema != nil {
183 qc.Schema = *schema
184 }
185 return qc
186}
187
188// preCheckAccess returns the user's most capable active access grant matching
189// the given query, or nil if none. When `requireExport` is true the CEL

Calls

no outgoing calls