1
1
with search_path_oids(schema_oid) as (
2
2
select y::regnamespace::oid from unnest(current_schemas(false)) x(y)
3
3
),
4
- schemas_(oid , name) as (
4
+
5
+ schemas_with_privilege(oid , name) as (
6
+ -- Schema segregated multi-tenant environments need a shortcut to
7
+ -- exclude schemas without USAGE permission so context reload can ignore
8
+ -- irreleavnt tenants
9
+ -- https://github.com/supabase/pg_graphql/pull/480
5
10
select
6
- pn .oid ::int , pn .nspname ::text
11
+ pn .oid ::int ,
12
+ pn .nspname ::text
7
13
from
8
14
pg_namespace pn
9
- -- filter to current schemas only
10
- join search_path_oids cur_schemas(oid )
11
- on pn .oid = cur_schemas .oid
12
15
where
13
16
pg_catalog .has_schema_privilege (
14
17
current_user ,
15
18
pn .oid ,
16
19
' USAGE'
17
20
)
21
+ ),
22
+
23
+ schemas_(oid , name) as (
24
+ select
25
+ pn .oid ,
26
+ pn .name
27
+ from
28
+ schemas_with_privilege pn
29
+ -- filter to current schemas only
30
+ join search_path_oids cur_schemas(oid )
31
+ on pn .oid = cur_schemas .oid
18
32
)
33
+
19
34
select
20
35
jsonb_build_object(
21
36
' config' , jsonb_build_object(
54
69
pg_enum pe
55
70
join pg_type pt
56
71
on pt .oid = pe .enumtypid
72
+ join schemas_with_privilege swp
73
+ on pt .typnamespace = swp .oid
57
74
group by
58
75
pt .oid
59
76
)
@@ -93,6 +110,8 @@ select
93
110
)
94
111
from
95
112
pg_type pt
113
+ join schemas_with_privilege swp
114
+ on pt .typnamespace = swp .oid
96
115
left join pg_class tabs
97
116
on pt .typrelid = tabs .oid
98
117
),
@@ -111,6 +130,8 @@ select
111
130
pg_type pt
112
131
join pg_class tabs
113
132
on pt .typrelid = tabs .oid
133
+ join schemas_with_privilege swp
134
+ on pt .typnamespace = swp .oid
114
135
where
115
136
pt .typcategory = ' C'
116
137
and tabs .relkind = ' c'
@@ -198,6 +219,8 @@ select
198
219
)
199
220
from
200
221
schemas_ pn
222
+ join schemas_with_privilege swp
223
+ on pn .oid = swp .oid
201
224
),
202
225
jsonb_build_object()
203
226
),
@@ -419,5 +442,4 @@ select
419
442
),
420
443
jsonb_build_array()
421
444
)
422
-
423
445
)
0 commit comments