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