schemas.ts22 lines · main
| 1 | import { safeSql } from '../pg-format' |
| 2 | |
| 3 | export const SCHEMAS_SQL = /* SQL */ safeSql` |
| 4 | -- Adapted from information_schema.schemata |
| 5 | |
| 6 | select |
| 7 | n.oid as id, |
| 8 | n.nspname as name, |
| 9 | u.rolname as owner, |
| 10 | obj_description(n.oid, 'pg_namespace') AS comment |
| 11 | from |
| 12 | pg_namespace n, |
| 13 | pg_roles u |
| 14 | where |
| 15 | n.nspowner = u.oid |
| 16 | and ( |
| 17 | pg_has_role(n.nspowner, 'USAGE') |
| 18 | or has_schema_privilege(n.oid, 'CREATE, USAGE') |
| 19 | ) |
| 20 | and not pg_catalog.starts_with(n.nspname, 'pg_temp_') |
| 21 | and not pg_catalog.starts_with(n.nspname, 'pg_toast_temp_') |
| 22 | ` |