按照这些帖子中的信息,我想使用角色系统和策略,即我系统中的每个用户都有一个 db 角色。我想对以下属性进行建模,但我无法提出角色层次结构。
考虑以下表格:
companies(id, name)
users(id, name)
projects(id, name, company_id)
users_companies(user_id, company_id, type)
users_projects(user_id, project_id)
每个用户在公司内可以有不同的类型(管理员/员工/客户),并且取决于策略应该改变。因此,当用户通过身份验证时,我们知道他的 user_id 和 company_id 可以提供策略中所需的 id,例如
set local user_vars.user_id = 10
set local user_vars.company_id = 20
获得此权限所需的角色和策略是
什么
我正在寻找一个我可以建立的基本案例。我的主要问题是用户可以根据当前公司拥有不同的角色/类型
postgresql authorization role row-level-security postgresql-9.5
我现在的用户是 pronto
mediapop_staging=> select current_user;
current_user
--------------
pronto
(1 row)
Run Code Online (Sandbox Code Playgroud)
此用户是在 AWS RDS 上创建的标准超级用户。
mediapop_staging=> \du pronto
List of roles
Role name | Attributes | Member of
-----------+-------------------------------+-----------------
pronto | Create role, Create DB +| {rds_superuser}
| Password valid until infinity |
Run Code Online (Sandbox Code Playgroud)
但我得到这个:
mediapop_staging=> REASSIGN OWNED BY pronto TO mediapop_staging;
ERROR: permission denied to reassign objects
Run Code Online (Sandbox Code Playgroud)
为什么?我该如何解决?
MS SQL Server 是否有像Postgresql那样的系列生成函数(又名generate_series)。如果没有,有没有基本的方法来实现该功能?优先考虑时间戳版本
我发现这个问题是一个老问题。也许新版本有更好的解决方案。
Postgres 13
我正在寻找一种在 postgresql 中搜索可能具有变体字符表示形式的 UTF-8 文本的方法(正确的术语是什么?即vs )。
life
我遇到匹配变体字符的问题,请考虑
-- This works as expected
select 'life' ilike '%life%' matches
-- I would like to also be able to match against this source text like this
select '' ilike '%life%' matches
Run Code Online (Sandbox Code Playgroud)
请注意,有无数的变体,我此时并不特别关心与非 ascii 可表示字符的匹配,也就是说,我认为只要最终与 匹配,我就可以从 utf-8 到 ascii 有损转换
life
。
假设我有一个表,其描述如下:
create table my_table (
id serial,
create_date timestamp with time zone default now(),
data text
);
Run Code Online (Sandbox Code Playgroud)
和这样的查询:
select * from my_table
where create_date >= timestamp with time zone 'yesterday'
Run Code Online (Sandbox Code Playgroud)
理论上哪个索引会更快,为什么?
create index index_a on my_table (create_date);
create index index_b on my_table (create_date DESC);
Run Code Online (Sandbox Code Playgroud) postgresql ×4
amazon-rds ×1
collation ×1
index ×1
index-tuning ×1
role ×1
sql-server ×1
utf-8 ×1