Hello,

I have a minor bug fix and enhancement patch for DBD::Pg 1.01. It
concerns the "table_info" method. First, the bug fix: When selecting
information about views, the syntax
"c.relkind = 'r'" is used when it should be: "c.relkind = 'v'"

It's documented here that 'r' is used for "regular" tables, while 'v' is
used for views:
http://www.postgresql.org/idocs/index.php?catalog-pg-class.html

Below is SQL code that both fixes the above issue and also adds in the missing
"remarks" field. This is accomplished by using a LEFT OUTER JOIN, which
I believe is a new feature in Postgres 7.1. This could be rewritten with
a UNION for better compatibility. 

            SELECT c.reltype, u.usename, c.relname, 'TABLE', pg_description.description
            FROM pg_user u, pg_class c
              LEFT OUTER JOIN pg_description ON (pg_description.objoid = c.oid)
            WHERE c.relkind = 'r'
            AND   c.relhasrules = FALSE
            AND   c.relname !~ '^pg_'
            AND   c.relname !~ '^xin[vx][0-9]+'
            AND   c.relowner = u.usesysid
            UNION
            SELECT c.reltype, u.usename, c.relname, 'VIEW', pg_description.description
            FROM pg_user u, pg_class c
              LEFT OUTER JOIN pg_description ON (pg_description.objoid = c.oid)
            WHERE c.relkind = 'v'
            AND   c.relhasrules = TRUE
            AND   c.relname !~ '^pg_'
            AND   c.relname !~ '^xin[vx][0-9]+'
            AND   c.relowner = u.usesysid
            ORDER BY 1, 2, 3


Thanks,

    -mark 
 . . . . . . . . . . . . . . . . . . . . . . . . . .
   Mark Stosberg              Principal Developer  
   [EMAIL PROTECTED]       Summersault, LLC     
   v: 765-939-9301 ext 223    website development  
 . . . . . http://www.summersault.com/ . . . . . . .

Reply via email to