21316: Merge commit '1416f698b72de4b09350d9c2fb25c1405c3247bc' into 21316-left-panel...
[arvados.git] / services / api / lib / create_ancestor_view.sql
1 -- Copyright (C) The Arvados Authors. All rights reserved.
2 --
3 -- SPDX-License-Identifier: AGPL-3.0
4
5 CREATE TEMPORARY VIEW ancestor_view AS
6 WITH RECURSIVE
7 ancestor (uuid, ancestor_uuid) AS (
8      SELECT groups.uuid::varchar(32)       AS uuid,
9             groups.owner_uuid::varchar(32) AS ancestor_uuid
10             FROM groups
11      UNION
12      SELECT ancestor.uuid::varchar(32)     AS uuid,
13             groups.owner_uuid::varchar(32) AS ancestor_uuid
14             FROM ancestor
15             INNER JOIN groups
16             ON groups.uuid = ancestor.ancestor_uuid
17 )
18 SELECT * FROM ancestor;