MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / insert_rls_rules

Function insert_rls_rules

crates/core/src/sql/execute.rs:455–474  ·  view source on GitHub ↗

Insert rules into the RLS system table

(
        db: &RelationalDB,
        table_ids: impl IntoIterator<Item = TableId>,
        rules: impl IntoIterator<Item = &'static str>,
    )

Source from the content-addressed store, hash-verified

453
454 /// Insert rules into the RLS system table
455 fn insert_rls_rules(
456 db: &RelationalDB,
457 table_ids: impl IntoIterator<Item = TableId>,
458 rules: impl IntoIterator<Item = &'static str>,
459 ) -> anyhow::Result<()> {
460 with_auto_commit(db, |tx| {
461 for (table_id, sql) in table_ids.into_iter().zip(rules) {
462 db.insert(
463 tx,
464 ST_ROW_LEVEL_SECURITY_ID,
465 &ProductValue::from(StRowLevelSecurityRow {
466 table_id,
467 sql: sql.into(),
468 })
469 .to_bsatn_vec()?,
470 )?;
471 }
472 Ok(())
473 })
474 }
475
476 /// Insert product values into a table
477 fn insert_rows(

Callers 2

test_rls_rulesFunction · 0.70
test_nested_rls_rulesFunction · 0.70

Calls 5

with_auto_commitFunction · 0.85
insertMethod · 0.65
OkFunction · 0.50
into_iterMethod · 0.45
to_bsatn_vecMethod · 0.45

Tested by 2

test_rls_rulesFunction · 0.56
test_nested_rls_rulesFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…