30 pg_get_expr(adbin, adrelid) AS adsrc,
31 COALESCE(condeferred, FALSE) AS deferred,
32 COALESCE(condeferrable, FALSE) AS deferrable,
33 CASE WHEN typname =
'int2' THEN
'smallint'
34 WHEN typname =
'int4' THEN
'integer'
35 WHEN typname =
'int8' THEN
'bigint'
36 WHEN typname =
'bpchar' THEN
'char'
37 ELSE typname END AS typname
39JOIN pg_namespace n ON (n.oid = c.relnamespace)
40JOIN pg_attribute a ON (a.attrelid = c.oid)
41JOIN pg_type t ON (t.oid = a.atttypid)
42LEFT JOIN pg_constraint o ON (o.conrelid = c.oid AND a.attnum = ANY(o.conkey) AND o.contype =
'f')
43LEFT JOIN pg_attrdef d on c.oid=d.adrelid and a.attnum=d.adnum
59 $row = $res->fetchObject();
64 $n->
type = $row->typname;
65 $n->nullable = !$row->attnotnull;
67 $n->tablename = $table;
68 $n->max_length = $row->attlen;
69 $n->deferrable = (bool)$row->deferrable;
70 $n->deferred = (bool)$row->deferred;
71 $n->conname = $row->conname;
72 $n->has_default = (bool)$row->atthasdef;
73 $n->default = $row->adsrc;