SELECT tab.colname AS "Column",
       tab.coltype AS "Type",
       CASE WHEN tab.attnotnull THEN 'not null '
            ELSE CAST('' AS text)
       END ||
       CASE
         WHEN atthasdef THEN
           'default ' || 
           (SELECT substring(d.adsrc for 128)
              FROM pg_catalog.pg_attrdef d
             WHERE d.adrelid = tab.attrelid
               AND d.adnum = tab.attnum) || ' '
         ELSE CAST('' AS text)
       END AS "Modifiers"
  FROM ( SELECT CASE 
                  WHEN i.indproc IS NULL THEN a.attname
                  WHEN i.indproc = ('-'::pg_catalog.regproc) THEN a.attname
                  ELSE SUBSTR(pg_catalog.pg_get_indexdef(attrelid),
                              POSITION('(' IN pg_catalog.pg_get_indexdef(attrelid))) 
                END AS colname,
                pg_catalog.format_type(a.atttypid, a.atttypmod) as coltype,
                a.attnotnull,
                a.atthasdef,
                a.attnum,
                a.attrelid
           FROM pg_catalog.pg_attribute a
                LEFT OUTER JOIN pg_catalog.pg_index i ON (a.attrelid = i.indexrelid)
          WHERE a.attrelid = $2
                AND a.attnum > 0
                AND NOT a.attisdropped
       ORDER BY a.attnum
       ) as tab,
       (SELECT $1 AS cmd) AS cmd