hoist select queryAccessibleObjectUuidsOfSubjectIds(...)
into WITH CTE for better performance
This commit is contained in:
parent
368da1cc95
commit
63db939583
@ -143,13 +143,15 @@ 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
|
||||||
|
with accessibleObjects as (
|
||||||
|
select queryAccessibleObjectUuidsOfSubjectIds('view', '%1$s', currentSubjectsUuids())
|
||||||
|
)
|
||||||
select target.*
|
select target.*
|
||||||
from %1$s as target
|
from %1$s as target
|
||||||
where target.uuid in (select queryAccessibleObjectUuidsOfSubjectIds('view', '%1$s', currentSubjectsUuids()))
|
where target.uuid in (select * from accessibleObjects)
|
||||||
order by %2$s;
|
order by %2$s;
|
||||||
grant all privileges on %1$s_rv to restricted;
|
grant all privileges on %1$s_rv to restricted;
|
||||||
$sql$, targetTable, orderBy);
|
$sql$, targetTable, orderBy);
|
||||||
|
Loading…
Reference in New Issue
Block a user