function getTypes($all = false, $tabletypes = false, $domains = false)
{
if ($all) {
$where = '1 = 1';
} else {
$c_schema = $this->_schema;
$this->clean($c_schema);
$where = "n.nspname = '{$c_schema}'";
}
// Never show system table types
$where2 = "AND c.relnamespace NOT IN (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname LIKE 'pg@_%' ESCAPE '@')";
// Create type filter
$tqry = "'c'";
if ($tabletypes) {
$tqry .= ", 'r', 'v'";
}
// Create domain filter
if (!$domains) {
$where .= " AND t.typtype != 'd'";
}
$sql = "SELECT\n\t\t\t\tt.typname AS basename,\n\t\t\t\tpg_catalog.format_type(t.oid, NULL) AS typname,\n\t\t\t\tpu.usename AS typowner,\n\t\t\t\tt.typtype,\n\t\t\t\tpg_catalog.obj_description(t.oid, 'pg_type') AS typcomment\n\t\t\tFROM (pg_catalog.pg_type t\n\t\t\t\tLEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace)\n\t\t\t\tLEFT JOIN pg_catalog.pg_user pu ON t.typowner = pu.usesysid\n\t\t\tWHERE (t.typrelid = 0 OR (SELECT c.relkind IN ({$tqry}) FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid {$where2}))\n\t\t\tAND t.typname !~ '^_'\n\t\t\tAND {$where}\n\t\t\tORDER BY typname\n\t\t";
return $this->selectSet($sql);
}