-
Notifications
You must be signed in to change notification settings - Fork 36
/
nodes.sql
21 lines (21 loc) · 945 Bytes
/
nodes.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2017, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#}
{% import 'systemobjects.macros' as SYSOBJECTS %}
SELECT rel.oid,
(SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE) AS triggercount,
(SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE AND tgenabled = 'O') AS has_enable_triggers,
(CASE WHEN rel.relkind = 'p' THEN true ELSE false END) AS is_partitioned,
nsp.nspname AS schema,
nsp.oid AS schemaoid,
rel.relname AS name,
{{ SYSOBJECTS.IS_SYSTEMSCHEMA('nsp') }} as is_system
FROM pg_class rel
INNER JOIN pg_namespace nsp ON rel.relnamespace= nsp.oid
WHERE rel.relkind IN ('r','t','f','p')
{% if tid %} AND rel.oid = {{tid}}::OID {% endif %}
AND NOT rel.relispartition
ORDER BY nsp.nspname, rel.relname;