MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / plan_update_privilege

Function plan_update_privilege

src/sql/src/plan/statement/acl.rs:422–614  ·  view source on GitHub ↗
(
    scx: &StatementContext,
    privileges: PrivilegeSpecification,
    target: GrantTargetSpecification<Aug>,
    roles: Vec<ResolvedRoleName>,
)

Source from the content-addressed store, hash-verified

420}
421
422fn plan_update_privilege(
423 scx: &StatementContext,
424 privileges: PrivilegeSpecification,
425 target: GrantTargetSpecification<Aug>,
426 roles: Vec<ResolvedRoleName>,
427) -> Result<UpdatePrivilegesPlan, PlanError> {
428 let (object_type, target_ids) = match target {
429 GrantTargetSpecification::Object {
430 object_type,
431 object_spec_inner,
432 } => {
433 fn object_type_filter(
434 object_id: &ObjectId,
435 object_type: &ObjectType,
436 scx: &StatementContext,
437 ) -> bool {
438 if object_type == &ObjectType::Table {
439 scx.get_object_type(object_id).is_relation()
440 } else {
441 object_type == &scx.get_object_type(object_id)
442 }
443 }
444 let object_type = object_type.into();
445 let object_ids: Vec<ObjectId> = match object_spec_inner {
446 GrantTargetSpecificationInner::All(GrantTargetAllSpecification::All) => {
447 let cluster_ids = scx
448 .catalog
449 .get_clusters()
450 .into_iter()
451 .map(|cluster| cluster.id().into());
452 let database_ids = scx
453 .catalog
454 .get_databases()
455 .into_iter()
456 .map(|database| database.id().into());
457 let schema_ids = scx
458 .catalog
459 .get_schemas()
460 .into_iter()
461 .filter(|schema| !schema.id().is_temporary())
462 .map(|schema| (schema.database().clone(), schema.id().clone()).into());
463 let item_ids = scx
464 .catalog
465 .get_items()
466 .into_iter()
467 .map(|item| item.id().into());
468 cluster_ids
469 .chain(database_ids)
470 .chain(schema_ids)
471 .chain(item_ids)
472 .filter(|object_id| object_type_filter(object_id, &object_type, scx))
473 .filter(|object_id| object_id.is_user())
474 .collect()
475 }
476 GrantTargetSpecificationInner::All(GrantTargetAllSpecification::AllDatabases {
477 databases,
478 }) => {
479 let schema_ids = databases

Callers 2

plan_grant_privilegesFunction · 0.85
plan_revoke_privilegesFunction · 0.85

Calls 15

object_type_filterFunction · 0.85
database_idMethod · 0.80
database_specMethod · 0.80
schema_specMethod · 0.80
ObjectClass · 0.50
mapMethod · 0.45
into_iterMethod · 0.45
get_clustersMethod · 0.45
idMethod · 0.45
get_databasesMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected