21 COALESCE(condeferred,
'f') AS deferred,
22 COALESCE(condeferrable,
'f') AS deferrable,
23 CASE WHEN typname =
'int2' THEN
'smallint'
24 WHEN typname =
'int4' THEN
'integer'
25 WHEN typname =
'int8' THEN
'bigint'
26 WHEN typname =
'bpchar' THEN
'char'
27 ELSE typname END AS typname
29JOIN pg_namespace n ON (n.oid =
c.relnamespace)
30JOIN pg_attribute a ON (a.attrelid =
c.oid)
31JOIN pg_type t ON (t.oid = a.atttypid)
32LEFT JOIN pg_constraint o ON (o.conrelid =
c.oid AND a.attnum = ANY(o.conkey) AND o.contype =
'f')
33LEFT JOIN pg_attrdef d on
c.oid=d.adrelid and a.attnum=d.adnum
53 $n->
type = $row->typname;
54 $n->nullable = ( $row->attnotnull ==
'f' );
56 $n->tablename = $table;
57 $n->max_length = $row->attlen;
58 $n->deferrable = ( $row->deferrable ==
't' );
59 $n->deferred = ( $row->deferred ==
't' );
60 $n->conname = $row->conname;
61 $n->has_default = ( $row->atthasdef ===
't' );
62 $n->default = $row->adsrc;