Create a row level security policy
Arguments
- con
a DBI database connection object
- policy
(list) a policy derived from
rls_construct_policy()
Examples
if (FALSE) { # interactive() && has_postgres()
library(DBI)
library(RPostgres)
con <- dbConnect(Postgres())
dbCreateTable(con, "sometable", mtcars)
policy1 <- rls_construct_policy(
name = "hide_confidential",
table = "sometable",
using = "(true)"
)
policy1
rls_create_policy(con, policy1)
rls_policies(con)
policy2 <- rls_construct_policy(
name = "policy_concerts",
table = "sometable",
command = "SELECT",
using = "(true)"
)
policy2
rls_create_policy(con, policy2)
rls_policies(con)
# cleanup
rls_drop_policy(con, policy1)
rls_drop_policy(con, policy2)
dbExecute(con, "DROP table sometable")
dbDisconnect(con)
}