Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id A6D0F6335C5 for ; Mon, 26 Oct 2009 20:42:12 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 63088-06 for ; Mon, 26 Oct 2009 23:41:55 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp.cal.net (smtp.cal.net [206.170.184.5]) by mail.postgresql.org (Postfix) with ESMTP id 236B063456E for ; Mon, 26 Oct 2009 20:41:54 -0300 (ADT) X-ASG-Debug-ID: 1256600509-21be02640000-hAWazd X-Barracuda-URL: http://206.170.184.5:8000/cgi-bin/mark.cgi Received: from [192.168.1.219] (statics-76-14-161-10.wsac.wavecable.com [76.14.161.10]) by smtp.cal.net (Spam & Virus Firewall) with ESMTP id 99DECB4FADD for ; Mon, 26 Oct 2009 16:41:49 -0700 (PDT) Received: from [192.168.1.219] (statics-76-14-161-10.wsac.wavecable.com [76.14.161.10]) by smtp.cal.net with ESMTP id 2kULz73n1QgT8y68 for ; Mon, 26 Oct 2009 16:41:49 -0700 (PDT) From: John To: pgsql-sql@postgresql.org X-ASG-Orig-Subj: trouble with getting the field names Subject: trouble with getting the field names Date: Mon, 26 Oct 2009 16:41:49 -0700 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200910261641.49211.jfabiani@yolo.com> X-Barracuda-Connect: statics-76-14-161-10.wsac.wavecable.com[76.14.161.10] X-Barracuda-Start-Time: 1256600509 X-Barracuda-Virus-Scanned: by Cal.net at cal.net X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=9.0 KILL_LEVEL=7.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.12932 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.958 tagged_above=-10 required=5 tests=AWL=-0.959, BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200910/128 X-Sequence-Number: 33327 Below is a SQL statement that was created to retreive the primary key , and column names and data types for a table name and a schema. The problem is that is works very well if I only use the 'public' schema. But it does not work if I use a 'system' schema I created (owned my me). The offending line is "AND pg_table_is_visible(c.oid)" which makes me believe I done something wrong with the roles? IOW if I drop the "pg_table_is_visible" it works with my 'system' schema. So I need a better guru than myself to help/tell me what I did wrong. Thanks in advance! SELECT a.attname, t.typname, EXISTS(SELECT * FROM generate_series(0, 31) idx(n) WHERE a.attnum = i.indkey[idx.n]) AS isprimary FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace JOIN pg_attribute a ON a.attrelid = c.oid JOIN pg_type t ON t.oid = a.atttypid LEFT JOIN pg_index i ON i.indrelid = c.oid AND i.indisprimary WHERE c.relname = 'sys_company' AND n.nspname = 'system' AND a.attname NOT IN ('ctid', 'cmin', 'cmax', 'tableoid', 'xmax', 'xmin') AND has_schema_privilege(n.oid, 'usage') AND has_table_privilege(c.oid, 'select') AND pg_table_is_visible(c.oid) ORDER BY c.relname, a.attname Johnf