/usr/share/pgmodeler/schemas/catalog/constraint.sch is in pgmodeler-common 0.9.1~beta-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | # Catalog queries for constraints
# CAUTION: Do not modify this file unless you know what you are doing.
# Code generation can be broken if incorrect changes are made.
%if {list} %then
[ SELECT cs.oid, cs.conname AS name FROM pg_constraint AS cs ]
%if {schema} %then
[ LEFT JOIN pg_namespace AS ns ON ns.oid = cs.connamespace
LEFT JOIN pg_class AS tb ON cs.conrelid = tb.oid
WHERE nspname= ] '{schema}'
%if {table} %then
[ AND relkind='r' AND relname=] '{table}'
%end
%end
%if {last-sys-oid} %then
%if {schema} %then
[ AND ]
%else
[ WHERE ]
%end
[ cs.oid ] {oid-filter-op} $sp {last-sys-oid}
%end
%if {last-sys-oid} %or {schema} %then
[ AND ]
%else
[ WHERE ]
%end
#Avoiding the listing of constraint generated by constraint triggers
[ cs.oid NOT IN (SELECT DISTINCT tgconstraint FROM pg_trigger WHERE tgconstrindid=0)]
%if {not-ext-object} %then
[ AND ]( {not-ext-object} )
%end
%else
%if {attribs} %then
[SELECT cs.oid, cs.conname AS name, cs.conrelid AS table, ds.description AS comment,
cs.conkey AS src_columns, cs.confkey AS dst_columns, cs.consrc AS expression,
cs.condeferrable AS deferrable_bool, cs.confrelid AS ref_table,
cl.reltablespace AS tablespace, cs.conexclop AS operators,
am.amname AS index_type, cl.reloptions AS factor, ]
[ id.indkey::oid] $ob $cb [ AS columns,
id. indclass::oid] $ob $cb [ AS opclasses,
pg_get_expr(id.indpred, id.indexrelid) AS condition,
pg_get_constraintdef(cs.oid) AS expressions, ]
%if ({pgsql-ver} <=f "9.1") %then
[ FALSE AS no_inherit_bool, ]
%else
[ cs.connoinherit AS no_inherit_bool, ]
%end
[ CASE cs.coninhcount
WHEN 0 THEN FALSE
ELSE TRUE
END AS inherited_bool,
CASE cs.contype
WHEN 'p' THEN 'pk-constr'
WHEN 'u' THEN 'uq-constr'
WHEN 'c' THEN 'ck-constr'
WHEN 'f' THEN 'fk-constr'
ELSE 'ex-constr'
END AS type,
CASE cs.condeferred
WHEN TRUE THEN 'INITIALLY DEFERRED'
ELSE 'INITIALLY IMMEDIATE'
END AS defer_type,
CASE cs.confupdtype
WHEN 'a' THEN 'NO ACTION'
WHEN 'r' THEN 'RESTRICT'
WHEN 'c' THEN 'CASCADE'
WHEN 'n' THEN 'SET NULL'
WHEN 'd' THEN 'SET DEFAULT'
ELSE NULL
END AS upd_action,
CASE cs.confdeltype
WHEN 'a' THEN 'NO ACTION'
WHEN 'r' THEN 'RESTRICT'
WHEN 'c' THEN 'CASCADE'
WHEN 'n' THEN 'SET NULL'
WHEN 'd' THEN 'SET DEFAULT'
ELSE NULL
END AS del_action,
CASE cs.confmatchtype
WHEN 'f' THEN 'MATCH FULL'
WHEN 'p' THEN 'MATCH PARTIAL' ]
[ WHEN ] %if ({pgsql-ver} >=f "9.3") %then 's' %else 'u' %end [ THEN 'MATCH SIMPLE' ]
[ ELSE NULL
END AS comparison_type
FROM pg_constraint AS cs
LEFT JOIN pg_description AS ds ON ds.objoid=cs.oid
LEFT JOIN pg_class AS cl ON cl.oid = cs.conindid
LEFT JOIN pg_am AS am ON cl.relam = am.oid
LEFT JOIN pg_index AS id ON id.indexrelid= cs.conindid ]
%if {schema} %then
[ LEFT JOIN pg_namespace AS ns ON ns.oid = cs.connamespace
LEFT JOIN pg_class AS tb ON cs.conrelid = tb.oid
WHERE ns.nspname= ] '{schema}'
%if {table} %then
[ AND tb.relkind='r' AND tb.relname= ] '{table}'
%end
%end
%if {last-sys-oid} %then
%if {schema} %then
[ AND ]
%else
[ WHERE ]
%end
[ cs.oid ] {oid-filter-op} $sp {last-sys-oid}
%end
%if {filter-oids} %then
%if {schema} %or {last-sys-oid} %then
[ AND ]
%else
[ WHERE ]
%end
[ cs.oid IN (] {filter-oids} )
%end
%if {filter-oids} %or {last-sys-oid} %or {schema} %then
[ AND ]
%else
[ WHERE ]
%end
#Avoiding the listing of constraint generated by constraint triggers
[ cs.oid NOT IN (SELECT DISTINCT tgconstraint FROM pg_trigger WHERE tgconstrindid=0)]
%if {not-ext-object} %then
[ AND ]( {not-ext-object} )
%end
%end
%end
|