hoist select queryAccessibleObjectUuidsOfSubjectIds(...)
into WITH CTE for better performance
This commit is contained in:
parent
368da1cc95
commit
63db939583
@ -143,15 +143,17 @@ begin
|
|||||||
/*
|
/*
|
||||||
Creates a restricted view based on the 'view' permission of the current subject.
|
Creates a restricted view based on the 'view' permission of the current subject.
|
||||||
*/
|
*/
|
||||||
-- TODO.refa: hoist `select queryAccessibleObjectUuidsOfSubjectIds(...)` into WITH CTE for performance
|
|
||||||
sql := format($sql$
|
sql := format($sql$
|
||||||
set session session authorization default;
|
set session session authorization default;
|
||||||
create view %1$s_rv as
|
create view %1$s_rv as
|
||||||
select target.*
|
with accessibleObjects as (
|
||||||
from %1$s as target
|
select queryAccessibleObjectUuidsOfSubjectIds('view', '%1$s', currentSubjectsUuids())
|
||||||
where target.uuid in (select queryAccessibleObjectUuidsOfSubjectIds('view', '%1$s', currentSubjectsUuids()))
|
)
|
||||||
order by %2$s;
|
select target.*
|
||||||
grant all privileges on %1$s_rv to restricted;
|
from %1$s as target
|
||||||
|
where target.uuid in (select * from accessibleObjects)
|
||||||
|
order by %2$s;
|
||||||
|
grant all privileges on %1$s_rv to restricted;
|
||||||
$sql$, targetTable, orderBy);
|
$sql$, targetTable, orderBy);
|
||||||
execute sql;
|
execute sql;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user