prepare stmt1 from "
with recursive g as (select distinct gid from auth_user_group where uid=?),
cte as (
  select
    f.uuid,
    f.parent,
    f.type,
    f.uid,
    f.gid,
    f.access,
    f.name,
    f.flags,
    f.created,
    f.modified,
    0 as level,
    cast('' as varchar(128)) path
  from feature f
    inner join g on f.gid = g.gid or ?
  where uuid=0x8c954007c5c749c9a4af10b23efd2ebf and (? or f.uid = ? or (f.access & ?))
  union
  select
    f.uuid,
    f.parent,
    f.type,
    f.uid,
    f.gid,
    f.access,
    f.name,
    f.flags,
    f.created,
    f.modified,
    r.level + 1,
    concat(r.path, '/', (select @rn := @rn + 1 from ( select @rn := 0 ) _rn)) path
  from feature f
    inner join cte r
    inner join g on f.gid = g.gid or ?
  where f.parent = r.uuid and 0=f.flags&4 and (? or f.uid = ? or (f.access & ?))
)
select
  cte.uuid,
  cte.parent,
  cte.type,
  cte.uid owner,
  g.authority`group`,
  cte.access,
  cte.name,
  cte.flags,
  timestampdiff(microsecond, '1970-01-01', cte.created),
  timestampdiff(microsecond, '1970-01-01', cte.modified),
  fs.value properties,
  fp.value gdmsprop,
  prj.value projection,
  cte.level
from cte
  inner join customer g on g.id=cte.gid
  left join prop fs on fs.uuid = cte.uuid and fs.name = 'properties'
  left join prop fp on fp.uuid = cte.uuid and fp.name = 'gdmsprop'
  left join prop prj on cte.type='Workspace' and prj.uuid = cte.uuid and prj.name = 'crs-proj4'
order
  by cte.path";
execute stmt1 using 1, true, true, 1, 237, true, true, 1, 237;
deallocate prepare stmt1;

