Skip to content

Commit c50a5e1

Browse files
committed
fix: always ignore temporary schemas
i.e. `pg_temp_*`, `pg_toast_temp_*`
1 parent 5edaf99 commit c50a5e1

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

src/lib/constants.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
export const DEFAULT_SYSTEM_SCHEMAS = [
2-
'information_schema',
3-
'pg_catalog',
4-
'pg_temp_1',
5-
'pg_toast',
6-
'pg_toast_temp_1',
7-
]
1+
export const DEFAULT_SYSTEM_SCHEMAS = ['information_schema', 'pg_catalog', 'pg_toast']

src/lib/sql/schemas.sql

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
-- Adapted from information_schema.schemata
22

3-
SELECT
4-
n.oid :: int8 AS id,
5-
n.nspname AS name,
6-
u.rolname AS owner
7-
FROM
3+
select
4+
n.oid::int8 as id,
5+
n.nspname as name,
6+
u.rolname as owner
7+
from
88
pg_namespace n,
99
pg_roles u
10-
WHERE
10+
where
1111
n.nspowner = u.oid
12-
AND (
12+
and (
1313
pg_has_role(n.nspowner, 'USAGE')
14-
OR has_schema_privilege(n.oid, 'CREATE, USAGE')
14+
or has_schema_privilege(n.oid, 'CREATE, USAGE')
1515
)
16+
and not pg_catalog.starts_with(n.nspname, 'pg_temp_')
17+
and not pg_catalog.starts_with(n.nspname, 'pg_toast_temp_')

0 commit comments

Comments
 (0)